From fdd0af4e886c7671985074872bec53f4d57677ae Mon Sep 17 00:00:00 2001 From: 3octaves <873551943@qq.com> Date: Fri, 15 Nov 2024 10:01:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E5=85=A8=E7=AB=99=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E4=BC=98=E5=8C=96=20#7951?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/system-search/Index.vue | 94 +++++++--- .../components/FilterTypeSelect.vue | 80 +++++++++ .../search-result/FilterOptions.vue | 4 +- .../components/search-result/Index.vue | 90 ++++++++-- .../render-result/ClusterDomain.vue | 17 +- .../render-result/ClusterName.vue | 19 +- .../search-result/render-result/Instance.vue | 24 +-- .../search-result/render-result/Machine.vue | 4 - .../render-result/ResourcePool.vue | 1 - .../search-result/render-result/Task.vue | 4 - .../search-result/render-result/Ticket.vue | 4 - dbm-ui/frontend/src/locales/zh-cn.json | 3 + .../src/services/source/quickSearch.ts | 8 +- .../frontend/src/views/quick-search/Index.vue | 31 +++- .../quick-search/components/SearchInput.vue | 170 ++++++++++++------ 15 files changed, 402 insertions(+), 151 deletions(-) create mode 100644 dbm-ui/frontend/src/components/system-search/components/FilterTypeSelect.vue diff --git a/dbm-ui/frontend/src/components/system-search/Index.vue b/dbm-ui/frontend/src/components/system-search/Index.vue index c31ad7afba..e440915151 100644 --- a/dbm-ui/frontend/src/components/system-search/Index.vue +++ b/dbm-ui/frontend/src/components/system-search/Index.vue @@ -28,6 +28,13 @@ @enter="handleEnter" @focus="handleFocus" @paste="handlePaste"> + + + @@ -52,7 +59,8 @@ + v-model="serach" + :filter-type="filterType"> @@ -64,8 +72,11 @@ import { computed, onBeforeUnmount, ref } from 'vue'; import { useI18n } from 'vue-i18n'; + import { quickSearch } from '@services/source/quickSearch'; + import { batchSplitRegex } from '@common/regex'; + import FilterTypeSelect, { FilterType } from './components/FilterTypeSelect.vue'; import SearchResult from './components/search-result/Index.vue'; import SearchHistory from './components/SearchHistory.vue'; import useKeyboard from './hooks/useKeyboard'; @@ -74,13 +85,16 @@ const route = useRoute(); const router = useRouter(); + let tippyIns: Instance | undefined; + const serach = ref(''); const rootRef = ref(); const popRef = ref(); - const searchResultRef = ref(); + const searchResultRef = ref>(); const isFocused = ref(false); const popContentStyle = ref({}); const isPopMenuShow = ref(false); + const filterType = ref(FilterType.CONTAINS); const styles = computed(() => ({ flex: isFocused.value ? '1' : '0 0 auto', @@ -88,8 +102,6 @@ const { activeIndex } = useKeyboard(rootRef, popRef); - let tippyIns: Instance | undefined; - const handlePaste = () => { setTimeout(() => { serach.value = serach.value.replace(batchSplitRegex, '|'); @@ -138,35 +150,37 @@ const handleSearch = () => { // 页面跳转参数处理 - const options = searchResultRef.value.getFilterOptions(); - const query = Object.keys(options).reduce((prevQuery, optionKey) => { - const optionItem = options[optionKey]; + const { formData, keyword } = searchResultRef.value!.getFilterOptions(); + quickSearch({ + ...formData, + keyword, + }).then((quickSearchResult) => { + const options = { + ...formData, + short_code: quickSearchResult.short_code, + }; + const query = Object.keys(options).reduce((prevQuery, optionKey) => { + const optionItem = options[optionKey as keyof typeof options]; - if (optionItem !== '' && !(Array.isArray(optionItem) && optionItem.length === 0)) { - if (Array.isArray(optionItem)) { + if (optionItem !== '' && !(Array.isArray(optionItem) && optionItem.length === 0)) { return { ...prevQuery, - [optionKey]: optionItem.join(','), + [optionKey]: Array.isArray(optionItem) ? optionItem.join(',') : optionItem, }; } - return { - ...prevQuery, - [optionKey]: optionItem, - }; - } + return prevQuery; + }, {}); - return prevQuery; - }, {}); - - const url = router.resolve({ - name: 'QuickSearch', - query: { - ...query, - from: route.name as string, - }, + const url = router.resolve({ + name: 'QuickSearch', + query: { + ...query, + from: route.name as string, + }, + }); + window.open(url.href, '_blank'); }); - window.open(url.href, '_blank'); }; const handleEnter = () => { @@ -224,6 +238,36 @@ width: auto !important; } + .system-search-top-filter-type-select { + display: flex; + width: 80px; + height: 30px; + color: #fff; + cursor: pointer; + background: #3b4b68; + align-items: center; + justify-content: space-around; + + .label-content { + position: relative; + + .more-icon { + display: inline-block; + font-size: 14px; + transform: rotate(0deg); + transition: all 0.5s; + } + + .more-icon-active { + transform: rotate(-180deg); + } + + .icon-disabled { + color: #c4c6cc; + } + } + } + .search-input { overflow: hidden; border: 1px solid transparent; diff --git a/dbm-ui/frontend/src/components/system-search/components/FilterTypeSelect.vue b/dbm-ui/frontend/src/components/system-search/components/FilterTypeSelect.vue new file mode 100644 index 0000000000..9f5b2a885a --- /dev/null +++ b/dbm-ui/frontend/src/components/system-search/components/FilterTypeSelect.vue @@ -0,0 +1,80 @@ + + + + + + + {{ currentTitle }} + + + + + + + + + + + diff --git a/dbm-ui/frontend/src/components/system-search/components/search-result/FilterOptions.vue b/dbm-ui/frontend/src/components/system-search/components/search-result/FilterOptions.vue index 4baec09f6a..48d679e208 100644 --- a/dbm-ui/frontend/src/components/system-search/components/search-result/FilterOptions.vue +++ b/dbm-ui/frontend/src/components/system-search/components/search-result/FilterOptions.vue @@ -85,7 +85,7 @@ - + +