<template>
    <div class="car_add visit-box">
        <div>
            <div class="communal-title">
                <div>{{ title }}</div>
            </div>
            <div class="ps-title">
                <span>PS:"请规范录入，未规范录入，造成公司损失或影响提成计算，需承担责任"</span>
                <!-- 客户名单 -->
                <el-popover placement="bottom" width="662" trigger="hover">
                    <el-table max-height="600" border :data="rollcallarr">
                        <el-table-column width="100" property="date" label="姓名">
                            <template slot-scope="scope">
                                {{ scope.row.lastName }}{{ scope.row.firstName }}
                            </template>
                        </el-table-column>
                        <el-table-column width="200" property="lastName" label="拼音">
                            <template slot-scope="scope">
                                {{ pinyingxing(scope.row.lastName) }}/{{ pinyingxing(scope.row.firstName) }}
                            </template>
                        </el-table-column>
                        <el-table-column width="50" property="sex" label="性别">
                            <template slot-scope="scope">
                                {{ scope.row.sex == 0 ? '男' : '女' }}
                            </template>
                        </el-table-column>
                        <el-table-column width="110" property="birthDay" label="生日">
                            <template slot-scope="scope">
                                {{ fgarr(scope.row.birthDay) }}
                            </template>
                        </el-table-column>
                        <el-table-column width="200" property="idCardNo" label="身份证号码">
                            <template slot-scope="scope">
                                {{ scope.row.idCardNo }}
                            </template>
                        </el-table-column>
                    </el-table>
                    <span slot="reference" style="cursor: pointer;margin-left: 20px;">"移上查看客户名单"</span>
                </el-popover>
            </div>
        </div>
        <hr style='background-color:#5555; height:1px; border:none;margin: 8px 0;' />
        <div>
            <el-form :model="delegationInfo" label-width="100px" class="demo-ruleForm">
                <div style="display: flex;flex-wrap: wrap;">
                    <div style="width: 385px;">
                        <el-form-item label="团组名称:" label-width="160px">
                            <el-select v-model="DiId" clearable filterable placeholder="团组选择" @change="DiIdChang"
                                :disabled="isShow">
                                <el-option v-for="item in delegationInfoList" :key="item.id" :label="item.teamName"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div style="width: 385px;">
                        <el-form-item label="团 号:" prop="tourCode" label-width="160px">
                            <el-input placeholder="团号" v-model="delegationInfo.tourCode" :disabled="true">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div style="width: 385px;">
                        <el-form-item label="客户:" prop="clientName" label-width="160px">
                            <el-input placeholder="客户" v-model="delegationInfo.clientName" :disabled="true">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div style="width: 385px;">
                        <el-form-item label="出访国家:" prop="visitCountry" label-width="160px">
                            <el-input placeholder="出访国家" v-model="delegationInfo.visitCountry" :disabled="true">
                            </el-input>
                        </el-form-item>
                    </div>
                </div>
            </el-form>
            <el-form :model="OpOfficialActivitiesDto" ref="OpOfficialActivitiesDto" :rules="OpOfficialActivitiesRules"
                label-width="100px" class="demo-ruleForm">
                <div style="display: flex;flex-wrap: wrap;">
                    <div style="width: 385px;">
                        <el-form-item label="公务形式:" prop="officialForm" label-width="160px">
                            <el-select @change="Officchange" v-model="OpOfficialActivitiesDto.officialForm" clearable
                                filterable placeholder="公务形式">
                                <el-option v-for="item in OfficialFormList" :key="item.id" :label="item.name"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="公务机构来源:" prop="officialForm" label-width="160px">
                            <el-select v-model="OpOfficialActivitiesDto.dataSource" clearable filterable
                                placeholder="公务机构来源">
                                <el-option v-for="item in dataSourceList" :key="item.id" :label="item.name"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div style="width: 385px;">
                        <el-form-item label="国家:" prop="country" label-width="160px">
                            <el-input clearable placeholder="国家" v-model="OpOfficialActivitiesDto.country">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div style="width: 385px;">
                        <el-form-item label="城市:" prop="area" label-width="160px">
                            <el-input clearable placeholder="城市" v-model="OpOfficialActivitiesDto.area">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div style="width: 385px;">
                        <el-form-item label="公务单位:" prop="client" label-width="160px">
                            <el-input clearable placeholder="公务单位" v-model="OpOfficialActivitiesDto.client">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div style="width: 385px;">
                        <el-form-item label="公务日期:" prop="date" label-width="160px">
                            <el-date-picker value-format="yyyy-MM-dd" type="date" v-model="OpOfficialActivitiesDto.date"
                                placeholder="选择日期">
                            </el-date-picker>

                        </el-form-item>
                    </div>
                    <div style="width: 385px;">
                        <el-form-item label="公务时刻:" prop="time" label-width="160px">
                            <el-time-picker v-model="OpOfficialActivitiesDto.time" format='HH:mm' value-format="HH:mm"
                                placeholder="公务时刻">
                            </el-time-picker>

                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="邀请方:" prop="type" label-width="160px">
                            <el-select v-model="OpOfficialActivitiesDto.type" clearable filterable placeholder="邀请方选择">
                                <el-option v-for="item in yqfarr" :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select>
                            <!-- <el-radio-group v-model="OpOfficialActivitiesDto.type">
                                <el-radio :label=1>是</el-radio>
                                <el-radio :label=0>否</el-radio>
                            </el-radio-group> -->
                        </el-form-item>
                    </div>
                    <!-- </div>
                <div style="display: flex;flex-wrap: wrap;"> -->

                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="公务方联系人职务:" prop="job" label-width="160px">
                            <el-input clearable placeholder="公务方联系人职务" v-model="OpOfficialActivitiesDto.job">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="公务方联系人:" prop="contact" label-width="160px">
                            <el-input clearable placeholder="公务方联系人" v-model="OpOfficialActivitiesDto.contact">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="电话:" prop="tel" label-width="160px">
                            <el-input clearable placeholder="电话" v-model="OpOfficialActivitiesDto.tel">
                            </el-input>
                        </el-form-item>
                    </div>

                    <!-- </div>
                <div style="display: flex;flex-wrap: wrap;"> -->
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="着装要求:" prop="dresscode" label-width="160px">
                            <el-input clearable placeholder="着装要求" v-model="OpOfficialActivitiesDto.dresscode">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="涉及领域:" prop="field" label-width="160px">
                            <el-input clearable placeholder="涉及领域" v-model="OpOfficialActivitiesDto.field">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="需要翻译:" prop="isNeedTrans" label-width="160px">
                            <el-radio-group v-model="OpOfficialActivitiesDto.isNeedTrans">
                                <el-radio :label=1>是</el-radio>
                                <el-radio :label=0>否</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.name" label="翻译人员:" label-width="160px">
                            <!-- <el-select
                                v-model="OpOfficialActivitiesDto.translatorIdItem"
                                multiple
                                collapse-tags
                                placeholder="请选择">
                                <el-option
                                v-for="item in restaurants"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id">
                                </el-option>
                            </el-select> -->
                            <el-autocomplete style="width: 100%;" class="inline-input"
                                v-model="OpOfficialActivitiesDto.translatorInfo.name" :fetch-suggestions="querySearch"
                                placeholder="请输入内容" @change="fyhandleChange" @select="handleSelect"></el-autocomplete>
                            <!-- <el-input clearable placeholder="翻译人员" v-model="OpOfficialActivitiesDto.translators">
                            </el-input> -->
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.area" label="翻译人员地区:" label-width="160px">
                            <el-input clearable placeholder="翻译人员地区"
                                v-model="OpOfficialActivitiesDto.translatorInfo.area">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.sex" label="翻译性别:" label-width="160px">
                            <el-radio-group v-model="OpOfficialActivitiesDto.translatorInfo.sex">
                                <el-radio :label=0>未设置</el-radio>
                                <el-radio :label=1>男</el-radio>
                                <el-radio :label=2>女</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.tel" label="翻译联系电话:" label-width="160px">
                            <el-input clearable placeholder="翻译联系电话"
                                v-model="OpOfficialActivitiesDto.translatorInfo.tel">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.email" label="翻译邮箱号:" label-width="160px">
                            <el-input clearable placeholder="翻译邮箱号"
                                v-model="OpOfficialActivitiesDto.translatorInfo.email">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.wechatNo" label="翻译微信号:" label-width="160px">
                            <el-input clearable placeholder="翻译微信号"
                                v-model="OpOfficialActivitiesDto.translatorInfo.wechatNo">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.otherSocialAccounts" label="翻译其他账号:" label-width="160px">
                            <el-input clearable placeholder="翻译其他账号"
                                v-model="OpOfficialActivitiesDto.translatorInfo.otherSocialAccounts">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.language" label="翻译语种:" label-width="160px">
                            <el-input clearable placeholder="翻译语种"
                                v-model="OpOfficialActivitiesDto.translatorInfo.language">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.price" label="翻译费用:" label-width="160px">
                            <el-input-number style="width:100%" :precision="2" placeholder="翻译费用"
                                v-model="OpOfficialActivitiesDto.translatorInfo.price"
                                :controls='false'></el-input-number>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337 && OpOfficialActivitiesDto.isNeedTrans == 1"
                        style="width: 385px;">
                        <el-form-item prop="translatorInfo.currency" label="翻译币种:" label-width="160px">
                            <el-select filterable v-model="OpOfficialActivitiesDto.translatorInfo.currency"
                                placeholder="请选择币种">
                                <el-option v-for="(item, index) in currencyarr" :key="index" :label="item.name"
                                    :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>



                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="是否付费:" prop="isPay" label-width="160px">
                            <el-radio-group v-model="OpOfficialActivitiesDto.isPay">
                                <el-radio :label=1>是</el-radio>
                                <el-radio :label=0>否</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="是否报批:" prop="type" label-width="160px">
                            <el-radio-group v-model="OpOfficialActivitiesDto.isSubmitApproval">
                                <el-radio :label=1>是</el-radio>
                                <el-radio :label=0>否</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </div>
                    <!-- <div v-if="OpOfficialActivitiesDto.officialForm!=384&&OpOfficialActivitiesDto.officialForm!=1337" style="width: 385px;">
                        <el-form-item label="性质:" prop="nature" label-width="160px">
                            <el-input clearable placeholder="性质" v-model="OpOfficialActivitiesDto.nature">
                            </el-input>
                        </el-form-item>
                    </div> -->
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="邮箱号/微信号:" prop="emailOrWeChat" label-width="160px">
                            <el-input clearable placeholder="邮箱号/微信号" v-model="OpOfficialActivitiesDto.emailOrWeChat">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 385px;">
                        <el-form-item label="网址:" prop="website" label-width="160px">
                            <el-input clearable placeholder="网址" v-model="OpOfficialActivitiesDto.website">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 770px;">
                        <el-form-item label="公务地址:" prop="address" label-width="160px">
                            <el-input type="textarea" :rows="3" placeholder="公务地址"
                                v-model="OpOfficialActivitiesDto.address"></el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 770px;">
                        <el-form-item label="公务方背景:" prop="setting" label-width="160px">
                            <el-input type="textarea" :rows="3" placeholder="公务方背景"
                                v-model="OpOfficialActivitiesDto.setting">
                            </el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 770px;">
                        <el-form-item style="position: relative;" label="公务请示范例:" label-width="160px">
                            <el-input @blur="reqSampleblur" @focus="PostOfficialActivitiesReqReqSampleTips"
                                type="textarea" :rows="3" placeholder="公务请示范例"
                                v-model="OpOfficialActivitiesDto.reqSample">
                            </el-input>
                            <div v-show="reqSampleArrpd" class="reqSampleArr-ul">
                                <div @click="reqSampleArrli(item)" class="reqSampleArr-li"
                                    v-for="(item, index) in reqSampleArr" :key="index">
                                    {{ '[' + item.teamName + '](' + item.client + ') ' + item.reqSample }}
                                </div>
                            </div>
                        </el-form-item>
                    </div>
                    <!-- </div>
                <div style="display: flex;"> -->
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width: 770px;">
                        <el-form-item label="暂定议程:" prop="trip" label-width="160px">
                            <el-input type="textarea" :rows="3" placeholder="暂定议程"
                                v-model="OpOfficialActivitiesDto.trip"></el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width:770px;">
                        <el-form-item label="参会人员:" prop="attendees" label-width="160px">
                            <el-input type="textarea" :rows="3" placeholder="参会人员"
                                v-model="OpOfficialActivitiesDto.attendees"></el-input>
                        </el-form-item>
                    </div>
                    <div style="width:770px;">
                        <el-form-item label="备注:" prop="remark" label-width="160px">
                            <el-input type="textarea" :rows="3" placeholder="备注"
                                v-model="OpOfficialActivitiesDto.remark"></el-input>
                        </el-form-item>
                    </div>
                    <div v-if="OpOfficialActivitiesDto.officialForm != 384 && OpOfficialActivitiesDto.officialForm != 1337"
                        style="width:770px;">
                        <el-form-item label="邮件截图:" label-width="160px">
                            <span style="display: inline-block;position: absolute;left: -82px;color: red;">*</span>
                            <!-- <el-upload 
                            ref="Emailscreenshotref" 
                            :action="Emailscreenshoturl" 
                            :data="Emailscreenshotdata"
                            :show-file-list="true"
                            :auto-upload="false" 
                            :file-list="Emailscreenshot"
                            :on-change="Emailscreenshotchange"
                            :multiple="true"
                            name="files">
                                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                                <el-button style="margin-left: 10px;" size="small" type="success"
                                    @click="UploadEmailscreenshot">上传</el-button>
                            </el-upload> -->
                            <el-upload accept="image/jpeg,image/png" class="pop-upload" ref="upload" action=""
                                :file-list="fileList" :auto-upload="false" :multiple="true" :on-change="handleChange"
                                :on-remove="handleRemove" :on-preview="handlePreview" :before-remove="beforeRemove"
                                name="files">
                                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                                <span style="color: red;font-size: 11px;">*
                                    需上传，对方初次回复的邮件/微信截图和最后确认会面的信息截图（截图显示对方有效邮箱地址）</span>
                                <!-- <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button> -->
                            </el-upload>
                        </el-form-item>
                    </div>
                </div>
                <!-- <div>
                    <div>
                        <div class="communal-title">
                            <div>公务文件</div>
                        </div>
                    </div>
                    <span style="color: red;">上传、删除文件时请谨慎！！！</span>
                    <hr style='background-color:#5555; height:1px; border:none;' />
                    <div style="display: flex;">
                        <div style="width: 33%;">
                            公务方简介:
                            <el-upload :file-list="uploadFiles1" ref="upload1" :on-success="upLoadSuccess1" :on-error="upLoadError1"
                                :before-remove="beforeRemove1" :on-change="onChange1" :limit="1" :on-exceed="exceed1"
                                :action="uploadURL" :headers="headers1" :auto-upload="false" :on-preview="onPreview1">
                                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                                <el-button style="margin-left: 10px;" size="small" type="success"
                                    @click="submitUpload1">上传</el-button>
                            </el-upload>
                        </div>
                        <div style="width: 33%;">
                            公务活动图片:
                            <el-upload :file-list="uploadFiles2" ref="upload2" :on-success="upLoadSuccess2" :on-error="upLoadError2"
                                :before-remove="beforeRemove2" :on-change="onChange2" :limit="1" :on-exceed="exceed2"
                                :action="uploadURL" :headers="headers2" :auto-upload="false" :on-preview="onPreview2">
                                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
        
                                <el-button style="margin-left: 10px;" size="small" type="success"
                                    @click="submitUpload2">上传</el-button>
                            </el-upload>
                        </div>
                        <div style="width: 33%;">
                            发票:
                            <el-upload :file-list="uploadFiles3" ref="upload3" :on-success="upLoadSuccess3" :on-error="upLoadError3"
                                :before-remove="beforeRemove3" :on-change="onChange3" :limit="1" :on-exceed="exceed3"
                                :action="uploadURL" :headers="headers3" :auto-upload="false" :on-preview="onPreview3">
                                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                                <el-button style="margin-left: 10px;" size="small" type="success"
                                    @click="submitUpload3">上传</el-button>
                            </el-upload>
                        </div>
                    </div>
                </div> -->
                <el-form-item>
                    <div style="text-align: right;">
                        <el-button type="primary" @click="addBtn">保存</el-button>
                        <el-button v-if="btnPermissions && confirmTheInvitation == 0"
                            @click="OfficialActivitiesInviteOperation(1)" type="primary">复核确认</el-button>
                        <el-button v-if="btnPermissions && confirmTheInvitation == 1"
                            @click="OfficialActivitiesInviteOperation(0)" type="primary">取消确认</el-button>
                        <el-button @click="returnbtn">取消</el-button>
                    </div>
                </el-form-item>
            </el-form>

        </div>
    </div>
</template>
<script>
import { pinyin } from 'pinyin-pro';
var validateBudget = (rule, value, callback) => {
    if (value.split('@')[0].includes('info')) {
        callback(new Error('请输正确格式！'));
    } else {
        callback();
    }
}
var addressloog = (rule, value, callback) => {
    console.log(value.length);
    
    if (value.length<15) {
        callback(new Error('字符不足15个！'));
    } else {
        callback();
    }
}
var validatetel = (rule, value, callback) => {
    if (!value) {
        callback(new Error('请输入电话号码'));
        return;
    }
    
    // 国内电话号码验证
    const domesticPhoneRegex = /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/;
    // 国际电话号码验证（包含国家代码）
    const internationalPhoneRegex = /^\+\d{1,4}[-.\s]?\(?\d{1,}\)?[-.\s]?\d{1,}[-.\s]?\d{1,}[-.\s]?\d{1,}$/;
    
    // 判断是否为国际号码（以+开头）
    if (value.startsWith('+')) {
        if (internationalPhoneRegex.test(value)) {
            callback();
        } else {
            // callback(new Error('请输入正确的国际电话号码格式，如：+86-13812345678 或 +1-202-555-0176'));
            callback(new Error('请输入正确的电话号码格式'));
        }
    } else {
        // 国内号码验证
        if (domesticPhoneRegex.test(value)) {
            callback();
        } else {
            // callback(new Error('请输入正确的国内电话号码格式，如：13812345678 或 010-12345678'));
            callback(new Error('请输入正确的电话号码格式'));
        }
    }
}
var validatetranslatortel = (rule, value, callback) => {
    if (!value) {
        callback(new Error('请输入翻译联系电话'));
        return;
    }
    
    // 国内手机号
    const mobileRegex = /^1[3-9]\d{9}$/;
    // 国内固话
    const landlineRegex = /^(0\d{2,3}-?)?[1-9]\d{4,7}(-\d{1,8})?$/;
    // 国际号码
    const internationalRegex = /^\+\d{1,4}[-.\s]?\(?\d{1,}\)?[-.\s]?\d{1,}[-.\s]?\d{1,}[-.\s]?\d{1,}$/;
    
    if (value.startsWith('+')) {
        if (internationalRegex.test(value)) {
            callback();
        } else {
            callback(new Error('请输入正确的国际电话号码格式'));
        }
    } else if (mobileRegex.test(value) || landlineRegex.test(value)) {
        callback();
    } else {
        callback(new Error('请输入正确的电话号码格式'));
    }
}
export default {
    data() {
        return {
            confirmTheInvitation: 0,
            title: "新增公务出访客户资料",
            token: '',
            userId: 0,
            id: '',
            DiId: '',
            isShow: false,
            delegationInfo: {},
            delegationInfoList: [],//团组下拉框
            OfficialFormList: [],//公务形式下拉框
            dataSourceList: [],//来源下拉框
            deleFile: [],//文件数据
            headers: {
                Authorization: JSON.parse(localStorage.getItem('userinif')).token,
                TypeName: "A"
            },
            currencyarr: [],
            OpOfficialActivitiesDto: {
                status: 0,
                id: 0,
                diId: "",
                type: "",
                client: "",//
                date: "",//
                time: "",//
                address: "",
                contact: "",
                job: "",
                tel: "",
                officialForm: "",
                setting: "",
                dresscode: "",
                attendees: "",
                isNeedTrans: 0,
                translatorIdItem: [],
                language: "",
                nature: "",
                emailOrWeChat: "",
                website: "",
                trip: "",
                createUserId: 0,
                isPay: 0,
                isSubmitApproval: 0,
                remark: "",//
                country: "",//
                area: "",//
                field: "",
                reqSample: "",
                dataSource: "",//来源
                translatorInfo: {
                    id: "",
                    area: "",
                    name: "",
                    sex: 1,
                    tel: "",
                    email: "",
                    wechatNo: "",
                    otherSocialAccounts: "",
                    language: "",
                    price: "",
                    currency: "",
                }
            },
            reqSampleArr: [],
            reqSampleArrpd: false,
            rollcallarr: [],
            OpOfficialActivitiesRules: {

                officialForm: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' }
                ],
                country: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                area: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                "translatorInfo.area": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                "translatorInfo.sex": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                "translatorInfo.name": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                "translatorInfo.tel": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { validator: validatetranslatortel, trigger: 'blur' },
                ],
                "translatorInfo.email": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                "translatorInfo.wechatNo": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                "translatorInfo.otherSocialAccounts": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                "translatorInfo.language": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                "translatorInfo.price": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                "translatorInfo.currency": [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                ],
                inviteCosts: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                client: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                date: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                time: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                address: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                    { validator: addressloog, trigger: 'blur' },
                ],
                contact: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                job: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                tel: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                    { validator: validatetel, trigger: 'blur' },
                ],
                dresscode: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                field: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                language: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                setting: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                nature: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                emailOrWeChat: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                    // { validator: validateBudget, trigger: 'blur' },
                ],
                website: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                type: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                fileList: [
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
                isPay: [
                    { required: true, message: '该信息为必填信息', trigger: 'blur' },
                    { required: true, message: '该信息为必填信息', trigger: 'change' },
                ],
            },
            uploadURL: "http://localhost:5256/api/Resource/UploadOfficialActivities",
            uploadFiles1: [],
            uploadFiles2: [],
            uploadFiles3: [],
            Emailscreenshot: [],
            Emailscreenshoturl: 'http://132.232.92.186:8888/api/Resource/OfficialActivitiesUploadFiles',
            Emailscreenshotdata: {
                id: 0,
                diId: 0,
                currUserId: 0,
            },
            Emailscreenshotheaders: {
                Authorization: "Content-Type:multipart/form-data"
            },
            headers1: {
                Authorization: JSON.parse(localStorage.getItem('userinif')).token,
                Type: "1",
                DiId: 0,
                CreateUserId: 0,
            },
            headers2: {
                Authorization: JSON.parse(localStorage.getItem('userinif')).token,
                Type: "2",
                DiId: 0,
                CreateUserId: 0,
            },
            headers3: {
                Authorization: JSON.parse(localStorage.getItem('userinif')).token,
                Type: "3",
                DiId: 0,
                CreateUserId: 0,
            },
            yqfarr: [],
            gwcfPermissions: [],
            btnPermissions: false,
            fileList: [],
            restaurants: [],
        }
    },

    methods: {
        //拼音
        pinyingxing(val) {
            return pinyin(val, { toneType: 'none' }).toUpperCase();
        },
        //fenge
        fgarr(val) {
            val = val + ""
            return val.split(' ')[0]
        },
        querySearch(queryString, cb) {
            var restaurants = this.restaurants;
            var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
            // 调用 callback 返回建议列表的数据
            cb(results);
        },
        createFilter(queryString) {
            return (restaurant) => {
                return restaurant.value.replace("  ", "").toLowerCase().match(queryString.toLowerCase());
            };
        },
        fyhandleChange(item) {
            if (item == '-') {
                this.OpOfficialActivitiesDto.translatorInfo.id = item.id;
                this.OpOfficialActivitiesDto.translatorInfo.area = '-';
                this.OpOfficialActivitiesDto.translatorInfo.name = '-';
                this.OpOfficialActivitiesDto.translatorInfo.sex = 1;
                this.OpOfficialActivitiesDto.translatorInfo.tel = '-';
                this.OpOfficialActivitiesDto.translatorInfo.email = '-';
                this.OpOfficialActivitiesDto.translatorInfo.wechatNo = '-';
                this.OpOfficialActivitiesDto.translatorInfo.otherSocialAccounts = '-';
                this.OpOfficialActivitiesDto.translatorInfo.language = '-';
                this.OpOfficialActivitiesDto.translatorInfo.price = 0;
                this.OpOfficialActivitiesDto.translatorInfo.currency = '';
            }
        },
        handleSelect(item) {
            this.OpOfficialActivitiesDto.translatorInfo = {
                id: "",
                area: "",
                name: "",
                sex: 1,
                tel: "",
                email: "",
                wechatNo: "",
                otherSocialAccounts: "",
                language: "",
                price: "",
                currency: "",
            };
            this.OpOfficialActivitiesDto.translatorInfo.id = item.id;
            this.OpOfficialActivitiesDto.translatorInfo.area = item.area;
            this.OpOfficialActivitiesDto.translatorInfo.name = item.value;
            this.OpOfficialActivitiesDto.translatorInfo.sex = item.sex;
            this.OpOfficialActivitiesDto.translatorInfo.tel = item.tel;
            this.OpOfficialActivitiesDto.translatorInfo.email = item.email;
            this.OpOfficialActivitiesDto.translatorInfo.wechatNo = item.wechatNo;
            this.OpOfficialActivitiesDto.translatorInfo.otherSocialAccounts = item.otherSocialAccounts;
            this.OpOfficialActivitiesDto.translatorInfo.language = item.language;
            this.OpOfficialActivitiesDto.translatorInfo.price = item.price;
            this.OpOfficialActivitiesDto.translatorInfo.currency = item.currency;
        },
        //日期处理（日）
        TimeProcessingri(val) {
            let datetime = new Date(val)
            let newsyear = datetime.getFullYear();
            let newsMonth = datetime.getMonth() + 1 < 10 ? '0' + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
            let newsday = datetime.getDate() < 10 ? '0' + datetime.getDate() : datetime.getDate();
            return newsyear + '-' + newsMonth + '-' + newsday;
        },
        //获取客户名单info
        PostTourClientListByDiId(val) {
            this.rollcallarr = [];
            var that = this
            var url = "/api/Groups/PostTourClientListByDiId"
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    portType: 1,
                    diid: val ? val : that.DiId,
                    pageId: 104,
                    userId: 233
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.rollcallarr = res.data.data;
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        //团组下拉框
        OfficialActivitiesGroupNameList() {
            this.fullscreenLoading = true;
            var url = "/api/Resource/OfficialActivitiesGroupNameList"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    portType: 3,
                    pageIndex: 1,
                    pageSize: 10000,
                    groupName: '',
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.delegationInfoList = res.data.data;
                    for (let index = 0; index < that.delegationInfoList.length; index++) {
                        if (that.delegationInfoList[index].id == parseInt(that.DiId)) {
                            that.delegationInfo = that.delegationInfoList[index];
                            break;
                        }
                    }
                    that.OfficialActivitiesInitDatabase();
                } else {
                    that.fullscreenLoading = false;
                }
            }).catch(function (error) {
                that.fullscreenLoading = false;
                that.$message.error("网络错误，请稍后重试");
            });
        },
        //基础数据初始化
        OfficialActivitiesInitDatabase() {
            var url = "/api/Resource/OfficialActivitiesInitDatabase"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    portType: 3,
                    pageIndex: 1,
                    pageSize: 10000,
                    groupName: '',
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.currencyarr = res.data.data.currencyData;
                    that.deleFile = res.data.data.deleFile;
                    that.deleFile.forEach(function (item) {
                        if (item.kind == 1) {
                            that.uploadFiles1.push({
                                name: item.fileName,
                                url: 'http://localhost:5256/Office/GrpFile/商邀相关文件/',
                                id: item.id
                            });
                        } else if (item.kind == 2) {
                            that.uploadFiles2.push({
                                name: item.fileName,
                                url: 'http://localhost:5256/Office/GrpFile/商邀相关文件/',
                                id: item.id
                            });
                        }
                        else if (item.kind == 3) {
                            that.uploadFiles3.push({
                                name: item.fileName,
                                url: 'http://localhost:5256/Office/GrpFile/商邀相关文件/',
                                id: item.id
                            });
                        }
                    });
                    that.OfficialFormList = res.data.data.setData;
                    that.dataSourceList = res.data.data.dataSource;
                    if (that.OfficialFormList.length != 0) {
                        if (that.id != that.id) {
                            that.OpOfficialActivitiesDto.officialForm = that.OfficialFormList[0].id
                        }
                    }
                    that.OfficialActivitiesTranslatorList();
                } else {
                    that.$message.error("网络错误，请稍后重试");
                }
            }).catch(function (error) {
                that.$message.error("网络错误，请稍后重试");
            });
        },
        //翻译人员
        OfficialActivitiesTranslatorList() {
            var url = "/api/Resource/OfficialActivitiesTranslatorList"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    portType: 3,
                    pageIndex: 1,
                    pageSize: 10000,
                    groupName: '',
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.restaurants = res.data.data.map((terminal) => {
                        return {
                            id: terminal.id,
                            value: terminal.name,
                            area: terminal.area,
                            sex: terminal.sex,
                            tel: terminal.tel,
                            email: terminal.email,
                            wechatNo: terminal.wechatNo,
                            otherSocialAccounts: terminal.otherSocialAccounts,
                            language: terminal.language,
                            price: terminal.price,
                            currency: terminal.currency,
                        };
                    });
                } else {
                    that.$message.error("网络错误，请稍后重试");
                }
            }).catch(function (error) {
                that.$message.error("网络错误，请稍后重试");
            });
        },
        //团组下拉框
        GetGroupAllList() {
            var url = "/api/Resource/GetGroupAllList"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    diid: that.DiId
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    // let datainfo=res.data.data;
                    // that.currencyarr=datainfo.currencyData;
                    // that.restaurants = res.data.data.translatorData;
                    // that.restaurants= datainfo.translatorData.map((terminal) => {
                    //     return {
                    //         id:terminal.id,
                    //         value:terminal.name,
                    //         area:terminal.area,
                    //         sex:terminal.sex,
                    //         tel:terminal.tel,
                    //         email:terminal.email,
                    //         wechatNo:terminal.wechatNo,
                    //         otherSocialAccounts:terminal.otherSocialAccounts,
                    //         language:terminal.language,
                    //         price:terminal.price,
                    //         currency:terminal.currency,
                    //     };
                    // });
                    // that.deleFile = res.data.data.deleFile;
                    // that.deleFile.forEach(function (item) {
                    //     if (item.kind == 1) {
                    //         that.uploadFiles1.push({
                    //             name: item.fileName,
                    //             url: 'http://localhost:5256/Office/GrpFile/商邀相关文件/',
                    //             id: item.id
                    //         });
                    //     } else if (item.kind == 2) {
                    //         that.uploadFiles2.push({
                    //             name: item.fileName,
                    //             url: 'http://localhost:5256/Office/GrpFile/商邀相关文件/',
                    //             id: item.id
                    //         });
                    //     }
                    //     else if (item.kind == 3) {
                    //         that.uploadFiles3.push({
                    //             name: item.fileName,
                    //             url: 'http://localhost:5256/Office/GrpFile/商邀相关文件/',
                    //             id: item.id
                    //         });
                    //     }
                    // });



                    // that.delegationInfoList = res.data.data.delegation;
                    // that.OfficialFormList = res.data.data.setData;
                    // that.dataSourceList = res.data.data.dataSource;
                    // if (that.OfficialFormList.length != 0) {
                    //     if(that.id!=that.id){
                    //         that.OpOfficialActivitiesDto.officialForm = that.OfficialFormList[0].id
                    //     }
                    // }
                    // for (let index = 0; index < that.delegationInfoList.length; index++) {
                    //     if (that.delegationInfoList[index].id == parseInt(that.DiId)) {

                    //         that.delegationInfo = that.delegationInfoList[index];
                    //         break;
                    //     }
                    // }
                }
            }).catch(function (error) {
                // that.$message.error("网络错误，请稍后重试");
            });
        },
        //UploadEmailscreenshot
        UploadEmailscreenshot() {
            console.log(file, fileList);
            this.Emailscreenshotdata.diId = this.DiId;
            this.Emailscreenshotdata.currUserId = this.userId;
            this.submitUpload()
        },

        //获取邀请方
        QuerySetData() {
            var that = this;
            var url = "/api/System/QuerySetData"
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    dataType: 85
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.yqfarr = res.data.data;
                    console.log(that.yqfarr);
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        Emailscreenshotchange(file, fileList) {
            console.log(file, fileList);
        },
        //获取公务请示范例提示
        PostOfficialActivitiesReqReqSampleTips() {
            var that = this;
            var url = "/api/Resource/PostOfficialActivitiesReqReqSampleTips"
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    country: that.OpOfficialActivitiesDto.country,
                    area: that.OpOfficialActivitiesDto.area,
                    client: that.OpOfficialActivitiesDto.client
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    console.log(res)
                    that.reqSampleArrpd = true
                    that.reqSampleArr = res.data.data;
                    // that.$message({
                    //     message: res.data.msg,
                    //     type: 'success'
                    // });
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        reqSampleblur() {
            // setTimeout(this.reqSampleArrpd=false,2000)
            setTimeout(() => {
                this.reqSampleArrpd = false
            }, 150);
        },
        DiIdChang(val) {
            for (let index = 0; index < this.delegationInfoList.length; index++) {
                if (this.delegationInfoList[index].id == parseInt(this.DiId)) {
                    this.delegationInfo = this.delegationInfoList[index];
                    break;
                }
            }
            this.PostTourClientListByDiId(val);
        },
        reqSampleArrli(val) {
            console.log(val);
            this.OpOfficialActivitiesDto.reqSample = val.reqSample;
            this.reqSampleArrpd = false;
        },
        QueryOfficialActivitiesById() {
            var url = "/api/Resource/QueryOfficialActivitiesById"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    Id: that.id,
                    DiId: that.DiId,
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    var dataList = res.data.data;
                    that.OpOfficialActivitiesDto.id = dataList.id;
                    that.OpOfficialActivitiesDto.diId = dataList.diId;
                    that.OpOfficialActivitiesDto.type = dataList.type;
                    that.OpOfficialActivitiesDto.client = dataList.client;
                    that.OpOfficialActivitiesDto.date = dataList.date;
                    that.OpOfficialActivitiesDto.time = dataList.time;;
                    that.OpOfficialActivitiesDto.address = dataList.address;
                    that.OpOfficialActivitiesDto.contact = dataList.contact;
                    that.OpOfficialActivitiesDto.job = dataList.job;
                    that.OpOfficialActivitiesDto.tel = dataList.tel;
                    that.OpOfficialActivitiesDto.officialForm = dataList.officialForm;
                    that.OpOfficialActivitiesDto.setting = dataList.setting;
                    that.OpOfficialActivitiesDto.dresscode = dataList.dresscode;
                    that.OpOfficialActivitiesDto.attendees = dataList.attendees;
                    that.OpOfficialActivitiesDto.isNeedTrans = dataList.isNeedTrans;
                    that.OpOfficialActivitiesDto.translatorIdItem = dataList.translatorIdItem;
                    that.OpOfficialActivitiesDto.language = dataList.language;
                    that.OpOfficialActivitiesDto.nature = dataList.nature;
                    that.OpOfficialActivitiesDto.emailOrWeChat = dataList.emailOrWeChat;
                    that.OpOfficialActivitiesDto.website = dataList.website;
                    that.OpOfficialActivitiesDto.trip = dataList.trip;
                    that.OpOfficialActivitiesDto.createUserId = dataList.createUserId;
                    that.OpOfficialActivitiesDto.remark = dataList.remark;
                    that.OpOfficialActivitiesDto.isSubmitApproval = dataList.isSubmitApproval;
                    that.OpOfficialActivitiesDto.isPay = dataList.isPay;
                    that.OpOfficialActivitiesDto.country = dataList.country;
                    that.OpOfficialActivitiesDto.area = dataList.area;
                    that.OpOfficialActivitiesDto.field = dataList.field;
                    that.OpOfficialActivitiesDto.reqSample = dataList.reqSample;
                    that.confirmTheInvitation = dataList.confirmTheInvitation;

                    that.OpOfficialActivitiesDto.dataSource = dataList.dataSource;//来源


                    that.OpOfficialActivitiesDto.translatorInfo.id = dataList.translatorInfo.id;//翻译详细
                    that.OpOfficialActivitiesDto.translatorInfo.area = dataList.translatorInfo.area;
                    that.OpOfficialActivitiesDto.translatorInfo.name = dataList.translatorInfo.name;
                    that.OpOfficialActivitiesDto.translatorInfo.sex = dataList.translatorInfo.sex;
                    that.OpOfficialActivitiesDto.translatorInfo.tel = dataList.translatorInfo.tel;
                    that.OpOfficialActivitiesDto.translatorInfo.email = dataList.translatorInfo.email;
                    that.OpOfficialActivitiesDto.translatorInfo.wechatNo = dataList.translatorInfo.wechatNo;
                    that.OpOfficialActivitiesDto.translatorInfo.otherSocialAccounts = dataList.translatorInfo.otherSocialAccounts;
                    that.OpOfficialActivitiesDto.translatorInfo.language = dataList.translatorInfo.language;
                    that.OpOfficialActivitiesDto.translatorInfo.price = dataList.translatorInfo.price;
                    that.OpOfficialActivitiesDto.translatorInfo.currency = dataList.translatorInfo.currency;
                    // that.fileList
                    that.fileList = []
                    for (let i = 0; i < dataList.screenshotOfMailUrls.length; i++) {
                        that.fileList.push({ 'name': dataList.screenshotOfMailUrls[i].split('/')[7], 'url': dataList.screenshotOfMailUrls[i] })
                    }
                }

            })
        },
        addBtn() {
            if (this.DiId == null && this.DiId == undefined && this.DiId == "") {
                this.$message.error("请选择团组名称");
                return;
            }
            if (this.fileList.length <= 0 && this.OpOfficialActivitiesDto.officialForm != 384) {
                this.$message.error("请先选取邮件截图");
                return;
            }

            const that = this;
            this.OpOfficialActivitiesDto.date = this.TimeProcessingri(this.OpOfficialActivitiesDto.date)
            that.OpOfficialActivitiesDto.createUserId = that.userId
            that.OpOfficialActivitiesDto.diId = that.DiId

            if (that.OpOfficialActivitiesDto.officialForm == 384 || that.OpOfficialActivitiesDto.officialForm == 1337) {
                that.OpOfficialActivitiesDto.type = 0;
                that.OpOfficialActivitiesDto.address = '';
                that.OpOfficialActivitiesDto.contact = '';
                that.OpOfficialActivitiesDto.job = '';
                that.OpOfficialActivitiesDto.tel = '';
                that.OpOfficialActivitiesDto.setting = '';
                that.OpOfficialActivitiesDto.dresscode = '';
                that.OpOfficialActivitiesDto.attendees = '';
                that.OpOfficialActivitiesDto.isNeedTrans = 0;
                that.OpOfficialActivitiesDto.translatorIdItem = [];
                that.OpOfficialActivitiesDto.language = '';
                that.OpOfficialActivitiesDto.nature = '';
                that.OpOfficialActivitiesDto.emailOrWeChat = '';
                that.OpOfficialActivitiesDto.website = '';
                that.OpOfficialActivitiesDto.trip = '';
                that.OpOfficialActivitiesDto.isPay = 0;
                that.OpOfficialActivitiesDto.isSubmitApproval = 0;
                that.OpOfficialActivitiesDto.field = '';
                that.OpOfficialActivitiesDto.reqSample = '';
                that.OpOfficialActivitiesDto.dataSource = 0;
                that.OpOfficialActivitiesDto.translatorInfo = {};
            }
            if (that.OpOfficialActivitiesDto.isNeedTrans == 0) {
                that.OpOfficialActivitiesDto.translatorInfo = {};
            }
            let filteredObjects = that.restaurants.filter(obj =>
                that.OpOfficialActivitiesDto.translatorInfo.name == obj.value

            );
            if (filteredObjects.length < 1) {
                that.OpOfficialActivitiesDto.translatorInfo.id = 0;
            }
            if (that.OpOfficialActivitiesDto.translatorInfo.id == '') {
                that.OpOfficialActivitiesDto.translatorInfo.id = 0
            }
            that.$refs.OpOfficialActivitiesDto.validate((valid) => {
                if (valid) {
                    var url = "/api/Resource/OpOfficialActivities"
                    that.$axios({
                        method: 'post',
                        url: url,
                        headers: {
                            Authorization: 'Bearer ' + that.token
                        },
                        data: that.OpOfficialActivitiesDto
                    }).then(function (res) {
                        if (res.data.code == 200) {
                            that.$message({
                                message: res.data.msg,
                                type: 'success'
                            });
                            that.submitUpload(res.data.data.id);
                            that.returnbtn();

                        } else {
                            that.$message.error(res.data.msg);
                        }
                    })
                } else {
                    this.$message.error('请完善信息在保存！');
                    return false;
                }
            })
        },

        // 文件超出限制
        exceed1(files, fileList) {
            this.$message.warning(
                `当前限制选择 1个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length
                } 个文件,请取消要替换的文件`
            );
        },
        //文件上传成功时的钩子
        upLoadSuccess1(response, file, fileList) {
            this.$message({
                message: response.msg,
                type: 'success'
            });
        },
        //文件上传失败时的钩子
        upLoadError1(response, file, fileList) {
            console.log("项目添加失败");
        },
        //取消文件时的钩子
        beforeRemove1(file, fileList) {
            const that = this;
            var url = "/api/Resource/DelloadOfficialActivities"
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    Id: file.id,
                    DeleteUserId: that.userId
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.$message({
                        message: res.data.msg,
                        type: 'success'
                    });
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        //文件状态改变时的钩子
        onChange1(file, fileList) {

        },
        //点击文件的钩子
        onPreview1(file) {
            window.location.href = "http://132.232.92.186:24/Office/GrpFile/商邀相关文件/" + file.name
        },

        // 文件超出限制
        exceed2(files, fileList) {
            this.$message.warning(
                `当前限制选择 1个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length
                } 个文件,请取消要替换的文件`
            );
        },
        //文件上传成功时的钩子
        upLoadSuccess2(response, file, fileList) {
            this.$message({
                message: response.msg,
                type: 'success'
            });
        },
        //文件上传失败时的钩子
        upLoadError2(response, file, fileList) {
            console.log("项目添加失败");
        },
        //删除文件时出发的事件
        beforeRemove2(file, fileList) {
            const that = this;
            var url = "/api/Resource/DelloadOfficialActivities"
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    Id: file.id,
                    DeleteUserId: that.userId
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.$message({
                        message: res.data.msg,
                        type: 'success'
                    });
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        //文件状态改变时的钩子
        onChange2(file, fileList) {

        },
        //点击文件的钩子
        onPreview2(file) {
            window.location.href = "http://132.232.92.186:24/Office/GrpFile/商邀相关文件/" + file.name
        },

        // 文件超出限制
        exceed3(files, fileList) {
            this.$message.warning(
                `当前限制选择 1个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length
                } 个文件,请取消要替换的文件`
            );
        },
        //文件上传成功时的钩子
        upLoadSuccess3(response, file, fileList) {
            this.$message({
                message: response.msg,
                type: 'success'
            });
        },
        //文件上传失败时的钩子
        upLoadError3(response, file, fileList) {
            console.log("项目添加失败");
        },
        //删除文件时出发的事件
        beforeRemove3(file, fileList) {
            const that = this;
            var url = "/api/Resource/DelloadOfficialActivities"
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    Id: file.id,
                    DeleteUserId: that.userId
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.$message({
                        message: res.data.msg,
                        type: 'success'
                    });
                    setTimeout(() => {
                        that.$router.push('/home/OfficialActivities')
                    }, 3000);
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        //文件状态改变时的钩子
        onChange3(file, fileList) {

        },
        //点击文件的钩子
        onPreview3(file) {
            let href = "http://132.232.92.186:24/Office/GrpFile/商邀相关文件/" + file.name
            var a = document.createElement("a");
            a.href = href;
            a.download = file.name;
            a.style.display = "none";
            document.body.appendChild(a);
            a.click();
            a.remove();
            //window.location.href = "http://132.232.92.186:24/Office/GrpFile/商邀相关文件/" + file.name
        },

        //返回
        returnbtn() {
            this.$router.push({
                path: "/home/OfficialActivities",
                query: {
                    DiId: this.DiId,
                }
            })
        },

        // 文件状态改变时的钩子，添加文件、上传成功和上传失败时都会被调用,function(file, fileList)
        handleChange(file, fileList) {
            console.log(file);
            console.log(fileList);
            this.fileList = fileList
        },
        //删除文件
        beforeRemove(file, fileList) {
            if (file && file.status == "success") {
                return this.$confirm('此文件已上传至服务器此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    // this.$message({
                    //     type: 'success',
                    //     message: '删除成功!'
                    // });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                    reject(false)
                });
            }
        },
        // 删除文件之前的钩子，参数为上传的文件和文件列表，若返回 false 或者返回 Promise 且被 reject，则停止删除。function(file, fileList)
        handleRemove(file, fileList) {
            this.fileList = fileList
            if (file && file.status == "success") {
                var that = this;
                var url = "/api/Resource/OfficialActivitiesDelFile"
                this.$axios({
                    method: 'post',
                    url: url,
                    headers: {
                        Authorization: 'Bearer ' + that.token
                    },
                    data: {
                        id: that.id,
                        fileName: file.name
                    }
                }).then(function (res) {
                    if (res.data.code == 200) {
                        that.$message.success(res.data.msg);
                    } else {
                        that.$message.error(res.data.msg);
                    }
                })
            }

        },
        //点击文件列表中已上传的文件
        handlePreview(file) {
            console.log(file);
            window.open(file.url);
        },

        //上传服务器
        submitUpload(val) {
            // console.log(this.id);
            var verdict = false
            if (this.id == undefined) {
                this.id == val
            }
            this.Emailscreenshotdata.id = val;
            this.Emailscreenshotdata.diId = this.DiId;
            this.Emailscreenshotdata.currUserId = this.userId;
            //判断是否有文件再上传
            if (this.fileList.length === 0) {
                return this.$message.warning('请选取文件后再上传');
            }
            // 下面的代码将创建一个空的FormData对象:
            const formData = new FormData()
            // 你可以使用FormData.append来添加键/值对到表单里面；
            this.fileList.forEach((file) => {
                if (file.raw != undefined) {
                    verdict = true;
                    formData.append('files', file.raw);
                }
            })
            formData.append('id', this.Emailscreenshotdata.id);
            formData.append('diId', this.Emailscreenshotdata.diId);
            formData.append('currUserId', this.Emailscreenshotdata.currUserId);
            if (!verdict) {
                return
            }
            var that = this;
            var url = "/api/Resource/OfficialActivitiesUploadFiles"
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: formData
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.$message.success(res.data.msg);

                    that.fileList = []
                    for (let i = 0; i < res.data.data.fileUrls.length; i++) {
                        that.fileList.push({ 'name': res.data.data.fileUrls[i].split('/')[7], 'url': res.data.data.fileUrls[i] })
                    }
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        //确认邀请
        OfficialActivitiesInviteOperation(val) {
            var that = this;
            var url = "/api/Resource/OfficialActivitiesInviteOperation"
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    id: that.id,
                    type: val
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.QueryOfficialActivitiesById()
                    that.$message.success(res.data.msg);
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        //控制表单
        Officchange(val) {
            console.log(this.OpOfficialActivitiesDto.officialForm != 384, this.OpOfficialActivitiesDto.officialForm != 1337);

        }
    },

    mounted() {

        this.token = JSON.parse(localStorage.getItem('userinif')).token;
        this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
        this.gwcfPermissions = JSON.parse(localStorage.getItem('Permissions'));
        this.DiId = parseInt(this.$route.query.DiId)
        this.PostTourClientListByDiId();
        console.log(this.gwcfPermissions);
        for (let k = 0; k < this.gwcfPermissions.length; k++) {
            if (this.gwcfPermissions[k].funid == 12) {
                this.btnPermissions = true;
            }
        }
        this.QuerySetData();
        this.id = this.$route.query.id
        this.headers1.DiId = this.DiId
        this.headers1.CreateUserId = this.userId

        this.headers2.DiId = this.DiId
        this.headers2.CreateUserId = this.userId

        this.headers3.DiId = this.DiId
        this.headers3.CreateUserId = this.userId

        // this.GetGroupAllList();
        this.OfficialActivitiesGroupNameList();

        if (this.DiId == null && this.DiId == undefined && this.DiId == 0) {
            this.DiId = '';
        }
        if (this.id != null && this.id != undefined && this.id != 0) {
            this.QueryOfficialActivitiesById();
            this.title = "修改公务出访客户资料";
            this.OpOfficialActivitiesDto.status = 2
            this.isShow = true
        } else {
            this.OpOfficialActivitiesDto.status = 1
            this.title = "新增公务出访客户资料"
            this.isShow = false
        }

    }
}
</script>
<style>
.car_add .communal-title {
    display: flex;
    font-size: 17px;
    font-weight: 600;
    color: #555;
    margin-bottom: 20px;
    justify-content: space-between;
    align-items: center;

}

.appraise-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin: 50px 0;
}

.appraise-box>div {
    width: 30%;
}

.communal-box {
    display: flex;
}

.communal-box>button {
    margin-left: 10px;
    padding: 8px 20px;
}

.car_add {
    background-color: #fff;
    padding: 20px;
    box-shadow: 0 0 5px #0005;
    border-radius: 10px;
    min-height: 810px;

}

.visit-box .el-date-editor.el-input,
.el-date-editor.el-input__inner {
    width: 100%;
}

.visit-box .el-select {
    width: 100%;
}

.reqSampleArr-ul {
    position: absolute;
    z-index: 1;
    background-color: #FFFFFF;
    box-shadow: #5555 0 0 10px;
    border-radius: 5px;
    max-height: 400px;
    overflow: auto;
}

.reqSampleArr-li:hover {
    background-color: #5551;
}

.reqSampleArr-li {
    line-height: 20px;
    padding: 10px;
    cursor: pointer;
}

.ps-title {
    color: red;
    font-size: 12px;
}

::v-deep input[aria-hidden="true"] {
    display: none !important;
}

::v-deep .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
    box-shadow: none !important;
}

@media screen and (max-width: 1700px) {
    .appraise-box>div {
        width: 48%;
    }

    .appraise-box>div el-form-item__content {
        width: 260px !important;
    }
}
</style>