<template>
    <div>
        <!-- 定制服务 -->
        <div style="margin:15px 30px 0 30px ;height: 50px;line-height: 50px;border-bottom: 1px solid #eaeaea;">
            <img src="@/assets/img/cooperationExchange/20200608_03.gif" alt=""
                 style="height: 20px;vertical-align: middle;">
            <span style="color: #3a6295;font-weight: 700;margin-left: 5px;">{{$t('common.CustomService')}}</span>
        </div>
        <div style="margin: 0 50px; margin-top: 20px;" class="continents">
            <div style="width: 100%;text-align: center;color: #32A0F5;font-size: 22px;line-height: 70px;">
                {{$t('common.GEIDCOProvides')}}{{$t('common.CustomService')}}
            </div>
            <ul>
                <li v-for="(item,index) in initData" :key="index">
                    <div style="position: relative;margin: 0 22px;" class="border">
                        <div style="width: 100%;text-align: center;padding-top: 30px;">
                            <div>
                                <img :src="getIconUrl(item.img)" alt="">
                            </div>
                            <div style="margin-top: 10px;font-weight: 700;color: #666;width: 100%;display: inline-block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
                                {{$t(item.lable)}}
                            </div>
                        </div>
                    </div>
                    <div style="margin-top: 10px;">

                        <div style="font-size: 14px;margin-top: 5px;line-height: 30px;" v-html="$t(item.value).replace(/[;；]/g,'$&\n')">
                           <!-- {{$t(item.value).replace(/[;；]/g,"$&\n")}}-->
                        </div>

                    </div>
                </li>
            </ul>
            <div style="width: 100%;position: relative;height: 100px;">
                <el-button type="primary" style="position: absolute; left:50%;top:0;transform: translate(-50%, 50%);"
                           @click="createOptions('1')">
                    {{$t('common.ApplicationServices')}}
                </el-button>
            </div>
        </div>
        <div style="width: 100%;height: 15px;background: #f5f5f7;"></div>

        <!-- 定制服务单位 -->
        <div style="background:rgba(250,251,252,1);width:100%;">
            <div style="margin:0px 30px 0 30px ;height: 50px;line-height: 50px;border-bottom: 1px solid #eaeaea;">
                <img src="@/assets/img/cooperationExchange/20200608_03.gif" alt=""
                     style="height: 20px;vertical-align: middle;">
                <span style="color: #3a6295;font-weight: 700;margin-left: 5px;">{{$t('common.CustomizedServicesUnit')}}</span>
                <span style="color: #3a6295;font-weight: 700;float: right;" class="cursor" @click="nextBatch">{{$t('common.NextBatch')}}</span>
            </div>
            <div style="margin: 0 20px; margin-top: 20px;" class="continents2">

                <ul>
                    <li v-for="(item,index) in collaboratorList" :key="index"
                        @click="toViewDetail('IntroductionCustomizationDetails',item)" style="margin-right: 5px;" class="LiActive cursor">
                        <div style="position: relative;margin: 0 22px;" class="border">
                            <div style="width: 100%;text-align: center;padding-top: 30px;">
                                <div style="border: 1px solid rgba(221,221,221, .5);height: 86px;">
                                    <img :src="'/api/file/pub/' + photoMap[item.unitId]" alt=""
                                         style="width: 100%;height: 100%;">
                                </div>
                                <div style="color: rgba(51,51,51,1);font-weight: 700;height:3em;display:flex;align-items:center;justify-content:center">
                                    <p style="line-height:1.5em;margin:0px">{{$i18n.locale === 'zh'?item.unitZhName:item.unitEnName}}</p>
                                </div>
                                <div v-if="$i18n.locale === 'zh'" class="introdcutiontxt">
                                    <p style="text-indent: 2em; -webkit-box-orient: vertical;
                                    position:relative;
                                    line-height:1.4em;
                                    overflow: hidden;
                                    height:5.6em;cursor: pointer; margin:0px" class="plate">
                                        {{item.unitIntroduction?item.unitIntroduction.replace(/<[^>]+>|&[^>]+;/g, ""):""}}</p>
                                </div>
                                <div v-if="$i18n.locale === 'en'" class="introdcutiontxt">
                                    <p>{{unitIntroductionMap[item.unitId]?unitIntroductionMap[item.unitId].replace(/<[^>]+>|&[^>]+;/g, ""):""}}</p>
                                </div>
                            </div>
                        </div>
                        <!-- <div style="margin-top: 10px;">

                        </div> -->
                    </li>
                </ul>

            </div>
        </div>
        <div style="width: 100%;height: 15px;background: #f5f5f7;"></div>

        <!-- 资助洽商 -->
        <div style="background:#fff;width:100%;">
            <div style="margin:0px 30px 0 30px ;height: 50px;line-height: 50px;border-bottom: 1px solid #eaeaea;">
                <img src="@/assets/img/cooperationExchange/20200608_03.gif" alt=""
                     style="height: 20px;vertical-align: middle;">
                <span style="color: #3a6295;font-weight: 700;margin-left: 5px;">{{$t('common.Donation')}}</span>
            </div>
            <div style="margin: 0 20px; margin-top: 20px;height: 250px;">
                <img src="@/assets/img/introductionCooperation/financialsSuppot.gif" alt=""
                     style="width: 264px;height: 196px;vertical-align: top;float: left;">
                <span style="font-size:14px; color:rgba(51,51,51,1); line-height:28px;float: left;width: 800px;margin: 20px 40px 0 40px;">
                    {{$t('common.IntroductionToFundingNegotiations')}}
                </span>
                <div style="width: 800px;margin: 20px;float: left;">
                    <div style="margin: auto;width: 126px;">
                        <el-button type="primary" @click='createOptions("2")'>
                            {{$t('common.Donation')}}
                        </el-button>
                    </div>
                </div>
            </div>
        </div>

        <!-- 定制服务申请 -->
        <el-dialog
                class="dialogVisible"
                :title="$t('common.CustomizedService')"
                :visible.sync="dialogVisible"
                width="35%">
            <div style="width: 100%;">
                <el-form ref="coopCustomService" :model="coopCustomService" :rules="rules" :label-width="$i18n.locale=='zh'?'100px':'160px'"
                         style="margin: auto;width: 80%;">
                    <el-form-item :label="$t(labels.applyUserName)" prop="applyUserName">
                        <el-input v-model="coopCustomService.applyUserName"
                                  :placeholder="$t('common.PleaseEnter')+$t('common.fullName')"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t(labels.unitZhName)" prop="unitId" class="Unitname">
                        <el-select v-model="coopCustomService.unitId" :placeholder="$t('common.enteUnitName')"
                                   filterable style="width: 100%;" ref="applySelect1"
                                   :no-match-text="$i18n.locale=='zh'?'无匹配数据':'No Data'"
                                   allow-create
                                   popper-class="mySelect"
                                   default-first-option>
                            <el-option
                                    class="dialogVisibleOptions"
                                    v-for="item in baseUnitViews"
                                    :key="item.unitName"
                                    :label="item.unitName"
                                    :value="item.baseEntityId">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item :label="$t(labels.ApplicationType)" prop="childTypeDict">
                        <el-select v-model="coopCustomService.childTypeDict" :placeholder="$t('common.ServiceType')"
                                   :no-match-text="$i18n.locale=='zh'?'无匹配数据':'No Data'"
                                   filterable
                                   style="width: 100%;" ref="applySelect2">
                            <el-option
                                    v-for="item in typeDialog1"
                                    :key="item.value"
                                    :label="$t(item.label)"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item :label="$t(labels.linkNumber)" prop="linkNumber" :label-width="$i18n.locale === 'zh'?'':'160px'">
                        <el-input v-model="coopCustomService.linkNumber"
                                  :placeholder="$t('common.Contactinformation')"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t(labels.linkEmail)" prop="linkEmail" >
                        <el-input v-model="coopCustomService.linkEmail" :placeholder="$t('common.ContactinformationEmail')"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t(labels.ApplicationContent)" prop="applyContent" >
                        <el-input v-model="coopCustomService.applyContent" type="textarea" maxlength="500"
                                  show-word-limit :placeholder="$t('common.Details')">
                        </el-input>
                    </el-form-item>
                    <el-form-item :label="$t(labels.AttachmentUpload)">
                        <el-upload
                                class="upload-demo"
                                action="./api/file/upload/attachment?module=CoopCustomServiceForm"
                                :on-change="handleChange"
                                :on-success="docSuccess"
                                :headers="myHeaders"
                                :before-upload="beforeUpload"
                                :file-list="fileList">
                            <el-button size="small" type="primary"> {{$t('common.SelectUploadCUnit')}}</el-button>
                            <div slot="tip" class="el-upload__tip">{{$t('common.OnlyUpload')}}</div>
                        </el-upload>
                    </el-form-item>

                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisible = false" type="info">{{$t('common.Cancel')}}</el-button>
              <el-button v-if="!disable" type="primary"
                         @click="customServiceAppForm('form1')">{{$t('common.Submit')}}</el-button>
          </span>
        </el-dialog>

        <!-- 资助洽商弹框 -->
        <el-dialog
                class="dialogVisible"
                :title="$t('common.Donation')"
                :visible.sync="dialogVisible2"
                width="35%">
            <div style="width: 100%;">
                <el-form ref="coopCustomService" :model="coopCustomService" :rules="rules2" :label-width="$i18n.locale=='zh'?'100px':'150px'"
                         style="width: 80%;margin: auto;">
                    <el-form-item :label="$t(labels.applyUserName)" prop="applyUserName">
                        <el-input v-model="coopCustomService.applyUserName"
                                  :placeholder="$t('common.PleaseEnter')+$t('common.fullName')"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t(labels.unitZhName)" prop="unitId" class="Unitname">
                        <el-select v-model="coopCustomService.unitId" :placeholder="$t('common.enteUnitName')"
                                   filterable style="width: 100%;" ref="supportSelect1" 
                                   :no-match-text="$i18n.locale=='zh'?'无匹配数据':'No Data'" 
                                   allow-create
                                   popper-class="mySelect"
                                   default-first-option>
                            <el-option
                                    class="dialogVisibleOptions"
                                  
                                    v-for="item in baseUnitViews"
                                    :key="item.unitName"
                                    :label="item.unitName"
                                    :value="item.baseEntityId">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item :label="$t(labels.linkNumber)" prop="linkNumber">
                        <el-input v-model="coopCustomService.linkNumber"
                                  :placeholder="$t('common.Contactinformation')"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t(labels.linkEmail)" prop="linkEmail">
                        <el-input v-model="coopCustomService.linkEmail" :placeholder="$t('common.Email')"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t(labels.supportWay)" prop="supportWayDict" style="" >
                        <el-select v-model="coopCustomService.supportWayDict"
                                   :placeholder="$t('common.SelectFundingMethods')"
                                   :no-match-text="$i18n.locale=='zh'?'无匹配数据':'No Data'"
                                    filterable
                                   style="width: 100%;" ref="supportSelect2">
                            <el-option
                                    v-for="item in typeDialog2"
                                    :key="item.value"
                                    :label="$t(item.label)"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>


                    <el-form-item :label="$t(labels.supportContent)" prop="applyContent">
                        <el-input v-model="coopCustomService.applyContent" type="textarea" maxlength="500"
                                  show-word-limit :placeholder="$t(labels.FundingDetails)">
                        </el-input>
                    </el-form-item>
                    <el-form-item :label="$t(labels.AttachmentUpload)">
                        <el-upload
                                class="upload-demo"
                                action="./api/file/upload/attachment?module=CoopCustomServiceForm"
                                :on-change="handleChange"
                                :on-success="docSuccess"
                                :headers="myHeaders"
                                :before-upload="beforeUpload"
                                :file-list="fileList">
                            <el-button size="small" type="primary">{{$t('common.SelectUploadCUnit')}}</el-button>
                            <div slot="tip" class="el-upload__tip">{{$t('common.OnlyUpload')}}</div>
                        </el-upload>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible2 = false">{{$t('common.Cancel')}}</el-button>
            <el-button v-if="!disable" type="primary"
                       @click="customServiceAppForm('form2')">{{$t('common.Submit')}}</el-button>
        </span>
        </el-dialog>

        <!-- 登录验证 -->
        <el-dialog
                :title="$i18n.locale=='zh'?'提示':'Reminder'"
                :visible.sync="toViewLogin"
                :width="$i18n.locale=='zh'?'500px':'750px'"
                :height="$i18n.locale=='zh'?'300px':'386px'"
                :before-close="toViewLoginChange"
        >
            <div style="width: 100%;height: 100%;">
                <img src="@/assets/img/loginTips.png" alt="" style="width: 180px;height: 180px;margin-left: 20px;">
                <div style="float: right;margin-right: 20px;"
                     :style="$i18n.locale=='zh'?'width: 49%;margin-top: 10px;':'width: 453px;margin-top: -25px;'">
                    <div style="font-size: 20px;font-weight: normal;color: #333333;
                font-family: HiraginoSansGB-W3, HiraginoSansGB;
                line-height: 40px;">
                        {{$t('common.ReminderFirst')}}
                    </div>
                    <div style="font-size: 16px;font-family: HiraginoSansGB-W3, HiraginoSansGB;
              font-weight: normal;color: #666666;line-height: 30px;">
                        {{$t('common.ReminderSecond')}} <span style="color: #0091FF;font-size: 18px;">{{num}}</span>
                        {{$t('common.ReminderThird')}}
                    </div>
                    <div style="font-size: 14px;font-family: HiraginoSansGB-W3, HiraginoSansGB;
              font-weight: normal;color: #666666;line-height: 30px;">
                        {{$t('common.ReminderForth')}}
                    </div>
                    <div style="font-size: 14px;font-family: HiraginoSansGB-W3, HiraginoSansGB;
              height:33px;line-height:60px;font-weight: normal;color: #0091FF;">
                <span style="margin-left: 40px;" class="cursor" @click="toView('login')">
                  {{$t('common.ReminderFifth')}}
                </span>
                        <span style="margin-left: 10px;" class="cursor" @click="toView('Register')">
                  {{$t('common.ReminderSixth')}}
                </span>
                    </div>
                </div>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import {getToken} from '@/utils/auth';
    import {getDicts} from '@/api/dict'
    import {getUserInfoById} from '@/api/user';
    import Base from "@/views/base/Base"
    import {
        getCoopCustomServices,
        get,
        saveOrUpdate,
        del,
        getByUnitId,
        downloadCoopCustom,
        getBaseUnitViews,
        getFiles
    } from '@/api/cooperation/coopCustomService'
    import {getViewByIds} from "@/api/baseUnitView";

    export default {
        name: 'IntroductionCustomService',
        extends: Base,
        data() {
            return {
                serviceTypeDicts: [],
                childTypeDicts: [],
                supportWayDicts: [],
                page: {
                    pageNo: 1,
                    pageSize: 8,
                },
                typeDialog0: [],
                typeDialog1: [],
                typeDialog2: [],
                baseUnitViews: [],
                toViewLogin: false,
                num: 0,
                timer: '',

                // 两个form的label
                labels: {
                    applyUserName: 'common.applyUserName',
                    unitZhName: 'common.unitName',
                    ApplicationType: 'common.ApplicationType',
                    linkNumber: 'common.linkNumber',
                    linkEmail: 'common.linkEmail',
                    ApplicationContent: 'common.ApplicationContent',
                    AttachmentUpload: 'common.AttachmentUpload',
                    supportWay: 'common.supportWay',
                    supportContent: 'common.supportContent',
                },
                photoMap:{},
                unitIntroductionMap: {},
                baseEnterpriseMap: {},
                coopCustomService: {
                    id: null,
                    manual:true,
                    unitId: '',
                    unitZhName: '',
                    unitEnName: '',
                    serviceType: '',
                    serviceTypeDict: '',
                    childType: '',
                    childTypeDict: '',
                    supportWay: '',
                    supportWayDict: '',
                    applyUserName: '',
                    linkNumber: '',
                    linkEmail: '',
                    userType: '1',
                    unitIntroduction: '',
                    applyContent: '',
                    applyDate: '',
                    subName: '',
                    subAccount: '',
                    subCompany: '',
                    subMail: '',
                    subPhone: '',
                    language: this.$i18n.locale,
                    status: '',
                    statusDict: '',
                    createBy: '',
                    createDate: '',
                    updateBy: '',
                    updateDate: '',
                },
                attachmentIds: [],
                baseEntityIds: '',
                dataSource: 'gate',
                myHeaders: {Authorization: ('Bearer ' + getToken())},
                dialogVisible: false,
                dialogVisible2: false,
                disable: false,
                enterpriseDetails: '',
                initData: [{
                    lable: 'common.ExclusiveProjects',
                    img: 'exclusive.png',
                    value: 'common.IntroductionToExclusiveProjects'
                }, {
                    lable: 'common.ThematicResearch',
                    img: 'research_.png',
                    value: 'common.IntroductionToExclusiveResearch'
                }, {
                    lable: 'common.TailoredService',
                    img: 'personalized.png',
                    value: 'common.IntroductionToPersonalizedService'
                }, {
                    lable: 'common.CustomizedInformation',
                    img: 'customized.png',
                    value: 'common.CustomizedInformationIntroduction'
                }, {
                    lable: 'common.JointConference',
                    img: 'organization.png',
                    value: 'common.IntroductionToTheJointMeeting'
                }],
                collaboratorList: [],
                fileList: []
            }
        },
        created() {
            //url承接
            if(this.$route.query.dialogVisible) {
                this.dialogVisible = this.$route.query.dialogVisible;
            }
            if(this.$route.query.dialogVisible2) {
                this.dialogVisible2 = this.$route.query.dialogVisible2;
            }
        },
        filter:{
            // filterUnitId(val){
            //     if(val){
            //         return val
            //     }else {
            //         if(this.$i18n.locale=='zh'){
            //             return this.coopCustomService.unitZhName;
            //         }else {
            //             return this.coopCustomService.unitEnName;
            //         }
            //
            //     }
            //
            // }
        },
        watch: {

            '$i18n.locale'() {
                this.init();
                this.setLang();
                this.getProjectViews();
                this.customServiceAppForm();
            },
            "toViewLogin"() {
                if (this.toViewLogin === true) {

                    this.loginTipsChange()
                }
            },
            'dialogVisible'() {
                if (this.$route.query.data && this.dialogVisible === false) {
                    this.$router.push({name: 'myConcerns', params: {index: this.$route.query.index}})
                }
            },
            'dialogVisible2'() {
                if (this.$route.query.data && this.dialogVisible2 === false) {
                    this.$router.push({name: 'myConcerns', params: {index: this.$route.query.index}})
                }
            }


        },
        mounted() {
            if (this.$route.query && this.$route.query.data) {
                this.coopCustomService = this.$route.query.data;
                this.coopCustomService.applyContent = this.coopCustomService.applyContent.replace(/<[^>]+>|&[^>]+;/g, "");
                let param = {
                    attachmentBusinessId: this.coopCustomService.id,
                    attachmentBusinessType: 'COOP_CUSTOM_SERVICE'
                };
                getFiles(param).then(result => {
                    const data = result.data
                    if (data) {
                        this.fileList = data.attachmentInfos
                        this.fileList.forEach(item => {
                            item.name = item.attachmentName;
                            item.url = item.attachmentSavePath;
                        })
                    }
                })
                if (this.coopCustomService.serviceTypeDict === '1') {
                    this.dialogVisible = true
                } else {
                    this.dialogVisible2 = true
                }
            }
            ;
            if (this.$route.query.disable) {
                this.disable = this.$route.query.disable
            }
            this.init();
            this.setLang();
            this.getProjectViews();
        },
        methods: {
            beforeUpload(file) {
                var FileExt = file.name.replace(/.+\./, "");
                if (['zip', 'pdf', 'doc', 'docx', 'excel', 'xls', 'xlsx'].indexOf(FileExt.toLowerCase()) === -1) {
                    this.$message({
                        type: 'warning',
                        message: '请上传zip,pdf,word,excel的附件！'
                    });
                    this.fileList.splice(this.fileList.indexOf(file), 1)
                    return false;
                }
                this.isLt2k = file.size / 1024 / 1024 < 2 ? '1' : '0';
                if (this.isLt2k === '0') {
                    this.$message({
                        message: '上传文件大小不能超过2M!',
                        type: 'error'
                    });
                    this.fileList.splice(this.fileList.indexOf(file), 1)
                    return false;
                }
            },
            getProjectViews() {
                let currentlang = this.$i18n.locale == 'zh' ? 'ZH' : 'EN'
                getBaseUnitViews(currentlang).then(res => {
                    if (res.data) {
                        this.baseUnitViews = res.data.baseUnitViewList
                        this.baseEnterpriseMap = res.data.baseUnitViewMap
                        let baseUnitView = {
                            baseEntityId : '',
                            unitName : '',
                        }
                        if(this.coopCustomService.unitZhName != '' && this.coopCustomService.unitId==''){
                            baseUnitView.baseEntityId = '';
                            baseUnitView.unitName = this.coopCustomService.unitZhName;
                            this.baseUnitViews.unshift(baseUnitView);
                        }
                        let baseUnitView1 = {
                            baseEntityId : '',
                            unitName : '',
                        }
                        if(this.coopCustomService.unitEnName != '' && this.coopCustomService.unitId==''){
                            baseUnitView1.baseEntityId = '';
                            baseUnitView1.unitName = this.coopCustomService.unitEnName;
                            this.baseUnitViews.unshift(baseUnitView1);
                        }
                    }
                })
            },
            init() {
                this.page.pageNo = 1
                if (this.$i18n.locale === 'zh') {
                    getDicts('SERVICE_TYPE_DICT,SERVICE_CHILD_TYPE_DICT,STATUS_DICT,SUPPORT_WAY_DICT').then(result => {
                        var data = result.data
                        if (data) {
                            this.serviceTypeDicts = result.data['0'] || []
                            this.typeDialog1 = result.data['1'] || []
                            this.statusDicts = result.data['序号'] || []
                            this.typeDialog2 = result.data['3'] || []
                        }
                    })
                } else {
                    getDicts('SERVICE_TYPE_DICT_EN,SERVICE_CHILD_TYPE_DICT_EN,STATUS_DICT,SUPPORT_WAY_DICT_EN').then(result => {
                        var data = result.data
                        if (data) {
                            this.serviceTypeDicts = result.data['0'] || []
                            this.typeDialog1 = result.data['1'] || []
                            this.statusDicts = result.data['序号'] || []
                            this.typeDialog2 = result.data['3'] || []
                        }
                    })
                }

            },
            setLang() {
                let param = {
                    serviceTypeDict: '1',
                    pageSize: 8,
                    pageNo: this.page.pageNo,
                    statusDict: '3'
                }
                const that = this;
                getCoopCustomServices(param).then((res) => {
                    const data = res.data;
                    if (data) {
                        that.collaboratorList = [];
                        that.collaboratorList = data.coopCustomServices;
                        that.photoMap = data.photoMap
                        that.collaboratorList.forEach(item =>{
                            if(that.photoMap[item.unitId]===''){
                                that.photoMap[item.unitId] = 'def/enterpriseDefault.png';
                            }
                        });
                        that.unitIntroductionMap = data.unitIntroductionMap
                        that.page = data.page
                        // let ids = []
                        // if (this.collaboratorList.length > 0) {
                        //     this.collaboratorList.forEach(item => {
                        //         ids.push(item.unitId)
                        //     })
                        //     that.baseEntityIds = ids.join(',')
                        //     let currentlang = that.$i18n.locale == 'zh' ? 'ZH' : 'EN'
                        //     // const that = this
                        //     // getViewByIds(that.baseEntityIds, currentlang).then((res) => {
                        //     //     var datas = res.data
                        //     //     if (datas) {
                        //     //         that.typeDialog0 = res.data;
                        //     //         that.typeDialog0.forEach(item => {
                        //     //             item.photo = item.photo !== undefined ? item.photo : 'def/enterpriseDefault.png';
                        //     //             item.unitIntrodution = item.unitIntrodution !== undefined ? item.unitIntrodution.replace(/<[^>]+>|&[^>]+;/g, "") : ''
                        //     //             that.photoMap.set(item.baseEntityId, item.photo);
                        //     //             if (that.$i18n.locale === 'en') {
                        //     //                 that.unitIntroductionMap.set(item.baseEntityId, item.unitIntrodution);
                        //     //             }
                        //     //         })
                        //     //     }
                        //     // })
                        // }
                    }
                }).catch((error) => {
                })
            },
            loginTipsChange() {
                const that = this;
                this.num = 5;
                // clearInterval(timer_interval);

                this.timer = setInterval(function () {
                    if (that.num > 0) {
                        that.num--;
                    } else {
                        if (that.toViewLogin == true) {
                            clearInterval(that.timer);
                            that.toView('login');
                        } else {
                            clearInterval(that.timer);
                        }
                    }
                }, 1000)
            },
            toViewLoginChange(done) {
                this.toViewLogin = false;
                this.num = 5;
                clearInterval(this.timer);
            },
            goToView(index) {
                this.toView('IntroductionEquipmentAlliance', index)
            },
            getIconUrl(url) {
                return require("@/assets/img/introductionCooperation/exclusive/" + url);
            },
            toView(router, json) {
                clearInterval(this.timer);
                this.$router.push({
                    name: router,
                    query: {
                        id: json
                    },

                });
            },
            toViewDetail(router, json) {
                this.$store.commit('modify', router);
                window.localStorage.setItem('router', router);
                const {href} = this.$router.resolve({
                    name: router,
                    query: {
                        key: json.id,
                    }
                });
                window.open(href, '_blank');
            },
            screenBack(data) {
            },
            handleChange(file, fileList) {
                this.fileList = fileList.slice(-3);
            },
            docSuccess(res, file) {
                if (res.data) {
                    this.attachmentIds.push(res.data.attachmentId)
                }

            },
            createOptions(formIndex) {
                if (!this.$Cookies.get('token')) {
                    this.toViewLogin = true;
                } else {
                    formIndex == '1' ? this.dialogVisible = true : this.dialogVisible2 = true
                    this.setLang()
                }

            },
            customServiceAppForm(num) {
                let user = JSON.parse(window.localStorage.getItem('user'));
                if (num == 'form1') {
                    // 定制服务
                    this.$refs["coopCustomService"].validate((valid1) => {
                        if (valid1) {
                            if(this.baseEnterpriseMap[this.coopCustomService.unitId]){
                                let item = this.baseEnterpriseMap[this.coopCustomService.unitId];
                                if (this.$i18n.locale === 'zh') {
                                    this.coopCustomService.unitZhName = item.unitName
                                    this.coopCustomService.serviceType = '定制服务';
                                } else {
                                    this.coopCustomService.unitEnName = item.unitName
                                    this.coopCustomService.serviceType = 'CustomService';
                                }
                            }else{
                                if (this.$i18n.locale === 'zh') {
                                    this.coopCustomService.unitZhName = this.coopCustomService.unitId;
                                    this.coopCustomService.serviceType = '定制服务';
                                } else {
                                    this.coopCustomService.unitEnName = this.coopCustomService.unitId;
                                    this.coopCustomService.serviceType = 'CustomService';
                                }
                                this.coopCustomService.unitId = "";
                            }
                            this.coopCustomService.serviceTypeDict = '1';
                            this.coopCustomService.statusDict = '1'
                            this.coopCustomService.updateBy = user.userId;
                            this.coopCustomService.createBy = user.userId
                            this.coopCustomService.subName = user.realName;
                            this.coopCustomService.subAccount = user.umsUser.userUid;
                            this.coopCustomService.subPhone = user.umsUser.userPreferredMobile;
                            this.coopCustomService.subCompany = user.umsUser.unitEntityId;
                            this.typeDialog1.forEach(item => {
                                if (item.value === this.coopCustomService.childTypeDict) {
                                    this.coopCustomService.childType = item.label
                                }
                            });
                            this.submitHandler((token) => {
                                saveOrUpdate(JSON.stringify(this.coopCustomService), JSON.stringify(this.attachmentIds), null, this.dataSource, token).then(res => {
                                    this.$message({
                                        message: this.$i18n.locale.toUpperCase()=="ZH"?'保存成功':'submit success',
                                        type: 'success'
                                    });
                                    this.dialogVisible = false
                                    this.resetToken();
                                    this.coopCustomService = {};
                                    this.fileList = []
                                }).catch((error) => {
                                    this.$notify.error({
                                        title:  this.$t('common.Error'),
                                        message: error.msg
                                    });
                                })
                            })

                        } else {
                            this.$notify.error({
                                title: this.$t('common.Error'),
                                message: this.$t('common.PleaseSinformation')
                            });
                            return false;
                        }
                    });
                } else {
                    this.$refs["coopCustomService"].validate((valid1) => {
                        if (valid1) {
                            if(this.baseEnterpriseMap[this.coopCustomService.unitId]){
                                let item = this.baseEnterpriseMap[this.coopCustomService.unitId];
                                if (this.$i18n.locale === 'zh') {
                                    this.coopCustomService.unitZhName = item.unitName
                                    this.coopCustomService.serviceType = '资助洽商';
                                } else {
                                    this.coopCustomService.unitEnName = item.unitName;
                                    this.coopCustomService.serviceType = 'FundingNegotiation';
                                }
                            }else{
                                if (this.$i18n.locale === 'zh') {
                                    this.coopCustomService.unitZhName = this.coopCustomService.unitId;
                                    this.coopCustomService.serviceType = '资助洽商';
                                } else {
                                    this.coopCustomService.unitEnName = this.coopCustomService.unitId;
                                    this.coopCustomService.serviceType = 'FundingNegotiation';
                                }
                                this.coopCustomService.unitId = "";
                            }
                            this.coopCustomService.serviceTypeDict = '2';
                            this.coopCustomService.statusDict = '1'
                            this.coopCustomService.updateBy = user.userId;
                            this.coopCustomService.createBy = user.userId;
                            this.coopCustomService.subName = user.realName;
                            this.coopCustomService.subAccount = user.umsUser.userUid;
                            this.coopCustomService.subPhone = user.umsUser.userPreferredMobile;
                            this.coopCustomService.subCompany = user.umsUser.unitEntityId;
                            this.typeDialog2.forEach(item => {
                                if (item.value === this.coopCustomService.supportWayDict) {
                                    this.coopCustomService.supportWay = item.label
                                }
                            });
                            this.submitHandler((token) => {
                                saveOrUpdate(JSON.stringify(this.coopCustomService), JSON.stringify(this.attachmentIds), null, this.dataSource, token).then(res => {
                                    this.$message({
                                        message: this.$i18n.locale.toUpperCase()=="ZH"?'保存成功':'submit success',
                                        type: 'success'
                                    });
                                    this.dialogVisible2 = false;
                                    this.resetToken();
                                    this.coopCustomService = {};
                                    this.fileList = []
                                }).catch((error) => {
                                    this.$notify.error({
                                        title: 'common.Error',
                                        message: error.msg
                                    });
                                })
                            })
                        } else {
                            this.$notify.error({
                                title: this.$t('common.Error'),
                                message: this.$t('common.PleaseneInformation') 
                            });
                            return false;
                        }
                    });
                }
            },
            nextBatch() {
                if (this.page.pageNo * 8 > (this.page.totalCount - 0)) {
                    this.page.pageNo = 1
                    this.setLang()
                    return
                } else {
                    this.page.pageNo++
                    this.setLang()
                }
            }
        },
        computed: {
            content() {
                return function (str) {
                    return str.replace(/<[^>]+>/g, "")
                }
            },
              // 定制服务验证
            rules(){
                return{
                    unitId: [
                        {required: true, message:this.$t('common.PleaseEnter')+this.$t('common.NameoftheEntity'), trigger: 'change'},
                    ],
                    childTypeDict: [
                            {required: true, message:this.$t('common.PleaseSelect')+this.$t('common.Applicationtype'), trigger: 'change'},
                    ],
                    applyUserName: [
                        {required: true, message: this.$t('common.PleaseEnter')+this.$t('common.fullName'), trigger: 'blur'},
                        {max: 40, message:this.$t('common.CharacterTooLong'), trigger: 'blur'}
                    ],
                    linkNumber: [
                        {required: true, message:this.$t('common.PleaseFillOut')+this.$t('common.ContactWay'), trigger: 'blur'},
                        {
                            pattern: /^0{0,1}(13[0-9]|15[7-9]|153|151|156|18[1-9])[0-9]{8}$/,
                            message: this.$i18n.locale=='zh'? '联系方式格式不正确，请重新输入': 'Contact number format is incorrect, please re-enter',
                            trigger: 'blur'
                        }
                    ],
                    linkEmail: [
                        {required: true, message:this.$t('common.PleaseFillOut')+this.$t('common.Email'), trigger: 'blur'},
                        {
                            pattern: /^[a-zA-Z0-9]+([-_.][a-zA-Z0-9]+)*@[a-zA-Z0-9]+([-_.][a-zA-Z0-9]+)*\.[a-z]{2,}$/,
                            message: this.$i18n.locale=='zh'? '邮箱格式不正确，请重新输入': 'Email format is incorrect, please re-enter',
                            trigger: 'blur'
                        }
                    ],
                    applyContent: [
                        {required: true, message: this.$t('common.PleaseFillOut')+this.$t('common.ApplyContent'), trigger: 'blur'},
                    ],
                }
            },
            // 资助申请验证

            rules2(){
                return {
                        unitId: [
                        {required: true, message:this.$t('common.PleaseEnter')+this.$t('common.NameoftheEntity'), trigger: 'change'},
                    ],
                    supportWayDict: [
                        {required: true, message:this.$t('common.PleaseSelect')+this.$t('common.Applicationtype'), trigger: 'change'},
                    ],
                    applyUserName: [
                        {required: true, message: this.$t('common.PleaseEnter')+this.$t('common.fullName'), trigger: 'blur'},
                        {max: 40, message: this.$t('common.CharacterTooLong'), trigger: 'blur'}
                    ],
                    linkNumber: [
                        {required: true, message:this.$t('common.PleaseFillOut')+this.$t('common.ContactWay'), trigger: 'blur'},
                        {max: 40, message: this.$t('common.CharacterTooLong'), trigger: 'blur'}
                    ],
                    linkEmail: [
                        {required: true, message:this.$t('common.PleaseFillOut')+this.$t('common.Email'), trigger: 'blur'},
                        {
                            pattern: /^[a-zA-Z0-9]+([-_.][a-zA-Z0-9]+)*@[a-zA-Z0-9]+([-_.][a-zA-Z0-9]+)*\.[a-z]{2,}$/,
                            message:this.$t('common.Emailformatisnotcorrect'),
                            trigger: 'blur'
                        }
                    ],
                    applyContent: [
                        {required: true, message:this.$t('common.PleaseFillOut')+this.$t('common.FinanceContent'), trigger: 'blur'},
                    ],
                }
            }
        
        },
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
    .box {
        margin-top: 10px;
        background: #fff;
        /* height: 500px; */
        padding: 20px 0;
        font-family: HiraginoSansGB-W3, HiraginoSansGB;
    }

    .crumbs {
        margin-left: 20px;
    }

    body {
        margin: 0;
    }

    .continents ul,
    .continents2 ul {
        display: flex;
        flex-wrap: wrap;
        text-align: center;

    }

    .continents ul {
        text-align: left;

    }

    .continents ul li {
        width: 199px;
        padding: 0 10px;
        background: #fff;
        color: #999;
        /* height: 384px; */
        border-right: 1px solid #EAEAEA;
    }

    .continents2 ul li {
        width: 210px;
        padding: 18px 30px;
        background: #fff;
        margin-bottom: 20px;
        color: #999;
        /* height: 384px; */
        /* border-right: 1px solid #EAEAEA; */
        border: 3px solid transparent;
        box-shadow: 5px 5px 5px #fafafa;
    }
    .dialogVisibleOptions  {
        max-width: 380px;
        display: block;
        overflow: hidden;white-space: nowrap;text-overflow: ellipsis;
    }
    .continents ul li:nth-of-type(5) {
        border-right: none;
    }

    .LiActive:hover {
        border: 3px solid #ececec;
    }

    .continents2 ul li:nth-of-type(5) {
        border-right: none;
    }

    /* .continents ul li:nth-of-type(1) .border{
      border-bottom: 2px solid #07a9fc;
    }
    .continents ul li:nth-of-type(2) .border{
      border-bottom: 2px solid #f7b500;
    }
    .continents ul li:nth-of-type(3) .border{
      border-bottom: 2px solid #6dd400;
    }
    .continents ul li:nth-of-type(4) .border{
      border-bottom: 2px solid #43d7b5;
    } */
    .continents ul li .button {
        position: absolute;
        left: 50%;
        bottom: 0;
        transform: translate(-50%, 0);
        width: 100px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        border: 1px solid #bcbcbc;
        font-size: 14px;
        border-radius: 5px;
        box-shadow: 5px 5px 5px #f1f1f1;
    }

    .dialogVisible >>> .el-dialog__header {
        border-bottom: 1px solid #bcbcbc;
        margin-left: 20px;
        margin-right: 20px;
        padding: 20px 0 20px;
    }

    .dialogVisible >>> .el-dialog__headerbtn {
        display: none;
    }

    .dialogVisible >>> .el-dialog__footer {
        text-align: center;
    }

    /* .el-form-item__label{
        width: 150px;
    } */
    .introdcutiontxt {
        font-size: 14px;
        line-height: 20px;
        width: 12em;
        height: 8em;
        -webkit-box-orient: vertical;
        position:relative;
        line-height:1.4em;
        overflow: hidden;
        height:4.2em;
        margin-top: 10px;
    }
    .el-form-item {
        margin-bottom: 26px;
    }

</style>
