fix: 修复一键查重默认字段不生效问题

pull/203/head
刘释隆 1 year ago
parent 0187c85944
commit 22d655c4d1

2
components.d.ts vendored

@ -11,6 +11,7 @@ declare module 'vue' {
BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default'] BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default']
DataHeader: typeof import('./src/components/DataHeader/index.vue')['default'] DataHeader: typeof import('./src/components/DataHeader/index.vue')['default']
NAvatar: typeof import('naive-ui')['NAvatar'] NAvatar: typeof import('naive-ui')['NAvatar']
NBackTop: typeof import('naive-ui')['NBackTop']
NButton: typeof import('naive-ui')['NButton'] NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard'] NCard: typeof import('naive-ui')['NCard']
NCheckbox: typeof import('naive-ui')['NCheckbox'] NCheckbox: typeof import('naive-ui')['NCheckbox']
@ -33,6 +34,7 @@ declare module 'vue' {
NModal: typeof import('naive-ui')['NModal'] NModal: typeof import('naive-ui')['NModal']
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
NotPassed: typeof import('./src/components/NotPassed.vue')['default'] NotPassed: typeof import('./src/components/NotPassed.vue')['default']
NPopconfirm: typeof import('naive-ui')['NPopconfirm']
NPopover: typeof import('naive-ui')['NPopover'] NPopover: typeof import('naive-ui')['NPopover']
NPopselect: typeof import('naive-ui')['NPopselect'] NPopselect: typeof import('naive-ui')['NPopselect']
NProgress: typeof import('naive-ui')['NProgress'] NProgress: typeof import('naive-ui')['NProgress']

@ -33,11 +33,6 @@ function showModal() {
return return
if (tempList.value.length > 0 && isEqual(tempList.value, configStore.getFilterConfig)) if (tempList.value.length > 0 && isEqual(tempList.value, configStore.getFilterConfig))
return return
console.log(
'开启了啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦筛选条件----------------',
customConfig,
)
const { showList, hideList } = generatList(config, customConfig) const { showList, hideList } = generatList(config, customConfig)
tempList.value = cloneDeep(showList) tempList.value = cloneDeep(showList)
if (tempList.value.length > 0) if (tempList.value.length > 0)
@ -136,17 +131,13 @@ function generatList(config, customConfig) {
const fixedList = generateDefaultList(config) const fixedList = generateDefaultList(config)
offList.unshift(...fixedList) offList.unshift(...fixedList)
onList.unshift(...fixedList) onList.unshift(...fixedList)
console.log('原始筛选条件customConfig', customConfig)
// onListcustomConfig // onListcustomConfig
const tempOnList = cloneDeep(onList) const tempOnList = cloneDeep(onList)
console.log('原始筛选条件tempOnList', tempOnList)
const sortKeyList: any = [] const sortKeyList: any = []
configStore.getFilterConfig.map((item: any) => { configStore.getFilterConfig.map((item: any) => {
sortKeyList.push(item?.id) sortKeyList.push(item?.id)
return item return item
}) })
console.log('原始筛选条件sortKeyList', sortKeyList)
const sortList: any = [] const sortList: any = []
if (sortKeyList.length > 0) { if (sortKeyList.length > 0) {
sortKeyList.map((key) => { sortKeyList.map((key) => {
@ -162,8 +153,6 @@ function generatList(config, customConfig) {
return key return key
}) })
} }
console.log('原始筛选条件sortList', sortList)
console.log('原始筛选条件configStore.getFilterConfig', configStore.getFilterConfig)
// return { showList: onList, hideList: offList } // return { showList: onList, hideList: offList }
return { showList: sortList, hideList: offList } return { showList: sortList, hideList: offList }
} }
@ -174,25 +163,21 @@ configStore.$subscribe(() => {
if (config == null || customConfig == null) if (config == null || customConfig == null)
return return
console.log('tempList.value-----------', tempList.value)
console.log('configStore.getFilterConfig-----------', configStore.getFilterConfig)
if (tempList.value.length > 0 && isEqual(tempList.value, configStore.getFilterConfig)) if (tempList.value.length > 0 && isEqual(tempList.value, configStore.getFilterConfig))
return return
const { showList, hideList } = generatList(config, customConfig) const { showList, hideList } = generatList(config, customConfig)
tempList.value = cloneDeep(showList) tempList.value = cloneDeep(showList)
console.log('克隆条件', tempList.value)
if (tempList.value.length > 0) if (tempList.value.length > 0)
configStore.setFilterConfig(tempList.value) configStore.setFilterConfig(tempList.value)
onList.value = hideList.filter(item => (item as any).checked)
// setTimeout(() => {
// }, 500);
onList.value = showList
offList.value = hideList offList.value = hideList
if (!showList.length)
handleSumbit()
}) })
async function handleSumbit(e: MouseEvent) { async function handleSumbit(e?: MouseEvent) {
e.preventDefault() e?.preventDefault()
const param = onList.value const param = onList.value
.map((item) => { .map((item) => {
return item.id return item.id
@ -201,21 +186,15 @@ async function handleSumbit(e: MouseEvent) {
await setFilter({ searchcount: param, type: 0 }) await setFilter({ searchcount: param, type: 0 })
const obj = await configStore.fetchCustomConfig() const obj = await configStore.fetchCustomConfig()
console.log('obj-------------------------------', obj)
const tempOnList = cloneDeep(onList.value) const tempOnList = cloneDeep(onList.value)
console.log('原始筛选条件tempOnList', tempOnList)
const sortList: any = [] const sortList: any = []
obj.map((key) => { obj.map((key) => {
const tempItem = tempOnList.find(item => item.id == key) const tempItem = tempOnList.find(item => item.id == key)
sortList.push(tempItem) sortList.push(tempItem)
return key return key
}) })
console.log('configStore.sortList---------------', sortList)
// setTimeout(() => {
if (sortList.length > 0) if (sortList.length > 0)
configStore.setFilterConfig(sortList) configStore.setFilterConfig(sortList)
// }, 500);
closeModal() closeModal()
} }

@ -10,6 +10,7 @@ import {
unref, unref,
watch, watch,
} from 'vue' } from 'vue'
import { useRoute } from 'vue-router'
import CustomFieldModal from '../modal/CustomFieldModal.vue' import CustomFieldModal from '../modal/CustomFieldModal.vue'
import AdvanceFilter from '../../home/aside/comp/AdvanceFilter.vue' import AdvanceFilter from '../../home/aside/comp/AdvanceFilter.vue'
import { FilterModalVue } from '../../home/aside/comp/modals' import { FilterModalVue } from '../../home/aside/comp/modals'
@ -17,22 +18,20 @@ import NewFilterModalVue from '../modal/NewFilterModal.vue'
import TaskList from './TaskList.vue' import TaskList from './TaskList.vue'
import type { AsideEntity } from '@/config/aside' import type { AsideEntity } from '@/config/aside'
import { useUser } from '@/store/modules/user' 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 { useTaskStore } from '@/store/modules/task'
import emitter from '@/utils/mitt' import emitter from '@/utils/mitt'
import { useConfig } from '@/store/modules/asideConfig' 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 route = useRoute()
const searchContent = route.query.searchContent as string; const searchContent = route.query.searchContent as string
const CustomFieldModalRef = ref(null) const CustomFieldModalRef = ref(null)
const collapse = ref(false) const collapse = ref(false)
const taskStore = useTaskStore() const taskStore = useTaskStore()
const taskListRef: any = ref(null) const taskListRef: any = ref(null)
const AdvanceFilterRef: any = ref(null); const AdvanceFilterRef: any = ref(null)
// //
const showFieldList = ref<any[]>([]) const showFieldList = ref<any[]>([])
const search = ref('') const search = ref('')
@ -115,6 +114,7 @@ async function getshowFieldList() {
} }
showFieldList.value.push(item) showFieldList.value.push(item)
} }
return v
}) })
} }
else { else {
@ -129,39 +129,40 @@ async function getshowFieldList() {
} }
showFieldList.value.push(item) showFieldList.value.push(item)
} }
return v
}) })
} }
} }
onMounted(() => { onMounted(() => {
getshowFieldList() getshowFieldList()
window.addEventListener("keydown", handleKeydown); window.addEventListener('keydown', handleKeydown)
init() init()
}) })
async function init() { async function init() {
try { try {
const searchParam: FilterSearchParam = { const searchParam: FilterSearchParam = {
search_searchname: { value: "", op: "like", type: "string" }, search_searchname: { value: '', op: 'like', type: 'string' },
}; }
const result = await getConditionList(1, searchParam, 2); const result = await getConditionList(1, searchParam, 2)
const { data } = result; const { data } = result
if (data[0]) { if (data[0]) {
AdvanceFilterRef.value.setCurrentlySelectedAdvanced(data[0].searchname); AdvanceFilterRef.value.setCurrentlySelectedAdvanced(data[0].searchname)
setTimeout(() => { setTimeout(() => {
filterHandler(data[0].id) filterHandler(data[0].id)
}, 1000); }, 1000)
//filterHandler(data[0].id); // filterHandler(data[0].id);
} }
// pagination.pageNo += 1 // pagination.pageNo += 1
} catch (error) {
return [];
} finally {
} }
//currentlySelectedAdvanced.value="" catch (error) {
return []
}
// currentlySelectedAdvanced.value=""
} }
function handleKeydown(event) { function handleKeydown(event) {
if (event.key === "s") setShowSearch(true) if (event.key === 's')
setShowSearch(true)
} }
// key // key
function scrollHandler(key: string) { function scrollHandler(key: string) {
@ -191,8 +192,8 @@ function newFilterOk() {
filterModalRef.value.query( filterModalRef.value.query(
filterModalRef.value.pagination.page, filterModalRef.value.pagination.page,
filterModalRef.value.pagination.pageSize, filterModalRef.value.pagination.pageSize,
); )
filterModalRef.value.showModal(); filterModalRef.value.showModal()
} }
onBeforeMount(async () => { onBeforeMount(async () => {
configStore.fetchConfig() configStore.fetchConfig()
@ -206,31 +207,37 @@ defineExpose({
setAsideItemName, setAsideItemName,
}) })
const initSerach = () => { function initSerach() {
if (searchContent) { if (searchContent) {
setShowSearch(true); setShowSearch(true)
const id_param = searchContent.match(/-\d+-/); const id_param = searchContent.match(/-\d+-/)
if (id_param) { if (id_param) {
search.value = id_param[0].slice(1, -1); search.value = id_param[0].slice(1, -1)
inputHandler(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) { if (item) {
AdvanceFilterRef.value.setCurrentlySelectedAdvanced(item.searchname); AdvanceFilterRef.value.setCurrentlySelectedAdvanced(item.searchname)
filterHandler(item.id); filterHandler(item.id)
} else { }
AdvanceFilterRef.value.setCurrentlySelectedAdvanced("高级筛选"); else {
filterHandler(""); AdvanceFilterRef.value.setCurrentlySelectedAdvanced('高级筛选')
filterHandler('')
} }
}; }
</script> </script>
<template> <template>
<div class="aside" :style="asideStyle" @mouseenter="asideEnter = true" @mouseleave="asideEnter = false"> <div
class="aside"
:style="asideStyle"
@mouseenter="asideEnter = true"
@mouseleave="asideEnter = false"
>
<div v-show="showCollapse" class="aside-collapse"> <div v-show="showCollapse" class="aside-collapse">
<div class="aside-collapse-btn" @click="collapseHandler"> <div class="aside-collapse-btn" @click="collapseHandler">
<SvgIcon :name="collapseIcon" size="40" /> <SvgIcon :name="collapseIcon" size="40" />
@ -259,24 +266,55 @@ const handleOk = (item: any) => {
</div> </div>
</div> --> </div> -->
<!-- 高级筛选 --> <!-- 高级筛选 -->
<AdvanceFilter v-show="!showSearch" :type="2" @select="filterHandler" @update:search="setShowSearch(true)" <AdvanceFilter
@show-custom="showModal(CustomFieldModalRef)" @show-filter="showModal(filterModalRef)" ref="AdvanceFilterRef" /> v-show="!showSearch"
ref="AdvanceFilterRef"
:type="2"
@select="filterHandler"
@update:search="setShowSearch(true)"
@show-custom="showModal(CustomFieldModalRef)"
@show-filter="showModal(filterModalRef)"
/>
<div v-show="showSearch" class="warpper"> <div v-show="showSearch" class="warpper">
<n-input v-model:value="search" style="flex: 1; height: 32px" placeholder="请输入你需要搜索的内容" @input="inputHandler"> <n-input
v-model:value="search"
style="flex: 1; height: 32px"
placeholder="请输入你需要搜索的内容"
@input="inputHandler"
>
<template #suffix> <template #suffix>
<SvgIcon size="14px" name="magnifying-1" /> <SvgIcon size="14px" name="magnifying-1" />
</template> </template>
</n-input> </n-input>
<SvgIcon size="16px" style="margin-left: 6px; cursor: pointer" name="clear" @click="setShowSearch(false)" /> <SvgIcon
size="16px"
style="margin-left: 6px; cursor: pointer"
name="clear"
@click="setShowSearch(false)"
/>
</div> </div>
</div> </div>
<TaskList ref="taskListRef" :show-field-list="showFieldList" style="height: 811px" class="work-sheet-list" /> <TaskList
ref="taskListRef"
:show-field-list="showFieldList"
style="height: 811px"
class="work-sheet-list"
/>
<!-- calc(100vh - 146px) --> <!-- calc(100vh - 146px) -->
<CustomFieldModal ref="CustomFieldModalRef" :review-type="reviewType" @on-ok="getshowFieldList" /> <CustomFieldModal
ref="CustomFieldModalRef"
:review-type="reviewType"
@on-ok="getshowFieldList"
/>
<!-- 过滤列表 --> <!-- 过滤列表 -->
<FilterModalVue ref="filterModalRef" :type="2" @edit-filter="editFilter" <FilterModalVue
@show-new-filter="showModal(newFilterModalRef)" @handleOk="handleOk" /> ref="filterModalRef"
:type="2"
@edit-filter="editFilter"
@show-new-filter="showModal(newFilterModalRef)"
@handle-ok="handleOk"
/>
<!-- 新增过滤 --> <!-- 新增过滤 -->
<NewFilterModalVue ref="newFilterModalRef" @on-ok="newFilterOk" /> <NewFilterModalVue ref="newFilterModalRef" @on-ok="newFilterOk" />
</div> </div>

Loading…
Cancel
Save