From 60f0d6bdeaa2670b851e0d45091bc5e319db142f Mon Sep 17 00:00:00 2001 From: yaojn Date: Fri, 17 Nov 2023 11:49:58 +0800 Subject: [PATCH 01/10] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E6=A1=86=E3=80=81=E5=A4=8D=E9=80=89=E6=A1=86=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9?= =?UTF-8?q?=E6=88=90{value:xxx,text:yyy}=20=20=20-=20[=E5=85=B3=E8=81=94]#?= =?UTF-8?q?[1025854879006720]=E8=A1=A8=E5=8D=95=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E3=80=81=E5=8D=95=E9=80=89=E6=A1=86=E3=80=81=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E6=A1=86=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD=E5=80=BC=E7=94=B1?= =?UTF-8?q?xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:yyy}=20http://192.?= =?UTF-8?q?168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/93905?= =?UTF-8?q?0947543042/1025854879006720?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/framework/integration/integration.js | 4 -- src/resources/mixins/formMixins.js | 37 ++++++++++++++++++- .../plugins/TsForm/TsFormCheckbox.vue | 10 +++-- src/resources/plugins/TsForm/TsFormRadio.vue | 10 +++-- src/resources/plugins/TsForm/TsFormSelect.vue | 20 +++++++--- src/resources/plugins/TsSheet/TsSheet.vue | 1 + src/resources/plugins/TsSheet/form-item.vue | 6 +++ .../plugins/TsSheet/form/component/base.vue | 5 +++ .../TsSheet/form/component/formcheckbox.vue | 1 + .../TsSheet/form/component/formradio.vue | 1 + .../TsSheet/form/component/formselect.vue | 1 + .../actionDetail/params/param-detail.vue | 1 + .../report/paramhandler/formcheckbox.vue | 22 ++--------- .../report/report/paramhandler/formradio.vue | 21 ++--------- .../report/report/paramhandler/formselect.vue | 22 ++--------- .../report/paramhandler/formselects.vue | 25 ++----------- .../pages/report/report/report-param.vue | 1 - src/views/pages/report/report/report-show.vue | 14 ------- 18 files changed, 93 insertions(+), 109 deletions(-) diff --git a/src/resources/api/framework/integration/integration.js b/src/resources/api/framework/integration/integration.js index 9c18c73f7..0a2f5b620 100644 --- a/src/resources/api/framework/integration/integration.js +++ b/src/resources/api/framework/integration/integration.js @@ -48,9 +48,6 @@ const integration = { getIntegrationColumnList(params) { return axios.post('/api/rest/integration/table/column/list', params); }, - getIntegrationColumnSearch(params) { - return axios.post('/api/rest/integration/column/data/search', params); - }, getIntegrationTableSearch(params) { return axios.post('/api/rest/integration/table/data/search', params); }, @@ -62,7 +59,6 @@ const integration = { // 查看集成调用记录内容 return axios.post('/api/rest/integration/audit/detail/get', params); } - }; export default integration; diff --git a/src/resources/mixins/formMixins.js b/src/resources/mixins/formMixins.js index 2cf753ae5..df18dfcce 100644 --- a/src/resources/mixins/formMixins.js +++ b/src/resources/mixins/formMixins.js @@ -45,6 +45,11 @@ export default { // 是否清空回显失败默认值 type: Boolean, default: false + }, + isValueObject: { + // 返回值是否是对象,默认是false + type: Boolean, + default: false } }, methods: { @@ -111,7 +116,12 @@ export default { let valueList = []; value.forEach(v => { if (v != false && !this.$utils.isEmpty(v)) { - valueList.push(v); + if (this.isValueObject && v[this.valueName]) { + // 数组对象类型 + valueList.push(v?.[this.valueName]); + } else { + valueList.push(v); + } } }); value = valueList; @@ -223,6 +233,31 @@ export default { className = 'text-warning'; } return className; + }, + handleCurrentValue(currentValue) { + let value; + + return currentValue => { + if (this.multiple || this.$options.name == 'TsFormCheckbox') { + if (this.$utils.isEmpty(currentValue)) { + value = []; + } else { + if (this.isValueObject) { + // 返回的是对象处理需要处理成['value1', 'value2'] + value = currentValue instanceof Array ? currentValue.filter(item => item?.[this.valueName]).map(item => item[this.valueName]) : []; + } else { + value = [].concat(currentValue); + } + } + } else { + if (this.isValueObject && currentValue && typeof currentValue === 'object' && currentValue[this.valueName]) { + value = currentValue[this.valueName]; + } else { + value = currentValue; + } + } + return value; + }; } }, diff --git a/src/resources/plugins/TsForm/TsFormCheckbox.vue b/src/resources/plugins/TsForm/TsFormCheckbox.vue index f74a3d083..a957e86d1 100755 --- a/src/resources/plugins/TsForm/TsFormCheckbox.vue +++ b/src/resources/plugins/TsForm/TsFormCheckbox.vue @@ -114,13 +114,14 @@ export default { }, data() { return { - currentValue: this.value || [], + currentValue: [], validMesage: this.errorMessage || '', nodeList: this.url ? [] : this.dataList, currentValidList: this.filterValid(this.validateList) || [] }; }, created() { + this.currentValue = this.handleCurrentValue(this.value) || []; this.setSelectList(); this.initDataListByUrl(); }, @@ -186,7 +187,7 @@ export default { }, onChangeValue(val, item) { let isSame = JSON.stringify(this.value) == JSON.stringify(this.currentValue); - let value = JSON.parse(JSON.stringify(this.currentValue)); + let value = this.$utils.deepClone(this.currentValue); //20210129_zqp_新增支持on-change方法第二个参数获取选中的选项的完整数据 let selectedItem = []; let label = []; @@ -197,6 +198,9 @@ export default { return true; } }); + if (this.isValueObject) { + value = selectedItem; + } } this.$emit('update:value', value); this.$emit('change', value, selectedItem); @@ -259,7 +263,7 @@ export default { watch: { value(newValue, oldValue) { if (JSON.stringify(newValue) != JSON.stringify(this.currentValue)) { - this.currentValue = JSON.parse(JSON.stringify(newValue || [])); + this.currentValue = this.handleCurrentValue(this.$utils.deepClone(newValue)) || []; this.validMesage = ''; this.setSelectList(); } diff --git a/src/resources/plugins/TsForm/TsFormRadio.vue b/src/resources/plugins/TsForm/TsFormRadio.vue index da570a860..ab92ef432 100755 --- a/src/resources/plugins/TsForm/TsFormRadio.vue +++ b/src/resources/plugins/TsForm/TsFormRadio.vue @@ -80,7 +80,7 @@ export default { default: 'text' }, value: { - type: [String, Number, Boolean], + type: [String, Number, Boolean, Object], default: '' }, url: { @@ -121,13 +121,14 @@ export default { }, data() { return { - currentValue: this.value, + currentValue: '', validMesage: this.errorMessage || '', nodeList: this.url ? [] : this.dataList, currentValidList: this.filterValid(this.validateList) || [] }; }, created() { + this.currentValue = this.handleCurrentValue(this.value); this.setSelectList(); this.initDataListByUrl(); }, @@ -198,6 +199,9 @@ export default { return n[this.valueName] === value; }); } + if (this.isValueObject) { + value = selectedItem || {}; + } this.$emit('update:value', value); this.$emit('change', value, selectedItem || null); if (!(!this.isChangeWrite && isSame)) { @@ -252,7 +256,7 @@ export default { watch: { value(newValue, oldValue) { if (newValue != this.currentValue) { - this.currentValue = newValue; + this.currentValue = this.handleCurrentValue(newValue); this.validMesage = ''; this.setSelectList(); this.handleEchoFailedDefaultValue(); diff --git a/src/resources/plugins/TsForm/TsFormSelect.vue b/src/resources/plugins/TsForm/TsFormSelect.vue index a39068071..b266aded3 100755 --- a/src/resources/plugins/TsForm/TsFormSelect.vue +++ b/src/resources/plugins/TsForm/TsFormSelect.vue @@ -314,7 +314,7 @@ export default { mode: { type: String, default: 'normal' }, //normal或group,group代表分组下拉框 value: { //默认值 - type: [String, Number, Array], + type: [String, Number, Array, Object], default: function() { if (this.multiple == true) { return new Array(); @@ -511,7 +511,7 @@ export default { focussing: false, //是否处于焦点中 focusIndex: -1, //通过键盘选中列表 searchKeyWord: '', //搜索对应可以word - currentValue: this.multiple ? (this.$utils.isEmpty(this.value) ? [] : [].concat(this.value)) : this.value, + currentValue: null, isVisible: false, //下拉选项显示 selectedList: [], //选中的集合{text:"",value:""} nodeList: this.url ? [] : JSON.parse(JSON.stringify(this.dataList || [])), @@ -536,6 +536,7 @@ export default { beforeCreate() {}, created() { this.initDataListByUrl(false); + this.currentValue = this.handleCurrentValue(this.value); }, mounted() {}, updated() {}, @@ -1012,14 +1013,21 @@ export default { }, onChangeValue() { let isSame = false; - let valueObject = this.selectedList.map(item => { + let selectedList = this.selectedList.map(item => { return { value: item[this.valueName], text: item[this.textName] }; }); - valueObject = this.multiple ? valueObject : valueObject[0] || {}; + let valueObject = this.multiple ? selectedList : selectedList[0] || {}; let toValue = this.currentValue; //额外赋值主要是为了避免引用数据导致值的联动 if (this.multiple) { isSame = JSON.stringify(this.value) == JSON.stringify(this.currentValue); - toValue = this.currentValue.concat([]); + if (this.isValueObject) { + toValue = this.selectedList.concat([]); + } else { + toValue = this.currentValue.concat([]); + } + } else if (this.isValueObject) { + isSame = this.$utils.isSame(this.value, this.currentValue); + toValue = valueObject; } else if (this.value == this.currentValue) { isSame = true; } @@ -1430,7 +1438,7 @@ export default { // isSame = true; // } if (!isSame) { - this.currentValue = this.multiple ? (this.$utils.isEmpty(newValue) ? [] : [].concat(newValue)) : newValue; + this.currentValue = this.handleCurrentValue(newValue); this.validMesage = ''; this.isValidPass = true; this.watchChange(!!this.url); diff --git a/src/resources/plugins/TsSheet/TsSheet.vue b/src/resources/plugins/TsSheet/TsSheet.vue index 5096fd624..ab017db5c 100644 --- a/src/resources/plugins/TsSheet/TsSheet.vue +++ b/src/resources/plugins/TsSheet/TsSheet.vue @@ -298,6 +298,7 @@ :disabled="disabled" :readonly="readonly" :formHighlightData="formHighlightData" + :isValueObject="true" class="padding-xs" @changeConfig="addHistory()" @change="resizeCell(cell.row, cell.col, true)" diff --git a/src/resources/plugins/TsSheet/form-item.vue b/src/resources/plugins/TsSheet/form-item.vue index b5f0dd816..5c1c94e0c 100644 --- a/src/resources/plugins/TsSheet/form-item.vue +++ b/src/resources/plugins/TsSheet/form-item.vue @@ -63,6 +63,7 @@ :formData="formData" :readonlyTextIsHighlight="readonlyTextIsHighlight" :isClearEchoFailedDefaultValue="isClearEchoFailedDefaultValue" + :isValueObject="isValueObject" @setValue="setValue" @resize="$emit('resize')" @select="selectFormItem" @@ -125,6 +126,11 @@ export default { // 默认值对应不上下列列表时,是否需要清空默认值 type: Boolean, default: false + }, + isValueObject: { + // 返回的值是否是对象 + type: Boolean, + default: false } }, data() { diff --git a/src/resources/plugins/TsSheet/form/component/base.vue b/src/resources/plugins/TsSheet/form/component/base.vue index eec419988..930ba4dc1 100644 --- a/src/resources/plugins/TsSheet/form/component/base.vue +++ b/src/resources/plugins/TsSheet/form/component/base.vue @@ -15,6 +15,11 @@ export default { // 是否清空回显失败默认值 type: Boolean, default: false + }, + isValueObject: { + // 返回的值是否是对象 + type: Boolean, + default: false } }, data() { diff --git a/src/resources/plugins/TsSheet/form/component/formcheckbox.vue b/src/resources/plugins/TsSheet/form/component/formcheckbox.vue index 52e27f802..e0321c27c 100644 --- a/src/resources/plugins/TsSheet/form/component/formcheckbox.vue +++ b/src/resources/plugins/TsSheet/form/component/formcheckbox.vue @@ -10,6 +10,7 @@ :validateList="validateList" :readonlyTextIsHighlight="readonlyTextIsHighlight" :isClearEchoFailedDefaultValue="isClearEchoFailedDefaultValue" + :isValueObject="isValueObject" @change=" val => { setValue(val); diff --git a/src/resources/plugins/TsSheet/form/component/formradio.vue b/src/resources/plugins/TsSheet/form/component/formradio.vue index 381f1475a..df36048d4 100644 --- a/src/resources/plugins/TsSheet/form/component/formradio.vue +++ b/src/resources/plugins/TsSheet/form/component/formradio.vue @@ -11,6 +11,7 @@ :allowToggle="true" :readonlyTextIsHighlight="readonlyTextIsHighlight" :isClearEchoFailedDefaultValue="isClearEchoFailedDefaultValue" + :isValueObject="isValueObject" @change=" val => { setValue(val); diff --git a/src/resources/plugins/TsSheet/form/component/formselect.vue b/src/resources/plugins/TsSheet/form/component/formselect.vue index 1546141d8..4c978e163 100644 --- a/src/resources/plugins/TsSheet/form/component/formselect.vue +++ b/src/resources/plugins/TsSheet/form/component/formselect.vue @@ -10,6 +10,7 @@ :validateList="validateList" :readonlyTextIsHighlight="readonlyTextIsHighlight" :isClearEchoFailedDefaultValue="isClearEchoFailedDefaultValue" + :isValueObject="isValueObject" border="border" search @change=" diff --git a/src/views/pages/autoexec/detail/actionDetail/params/param-detail.vue b/src/views/pages/autoexec/detail/actionDetail/params/param-detail.vue index 056e0ae1b..e2fd8830d 100644 --- a/src/views/pages/autoexec/detail/actionDetail/params/param-detail.vue +++ b/src/views/pages/autoexec/detail/actionDetail/params/param-detail.vue @@ -66,6 +66,7 @@
+ {{ getselectConfig(item) }}
-
@@ -40,8 +39,7 @@ export default { textField: this.config.textKey } }, - value: [], - dataList: [] + value: [] }; }, beforeCreate() {}, @@ -55,21 +53,7 @@ export default { deactivated() {}, beforeDestroy() {}, destroyed() {}, - methods: { - formatDataList: function(nodeList) { - let dataList = []; - if (nodeList.tbodyList) { - nodeList.tbodyList.forEach(element => { - dataList.push({ - //后端要求value值需要用&=&分隔,后期要改掉,后端直接返回正确的值 - value: element[this.config.valueKey].value + '&=&' + element[this.config.textKey].text, - text: element[this.config.textKey].text - }); - }); - } - return dataList; - } - }, + methods: {}, filter: {}, computed: {}, watch: { diff --git a/src/views/pages/report/report/paramhandler/formradio.vue b/src/views/pages/report/report/paramhandler/formradio.vue index 87241de45..dd82d2a94 100644 --- a/src/views/pages/report/report/paramhandler/formradio.vue +++ b/src/views/pages/report/report/paramhandler/formradio.vue @@ -3,10 +3,9 @@ @@ -40,8 +39,7 @@ export default { textField: this.config.textKey } }, - value: '', - dataList: [] + value: '' }; }, beforeCreate() {}, @@ -55,20 +53,7 @@ export default { deactivated() {}, beforeDestroy() {}, destroyed() {}, - methods: { - formatDataList: function(nodeList) { - let dataList = []; - if (nodeList.tbodyList) { - nodeList.tbodyList.forEach(element => { - dataList.push({ - //后端要求value值需要用&=&分隔,后期要改掉,后端直接返回正确的值 - value: element[this.config.valueKey].value + '&=&' + element[this.config.textKey].text, - text: element[this.config.textKey].text}); - }); - } - return dataList; - } - }, + methods: {}, filter: {}, computed: {}, watch: { diff --git a/src/views/pages/report/report/paramhandler/formselect.vue b/src/views/pages/report/report/paramhandler/formselect.vue index 408cd651a..8b237605f 100644 --- a/src/views/pages/report/report/paramhandler/formselect.vue +++ b/src/views/pages/report/report/paramhandler/formselect.vue @@ -3,11 +3,10 @@ @@ -42,8 +41,7 @@ export default { keywordColumn: this.config.textKey } }, - value: '', - dataList: [] + value: '' }; }, beforeCreate() {}, @@ -57,21 +55,7 @@ export default { deactivated() {}, beforeDestroy() {}, destroyed() {}, - methods: { - formatDataList: function(nodeList) { - let dataList = []; - if (nodeList.tbodyList) { - nodeList.tbodyList.forEach(element => { - dataList.push({ - //后端要求value值需要用&=&分隔,后期要改掉,后端直接返回正确的值 - value: element[this.config.valueKey].compose, - text: element[this.config.textKey].text - }); - }); - } - return dataList; - } - }, + methods: {}, filter: {}, computed: {}, watch: { diff --git a/src/views/pages/report/report/paramhandler/formselects.vue b/src/views/pages/report/report/paramhandler/formselects.vue index bd95b2cfb..76b71edd2 100644 --- a/src/views/pages/report/report/paramhandler/formselects.vue +++ b/src/views/pages/report/report/paramhandler/formselects.vue @@ -3,12 +3,11 @@ @@ -43,36 +42,20 @@ export default { keywordColumn: this.config.textKey } }, - value: '', - dataList: [] + value: '' }; }, beforeCreate() {}, created() {}, beforeMount() {}, - mounted() { - }, + mounted() {}, beforeUpdate() {}, updated() {}, activated() {}, deactivated() {}, beforeDestroy() {}, destroyed() {}, - methods: { - formatDataList: function(nodeList) { - let dataList = []; - if (nodeList.tbodyList) { - nodeList.tbodyList.forEach(element => { - dataList.push({ - //后端要求value值需要用&=&分隔,后期要改掉,后端直接返回正确的值 - value: element[this.config.valueKey].compose, - text: element[this.config.textKey].text - }); - }); - } - return dataList; - } - }, + methods: {}, filter: {}, computed: {}, watch: { diff --git a/src/views/pages/report/report/report-param.vue b/src/views/pages/report/report/report-param.vue index a93294cb9..7d11077e1 100644 --- a/src/views/pages/report/report/report-param.vue +++ b/src/views/pages/report/report/report-param.vue @@ -125,7 +125,6 @@ export default { } }, data() { - let _this = this; return { myParamList: [], controllerTypeList: [ diff --git a/src/views/pages/report/report/report-show.vue b/src/views/pages/report/report/report-show.vue index ea899e3ae..07e5abeb5 100644 --- a/src/views/pages/report/report/report-show.vue +++ b/src/views/pages/report/report/report-show.vue @@ -177,20 +177,6 @@ export default { } }, setParam: function(paramName, paramValue) { - if (Array.isArray(paramValue)) { - let _paramValue = []; - paramValue.forEach((element) => { - if (element.indexOf('&=&') > -1) { - let item = element.split('&=&')[0]; - _paramValue.push(item); - } - }); - paramValue = _paramValue; - } else { - if (paramValue && paramValue.indexOf('&=&') > -1) { - paramValue = paramValue.split('&=&')[0]; - } - } let obj = {}; obj[paramName] = paramValue; this.searchParam = Object.assign({}, this.searchParam, obj); -- Gitee From e22ee666a04739d285ec2a8a6549d61c3549fd6f Mon Sep 17 00:00:00 2001 From: yaojn Date: Fri, 17 Nov 2023 15:55:32 +0800 Subject: [PATCH 02/10] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E6=A1=86=E3=80=81=E5=A4=8D=E9=80=89=E6=A1=86=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9?= =?UTF-8?q?=E6=88=90{value:xxx,text:yyy}=20=20=20-=20[=E5=85=B3=E8=81=94]#?= =?UTF-8?q?[1025854879006720]=E8=A1=A8=E5=8D=95=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E3=80=81=E5=8D=95=E9=80=89=E6=A1=86=E3=80=81=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E6=A1=86=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD=E5=80=BC=E7=94=B1?= =?UTF-8?q?xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:yyy}=20http://192.?= =?UTF-8?q?168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/93905?= =?UTF-8?q?0947543042/1025854879006720?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/matrixMinxis.js | 4 +-- src/resources/mixins/sheetCompontMixins.js | 4 +-- src/resources/plugins/TsForm/TsFormSelect.vue | 4 +-- .../form/component/formtableinputer/index.vue | 18 +++++++----- .../component/formtableselector/index.vue | 2 +- .../config/formtableselector-conf/index.vue | 4 +-- .../report/paramconfig/forminput-config.vue | 1 - .../report/paramhandler/formcheckbox.vue | 5 ++-- .../report/report/paramhandler/formradio.vue | 5 ++-- .../report/report/reportinstance-show.vue | 14 --------- .../pages/report/sendjob/sendjob-edit.vue | 29 +------------------ 11 files changed, 25 insertions(+), 65 deletions(-) diff --git a/src/resources/components/ProcessTaskSearcher/handlers/matrixMinxis.js b/src/resources/components/ProcessTaskSearcher/handlers/matrixMinxis.js index b1ff2e027..b92690501 100644 --- a/src/resources/components/ProcessTaskSearcher/handlers/matrixMinxis.js +++ b/src/resources/components/ProcessTaskSearcher/handlers/matrixMinxis.js @@ -9,13 +9,13 @@ export default { if (this.config.mapping.value != this.config.mapping.text) { columlist.push({ text: co[this.config.mapping.text].text, - value: co[this.config.mapping.value].value + '&=&' + co[this.config.mapping.text].text, + value: co[this.config.mapping.value].value, html: co[this.config.mapping.text].text + "(" + co[this.config.mapping.value].text + ')' }); } else { columlist.push({ text: co[this.config.mapping.text].text, - value: co[this.config.mapping.value].value + '&=&' + co[this.config.mapping.text].text, + value: co[this.config.mapping.value].value, html: co[this.config.mapping.text].text }); } diff --git a/src/resources/mixins/sheetCompontMixins.js b/src/resources/mixins/sheetCompontMixins.js index db647b0a8..6184f6acc 100644 --- a/src/resources/mixins/sheetCompontMixins.js +++ b/src/resources/mixins/sheetCompontMixins.js @@ -24,13 +24,13 @@ export default { if (config.mapping.value != config.mapping.text) { columlist.push({ text: co[config.mapping.text].text, - value: co[config.mapping.value].value + '&=&' + co[config.mapping.text].text, + value: co[config.mapping.value].value, html: co[config.mapping.text].text + "(" + co[config.mapping.value].text + ')' }); } else { columlist.push({ text: co[config.mapping.text].text, - value: co[config.mapping.value].value + '&=&' + co[config.mapping.text].text, + value: co[config.mapping.value].value, html: co[config.mapping.text].text }); } diff --git a/src/resources/plugins/TsForm/TsFormSelect.vue b/src/resources/plugins/TsForm/TsFormSelect.vue index b266aded3..5e74c373e 100755 --- a/src/resources/plugins/TsForm/TsFormSelect.vue +++ b/src/resources/plugins/TsForm/TsFormSelect.vue @@ -535,8 +535,8 @@ export default { }, beforeCreate() {}, created() { - this.initDataListByUrl(false); this.currentValue = this.handleCurrentValue(this.value); + this.initDataListByUrl(false); }, mounted() {}, updated() {}, @@ -1021,7 +1021,7 @@ export default { if (this.multiple) { isSame = JSON.stringify(this.value) == JSON.stringify(this.currentValue); if (this.isValueObject) { - toValue = this.selectedList.concat([]); + toValue = this.$utils.deepClone(this.selectedList); } else { toValue = this.currentValue.concat([]); } diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue index 59e857c2c..9c99294f5 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue @@ -71,6 +71,7 @@ :readonly="readonly" :disabled="disabled" :isClearEchoFailedDefaultValue="true" + :isValueObject="true" style="min-width:130px" @change="changeRow(row,index)" > @@ -403,8 +404,8 @@ export default { let {dataSource = '', isMultiple = false} = config; if (handler == 'formtable') { this.$set(item, [key], null); - } else if (dataSource == 'matrix' && (isMultiple || handler == 'formradio' || handler == 'formcheckbox')) { - // 矩阵数据源并且是多选,需要处理值去掉&=& + } else if (dataSource == 'matrix' && (isMultiple || handler == 'formradio' || handler == 'formcheckbox' || handler == 'formselect')) { + // 矩阵数据源并且是多选 this.$set(item, [key], this.handleSpecialValue(item[key])); } else if (dataSource == 'static' && (isMultiple || handler == 'formcheckbox')) { // 静态数据源并且是多选 @@ -506,10 +507,13 @@ export default { handleSpecialValue(value) { let valueList = []; if (typeof value == 'string') { - return value?.split('&=&')?.[1] || value; + return value; + } else if (typeof value == 'object' && value?.['text']) { + return value['text']; } else if (Array.isArray(value)) { - valueList = value.map((item) => item?.split('&=&')?.[1] || item).filter(Boolean); + valueList = value.map((item) => item['text']).filter(Boolean); } + console.log('返回的值', value); return valueList.join(','); }, handleFormatError(file) { @@ -567,11 +571,11 @@ export default { valueList = value.split(','); valueList.forEach((valueItem) => { if (valueItem) { - resultValue.push(valueItem.indexOf('&=&') != -1 ? valueItem : `${valueItem}&=&${valueItem}`); + resultValue.push({text: valueItem, value: valueItem}); } }); } else { - resultValue.push(valueItem.indexOf('&=&') != -1 ? valueItem : `${value}&=&${value}`); + resultValue.push({text: valueItem, value: valueItem}); } } else if (dataSource == 'static' && (isMultiple || (handler == 'formcheckbox'))) { resultValue = []; @@ -614,7 +618,7 @@ export default { if (['formselect', 'formradio', 'formcheckbox'].includes(dataConfig.handler)) { const defaultValueField = dataConfig.config.defaultValueField; const defaultTextField = dataConfig.config.defaultTextField; - return row[defaultValueField] + '&=&' + row[defaultTextField]; + return {text: row[defaultValueField], value: row[defaultTextField]}; } else { return row[defaultValue]; } diff --git a/src/resources/plugins/TsSheet/form/component/formtableselector/index.vue b/src/resources/plugins/TsSheet/form/component/formtableselector/index.vue index e52c55e36..a23a17775 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableselector/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableselector/index.vue @@ -273,7 +273,7 @@ export default { if (['formselect', 'formradio', 'formcheckbox'].includes(dataConfig.handler)) { const defaultValueField = dataConfig.config.defaultValueField; const defaultTextField = dataConfig.config.defaultTextField; - return row[defaultValueField] + '&=&' + row[defaultTextField]; + return {text: row[defaultTextField], value: row[defaultValueField]}; } else { return row[defaultValue]; } diff --git a/src/resources/plugins/TsSheet/form/config/formtableselector-conf/index.vue b/src/resources/plugins/TsSheet/form/config/formtableselector-conf/index.vue index d63329052..b48ea2d5e 100644 --- a/src/resources/plugins/TsSheet/form/config/formtableselector-conf/index.vue +++ b/src/resources/plugins/TsSheet/form/config/formtableselector-conf/index.vue @@ -259,13 +259,13 @@ export default { if (this.config.mapping.value != this.config.mapping.text) { columlist.push({ text: d[this.config.mapping.text].text, - value: d[this.config.mapping.value].value + '&=&' + d[this.config.mapping.text].text, + value: d[this.config.mapping.value].value, html: d[this.config.mapping.text].text + "(" + d[this.config.mapping.value].text + ')' }); } else { columlist.push({ text: d[this.config.mapping.text].text, - value: d[this.config.mapping.value].value + '&=&' + d[this.config.mapping.text].text, + value: d[this.config.mapping.value].value, html: d[this.config.mapping.text].text }); } diff --git a/src/views/pages/report/report/paramconfig/forminput-config.vue b/src/views/pages/report/report/paramconfig/forminput-config.vue index 777dcc5b4..7b1d825e3 100644 --- a/src/views/pages/report/report/paramconfig/forminput-config.vue +++ b/src/views/pages/report/report/paramconfig/forminput-config.vue @@ -16,7 +16,6 @@ export default { } }, data() { - const _this = this; return { myConfig: {length: '', defaultValue: ''}, formConfig: { diff --git a/src/views/pages/report/report/paramhandler/formcheckbox.vue b/src/views/pages/report/report/paramhandler/formcheckbox.vue index 6a7b12212..52350bb41 100644 --- a/src/views/pages/report/report/paramhandler/formcheckbox.vue +++ b/src/views/pages/report/report/paramhandler/formcheckbox.vue @@ -31,7 +31,7 @@ export default { data() { return { myConfig: { - dynamicUrl: '/api/rest/matrix/column/data/search/forselect', + url: '/api/rest/matrix/column/data/search/forselect', rootName: 'dataList', params: { matrixUuid: this.config.matrix, @@ -45,8 +45,7 @@ export default { beforeCreate() {}, created() {}, beforeMount() {}, - mounted() { - }, + mounted() {}, beforeUpdate() {}, updated() {}, activated() {}, diff --git a/src/views/pages/report/report/paramhandler/formradio.vue b/src/views/pages/report/report/paramhandler/formradio.vue index dd82d2a94..8663c673c 100644 --- a/src/views/pages/report/report/paramhandler/formradio.vue +++ b/src/views/pages/report/report/paramhandler/formradio.vue @@ -31,7 +31,7 @@ export default { data() { return { myConfig: { - dynamicUrl: '/api/rest/matrix/column/data/search/forselect', + url: '/api/rest/matrix/column/data/search/forselect', rootName: 'dataList', params: { matrixUuid: this.config.matrix, @@ -45,8 +45,7 @@ export default { beforeCreate() {}, created() {}, beforeMount() {}, - mounted() { - }, + mounted() {}, beforeUpdate() {}, updated() {}, activated() {}, diff --git a/src/views/pages/report/report/reportinstance-show.vue b/src/views/pages/report/report/reportinstance-show.vue index 81aab82bd..85aaa9054 100644 --- a/src/views/pages/report/report/reportinstance-show.vue +++ b/src/views/pages/report/report/reportinstance-show.vue @@ -170,20 +170,6 @@ export default { } }, setParam(paramName, paramValue) { - if (Array.isArray(paramValue)) { - let _paramValue = []; - paramValue.forEach((element) => { - if (element.indexOf('&=&') > -1) { - let item = element.split('&=&')[0]; - _paramValue.push(item); - } - }); - paramValue = _paramValue; - } else { - if (paramValue && paramValue.indexOf('&=&') > -1) { - paramValue = paramValue.split('&=&')[0]; - } - } let obj = {}; obj[paramName] = paramValue; this.searchParam = Object.assign({}, this.searchParam, obj); diff --git a/src/views/pages/report/sendjob/sendjob-edit.vue b/src/views/pages/report/sendjob/sendjob-edit.vue index fa84deee4..d268441b3 100644 --- a/src/views/pages/report/sendjob/sendjob-edit.vue +++ b/src/views/pages/report/sendjob/sendjob-edit.vue @@ -392,17 +392,6 @@ export default { const reportParams = report.paramList.reduce( (result, { name, value }) => { if (![undefined, null, ''].includes(value)) { - if (value.indexOf('&=&') > -1) { - value = value.split('&=&')[0]; - } else if (value instanceof Array) { - let valueList = []; - value.forEach(item => { - if (item.indexOf('&=&') > -1 && item.split('&=&')) { - valueList.push(item.split('&=&')[0]); - } - }); - value = valueList && valueList.length > 0 ? valueList : value; - } result[name] = value; } return result; @@ -455,7 +444,7 @@ export default { paramList && paramList.forEach(({ name, value }) => { formValue[name] = value; - condition[name] = this.handleSpecial(value); + condition[name] = value; }); return { id, formValue, condition }; }); @@ -491,22 +480,6 @@ export default { }); this.isAddDialogShow = false; }, - handleSpecial(value) { - // 处理特殊字符 &=& - let currentValue = this.$utils.deepClone(value); - let valueList = []; - if (currentValue && typeof currentValue == 'string' && currentValue.includes('&=&')) { - currentValue = currentValue.split('&=&')[0]; - } else if (currentValue && currentValue instanceof Array) { - currentValue.forEach(item => { - if (item.indexOf('&=&') > -1 && item.split('&=&')) { - valueList.push(item.split('&=&')[0]); - } - }); - currentValue = valueList && valueList.length > 0 ? valueList : currentValue; - } - return currentValue; - }, showAddDialog() { this.isAddDialogShow = true; this.formConfig.reportIdList.value = this.jobConfig.reportList.map(report => report.id); -- Gitee From 22fab4792891559ca7ab035f2c404a0278dd0e1c Mon Sep 17 00:00:00 2001 From: yaojn Date: Fri, 17 Nov 2023 18:16:06 +0800 Subject: [PATCH 03/10] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E6=A1=86=E3=80=81=E5=A4=8D=E9=80=89=E6=A1=86=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9?= =?UTF-8?q?=E6=88=90{value:xxx,text:yyy}=20=20=20-=20[=E5=85=B3=E8=81=94]#?= =?UTF-8?q?[1025854879006720]=E8=A1=A8=E5=8D=95=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E3=80=81=E5=8D=95=E9=80=89=E6=A1=86=E3=80=81=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E6=A1=86=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD=E5=80=BC=E7=94=B1?= =?UTF-8?q?xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:yyy}=20http://192.?= =?UTF-8?q?168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/93905?= =?UTF-8?q?0947543042/1025854879006720?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/mixins/formMixins.js | 1 - .../plugins/TsSheet/child-form-item.vue | 1 + .../plugins/TsSheet/form-item-config.vue | 1 + src/resources/plugins/TsSheet/form-item.vue | 30 +++++++------------ .../formtableinputer-attr-config-dialog.vue | 1 + 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/resources/mixins/formMixins.js b/src/resources/mixins/formMixins.js index df18dfcce..8f3091e4a 100644 --- a/src/resources/mixins/formMixins.js +++ b/src/resources/mixins/formMixins.js @@ -236,7 +236,6 @@ export default { }, handleCurrentValue(currentValue) { let value; - return currentValue => { if (this.multiple || this.$options.name == 'TsFormCheckbox') { if (this.$utils.isEmpty(currentValue)) { diff --git a/src/resources/plugins/TsSheet/child-form-item.vue b/src/resources/plugins/TsSheet/child-form-item.vue index f3d4a40b0..4072198e1 100644 --- a/src/resources/plugins/TsSheet/child-form-item.vue +++ b/src/resources/plugins/TsSheet/child-form-item.vue @@ -27,6 +27,7 @@ :disabled="disabled" :readonly="readonly" :showStatusIcon="false" + :isValueObject="true" @resize="$emit('resize')" @emit=" val => { diff --git a/src/resources/plugins/TsSheet/form-item-config.vue b/src/resources/plugins/TsSheet/form-item-config.vue index a55690fed..680ee9f90 100644 --- a/src/resources/plugins/TsSheet/form-item-config.vue +++ b/src/resources/plugins/TsSheet/form-item-config.vue @@ -48,6 +48,7 @@ mode="defaultvalue" :value="formItem.config.defaultValue" :disabled="!!formItem.inherit || disabled" + :isValueObject="true" @change=" val => { setConfig('defaultValue', val); diff --git a/src/resources/plugins/TsSheet/form-item.vue b/src/resources/plugins/TsSheet/form-item.vue index 5c1c94e0c..9b27128ab 100644 --- a/src/resources/plugins/TsSheet/form-item.vue +++ b/src/resources/plugins/TsSheet/form-item.vue @@ -292,34 +292,24 @@ export default { if (this.formData[r.formItemUuid] instanceof Array) { this.formData[r.formItemUuid].forEach(value => { if (typeof value === 'string') { - if (value.includes('&=&')) { - valueList.push(value.split('&=&')[0]); //只取value部分 - textList.push(value.split('&=&')[1]); //只取text部分 + valueList.push(value); + if (!this.$utils.isEmpty(formItem.config.dataList)) { + let findData = formItem.config.dataList.find(f => f.value === value); + textList.push(findData.text); } else { - valueList.push(value); - if (!this.$utils.isEmpty(formItem.config.dataList)) { - let findData = formItem.config.dataList.find(f => f.value === value); - textList.push(findData.text); - } else { - textList.push(value); - } + textList.push(value); } } }); } else { let value = this.formData[r.formItemUuid]; if (value) { - if (value.includes('&=&')) { - valueList.push(value.split('&=&')[0]); //只取value部分 - textList.push(value.split('&=&')[1]); //只取text部分,用于矩阵搜索回显 + valueList.push(value); + if (!this.$utils.isEmpty(formItem.config.dataList)) { + const findData = formItem.config.dataList.find(f => f.value === value); + textList.push(findData.text); } else { - valueList.push(value); - if (!this.$utils.isEmpty(formItem.config.dataList)) { - const findData = formItem.config.dataList.find(f => f.value === value); - textList.push(findData.text); - } else { - textList.push(value); - } + textList.push(value); } } } 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 fc7f97002..bdf0bd4d6 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 @@ -130,6 +130,7 @@ -- Gitee From 9fbcda65c3d4f4621cf9d94bde1b1b747836399c Mon Sep 17 00:00:00 2001 From: yaojn Date: Mon, 20 Nov 2023 18:49:37 +0800 Subject: [PATCH 04/10] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E4=B8=8B=E6=8B=89=E6=A1=86=E3=80=81=E5=8D=95=E9=80=89?= =?UTF-8?q?=E6=A1=86=E3=80=81=E5=A4=8D=E9=80=89=E6=A1=86=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E5=80=BC=E7=94=B1xxx&=3D&yyy=E6=94=B9?= =?UTF-8?q?=E6=88=90{value:xxx,text:yyy}=20=20=20-=20[=E5=85=B3=E8=81=94]#?= =?UTF-8?q?[1025854879006720]=E8=A1=A8=E5=8D=95=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E3=80=81=E5=8D=95=E9=80=89=E6=A1=86=E3=80=81=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E6=A1=86=E7=BB=84=E4=BB=B6=E9=80=89=E4=B8=AD=E5=80=BC=E7=94=B1?= =?UTF-8?q?xxx&=3D&yyy=E6=94=B9=E6=88=90{value:xxx,text:yyy}=20http://192.?= =?UTF-8?q?168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/93905?= =?UTF-8?q?0947543042/1025854879006720?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/channelselect.vue | 9 +- .../ProcessTaskSearcher/handlers/checkbox.vue | 1 + .../handlers/matrixMinxis.js | 7 + .../ProcessTaskSearcher/handlers/radio.vue | 1 + .../ProcessTaskSearcher/handlers/select.vue | 12 +- .../ProcessTaskSearcher/search-inputer.vue | 12 +- .../ProcessTaskSearcher/simple-panel.vue | 1 + src/resources/plugins/TsForm/TsFormSelect.vue | 321 +++++++++--------- .../TsSheet/form/component/formtable.vue | 1 + .../form/component/formtableinputer/index.vue | 1 - .../components/param/edit/editmixin.js | 5 + .../actionDetail/params/param-detail.vue | 1 - 12 files changed, 202 insertions(+), 170 deletions(-) diff --git a/src/resources/components/ProcessTaskSearcher/handlers/channelselect.vue b/src/resources/components/ProcessTaskSearcher/handlers/channelselect.vue index 28231912a..d16aaffd5 100644 --- a/src/resources/components/ProcessTaskSearcher/handlers/channelselect.vue +++ b/src/resources/components/ProcessTaskSearcher/handlers/channelselect.vue @@ -44,6 +44,8 @@ mode="simple" :condition="getFormConditionByName(formcondition.name)" :workcenterConditionData="workcenterConditionData" + :isValueObject="isValueObject" + fromComponent="channelselect" @change="changeFromCondition" > @@ -65,7 +67,12 @@ export default { mode: { type: String, default: 'simple' }, conditionData: { type: Object }, //当前组件在工单中心配置中的数据 condition: { type: Object }, - workcenterConditionData: { type: Object } //工单中心所有条件数据 + workcenterConditionData: { type: Object }, //工单中心所有条件数据 + isValueObject: { + // 返回的值是否是对象 + type: Boolean, + default: false + } }, data() { return { diff --git a/src/resources/components/ProcessTaskSearcher/handlers/checkbox.vue b/src/resources/components/ProcessTaskSearcher/handlers/checkbox.vue index b0b27ae51..547e69996 100644 --- a/src/resources/components/ProcessTaskSearcher/handlers/checkbox.vue +++ b/src/resources/components/ProcessTaskSearcher/handlers/checkbox.vue @@ -6,6 +6,7 @@ className="block-span" :value="conditionData && conditionData.valueList" :validateList="[{ name: 'required', message: ' ' }]" + :isValueObject="isValueObject" @on-change="change" > diff --git a/src/resources/components/ProcessTaskSearcher/handlers/matrixMinxis.js b/src/resources/components/ProcessTaskSearcher/handlers/matrixMinxis.js index b92690501..189554356 100644 --- a/src/resources/components/ProcessTaskSearcher/handlers/matrixMinxis.js +++ b/src/resources/components/ProcessTaskSearcher/handlers/matrixMinxis.js @@ -1,4 +1,11 @@ export default { + props: { + isValueObject: { + // 返回的值是否是对象 + type: Boolean, + default: false + } + }, methods: { dealDataByUrl(nodeList) { //处理返回的数据结构为tsFormSelect需要的数据结构 diff --git a/src/resources/components/ProcessTaskSearcher/handlers/radio.vue b/src/resources/components/ProcessTaskSearcher/handlers/radio.vue index 5eda272a9..cdf11dc11 100644 --- a/src/resources/components/ProcessTaskSearcher/handlers/radio.vue +++ b/src/resources/components/ProcessTaskSearcher/handlers/radio.vue @@ -6,6 +6,7 @@ className="block-span" :value="conditionData && conditionData.valueList" :validateList="[{ name: 'required', message: ' ' }]" + :isValueObject="isValueObject" @on-change="change" > diff --git a/src/resources/components/ProcessTaskSearcher/handlers/select.vue b/src/resources/components/ProcessTaskSearcher/handlers/select.vue index 13954ea98..0304f4f1d 100644 --- a/src/resources/components/ProcessTaskSearcher/handlers/select.vue +++ b/src/resources/components/ProcessTaskSearcher/handlers/select.vue @@ -14,6 +14,7 @@ border="border" :value="conditionData && conditionData.valueList" :validateList="[{ name: 'required', message: ' ' }]" + :isValueObject="isValueObject" @change="change" > @@ -31,10 +32,14 @@ export default { default: 'simple' }, condition: { type: Object }, - conditionData: {type: Object}//当前组件在工单中心配置中的数据 + conditionData: {type: Object}, //当前组件在工单中心配置中的数据 + isValueObject: { + // 返回的值是否是对象 + type: Boolean, + default: false + } }, data() { - const _this = this; return { config: this.condition.config, matrixConfig: { @@ -46,8 +51,7 @@ export default { beforeCreate() {}, created() { this.mergeMatrixConfig(); }, beforeMount() {}, - mounted() { - }, + mounted() {}, beforeUpdate() {}, updated() {}, activated() {}, diff --git a/src/resources/components/ProcessTaskSearcher/search-inputer.vue b/src/resources/components/ProcessTaskSearcher/search-inputer.vue index 1e34d41a7..ca796a51b 100644 --- a/src/resources/components/ProcessTaskSearcher/search-inputer.vue +++ b/src/resources/components/ProcessTaskSearcher/search-inputer.vue @@ -8,6 +8,7 @@ :workcenterConditionData="workcenterConditionData" :conditionData="getWorkcenterConditionData(condition.handler)" :mode="mode" + :isValueObject="isValueObject" @change="change" @changeWithCondition="changeWithCondition" > @@ -19,6 +20,7 @@ :condition="condition" :conditionData="conditionData || getWorkcenterConditionData(condition.handler)" :mode="mode" + :isValueObject="fromComponent == 'channelselect' && isValueObject" @change="change" > @@ -50,7 +52,15 @@ export default { mode: { type: String, default: 'simple' }, workcenterConditionData: { type: Object }, //全量的工单中心条件数据,主要提供给channelselect.vue使用,其他组件不需要用的此数据 condition: { type: Object }, //默认条件 - conditionData: { type: Object } //工单中心组件条件数据 + conditionData: { type: Object }, //工单中心组件条件数据 + isValueObject: { // 返回的值是否是对象 + type: Boolean, + default: false + }, + fromComponent: { // 用于再简单模式下,表单过滤属性按钮打开之后,表单属性下拉框传递的值是对象的问题 + type: String, + default: '' + } }, data() { return { diff --git a/src/resources/components/ProcessTaskSearcher/simple-panel.vue b/src/resources/components/ProcessTaskSearcher/simple-panel.vue index de5efc007..e97ada192 100644 --- a/src/resources/components/ProcessTaskSearcher/simple-panel.vue +++ b/src/resources/components/ProcessTaskSearcher/simple-panel.vue @@ -7,6 +7,7 @@ mode="simple" :condition="condition" :workcenterConditionData="workcenterConditionDataLocal" + :isValueObject="true" @change="change" > diff --git a/src/resources/plugins/TsForm/TsFormSelect.vue b/src/resources/plugins/TsForm/TsFormSelect.vue index 5e74c373e..1a7539d31 100755 --- a/src/resources/plugins/TsForm/TsFormSelect.vue +++ b/src/resources/plugins/TsForm/TsFormSelect.vue @@ -514,7 +514,7 @@ export default { currentValue: null, isVisible: false, //下拉选项显示 selectedList: [], //选中的集合{text:"",value:""} - nodeList: this.url ? [] : JSON.parse(JSON.stringify(this.dataList || [])), + nodeList: this.url ? [] : this.$utils.deepClone(this.dataList || []), loading: !!this.dynamicUrl, validMesage: this.errorMessage || '', currentValidList: this.filterValid(this.validateList) || [], @@ -594,7 +594,7 @@ export default { // 暂无数据 return (this.nodeList.length <= 0 || this.hiddenLength == this.nodeList.length) && !this.allowCreate; }, - handleOpen: function() { + handleOpen() { if (this.disabled || this.readonly) { return; } @@ -622,7 +622,7 @@ export default { // 取消上次请求的接口 // let ajaxArr = { method: this.ajaxType, url: url, cancelAxios: this[cancel].token}; let needdataLi = ['post', 'put']; - ArrIndexOf(needdataLi, this.ajaxType) < 0 ? Object.assign(ajaxArr, { params: params }) : Object.assign(ajaxArr, { data: params }); + this.ArrIndexOf(needdataLi, this.ajaxType) < 0 ? Object.assign(ajaxArr, { params: params }) : Object.assign(ajaxArr, { data: params }); let res = await this.$https(ajaxArr); let nodeList = []; if (res && res.Status == 'OK') { @@ -674,7 +674,6 @@ export default { initDataListByUrl(isSearch) { //isSearch: Boolean 如果是value 改变时,不需要从新通过url来获取nodelist //初始化数据 - let _this = this; this.hiddenLength = 0; if (this.url && !isSearch) { //url @@ -683,12 +682,12 @@ export default { this.isSingel = !!(this.isSquare && this.currentSearch); // 解决文本占位符显示不出来问题 this.getDataByAjax(params, this.url, 'cancelAxios1').then(res => { - _this.nodeList = res; - _this.nodeList && _this.nodeList.length > 20 && _this.search === null ? (_this.currentSearch = true) : (_this.currentSearch = _this.search); //当search参数值不存在时 如果长度大于20增加搜索功能, - _this.setDefaultValue(); //默认选中第一个 - _this.initValueByNodeList(); + this.nodeList = res; + this.nodeList && this.nodeList.length > 20 && this.search === null ? (this.currentSearch = true) : (this.currentSearch = this.search); //当search参数值不存在时 如果长度大于20增加搜索功能, + this.setDefaultValue(); //默认选中第一个 + this.initValueByNodeList(); }); - } else if (_this.dynamicUrl) { + } else if (this.dynamicUrl) { //dynamicUrl this.currentSearch = true; if (!this.$utils.isEmpty(this.value)) { @@ -716,23 +715,22 @@ export default { }, initValueByNodeList() { //通过nodeList,初始化selectedList - let _this = this; this.selectedList = []; if (this.$utils.isEmpty(this.currentValue)) { this.searchKeyWord = ''; return; } - let ary = this.multiple ? this.currentValue : [this.currentValue]; + let valueList = this.multiple ? this.currentValue : this.currentValue instanceof Array ? this.currentValue : [this.currentValue]; let selectedList = []; if (this.mode == 'normal') { - _this.nodeList.forEach(function(item) { - ArrIndexOf(ary, item[_this.valueName]) >= 0 && selectedList.push(item); + this.nodeList.forEach((item) => { + this.ArrIndexOf(valueList, item[this.valueName]) >= 0 && selectedList.push(item); }); } else if (this.mode == 'group') { this.nodeList.forEach(pitem => { if (pitem[this.childrenName] && pitem[this.childrenName].length > 0) { pitem[this.childrenName].forEach(item => { - ArrIndexOf(ary, item[this.valueName]) >= 0 && selectedList.push(item); + this.ArrIndexOf(valueList, item[this.valueName]) >= 0 && selectedList.push(item); }); } }); @@ -742,7 +740,7 @@ export default { if (selectedList.length > 1) { this.currentValue instanceof Array && this.currentValue.forEach(item => { - let findSelect = selectedList.find(sel => sel[this.valueName] == item); + let findSelect = selectedList.find(sel => sel[this.valueName] == item || sel[this.valueName] == item[this.valueName]); findSelect && list.push(findSelect); }); } else { @@ -751,7 +749,7 @@ export default { this.selectedList = list; if (!this.multiple) { //单选时需要给searchKeyword赋值 - if (ary.length > _this.selectedList.length && this.allowCreate) { + if (valueList.length > this.selectedList.length && this.allowCreate) { //如果不是通过接口调用写死的单独做一次性回显的,在下次初始化时把值回显回去 this.searchKeyWord = this.currentValue; //在下拉列表里面添加用户手动创建的数据,主要是为了回显 @@ -773,7 +771,6 @@ export default { this.openOption(); } if (this.dynamicUrl) { - let _this = this; this.setTimeoutDynaic && clearTimeout(this.setTimeoutDynaic); this.setTimeoutDynaic = setTimeout(() => { this.currentPage = 1; @@ -799,7 +796,7 @@ export default { this.selectedList.splice(ind, 1); if (this.currentValue instanceof Array) { // 解决单选时,当前值不是数组时,splice报错问题 - this.currentValue.splice(ArrIndexOf(this.currentValue, value), 1); + this.currentValue.splice(this.ArrIndexOf(this.currentValue, value), 1); } this.$refs.input && this.$refs.input.focus(); this.onChangeValue(); @@ -819,9 +816,8 @@ export default { }, filterNodeList(query) { //nodeList进行搜索过滤 - let _this = this; this.hiddenLength = 0; - _this.liHtml = _this.showName ? _this.showName : _this.textName; + this.liHtml = this.showName ? this.showName : this.textName; this.nodeList.forEach(item => { if (this.mode == 'normal') { if (item) { @@ -837,11 +833,10 @@ export default { } } }); - _this.updatePosition(); + this.updatePosition(); }, selectMatchItem(query, item) { - const _this = this; - let searchNameList = _this.$utils.isEmpty(_this.filterName) ? [_this.textName, _this.valueName] : typeof _this.filterName == 'string' ? [_this.filterName] : _this.filterName; + let searchNameList = this.$utils.isEmpty(this.filterName) ? [this.textName, this.valueName] : typeof this.filterName == 'string' ? [this.filterName] : this.filterName; let filterNode = searchNameList.find(search => { if ( !query || @@ -855,28 +850,27 @@ export default { } }); if (filterNode) { - _this.$set(item, '_isHidden', false); + this.$set(item, '_isHidden', false); if (query) { - let newtext = item[_this.liHtml].replace(new RegExp('(' + query + ')', 'ig'), '$1'); - _this.$set(item, 'showtxt', newtext); + let newtext = item[this.liHtml].replace(new RegExp('(' + query + ')', 'ig'), '$1'); + this.$set(item, 'showtxt', newtext); } else { - _this.$set(item, 'showtxt', item[_this.liHtml]); + this.$set(item, 'showtxt', item[this.liHtml]); } } else { - _this.$set(item, '_isHidden', true); - _this.$set(item, 'showtxt', item[_this.liHtml]); + this.$set(item, '_isHidden', true); + this.$set(item, 'showtxt', item[this.liHtml]); this.hiddenLength++; } }, dynamicInit() { //通过dynamicurl初始化数据 - let _this = this; this.hiddenLength = 0; //不用掉接口初始化text值 if (this.isEqualValue) { this.selectedList = []; - let ary = this.currentValue instanceof Array ? this.currentValue : [this.currentValue]; - ary.forEach(item => { + let valueList = this.currentValue instanceof Array ? this.currentValue : [this.currentValue]; + valueList.forEach(item => { let obj = {}; obj[this.valueName] = obj[this.textName] = item; this.selectedList.push(obj); @@ -888,7 +882,7 @@ export default { this.getDataByAjax(params, this.dynamicUrl, 'cancelAxios1').then(res => { if (((this.multiple && this.currentValue.length) || (!this.multiple && (this.currentValue || ['boolean', 'number'].includes(typeof this.currentValue)))) && res.length) { let selectedList = res.filter(r => { - return _this.multiple ? ArrIndexOf(this.currentValue, r[_this.valueName]) > -1 : this.currentValue == r[_this.valueName]; + return this.multiple ? this.ArrIndexOf(this.currentValue, r[this.valueName]) > -1 : this.handleObjectValue(r[this.valueName]); }); //进行排序,主要是为了显示的text的顺序和value值顺序一样 ,因为接口的数据顺序可能不会根据value来 let list = []; @@ -902,45 +896,56 @@ export default { this.selectedList = selectedList.length > 1 ? list : selectedList; this.handleEchoFailedDefaultValue(); } else { - _this.selectedList = []; + this.selectedList = []; this.handleEchoFailedDefaultValue(); } - if (!_this.multiple) { + if (!this.multiple) { //是单选,进行赋值处理 - _this.searchKeyWord = ''; - _this.isSingel = !!(this.isSquare && this.currentSearch); + this.searchKeyWord = ''; + this.isSingel = !!(this.isSquare && this.currentSearch); } - if (_this.needCallback) { + if (this.needCallback) { //成功回调设置为false - _this.$emit('update:needCallback', false); - _this.$emit('searchCallback'); + this.$emit('update:needCallback', false); + this.$emit('searchCallback'); } }); }, + handleObjectValue(valueName) { + if (!this.isValueObject) { + return this.currentValue == valueName; + } + if (this.currentValue instanceof Array) { + return this.currentValue.find((item) => item[this.valueName] == valueName); + } else if (typeof this.currentValue == 'string') { + return this.currentValue == valueName; + } else if (typeof this.currentValue == 'object' && this.currentValue) { + return this.currentValue[this.valueName]; + } + }, handleEchoFailedDefaultValue() { // 处理回显失败默认值,回显失败清空默认值 - if (this.isClearEchoFailedDefaultValue && !this.$utils.isEmpty(this.selectedList)) { - let selectedList = []; - let valueList = this.multiple ? this.currentValue : this.currentValue instanceof Array ? this.currentValue : [this.currentValue]; - valueList.forEach((item, index) => { - if (item && !this.selectedList.find((n) => n[this.valueName] == item)) { - selectedList.push(item[this.valueName]); - if (this.currentValue instanceof Array) { - this.currentValue.splice(index, 1); - } else if (this.currentValue) { - this.currentValue = null; - } - } - }); - if (!this.$utils.isEmpty(selectedList)) { - this.onChangeValue(); - } - } + // if (this.isClearEchoFailedDefaultValue && !this.$utils.isEmpty(this.selectedList)) { + // let selectedList = []; + // let valueList = this.multiple ? this.currentValue : this.currentValue instanceof Array ? this.currentValue : [this.currentValue]; + // valueList.forEach((item, index) => { + // if (item && !this.selectedList.find((n) => n[this.valueName] == item)) { + // selectedList.push(item[this.valueName]); + // if (this.currentValue instanceof Array) { + // this.currentValue.splice(index, 1); + // } else if (this.currentValue) { + // this.currentValue = null; + // } + // } + // }); + // if (!this.$utils.isEmpty(selectedList)) { + // this.onChangeValue(); + // } + // } }, dynamicSearch(query, isFirst) { //query:搜索的关键字,isFirst 是否第一次初始化下拉值,主要为了必填时只有一个下拉值时默认填充 - let _this = this; this.hiddenLength = 0; this.loading = true; if (isFirst) { @@ -952,41 +957,41 @@ export default { params[this.keyword] = query ? query.trim() : ''; this.getDataByAjax(params, this.dynamicUrl, 'cancelAxios') .then(res => { - if (_this.isReachBottomSearch && this.currentPage > 1 && !this.$utils.isSame(this.nodeList, res)) { + if (this.isReachBottomSearch && this.currentPage > 1 && !this.$utils.isSame(this.nodeList, res)) { if (res && res.length > 0) { for (let i = 0; i < res.length; i++) { - _this.nodeList.push(res[i]); + this.nodeList.push(res[i]); } - _this.delMoreSearchTip(); - if (_this.pageCount > 1) { - _this.nodeList.push(_this.moreSearchTip); + this.delMoreSearchTip(); + if (this.pageCount > 1) { + this.nodeList.push(this.moreSearchTip); } } - _this.nodeList = _this.$utils.uniqueByField(_this.nodeList, _this.valueName); // 去重 + this.nodeList = this.$utils.uniqueByField(this.nodeList, this.valueName); // 去重 } else { - _this.nodeList = []; - _this.nodeList = res; // 有传递的时候,拿到所有的值 + this.nodeList = []; + this.nodeList = res; // 有传递的时候,拿到所有的值 } - _this.creatNewItem(query); - _this.nodeList.splice(0, {}); - _this.updatePosition(); - _this.$nextTick(() => { - _this.hasLoadMore = this.hasScrollbar(); + this.creatNewItem(query); + this.nodeList.splice(0, {}); + this.updatePosition(); + this.$nextTick(() => { + this.hasLoadMore = this.hasScrollbar(); }); if (isFirst) { //如果必填或者默认选中第一个,而且下拉值只有一个则默认选中第一个 - _this.setDefaultValue(); + this.setDefaultValue(); } - _this.loading = false; - if (_this.needCallback) { + this.loading = false; + if (this.needCallback) { //成功回调设置为false - _this.$emit('update:needCallback', false); - _this.$emit('searchCallback'); + this.$emit('update:needCallback', false); + this.$emit('searchCallback'); } }) .finally(() => { - _this.loading = false; + this.loading = false; }); }, delMoreSearchTip() { @@ -1048,15 +1053,15 @@ export default { this.isValidPass = true; } }, - onSelectFocus: function() { + onSelectFocus() { typeof this.onFocus == 'function' && this.onFocus(); this.$emit('on-focus'); }, - // onFirst: function() { + // onFirst() { // typeof this.onFirst == 'function' && this.onFirst(); // this.$emit('on-first'); // }, - onSelectBlur: function() { + onSelectBlur() { typeof this.onBlur == 'function' && this.onBlur(); this.$emit('on-blur'); }, @@ -1066,11 +1071,14 @@ export default { return; } let value = item[this.valueName]; - let index = ArrIndexOf(this.currentValue, value); + let index = this.ArrIndexOf(this.currentValue, value); + if (this.multiple && this.$utils.isEmpty(this.currentValue)) { + this.currentValue = []; + } if (index < 0) { //选中 this.multiple ? this.selectedList.push(item) : (this.selectedList = [item]); - this.multiple ? this.currentValue.push(value) : (this.currentValue = value); + this.multiple && value ? this.currentValue.push(value) : (this.currentValue = value); } else if (this.isRequired && !this.multiple) { //取消选中 如果必填且单选,则不能取消选中 return; @@ -1086,6 +1094,7 @@ export default { } this.multiple ? (this.searchKeyWord = '') : this.hideOption(); this.isSingel = !!(this.isSquare && this.currentSearch); + this.onChangeValue(); this.scrollTop(); }, @@ -1122,7 +1131,6 @@ export default { } }, hideOption(isEnterSearch) { - var _this = this; this.isVisible = false; if (!isEnterSearch) { !this.multiple ? (this.searchKeyWord = '') : (this.searchKeyWord = ''); @@ -1131,7 +1139,7 @@ export default { //如果是单选实时搜索在收起元素时,然后下拉里面的值为当前选中项 setTimeout(() => { // this.dynamicSearch('search', this.selectedList[0][this.textName]); - this.selectedList.length > 0 && _this.nodeList && (_this.nodeList = _this.nodeList.filter(item => item[_this.valueName] == _this.selectedList[0][_this.valueName])); + this.selectedList.length > 0 && this.nodeList && (this.nodeList = this.nodeList.filter(item => item[this.valueName] == this.selectedList[0][this.valueName])); }); } }, @@ -1139,7 +1147,6 @@ export default { this.isVisible = true; }, handleKeydown(e) { - let _this = this; if ((this.nodeList && this.nodeList.length > 0) || e.keyCode == 13) { let maxLength = this.nodeList.length; let minLength = this.allowCreate ? 0 : 1; @@ -1158,7 +1165,6 @@ export default { let focusItem = this.setFocusItem(minLength, maxLength, 'down'); } else if (keyCode == '13') { // enter - let _this = this; e.preventDefault(); if (!this.isVisible) { //显示下拉框 @@ -1179,32 +1185,32 @@ export default { selectData && this.toggleSelect(selectData); //键盘回车,如果val与当前下拉某一个一样的就是选中当前一个,如果是回车新加的继续新加逻辑 let isExist = false; - let keyval = _this.addItem ? _this.addItem[_this.textName] || this.searchKeyWord : this.searchKeyWord; - if (keyval && _this.nodeList && _this.nodeList.length > 0) { - _this.nodeList.find(no => { - if (this.$utils.equalStr(no[_this.valueName], keyval) || this.$utils.equalStr(no[_this.textName], keyval)) { + let keyval = this.addItem ? this.addItem[this.textName] || this.searchKeyWord : this.searchKeyWord; + if (keyval && this.nodeList && this.nodeList.length > 0) { + this.nodeList.find(no => { + if (this.$utils.equalStr(no[this.valueName], keyval) || this.$utils.equalStr(no[this.textName], keyval)) { isExist = true; } return isExist; }); } - if (!_this.allowCreate || (_this.allowCreate && isExist)) { - _this.$set(_this, 'addItem', null); + if (!this.allowCreate || (this.allowCreate && isExist)) { + this.$set(this, 'addItem', null); return; } else { - _this.nodeList.unshift(_this.addItem); - if (_this.$listeners && _this.$listeners['on-create']) { - _this.$emit('on-create', keyval); + this.nodeList.unshift(this.addItem); + if (this.$listeners && this.$listeners['on-create']) { + this.$emit('on-create', keyval); } - _this.toggleSelect(_this.nodeList[0]); - _this.$set(_this, 'addItem', null); + this.toggleSelect(this.nodeList[0]); + this.$set(this, 'addItem', null); } } else if (keyCode == '8') { if (this.multiple && !this.searchKeyWord && this.selectedList.length > 0) { let lastLi = this.selectedList.length - 1; let lastval = this.selectedList[lastLi][this.valueName]; - this.currentValue.splice(ArrIndexOf(this.currentValue, lastval), 1); + this.currentValue.splice(this.ArrIndexOf(this.currentValue, lastval), 1); this.selectedList.splice(lastLi, 1); this.onChangeValue(); } @@ -1214,14 +1220,13 @@ export default { setFocusItem(maxLength, minLength, type) { //利用键盘,选中的元素样色 let length = 0; - let _this = this; let selectData = null; this.nodeList.forEach((item, iindex) => { - if (iindex + 1 === _this.focusIndex) { - _this.$set(item, '_focusSelect', true); + if (iindex + 1 === this.focusIndex) { + this.$set(item, '_focusSelect', true); selectData = item; } else { - _this.$set(item, '_focusSelect', false); + this.$set(item, '_focusSelect', false); } }); @@ -1229,10 +1234,10 @@ export default { this.focusIndex = this.focusIndex == maxLength ? minLength : this.focusIndex + (type == 'up' ? -1 : 1); selectData = this.setFocusItem(maxLength, minLength, type); } else { - this.$nextTick(function() { + this.$nextTick(() => { //内容的滚动 - if (_this.$refs.dropdown) { - let $scrollContain = _this.$refs.dropdown.$el.parentNode; + if (this.$refs.dropdown) { + let $scrollContain = this.$refs.dropdown.$el.parentNode; let $selected = $scrollContain.querySelector(' .select-li.hover'); if ($selected) { $scrollContain.scrollTop = $selected.offsetTop - 100; @@ -1246,11 +1251,10 @@ export default { checkExist(str) { //校验某个字符串是否存在下拉列表里 let isExist = false; - let _this = this; - if (str && _this.nodeList && _this.nodeList.length > 0) { - _this.nodeList.forEach(no => { - let textStr = no[_this.textName].toString(); - let valueStr = no[_this.valueName].toString(); + if (str && this.nodeList && this.nodeList.length > 0) { + this.nodeList.forEach(no => { + let textStr = no[this.textName].toString(); + let valueStr = no[this.valueName].toString(); if (textStr === str.toString() || valueStr === str.toString()) { isExist = true; } @@ -1267,12 +1271,11 @@ export default { } }, watchChange(isChange) { - let _this = this; - this.initSettime && clearTimeout(_this.initSettime); + this.initSettime && clearTimeout(this.initSettime); this.initSettime = setTimeout(() => { - _this.initSettime = null; - _this.loading = !!_this.dynamicUrl; - _this.initDataListByUrl(isChange); + this.initSettime = null; + this.loading = !!this.dynamicUrl; + this.initDataListByUrl(isChange); }, 10); }, getSelectedList() { @@ -1284,7 +1287,7 @@ export default { }, scrollTop() { if (this.nowrapHead) { - this.$nextTick(function() { + this.$nextTick(() => { this.$refs.topHead && (this.$refs.topHead.scrollLeft = this.$refs.topHead.scrollWidth); }); } @@ -1306,7 +1309,7 @@ export default { return 0; } }, - handleReachBottom: function() { + handleReachBottom() { // 触底滚动加载 return new Promise(resolve => { setTimeout(() => { @@ -1332,6 +1335,19 @@ export default { hasScrollbar = dropdownContain.$el.clientHeight > 200; } return hasScrollbar; + }, + ArrIndexOf(arr, str) { + //重写 数组的indexof功能 主要是为了实现 1 = '1' 的情况 + let index = -1; + if (arr instanceof Array) { + arr.find((item, i) => { + utils.equalStr(this.isValueObject ? item[this.valueName] : item, str) && (index = i); + return index >= 0; + }); + } else { + utils.equalStr(arr, str) && (index = 0); + } + return index; } }, computed: { @@ -1346,10 +1362,9 @@ export default { if (this.nowrapHead && this.multiple) { classStr += ' nowrap'; } - return classStr; }, - getPlaceholder: function() { + getPlaceholder() { if ((this.selectedList && this.selectedList.length > 0) || this.disabled) { return ''; } @@ -1361,14 +1376,13 @@ export default { return this.$t('form.placeholder.pleaseselect', { target: '' }); } }, - getClearable: function() { - let _this = this; - let clearable = _this.clearable; + getClearable() { + let clearable = this.clearable; !clearable && - _this.validateList && - _this.validateList.forEach(item => { - typeof item == 'string' && item == 'required' && !_this.multiple && (clearable = false); - typeof item == 'object' && item.name == 'required' && !_this.multiple && (clearable = false); + this.validateList && + this.validateList.forEach(item => { + typeof item == 'string' && item == 'required' && !this.multiple && (clearable = false); + typeof item == 'object' && item.name == 'required' && !this.multiple && (clearable = false); }); if (this.disabled || this.readonly || this.selectedList.length == 0) { clearable = false; @@ -1388,15 +1402,14 @@ export default { return classNameList; }, setLiClass() { - return function(node, index) { - let _this = this; + return (node, index) => { let classtxt = 'select-li ivu-dropdown-item overflow'; - if (this.multiple && this.currentValue && ArrIndexOf(this.currentValue, node[_this.valueName]) > -1) { + if (this.multiple && this.currentValue && this.ArrIndexOf(this.currentValue, node[this.valueName]) > -1) { classtxt = classtxt + ' selected'; - } else if (!this.multiple && this.$utils.equalStr(this.currentValue, node[_this.valueName])) { + } else if (!this.multiple && (this.$utils.equalStr(this.currentValue, node[this.valueName]) || this.handleObjectValue(node[this.valueName]))) { classtxt = classtxt + ' selected'; } - if (index + 1 == _this.focusIndex || node['_focusSelect']) { + if (index + 1 == this.focusIndex || node['_focusSelect']) { classtxt = classtxt + ' hover'; } if (node['_disabled']) { @@ -1406,17 +1419,16 @@ export default { }; }, setInputwidth() { - let _this = this; - return function(keyword) { + return (keyword) => { let style = {}; - if (!_this.multiple) { - if (keyword || _this.getPlaceholder || (_this.isSingel && _this.selectedList.length > 0) || (!_this.multiple && _this.currentSearch && !_this.isSquare)) { - Object.assign(style, { maxWidth: '100%', minWidth: '14px', width: _this.calculateInputWidth(keyword) * 14 + 14 + 'px' }); + if (!this.multiple) { + if (keyword || this.getPlaceholder || (this.isSingel && this.selectedList.length > 0) || (!this.multiple && this.currentSearch && !this.isSquare)) { + Object.assign(style, { maxWidth: '100%', minWidth: '14px', width: this.calculateInputWidth(keyword) * 14 + 14 + 'px' }); } else { style.width = '100%'; } } else if (keyword || this.getPlaceholder) { - Object.assign(style, { maxWidth: '100%', minWidth: '14px', width: _this.calculateInputWidth(keyword) * 14 + 14 + 'px' }); + Object.assign(style, { maxWidth: '100%', minWidth: '14px', width: this.calculateInputWidth(keyword) * 14 + 14 + 'px' }); } else if (this.currentValue && this.currentValue.length > 0) { style.width = '14px'; // 将原有的30像素改成14像素,解决输入框宽度过长,导致换行问题 } @@ -1449,7 +1461,7 @@ export default { dataList: { handler: function(newValue, oldValue) { if (!this.url) { - this.nodeList = JSON.parse(JSON.stringify(this.dataList || [])); + this.nodeList = this.$utils.deepClone(this.dataList) || []; this.nodeList && this.nodeList.length > 20 && this.search === null ? (this.currentSearch = true) : (this.currentSearch = this.search); //当search参数值不存在时 如果长度大于20增加搜索功能, this.watchChange(true); } @@ -1457,10 +1469,10 @@ export default { deep: true }, url(newValue, oldValue) { - newValue ? this.watchChange(false) : (this.nodeList = JSON.parse(JSON.stringify(this.dataList || []))); + newValue ? this.watchChange(false) : (this.nodeList = this.$utils.deepClone(this.dataList || [])); }, dynamicUrl(newValue, oldValue) { - newValue ? this.watchChange(false) : (this.nodeList = JSON.parse(JSON.stringify(this.dataList || []))); + newValue ? this.watchChange(false) : (this.nodeList = this.$utils.deepClone(this.dataList || [])); }, params: { handler(newValue, oldValue) { @@ -1471,11 +1483,10 @@ export default { }, deep: true }, - isVisible: function(val) { - let _this = this; + isVisible(val) { if (val) { - this.$nextTick(function() { - _this.updatePosition(); + this.$nextTick(() => { + this.updatePosition(); }); typeof this.onOpenChange == 'function' && this.onOpenChange(val); this.firstOutside = false; @@ -1487,15 +1498,15 @@ export default { } } } - if (!val && _this.nodeList.length > 0) { - _this.nodeList.forEach(no => { + if (!val && this.nodeList.length > 0) { + this.nodeList.forEach(no => { no['_focusSelect'] = false; }); - _this.focusIndex = -1; + this.focusIndex = -1; } this.$emit('on-open-change', val); }, - multiple: function(val) { + multiple(val) { if (this.multiple == true && typeof this.currentValue == 'string') { this.currentValue = [this.currentValue]; } else if (this.multiple == false && typeof this.currentValue == 'object') { @@ -1530,20 +1541,6 @@ function setWidth($contain, $target, transfer) { // } } } - -function ArrIndexOf(arr, str) { - //重写 数组的indexof功能 主要是为了实现 1 = '1' 的情况 - let index = -1; - if (arr instanceof Array) { - arr.find((item, i) => { - utils.equalStr(item, str) && (index = i); - return index >= 0; - }); - } else { - utils.equalStr(arr, str) && (index = 0); - } - return index; -}