From 99325dd36753f227b2259d79350493421ffb91a6 Mon Sep 17 00:00:00 2001 From: dengbf Date: Thu, 8 May 2025 18:48:05 +0800 Subject: [PATCH 1/3] =?UTF-8?q?-=20[=E5=85=B3=E8=81=94]=20#[14159593345843?= =?UTF-8?q?20]IT=E6=9C=8D=E5=8A=A1=E5=AE=9A=E5=88=B6=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=A0=87=E7=AD=BE=E6=95=B0=E6=8D=AE=E8=83=BD?= =?UTF-8?q?=E8=A2=AB=E5=B8=B8=E8=A7=84=E9=85=8D=E7=BD=AE=E7=9A=84=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E7=BB=84=E4=BB=B6=E6=B6=88=E8=B4=B9=20http://192.168.?= =?UTF-8?q?0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947?= =?UTF-8?q?543042/1415959334584320?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/plugins/TsSheet/TsSheet.vue | 14 +- src/resources/plugins/TsSheet/form-edit.vue | 2 + .../plugins/TsSheet/form-item-config.vue | 7 +- src/resources/plugins/TsSheet/form-item.vue | 7 +- .../plugins/TsSheet/form/component/base.vue | 5 + .../form/component/common/validate-mixin.js | 10 + .../TsSheet/form/component/formselect.vue | 62 ++++++ .../form/component/formtableinputer/index.vue | 1 + .../TsSheet/form/config/base-config.vue | 6 +- .../form/config/common/tag-source-setting.vue | 189 ++++++++++++++++++ .../TsSheet/form/config/formselect-conf.vue | 17 +- .../formtableinputer-attr-config-dialog.vue | 21 +- .../config/formtableinputer-conf/index.vue | 1 + 13 files changed, 332 insertions(+), 10 deletions(-) create mode 100644 src/resources/plugins/TsSheet/form/config/common/tag-source-setting.vue diff --git a/src/resources/plugins/TsSheet/TsSheet.vue b/src/resources/plugins/TsSheet/TsSheet.vue index 0935d6568..4068f5671 100644 --- a/src/resources/plugins/TsSheet/TsSheet.vue +++ b/src/resources/plugins/TsSheet/TsSheet.vue @@ -316,6 +316,7 @@ :formExtendData="formExtendData" :isClearSpecifiedAttr="isClearSpecifiedAttr" :externalData="externalData" + :extendConfigList="extendConfigList" :rowUuid="rowUuid" class="padding-xs" @changeConfig="addHistory()" @@ -517,7 +518,12 @@ export default { type: Object, default: () => {} }, - rowUuid: String //表单子组件行uuid + rowUuid: String, //表单子组件行uuid + defaultExtendConfigList: { + // 扩展配置列表 + type: Array, + default: () => [] + } }, data() { return { @@ -561,7 +567,8 @@ export default { currentEventItem: null, //当前单元格获取的新组件 actionType: '', //当前操作类型,'add'新增组件,'copy'复制组件 windowKeypressHandler: null, // 用于存储事件处理函数的引用 - formStyleData: {} //表单样式设置 + formStyleData: {}, //表单样式设置 + extendConfigList: this.defaultExtendConfigList || [] //扩展配置列表 }; }, beforeCreate() { @@ -702,6 +709,9 @@ export default { //初始化表格 initSheet() { this.hideComponentList = this.value?.hideComponentList || []; + if (this.value && this.value.formCustomExtendConfig && !this.$utils.isEmpty(this.value.formCustomExtendConfig.extendConfigList)) { + this.extendConfigList = this.value.formCustomExtendConfig.extendConfigList; + } if (this.value && this.value.lefterList && this.value.headerList && this.value.tableList) { /** * 编辑模式下,直接将外部数据赋值给config,这样在外部对数据做了修改,也能触发表格控件发生变化。 diff --git a/src/resources/plugins/TsSheet/form-edit.vue b/src/resources/plugins/TsSheet/form-edit.vue index 194732839..c832f2011 100644 --- a/src/resources/plugins/TsSheet/form-edit.vue +++ b/src/resources/plugins/TsSheet/form-edit.vue @@ -259,6 +259,7 @@ ref="sheet" v-model="formData.formConfig" :readonly="readOnly" + :defaultExtendConfigList="extendConfigList" @selectCell="selectCell" @removeComponent="removeComponent" @updateResize="updateResize" @@ -269,6 +270,7 @@ :formItem="currentFormItem" :formItemList="cellFormItemList" :error="currentFormItemError" + :extendConfigList="extendConfigList" class="form-item-config bg-grey border-base-left" @close="currentFormItem = null" @editSubForm="editSubForm" diff --git a/src/resources/plugins/TsSheet/form-item-config.vue b/src/resources/plugins/TsSheet/form-item-config.vue index 4ca9df69b..fb7ee04c0 100644 --- a/src/resources/plugins/TsSheet/form-item-config.vue +++ b/src/resources/plugins/TsSheet/form-item-config.vue @@ -30,6 +30,7 @@ :disabled="!!formItem.inherit || disabled" :initFormItemList="initFormItemList" :source="source" + :extendConfigList="extendConfigList" class="mb-sm" @editSubForm="editSubForm" @setValue="(value)=> updateComponentConfig(formItem.handler, value)" @@ -125,7 +126,11 @@ export default { type: Array, default: () => [] }, - source: { type: String, default: '' } //表单组件配置来源:scene(场景) + source: { type: String, default: '' }, //表单组件配置来源:scene(场景) + extendConfigList: { //扩展的表单组件列表 + type: Array, + default: () => [] + } }, data() { const _this = this; diff --git a/src/resources/plugins/TsSheet/form-item.vue b/src/resources/plugins/TsSheet/form-item.vue index c48f59ce1..041b879c1 100644 --- a/src/resources/plugins/TsSheet/form-item.vue +++ b/src/resources/plugins/TsSheet/form-item.vue @@ -71,6 +71,7 @@ :isClearSpecifiedAttr="isClearSpecifiedAttr" :externalData="externalData" :rowUuid="rowUuid" + :extendConfigList="extendConfigList" @setValue="setValue" @resize="$emit('resize')" @select="selectFormItem" @@ -199,7 +200,11 @@ export default { type: Object, default: () => {} }, - rowUuid: { type: String } //行uuid,表格组件引用时需要 + rowUuid: { type: String }, //行uuid,表格组件引用时需要 + extendConfigList: { + type: Array, + default: () => [] + } }, data() { return { diff --git a/src/resources/plugins/TsSheet/form/component/base.vue b/src/resources/plugins/TsSheet/form/component/base.vue index 115ebbd6b..b203d8ddc 100644 --- a/src/resources/plugins/TsSheet/form/component/base.vue +++ b/src/resources/plugins/TsSheet/form/component/base.vue @@ -33,6 +33,11 @@ export default { // 外部数据,非表单数据,例如工单上报人数据等 type: Object, default: () => {} + }, + extendConfigList: { + // 扩展配置列表 + type: Array, + default: () => [] } }, data() { diff --git a/src/resources/plugins/TsSheet/form/component/common/validate-mixin.js b/src/resources/plugins/TsSheet/form/component/common/validate-mixin.js index e2ffe36f3..a2590e420 100644 --- a/src/resources/plugins/TsSheet/form/component/common/validate-mixin.js +++ b/src/resources/plugins/TsSheet/form/component/common/validate-mixin.js @@ -68,6 +68,16 @@ export default { } } } + } else if (this.config.dataSource === 'tag') { + if (!this.config.tagKey) { + errorList.push({field: 'tagKey', error: $t('form.placeholder.pleaseselect', {'target': $t('page.tag')})}); + } + if (!this.config.tableKey) { + errorList.push({field: 'tableKey', error: $t('form.placeholder.pleaseselect', {'target': $t('term.framework.tablecomponent')})}); + } + if (!this.config.mapping.value || !this.config.mapping.text) { + errorList.push({field: 'mapping', error: $t('form.placeholder.pleaseselect', {'target': $t('page.fieldmapping')})}); + } } return errorList; } diff --git a/src/resources/plugins/TsSheet/form/component/formselect.vue b/src/resources/plugins/TsSheet/form/component/formselect.vue index 17d5ae16d..70085fd8f 100644 --- a/src/resources/plugins/TsSheet/form/component/formselect.vue +++ b/src/resources/plugins/TsSheet/form/component/formselect.vue @@ -101,6 +101,66 @@ export default { } else { return value; } + }, + getFormData(formData) { + const formItemList = []; + for (let key in formData) { + const formitem = this.formItemList.find(d => d.uuid === key); + if (formitem) { + formItemList.push({ + attributeUuid: key, + key: formitem.key, + handler: formitem.handler, + dataList: formData[key] + }); + } + } + return formItemList; + }, + getFormCustomexend(formData) { + let list = []; + let currentData = this.getFormData(formData); + if (!this.$utils.isEmpty(this.extendConfigList)) { + this.extendConfigList.forEach(item => { + this.$ = {}; + try { + if (item.extendMethods) { + // eslint-disable-next-line no-eval + const dataMethods = eval('(' + item.extendMethods + ')'); + Object.keys(dataMethods).forEach(methodsName => { + if (typeof dataMethods[methodsName] === 'function' && !this.$.methodsName) { + this.$[methodsName] = dataMethods[methodsName].bind(this); + } + }); + if (currentData) { + let outinpuData = this.$.main(item.attributeList, currentData); + list.push(...outinpuData); + } + } + } catch (e) { + console.error(e); + } + }); + } + return list; + }, + getTagDataList(formData) { + let list = this.getFormCustomexend(formData); + let dataList = []; + if (!this.$utils.isEmpty(list)) { + let findItem = list.find(item => item.tag === this.config.tagKey && item.key === this.config.tableKey); + if (findItem) { + findItem.dataList.forEach(item => { + if (item[this.config.mapping.value] && !dataList.find(d => d.value === item[this.config.mapping.value])) { + dataList.push({ + value: item[this.config.mapping.value], + text: item[this.config.mapping.text] + }); + } + }); + } + } + return dataList; } }, filter: {}, @@ -230,6 +290,8 @@ export default { } } } + } else if (this.config.dataSource === 'tag') { + setting.dataList = this.getTagDataList(this.formData); } else { setting.showName = 'text'; setting.dataList = this.validatedDataList; diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue index 6d9cc571e..50bd6d0f2 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue @@ -84,6 +84,7 @@ :isClearSpecifiedAttr="isClearSpecifiedAttr" :externalData="externalData" :rowUuid="row.uuid" + :extendConfigList="extendConfigList" style="min-width: 130px" @change="val => changeRow(val, extra.uuid, row)" @updateCurrentRow=" diff --git a/src/resources/plugins/TsSheet/form/config/base-config.vue b/src/resources/plugins/TsSheet/form/config/base-config.vue index 868e148ac..46fb5b7e5 100644 --- a/src/resources/plugins/TsSheet/form/config/base-config.vue +++ b/src/resources/plugins/TsSheet/form/config/base-config.vue @@ -9,7 +9,11 @@ export default { type: Array, default: () => [] }, - source: { type: String, default: '' } //表单组件配置来源:scene(场景) + source: { type: String, default: '' }, //表单组件配置来源:scene(场景) + extendConfigList: { //扩展数据标签配置列表 + type: Array, + default: () => [] + } }, methods: { //设置属性值 diff --git a/src/resources/plugins/TsSheet/form/config/common/tag-source-setting.vue b/src/resources/plugins/TsSheet/form/config/common/tag-source-setting.vue new file mode 100644 index 000000000..aa8f4e114 --- /dev/null +++ b/src/resources/plugins/TsSheet/form/config/common/tag-source-setting.vue @@ -0,0 +1,189 @@ + + + diff --git a/src/resources/plugins/TsSheet/form/config/formselect-conf.vue b/src/resources/plugins/TsSheet/form/config/formselect-conf.vue index eaac3a713..b8a3da7e4 100644 --- a/src/resources/plugins/TsSheet/form/config/formselect-conf.vue +++ b/src/resources/plugins/TsSheet/form/config/formselect-conf.vue @@ -161,6 +161,15 @@ > +