diff --git a/src/components/Template/BaseInfoFormPcakge.vue b/src/components/Template/BaseInfoFormPcakge.vue index 70aa4ae..8bff540 100644 --- a/src/components/Template/BaseInfoFormPcakge.vue +++ b/src/components/Template/BaseInfoFormPcakge.vue @@ -273,7 +273,6 @@ export default { formFields[key] !== ''&& typeof formFields[key] !== 'object' ) { - console.log(key,formData,formFields[key],"kkk") // 保留原值,不使用formData中的值 result[key] = formFields[key]; } else { @@ -339,6 +338,10 @@ export default { if (o.label === "其他" && !this.isShowOther(formFields[o.parentKey])) { continue } + //span的字段不校验 + if(o.type === "span"){ + continue + } if (o.fillType == templateStatus && !o.disabled) { // 标记为错误状态 errors[key] = true; @@ -362,7 +365,7 @@ export default { return new Promise((resolve, reject) => { if (Object.keys(errors).length > 0) { // 显示第一个错误的提示信息 - this.$message.error(`表单内容未填完,请填写后再提交`); + // this.$message.error(`表单内容未填完,请填写后再提交`); reject(`${firstError.label}还未${firstError.prefix}`); } else { resolve(formFields); diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index cdd0b86..237677e 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -163,7 +163,7 @@ export default { headerSelectFields: this.headerSelectFields, }) }else{ - this.$message.error("表单内容未填完,请填写后再提交"); + // this.$message.error("表单内容未填完,请填写后再提交"); reject(validateResult.errors[0].error) } }) diff --git a/src/components/Template/Step.vue b/src/components/Template/Step.vue index cc401a9..123afa0 100644 --- a/src/components/Template/Step.vue +++ b/src/components/Template/Step.vue @@ -233,15 +233,15 @@ export default { // 校验所有步骤是否填写完整 const validation = this.validateSteps() if (!validation.isValid) { - this.$message.error(validation.errors[0]) + // this.$message.error(validation.errors[0]) reject(validation.errors[0]) return } // 检查是否有步骤数据 if (this.steps.length === 0) { - this.$message.error(this.$t('template.common.addStepError')) - reject(this.$t('template.common.addStepError')) + // this.$message.error(this.$t('template.common.addStepError')) + reject({errorType:"step"}); return } @@ -249,7 +249,7 @@ export default { type: step.type, ...step.formData })) - resolve(stepData) + resolve({stepData}) }) }, diff --git a/src/views/business/comps/template/comps/dl/SYWZPZJHB.vue b/src/views/business/comps/template/comps/dl/SYWZPZJHB.vue index 45f01d3..b46b4b7 100644 --- a/src/views/business/comps/template/comps/dl/SYWZPZJHB.vue +++ b/src/views/business/comps/template/comps/dl/SYWZPZJHB.vue @@ -186,13 +186,7 @@ export default { }; }, mounted() { - this.formData = { - headerSelectFields: { - preparationVolumeUnit: "ml", - preparationConcentrationUnit: "ul", - - } - } +console.log("mounted") }, methods: { diff --git a/src/views/business/comps/template/comps/gy/MJYLQSQD.vue b/src/views/business/comps/template/comps/gy/MJYLQSQD.vue index 534643f..d201d1c 100644 --- a/src/views/business/comps/template/comps/gy/MJYLQSQD.vue +++ b/src/views/business/comps/template/comps/gy/MJYLQSQD.vue @@ -186,13 +186,6 @@ export default { }; }, mounted() { - this.formData = { - headerSelectFields: { - preparationVolumeUnit: "ml", - preparationConcentrationUnit: "ul", - - } - } }, methods: { diff --git a/src/views/business/comps/template/comps/gy/SYWZPZJHB.vue b/src/views/business/comps/template/comps/gy/SYWZPZJHB.vue index 45f01d3..922d60d 100644 --- a/src/views/business/comps/template/comps/gy/SYWZPZJHB.vue +++ b/src/views/business/comps/template/comps/gy/SYWZPZJHB.vue @@ -186,13 +186,7 @@ export default { }; }, mounted() { - this.formData = { - headerSelectFields: { - preparationVolumeUnit: "ml", - preparationConcentrationUnit: "ul", - - } - } + }, methods: { diff --git a/src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue b/src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue index bb287eb..cbce7b9 100644 --- a/src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue @@ -53,22 +53,12 @@ export default { components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion }, mixins: [templateMixin], props: { - value: { - type: {}, - default: () => { }, - }, fillType: { type: String, default: 'preFill', }, }, watch: { - value: { - immediate: true, - handler(v) { - - } - }, fillType: { immediate: true, handler(v) { diff --git a/src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue b/src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue index e2a8d90..8712665 100644 --- a/src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue @@ -41,23 +41,11 @@ export default { components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable }, mixins: [templateMixin], props: { - value: { - type: {}, - default: () => { }, - }, fillType: { type: String, default: 'preFill', }, }, - watch: { - value: { - immediate: true, - handler(v) { - - } - } - }, computed: { storageFormConfig() { return [ diff --git a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue index 0c12df4..fd2d4c1 100644 --- a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue @@ -41,23 +41,11 @@ export default { components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable }, mixins: [templateMixin], props: { - value: { - type: {}, - default: () => { }, - }, fillType: { type: String, default: 'preFill', }, }, - watch: { - value: { - immediate: true, - handler(v) { - - } - } - }, computed: { storageFormConfig() { return [ @@ -269,16 +257,13 @@ export default { }, methods: { async getFormData() { - const baseData = await this.$refs.baseInfoRef.getFormData(); - const conditionData = await this.$refs.storageConditionRef.getFormData(); - const stepFormData = await this.$refs.stepFormPackageRef.getFormData(); - const stepData = await this.$refs.stepRef.getFormData(); - if (!stepData.length) { - this.$message.error(this.$t('template.common.addStepError')); - return; - } - const remarkData = await this.$refs.remarkRef.getFormData(); - + // const baseData = await this.$refs.baseInfoRef.getFormData(); + // const conditionData = await this.$refs.storageConditionRef.getFormData(); + // const stepFormData = await this.$refs.stepFormPackageRef.getFormData(); + // const stepData = await this.$refs.stepRef.getFormData(); + // const remarkData = await this.$refs.remarkRef.getFormData(); + return await this.validFormFields(["baseInfoRef", "storageConditionRef","stepFormPackageRef","stepRef","remarkRef"]); + return { ...baseData, ...conditionData, @@ -289,10 +274,7 @@ export default { }, async onSave() { // const formData = await this.getFormData(); - const result = await Promise.all([this.$refs.baseInfoRef.getFormData(), this.$refs.storageConditionRef.getFormData()]).catch(()=>{ - console.log("error") - }); - console.log(result,"res") + // console.log(formData, "formData") }, diff --git a/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue b/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue index 187ad88..e592b5f 100644 --- a/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue @@ -144,10 +144,6 @@ export default { components: { BaseInfoFormPcakge, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion }, mixins: [templateMixin], props: { - value: { - type: {}, - default: () => { }, - }, fillType: { type: String, default: 'preFill', diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index fb05cb9..266a089 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -37,7 +37,30 @@ export default { this.setTemplateData({}); }, methods: { - + //统一校验form表单是否填写 + async validFormFields(refArr = []) { + let result = {}; + const refs = refArr.map(ref => { + const refData = this.$refs[ref].getFormData(); + return refData; + }); + const validFormData = await Promise.all(refs).catch(err => { + // this.$message.error(err); + if(err.errorType && err.errorType === "step"){ + this.$message.error("请添加步骤"); + return + } + console.log(err,"err") + this.$message.error("表单内容未填完,请填写后再提交"); + }); + if(validFormData){ + validFormData.forEach(item => { + result = {...result,...item} + }) + return result; + } + return false; + }, //试验配制条件options getDictOptions(dictType) { return this.dict.type[dictType] || [];