From 651234ab99b6ac48eaff12ec58b33cf023c39c36 Mon Sep 17 00:00:00 2001 From: Xia Zekun Date: Tue, 19 Mar 2024 15:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E5=87=86=E6=80=A7=E8=B4=A8=E6=98=AF?= =?UTF-8?q?=E5=87=86=E5=85=A5,=E7=8A=B6=E6=80=81=E4=B8=BA=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E3=80=81=E5=8D=B3=E5=B0=86=E5=AE=9E=E6=96=BD=E5=92=8C?= =?UTF-8?q?=E7=8E=B0=E8=A1=8C=E6=9C=89=E6=95=88=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=20=20=E6=96=B0=E8=BD=A6=E5=9E=8B=E5=AE=9E=E6=96=BD=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E5=92=8C=E5=9C=A8=E4=BA=A7=E8=BD=A6=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E6=96=BD=E6=97=A5=E6=9C=9F=20=E9=83=BD=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/customField/AddForm.vue | 33 ++++++++++++ .../StandardEntryOrChangeProcess.vue | 51 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/src/components/customField/AddForm.vue b/src/components/customField/AddForm.vue index bb837871..4a7bb1cf 100644 --- a/src/components/customField/AddForm.vue +++ b/src/components/customField/AddForm.vue @@ -340,6 +340,7 @@ export default { // 国内的零部件分类、适用认证、适用车型和标准性质关联,准入标准必填,非准入标准不必填 'formInline.standard_property' () { this.handleDomesticSpecialCheck() + this.handleStatePropertyCheck() }, // 标准等级分类改变后授权部门需要自动带出 'formInline.grade_classification' (val) { @@ -501,6 +502,7 @@ export default { } // 起草、征求依据、报批、废止状态时发布日期、实施日期不必填 this.handleRequiredByState(val) + this.handleStatePropertyCheck() }, // 企标:企业标准代号选Q,企业名称代号只能选ZZ\ZR;标准代号选TS,企业名称代号只能选ZZ 'formInline.standard_code' (val) { @@ -758,6 +760,37 @@ export default { clearValidate (fieldNameList) { this.$refs.ruleForm.clearValidate(fieldNameList) }, + /** + * 标准性质是准入,状态为发布、即将实施和现行有效的时候 新车型实施日期和在产车的实施日期 都改成必填 + */ + handleStatePropertyCheck () { + const mustFillFields = ['new_model_implementation_date', 'on_the_production_date'] + const rules = JSON.parse(JSON.stringify(this.rules)) + if (this.formInline.standard_property === StandardProperty.admittance.value && ( + this.formInline.standard_state === StandardStatus.RELEASE.value || + this.formInline.standard_state === StandardStatus.BE_IMPLEMENTED_SOON.value || + this.formInline.standard_state === StandardStatus.CURRENTLY_EFFECTIVE.value)) { + mustFillFields.forEach(key => { + if (rules[key] && rules[key].length > 0) { + rules[key][0].required = true + const dataPart = Object.keys(this.dataList).find(tt => this.dataList[tt].some(item => item.dbFieldName === key)) + const index = this.dataList[dataPart].findIndex(tt => tt.dbFieldName === key) + this.dataList[dataPart][index].fieldMustInput = '1' + } + }) + } else { + mustFillFields.forEach(key => { + if (rules[key] && rules[key].length > 0) { + rules[key][0].required = false + const dataPart = Object.keys(this.dataList).find(tt => this.dataList[tt].some(item => item.dbFieldName === key)) + const index = this.dataList[dataPart].findIndex(tt => tt.dbFieldName === key) + this.dataList[dataPart][index].fieldMustInput = '0' + } + }) + } + this.rules = Object.assign({}, rules) + this.clearValidate(mustFillFields) + }, /** * 国内海外的特殊处理 */ diff --git a/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue b/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue index 96042233..f3143480 100644 --- a/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue +++ b/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue @@ -501,10 +501,12 @@ export default { // 国内的零部件分类、适用认证、适用车型和标准性质关联,准入标准必填,非准入标准不必填 'formInline.standard_property' () { this.handleDomesticSpecialCheck() + this.handleStatePropertyCheck() }, 'formInline.standard_state' (val) { // 起草、征求依据、报批状态时发布日期、实施日期不必填 this.handleRequiredByState(val) + this.handleStatePropertyCheck() }, /** * 生成流程名称 @@ -1203,6 +1205,55 @@ export default { this.rules = Object.assign({}, rules) this.$refs.ruleForm.clearValidate(fieldNameList) }, + /** + * 标准性质是准入,状态为发布、即将实施和现行有效的时候 新车型实施日期和在产车的实施日期 都改成必填 + */ + handleStatePropertyCheck () { + const mustFillFields = ['new_model_implementation_date', 'on_the_production_date'] + const rules = JSON.parse(JSON.stringify(this.rules)) + // console.log('this.formListArr', this.formListArr) + console.log('this.formList', this.formList) + // 逻辑: 如果rules里没有mustFillFields里的所需字段 + // 就去 this.formListArr 里寻找其名字,然后填入规则 + mustFillFields.forEach(key => { + if (!Object.keys(rules).includes(key)) { + console.log('rules不包含', key, '尝试查找添加') + const fieldInfo = this.formListArr.find(item => item.dbFieldName === key) + rules[key] = [{ + required: false, + message: fieldInfo.dbFieldTxt + this.$t('cannotEmpty'), + trigger: 'blur' + }] + console.log('添加rule.', key, rules[key]) + } + }) + if (this.formInline.standard_property === StandardProperty.admittance.value && ( + this.formInline.standard_state === StandardStatus.RELEASE.value || + this.formInline.standard_state === StandardStatus.BE_IMPLEMENTED_SOON.value || + this.formInline.standard_state === StandardStatus.CURRENTLY_EFFECTIVE.value)) { + console.log('标准性质是准入,状态为发布、即将实施和现行有效的时候 新车型实施日期和在产车的实施日期 都改成必填') + mustFillFields.forEach(key => { + if (rules[key] && rules[key].length > 0) { + rules[key][0].required = true + const dataPart = Object.keys(this.formList).find(tt => this.formList[tt].some(item => item.dbFieldName === key)) + const index = this.formList[dataPart].findIndex(tt => tt.dbFieldName === key) + this.formList[dataPart][index].fieldMustInput = '1' + } + }) + } else { + console.log('标准性质是准入,状态为发布、即将实施和现行有效 已不符合, 取消 新车型实施日期和在产车的实施日期 的必填') + mustFillFields.forEach(key => { + if (rules[key] && rules[key].length > 0) { + rules[key][0].required = false + const dataPart = Object.keys(this.formList).find(tt => this.formList[tt].some(item => item.dbFieldName === key)) + const index = this.formList[dataPart].findIndex(tt => tt.dbFieldName === key) + this.formList[dataPart][index].fieldMustInput = '0' + } + }) + } + this.rules = Object.assign({}, rules) + this.$refs.ruleForm.clearValidate(mustFillFields) + }, /** * 获取海外的表单数据 * @param id