From 331723ed31a71f2161e3b076534afc2cebf7a34d Mon Sep 17 00:00:00 2001 From: dengbf Date: Wed, 24 Jan 2024 17:26:34 +0800 Subject: [PATCH 1/9] =?UTF-8?q?-[=E5=8A=9F=E8=83=BD]=20=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE-=E8=A1=A8=E5=8D=95-=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E7=BB=84=E4=BB=B6-=E5=A4=96=E9=83=A8=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=81=94=E5=8A=A8=EF=BC=8C=E5=BD=B1=E5=93=8D=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E7=9A=84=E6=9F=90=E4=B8=80=E5=88=97=20=20-[=E5=85=B3=E8=81=94]?= =?UTF-8?q?=20#[1075174609223681]=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE-?= =?UTF-8?q?=E8=A1=A8=E5=8D=95-=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6-?= =?UTF-8?q?=E5=A4=96=E9=83=A8=E7=BB=84=E4=BB=B6=E8=81=94=E5=8A=A8=EF=BC=8C?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=E8=A1=A8=E6=A0=BC=E7=9A=84=E6=9F=90=E4=B8=80?= =?UTF-8?q?=E5=88=97=20http://192.168.0.96:8090/demo/rdm.html#/story-detai?= =?UTF-8?q?l/939050947543040/939050947543042/1075174609223681?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/component/formtableinputer/index.vue | 4 ++-- .../TsSheet/form/config/common/condition-group.vue | 2 +- .../formtableinputer-attr-config-dialog.vue | 14 +++++++++----- .../form/config/formtableinputer-conf/index.vue | 13 ++----------- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue index 63336162..417990ed 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue @@ -65,8 +65,8 @@ :ref="'formitem_' + extra.uuid + '_' + index" :formItem="getExtraFormItem(extra, row)" :value="getDefaultValue(extra.uuid, row)" - :formData="row" - :formItemList="$utils.deepClone(extraList)" + :formData="formData" + :formItemList="$utils.deepClone(extraList.concat(formItemList))" :showStatusIcon="false" mode="read" :readonly="readonly" diff --git a/src/resources/plugins/TsSheet/form/config/common/condition-group.vue b/src/resources/plugins/TsSheet/form/config/common/condition-group.vue index a1ef4107..0d71859f 100644 --- a/src/resources/plugins/TsSheet/form/config/common/condition-group.vue +++ b/src/resources/plugins/TsSheet/form/config/common/condition-group.vue @@ -150,7 +150,7 @@ export default { value: 'or' } ], - filterComponentList: ['formtableselector', 'formtableinputer', 'formsubassembly'] //过滤不参与规则的组件 + filterComponentList: ['formtableselector', 'formtableinputer', 'formsubassembly', 'formupload', 'formcube', 'formtable', 'formresoureces', 'formprotocol'] //过滤不参与规则的组件 }; }, beforeCreate() {}, diff --git a/src/resources/plugins/TsSheet/form/config/formtableinputer-conf/formtableinputer-attr-config-dialog.vue b/src/resources/plugins/TsSheet/form/config/formtableinputer-conf/formtableinputer-attr-config-dialog.vue index d3b69373..f9cdabd0 100644 --- a/src/resources/plugins/TsSheet/form/config/formtableinputer-conf/formtableinputer-attr-config-dialog.vue +++ b/src/resources/plugins/TsSheet/form/config/formtableinputer-conf/formtableinputer-attr-config-dialog.vue @@ -199,7 +199,7 @@ v-if="key !== 'filter'" :ref="'condition_' + key" :value="r" - :formItemList="formItemList" + :formItemList="allFormItemList" :formItem="propertyLocal" @input=" rule => { @@ -229,7 +229,7 @@ :value="r" :martixAttrList="mappingDataList" :formItem="propertyLocal" - :formItemList="formItemList" + :formItemList="allFormItemList" @input=" rule => { setReaction(key, rule); @@ -275,6 +275,10 @@ export default { isNeedReaction: { type: Boolean, default: true + }, + formItemList: { //表格外部的组件 + type: Array, + default: () => [] } }, data() { @@ -532,9 +536,9 @@ export default { }, filter: {}, computed: { - formItemList() { - //所有表单组件列表 - return this.formItemConfig.dataConfig; + allFormItemList() { + //表格输入组件和表格外组件 + return this.formItemConfig.dataConfig.concat(this.formItemList); }, //表格选择组件矩阵的字段 tableMatrixColumnList() { diff --git a/src/resources/plugins/TsSheet/form/config/formtableinputer-conf/index.vue b/src/resources/plugins/TsSheet/form/config/formtableinputer-conf/index.vue index aedda18f..e14cf623 100644 --- a/src/resources/plugins/TsSheet/form/config/formtableinputer-conf/index.vue +++ b/src/resources/plugins/TsSheet/form/config/formtableinputer-conf/index.vue @@ -106,6 +106,7 @@ v-if="isAttrConfigDialogShow && currentProperty" :formItemConfig="config" :property="currentProperty" + :formItemList="formItemList" @close="closeAttrConfigDialog" > @@ -198,17 +199,7 @@ export default { } }, filter: {}, - computed: { - componentList() { - const componentList = []; - this.formItemList.forEach(d => { - if (d.uuid != this.formItem.uuid && (d.handler === 'formselect' || d.handler === 'formradio' || d.handler === 'checkbox')) { - componentList.push({ value: d.uuid, text: d.label }); - } - }); - return componentList; - } - }, + computed: {}, watch: { } }; -- Gitee From 6be3234f1a450da8a57d4f47bd44606546752d43 Mon Sep 17 00:00:00 2001 From: dengbf Date: Fri, 26 Jan 2024 09:56:07 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/component/formtableinputer/index.vue | 58 +++++++++++++------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue index 417990ed..44b6dc8c 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue @@ -65,8 +65,7 @@ :ref="'formitem_' + extra.uuid + '_' + index" :formItem="getExtraFormItem(extra, row)" :value="getDefaultValue(extra.uuid, row)" - :formData="formData" - :formItemList="$utils.deepClone(extraList.concat(formItemList))" + :formItemList="extraList" :showStatusIcon="false" mode="read" :readonly="readonly" @@ -74,7 +73,7 @@ :isClearEchoFailedDefaultValue="true" :isCustomValue="true" style="min-width:130px" - @change="changeRow(row,index)" + @change="(val)=>changeRow(val,extra.uuid,row,index)" > @@ -95,6 +94,7 @@ import validmixin from '../common/validate-mixin.js'; import TsTable from '@/resources/components/TsTable/TsTable.vue'; import ExcelJS from 'exceljs'; import FileSaver from 'file-saver'; +import reactionMix from './reaction.js'; export default { name: '', @@ -103,7 +103,7 @@ export default { FormItem: resolve => require(['@/resources/plugins/TsSheet/form-item.vue'], resolve) }, extends: base, - mixins: [validmixin], + mixins: [validmixin, reactionMix], props: { readonly: { type: Boolean, default: false }, disabled: { type: Boolean, default: false } @@ -117,7 +117,8 @@ export default { maxSize: 1024 * 10, isShowExportExcelTemplate: true, isShowExportExcel: true, - loading: false + loading: false, + isFormData: false }; }, beforeCreate() {}, @@ -224,6 +225,7 @@ export default { if (this.disabled || this.readonly) { this.$set(formItem.config, 'isDisabled', true); } + this.$set(row, '_formItem', formItem); return formItem; }, validConfig() { @@ -280,8 +282,10 @@ export default { } return errorList; }, - changeRow(row, index) { - this.$set(this.tableData.tbodyList, index, row); + changeRow(val, uuid, row, index) { + this.isFormData = false; + this.$set(row, uuid, val); + // this.$set(this.tableData.tbodyList, index, row); }, updateRowSort(event) { let beforeVal = this.tableData.tbodyList.splice(event.oldIndex, 1)[0]; @@ -624,20 +628,24 @@ export default { if (!dataConfig) { dataConfig = this.config.dataConfig.find(d => d.uuid === uuid); } - if (dataConfig && dataConfig.config) { - const defaultValue = dataConfig.config.defaultValue; - if (dataConfig.config.defaultValueType === 'custom') { - return defaultValue; - } else if (dataConfig.config.defaultValueType === 'matrix') { - if (['formselect', 'formradio', 'formcheckbox'].includes(dataConfig.handler)) { - const defaultValueField = dataConfig.config.defaultValueField; - const defaultTextField = dataConfig.config.defaultTextField; - return {text: row[defaultValueField], value: row[defaultTextField]}; + if (dataConfig) { + if (dataConfig.config) { + const defaultValue = dataConfig.config.defaultValue; + if (dataConfig.config.defaultValueType === 'custom') { + return defaultValue; + } else if (dataConfig.config.defaultValueType === 'matrix') { + if (['formselect', 'formradio', 'formcheckbox'].includes(dataConfig.handler)) { + const defaultValueField = dataConfig.config.defaultValueField; + const defaultTextField = dataConfig.config.defaultTextField; + return {text: row[defaultValueField], value: row[defaultTextField]}; + } else { + return row[defaultValue]; + } } else { - return row[defaultValue]; + return defaultValue; } - } else { - return defaultValue; + } else if (dataConfig[uuid]) { + return this.$utils.deepClone(dataConfig[uuid]); } } return null; @@ -645,6 +653,9 @@ export default { }, canAdd() { return !this.config.hasOwnProperty('isCanAdd') || this.config.isCanAdd; + }, + formDataForWatch() { + return JSON.parse(JSON.stringify(this.formData)); } }, watch: { @@ -687,6 +698,15 @@ export default { }, deep: true, immediate: true + }, + formDataForWatch: { + handler(val, oldVal) { + this.isFormData = false; + if (!this.$utils.isSame(val, oldVal)) { + this.initReactionWatch(); + } + }, + deep: true } } }; -- Gitee From 8c142f70b68c23006d26b3b07972ad8911e767be Mon Sep 17 00:00:00 2001 From: dengbf Date: Thu, 1 Feb 2024 10:57:44 +0800 Subject: [PATCH 3/9] commit --- .../form/component/formtableinputer/index.vue | 58 ++++++------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue index 44b6dc8c..63336162 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue @@ -65,7 +65,8 @@ :ref="'formitem_' + extra.uuid + '_' + index" :formItem="getExtraFormItem(extra, row)" :value="getDefaultValue(extra.uuid, row)" - :formItemList="extraList" + :formData="row" + :formItemList="$utils.deepClone(extraList)" :showStatusIcon="false" mode="read" :readonly="readonly" @@ -73,7 +74,7 @@ :isClearEchoFailedDefaultValue="true" :isCustomValue="true" style="min-width:130px" - @change="(val)=>changeRow(val,extra.uuid,row,index)" + @change="changeRow(row,index)" > @@ -94,7 +95,6 @@ import validmixin from '../common/validate-mixin.js'; import TsTable from '@/resources/components/TsTable/TsTable.vue'; import ExcelJS from 'exceljs'; import FileSaver from 'file-saver'; -import reactionMix from './reaction.js'; export default { name: '', @@ -103,7 +103,7 @@ export default { FormItem: resolve => require(['@/resources/plugins/TsSheet/form-item.vue'], resolve) }, extends: base, - mixins: [validmixin, reactionMix], + mixins: [validmixin], props: { readonly: { type: Boolean, default: false }, disabled: { type: Boolean, default: false } @@ -117,8 +117,7 @@ export default { maxSize: 1024 * 10, isShowExportExcelTemplate: true, isShowExportExcel: true, - loading: false, - isFormData: false + loading: false }; }, beforeCreate() {}, @@ -225,7 +224,6 @@ export default { if (this.disabled || this.readonly) { this.$set(formItem.config, 'isDisabled', true); } - this.$set(row, '_formItem', formItem); return formItem; }, validConfig() { @@ -282,10 +280,8 @@ export default { } return errorList; }, - changeRow(val, uuid, row, index) { - this.isFormData = false; - this.$set(row, uuid, val); - // this.$set(this.tableData.tbodyList, index, row); + changeRow(row, index) { + this.$set(this.tableData.tbodyList, index, row); }, updateRowSort(event) { let beforeVal = this.tableData.tbodyList.splice(event.oldIndex, 1)[0]; @@ -628,24 +624,20 @@ export default { if (!dataConfig) { dataConfig = this.config.dataConfig.find(d => d.uuid === uuid); } - if (dataConfig) { - if (dataConfig.config) { - const defaultValue = dataConfig.config.defaultValue; - if (dataConfig.config.defaultValueType === 'custom') { - return defaultValue; - } else if (dataConfig.config.defaultValueType === 'matrix') { - if (['formselect', 'formradio', 'formcheckbox'].includes(dataConfig.handler)) { - const defaultValueField = dataConfig.config.defaultValueField; - const defaultTextField = dataConfig.config.defaultTextField; - return {text: row[defaultValueField], value: row[defaultTextField]}; - } else { - return row[defaultValue]; - } + if (dataConfig && dataConfig.config) { + const defaultValue = dataConfig.config.defaultValue; + if (dataConfig.config.defaultValueType === 'custom') { + return defaultValue; + } else if (dataConfig.config.defaultValueType === 'matrix') { + if (['formselect', 'formradio', 'formcheckbox'].includes(dataConfig.handler)) { + const defaultValueField = dataConfig.config.defaultValueField; + const defaultTextField = dataConfig.config.defaultTextField; + return {text: row[defaultValueField], value: row[defaultTextField]}; } else { - return defaultValue; + return row[defaultValue]; } - } else if (dataConfig[uuid]) { - return this.$utils.deepClone(dataConfig[uuid]); + } else { + return defaultValue; } } return null; @@ -653,9 +645,6 @@ export default { }, canAdd() { return !this.config.hasOwnProperty('isCanAdd') || this.config.isCanAdd; - }, - formDataForWatch() { - return JSON.parse(JSON.stringify(this.formData)); } }, watch: { @@ -698,15 +687,6 @@ export default { }, deep: true, immediate: true - }, - formDataForWatch: { - handler(val, oldVal) { - this.isFormData = false; - if (!this.$utils.isSame(val, oldVal)) { - this.initReactionWatch(); - } - }, - deep: true } } }; -- Gitee From 30f8c346a9f1e331f1685036d7c463dbe6807c52 Mon Sep 17 00:00:00 2001 From: dengbf Date: Fri, 2 Feb 2024 10:34:15 +0800 Subject: [PATCH 4/9] =?UTF-8?q?-=20[=E5=85=B3=E8=81=94]=20#[10751746092236?= =?UTF-8?q?81]=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE-=E8=A1=A8=E5=8D=95-?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E7=BB=84=E4=BB=B6-=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=81=94=E5=8A=A8=EF=BC=8C=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E7=9A=84=E6=9F=90=E4=B8=80=E5=88=97=20http:/?= =?UTF-8?q?/192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/?= =?UTF-8?q?939050947543042/1075174609223681?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/mixins/formMixins.js | 10 ++- .../plugins/TsForm/TsFormCheckbox.vue | 17 ++-- src/resources/plugins/TsSheet/TsSheet.vue | 13 +++ .../TsSheet/form/component/formselect.vue | 15 ++-- .../form/component/formtableinputer/index.vue | 87 ++++++++++++++----- 5 files changed, 105 insertions(+), 37 deletions(-) diff --git a/src/resources/mixins/formMixins.js b/src/resources/mixins/formMixins.js index 97edd112..f0f494e9 100644 --- a/src/resources/mixins/formMixins.js +++ b/src/resources/mixins/formMixins.js @@ -243,7 +243,15 @@ export default { } else { if (this.isCustomValue) { // 返回的是对象处理需要处理成['value1', 'value2'] - value = currentValue instanceof Array ? currentValue.filter(item => item?.[this.valueName]).map(item => item[this.valueName]) : []; + if (currentValue instanceof Array) { + currentValue.forEach(item => { + if (typeof item === 'object' && item[this.valueName]) { + value.push(item[this.valueName]); + } else if (!this.$utils.isEmpty(item)) { + value.push(item); + } + }); + } } else { value = [].concat(currentValue); } diff --git a/src/resources/plugins/TsForm/TsFormCheckbox.vue b/src/resources/plugins/TsForm/TsFormCheckbox.vue index 85218f42..db6c343a 100755 --- a/src/resources/plugins/TsForm/TsFormCheckbox.vue +++ b/src/resources/plugins/TsForm/TsFormCheckbox.vue @@ -260,13 +260,16 @@ export default { } }, watch: { - value(newValue, oldValue) { - let isSame = this.$utils.isSame(this.handleCurrentValue(newValue), this.currentValue); - if (!isSame) { - this.currentValue = this.handleCurrentValue(this.$utils.deepClone(newValue)) || []; - this.validMesage = ''; - this.setSelectList(); - } + value: { + handler(newValue, oldValue) { + let isSame = this.$utils.isSame(this.handleCurrentValue(newValue), this.currentValue); + if (!isSame) { + this.currentValue = this.handleCurrentValue(this.$utils.deepClone(newValue)) || []; + this.validMesage = ''; + this.setSelectList(); + } + }, + deep: true }, dataList: { handler(newValue) { diff --git a/src/resources/plugins/TsSheet/TsSheet.vue b/src/resources/plugins/TsSheet/TsSheet.vue index 6ea4a079..ae90c1d1 100644 --- a/src/resources/plugins/TsSheet/TsSheet.vue +++ b/src/resources/plugins/TsSheet/TsSheet.vue @@ -863,6 +863,7 @@ export default { for (let key in this.formData) { const formitem = this.formItemList.find(d => d.uuid === key); if (formitem) { + this.clearFormInputTableAttr(formitem, this.formData[key]); this.clearPrivateAttr(this.formData[key]); formItemList.push({ attributeUuid: key, handler: formitem.handler, dataList: this.formData[key] }); } @@ -887,6 +888,18 @@ export default { } } }, + clearFormInputTableAttr(formitem, valueList) { //清除表单输入组件非表头属性 + if (formitem.handler === 'formtableinputer' && !this.$utils.isEmpty(valueList)) { + let uuidList = this.$utils.mapArray(formitem.config.dataConfig, 'uuid'); + valueList.forEach(item => { + Object.keys(item).forEach(key => { + if (!uuidList.includes(key) && key !== 'uuid') { //uuid作为每一行的唯一标识,不能删除 + delete item[key]; + } + }); + }); + } + }, //是否包含class hasClass(classname) { for (let i = 0; i < this.selectedCell.length; i++) { diff --git a/src/resources/plugins/TsSheet/form/component/formselect.vue b/src/resources/plugins/TsSheet/form/component/formselect.vue index d91ab11b..90081c71 100644 --- a/src/resources/plugins/TsSheet/form/component/formselect.vue +++ b/src/resources/plugins/TsSheet/form/component/formselect.vue @@ -43,7 +43,8 @@ export default { }, data() { return { - isFirst: true + isFirst: true, + initFilter: this.$utils.deepClone(this.filter) }; }, beforeCreate() {}, @@ -111,8 +112,8 @@ export default { setting.dynamicUrl = '/api/rest/matrix/column/data/search/forselect'; setting.rootName = 'dataList'; const params = { matrixUuid: this.config.matrixUuid, filterList: []}; - if (this.filter) { - params.filterList = this.$utils.deepClone(this.filter); + if (!this.$utils.isEmpty(this.initFilter)) { + params.filterList = this.$utils.deepClone(this.initFilter); } if (this.config.mapping) { params.keywordColumn = this.config.mapping.text; @@ -150,15 +151,15 @@ export default { }, watch: { filter: { - handler(val, oldVal) { - if (!this.isFirst && !this.$utils.isEmpty(val) && !this.$utils.isSame(val, oldVal)) { + handler(val) { + if (!this.isFirst && !this.$utils.isEmpty(val) && !this.$utils.isSame(val, this.initFilter)) { //改变过滤条件,清空选项 this.setValue(null); } + this.initFilter = this.$utils.deepClone(val); this.isFirst = false; }, - deep: true, - immediate: true + deep: true } } }; diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue index 63336162..3dac465e 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue @@ -56,7 +56,7 @@ @updateRowSort="updateRowSort" @getSelected="getSelectedItem" > -