From a3bd1361d4747c5584e4fed3423b0369c7fa25e8 Mon Sep 17 00:00:00 2001 From: yaojn Date: Thu, 27 Nov 2025 16:45:00 +0800 Subject: [PATCH] =?UTF-8?q?=20-=20[=E4=BF=AE=E5=A4=8D]=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E8=A1=A8=E6=A0=BC=E8=BE=93=E5=85=A5=E4=B8=AD?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E8=84=9A=E6=9C=AC=E4=B8=AD=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E8=A1=A8=E6=A0=BC=E8=BE=93=E5=85=A5=E5=A4=96=E7=9A=84?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=EF=BC=8C=E5=8F=96=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20=20=20=20=20-=20[=E5=85=B3=E8=81=94]#[1563?= =?UTF-8?q?641650839559]=E6=B5=81=E7=A8=8B=E8=A1=A8=E5=8D=95=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E8=BE=93=E5=85=A5=E4=B8=AD=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=B8=AD=E5=BC=95=E7=94=A8=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E5=A4=96=E7=9A=84=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E4=B8=8D=E5=88=B0=E6=95=B0=E6=8D=AE=20http:/?= =?UTF-8?q?/192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/93?= =?UTF-8?q?9050947543057/1563641650839559?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../formtableinputer/column-item.vue | 7 +- .../formtableinputer/expression-mixin.js | 66 +++++++++++++++++++ .../form/component/formtableinputer/index.vue | 15 ++++- 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 src/resources/plugins/TsSheet/form/component/formtableinputer/expression-mixin.js diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/column-item.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/column-item.vue index d18008a7d..1564bde7d 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/column-item.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/column-item.vue @@ -118,6 +118,11 @@ export default { reactionValueData: { type: Object, default: () => {} + }, + expressionData: { + // 表达式的值 + type: Object, + default: () => {} } }, data() { @@ -559,7 +564,7 @@ export default { }; }, formData() { - return {...(this.reactionValueData || {}), ...(this.rowData || {})}; + return {...(this.reactionValueData || {}), ...(this.rowData || {}), ...(this.expressionData || {})}; }, formItemUuid() { return this.formItem && this.formItem.uuid; diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/expression-mixin.js b/src/resources/plugins/TsSheet/form/component/formtableinputer/expression-mixin.js new file mode 100644 index 000000000..d99de2266 --- /dev/null +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/expression-mixin.js @@ -0,0 +1,66 @@ +export default { + methods: { + handleExpressionData({expression, formData = {}}) { + let expressionFormData = {}; + const { type = '', jsValue = '', list = [] } = expression || {}; + if (type === 'strExpression') { + list.forEach(item => { + if (item.mappingMode === 'formCommonComponent') { + const uuidList = item.value.split('#'); + const formItemValue = formData[uuidList[0]] || ''; + const uuid = uuidList[0]; + if (!this.$utils.isEmpty(formItemValue)) { + if (Array.isArray(formItemValue)) { + let multipleValueList = []; + formItemValue.forEach(a => { + if (typeof a === 'object') { + if (uuidList[1]) { + multipleValueList.push(a[uuidList[1]]); + } else { + multipleValueList.push(a['value']); + } + } else { + multipleValueList.push(a); + } + }); + expressionFormData[uuid] = multipleValueList; + } else if (typeof formItemValue === 'object') { + if (uuidList[1]) { + expressionFormData[uuidList[1]] = formItemValue[uuidList[1]] || ''; + } else { + expressionFormData[uuid] = formItemValue; + } + } else { + expressionFormData[uuid] = formItemValue; + } + } + } + }); + } else if (type === 'jsExpression' && jsValue) { + expressionFormData = this._getFormlabelMapping(formData); + } + return expressionFormData; + }, + _getFormlabelMapping(formData) { + let data = {}; + const whiteList = ['formtext', 'formdate', 'formtime', 'formselect', 'formradio', 'formnumber']; + this.formItemList.forEach(item => { + if (whiteList.includes(item.handler)) { + data[item.uuid] = formData[item.uuid]; + } else { + if (item.config && item.config.dataConfig) { + const findItem = item.config.dataConfig.find(a => a.uuid === this.formItem.uuid); + if (findItem) { + item.config.dataConfig.forEach(a => { + if (whiteList.includes(a.handler)) { + data[a.uuid] = formData[a.uuid]; + } + }); + } + } + } + }); + return data; + } + } +}; diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue index fea45a586..72f461c13 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue @@ -130,6 +130,7 @@ :extraUuid="extra.uuid" :reactionData="getReactionData(extra, row)" :reactionValueData="reactionValuesMap[extra.uuid]" + :expressionData="getExpressionData(extra)" class="form-item-width" @change="changeRow" @getCurrentRowData="getCurrentRowData" @@ -163,6 +164,7 @@ import base from '../base.vue'; import validmixin from '../common/validate-mixin.js'; import conditionMixin from './condition-mixin.js'; +import expressionMixin from './expression-mixin.js'; import TableImportExportMixin from './table-import-export-mixin.js'; export default { name: '', @@ -172,7 +174,7 @@ export default { ColumnItem: () => import('@/resources/plugins/TsSheet/form/component/formtableinputer/column-item.vue') }, extends: base, - mixins: [validmixin, conditionMixin, TableImportExportMixin], + mixins: [validmixin, conditionMixin, expressionMixin, TableImportExportMixin], props: { readonly: { type: Boolean, default: false }, disabled: { type: Boolean, default: false } @@ -684,6 +686,17 @@ export default { return result; }; }, + getExpressionData() { + return (extra) => { + const { handler, config = {} } = extra || {}; + const { expression } = config || {}; + let resultData = {}; + if (handler === 'formexpression') { + resultData = this.handleExpressionData({expression: expression, formData: this.formData}); + } + return resultData; + }; + }, frozenFormItemList() { return Object.freeze([...this.formItemList || []]); // 解构不影响原数据 }, -- Gitee