diff --git a/src/resources/plugins/TsForm/TsFormSelect.vue b/src/resources/plugins/TsForm/TsFormSelect.vue index c5fb71838bd54e2d913aaec7cd9bc5603fa30ded..f31f86da614dbfb5551d1969493dc048497520c4 100755 --- a/src/resources/plugins/TsForm/TsFormSelect.vue +++ b/src/resources/plugins/TsForm/TsFormSelect.vue @@ -913,12 +913,27 @@ export default { let findSelect = selectedList.find(sel => sel[this.valueName] == item); findSelect && list.push(findSelect); }); + const tempList = this.handleEnterDisplayValue(); + if (tempList.length > 0) { + list.unshift(...tempList); + list = this.$utils.uniqueByField(list, this.valueName); + } + } else { + const tempList = this.handleEnterDisplayValue(); + if (tempList.length > 0) { + selectedList.unshift(...tempList); + selectedList = this.$utils.uniqueByField(selectedList, this.valueName); + } } this.selectedList = selectedList.length > 1 && !this.$utils.isEmpty(list) ? list : selectedList; this.handleEchoFailedDefaultValue(); } else { this.selectedList = []; this.handleEchoFailedDefaultValue(); + const tempList = this.handleEnterDisplayValue(); + if (tempList.length > 0) { + this.selectedList = this.$utils.uniqueByField(tempList, this.valueName); + } } if (!this.multiple) { @@ -932,6 +947,29 @@ export default { } }); }, + handleEnterDisplayValue() { + // 处理回车创建值回显问题 + let tempList = []; + if (this.allowCreate && !this.$utils.isEmpty(this.currentValue)) { + if (Array.isArray(this.currentValue)) { + this.currentValue.forEach(item => { + const findItem = this.selectedList.find(v => v[this.valueName] == item); + if (!findItem && !this.$utils.isEmpty(item)) { + tempList.unshift({ + [this.valueName]: item, + [this.textName]: item + }); + } + }); + } else { + tempList.unshift({ + [this.valueName]: this.currentValue, + [this.textName]: this.currentValue + }); + } + } + return tempList; + }, handleObjectValue(valueName) { if (!this.isCustomValue) { return this.currentValue == valueName;