From ba345e07ba90e9b0b05d5d81b294df426285a560 Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Wed, 14 Jan 2026 20:43:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E5=A4=8D=E6=A0=B8=E8=B0=83=E8=AF=95]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/HandleFormItem.vue | 103 +++++++++++---------- .../business/comps/template/TemplateTable.vue | 52 ++++++----- .../comps/template/comps/sp/SWYPFXRYPZB.vue | 1 + 3 files changed, 83 insertions(+), 73 deletions(-) diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index 3f553f5..633be2d 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -91,6 +91,7 @@ 确 定 + @@ -100,11 +101,13 @@ import DecimalInput from "./DecimalInput.vue"; import { EventBus } from "@/utils/eventBus"; import moment from "moment"; import { deepClone } from "@/utils/index"; +import EditSign from "@/views/business/comps/template/dialog/EditSign.vue" export default { inject: ['templateFillType', "getZdxgjl", "getFhyjjl", "updateZdxgjl", "replaceFhyjjl", "updateFhyjjl", "getFieldCheckObj", "updateFieldCheckObj"], components: { Question, - DecimalInput + DecimalInput, + EditSign, }, props: { type: {//form类型 input/select等 @@ -174,7 +177,9 @@ export default { console.log(this.$i18n.locale, "locale") }, methods: { - + onEditSignSave(data){ + this.handleUpdateRecord(data) + }, getChecked() { return !!this.getFieldCheckObj()[this.fieldKey]?.checked; }, @@ -235,9 +240,10 @@ export default { } const params = { - type: "reply", + //reply:回复,content:复核 + type: this.templateFillType == 'actFill' ? "reply" : "content", newRecord: record, - resourceList: deepClone(this.getFhyjjl()), + resourceList: this.getFhyjjl(), } // 触发回复记录事件 EventBus.$emit('onModifyRecord', params); @@ -305,7 +311,7 @@ export default { }, // 点击question图标 onClickQuestion() { - const {templateFillType} = this; + const {templateFillType} = this; if (templateFillType == 'actFill' || templateFillType == 'qc') { if (templateFillType == 'qc') { const field = this.getFieldCheckObj()[this.fieldKey]; @@ -342,50 +348,15 @@ export default { // 检查值是否发生变化 if (this.templateFillType === "actFill") { // 值发生了变化,需要弹出密码输入框 - try { - const isSame = this.isEqual(this.oldValue, this.inputValue); - if (this.oldValue && !isSame) { - const passwordResult = await this.$prompt('请输入密码以确认修改', '密码验证', { - confirmButtonText: '确定', - cancelButtonText: '取消', - inputType: 'password', - inputPattern: /.+/, - inputErrorMessage: '请输入密码', - zIndex: 10000, - }); - - - - } - const baseInfo = this.getCommonRecordInfo(); - const record = { - ...baseInfo, - oldValue: this.oldValue, - value: this.inputValue, - title: this.oldValue ? "修改记录" : "填写", - time: moment().format("YYYY-MM-DD HH:mm:ss"), - } - const params = { - type: "fieldChanged", - newRecord: record, - resourceList: deepClone(this.getZdxgjl()), - } - EventBus.$emit('onModifyRecord', params,) - this.updateZdxgjl(record); - //用户输入密码并点击确定,保存修改 - this.oldValue = this.inputValue; // 更新旧值 - this.$emit("blur", val); - this.$emit('input', this.inputValue); - this.$emit("change", val); - // 调用后端接口记录修改记录 - // await this.saveModificationRecord(); - } catch { - // 用户点击取消,还原数据 - this.inputValue = this.oldValue; - this.$emit('input', this.inputValue); // 触发 v-model 更新 - this.$emit("blur", this.oldValue); - this.$emit("change", this.oldValue); + const isSame = this.isEqual(this.oldValue, this.inputValue); + if (this.oldValue && !isSame) { + this.$refs.editSignRef.show() + + } + if(!this.oldValue){//如果是第一次填写,不需要密码验证 + this.handleUpdateRecord() } + } else { // 值没有变化,正常触发 blur和change 事件 this.$emit("blur", val) @@ -394,6 +365,42 @@ export default { } }, + //如果用户取消,那么回退到上一次的值 + resetRecord(){ + // 用户点击取消,还原数据 + this.inputValue = this.oldValue; + this.$emit('input', this.inputValue); // 触发 v-model 更新 + this.$emit("blur", this.oldValue); + this.$emit("change", this.oldValue); + }, + + //处理更新记录 + handleUpdateRecord(data){ + const baseInfo = this.getCommonRecordInfo(); + const record = { + ...baseInfo, + oldValue: this.oldValue, + value: this.inputValue, + title: this.oldValue ? "修改记录" : "填写", + time: moment().format("YYYY-MM-DD HH:mm:ss"), + } + if(data){ + record.reason = data.remark + } + const params = { + type: "fieldChanged", + newRecord: record, + resourceList: deepClone(this.getZdxgjl()), + } + EventBus.$emit('onModifyRecord', params,) + this.updateZdxgjl(record); + //用户输入密码并点击确定,保存修改 + this.oldValue = this.inputValue; // 更新旧值 + this.$emit("blur", this.inputValue); + this.$emit('input', this.inputValue); + this.$emit("change", this.inputValue); + }, + //判断两个值是否相等 isEqual(oldValue, nowValue){ if (oldValue === null || nowValue === null) { diff --git a/src/views/business/comps/template/TemplateTable.vue b/src/views/business/comps/template/TemplateTable.vue index 0fdeeed..1ddd89b 100644 --- a/src/views/business/comps/template/TemplateTable.vue +++ b/src/views/business/comps/template/TemplateTable.vue @@ -71,14 +71,16 @@ export default { 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 || {}; + if (v) { + if (v.zdxgjl) { + this.zdxgjl = v.zdxgjl || []; + } + if (v.fhyjjl) { + this.fhyjjl = v.fhyjjl || []; + } + if (v.fieldCheckObj) { + this.fieldCheckObj = v.fieldCheckObj || {}; + } } } } @@ -87,38 +89,38 @@ export default { return { //分发给子组件的fillType templateFillType: this.fillType, - 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'}, + 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' }, ]), - getFhyjjl: ()=>( + getFhyjjl: () => ( this.fhyjjl || [ - {key:"versionNum",title:'复核意见',field:'试验基本信息-其他信息',content:'复核意见内容',replay:'',userName:'签名人',time:'2026-01-01 14:22:22',sfhf:'1'} - ] + { key: "versionNum", title: '复核意见', field: '试验基本信息-其他信息', content: '复核意见内容', replay: '', userName: '签名人', time: '2026-01-01 14:22:22', sfhf: '1' } + ] ), - getFieldCheckObj: ()=>( + getFieldCheckObj: () => ( this.fieldCheckObj || { - versionNum:{checked:true}, - act:{checked:true}, - } + 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)=>{ - this.fieldCheckObj = {...this.fieldCheckObj, ...data}; + updateFieldCheckObj: (data) => { + this.fieldCheckObj = { ...this.fieldCheckObj, ...data }; }, } diff --git a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue index 9285154..3df90db 100644 --- a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue @@ -26,6 +26,7 @@ +