From 22d655c4d1031d8d6ecda2cfa3a81857c0a07f28 Mon Sep 17 00:00:00 2001 From: liushilong <2224574157@qq.com> Date: Tue, 16 Apr 2024 15:29:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E6=9F=A5=E9=87=8D=E9=BB=98=E8=AE=A4=E5=AD=97=E6=AE=B5=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 2 + .../aside/comp/modals/CustomFilterModal.vue | 31 +---- src/views/task/aside/Aside.vue | 126 ++++++++++++------ 3 files changed, 89 insertions(+), 70 deletions(-) diff --git a/components.d.ts b/components.d.ts index 8bdf533..61136d3 100644 --- a/components.d.ts +++ b/components.d.ts @@ -11,6 +11,7 @@ declare module 'vue' { BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default'] DataHeader: typeof import('./src/components/DataHeader/index.vue')['default'] NAvatar: typeof import('naive-ui')['NAvatar'] + NBackTop: typeof import('naive-ui')['NBackTop'] NButton: typeof import('naive-ui')['NButton'] NCard: typeof import('naive-ui')['NCard'] NCheckbox: typeof import('naive-ui')['NCheckbox'] @@ -33,6 +34,7 @@ declare module 'vue' { NModal: typeof import('naive-ui')['NModal'] NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] NotPassed: typeof import('./src/components/NotPassed.vue')['default'] + NPopconfirm: typeof import('naive-ui')['NPopconfirm'] NPopover: typeof import('naive-ui')['NPopover'] NPopselect: typeof import('naive-ui')['NPopselect'] NProgress: typeof import('naive-ui')['NProgress'] diff --git a/src/views/home/aside/comp/modals/CustomFilterModal.vue b/src/views/home/aside/comp/modals/CustomFilterModal.vue index 514f677..42831c1 100644 --- a/src/views/home/aside/comp/modals/CustomFilterModal.vue +++ b/src/views/home/aside/comp/modals/CustomFilterModal.vue @@ -33,11 +33,6 @@ function showModal() { return if (tempList.value.length > 0 && isEqual(tempList.value, configStore.getFilterConfig)) return - - console.log( - '开启了啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦筛选条件----------------', - customConfig, - ) const { showList, hideList } = generatList(config, customConfig) tempList.value = cloneDeep(showList) if (tempList.value.length > 0) @@ -136,17 +131,13 @@ function generatList(config, customConfig) { const fixedList = generateDefaultList(config) offList.unshift(...fixedList) onList.unshift(...fixedList) - console.log('原始筛选条件customConfig', customConfig) // onList按照customConfig排序 const tempOnList = cloneDeep(onList) - console.log('原始筛选条件tempOnList', tempOnList) - const sortKeyList: any = [] configStore.getFilterConfig.map((item: any) => { sortKeyList.push(item?.id) return item }) - console.log('原始筛选条件sortKeyList', sortKeyList) const sortList: any = [] if (sortKeyList.length > 0) { sortKeyList.map((key) => { @@ -162,8 +153,6 @@ function generatList(config, customConfig) { return key }) } - console.log('原始筛选条件sortList', sortList) - console.log('原始筛选条件configStore.getFilterConfig', configStore.getFilterConfig) // return { showList: onList, hideList: offList } return { showList: sortList, hideList: offList } } @@ -174,25 +163,21 @@ configStore.$subscribe(() => { if (config == null || customConfig == null) return - console.log('tempList.value-----------', tempList.value) - console.log('configStore.getFilterConfig-----------', configStore.getFilterConfig) if (tempList.value.length > 0 && isEqual(tempList.value, configStore.getFilterConfig)) return const { showList, hideList } = generatList(config, customConfig) tempList.value = cloneDeep(showList) - console.log('克隆条件', tempList.value) if (tempList.value.length > 0) configStore.setFilterConfig(tempList.value) - - // setTimeout(() => { - // }, 500); - onList.value = showList + onList.value = hideList.filter(item => (item as any).checked) offList.value = hideList + if (!showList.length) + handleSumbit() }) -async function handleSumbit(e: MouseEvent) { - e.preventDefault() +async function handleSumbit(e?: MouseEvent) { + e?.preventDefault() const param = onList.value .map((item) => { return item.id @@ -201,21 +186,15 @@ async function handleSumbit(e: MouseEvent) { await setFilter({ searchcount: param, type: 0 }) const obj = await configStore.fetchCustomConfig() - console.log('obj-------------------------------', obj) const tempOnList = cloneDeep(onList.value) - console.log('原始筛选条件tempOnList', tempOnList) const sortList: any = [] obj.map((key) => { const tempItem = tempOnList.find(item => item.id == key) sortList.push(tempItem) return key }) - console.log('configStore.sortList---------------', sortList) - // setTimeout(() => { if (sortList.length > 0) configStore.setFilterConfig(sortList) - - // }, 500); closeModal() } diff --git a/src/views/task/aside/Aside.vue b/src/views/task/aside/Aside.vue index d837b8d..1850148 100644 --- a/src/views/task/aside/Aside.vue +++ b/src/views/task/aside/Aside.vue @@ -10,6 +10,7 @@ import { unref, watch, } from 'vue' +import { useRoute } from 'vue-router' import CustomFieldModal from '../modal/CustomFieldModal.vue' import AdvanceFilter from '../../home/aside/comp/AdvanceFilter.vue' import { FilterModalVue } from '../../home/aside/comp/modals' @@ -17,22 +18,20 @@ import NewFilterModalVue from '../modal/NewFilterModal.vue' import TaskList from './TaskList.vue' import type { AsideEntity } from '@/config/aside' import { useUser } from '@/store/modules/user' -import { getAllfieldList, getfieldList } from '@/api/home/filter' +import { getAllfieldList, getConditionList, getfieldList } from '@/api/home/filter' import { useTaskStore } from '@/store/modules/task' import emitter from '@/utils/mitt' import { useConfig } from '@/store/modules/asideConfig' -import { getConditionList } from "@/api/home/filter"; -import type { FilterSearchParam } from "/#/api"; -import { useRoute } from 'vue-router' +import type { FilterSearchParam } from '/#/api' const route = useRoute() -const searchContent = route.query.searchContent as string; +const searchContent = route.query.searchContent as string const CustomFieldModalRef = ref(null) const collapse = ref(false) const taskStore = useTaskStore() const taskListRef: any = ref(null) -const AdvanceFilterRef: any = ref(null); +const AdvanceFilterRef: any = ref(null) // 展示字段 const showFieldList = ref([]) const search = ref('') @@ -115,6 +114,7 @@ async function getshowFieldList() { } showFieldList.value.push(item) } + return v }) } else { @@ -129,39 +129,40 @@ async function getshowFieldList() { } showFieldList.value.push(item) } + return v }) } } onMounted(() => { getshowFieldList() - window.addEventListener("keydown", handleKeydown); + window.addEventListener('keydown', handleKeydown) init() }) async function init() { try { const searchParam: FilterSearchParam = { - search_searchname: { value: "", op: "like", type: "string" }, - }; - const result = await getConditionList(1, searchParam, 2); - const { data } = result; + search_searchname: { value: '', op: 'like', type: 'string' }, + } + const result = await getConditionList(1, searchParam, 2) + const { data } = result if (data[0]) { - AdvanceFilterRef.value.setCurrentlySelectedAdvanced(data[0].searchname); + AdvanceFilterRef.value.setCurrentlySelectedAdvanced(data[0].searchname) setTimeout(() => { filterHandler(data[0].id) - }, 1000); - //filterHandler(data[0].id); + }, 1000) + // filterHandler(data[0].id); } // pagination.pageNo += 1 - - } catch (error) { - return []; - } finally { } - //currentlySelectedAdvanced.value="邱霞" + catch (error) { + return [] + } + // currentlySelectedAdvanced.value="邱霞" } function handleKeydown(event) { - if (event.key === "s") setShowSearch(true) + if (event.key === 's') + setShowSearch(true) } // 滚动容器,让key对应模块处于可视区域 function scrollHandler(key: string) { @@ -191,8 +192,8 @@ function newFilterOk() { filterModalRef.value.query( filterModalRef.value.pagination.page, filterModalRef.value.pagination.pageSize, - ); - filterModalRef.value.showModal(); + ) + filterModalRef.value.showModal() } onBeforeMount(async () => { configStore.fetchConfig() @@ -206,31 +207,37 @@ defineExpose({ setAsideItemName, }) -const initSerach = () => { +function initSerach() { if (searchContent) { - setShowSearch(true); - const id_param = searchContent.match(/-\d+-/); + setShowSearch(true) + const id_param = searchContent.match(/-\d+-/) if (id_param) { - search.value = id_param[0].slice(1, -1); - inputHandler(id_param[0].slice(1, -1)); + search.value = id_param[0].slice(1, -1) + inputHandler(id_param[0].slice(1, -1)) } } } -initSerach(); +initSerach() -const handleOk = (item: any) => { +function handleOk(item: any) { if (item) { - AdvanceFilterRef.value.setCurrentlySelectedAdvanced(item.searchname); - filterHandler(item.id); - } else { - AdvanceFilterRef.value.setCurrentlySelectedAdvanced("高级筛选"); - filterHandler(""); + AdvanceFilterRef.value.setCurrentlySelectedAdvanced(item.searchname) + filterHandler(item.id) + } + else { + AdvanceFilterRef.value.setCurrentlySelectedAdvanced('高级筛选') + filterHandler('') } -}; +}