<template>
	<view class="content">
		<view class="card">
			<u--form labelPosition="left" :model="form" :rules="rules" ref="form" labelWidth="auto">
				<u-form-item label="岗位名称" prop="POST_ID" borderBottom required>
					<u--input v-model="form.POST_ID" border="none" disabledColor="#ffffff" inputAlign="right">
					</u--input>
				</u-form-item>
<!--				<u-form-item label="本企业从业开始日期" prop="CORP_START_DATE" borderBottom required-->
<!--					@click="fnShowDatePicke('CORP_START_DATE')">-->
<!--					<u&#45;&#45;input v-model="form.CORP_START_DATE" border="none" disabled disabledColor="#ffffff"-->
<!--						inputAlign="right"></u&#45;&#45;input>-->
<!--				</u-form-item>-->
<!--				<u-form-item label="本岗位从业开始日期" prop="ENTRY_DATE" borderBottom required-->
<!--					@click="fnShowDatePicke('ENTRY_DATE')">-->
<!--					<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_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>
				<view v-if="form.IS_SIGN_LABOR==='1'">
					<u-form-item label="劳动合同附件" prop="contractFile" borderBottom required class="form-item-block">
						<u-upload class="mt-10" :fileList="form.contractFile"
							@afterRead="fnAttachmentToLaborContractAfterRead"
							@delete="fnAttachmentToLaborContractDelete" multiple :maxCount="4" previewFullImage>
						</u-upload>
					</u-form-item>
				</view>
				<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>
				<view v-if="form.IS_INJURIES_PAY==='1'">
					<u-form-item label="工伤保险有效期" prop="IS_INJURIES_PAY_TIME" borderBottom required
						@click="fnShowDatePicke('IS_INJURIES_PAY_TIME')">
						<u--input v-model="form.IS_INJURIES_PAY_TIME" border="none" disabled disabledColor="#ffffff"
							inputAlign="right"></u--input>
					</u-form-item>
				</view>
				<view v-if="form.IS_INJURIES_PAY==='1'">
					<u-form-item label="工伤保险凭证" prop="workInsurancePhotoFile" borderBottom required
						class="form-item-block">
						<u-upload class="mt-10" :fileList="form.workInsurancePhotoFile"
							@afterRead="fnWorkInsuranceRead" @delete="fnWorkInsuranceDelete" multiple
							:maxCount="4" previewFullImage>
						</u-upload>
					</u-form-item>
				</view>
				<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 v-if="form.ISPAY==='1'" label="商业保险单号" prop="ISPAY_NUMBER" borderBottom required>
					<u--input v-model="form.ISPAY_NUMBER" border="none" disabledColor="#ffffff" inputAlign="right">
					</u--input>
				</u-form-item>
				<view v-if="form.ISPAY==='1'">
					<u-form-item label="保险附件" prop="insuranceFile" borderBottom required class="form-item-block">
						<u-upload class="mt-10" :fileList="form.insuranceFile"
							@afterRead="fnInsuranceAttachmentsAfterRead" @delete="fnInsuranceDelete" multiple
							:maxCount="4" previewFullImage></u-upload>
					</u-form-item>
				</view>
				<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="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="身体状况是否适应本岗位工作" prop="IS_BODY_ADAPT_NAME" borderBottom required
					@click="fnShowAdaptToTheJobPosition">
					<u--input v-model="form.IS_BODY_ADAPT_NAME" border="none" disabled disabledColor="#ffffff"
						inputAlign="right"></u--input>
				</u-form-item>
				<u-form-item label="是否特殊工种" prop="IS_SPECIAL_JOB_NAME" borderBottom required
					@click="fnShowSpecialTypeOfWork">
					<u--input v-model="form.IS_SPECIAL_JOB_NAME" border="none" disabled disabledColor="#ffffff"
						inputAlign="right"></u--input>
				</u-form-item>
				<!-- <u-form-item label="是否流动人员" prop="ISFLOW_NAME" borderBottom required>
					<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-picker :show="showPersonWorkType" :columns="personWorkTypeColumns" keyName="NAME"></u-picker>
			<u-picker :show="showPost" :columns="postColumns" keyName="NAME"></u-picker>
			<u-datetime-picker :show="datePicker" v-model="dateValue" mode="date" @confirm="fnDateConfirm"
				@cancel="fnDateCancel"></u-datetime-picker>

			<u-picker :show="showLaborContract" :columns="[[{name: '是', id: '1'}, {name: '否', id: '0'}]]" keyName="name"
				@confirm="fnLaborContractConfirm" @cancel="fnShowLaborContract"></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-button type="primary" text="修 改" class="mt-10" @click="$u.debounce(fnSubmit, 1000,true)"></u-button>
		</view>
	</view>
</template>

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

	export default {
		data() {
			return {
				changeFrom: '',
				datePicker: false,
				dateValue: new Date().toString(),
				imgDelKey: [],
				RELEVANT_UNIT_NAME: '',
				CORPINFO_ID: '',
				EMPLOYMENT_APPLY_MANAGEMENT_ID: '',
				showDegreeOfEducation: false,
				degreeOfEducationColumns: [],
				showPersonWorkType: false,
				personWorkTypeColumns: [],
				showPost: false,
				postColumns: [],
				showEnterpriseStartingDateOfEmployment: false,
				enterpriseStartingDateOfEmploymentValue: new Date().toString(),
				showPostStartingDateOfEmployment: false,
				postStartingDateOfEmploymentValue: new Date().toString(),
				showLaborContract: false,
				showEmploymentInjuryInsurance: false,
				showEmploymentPayInsurance: false,
				showSafetyTraining: false,
				showAdmissionSafetyNotification: false,
				showAdaptToTheJobPosition: false,
				showSpecialTypeOfWork: false,
				showFloatingPersonnel: false,
				certificateInformationLength: 0,
				form: {
					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: '',
					IS_INJURIES_PAY: '',
					IS_INJURIES_PAY_NAME: '',
					insuranceFile: [],
					workInsurancePhotoFile: [],
					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: '',
				},
				rules: {
					userPhoto: {
						type: 'array',
						required: false,
						message: '请上传照片',
						trigger: ['change']
					},
					NAME: {
						required: false,
						message: '请填写姓名',
						trigger: ['blur']
					},
					CARD_ID: [{
							required: true,
							message: '请填写身份证',
							trigger: ['blur']
						},
						{
							validator: (rule, value, callback) => {
								return uni.$u.test.idCard(value);
							},
							message: '身份证号格式不正确',
							trigger: ['blur'],
						},
					],
					HKLOCAL: {
						required: false,
						message: '请填写户口所在地',
						trigger: ['blur']
					},
					ADDRESS: {
						required: false,
						message: '请填写现住址',
						trigger: ['blur']
					},
					PHONE: [{
							required: false,
							message: '请填写联系电话',
							trigger: ['blur']
						},
						{
							validator: (rule, value, callback) => {
								return uni.$u.test.mobile(value);
							},
							message: '联系电话格式不正确',
							trigger: ['blur'],
						},
					],
					DEGREE_OF_EDUCATION_NAME: {
						required: false,
						message: '请选择文化程度',
						trigger: ['change']
					},
					PERSON_WORK_TYPE: {
						required: false,
						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: false,
						message: '请填写社会保障号码',
						trigger: ['change']
					},
					IS_SIGN_LABOR_NAME: {
						required: true,
						message: '请选择是否签署劳动合同',
						trigger: ['change']
					},
					contractFile: {
						type: 'array',
						required: true,
						message: '请上传劳动合同附件',
						trigger: ['change']
					},
					IS_INJURIES_PAY_NAME: {
						required: true,
						message: '请选择是否缴纳工伤保险',
						trigger: ['change']
					},
					workInsurancePhotoFile: {
						type: 'array',
						required: true,
						message: '请上传工伤保险凭证',
						trigger: ['change']
					},
					IS_INJURIES_PAY_TIME: {
						required: true,
						message: '请选择本企业从业开始日期',
						trigger: ['change']
					},
					ISPAY_NAME: {
						required: true,
						message: '请选择是否缴纳商业保险',
						trigger: ['change']
					},
					ISPAY_NUMBER: {
						required: true,
						message: '请输入保险单号',
						trigger: ['blur']
					},
					insuranceFile: {
						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_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.EMPLOYMENT_APPLY_MANAGEMENT_ID = query.EMPLOYMENT_APPLY_MANAGEMENT_ID
			this.RELEVANT_UNIT_NAME = query.RELEVANT_UNIT_NAME
			this.fnGetDataDictionary('d7d80f08d73a4accbccf4fd3d8d1d867', 'degreeOfEducationColumns')
			// this.fnGetDataDictionary('09e36ac01e9540f8bc84eab1c1a78754', 'postColumns')
			// this.fnGetDataDictionary('55484e491a5e442d839c4595380713ec', 'personWorkTypeColumns')
			this.fnGetData()
		},
		computed: {
			userInfo() {
				return this.$store.getters.getUserInfo
			}
		},
		methods: {
			// 日期确认
			fnDateConfirm(event) {
				this.$set(this.form, this.changeFrom, uni.$u.timeFormat(event.value, 'yyyy-mm-dd'))
				this.datePicker = false
			},
			// 日期选择器取消
			fnDateCancel() {
				this.datePicker = false
			},
			fnShowDatePicke(changeFrom) {
				this.changeFrom = changeFrom
				this.datePicker = true
			},
			async fnGetData() {
				let resData = await getUserInfo({
					CORPINFO_ID: this.userInfo.CORPINFO_ID,
					EMPLOYMENT_APPLY_MANAGEMENT_ID: this.EMPLOYMENT_APPLY_MANAGEMENT_ID
				})
				this.form = {
					...this.form,
					...resData.pd
				}
				this.form.PHONE = this.form.USERNAME
				// 转换数据
				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_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 = '是'
				}
				if (this.form.ISPAY === '0') {
					this.form.ISPAY_NAME = '否'
				} else if (this.form.ISPAY === '1') {
					this.form.ISPAY_NAME = '是'
				}
				if (resData.contractFile.length > 0) {
					this.form.IS_SIGN_LABOR = '1'
					this.form.IS_SIGN_LABOR_NAME = '是'
					resData.contractFile.forEach(item => {
						const obj = {
							id: item.IMGFILES_ID,
							url: this.$filePath + item.FILEPATH
						}
						this.form.contractFile.push(obj)
					})
				}
				if (resData.workInsurancePhotoFile.length > 0) {
					resData.workInsurancePhotoFile.forEach(item => {
						const obj = {
							id: item.IMGFILES_ID,
							url: this.$filePath + item.FILEPATH
						}
						this.form.workInsurancePhotoFile.push(obj)
					})
				}

				if (resData.insuranceFile.length > 0) {
					this.form.ISPAY = '1'
					this.form.ISPAY_NAME = '是'
					resData.insuranceFile.forEach(item => {
						const obj = {
							id: item.IMGFILES_ID,
							url: this.$filePath + item.FILEPATH
						}
						this.form.insuranceFile.push(obj)
					})
				}
				this.$set(this.form, 'userPhoto', [{
					url: this.$filePath + resData.userPhotoFile[0].FILEPATH
				}])
				await this.fnCardIdDisassembly(this.form.CARD_ID)
				await this.getDataCertificateInformation()
			},
			async getDataCertificateInformation() {
				let resData = await getCertificateInformationList({
					showCount: 9999,
					currentPage: 1,
					keyCrelType:'7498057c4c1f4a11b9a960e66ea04a7a'
				});
				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 != 0) {
						this.form.SEX = "0";
						this.form.SEX_NAME = "男";
					} else {
						this.form.SEX = "1";
						this.form.SEX_NAME = "女";
					}
					this.$forceUpdate()
					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()
			},
			fnShowPersonWorkType() {
				this.showPersonWorkType = !this.showPersonWorkType
			},
			fnShowPost() {
				this.showPost = !this.showPost
			},
			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
			},
			fnLaborContractConfirm(e) {
				this.form.IS_SIGN_LABOR = e.value[0].id
				this.form.IS_SIGN_LABOR_NAME = e.value[0].name
				this.fnShowLaborContract()
			},
			fnShowEmploymentInjuryInsurance() {
				this.showEmploymentInjuryInsurance = !this.showEmploymentInjuryInsurance
			},
			fnShowEmploymentPayInsurance() {
				this.showEmploymentPayInsurance = !this.showEmploymentPayInsurance
			},
			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) {
				for (let i = 0; i < event.file.length; i++) {
					this.form.userPhoto.push(event.file[i])
				}
			},
			fnAttachmentToLaborContractAfterRead(event) {
				for (let i = 0; i < event.file.length; i++) {
					this.form.contractFile.push(event.file[i])
				}
			},
			fnWorkInsuranceRead(event) {
				for (let i = 0; i < event.file.length; i++) {
					this.form.workInsurancePhotoFile.push(event.file[i])
				}
			},
			fnAttachmentToLaborContractDelete(event) {
				uni.showModal({
					title: '提示',
					content: '确定删除吗',
					success: async (res) => {
						if (res.confirm) {
							if (event.file.id) {
								this.imgDelKey.push(event.file.id)
							}
							uni.showToast({
								title: '操作成功',
								duration: 2000
							});
							this.form.contractFile.splice(event.index, 1)
						} else if (res.cancel) {}
					}
				});
			},
			fnWorkInsuranceDelete(event) {
				uni.showModal({
					title: '提示',
					content: '确定删除吗',
					success: async (res) => {
						if (res.confirm) {
							if (event.file.id) {
								this.imgDelKey.push(event.file.id)
							}
							uni.showToast({
								title: '操作成功',
								duration: 2000
							});
							this.form.workInsurancePhotoFile.splice(event.index, 1)
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			fnInsuranceDelete(event) {
				uni.showModal({
					title: '提示',
					content: '确定删除吗',
					success: async (res) => {
						if (res.confirm) {
							if (event.file.id) {
								this.imgDelKey.push(event.file.id)
							}
							uni.showToast({
								title: '操作成功',
								duration: 2000
							});
							this.form.insuranceFile.splice(event.index, 1)
						} else if (res.cancel) {
							// console.log('用户点击取消');
						}
					}
				});
			},
			fnInsuranceAttachmentsAfterRead(event) {
				for (let i = 0; i < event.file.length; i++) {
					this.form.insuranceFile.push(event.file[i])
				}
			},
			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()
			},
			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
			},
			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()
			},
			async fnCheckRelatedUnitsPersonCount() {
				try {
					await checkRelatedUnitsPersonCount({
						ISFLOW: this.form.ISFLOW,
						CORPINFO_ID: this.CORPINFO_ID
					})
					return false
				} catch (e) {
					return true
				}
			},
			fnSubmit() {
				let fileUrl = ''
				this.$refs.form.validate().then(async () => {
					for (let i = 0; i < this.form.contractFile.length; i++) {
						if (!this.form.contractFile[i].id) {
							await setUploadAttachments({
								filePath: this.form.contractFile[i].url,
								name: 'files',
								formData: {
									TYPE: '10',
									FOREIGN_KEY: this.EMPLOYMENT_APPLY_MANAGEMENT_ID,
									CORPINFO_ID: this.CORPINFO_ID,
								}
							})
						}

					}
					for (let i = 0; i < this.form.insuranceFile.length; i++) {
						if (!this.form.insuranceFile[i].id) {
							await setUploadAttachments({
								filePath: this.form.insuranceFile[i].url,
								name: 'files',
								formData: {
									TYPE: '11',
									FOREIGN_KEY: this.EMPLOYMENT_APPLY_MANAGEMENT_ID,
									CORPINFO_ID: this.CORPINFO_ID,
								}
							})
						}
					}
					for (let i = 0; i < this.form.workInsurancePhotoFile.length; i++) {
						if (!this.form.workInsurancePhotoFile[i].id) {
							await setUploadAttachments({
								filePath: this.form.workInsurancePhotoFile[i].url,
								name: 'files',
								formData: {
									TYPE: '16',
									FOREIGN_KEY: this.EMPLOYMENT_APPLY_MANAGEMENT_ID,
									CORPINFO_ID: this.CORPINFO_ID,
								}
							})
						}
					}
					this.form.PHONE = this.form.USERNAME
					await setRelatedPartyUpdate({
						...this.form,
						imgDelKey: this.imgDelKey,
						USER_ID: this.userInfo.USER_ID,
						CORPINFO_ID: this.userInfo.CORPINFO_ID,
						EMPLOYMENT_APPLY_MANAGEMENT_ID: this.EMPLOYMENT_APPLY_MANAGEMENT_ID,
					})
					uni.$u.toast('修改成功')
					setTimeout(() => {
						var pages = getCurrentPages(); // 获取当前页面栈
						var prePage = pages[pages.length - 2]; // 上级页面
						uni.navigateBack({
							delta: 1,
							success: (e) => {
								prePage.$vm.reloadx();
							},
							fail: (e) => {
								console.log(e)
							}
						});
					}, 2000)
				}).catch((e) => {
					uni.$u.toast('请补全必填项')
				})
			}
		},
	}
</script>

<style scoped>

</style>
