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']
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']

@ -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)
// onListcustomConfig
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()
}

@ -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<any[]>([])
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('')
}
};
}
</script>
<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 class="aside-collapse-btn" @click="collapseHandler">
<SvgIcon :name="collapseIcon" size="40" />
@ -259,24 +266,55 @@ const handleOk = (item: any) => {
</div>
</div> -->
<!-- 高级筛选 -->
<AdvanceFilter v-show="!showSearch" :type="2" @select="filterHandler" @update:search="setShowSearch(true)"
@show-custom="showModal(CustomFieldModalRef)" @show-filter="showModal(filterModalRef)" ref="AdvanceFilterRef" />
<AdvanceFilter
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">
<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>
<SvgIcon size="14px" name="magnifying-1" />
</template>
</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>
<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) -->
<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"
@show-new-filter="showModal(newFilterModalRef)" @handleOk="handleOk" />
<FilterModalVue
ref="filterModalRef"
:type="2"
@edit-filter="editFilter"
@show-new-filter="showModal(newFilterModalRef)"
@handle-ok="handleOk"
/>
<!-- 新增过滤 -->
<NewFilterModalVue ref="newFilterModalRef" @on-ok="newFilterOk" />
</div>

Loading…
Cancel
Save