diff --git a/src/views/pro/apply/supervisorEnterApply.vue b/src/views/pro/apply/supervisorEnterApply.vue index a8ee0c6..70be507 100644 --- a/src/views/pro/apply/supervisorEnterApply.vue +++ b/src/views/pro/apply/supervisorEnterApply.vue @@ -972,9 +972,9 @@ export default { this.postList = response.data }) }, - submitForm(formName, submitType) { + async submitForm(formName, submitType) { this.loading = true - let isReturn = false + let isReturn = true if (submitType === '提交') { const param = { ...this.getParams(), @@ -997,100 +997,107 @@ export default { return false } //查询判断当前下所以人员文件是否上传 - try { - const response = judgeIsFileComplete(param) - console.log('response=====', response) - // if (response.msg === '部分人员文件不存在,请先仔细核对,上传相关文件!') { - // this.$message({ - // message: '部分人员文件不存在,请先仔细核对,上传相关文件!', - // type: 'error', - // }) - // // return false - // isReturn = true - // } - if (response.code == 500) { - this.$message({ - message: response.msg, - type: 'error', + // try { + // const response = await judgeIsFileComplete(param) + // console.log('response=====', response) + // // if (response.msg === '部分人员文件不存在,请先仔细核对,上传相关文件!') { + // // this.$message({ + // // message: '部分人员文件不存在,请先仔细核对,上传相关文件!', + // // type: 'error', + // // }) + // // // return false + // // isReturn = true + // // } + // if (response.code == 500) { + // this.$message({ + // message: response.msg, + // type: 'error', + // }) + // // return false + // isReturn = true + // } + // } catch (error) { + // this.$message({ + // message: '文件检查失败,请稍后重试!', + // type: 'error', + // }) + // // return false + // } + + judgeIsFileComplete(param) + .then(res => { + this.$refs[formName].validate(valid => { + if (submitType === '提交' && !valid) { + return this.$modal.msgError('请完善全部上传信息') + } + console.log(this.formData) + const reqData = new FormData() + this.formData.proId = this.$store.state.user.thisIds.proId + this.formData.supId = this.$store.state.user.thisIds.supId + this.formData.supUuid = this.$store.state.user.thisIds.supUuid + this.formData.uuid = this.$store.state.user.thisIds.uuid + this.formData.delFileIds = this.delFileIds.join(',') + this.formData.submitType = submitType + reqData.append('params', JSON.stringify(this.formData)) + + // 使用 Promise.all 并行处理文件数据获取,提高效率 + Promise.all([ + this.getFileData(this.formData.enterpriseQualificationFiles), + this.getFileData(this.formData.securityAgreementFiles), + this.getFileData(this.formData.supervisionPlanningFiles), + this.getFileData(this.formData.implementationRulesFiles), + ]).then( + ([ + enterpriseQualificationFiles, + securityAgreementFiles, + supervisionPlanningFiles, + implementationRulesFiles, + ]) => { + if (!enterpriseQualificationFiles || enterpriseQualificationFiles.length === 0) { + reqData.append('enterpriseQualificationFiles', new Blob()) + } else { + enterpriseQualificationFiles.forEach(item => reqData.append('enterpriseQualificationFiles', item)) + } + if (!securityAgreementFiles || securityAgreementFiles.length === 0) { + reqData.append('securityAgreementFiles', new Blob()) + } else { + securityAgreementFiles.forEach(item => reqData.append('securityAgreementFiles', item)) + } + if (!supervisionPlanningFiles || supervisionPlanningFiles.length === 0) { + reqData.append('supervisionPlanningFiles', new Blob()) + } else { + supervisionPlanningFiles.forEach(item => reqData.append('supervisionPlanningFiles', item)) + } + if (!implementationRulesFiles || implementationRulesFiles.length === 0) { + reqData.append('implementationRulesFiles', new Blob()) + } else { + implementationRulesFiles.forEach(item => reqData.append('implementationRulesFiles', item)) + } + addSupervisoryApply(reqData) + .then(response => { + if (submitType === '提交') { + this.submitApply() + } else { + this.loading = false + this.$modal.msgSuccess('保存成功') + this.$tab.closePage() + } + }) + .catch(error => { + // 增加错误处理 + this.loading = false + this.$modal.msgError('提交失败') + }) + } + ) }) - // return false - isReturn = true - } - } catch (error) { - this.$message({ - message: '文件检查失败,请稍后重试!', - type: 'error', }) - // return false - } + .catch(error => { + console.log(error, '校验失败') + }) } - if (isReturn) return - this.$refs[formName].validate(valid => { - if (submitType === '提交' && !valid) { - return this.$modal.msgError('请完善全部上传信息') - } - console.log(this.formData) - const reqData = new FormData() - this.formData.proId = this.$store.state.user.thisIds.proId - this.formData.supId = this.$store.state.user.thisIds.supId - this.formData.supUuid = this.$store.state.user.thisIds.supUuid - this.formData.uuid = this.$store.state.user.thisIds.uuid - this.formData.delFileIds = this.delFileIds.join(',') - this.formData.submitType = submitType - reqData.append('params', JSON.stringify(this.formData)) - - // 使用 Promise.all 并行处理文件数据获取,提高效率 - Promise.all([ - this.getFileData(this.formData.enterpriseQualificationFiles), - this.getFileData(this.formData.securityAgreementFiles), - this.getFileData(this.formData.supervisionPlanningFiles), - this.getFileData(this.formData.implementationRulesFiles), - ]).then( - ([ - enterpriseQualificationFiles, - securityAgreementFiles, - supervisionPlanningFiles, - implementationRulesFiles, - ]) => { - if (!enterpriseQualificationFiles || enterpriseQualificationFiles.length === 0) { - reqData.append('enterpriseQualificationFiles', new Blob()) - } else { - enterpriseQualificationFiles.forEach(item => reqData.append('enterpriseQualificationFiles', item)) - } - if (!securityAgreementFiles || securityAgreementFiles.length === 0) { - reqData.append('securityAgreementFiles', new Blob()) - } else { - securityAgreementFiles.forEach(item => reqData.append('securityAgreementFiles', item)) - } - if (!supervisionPlanningFiles || supervisionPlanningFiles.length === 0) { - reqData.append('supervisionPlanningFiles', new Blob()) - } else { - supervisionPlanningFiles.forEach(item => reqData.append('supervisionPlanningFiles', item)) - } - if (!implementationRulesFiles || implementationRulesFiles.length === 0) { - reqData.append('implementationRulesFiles', new Blob()) - } else { - implementationRulesFiles.forEach(item => reqData.append('implementationRulesFiles', item)) - } - addSupervisoryApply(reqData) - .then(response => { - if (submitType === '提交') { - this.submitApply() - } else { - this.loading = false - this.$modal.msgSuccess('保存成功') - this.$tab.closePage() - } - }) - .catch(error => { - // 增加错误处理 - this.loading = false - this.$modal.msgError('提交失败') - }) - } - ) - }) + // if (isReturn) return }, /** * 提交审批