Merge branch 'al'

bak
刘释隆 1 year ago
commit 8671c62ca7

@ -1,13 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import { favorite, getConditionList, unfavorite } from '@/api/home/filter' import { favorite, getConditionList, unfavorite } from "@/api/home/filter";
import { asideMap } from '@/config/aside' import { asideMap } from "@/config/aside";
import { useInfiniteScroll } from '@vueuse/core' import { useInfiniteScroll } from "@vueuse/core";
import { debounce } from 'lodash-es' import { debounce } from "lodash-es";
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref,watch } from "vue";
import type { FilterSearchParam } from '/#/api' import type { FilterSearchParam } from "/#/api";
import type { Filter, FilterEntity } from '/#/home' import type { Filter, FilterEntity } from "/#/home";
defineOptions({ name: 'AdvanceFilter' }) defineOptions({ name: "AdvanceFilter" });
const props = defineProps({ const props = defineProps({
type: { type: {
@ -15,109 +15,115 @@ const props = defineProps({
default: 0, default: 0,
required: true, required: true,
}, },
}) });
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'show-filter'): void (e: "show-filter"): void;
(e: 'show-custom'): void (e: "show-custom"): void;
(e: 'update:search'): void (e: "update:search"): void;
(e: 'select', id: string) (e: "select", id: string);
}>() }>();
const data = ref<FilterEntity[]>([]) const data = ref<FilterEntity[]>([]);
let loading = false let loading = false;
const canloadMore = true const canloadMore = true;
const el = ref<HTMLDivElement | null>(null) const el = ref<HTMLDivElement | null>(null);
const popover = ref<ComponentRef | null>(null) const popover = ref<ComponentRef | null>(null);
const pagination = reactive({ const pagination = reactive({
pageNo: 1, pageNo: 1,
pageSize: 300, pageSize: 300,
}) });
const keyword = ref('') const keyword = ref("");
onMounted(() => { onMounted(() => {
// data.value = generateDefaultConfig() // data.value = generateDefaultConfig()
}) });
// //
function generateDefaultConfig(): FilterEntity[] { function generateDefaultConfig(): FilterEntity[] {
return Object.keys(asideMap).reduce((acc, key) => { return Object.keys(asideMap).reduce((acc, key) => {
const { label, defaultValue, isDefaultFilter } = asideMap[key] const { label, defaultValue, isDefaultFilter } = asideMap[key];
if (isDefaultFilter === true) { if (isDefaultFilter === true) {
const config = { const config = {
id: '', id: "",
name: label, name: label,
favorite: false, favorite: false,
isDefaultFilter, isDefaultFilter,
filterList: [{ filterList: [
key, {
value: defaultValue, key,
}], value: defaultValue,
} },
return [...acc, config] ],
} };
else { return [...acc, config];
return acc } else {
return acc;
} }
}, []) }, []);
} }
useInfiniteScroll( useInfiniteScroll(
el as any, el as any,
() => { () => {
loadMore() loadMore();
}, },
{ distance: 10, interval: 300, canLoadMore: () => false }, { distance: 10, interval: 300, canLoadMore: () => false }
) );
const showClick = ()=>{
console.log('showClick')
inputHandler('')
}
async function loadMore() { async function loadMore() {
if (loading || el.value == null) if (loading || el.value == null) return;
return
const more = await featchList() const more = await featchList();
if (more.length === 0) if (more.length === 0) return;
return
data.value.push(...more) data.value.push(...more);
} }
async function featchList() { async function featchList() {
loading = true loading = true;
try { try {
const searchParam: FilterSearchParam = { search_searchname: { value: keyword.value, op: 'like', type: 'string' } } const searchParam: FilterSearchParam = {
const result = await getConditionList(pagination, searchParam, props.type) search_searchname: { value: keyword.value, op: "like", type: "string" },
const { data } = result };
const result = await getConditionList(pagination, searchParam, props.type);
const { data } = result;
// pagination.pageNo += 1 // pagination.pageNo += 1
// canloadMore = pageCount >= pagination.pageNo // canloadMore = pageCount >= pagination.pageNo
const entityList = generateFilterEntityList(data) const entityList = generateFilterEntityList(data);
return entityList return entityList;
} } catch (error) {
catch (error) { return [];
return [] } finally {
} loading = false;
finally {
loading = false
} }
} }
// //
function generateFilterEntityList(data) { function generateFilterEntityList(data) {
const filterEntityList = data.map((item) => { const filterEntityList = data.map((item) => {
const { searchname, iztop, ocrUsersearchchildList, id } = item const { searchname, iztop, ocrUsersearchchildList, id } = item;
const list = ocrUsersearchchildList.map((item) => { const list = ocrUsersearchchildList.map((item) => {
const { searchfield, searchvalue } = item const { searchfield, searchvalue } = item;
return { return {
key: searchfield, key: searchfield,
value: searchvalue, value: searchvalue,
} };
}) });
const reg = new RegExp(keyword.value, 'gi') const reg = new RegExp(keyword.value, "gi");
const hilightText = searchname.replace(reg, `<span style='color:#FF0000'>${keyword.value}</span>`) const hilightText = searchname.replace(
reg,
`<span style='color:#FF0000'>${keyword.value}</span>`
);
return { return {
id, id,
@ -125,45 +131,45 @@ function generateFilterEntityList(data) {
favorite: iztop, favorite: iztop,
isDefaultFilter: false, isDefaultFilter: false,
filterList: list, filterList: list,
} };
}) });
return filterEntityList return filterEntityList;
} }
function selectHandler(item: FilterEntity) { function selectHandler(item: FilterEntity) {
(popover.value as any).setShow(false) (popover.value as any).setShow(false);
emit('select', item.id) emit("select", item.id);
} }
const inputHandler = debounce((word) => { const inputHandler = debounce((word) => {
keyword.value = word keyword.value = word;
featchList().then((list) => { featchList().then((list) => {
data.value = list data.value = list;
}) });
}, 300) }, 300);
function favoriteHandler(event: MouseEvent, item: any) { function favoriteHandler(event: MouseEvent, item: any) {
event.stopImmediatePropagation() event.stopImmediatePropagation();
event.stopPropagation() event.stopPropagation();
const { isDefaultFilter, id } = item const { isDefaultFilter, id } = item;
if (!isDefaultFilter) { if (!isDefaultFilter) {
item.favorite = true item.favorite = true;
favorite(id) favorite(id);
} }
} }
function unFavoriteHandler(event: MouseEvent, item) { function unFavoriteHandler(event: MouseEvent, item) {
event.stopImmediatePropagation() event.stopImmediatePropagation();
event.stopPropagation() event.stopPropagation();
const { isDefaultFilter, id } = item const { isDefaultFilter, id } = item;
if (!isDefaultFilter) { if (!isDefaultFilter) {
item.favorite = false item.favorite = false;
unfavorite(id) unfavorite(id);
} }
} }
</script> </script>
@ -173,29 +179,58 @@ function unFavoriteHandler(event: MouseEvent, item) {
<div class="wrapper-left"> <div class="wrapper-left">
<svg-icon name="shield" size="32" /> <svg-icon name="shield" size="32" />
<n-popover <n-popover
ref="popover" :style="{ padding: '0px' }" style="width: 248px" :show-arrow="false" ref="popover"
placement="bottom-start" trigger="click" :style="{ padding: '0px' }"
style="width: 248px"
:show-arrow="false"
placement="bottom-start"
trigger="click"
> >
<template #trigger> <template #trigger>
<div class="wrapper-left-dropdown"> <div class="wrapper-left-dropdown" @click="showClick">
<span>高级筛选</span> <span>高级筛选</span>
<SvgIcon :style="{ marginLeft: '5px' }" name="down" size="14" /> <SvgIcon :style="{ marginLeft: '5px' }" name="down" size="14" />
</div> </div>
</template> </template>
<n-spin :show="loading"> <n-spin :show="loading">
<div class="wrapper-left-popover"> <div class="wrapper-left-popover">
<n-input :style="{ '--n-border': '0px' }" placeholder="请输入关键字" @input="inputHandler"> <n-input
:style="{ '--n-border': '0px' }"
placeholder="请输入关键字"
@input="inputHandler"
>
<template #prefix> <template #prefix>
<SvgIcon size="14px" name="magnifying-1" /> <SvgIcon size="14px" name="magnifying-1" />
</template> </template>
<template #suffix> <template #suffix>
<SvgIcon size="14px" style="cursor: pointer;" name="setting" @click="emit('show-filter')" /> <SvgIcon
size="14px"
style="cursor: pointer"
name="setting"
@click="emit('show-filter')"
/>
</template> </template>
</n-input> </n-input>
<ul ref="el" class="wrapper-left-list"> <ul ref="el" class="wrapper-left-list">
<li v-for="(item, index) in data" :key="index" style="display: flex;align-items: center;" @click="selectHandler(item)"> <li
<SvgIcon v-if="item.favorite && !item.isDefaultFilter" name="favorite-fill" color="#fd9b0a" size="18" @click="unFavoriteHandler($event, item)" /> v-for="(item, index) in data"
<SvgIcon v-else-if="!item.favorite && !item.isDefaultFilter" name="favorite-unfill" size="18" @click="favoriteHandler($event, item)" /> :key="index"
style="display: flex; align-items: center"
@click="selectHandler(item)"
>
<SvgIcon
v-if="item.favorite && !item.isDefaultFilter"
name="favorite-fill"
color="#fd9b0a"
size="18"
@click="unFavoriteHandler($event, item)"
/>
<SvgIcon
v-else-if="!item.favorite && !item.isDefaultFilter"
name="favorite-unfill"
size="18"
@click="favoriteHandler($event, item)"
/>
<div v-html="item.name" /> <div v-html="item.name" />
</li> </li>
</ul> </ul>
@ -204,8 +239,18 @@ function unFavoriteHandler(event: MouseEvent, item) {
</n-popover> </n-popover>
</div> </div>
<div class="wrapper-right"> <div class="wrapper-right">
<SvgIcon style="display: block;cursor: pointer;" size="18" name="magnifying-1" @click="emit('update:search')" /> <SvgIcon
<SvgIcon style="display: block;cursor: pointer;margin-left: 10px;" size="18" name="filter" @click="emit('show-custom')" /> style="display: block; cursor: pointer"
size="18"
name="magnifying-1"
@click="emit('update:search')"
/>
<SvgIcon
style="display: block; cursor: pointer; margin-left: 10px"
size="18"
name="filter"
@click="emit('show-custom')"
/>
</div> </div>
</div> </div>
</template> </template>
@ -243,7 +288,7 @@ function unFavoriteHandler(event: MouseEvent, item) {
scrollbar-width: none; /* firefox */ scrollbar-width: none; /* firefox */
-ms-overflow-style: none; /* IE 10+ */ -ms-overflow-style: none; /* IE 10+ */
&::-webkit-scrollbar{ &::-webkit-scrollbar {
display: none; display: none;
} }

@ -1,13 +1,18 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useTaskStore } from "@/store/modules/task"; import { useTaskStore } from "@/store/modules/task";
import { debounce } from "lodash-es"; import { debounce } from "lodash-es";
import { computed, onMounted, ref, unref, watch } from "vue"; import { computed, onMounted, ref, unref, watch,shallowRef } from "vue";
import CustomFieldModal from "../modal/CustomFieldModal.vue"; import CustomFieldModal from "../modal/CustomFieldModal.vue";
import type { AsideEntity } from '@/config/aside'
import { useUser } from "@/store/modules/user"; import { useUser } from "@/store/modules/user";
import { getAllfieldList, getfieldList, savefield } from "@/api/home/filter"; import { getAllfieldList, getfieldList, savefield } from "@/api/home/filter";
import TaskList from "./TaskList.vue"; import TaskList from "./TaskList.vue";
import AdvanceFilter from '../../home/aside/comp/AdvanceFilter.vue'
import emitter from '@/utils/mitt'
const CustomFieldModalRef = ref(null); const CustomFieldModalRef = ref(null);
const collapse = ref(false); const collapse = ref(false);
@ -110,6 +115,30 @@ async function getshowFieldList() {
onMounted(() => { onMounted(() => {
getshowFieldList(); getshowFieldList();
}); });
// key
function scrollHandler(key: string) {
const element = document.querySelector(`#${key}`)
element?.scrollIntoView(true)
}
//
function filterHandler(searchId: string) {
emitter.emit('filter', searchId)
}
function showModal(modalRef: any) {
const modal = unref(modalRef)! as any
modal.showModal()
}
//
const showItems = shallowRef<{ key: string, config: AsideEntity }[]>([])
const filterModalRef = ref(null)
const newFilterModalRef = ref(null)
const customModalRef = ref(null)
function editFilter(filter: any) {
const modal = unref(newFilterModalRef)! as any
modal.showModal()
modal.edit(filter)
}
</script> </script>
<template> <template>
@ -125,7 +154,7 @@ onMounted(() => {
</div> </div>
</div> </div>
<div class="aside-header"> <div class="aside-header">
<div v-show="!showSearch" class="warpper"> <!-- <div v-show="!showSearch" class="warpper">
<div class="left"> <div class="left">
<svg-icon name="all-worksheet" size="32" /> <svg-icon name="all-worksheet" size="32" />
<span style="margin-left: 8px">所有请求</span> <span style="margin-left: 8px">所有请求</span>
@ -144,7 +173,13 @@ onMounted(() => {
@click="showFilter" @click="showFilter"
/> />
</div> </div>
</div> </div> -->
<!-- 高级筛选 -->
<AdvanceFilter
v-show="!showSearch" :type="2" @select="filterHandler" @update:search="setShowSearch(true)"
@show-custom="showModal(customModalRef)" @show-filter="showModal(filterModalRef)"
/>
<div v-show="showSearch" class="warpper"> <div v-show="showSearch" class="warpper">
<n-input <n-input
style="flex: 1; height: 32px" style="flex: 1; height: 32px"
@ -162,6 +197,7 @@ onMounted(() => {
@click="setShowSearch(false)" @click="setShowSearch(false)"
/> />
</div> </div>
</div> </div>
<TaskList <TaskList
ref="taskListRef" ref="taskListRef"

Loading…
Cancel
Save