diff --git a/src/views/construction-person/entry-and-exit-manage/person-exit/person-exit-form.vue b/src/views/construction-person/entry-and-exit-manage/person-exit/person-exit-form.vue index 3789423..9a9f31a 100644 --- a/src/views/construction-person/entry-and-exit-manage/person-exit/person-exit-form.vue +++ b/src/views/construction-person/entry-and-exit-manage/person-exit/person-exit-form.vue @@ -122,16 +122,40 @@ export default { personExitFormRules: { fileList: [ { + required: true, trigger: 'change,blur', - required: this.checkExitFileFun() == 1, - message: '请上传离场工资结算确认单', + validator: this.validateFileList, }, ], }, + needExitFile: false, } }, methods: { - // 确定按钮 + async initExitFileRule() { + if (!this.personExitFormData.proId) { + return + } + const result = await this.checkExitFileFun() + + this.needExitFile = result == 1 + if (this.needExitFile) { + this.personExitFormRules.fileList[0].required = true + } else { + this.personExitFormRules.fileList[0].required = false + } + }, + validateFileList(rule, value, callback) { + if (this.needExitFile) { + if (!value || value.length === 0) { + callback(new Error('请上传离场工资结算确认单')) + } else { + callback() + } + } else { + callback() + } + }, onHandleConfirmAddOrEditFun() { return new Promise(async (resolve, reject) => { if (this.isExitUpload === 1) { @@ -236,7 +260,7 @@ export default { handler(newVal) { if (Object.keys(newVal).length > 0) { Object.assign(this.personExitFormData, newVal) - this.checkExitFileFun() + this.initExitFileRule() } }, deep: true,