<template>
  <view class="content">
    <view class="card">
      <u--form labelPosition="left" :model="form" :rules="rules" ref="form" labelWidth="auto">
        <u-form-item label="照片" prop="userPhoto" borderBottom required labelPosition="top" labelWidth="auto">
          <view class="mt-10 w100">
            <u-upload :fileList="form.userPhoto" :maxCount="1" @afterRead="fnUserPhotoRead"
                      @delete="fnUserPhotoDelete" multiple previewFullImage></u-upload>
          </view>
        </u-form-item>
        <u-form-item label="单位名称" prop="NAME" borderBottom required>
          <u--input v-model="RELEVANT_UNIT_NAME" :disabled="true" border="none" inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="部门" prop="NAME" borderBottom required>
          <u--input v-model="RELEVANT_UNIT_NAME" :disabled="true" border="none" inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="姓名" prop="NAME" borderBottom required>
          <u--input v-model="form.NAME" border="none" inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="性别" prop="SEX_NAME" borderBottom required>
          <u--input v-model="form.SEX_NAME" border="none" disabled disabledColor="#ffffff" inputAlign="right">
          </u--input>
        </u-form-item>
        <u-form-item label="出生年月" prop="DATE_OF_BIRTH" borderBottom required>
          <u--input v-model="form.DATE_OF_BIRTH" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="年龄" prop="AGE" borderBottom required>
          <u--input v-model="form.AGE" border="none" disabled disabledColor="#ffffff" inputAlign="right">
          </u--input>
        </u-form-item>
        <u-form-item label="身份证" prop="CARD_ID" borderBottom required>
          <u--input v-model="form.CARD_ID" border="none" @blur="fnCardIdDisassembly" inputAlign="right">
          </u--input>
        </u-form-item>
        <u-form-item label="身份证照片(录入身份证正、反彩色照片)" prop="userCardIDFileList" borderBottom required
                     labelPosition="top" labelWidth="auto">
          <view class="mt-10 w100">
            <u-upload :fileList="form.userCardIDFileList" @afterRead="fnUserCardIDAttachmentsRead"
                      @delete="fnUserCardIDAttachmentsDelete" multiple :maxCount="2" previewFullImage></u-upload>
            <view class="tip">
              温馨提示：用户需上传身份证正反面（身份证照片数量需≥2张），才能进行人员培训
            </view>
          </view>
        </u-form-item>

        <u-form-item label="民族" prop="NATIONALITY_NAME" borderBottom required @click="fnShowMizuOfEducation">
          <u--input v-model="form.NATIONALITY_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>

        <u-form-item label="婚姻状况" prop="MARITALSTATUS_NAME" borderBottom required
                     @click="fnShowMaritalContract">
          <u--input v-model="form.MARITALSTATUS_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="政治面貌" prop="POLITICAL_STATUS_NAME" borderBottom required
                     @click="fnShowPoliticalStatusEducation">
          <u--input v-model="form.POLITICAL_STATUS_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="入党时间" v-if="form.POLITICAL_STATUS_NAME === '中共党员'" prop="POLITICAL_TIME"
                     borderBottom required @click="fnShowPoliticalTimeEducation">
          <u--input v-model="form.POLITICAL_TIME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="户口所在地" prop="HKLOCAL" borderBottom labelPosition="top" labelWidth="auto">
          <u--textarea v-model="form.HKLOCAL" border="none" autoHeight></u--textarea>
        </u-form-item>
        <u-form-item label="现住址" prop="ADDRESS" borderBottom labelPosition="top" labelWidth="auto">
          <u--textarea v-model="form.ADDRESS" border="none" autoHeight></u--textarea>
        </u-form-item>
        <u-form-item label="联系电话" prop="PHONE" borderBottom required>
          <u--input v-model="form.PHONE" border="none" :disabled="true" inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="文化程度" prop="DEGREE_OF_EDUCATION_NAME" borderBottom required
                     @click="fnShowDegreeOfEducation">
          <u--input v-model="form.DEGREE_OF_EDUCATION_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <!--   @click="fnShowPersonWorkType"     -->
        <!--        <u-form-item label="工种" prop="PERSON_WORK_TYPE" borderBottom required>-->
        <!--          &lt;!&ndash;     20230612改成输入框     &ndash;&gt;-->
        <!--          <u&#45;&#45;input v-model="form.PERSON_WORK_TYPE" border="none" disabledColor="#ffffff" inputAlign="right"></u&#45;&#45;input>-->
        <!--        </u-form-item>-->
        <!--				<u-form-item label="本企业从业开始日期" prop="CORP_START_DATE" borderBottom required-->
        <!--					@click="fnShowEnterpriseStartingDateOfEmployment">-->
        <!--					<u&#45;&#45;input v-model="form.CORP_START_DATE" border="none" disabled disabledColor="#ffffff"-->
        <!--						inputAlign="right"></u&#45;&#45;input>-->
        <!--				</u-form-item>-->
        <!--     @click="fnShowPost"    -->
        <u-form-item label="岗位名称" prop="POST_ID" borderBottom required>
          <!--     20230612改成输入框     -->
          <u--input v-model="form.POST_ID" border="none" disabledColor="#ffffff" inputAlign="right">
          </u--input>
        </u-form-item>
        <!--				<u-form-item label="本岗位从业开始日期" prop="ENTRY_DATE" borderBottom required-->
        <!--					@click="fnShowPostStartingDateOfEmployment">-->
        <!--					<u&#45;&#45;input v-model="form.ENTRY_DATE" border="none" disabled disabledColor="#ffffff"-->
        <!--						inputAlign="right"></u&#45;&#45;input>-->
        <!--				</u-form-item>-->
        <u-form-item label="是否缴纳社保" prop="IS_SOCIAL_NAME" borderBottom required
                     @click="fnShowIsSocial">
          <u--input v-model="form.IS_SOCIAL_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="社会保障号码" prop="SOCIAL_NUMBER" borderBottom required v-if="form.IS_SOCIAL==='1'">
          <u--input v-model="form.SOCIAL_NUMBER" border="none" inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="社保卡照片" prop="socialFileList" borderBottom required labelPosition="top"
                     labelWidth="auto" v-if="form.IS_SOCIAL==='1'">
          <view class="mt-10 w100">
            <u-upload :fileList="form.socialFileList" @afterRead="fnSocialAttachmentsRead"
                      @delete="fnSocialAttachmentsDelete" multiple :maxCount="2" previewFullImage></u-upload>
          </view>
        </u-form-item>
        <u-form-item label="是否缴纳保险" prop="IS_BF_NAME" borderBottom required
                     @click="fnShowInjuryInsurance">
          <u--input v-model="form.IS_BF_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="是否签署劳动合同" prop="IS_SIGN_LABOR_NAME" borderBottom required
                     @click="fnShowLaborContract">
          <u--input v-model="form.IS_SIGN_LABOR_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="劳动合同附件" prop="contractFile" borderBottom required v-if="form.IS_SIGN_LABOR==='1'"
                     labelPosition="top" labelWidth="auto">
          <view class="mt-10 w100">
            <u-upload :fileList="form.contractFile"
                      @afterRead="fnAttachmentToLaborContractAfterRead" @delete="fnAttachmentToLaborContractDelete"
                      multiple :maxCount="4" previewFullImage></u-upload>
          </view>
        </u-form-item>
        <u-form-item label="是否按期缴纳工伤保险" prop="IS_INJURIES_PAY_NAME" borderBottom required
                     @click="fnShowEmploymentInjuryInsurance">
          <u--input v-model="form.IS_INJURIES_PAY_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="工伤保险有效期" v-if="form.IS_INJURIES_PAY==='1'" prop="IS_INJURIES_PAY_TIME" borderBottom
                     required @click="fnShowInjuriesPayTiemEducation">
          <u--input v-model="form.IS_INJURIES_PAY_TIME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="上传工伤保险凭证" prop="injuriesPayTiemFile" borderBottom required
                     v-if="form.IS_INJURIES_PAY==='1'" labelPosition="top" labelWidth="auto">
          <view class="mt-10 w100">
            <u-upload :fileList="form.injuriesPayTiemFile"
                      @afterRead="fnInjuriesPayTiemAttachmentsAfterRead" @delete="fnInjuriesPayTiemAttachmentsDelete"
                      multiple :maxCount="4" previewFullImage></u-upload>
          </view>
        </u-form-item>


        <u-form-item label="是否缴纳商业保险" prop="ISPAY_NAME" borderBottom required
                     @click="fnShowEmploymentPayInsurance">
          <u--input v-model="form.ISPAY_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="商业保险单号" v-if="form.ISPAY==='1'" prop="ISPAY_NUMBER" borderBottom required>
          <u--input v-model="form.ISPAY_NUMBER" border="none" inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="保险附件" prop="insuranceFile" borderBottom required v-if="form.ISPAY==='1'"
                     labelPosition="top" labelWidth="auto">
          <view class="mt-10 w100">
            <u-upload :fileList="form.insuranceFile" @afterRead="fnInsuranceAttachmentsAfterRead2"
                      @delete="fnInsuranceAttachmentsDelete" multiple :maxCount="4" previewFullImage></u-upload>
          </view>
        </u-form-item>
        <u-form-item label="是否参加三级安全培训" prop="IS_LEVEL_THREE_NAME" borderBottom required
                     @click="fnShowSafetyTraining">
          <u--input v-model="form.IS_LEVEL_THREE_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="三级安全培训图片" prop="safetytraining" borderBottom required
                     v-if="form.IS_LEVEL_THREE==='1'"
                     labelPosition="top" labelWidth="auto">
          <view class="mt-10 w100">
            <u-upload :fileList="form.safetytraining" @afterRead="fnSafetyTrainingAfterRead2"
                      @delete="fnSafetyTrainingAttachmentsDelete" multiple :maxCount="4" previewFullImage></u-upload>
          </view>
        </u-form-item>
        <!-- <u-form-item label="安全告知培训是否合格" prop="IS_SAFETY_TELL_NAME" borderBottom required
                     @click="fnShowAdmissionSafetyNotification">
          <u--input v-model="form.IS_SAFETY_TELL_NAME" border="none" disabled
                    disabledColor="#ffffff" inputAlign="right"></u--input>
        </u-form-item>
        <u-form-item label="安全告知培训合格日期"
                     v-if ="form.IS_SAFETY_TELL === '1'" prop="IS_SAFETY_TIME" borderBottom required
                     @click="fnShowSafetyTimeTraining">
          <u--input v-model="form.IS_SAFETY_TIME" border="none" disabled disabledColor="#ffffff" inputAlign="right"></u--input>
        </u-form-item> -->
        <!--				<u-form-item label="身体状况是否适应本岗位工作" prop="IS_BODY_ADAPT_NAME" borderBottom required-->
        <!--					@click="fnShowAdaptToTheJobPosition">-->
        <!--					<u&#45;&#45;input v-model="form.IS_BODY_ADAPT_NAME" border="none" disabled disabledColor="#ffffff"-->
        <!--						inputAlign="right"></u&#45;&#45;input>-->
        <!--				</u-form-item>-->
        <!--				<u-form-item label="是否特殊工种" prop="IS_SPECIAL_JOB_NAME" borderBottom required-->
        <!--					@click="fnShowSpecialTypeOfWork">-->
        <!--					<u&#45;&#45;input v-model="form.IS_SPECIAL_JOB_NAME" border="none" disabled disabledColor="#ffffff"-->
        <!--						inputAlign="right"></u&#45;&#45;input>-->
        <!--				</u-form-item>-->
        <u-form-item label="是否流动人员" prop="ISFLOW_NAME" borderBottom required
                     @click="fnShowFloatingPersonnel">
          <u--input v-model="form.ISFLOW_NAME" border="none" disabled disabledColor="#ffffff"
                    inputAlign="right"></u--input>
        </u-form-item>
      </u--form>
      <u-picker :show="showDegreeOfEducation" :columns="degreeOfEducationColumns" keyName="NAME"
                @confirm="fnDegreeOfEducationConfirm" @cancel="fnShowDegreeOfEducation"></u-picker>

      <u-datetime-picker :show="showEnterpriseStartingDateOfEmployment"
                         v-model="enterpriseStartingDateOfEmploymentValue" mode="date"
                         @confirm="fnEnterpriseStartingDateOfEmploymentConfirm"
                         @cancel="fnShowEnterpriseStartingDateOfEmployment"></u-datetime-picker>
      <u-datetime-picker :show="showPostStartingDateOfEmployment" v-model="postStartingDateOfEmploymentValue"
                         mode="date" @confirm="fnPostStartingDateOfEmploymentConfirm"
                         @cancel="fnShowPostStartingDateOfEmployment"></u-datetime-picker>

      <u-picker :show="showIsSocial" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]" keyName="name"
                @confirm="fnIsSocialConfirm" @cancel="fnShowIsSocial"></u-picker>

      <u-picker :show="showLaborContract" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]" keyName="name"
                @confirm="fnLaborContractConfirm" @cancel="fnShowLaborContract"></u-picker>
      <u-picker :show="showInsurance" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]"
                keyName="name" @confirm="fnEInsuranceConfirm" @cancel="fnShowEmploymentInjuryInsurance">
      </u-picker>
      <u-picker :show="showEmploymentInjuryInsurance" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]"
                keyName="name" @confirm="fnEmploymentInjuryInsuranceConfirm" @cancel="fnShowEmploymentInjuryInsurance">
      </u-picker>
      <u-picker :show="showEmploymentPayInsurance" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]"
                keyName="name" @confirm="fnEmploymentPayInsuranceConfirm" @cancel="fnShowEmploymentPayInsurance">
      </u-picker>
      <u-picker :show="showSafetyTraining" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]"
                keyName="name" @confirm="fnSafetyTrainingConfirm" @cancel="fnShowSafetyTraining"></u-picker>
      <u-picker :show="showAdmissionSafetyNotification" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]"
                keyName="name" @confirm="fnAdmissionSafetyNotificationConfirm"
                @cancel="fnShowAdmissionSafetyNotification"></u-picker>
      <u-picker :show="showAdaptToTheJobPosition" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]"
                keyName="name" @confirm="fnAdaptToTheJobPositionConfirm" @cancel="fnShowAdaptToTheJobPosition">
      </u-picker>
      <u-picker :show="showSpecialTypeOfWork" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]"
                keyName="name" @confirm="fnSpecialTypeOfWorkConfirm" @cancel="fnShowSpecialTypeOfWork"></u-picker>
      <u-picker :show="showFloatingPersonnel" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]"
                keyName="name" @confirm="fnFloatingPersonnelConfirm" @cancel="fnShowFloatingPersonnel"></u-picker>

      <!-- 安全告知培训时间 -->
      <u-datetime-picker :show="showSafetyTimeTraining" v-model="safetyDateOfEmploymentValue" mode="date"
                         @confirm="fnSafetyTimeTrainingConfirm" @cancel="fnShowSafetyTimeTraining"></u-datetime-picker>
      <!-- 民族 -->
      <u-picker :show="showMizuOfEducation" :columns="degreeOfMizuColumns" keyName="NAME"
                @confirm="fnDegreeOfMizuConfirm" @cancel="fnShowMizuOfEducation"></u-picker>
      <!-- 婚姻 状况 -->
      <u-picker :show="showMaritalContract" :columns="[[{name: '已婚', id: '1'}, {name: '未婚', id: '0'}]]"
                keyName="name" @confirm="fnMaritalContractConfirm" @cancel="fnShowMaritalContract"></u-picker>
      <!-- 政治面貌 -->
      <u-picker :show="showPoliticalStatus" :columns="degreeOfPoliticalStatus" keyName="NAME"
                @confirm="fnShowPoliticalStatusConfirm" @cancel="fnShowPoliticalStatusEducation"></u-picker>
      <!-- 入党时间 -->
      <u-datetime-picker :show="showPoliticalTime" v-model="POLITICAL_TIME" mode="date"
                         @confirm="fnShowPoliticalTimeConfirm"
                         @cancel="fnShowPoliticalTimeEducation"></u-datetime-picker>
      <!--工伤报销有效时间 -->
      <u-datetime-picker :show="showInjuriesPayTiem" v-model="IS_INJURIES_PAY_TIME" mode="date"
                         @confirm="fnShowInjuriesPayTiemConfirm"
                         @cancel="fnShowInjuriesPayTiemEducation"></u-datetime-picker>
      <view class="mt-10">
        <u-button type="primary" text="保 存" @click="$u.debounce(fnSubmit, 1000,true)"></u-button>
      </view>
    </view>
  </view>
</template>

<script>
import {
  getCertificateInformationList,
  getDataDictionary,
  getDeptTree,
  getIDCardDeduplication,
  getPhoneNumberDeduplication,
  getUserInfo,
  setRelatedPartyRegistration,
  setUploadAttachments,
  getEMPLOYMENTAPPLYMANAGEMENTID,
  getEmployedBy,
  removeUploadAttachments
} from "../../api";

export default {
  data() {
    return {
      showSafetyTimeTraining: false, //安全告知培训时间 下拉显示隐藏
      safetyDateOfEmploymentValue: new Date().toString(), //安全告知培训时间
      showPoliticalStatus: false, //政治面貌
      degreeOfPoliticalStatus: [], //政治面貌
      showPoliticalTime: false, //入党时间
      socialFile: [], //社保卡照片
      showInjuriesPayTiem: false, //工伤保险有效期
      IS_INJURIES_PAY_TIME: new Date().toString(),
      injuriesPayTiemFile: [], //工伤保险有效凭证
      POLITICAL_TIME: new Date().toString(),
      RELEVANT_UNIT_NAME: '',
      CORPINFO_ID: '',
      showDegreeOfEducation: false,
      showMizuOfEducation: false,
      showMaritalContract: false,
      degreeOfEducationColumns: [],
      degreeOfMizuColumns: [],
      showPersonWorkType: false,
      personWorkTypeColumns: [],
      showPost: false,
      postColumns: [],
      showEnterpriseStartingDateOfEmployment: false,
      enterpriseStartingDateOfEmploymentValue: new Date().toString(),
      showPostStartingDateOfEmployment: false,
      postStartingDateOfEmploymentValue: new Date().toString(),
      showIsSocial: false,
      showLaborContract: false,
      showEmploymentInjuryInsurance: false,
      showInsurance: false,
      showEmploymentPayInsurance: false,
      showSafetyTraining: false,
      showAdmissionSafetyNotification: false,
      showAdaptToTheJobPosition: false,
      showSpecialTypeOfWork: false,
      showFloatingPersonnel: false,
      certificateInformationLength: 0,
      form: {
        IS_SAFETY_TIME: '', // 安全告知培训时间
        userCardIDFileList: [], //身份证正反照片
        POLITICAL_STATUS: '', // 政治面貌
        POLITICAL_STATUS_NAME: '', // 政治面貌
        POLITICAL_TIME: '', //入党时间
        socialFileList: [], //社保卡照片
        IS_INJURIES_PAY_TIME: '', // 工伤保险有效时间
        injuriesPayTiemFile: [], //工伤保险有效凭证
        ISPAY_NUMBER: '', //商业保险单号
        userPhoto: [],
        NAME: '',
        USERNAME: '',
        SEX: '',
        SEX_NAME: '',
        DATE_OF_BIRTH: '',
        AGE: '',
        CARD_ID: '',
        HKLOCAL: '',
        ADDRESS: '',
        PHONE: '',
        DEGREE_OF_EDUCATION: '',
        DEGREE_OF_EDUCATION_NAME: '',
        PERSON_WORK_TYPE: '',
        PERSON_WORK_TYPE_NAME: '',
        CORP_START_DATE: '',
        POST_ID: '',
        POST_NAME: '',
        ENTRY_DATE: '',
        SOCIAL_NUMBER: '',
        IS_SIGN_LABOR: '',
        IS_SIGN_LABOR_NAME: '',
        contractFile: [],
        ISPAY: '',
        ISPAY_NAME: '',
        imgDelKey: '',
        IS_BF: '',
        IS_BF_NAME: '',
        IS_INJURIES_PAY: '',
        IS_INJURIES_PAY_NAME: '',
        safetytraining: [],
        insuranceFile: [],
        IS_LEVEL_THREE: '',
        IS_LEVEL_THREE_NAME: '',
        IS_SAFETY_TELL: '',
        IS_SAFETY_TELL_NAME: '',
        IS_BODY_ADAPT: '',
        // IS_BODY_ADAPT_NAME: '',
        IS_SPECIAL_JOB: '',
        IS_SPECIAL_JOB_NAME: '',
        ISFLOW: '',
        ISFLOW_NAME: '',
        NATIONALITY_NAME: '',
        NATIONALITY: '',
        IS_SOCIAL: '',
        IS_SOCIAL_NAME: '',
        EMPLOYMENT_APPLY_MANAGEMENT_ID: ''
      },
      rules: {
        userPhoto: {
          type: 'array',
          required: true,
          message: '请上传照片',
          trigger: ['change']
        },
        NAME: {
          required: true,
          message: '请填写姓名',
          trigger: ['blur']
        },
        // SEX: {
        //   required: true,
        //   message: '请填写性别',
        //   trigger: ['blur']
        // },
        // DATE_OF_BIRTH: {
        //   required: true,
        //   message: '请填写出生年月',
        //   trigger: ['blur']
        // },
        // AGE: {
        //   required: true,
        //   message: '请填写年龄',
        //   trigger: ['blur']
        // },
        CARD_ID: [{
          required: true,
          message: '请填写身份证',
          trigger: ['blur']
        },
          {
            validator: (rule, value, callback) => {
              return uni.$u.test.idCard(value);
            },
            message: '身份证号格式不正确',
            trigger: ['blur'],
          },
        ],
        userCardIDFileList: {
          type: 'array',
          required: true,
          message: '请上传身份证照片',
          trigger: ['change']
        },
        // HKLOCAL: {
        // 	required: true,
        // 	message: '请填写户口所在地',
        // 	trigger: ['blur']
        // },
        // ADDRESS: {
        // 	required: true,
        // 	message: '请填写现住址',
        // 	trigger: ['blur']
        // },
        PHONE: [{
          required: true,
          message: '请填写联系电话',
          trigger: ['blur']
        },
          {
            validator: (rule, value, callback) => {
              return uni.$u.test.mobile(value);
            },
            message: '联系电话格式不正确',
            trigger: ['blur'],
          },
        ],
        NATIONALITY_NAME: {
          required: true,
          message: '请选择民族',
          trigger: ['change']
        },
        MARITALSTATUS_NAME: {
          required: true,
          message: '请选择婚姻状况',
          trigger: ['change']
        },
        POLITICAL_STATUS_NAME: {
          required: true,
          message: '请选择政治面貌',
          trigger: ['change']
        },
        POLITICAL_TIME: {
          required: true,
          message: '请选择入党时间',
          trigger: ['change']
        },
        DEGREE_OF_EDUCATION_NAME: {
          required: true,
          message: '请选择文化程度',
          trigger: ['change']
        },
        // PERSON_WORK_TYPE: {
        //   required: true,
        //   message: '请输入工种',
        //   trigger: ['change']
        // },
        // CORP_START_DATE: {
        // 	required: true,
        // 	message: '请选择本企业从业开始日期',
        // 	trigger: ['change']
        // },
        POST_ID: {
          required: true,
          message: '请选择岗位名称',
          trigger: ['blur']
        },
        // ENTRY_DATE: {
        // 	required: true,
        // 	message: '请选择本岗位从业开始日期',
        // 	trigger: ['change']
        // },
        SOCIAL_NUMBER: {
          required: true,
          message: '请填写社会保障号码',
          trigger: ['change']
        },
        socialFileList: {
          type: 'array',
          required: true,
          message: '请上传社保卡照片',
          trigger: ['change']
        },
        IS_SOCIAL_NAME: {
          required: true,
          message: '请选择是否缴纳社保',
          trigger: ['change']
        },
        IS_SIGN_LABOR_NAME: {
          required: true,
          message: '请选择是否签署劳动合同',
          trigger: ['change']
        },
        contractFile: {
          type: 'array',
          required: true,
          message: '请上传劳动合同附件',
          trigger: ['change']
        },
        IS_BF_NAME: {
          required: true,
          message: '请选择是否缴纳保险',
          trigger: ['change']
        }, IS_INJURIES_PAY_NAME: {
          required: true,
          message: '请选择是否按期缴纳工伤保险',
          trigger: ['change']
        },
        IS_INJURIES_PAY_TIME: {
          required: true,
          message: '请选择工伤保险有效期',
          trigger: ['change']
        },
        ISPAY_NUMBER: {
          required: true,
          message: '请输入商业保险单号',
          trigger: ['change']
        },
        injuriesPayTiemFile: {
          type: 'array',
          required: true,
          message: '请上传工伤保险凭证',
          trigger: ['change']
        },
        insuranceFile: {
          type: 'array',
          required: true,
          message: '请上传保险附件',
          trigger: ['change']
        },
        safetytraining: {
          type: 'array',
          required: true,
          message: '请上传三方安全培训图片',
          trigger: ['change']
        },
        IS_LEVEL_THREE_NAME: {
          required: true,
          message: '请选择是否参加三级安全培训',
          trigger: ['change']
        },
        IS_SAFETY_TELL_NAME: {
          required: false,
          message: '请选择安全告知培训是否合格',
          trigger: ['change']
        },
        IS_SAFETY_TIME: {
          required: false,
          message: '请选择安全告知培训合格日期',
          trigger: ['change']
        },
        // IS_BODY_ADAPT_NAME: {
        // 	required: true,
        // 	message: '请选择身体状况是否适应本岗位工作',
        // 	trigger: ['change']
        // },
        // IS_SPECIAL_JOB_NAME: {
        // 	required: true,
        // 	message: '请选择是否特殊工种',
        // 	trigger: ['change']
        // },
        ISFLOW_NAME: {
          required: true,
          message: '请选择是否流动人员',
          trigger: ['change']
        },
      }
    }
  },
  onShow(options) {
    this.getDataCertificateInformation()
  },
  onLoad(query) {
    this.CORPINFO_ID = query.CORPINFO_ID
    this.RELEVANT_UNIT_NAME = query.RELEVANT_UNIT_NAME
    this.fnGetDataDictionary('d7d80f08d73a4accbccf4fd3d8d1d867', 'degreeOfEducationColumns')
    this.fnGetDataDictionary('0a0e406f27f74ee698fe9979d25f62dd', 'degreeOfMizuColumns')
    this.fnGetDataDictionary('6351efdd12dc4730952e5d195718e252', 'degreeOfPoliticalStatus')

    // this.fnGetDataDictionary('09e36ac01e9540f8bc84eab1c1a78754', 'postColumns')
    // this.fnGetDataDictionary('55484e491a5e442d839c4595380713ec', 'personWorkTypeColumns')
    this.fnGetData()
    this.getDept()
  },
  computed: {
    userInfo() {
      return this.$store.getters.getUserInfo
    }
  },
  methods: {
    async getDept() {
      let resData = await getDeptTree({
        CORPINFO_ID: this.userInfo.CORPINFO_ID,
      })
      console.info(resData)
    },
    async fnGetData() {
      let resData = await getUserInfo({
        CORPINFO_ID: this.userInfo.CORPINFO_ID,
      })
      this.form = {
        ...this.form,
        ...resData.pd
      }
      this.form.PHONE = this.form.USERNAME
      this.fnCardIdDisassembly(this.form.CARD_ID)
      console.log(this.form)
      // 转换数据
      if (this.form.IS_SOCIAL === '0') {
        this.form.IS_SOCIAL_NAME = '否'
      } else if (this.form.IS_SOCIAL === '1') {
        this.form.IS_SOCIAL_NAME = '是'
      }
      if (this.form.MARITALSTATUS === '0') {
        this.form.MARITALSTATUS_NAME = '未婚'
      } else if (this.form.MARITALSTATUS === '1') {
        this.form.MARITALSTATUS_NAME = '已婚'
      }
      if (this.form.IS_SIGN_LABOR === '0') {
        this.form.IS_SIGN_LABOR_NAME = '否'
      } else if (this.form.IS_SIGN_LABOR === '1') {
        this.form.IS_SIGN_LABOR_NAME = '是'
      }
      if (this.form.IS_BF === '0') {
        this.form.IS_BF_NAME = '否'
      } else if (this.form.IS_BF === '1') {
        this.form.IS_BF_NAME = '是'
      }
      if (this.form.IS_INJURIES_PAY === '0') {
        this.form.IS_INJURIES_PAY_NAME = '否'
      } else if (this.form.IS_INJURIES_PAY === '1') {
        this.form.IS_INJURIES_PAY_NAME = '是'
      }
      if (this.form.IS_LEVEL_THREE === '0') {
        this.form.IS_LEVEL_THREE_NAME = '否'
      } else if (this.form.IS_LEVEL_THREE === '1') {
        this.form.IS_LEVEL_THREE_NAME = '是'
      }
      if (this.form.IS_SAFETY_TELL === '0') {
        this.form.IS_SAFETY_TELL_NAME = '否'
      } else if (this.form.IS_SAFETY_TELL === '1') {
        this.form.IS_SAFETY_TELL_NAME = '是'
      }
      // if (this.form.IS_BODY_ADAPT === '0') {
      // 	this.form.IS_BODY_ADAPT_NAME = '否'
      // } else if (this.form.IS_BODY_ADAPT === '1') {
      // 	this.form.IS_BODY_ADAPT_NAME = '是'
      // }
      // if (this.form.IS_SPECIAL_JOB === '0') {
      // 	this.form.IS_SPECIAL_JOB_NAME = '否'
      // } else if (this.form.IS_SPECIAL_JOB === '1') {
      // 	this.form.IS_SPECIAL_JOB_NAME = '是'
      // }
      if (this.form.ISFLOW === '0') {
        this.form.ISFLOW_NAME = '否'
      } else if (this.form.ISFLOW === '1') {
        this.form.ISFLOW_NAME = '是'
      }
      this.$set(this.form, 'userPhoto', [{
        url: this.$filePath + resData.userPhotoFile[0].FILEPATH,
        id: resData.userPhotoFile[0].IMGFILES_ID
      }])
      for (let i = 0; i < resData.userCardIDPhotoFile.length; i++) {
        let ogj = {}
        ogj.url = this.$filePath + resData.userCardIDPhotoFile[i].FILEPATH
        ogj.id = resData.userCardIDPhotoFile[i].IMGFILES_ID
        this.form.userCardIDFileList.push(ogj)
      }
      for (let i = 0; i < resData.socialPhotoFile.length; i++) {
        let ogj = {}
        ogj.url = this.$filePath + resData.socialPhotoFile[i].FILEPATH
        ogj.id = resData.socialPhotoFile[i].IMGFILES_ID
        this.form.socialFileList.push(ogj)
      }
      this.getDataCertificateInformation()
    },
    async getDataCertificateInformation() {
      let resData = await getCertificateInformationList({
        showCount: 9999,
        currentPage: 1,
      });
      // this.certificateInformationLength = resData.varList.length
      // if (resData.varList.length > 0) {
      // 	this.form.IS_SPECIAL_JOB = '1'
      // 	this.form.IS_SPECIAL_JOB_NAME = '是'
      // } else {
      // 	this.form.IS_SPECIAL_JOB = '0'
      // 	this.form.IS_SPECIAL_JOB_NAME = '否'
      // }
    },
    async fnIDCardDeduplication(CARD_ID = this.form.CARD_ID) {
      let resData = await getIDCardDeduplication({
        CARD_ID
      })
      if (resData.pd) {
        uni.$u.toast('身份证号重复')
        return true
      }
      return false
    },
    async fnPhoneNumberDeduplication(PHONE = this.form.PHONE) {
      if (uni.$u.test.mobile(PHONE)) {
        let resData = await getPhoneNumberDeduplication({
          PHONE
        })
        if (resData.pd) {
          uni.$u.toast('联系电话重复')
          return true
        }
        return false
      }
    },
    async fnCardIdDisassembly(event) {
      if (uni.$u.test.idCard(event)) {
        if (await this.fnIDCardDeduplication()) return
        this.form.DATE_OF_BIRTH = event.substring(6, 10) + "-" + event.substring(10, 12) + "-" + event
            .substring(12, 14);
        if (parseInt(event.substring(17, 1)) % 2 === 1) {
          this.form.SEX = "0";
          this.form.SEX_NAME = "男";
        } else {
          this.form.SEX = "1";
          this.form.SEX_NAME = "女";
        }
        let myDate = new Date();
        let month = myDate.getMonth() + 1;
        let day = myDate.getDate();
        let age = myDate.getFullYear() - event.substring(6, 10) - 1;
        if (event.substring(10, 12) < month || event.substring(10, 12) === month && event.substring(12,
            14) <= day) {
          age++;
        }
        this.form.AGE = age;
      }
    },
    async fnGetDataDictionary(DICTIONARIES_ID, list) {
      let resData = await getDataDictionary({
        DICTIONARIES_ID
      })
      this[list] = [resData.list]
    },
    fnShowDegreeOfEducation() {
      this.showDegreeOfEducation = !this.showDegreeOfEducation
    },
    fnDegreeOfEducationConfirm(e) {
      this.form.DEGREE_OF_EDUCATION = e.value[0].BIANMA
      this.form.DEGREE_OF_EDUCATION_NAME = e.value[0].NAME
      this.fnShowDegreeOfEducation()
    },
    fnShowMizuOfEducation() {
      this.showMizuOfEducation = !this.showMizuOfEducation
    },
    fnDegreeOfMizuConfirm(e) {
      this.form.NATIONALITY = e.value[0].BIANMA
      this.form.NATIONALITY_NAME = e.value[0].NAME
      this.fnShowMizuOfEducation()
    },
    fnShowPersonWorkType() {
      this.showPersonWorkType = !this.showPersonWorkType
    },
    /*fnPersonWorkTypeConfirm(e) {
      this.form.PERSON_WORK_TYPE = e.value[0].BIANMA
      this.form.PERSON_WORK_TYPE_NAME = e.value[0].NAME
      this.fnShowPersonWorkType()
    },*/
    fnShowPost() {
      this.showPost = !this.showPost
    },
    /*fnPostConfirm(e) {
      this.form.POST_ID = e.value[0].BIANMA
      this.form.POST_NAME = e.value[0].NAME
      this.fnShowPost()
    },*/
    fnShowEnterpriseStartingDateOfEmployment() {
      this.showEnterpriseStartingDateOfEmployment = !this.showEnterpriseStartingDateOfEmployment
    },
    fnEnterpriseStartingDateOfEmploymentConfirm(event) {
      this.enterpriseStartingDateOfEmploymentValue = event.value
      this.fnShowEnterpriseStartingDateOfEmployment()
      this.form.CORP_START_DATE = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
    },
    fnShowPostStartingDateOfEmployment() {
      this.showPostStartingDateOfEmployment = !this.showPostStartingDateOfEmployment
    },
    fnPostStartingDateOfEmploymentConfirm(event) {
      this.postStartingDateOfEmploymentValue = event.value
      this.fnShowPostStartingDateOfEmployment()
      this.form.ENTRY_DATE = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
    },
    fnShowLaborContract() {
      this.showLaborContract = !this.showLaborContract
    },
    fnShowIsSocial() {
      this.showIsSocial = !this.showIsSocial
    },
    fnLaborContractConfirm(e) {
      this.form.IS_SIGN_LABOR = e.value[0].id
      this.form.IS_SIGN_LABOR_NAME = e.value[0].name
      this.fnShowLaborContract()
    },
    fnIsSocialConfirm(e) {
      this.form.IS_SOCIAL = e.value[0].id
      this.form.IS_SOCIAL_NAME = e.value[0].name
      this.fnShowIsSocial()
    },


    fnShowMaritalContract() {
      this.showMaritalContract = !this.showMaritalContract
    },
    fnMaritalContractConfirm(e) {
      console.info(e)
      this.form.MARITALSTATUS = e.value[0].id
      this.form.MARITALSTATUS_NAME = e.value[0].name
      this.fnShowMaritalContract()
    },

    fnShowEmploymentInjuryInsurance() {
      this.showEmploymentInjuryInsurance = !this.showEmploymentInjuryInsurance
    },
    fnShowInjuryInsurance() {
      this.showInsurance = !this.showInsurance
    },
    fnShowEmploymentPayInsurance() {
      this.showEmploymentPayInsurance = !this.showEmploymentPayInsurance
    },
    fnEInsuranceConfirm(e) {
      this.form.IS_BF = e.value[0].id
      this.form.IS_BF_NAME = e.value[0].name
      this.fnShowInjuryInsurance()
    },
    fnEmploymentInjuryInsuranceConfirm(e) {
      this.form.IS_INJURIES_PAY = e.value[0].id
      this.form.IS_INJURIES_PAY_NAME = e.value[0].name
      this.fnShowEmploymentInjuryInsurance()
    },
    fnEmploymentPayInsuranceConfirm(e) {
      this.form.ISPAY = e.value[0].id
      this.form.ISPAY_NAME = e.value[0].name
      this.fnShowEmploymentPayInsurance()
    },
    fnUserPhotoRead(event) {
      console.log(event.file)
      for (let i = 0; i < event.file.length; i++) {
        this.form.userPhoto.push(event.file[i])
      }
    },
    fnUserPhotoDelete(event) {
      var id = this.form.userPhoto[event.index].id
      this.form.imgDelKey = this.form.imgDelKey + id + ','
      this.form.userPhoto.splice(event.index, 1)
    },
    fnAttachmentToLaborContractAfterRead(event) {
      for (let i = 0; i < event.file.length; i++) {
        this.form.contractFile.push(event.file[i])
      }
    },
    fnAttachmentToLaborContractDelete(event) {
      this.form.contractFile.splice(event.index, 1)
    },
    fnSafetyTrainingAfterRead2(event) {
      for (let i = 0; i < event.file.length; i++) {
        this.form.safetytraining.push(event.file[i])
      }
    },
    fnSafetyTrainingAttachmentsDelete(event) {
      this.form.safetytraining.splice(event.index, 1)
    },
    fnInsuranceAttachmentsAfterRead2(event) {
      for (let i = 0; i < event.file.length; i++) {
        this.form.insuranceFile.push(event.file[i])
      }
    },
    fnInsuranceAttachmentsDelete(event) {
      this.form.insuranceFile.splice(event.index, 1)
    },
    fnShowSafetyTraining() {
      this.showSafetyTraining = !this.showSafetyTraining
    },
    fnSafetyTrainingConfirm(e) {
      this.form.IS_LEVEL_THREE = e.value[0].id
      this.form.IS_LEVEL_THREE_NAME = e.value[0].name
      this.fnShowSafetyTraining()
    },
    // 安全告知时间
    fnShowSafetyTimeTraining() {
      this.showSafetyTimeTraining = !this.showSafetyTimeTraining
    },
    fnSafetyTimeTrainingConfirm(event) {
      this.safetyDateOfEmploymentValue = event.value
      this.fnShowSafetyTimeTraining()
      this.form.IS_SAFETY_TIME = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
    },
    // 安全告知培训是否合格
    fnShowAdmissionSafetyNotification() {
      this.showAdmissionSafetyNotification = !this.showAdmissionSafetyNotification
    },
    fnAdmissionSafetyNotificationConfirm(e) {
      this.form.IS_SAFETY_TELL = e.value[0].id
      this.form.IS_SAFETY_TELL_NAME = e.value[0].name
      this.fnShowAdmissionSafetyNotification()
    },
    fnShowAdaptToTheJobPosition() {
      this.showAdaptToTheJobPosition = !this.showAdaptToTheJobPosition
    },
    fnInsuranceAttachmentsAfterRead(event) {
      for (let i = 0; i < event.file.length; i++) {
        this.form.insuranceFile.push(event.file[i])
      }
    },
    // 身份证正反照片
    fnUserCardIDAttachmentsRead(event) {
      for (let i = 0; i < event.file.length; i++) {
        this.form.userCardIDFileList.push(event.file[i])
      }
    },
    fnUserCardIDAttachmentsDelete(event) {
      var id = this.form.userCardIDFileList[event.index].id
      this.form.imgDelKey = this.form.imgDelKey + id + ','
      this.form.userCardIDFileList.splice(event.index, 1)
    },
    //政治面貌 POLITICAL_STATUS
    fnShowPoliticalStatusEducation() {
      this.showPoliticalStatus = !this.showPoliticalStatus
    },
    fnShowPoliticalStatusConfirm(e) {
      this.form.POLITICAL_STATUS = e.value[0].BIANMA
      this.form.POLITICAL_STATUS_NAME = e.value[0].NAME
      this.fnShowPoliticalStatusEducation()
    },
    //入党时间 POLITICAL_TIME
    fnShowPoliticalTimeEducation() {
      this.showPoliticalTime = !this.showPoliticalTime
    },
    fnShowPoliticalTimeConfirm(event) {
      this.POLITICAL_TIME = event.value
      this.fnShowPoliticalTimeEducation()
      this.form.POLITICAL_TIME = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
    },
    // 社保卡 照片
    fnSocialAttachmentsRead(event) {
      for (let i = 0; i < event.file.length; i++) {
        this.form.socialFileList.push(event.file[i])
      }
    },
    fnSocialAttachmentsDelete(event) {
      var id = this.form.socialFileList[event.index].id
      this.form.imgDelKey = this.form.imgDelKey + id + ','
      this.form.socialFileList.splice(event.index, 1)
    },

    //工伤保险有效期 IS_INJURIES_PAY_TIME  InjuriesPayTiem
    fnShowInjuriesPayTiemEducation() {
      this.showInjuriesPayTiem = !this.showInjuriesPayTiem
    },
    fnShowInjuriesPayTiemConfirm(event) {
      this.IS_INJURIES_PAY_TIME = event.value
      this.fnShowInjuriesPayTiemEducation()
      this.form.IS_INJURIES_PAY_TIME = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
    },
    //工伤保险有效 凭证
    fnInjuriesPayTiemAttachmentsAfterRead(event) {
      for (let i = 0; i < event.file.length; i++) {
        this.form.injuriesPayTiemFile.push(event.file[i])
      }
    },
    fnInjuriesPayTiemAttachmentsDelete(event) {
      this.form.injuriesPayTiemFile.splice(event.index, 1)
    },
    fnAdaptToTheJobPositionConfirm(e) {
    	this.form.IS_BODY_ADAPT = e.value[0].id
    	this.form.IS_BODY_ADAPT_NAME = e.value[0].name
    	this.fnShowAdaptToTheJobPosition()
    },
    fnShowSpecialTypeOfWork() {
      this.showSpecialTypeOfWork = !this.showSpecialTypeOfWork
    },
    fnSpecialTypeOfWorkConfirm(e) {
    	this.form.IS_SPECIAL_JOB = e.value[0].id
    	this.form.IS_SPECIAL_JOB_NAME = e.value[0].name
    	this.fnShowSpecialTypeOfWork()
    	if (e.value[0].id === '1' && this.certificateInformationLength === 0) {
    		uni.showModal({
    			title: '提示',
    			content: '当前没有证书信息，请完善证书信息',
    			showCancel: false,
    			success: (res) => {
    				if (res.confirm) {
    					uni.$u.route({
    						url: '/pages/certificate_information/index',
    					})
    				}
    			}
    		})
    	}
    },
    fnShowFloatingPersonnel() {
      this.showFloatingPersonnel = !this.showFloatingPersonnel
    },
    fnFloatingPersonnelConfirm(e) {
      this.form.ISFLOW = e.value[0].id
      this.form.ISFLOW_NAME = e.value[0].name
      this.fnShowFloatingPersonnel()
    },
    fnSubmit() {
      let fileUrl = ''
      let imgDelKey = String(this.form.imgDelKey)
      if (imgDelKey.length > 0) {
        this.form.imgDelKey = imgDelKey.replace(/undefined,/g, '').slice(0, -1)
      }
      this.$refs.form.validate().then(async () => {
        if (await this.fnIDCardDeduplication()) return
        if (await this.fnPhoneNumberDeduplication()) return
        let Employed = await getEmployedBy({
          showCount: 10,
          currentPage: 1,
          DEPART_STATE: '0,2'
        })
        console.log(Employed)
        if (Employed.varList.length > 0) {
          Employed.varList.forEach(item => {
            console.log(item.EMPLOYMENT_APPLY_MANAGEMENT_ID);
            this.form.EMPLOYMENT_APPLY_MANAGEMENT_ID = item.EMPLOYMENT_APPLY_MANAGEMENT_ID
          })
        }
        if (!this.form.EMPLOYMENT_APPLY_MANAGEMENT_ID) {
          console.log(this.EMPLOYMENT_APPLY_MANAGEMENT_ID);
          Employed = await getEMPLOYMENTAPPLYMANAGEMENTID({});

          console.log(Employed);
          this.form.EMPLOYMENT_APPLY_MANAGEMENT_ID = Employed.EMPLOYMENT_APPLY_MANAGEMENT_ID;
        }

        //校验社保和工伤保险必须有一个选是
        if (this.form.IS_INJURIES_PAY === '0' && this.form.IS_SOCIAL === '0') {
          uni.$u.toast('工商或社保全无人员，不可进入本系统相关方人员管理！');
          return;
        }
        // 开始上传图片
        // 头像
        for (let i = 0; i < this.form.userPhoto.length; i++) {
          let resData = await setUploadAttachments({
            filePath: this.form.userPhoto[i].url,
            name: 'files',
            formData: {
              TYPE: '13',
              FOREIGN_KEY: this.userInfo.USER_ID,
              CORPINFO_ID: this.CORPINFO_ID,
            }
          })
          fileUrl = resData.filePath
        }
        for (let i = 0; i < this.form.contractFile.length; i++) {
          await setUploadAttachments({
            filePath: this.form.contractFile[i].url,
            name: 'files',
            formData: {
              TYPE: '10',
              FOREIGN_KEY: this.form.EMPLOYMENT_APPLY_MANAGEMENT_ID,
              CORPINFO_ID: this.CORPINFO_ID,
            }
          })
        }
        for (let i = 0; i < this.form.safetytraining.length; i++) {
          await setUploadAttachments({
            filePath: this.form.safetytraining[i].url,
            name: 'files',
            formData: {
              TYPE: '19',
              FOREIGN_KEY: this.form.EMPLOYMENT_APPLY_MANAGEMENT_ID,
              CORPINFO_ID: this.CORPINFO_ID,
            }
          })
        }
        for (let i = 0; i < this.form.insuranceFile.length; i++) {
          await setUploadAttachments({
            filePath: this.form.insuranceFile[i].url,
            name: 'files',
            formData: {
              TYPE: '11',
              FOREIGN_KEY: this.form.EMPLOYMENT_APPLY_MANAGEMENT_ID,
              CORPINFO_ID: this.CORPINFO_ID,
            }
          })
        }
        // 身份证
        for (let i = 0; i < this.form.userCardIDFileList
            .length; i++) { // 14 身份证照片 15 社保卡照片 16上传工伤保险凭证
          await setUploadAttachments({
            filePath: this.form.userCardIDFileList[i].url,
            name: 'files',
            formData: {
              TYPE: '14',
              FOREIGN_KEY: this.userInfo.USER_ID,
              CORPINFO_ID: this.CORPINFO_ID,
            }
          })
        }
        for (let i = 0; i < this.form.socialFileList.length; i++) { // 15 社保卡照片
          await setUploadAttachments({
            filePath: this.form.socialFileList[i].url,
            name: 'files',
            formData: {
              TYPE: '15',
              FOREIGN_KEY: this.userInfo.USER_ID,
              CORPINFO_ID: this.CORPINFO_ID,
            }
          })
        }
        for (let i = 0; i < this.form.injuriesPayTiemFile.length; i++) { // 16上传工伤保险凭证
          await setUploadAttachments({
            filePath: this.form.injuriesPayTiemFile[i].url,
            name: 'files',
            formData: {
              TYPE: '16',
              FOREIGN_KEY: this.form.EMPLOYMENT_APPLY_MANAGEMENT_ID,
              CORPINFO_ID: this.CORPINFO_ID,
            }
          })
        }
        this.form.PHONE = this.form.USERNAME
        await setRelatedPartyRegistration({
          ...this.form,
          CORPINFO_ID: this.CORPINFO_ID,
          RELEVANT_UNIT_NAME: this.RELEVANT_UNIT_NAME,
          PHOTO: fileUrl,
          WORK_SIGN: this.form.IS_SIGN_LABOR,
        })
        uni.$u.toast('保存成功，请等待相关方审核')
        setTimeout(() => {
          uni.navigateBack()
        }, 2000)
      }).catch((e) => {
        console.info(e)
        uni.$u.toast('请补全必填项')
      })
    }
  },
}
</script>

<style scoped>
.tip {
  color: red;
  font-size: 12px;
  margin-top: 5px;
}
</style>
