diff --git a/src/components/Template/Step.vue b/src/components/Template/Step.vue index 7343586..5743dd1 100644 --- a/src/components/Template/Step.vue +++ b/src/components/Template/Step.vue @@ -114,7 +114,7 @@ const stepTypes = [ { label: '灭菌', value: 'mj' }, { label: '复苏', value: 'fs' }, { label: '封板', value: 'fb' }, - // { label: '质量分装', value: 'zlfz' }, + { label: '质量分装', value: 'zlfz' }, ]; diff --git a/src/components/Template/StepComponents/ZLSubPackage.vue b/src/components/Template/StepComponents/ZLSubPackage.vue index 4d9f4cd..aeaeeac 100644 --- a/src/components/Template/StepComponents/ZLSubPackage.vue +++ b/src/components/Template/StepComponents/ZLSubPackage.vue @@ -94,9 +94,9 @@ export default { fzList: [],//分装列表 // 错误状态字段 formErrors: { - mybh: false, fzsl: false, dw: false, + mfbzl: false, }, fzListErrors: [], // 分装列表错误状态 uuid:"",//事件id @@ -105,7 +105,6 @@ export default { watch: { subData:{ handler(newVal) { - console.log(newVal,"fff"); if(newVal.formData){ this.formData = newVal.formData; } @@ -157,46 +156,65 @@ export default { validateFormData() { let isValid = true; - // 验证母液编号 - if (!this.formData.mybh) { - this.formErrors.mybh = true; - isValid = false; - } - - // 验证分装数量 - if (!this.formData.fzsl) { - this.formErrors.fzsl = true; - isValid = false; - } + // 定义需要验证的基础字段配置 + const baseFieldConfigs = [ + + { + field: 'fzsl', + errorField: 'fzsl', + itemConfig: this.integerInputNumberItem + }, + { + field: 'dw', + errorField: 'dw', + itemConfig: this.unitItem + }, + { + field: 'mfbzl', + errorField: 'mfbzl', + itemConfig: this.inputNumberItem + } + ]; - // 验证单位 - if (!this.formData.dw) { - this.formErrors.dw = true; - isValid = false; - } + // 验证基础字段 + baseFieldConfigs.forEach(config => { + if (config.itemConfig.fillType === this.templateFillType) { + if (!this.formData[config.field]) { + this.formErrors[config.errorField] = true; + isValid = false; + } + } + }); - // 验证分装列表中的数值 + // 验证分装列表中的数值 - 根据字段的fillType和当前templateFillType比较 if (this.fzList && this.fzList.length > 0) { for (let i = 0; i < this.fzList.length; i++) { - if (isValueEmpty(this.fzList[i].prenum)) { - this.fzListErrors.push({ - rowIndex: i, - field: "prenum", - error: "请输入预填分装数量", - }) - isValid = false; + // 验证预填分装数量 + if (this.preInputNumberItem.fillType === this.templateFillType) { + if (isValueEmpty(this.fzList[i].prenum)) { + this.fzListErrors.push({ + rowIndex: i, + field: "prenum", + error: "请输入预填分装数量", + }) + isValid = false; + } } - if (isValueEmpty(this.fzList[i].actnum)) { - this.fzListErrors.push({ - rowIndex: i, - field: "actnum", - error: "请输入实际分装数量", - }) - isValid = false; + + // 验证实际分装数量 + if (this.inputNumberItem.fillType === this.templateFillType) { + if (isValueEmpty(this.fzList[i].actnum)) { + this.fzListErrors.push({ + rowIndex: i, + field: "actnum", + error: "请输入实际分装数量", + }) + isValid = false; + } } } } - return isValid; + return {valid: isValid,error:""}; }, resetErrors() { // 重置表单错误状态 diff --git a/src/components/Template/StepFormPackage.vue b/src/components/Template/StepFormPackage.vue index dfb88f2..4f2bd9b 100644 --- a/src/components/Template/StepFormPackage.vue +++ b/src/components/Template/StepFormPackage.vue @@ -125,7 +125,7 @@ export default { this.formFields[key] = data; }, // 重写子组件校验钩子方法,检查ZLSubPackage的表单验证 - async validateSubComponents() { + validateSubComponents() { const refs = []; // 遍历formConfig,找到所有type为zlfz的项 for (const item of this.formConfig) { @@ -145,8 +145,11 @@ export default { } } } - const result = await Promise.all(refs.map(ref => ref[0].validateFormData())); - return result[0] + if(refs.length === 0){ + return {valid: true, error: ''}; + }else{//目前一个步骤只会有一个质量分装,所以不考虑多个的情况 + return refs[0][0].validateFormData(); + } }, getSjResource(){ const {allFieldsConfig,formFields} = this; diff --git a/src/components/Template/mixins/formPackageMixins.js b/src/components/Template/mixins/formPackageMixins.js index ff5bf8e..e94afb6 100644 --- a/src/components/Template/mixins/formPackageMixins.js +++ b/src/components/Template/mixins/formPackageMixins.js @@ -411,10 +411,10 @@ export default { getFormData() { // 同时执行数据校验和子组件校验 const validateResult = this.validateFormData(); - // const subComponentValidateResult = this.validateSubComponents(); - const subComponentValidateResult = {valid: true, error: ''}; + const subComponentValidateResult = this.validateSubComponents(); + // const subComponentValidateResult = {valid: true, error: ''}; - console.log(subComponentValidateResult,"subComponentValidateResult") + console.log(subComponentValidateResult,validateResult,"subComponentValidateResult") return new Promise((resolve, reject) => { if (validateResult.valid && subComponentValidateResult.valid) { resolve(this.formFields); diff --git a/src/views/business/comps/template/comps/sp/SP001.vue b/src/views/business/comps/template/comps/sp/SP001.vue index 28ff59d..b52c651 100644 --- a/src/views/business/comps/template/comps/sp/SP001.vue +++ b/src/views/business/comps/template/comps/sp/SP001.vue @@ -27,7 +27,7 @@ - + @@ -314,7 +314,7 @@ export default { }, //保存 async onSave() { - let content = this.$refs.stepRef.getStepResource(); + let content =await this.$refs.stepRef.getFormData(); console.log(content); },