From 0d415e9a08480ebcd2b6bc317dce640372f01053 Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Sat, 10 Jan 2026 20:03:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][blu?= =?UTF-8?q?r=E4=BA=8B=E4=BB=B6=E8=AE=B0=E5=BD=95=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=9A=84=E5=80=BC]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/HandleFormItem.vue | 62 ++++- .../business/comps/template/TemplateTable.vue | 5 +- .../comps/template/comps/sp/IndexDBDemo.vue | 261 +++++++++++++++++++++ .../comps/template/mixins/templateMixin.js | 2 + 4 files changed, 325 insertions(+), 5 deletions(-) create mode 100644 src/views/business/comps/template/comps/sp/IndexDBDemo.vue diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index e146ec4..158001e 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -84,7 +84,8 @@ export default { }, data() { return { - inputValue: this.value + inputValue: this.value, + oldValue: this.value, // 记录上一次的值 } }, watch: { @@ -198,7 +199,7 @@ export default { onCopy() { this.$emit("copy") }, - onBlur(val) { + async onBlur(val) { // 根据输入值判断是否显示错误状态 const isEmpty = this.isValueEmpty(this.inputValue); if (this.error && !isEmpty) { @@ -206,8 +207,63 @@ export default { } else if (!this.error && isEmpty) { this.$emit('update:error', true); } - this.$emit("blur", val) + + // 检查值是否发生变化 + if (this.inputValue !== this.oldValue && this.fillType === "actFill") { + return; + // 值发生了变化,需要弹出密码输入框 + try { + const passwordResult = await this.$prompt('请输入密码以确认修改', '密码验证', { + confirmButtonText: '确定', + cancelButtonText: '取消', + inputType: 'password', + inputPattern: /.+/, + inputErrorMessage: '请输入密码' + }); + + // 用户输入密码并点击确定,保存修改 + this.oldValue = this.inputValue; // 更新旧值 + this.$emit("blur", val); + + // 调用后端接口记录修改记录 + await this.saveModificationRecord(passwordResult.value); + } catch { + // 用户点击取消,还原数据 + this.inputValue = this.oldValue; + this.$emit('input', this.oldValue); // 触发 v-model 更新 + this.$emit("blur", this.oldValue); + } + } else { + // 值没有变化,正常触发 blur 事件 + this.$emit("blur", val) + } }, + // 记录数据修改 + async saveModificationRecord(password) { + // 这里可以调用后端API记录修改记录 + // 示例: + // const recordData = { + // field: this.item.label || '', // 字段名 + // oldValue: this.oldValue, // 旧值 + // newValue: this.inputValue, // 新值 + // timestamp: Date.now(), // 时间戳 + // password: password // 用户输入的密码 + // }; + // try { + // await api.recordModification(recordData); + // } catch (error) { + // this.$message.error('记录修改失败'); + // console.error('记录修改失败:', error); + // } + + // 发送事件告知父组件值已修改 + this.$emit('modification-recorded', { + field: this.item.label || '', + oldValue: this.oldValue, + newValue: this.inputValue, + password: password + }); + } }, } diff --git a/src/views/business/comps/template/TemplateTable.vue b/src/views/business/comps/template/TemplateTable.vue index c5e8fb0..081de54 100644 --- a/src/views/business/comps/template/TemplateTable.vue +++ b/src/views/business/comps/template/TemplateTable.vue @@ -15,6 +15,7 @@ import SWYPFXCBYPZB from "./comps/sp/SWYPFXCBYPZB.vue"; import SWYPBQGZYZBB from "./comps/sp/SWYPBQGZYZBB.vue"; import SWYPNBGZYZBB from "./comps/sp/SWYPNBGZYZBB.vue"; import Demo from "./comps/sp/Demo.vue"; +import IndexDBDemo from "./comps/sp/IndexDBDemo.vue"; //公用 import SYWZPZJHB from "./comps/gy/SYWZPZJHB.vue"; import MJYLQSQD from "./comps/gy/MJYLQSQD.vue"; @@ -23,7 +24,7 @@ export default { name: "TemplateTable", components: { MJYLQSQD,SYWZPZJHB, - SP001,SWYPFXRYPZB ,Demo,SWYPFXCBYPZB,SWYPBQGZYZBB,SWYPNBGZYZBB, + SP001,SWYPFXRYPZB ,Demo,SWYPFXCBYPZB,SWYPBQGZYZBB,SWYPNBGZYZBB,IndexDBDemo }, props: { sn: { @@ -50,7 +51,7 @@ export default { 'SP004': 'SWYPNBGZYZBB', 'SYWZPZJHB': 'SYWZPZJHB', 'MJYLQSQD': 'MJYLQSQD', - // 'SP001': 'Demo', + // 'SP001': 'IndexDBDemo', } } return this.componentMap || "Demo" diff --git a/src/views/business/comps/template/comps/sp/IndexDBDemo.vue b/src/views/business/comps/template/comps/sp/IndexDBDemo.vue new file mode 100644 index 0000000..f325d41 --- /dev/null +++ b/src/views/business/comps/template/comps/sp/IndexDBDemo.vue @@ -0,0 +1,261 @@ + + + + + \ No newline at end of file diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index 5f140c9..811d4e8 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -14,9 +14,11 @@ export default { handler(v) { if (v) { let n = { ...v }; + this.formData =n; if (v.bdnr) { this.formData = { ...n, ...JSON.parse(v.bdnr) }; } + this.setTemplateData(n); } }