affix-invitation.vue 23.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
<template>
  <el-dialog
      v-model="show" :close-on-click-modal="false" :title="title" append-to-body center
      class="pcloginpop" close-icon="CircleClose"
      destroy-on-close
  >
    <div class="boxInvitation">

      <div v-if="showR" class="text-center pd20">
        <img class="mauto" src="@/assets/dance/ok.png"/>
        <!--     提交成功等待审核-->
        <h3 v-if="form.status">
          <span v-if="form.status==0">In Approval</span>
          <span v-if="form.status==1">Approved</span>
        </h3>
        <h4>
          Your invitation letter application has been received,<br/>
          and we will process it as soon as possible.
          <br/>
          Thank you so much for your kind patience.
        </h4>

        <div class="red">To check your application status, please go to Account > Personal > Visa Review Record, or
          refer to your email for any updates.
        </div>

      </div>

      <el-form v-else ref="iformRef" :model="form" :rules="rules" label-position="top">
        <el-form-item :label="language==0?'申请人类别':'Applicant Type'" prop="applicatType" required>
          <el-select v-model="form.applicatType" @change="changeApplicatType">
            <el-option label="MNA/Team" value="1"/>
            <el-option label="Technical Official" value="2"/>
            <el-option label="WT Team" value="3"/>
            <!--            <el-option label="Supplier" value="4"/>-->
            <el-option label="Other(not listed above)" value="5"/>
          </el-select>
          <el-input v-if="form.applicatType==5" v-model="form.remarks" class="mt10" placeholder="Please specify"/>
        </el-form-item>
        <el-form-item :label="language==0?'邀请函类别':'Invitation Type'" prop="invitationType" required>
          <el-select v-model="form.invitationType">
            <el-option :label="language==0?'一般邀请函':'General Invitation'" value="1"/>
            <el-option :label="language==0?'TE/PU(外办)邀请函':'TE/PU Invitation'" value="2"/>
          </el-select>
        </el-form-item>
        <el-form-item v-if="form.invitationType=='2'" label="Proof of Employment" prop="invitationFileArr" required>
          <div class="red">Proof of employment is required for TE/PU invitation letters.</div>
          <div class="red">
            This document must be issued by the invitee's association and must bear an official stamp or signature.
          </div>
          <br/>
          <file-upload v-model="form.invitationFileArr" :button-text="language==0?'上传':'Upload'" :is-show-tip="false"
                       :limit="1"></file-upload>
        </el-form-item>
<!--        <el-form-item :label="language==0?'是否需要中文邀请函':'Do you need a Chinese invitation?'" prop="chinese"-->
<!--                      required>-->
<!--          <el-radio-group v-model="form.chinese">-->
<!--            <el-radio value="1">{{ language == 0 ? '是' : 'Yes' }}</el-radio>-->
<!--            <el-radio value="0">{{ language == 0 ? '否' : 'No' }}</el-radio>-->
<!--          </el-radio-group>-->
<!--        </el-form-item>-->

        <!--        一般信息-->
        <el-form-item :label="language==0?'国家/地区协会名':'MNA/Team Name'" :required="form.applicatType==1"
                      prop="associationCode">
          <el-select v-model="form.associationCode" clearable filterable>
            <el-option v-for="item in mnaList" :key="item.code" :label="language==0?item.nameCn:item.nameEn"
                       :value="item.code"/>
          </el-select>
        </el-form-item>
        <el-form-item :label="language==0?'国家/地区协会地址':'MNA/Team Address'" :required="form.applicatType==1"
                      prop="associationAddress">
          <el-input v-model="form.associationAddress"/>
        </el-form-item>
        <el-form-item :label="language==0?'邮箱':'Contact Email'" prop="email" required>
          <div class="red">Note: Notifications from the organizing committee will be sent to this email address.
          </div>
          <el-input v-model="form.email" type="email">
            <template #append>
              <el-button v-loading="codeloading" class="codeBtn" @click="sendEmail">
                {{ language == 0 ? '发送验证码' : 'Send Code' }}
              </el-button>
            </template>
          </el-input>
          <!--          <div class="tip"></div>-->
        </el-form-item>
        <el-form-item prop="code" required>
          <el-input v-model="form.code" placeholder="Email verification code"/>
        </el-form-item>
        <el-form-item :label="language==0?'姓名':'Contact person Full Name'" prop="fullName" required>
          <el-input v-model="form.fullName"/>
        </el-form-item>
        <el-form-item :label="language==0?'联系人职位':'Contact person Position'" prop="position" required>
          <el-select v-model="form.position">
            <el-option label="Manager" value="0"/>
            <el-option label="Team leader" value="1"/>
            <el-option label="Coach" value="2"/>
            <el-option label="Other" value="3"/>
          </el-select>
          <el-input v-if="form.position==3" v-model="form.remarks1" class="mt10" placeholder="Please specify"/>
        </el-form-item>
        <el-form-item :label="language==0?'联系电话':'Contact person Phone Number'" prop="phone" required>
          <el-input v-model="form.phone"/>
        </el-form-item>
        <el-form-item :label="language==0?'签证办理中国大使馆':'Chinese Embassy Visas Office'" prop="embassy" required>
          <div class="red">Ex:EMBASSY OF THE PEOPLE'S REPUBLIC OFCHINA IN THE ISLAMIC REPUBLIC OF PAKISTAN
          </div>
          <el-input v-model="form.embassy"/>
        </el-form-item>
        <el-form-item :label="language==0?'中国大使馆邮箱':'Chinese Embassy Email'" prop="embassyEmail" required>
          <el-input v-model="form.embassyEmail"/>
        </el-form-item>

        <!--上传护照,多张-->
        <div class="cptVisaInfoBosTable">
          <el-form-item :label="language==0?'有效证件':'Passport Copy'" required>
            <div class="wrap-item">
              <!-- <el-text type="success">Please ensure that the uploaded passport image is clear, complete, and free from
                glare or reflections.
              </el-text> -->
              <div class="red">Please ensure that the uploaded passport image is clear, complete, and free from
                glare or reflections.
              </div>
              <div class="red">You may upload multiple passports at once to appy for multiple applicants.
              </div>
              <div class="red">Please review the extracted passport information carefully.
              </div>
              <div class="red">If you notice any errors, you can edit the fields manually before submission.
              </div>
              <ImageUpload v-model="form.passportCopy" :action="'/league/visa/getPersonInfoFromCert/3' "
                           :button-text="language==0?'上传':'Upload'"
                           :is-show-tip="false"
                           :limit="20" :show-file-list="false" list-type="text"
                           paramName="pic" @response="getPassportInfo"
              />
            </div>
          </el-form-item>
          <!--识别信息-->
          <div v-if="form.cptVisaInfoBos?.length>0" class="border">
            <el-table :data="form.cptVisaInfoBos" border size="small">
              <el-table-column :label="language==0?'护照':'Passport Copy'" min-width="100" prop="passportCopy">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>Passport Copy
                  </div>
                </template>
                <template #default="scope">
                  <el-image :preview-src-list="[fillImgUrl(scope.row.passportCopy)]"
                            :src="fillImgUrl(scope.row.passportCopy)"
                            preview-teleported style="width: 60px;z-index: 999;"/>
                </template>
              </el-table-column>
              <el-table-column :label="'position'" min-width="100" prop="position">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>Position
                  </div>
                </template>
                <template #default="scope">
                  <el-select v-model="scope.row.position" size="small">
                    <!--MNA/Team-->
                    <template v-if="form.applicatType=='1'">
                      <el-option label="Head Of Team" value="Head Of Team"/>
                      <el-option label="Head Coach" value="Head Coach"/>
                      <el-option label="Manager" value="Manager"/>
                      <el-option label="Coach" value="Coach"/>
                      <el-option label="Trainer" value="Trainer"/>
                      <el-option label="Team Doctor" value="Team Doctor"/>
                      <el-option label="Team Physiotherepaist" value="Team Physiotherepaist"/>
                      <el-option label="Competitor" value="Competitor"/>
                      <el-option label="MNA Official" value="MNA Official"/>
                      <el-option label="MNA Guest" value="MNA Guest"/>
                    </template>
                    <!--Technical Official-->
                    <template v-if="form.applicatType=='2'">
                      <el-option label="International Referee" value="International Referee"/>
                      <el-option label="Technical Delegate" value="Technical Delegate"/>
                      <el-option label="CSB member" value="CSB member"/>
                    </template>
                    <!--WT Team-->
                    <template v-if="form.applicatType=='3'">
                      <el-option label="WT Director" value="WT Director"/>
                      <el-option label="WT Manager" value="WT Manager"/>
                      <el-option label="WT Assistant Manager" value="WT Assistant Manager"/>
                      <el-option label="WT Coordinator" value="WT Coordinator"/>
                    </template>
                    <el-option label="Other (please specify)" value="other"/>
                  </el-select>
                  <el-input v-if="scope.row.position=='other'" v-model="scope.row.remarks" placeholder="Please specify"
                            size="small"></el-input>
                </template>
              </el-table-column>
              <el-table-column :label="'lastName'" min-width="100" prop="lastName">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>LastName
                  </div>
                </template>
                <template #default="scope">
                  <el-input v-model="scope.row.lastName" size="small"/>
                </template>
              </el-table-column>
              <el-table-column :label="'firstName'" min-width="100" prop="fristName">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>firstName
                  </div>
                </template>
                <template #default="scope">
                  <el-input v-model="scope.row.fristName" size="small"/>
                </template>
              </el-table-column>
              <el-table-column :label="language==0?'性别':'Gender'" prop="sex" width="70">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>Gender
                  </div>
                </template>
                <template #default="scope">
                  <el-select v-model="scope.row.sex" size="small">
                    <el-option label="M" value="0"/>
                    <el-option label="F" value="1"/>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column :label="language==0?'国籍':'Nationality'" prop="nationality" width="110px">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>Nationality
                  </div>
                </template>
                <template #default="scope">
                  <el-select v-model="scope.row.nationality" filterable size="small">
                    <el-option v-for="item in countrys" :key="item.id" :label="item.noc"
                               :value="item.id"/>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column :label="language==0?'出生日期':'Birth'" prop="birth" width="130px">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>Birth
                  </div>
                </template>
                <template #default="scope">
                  <el-date-picker v-model="scope.row.birthday"
                                  format="YYYY-MM-DD"
                                  placeholder="YYYY-MM-DD" size="small"
                                  style="width: 100%;" type="date" value-format="YYYY-MM-DD"
                  />
                </template>
              </el-table-column>
              <el-table-column :label="language==0?'护照号':'Passport No.'" prop="passportNo" width="110px">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>Passport No.
                  </div>
                </template>
                <template #default="scope">
                  <el-input v-model="scope.row.passportNo" size="small"/>
                </template>
              </el-table-column>
              <el-table-column :label="language==0?'护照签发日':'DATE OF ISSUE'" prop="expiryDate" width="130px">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>DATE OF ISSUE
                  </div>
                </template>
                <template #default="scope">
                  <el-date-picker
                      v-model="scope.row.issueDate" format="YYYY-MM-DD"
                      placeholder="YYYY-MM-DD" size="small"
                      style="width: 100%;" type="date" value-format="YYYY-MM-DD"
                  />
                </template>
              </el-table-column>
              <el-table-column :label="language==0?'护照过期日':'DATE OF EXPIRY'" prop="arrival" width="130px">
                <template #header>
                  <div class="esp">
                    <span class="red">*</span>DATE OF EXPIRY
                  </div>
                </template>
                <template #default="scope">
                  <el-date-picker
                      v-model="scope.row.expiryDate" format="YYYY-MM-DD"
                      placeholder="YYYY-MM-DD" size="small"
                      style="width: 100%;" type="date" value-format="YYYY-MM-DD"
                  />
                </template>
              </el-table-column>
              <el-table-column fixed="right" label="Actions">
                <template #default="scope">
                  <el-button icon="delete" size="small" type="danger" @click="delPassportInfo(scope.$index)"/>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <el-form-item :label="language==0?'备注':'Remarks'" prop="remarks3">
          <div class="red">
            You may leave any message here, or let us know if you require additional documents for your visa application.
          </div>
          <el-input v-model="form.remarks3"/>
        </el-form-item>
        <!--        补充材料-->
        <el-form-item :label="language==0?'补充材料':'Additional Documents'" prop="files">
          <file-upload v-model="form.files" :button-text="language==0?'上传':'Upload'" :is-show-tip="false"
                       :limit="1"/>
        </el-form-item>


        <div class="text-center">
          <el-button :disabled="!cptId" class="btn-lineG" round size="large" type="primary" @click="submit">
            {{ language == 0 ? '提交' : 'SUBMIT' }}
          </el-button>
        </div>
      </el-form>
    </div>
  </el-dialog>

</template>

<script setup>
import {useStorage} from "@vueuse/core/index";
import {getCurrentInstance, ref} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {
  addInvitation,
  associationList,
  countryList,
  getInvitation,
  getVisaInfo,
  getVisaInfoList,
  sendVisaCode
} from "@/apiPc/match";
import ImageUpload from '@/components/ImageUpload/index.vue'
import useUserStore from "@/store/modules/user";
import _ from 'lodash'
import FileUpload from "@/components/FileUpload";

const emit = defineEmits(['refresh'])
const user = useUserStore().user
const {proxy} = getCurrentInstance()
const language = useStorage('language', 0)
const form = ref({
  gender: '0',
  chinese:'0',
  cptVisaInfoBos: [],
  email: user?.email,
})
const show = ref(false)
const codeloading = ref(false)
const showR = ref(false)
const title = ref('')
const countrys = ref([])
const mnaList = ref([])
const cptId = ref('')
const rules = ref(
    {
      nationality: [{required: true, trigger: 'change', message: language.value == 0 ? '请选择' : 'Please choose'},],
      name: [{required: true, trigger: 'blur', message: language.value == 0 ? '请输入' : 'Please enter'},],
      email: [{required: true, trigger: 'blur', message: language.value == 0 ? '请输入' : 'Please enter'},],
      birth: [{required: true, trigger: 'change', message: language.value == 0 ? '请选择' : 'Please choose'},],
      passportNo: [{required: true, trigger: 'blur', message: language.value == 0 ? '请输入' : 'Please enter'},],
      passportCopy: [{required: true, trigger: 'blur', message: language.value == 0 ? '请上传' : 'Please Upload'},],
      arrival: [{required: true, trigger: 'change', message: language.value == 0 ? '请选择' : 'Please choose'},],
      departure: [{required: true, trigger: 'change', message: language.value == 0 ? '请选择' : 'Please choose'},],
    })
const open = (params) => {
  show.value = true
  title.value = params.title
  cptId.value = params.cptId
  if (!cptId.value) {
    proxy.$modal.msgError('参数有误');
  }
  form.value = {
    gender: '0',
    chinese:'0',
    cptVisaInfoBos: [],
    email: user?.email,
    userId: user?.userId,
    cptId: params.cptId
  }
  getCountryList()
  getMNAList()
  // getVisa()
}
defineExpose({
  open,
  reOpen: (id) => {
    show.value = true
    showR.value = false
    title.value = language.value == 0 ? '邀请函申请' : 'Visa Invitation Letter '

    getCountryList()
    getMNAList()
    getInvitation(id).then((res => {
      form.value = res.data
      cptId.value = res.data.cptId
      delete form.value.id
    })).then(() => {
      getVisaInfoList(id).then(res => {
        _.each(res.data, (item) => {
          delete item.id
        })

        if (form.value.invitationFile) {
          form.value.invitationFileArr = JSON.parse(form.value.invitationFile)
        }

        form.value.cptVisaInfoBos = res.data
      })
    })
  }
})

function getVisa() {
  getVisaInfo({
    userId: user.userId,
    cptId: cptId.value
  }).then(res => {
    if (res.data && res.data.status != 2) {
      showR.value = true
      form.value = res.data
    } else {
      showR.value = false
    }
  })
}

function getCountryList() {
  countryList().then(res => {
    countrys.value = res.data
  })
}

function getMNAList() {
  associationList().then(res => {
    mnaList.value = res.data
  })
}

const submit = () => {
  console.log(form.value)
  if (form.value.email?.indexOf('@') == -1) {
    ElMessage.warning(language.value == 0 ? '请填写正确的邮箱' : 'Invalid Emaill Address!')
    return
  }
  if (form.value.applicatType == 5 && !form.value.remarks) {
    ElMessage.warning('Please specify Applicant Type')
    return
  }
  if (form.value.position == 3 && !form.value.remarks1) {
    ElMessage.warning('Please specify position')
    return
  }
  for (let row of form.value.cptVisaInfoBos) {
    if (!row.position) {
      ElMessage.warning(`Please specify ${row.fristName}'s position`)
      return
    }
    if (row.position == 'other' && !row.remarks) {
      ElMessage.warning(`Please specify ${row.fristName}'s position`)
      return;
    }
  }

  if (form.value.files && Array.isArray(form.value.files)) {
    form.value.files = form.value.files[0]?.url
  }
  if (form.value.invitationFileArr) {
    form.value.invitationFile = JSON.stringify(form.value.invitationFileArr)
  }

  proxy.$refs.iformRef.validate(valid => {
    if (valid) {
      ElMessageBox.confirm(
          language.value == 0 ? '请确认信息正确并提交吗?' : 'Please confirm that the information is correct and submit it',
          language.value == 0 ? '提示' : 'Tips', {
            confirmButtonText: language.value == 0 ? '确定' : 'Confirm',
            cancelButtonText: language.value == 0 ? '取消' : 'Cancel',
            type: 'warning'
          }).then(() => {
        form.value.cptId = cptId.value
        addInvitation(form.value).then((res) => {
          if (res.data == -200) {
            ElMessage.error(language.value == 0 ? '邮箱验证码不正确' : 'Invalid email verification code')
          } else {
            ElMessage.success(language.value == 0 ? '提交成功' : 'Successfully!')
            showR.value = true
            emit('refresh')
          }
        })
      })
    }
  })
}

const getPassportInfo = (res) => {
  if (res.code == 200) {
    let obj = {
      position: '',
      lastName: res.data.surname,
      fristName: res.data.givenName,
      sex: res.data.sex,
      birthday: res.data.birth?.slice(0, 10),
      nationality: res.data.nationality,
      passportNo: res.data.code,
      issueDate: res.data.issueDate?.slice(0, 10),
      expiryDate: res.data.validToDate?.slice(0, 10),
      passportCopy: res.data.pic
    }
    form.value.cptVisaInfoBos.push(obj)
  } else {
    if (res.data) {
      ElMessage.error(res.data.code)

      let obj = {
        position: '',
        lastName: '',
        fristName: '',
        sex: '',
        birthday: '',
        nationality: '',
        passportNo: '',
        issueDate: '',
        expiryDate: '',
        passportCopy: res.data.pic
      }
      form.value.cptVisaInfoBos.push(obj)
    } else {
      ElMessage.error(res.msg)
    }
  }
}

function delPassportInfo(index) {
  form.value.cptVisaInfoBos.splice(index, 1)
}

function sendEmail() {
  if (!form.value.email) {
    ElMessage.error(language.value == 0 ? '请输入邮箱' : 'Please enter contact Email')
    return
  }
  if (!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(form.value.email)) {
    ElMessage.error(language.value == 0 ? '请输入正确的邮箱' : 'Please enter the correct contact email')
    return
  }
  codeloading.value = true
  sendVisaCode({email: form.value.email}).then(res => {
    codeloading.value = false
    if (res.code == 200) {
      ElMessage.success(language.value == 0 ? '发送成功,请前往邮箱查看' : 'Send success, please check your email')
    } else {
      ElMessage.error(res.msg)
    }
  })
}

function changeApplicatType() {
  _.each(form.value.cptVisaInfoBos || [], (item) => {
    item.position = ''
  })
}

</script>

<style lang="scss" scoped>
.red {
  color: red !important;
}

:deep(.el-upload--picture-card) {
  --el-upload-picture-card-size: 60px;
}

.tip {
  font-size: 12px;
}

.boxInvitation {
  width: 96%;
  margin: 20px auto 0;
}

h4 {
  font-size: 15px;
  line-height: 1.6;
}

.cptVisaInfoBosTable {
  padding: 10px;
  margin-bottom: 20px;
  border: 1px dashed #ebeef5;

  :deep(.el-table .el-table__header-wrapper th) {
    font-size: 12px;
  }
}

.wrap-item {
  flex-wrap: wrap;
  display: block;
}

.codeBtn {
  background-color: #0540EC !important;
  color: #fff !important;

}
</style>