perf: 优化标签选择

This commit is contained in:
kuaifan 2025-07-08 10:57:09 +08:00
parent b01a54437a
commit 5e4a08538b
3 changed files with 11 additions and 7 deletions

View File

@ -98,10 +98,7 @@ export default {
}, },
methods: { methods: {
onOpen(tag = null) { onOpen(tag = null) {
if (tag === null) { this.editingTag = { ...this.getEmptyTag(), ...(tag || {}) }
tag = this.getEmptyTag()
}
this.editingTag = { ...tag }
this.showEditModal = true this.showEditModal = true
}, },

View File

@ -35,7 +35,7 @@
<!-- Add Button --> <!-- Add Button -->
<div class="footer-box"> <div class="footer-box">
<div class="add-button" @click="$emit('add')"> <div class="add-button" @click="$emit('add', searchQuery)">
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
<span>{{ $L('添加标签') }}</span> <span>{{ $L('添加标签') }}</span>
</div> </div>
@ -99,6 +99,9 @@ export default {
isSelected(tag) { isSelected(tag) {
return this.value.some(item => item.name === tag.name); return this.value.some(item => item.name === tag.name);
}, },
clearSearch() {
this.searchQuery = '';
},
toggleTag(tag) { toggleTag(tag) {
const isSelected = this.isSelected(tag); const isSelected = this.isSelected(tag);
let newValue; let newValue;
@ -176,6 +179,8 @@ export default {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
max-height: 300px; max-height: 300px;
margin: 0 -12px;
padding: 0 12px;
.tag-item { .tag-item {
display: flex; display: flex;

View File

@ -155,6 +155,7 @@
<div class="item-content tags"> <div class="item-content tags">
<EPopover v-model="tagShow" class="tags-select" placement="bottom"> <EPopover v-model="tagShow" class="tags-select" placement="bottom">
<TaskTagSelect <TaskTagSelect
ref="tagSelect"
v-model="tagValue" v-model="tagValue"
:data-sources="tagData" :data-sources="tagData"
:loading="tagLoad > 0" :loading="tagLoad > 0"
@ -2063,13 +2064,13 @@ export default {
this.$set(this.delayTaskForm, 'type', type) this.$set(this.delayTaskForm, 'type', type)
}, },
onTagAdd() { onTagAdd(tagName) {
// //
this.tagValue = this.getTag; this.tagValue = this.getTag;
this.tagBakValue = $A.cloneJSON(this.tagValue); this.tagBakValue = $A.cloneJSON(this.tagValue);
// //
this.tagShow = false this.tagShow = false
this.$refs.addTag.onOpen(null) this.$refs.addTag.onOpen(tagName ? {name: tagName} : null)
}, },
onTagAddSave(result) { onTagAddSave(result) {
@ -2082,6 +2083,7 @@ export default {
]; ];
// //
this.updateData('tag', mergedTags); this.updateData('tag', mergedTags);
this.$refs.tagSelect?.clearSearch();
}, },
getTypeLabel(type) { getTypeLabel(type) {