From 673b1a41a82757bd2e2ff2128115d655365a520e Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Mon, 25 Jul 2022 17:34:05 +0800 Subject: [PATCH] refactor: update the tags component (#127) --- src/views/components/ConditionTags.vue | 95 +++++++++++++++++--------- 1 file changed, 61 insertions(+), 34 deletions(-) diff --git a/src/views/components/ConditionTags.vue b/src/views/components/ConditionTags.vue index 2c32a6bf..f7e2ae60 100644 --- a/src/views/components/ConditionTags.vue +++ b/src/views/components/ConditionTags.vue @@ -33,32 +33,34 @@ limitations under the License. --> @change="addLabels" :placeholder="t('addTags')" /> - - - - - - + + +
+ + {{ item }} + +
+
(""); const tagsList = ref([]); const tagArr = ref([]); +const tagList = ref([]); const tagKeys = ref([]); +const visible = ref(false); const tipsMap = { LOG: "logTagsTip", TRACE: "traceTagsTip", ALARM: "alarmTagsTip", }; -const dropdownTag = ref>(null); fetchTagKeys(); @@ -144,6 +147,7 @@ async function fetchTagKeys() { } tagArr.value = resp.data.tagKeys; tagKeys.value = resp.data.tagKeys; + searchTags(); } async function fetchTagValues() { @@ -160,25 +164,36 @@ async function fetchTagValues() { return; } tagArr.value = resp.data.tagValues; + searchTags(); } function selectTag(item: string) { if (tags.value.includes("=")) { - tags.value += item; + const key = tags.value.split("=")[0]; + tags.value = key + "=" + item; addLabels(); tagArr.value = tagKeys.value; - dropdownTag.value.handleClose(); + searchTags(); return; } tags.value = item + "="; fetchTagValues(); } -function showClick() { - if (dropdownTag.value) { - dropdownTag.value.handleOpen(); +function searchTags() { + if (!tags.value) { + tagList.value = tagArr.value; + return; } + let search = ""; + if (tags.value.includes("=")) { + search = tags.value.split("=")[1]; + } else { + search = tags.value; + } + tagList.value = tagArr.value.filter((d: string) => d.includes(search)); } + watch( () => appStore.durationTime, () => { @@ -211,6 +226,7 @@ watch( padding: 2px 5px; border-radius: 3px; width: 250px; + z-index: 999; } .remove-icon { @@ -222,6 +238,12 @@ watch( .tag-item { display: inline-block; min-width: 210px; + cursor: pointer; + margin-top: 10px; + + &:hover { + color: #409eff; + } } .tags-tip { @@ -230,7 +252,6 @@ watch( .link-tips { display: inline-block; - margin-left: 130px; } .light { @@ -248,4 +269,10 @@ watch( .icon-help { cursor: pointer; } + +.content { + width: 300px; + max-height: 400px; + overflow: auto; +}