From f2f056f95b1035eaa4faaae8b782952118b765e6 Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Wed, 14 Jan 2026 15:45:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=A4=E4=BA=92]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/BaseInfoFormPcakge.vue | 8 +- src/components/Template/HandleFormItem.vue | 147 ++++++++++++++------- .../business/comps/template/TemplateTable.vue | 42 ++++-- .../comps/template/comps/sp/SWYPFXRYPZB.vue | 14 +- 4 files changed, 146 insertions(+), 65 deletions(-) diff --git a/src/components/Template/BaseInfoFormPcakge.vue b/src/components/Template/BaseInfoFormPcakge.vue index ec26ce0..8f1287b 100644 --- a/src/components/Template/BaseInfoFormPcakge.vue +++ b/src/components/Template/BaseInfoFormPcakge.vue @@ -124,7 +124,7 @@ @change="onSelectChange(sItem.subKey, $event)" :error="errors[sItem.subKey]" @update:error="errors[sItem.subKey] = false" :orange-bg="orangeBgFields[sItem.subKey]" /> -
{{ formFields[sItem.subKey] }}
+
{{ formFields[sItem.subKey] }}
@@ -152,7 +152,7 @@ @change="onSelectChange(sItem.subKey, $event)" :error="errors[sItem.subKey]" @update:error="errors[sItem.subKey] = false" :orange-bg="orangeBgFields[sItem.subKey]" /> -
{{ formFields[sItem.subKey] }}
+
{{ formFields[sItem.subKey] }}
@@ -669,4 +669,8 @@ export default { .ml-10 { margin-left: 10px; } +.item-span{ + color: #606266; + font-size: 14px; +} \ No newline at end of file diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index 1bcf536..86747e9 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -15,7 +15,7 @@ :placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" /> @@ -34,10 +34,11 @@
- +
- +
@@ -81,9 +82,10 @@
- - + + 取 消 确 定 @@ -97,9 +99,9 @@ import Question from "./icons/Question.vue"; import DecimalInput from "./DecimalInput.vue"; import { EventBus } from "@/utils/eventBus"; import moment from "moment"; -import {deepClone} from "@/utils/index"; +import { deepClone } from "@/utils/index"; export default { - inject: ['templateFillType', "zdxgjl", "fhyjjl", "updateZdxgjl", "replaceFhyjjl", "updateFhyjjl","fieldCheckObj", "updateFieldCheckObj"], + inject: ['templateFillType', "getZdxgjl", "getFhyjjl", "updateZdxgjl", "replaceFhyjjl", "updateFhyjjl", "getFieldCheckObj", "updateFieldCheckObj"], components: { Question, DecimalInput @@ -155,8 +157,8 @@ export default { isHoveringMain: false, // 是否悬停在主元素上(这个实际上不需要,因为我们有事件处理) currentRecordType: '', // 当前悬停的记录类型(replyRecord 或 modifyRecord) replyContent: '', // 回复内容 - visible:false,//是否显示弹窗 - checked:false,//是否选中 + visible: false,//是否显示弹窗 + checked: false,//是否选中 } }, watch: { @@ -173,8 +175,8 @@ export default { }, methods: { - getChecked(){ - return !!this.fieldCheckObj[this.fieldKey]?.checked; + getChecked() { + return !!this.getFieldCheckObj()[this.fieldKey]?.checked; }, getFillTypeStyle(type) { const { fillType } = this.item; @@ -190,7 +192,7 @@ export default { return typeObj[fillType] || "" }, //确认回复 - onReplyConfirm(){ + onReplyConfirm() { if (!this.replyContent) { this.$message({ message: '请输入内容', @@ -202,33 +204,48 @@ export default { const record = { ...baseInfo, title: this.templateFillType == 'actFill' ? "回复意见" : "复核意见", + time: moment().format("YYYY-MM-DD HH:mm:ss"), } - if(this.templateFillType == 'actFill'){ + if (this.templateFillType == 'actFill') { record.replay = this.replyContent; - const deepList = deepClone(this.fhyjjl);//实际填报应该是修改指定的字段 + const deepList = deepClone(this.getFhyjjl());//实际填报应该是修改指定的字段 const item = deepList.find(o => o.key == record.key); - if(item){ + if (item) { item.replay = this.replyContent; } this.replaceFhyjjl(deepList);//实际填报应该是修改指定的字段 - }else{ + } else { + const records = this.getReplyRecords(); record.content = this.replyContent; - this.updateFhyjjl(record);//qc直接插入数据源 - } - - - const params = { - type: "reply", - newRecord: record, - resourceList: deepClone(this.fhyjjl), + if (records.length > 0) { + const o = records[0]; + if (o.reply && o.content) {//如果填报人员已回复,那么就产生一条新的记录。 + this.updateFhyjjl(record);//qc直接插入数据源 + } else {//如果填报人员未填报,只更新当条记录的复核内容 + const deepList = deepClone(this.getFhyjjl()); + const item = deepList.find(it => it.key == record.key); + if (item) { + item.content = this.replyContent; } + this.replaceFhyjjl(deepList); + } + } else { + this.updateFhyjjl(record);//qc直接插入数据源 + } + + } + const params = { + type: "reply", + newRecord: record, + resourceList: deepClone(this.getFhyjjl()), + } // 触发回复记录事件 EventBus.$emit('onModifyRecord', params); // 清空回复内容 this.replyContent = ''; // 隐藏弹窗 this.visible = false; - + }, //获取question图标颜色 getQuestionColor() { @@ -249,20 +266,23 @@ export default { }, // 复选框变化处理 onCheckboxChange(val) { - console.log(JSON.stringify({...this.fieldCheckObj,[this.fieldKey]:{checked:val}}),"kkk") // 触发修改记录事件 EventBus.$emit('onModifyRecord', { type: "checkbox", - fieldCheckObj:JSON.stringify({...this.fieldCheckObj,[this.fieldKey]:{checked:val}}),//复选框状态对象 - + fieldCheckObj: JSON.stringify({ ...this.getFieldCheckObj(), [this.fieldKey]: { checked: val } }),//复选框状态对象 + }); - this.updateFieldCheckObj({[this.fieldKey]:{checked:val}}); + this.updateFieldCheckObj({ [this.fieldKey]: { checked: val } }); // this.$emit('input', val); // this.$emit('change', val); }, + onRemoveTag(e){ + this.onCommonHandleSaveRecord(this.inputValue); + }, // 下拉框失去焦点处理 onSelectBlur(visible) { if (!visible) { + console.log(this.inputValue,"onSelectBlur") this.onCommonHandleSaveRecord(this.inputValue); } }, @@ -286,15 +306,29 @@ export default { }, // 点击question图标 onClickQuestion() { - if(this.templateFillType == 'actFill' || this.templateFillType){ - const field = this.fieldCheckObj[this.fieldKey]; - if(field && field.checked){ - this.$message({ - message: '该字段已勾选复核框,请先取消勾选后再进行提交疑问', - type: 'error' - }); - return; + const {templateFillType} = this; + if (templateFillType == 'actFill' || templateFillType == 'qc') { + if (templateFillType == 'qc') { + const field = this.getFieldCheckObj()[this.fieldKey]; + if (field && field.checked) { + this.$message({ + message: '该字段已勾选复核框,请先取消勾选后再进行提交疑问', + type: 'error' + }); + return; + } + } + const records = this.getReplyRecords(); + let content = ""; + if (records.length > 0) { + const o = records[0]; + if (!o.reply && templateFillType == 'qc') {//如果填报人员没有回复,qc点击的时候需要回填上次填报的信息 + content = o.content; + }else if(!o.content&& templateFillType == 'actFill'){//如果qc没有复核,填报点击的时候需要回填上次填报的信息 + content = o.replay; + } } + this.replyContent = content; this.visible = true; } }, @@ -310,7 +344,8 @@ export default { if (this.templateFillType === "actFill") { // 值发生了变化,需要弹出密码输入框 try { - if (this.oldValue && this.oldValue !== this.inputValue) { + const isSame = this.isEqual(this.oldValue, this.inputValue); + if (this.oldValue && !isSame) { const passwordResult = await this.$prompt('请输入密码以确认修改', '密码验证', { confirmButtonText: '确定', cancelButtonText: '取消', @@ -326,16 +361,18 @@ export default { oldValue: this.oldValue, value: this.inputValue, title: this.oldValue ? "修改记录" : "填写", + time: moment().format("YYYY-MM-DD HH:mm:ss"), + } const params = { type: "fieldChanged", newRecord: record, password: passwordResult, - resourceList: deepClone(this.zdxgjl), + resourceList: deepClone(this.getZdxgjl()), } this.$emit("onModifyRecord", params,) this.updateZdxgjl(record); - + console.log(params, "params") } //用户输入密码并点击确定,保存修改 @@ -360,6 +397,17 @@ export default { } }, + //判断两个值是否相等 + isEqual(oldValue, nowValue){ + if (oldValue === null || nowValue === null) { + return oldValue === nowValue; + } + if (typeof oldValue === 'object' && typeof nowValue === 'object') { + return JSON.stringify(oldValue) === JSON.stringify(nowValue); + } + return oldValue === nowValue; + }, + //获取公共记录信息 getCommonRecordInfo() { const { nickName, name } = this.$store.getters; @@ -377,7 +425,6 @@ export default { userNameEn: name, key: this.fieldKey, field: `${this.fieldItemLabel}-${fieldLabel}`, - time: moment().format("YYYY-MM-DD HH:mm:ss"), } return commonInfo; }, @@ -409,7 +456,7 @@ export default { //判断是否显示操作按钮 isShowHandle() { //只有当模板状态不是预填时,才显示操作按钮 - return this.templateFillType !== "preFill" + return this.templateFillType !== "preFill" }, //判断是否禁用 getDisabled() { @@ -460,14 +507,14 @@ export default { }, //获取回复记录 getReplyRecords() { - const { fieldKey, fhyjjl = [] } = this; - const records = fhyjjl.filter(item => item.key === fieldKey); + const { fieldKey, getFhyjjl } = this; + const records = getFhyjjl()?.filter(item => item.key === fieldKey) || []; return records; }, //获取字段修改记录 getModifyRecords() { - const { fieldKey, zdxgjl = [] } = this; - const records = zdxgjl.filter(item => item.key === fieldKey); + const { fieldKey, getZdxgjl } = this; + const records = getZdxgjl().filter(item => item.key === fieldKey); return records; }, // 鼠标进入主容器 @@ -580,12 +627,13 @@ export default { .handle-icon { width: 18px; height: 18px; + &:not(:last-child) { margin-right: 5px; } } -.mr-5{ +.mr-5 { margin-right: 5px !important; } @@ -797,7 +845,8 @@ export default { border-color: #f56c6c !important; } } -.dialog-footer{ + +.dialog-footer { display: flex; justify-content: flex-end; } diff --git a/src/views/business/comps/template/TemplateTable.vue b/src/views/business/comps/template/TemplateTable.vue index 3bd4d34..2c0deac 100644 --- a/src/views/business/comps/template/TemplateTable.vue +++ b/src/views/business/comps/template/TemplateTable.vue @@ -66,39 +66,58 @@ export default { handler(v) { console.log(v, "sn") } + }, + templateData: { + immediate: true, + deep: true, + handler(v) { + if(v.zdxgjl){ + this.zdxgjl = v.zdxgjl || []; + } + if(v.fhyjjl){ + this.fhyjjl = v.fhyjjl || []; + } + if(v.fieldCheckObj){ + this.fieldCheckObj = v.fieldCheckObj || {}; + } + } } }, provide() { return { //分发给子组件的fillType templateFillType: this.fillType, - zdxgjl: this.templateData?.zdxgjl || [ + getZdxgjl: ()=>(this.zdxgjl || [ {key:"versionNum",title:'提交',filed:'试验基本信息-其他信息',value:'新值',oldValue:'',reason:'修改原因',userName:'签名人',time:'2026-01-01 14:22:22'}, {key:"versionNum",title:'修改记录',filed:'试验基本信息-其他信息',value:'新值',oldValue:'原值3',reason:'修改原因',userName:'签名人',time:'2026-01-01 14:22:22'}, {key:"act",title:'修改记录',filed:'试验基本信息-其他信息',value:'ss',oldValue:'old1',reason:'修改原因1',userName:'签名人',time:'2026-01-01 14:22:22'}, {key:"startSolutionCode_0",title:'修改记录',filed:'试验基本信息-其他信息',value:'ss',oldValue:'old1',reason:'修改原因1',userName:'签名人',time:'2026-01-01 14:22:22'}, - ], - fhyjjl: this.templateData?.fhyjjl || [ + ]), + getFhyjjl: ()=>( + this.fhyjjl || [ {key:"versionNum",title:'复核意见',field:'试验基本信息-其他信息',content:'复核意见内容',replay:'',userName:'签名人',time:'2026-01-01 14:22:22',sfhf:'1'} - ], - fieldCheckObj:{ + ] + ), + getFieldCheckObj: ()=>( + this.fieldCheckObj || { versionNum:{checked:true}, act:{checked:true}, - }, + } + ), //更新提交记录 - updateZdxgjl(data){ + updateZdxgjl:(data)=>{ this.zdxgjl.unshift(data); }, //更新复核意见记录 - updateFhyjjl(data){ + updateFhyjjl:(data)=>{ this.fhyjjl.unshift(data); }, //替换复核意见记录 - replaceFhyjjl(data){ + replaceFhyjjl:(data)=>{ this.fhyjjl = data; }, //更新字段检查对象 - updateFieldCheckObj(data){ + updateFieldCheckObj:(data)=>{ this.fieldCheckObj = {...this.fieldCheckObj, ...data}; }, @@ -107,6 +126,9 @@ export default { data() { return { info: {}, + zdxgjl: [], + fhyjjl: [], + fieldCheckObj: {}, }; }, mounted() { diff --git a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue index e79c361..9285154 100644 --- a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue @@ -254,12 +254,18 @@ export default { }; }, mounted() { - if(this.fillType === "actFill"){ - this.getCode(); - } - }, + watch: { + formData: { + immediate: true, + handler(v) { + if(!v.targetCodeSn && this.fillType === "actFill"){ + this.getCode(); + } + } + } + }, methods: { //获取目标溶液编号 async getCode(){