From 70e7d11a73f1c064582e062f6163ed555192dfd1 Mon Sep 17 00:00:00 2001 From: yaojn Date: Wed, 30 Apr 2025 15:49:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85-=E8=A1=A8=E5=8D=95=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=EF=BC=9A=E5=A4=B1=E5=8E=BB=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=BA=90=E6=97=B6=EF=BC=8C=E9=9C=80=E8=A6=81=E5=9B=9E?= =?UTF-8?q?=E6=98=BE=E6=97=A7=E6=95=B0=E6=8D=AE=20=20=20=20-=20[=E5=85=B3?= =?UTF-8?q?=E8=81=94]#[1364339037011968]=E5=B7=A5=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85-=E8=A1=A8=E5=8D=95=E7=BB=84=E4=BB=B6=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=A1=86=EF=BC=9A=E5=A4=B1=E5=8E=BB=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E6=97=B6=EF=BC=8C=E9=9C=80=E8=A6=81=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=E6=97=A7=E6=95=B0=E6=8D=AE=20http://192.168.0.96:8090/demo/rdm?= =?UTF-8?q?.html#/story-detail/939050947543040/939050947543042/13643390370?= =?UTF-8?q?11968?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/mixins/formMixins.js | 39 +++++++++++++ .../plugins/TsForm/TsFormCheckbox.vue | 56 +++++++++++-------- src/resources/plugins/TsForm/TsFormRadio.vue | 55 +++++++++++------- src/resources/plugins/TsForm/TsFormSelect.vue | 19 +------ src/resources/plugins/TsSheet/form-item.vue | 2 + .../TsSheet/form/component/formcheckbox.vue | 1 + .../TsSheet/form/component/formradio.vue | 1 + .../TsSheet/form/component/formselect.vue | 1 + 8 files changed, 113 insertions(+), 61 deletions(-) diff --git a/src/resources/mixins/formMixins.js b/src/resources/mixins/formMixins.js index 5dd33766..f2433ffa 100644 --- a/src/resources/mixins/formMixins.js +++ b/src/resources/mixins/formMixins.js @@ -50,6 +50,11 @@ export default { // 是否自定义值,单个字符串(value:1)可以自定义返回{text:1,value:1},数组[1]可以自定义返回[{text:1,value:1}] type: Boolean, default: false + }, + historyValue: { + // 历史值(Object包含text,value)存在时,用历史值回显数据(在dynamicUrl初始化时,不调用接口) + type: [String, Array, Object], + default: null } }, methods: { @@ -280,6 +285,40 @@ export default { } return value; }; + }, + handleHistoryValue() { + let selectedList = []; + return historyData => { + let historyValueList = Array.isArray(historyData) ? historyData : [historyData]; + historyValueList.forEach(item => { + if (!this.$utils.isEmpty(item)) { + let obj = {}; + if (typeof item === 'object') { + obj[this.valueName] = item.value; + obj[this.textName] = item.text; + } else { + obj[this.valueName] = obj[this.textName] = item; + } + selectedList.push(obj); + } + }); + return selectedList; + }; + }, + getSelectedText() { + return (val) => { + const getNodeText = (node) => node && node[this.textName] ? node[this.textName] : '-'; + let node = this.nodeList.find(item => item[this.valueName] == val); + if (node) { + return getNodeText(node); + } else if (!this.$utils.isEmpty(this.historyValue)) { + const nodeList = this.handleHistoryValue(this.historyValue); + const nodeItem = nodeList.find(item => item[this.valueName] == val); + return getNodeText(nodeItem); + } else { + return '-'; + } + }; } }, diff --git a/src/resources/plugins/TsForm/TsFormCheckbox.vue b/src/resources/plugins/TsForm/TsFormCheckbox.vue index 12b0d146..442d4e9f 100755 --- a/src/resources/plugins/TsForm/TsFormCheckbox.vue +++ b/src/resources/plugins/TsForm/TsFormCheckbox.vue @@ -1,13 +1,13 @@