mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 11:26:43 +08:00
调整
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
multiple
|
||||
filterable
|
||||
value-key="id"
|
||||
default-first-option
|
||||
remote
|
||||
reserve-keyword
|
||||
:remote-method="debouncedSearch"
|
||||
@@ -13,8 +14,8 @@
|
||||
:placeholder="'回车创建新标签'"
|
||||
@remove-tag="handleTagRemove"
|
||||
@change="handleSelectionChange"
|
||||
@keyup.enter.native="handleEnterKey"
|
||||
@keyup.delete.native="handleDeleteKey"
|
||||
|
||||
|
||||
@focus="handleFocus"
|
||||
ref="tagSelect"
|
||||
>
|
||||
@@ -168,26 +169,26 @@ export default {
|
||||
},
|
||||
|
||||
//按回车键,创建新标签
|
||||
handleEnterKey(event) {
|
||||
const inputVal = event.target.value?.trim()
|
||||
if (!inputVal) return;
|
||||
// 检查是否与已选择的标签重复
|
||||
const isDuplicate = this.selectedTags.some(tag => tag.tagName === inputVal);
|
||||
if (isDuplicate) {
|
||||
this.$message.warning('该标签已存在,无需重复创建');
|
||||
event.target.value = '';
|
||||
return;
|
||||
}
|
||||
if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) {
|
||||
this.createNewTag(event.target.value.trim())
|
||||
this.clearInput();
|
||||
} else if (this.selectedTags.length >= this.maxTags) {
|
||||
this.$message.warning('最多只能添加5个标签')
|
||||
this.clearInput();
|
||||
} else {
|
||||
this.clearInput();
|
||||
}
|
||||
},
|
||||
// handleEnterKey(event) {
|
||||
// const inputVal = event.target.value?.trim()
|
||||
// if (!inputVal) return;
|
||||
// // 检查是否与已选择的标签重复
|
||||
// const isDuplicate = this.selectedTags.some(tag => tag.tagName === inputVal);
|
||||
// if (isDuplicate) {
|
||||
// this.$message.warning('该标签已存在,无需重复创建');
|
||||
// event.target.value = '';
|
||||
// return;
|
||||
// }
|
||||
// if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) {
|
||||
// this.createNewTag(event.target.value.trim())
|
||||
// this.clearInput();
|
||||
// } else if (this.selectedTags.length >= this.maxTags) {
|
||||
// this.$message.warning('最多只能添加5个标签')
|
||||
// this.clearInput();
|
||||
// } else {
|
||||
// this.clearInput();
|
||||
// }
|
||||
// },
|
||||
|
||||
// 新增:处理选择变化事件
|
||||
handleSelectionChange(newValues) {
|
||||
|
||||
Reference in New Issue
Block a user