|
|
|
@ -5,6 +5,7 @@ import { debounce } from 'lodash-es'
|
|
|
|
|
import { asideMap } from '@/config/aside'
|
|
|
|
|
import { favorite, getConditionList, unfavorite } from '@/api/home/filter'
|
|
|
|
|
import type { Filter, FilterEntity } from '/#/home'
|
|
|
|
|
import type { FilterSearchParam } from '/#/api'
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'AdvanceFilter' })
|
|
|
|
|
|
|
|
|
@ -17,17 +18,17 @@ const emit = defineEmits<{
|
|
|
|
|
|
|
|
|
|
const data = ref<FilterEntity[]>([])
|
|
|
|
|
let loading = false
|
|
|
|
|
let lastPostion = 0
|
|
|
|
|
let canloadMore = true
|
|
|
|
|
const canloadMore = true
|
|
|
|
|
const el = ref<HTMLDivElement | null>(null)
|
|
|
|
|
const popover = ref<ComponentRef | null>(null)
|
|
|
|
|
const pagination = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
pageSize: 300,
|
|
|
|
|
})
|
|
|
|
|
const keyword = ref('')
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
data.value = generateDefaultConfig()
|
|
|
|
|
// data.value = generateDefaultConfig()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 默认的过滤配置
|
|
|
|
@ -58,30 +59,29 @@ useInfiniteScroll(
|
|
|
|
|
() => {
|
|
|
|
|
loadMore()
|
|
|
|
|
},
|
|
|
|
|
{ distance: 10, interval: 3000, canLoadMore: () => canloadMore },
|
|
|
|
|
{ distance: 10, interval: 300, canLoadMore: () => false },
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
async function loadMore() {
|
|
|
|
|
if (loading || el.value == null)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
lastPostion = el.value!.scrollTop
|
|
|
|
|
const more = await featchList()
|
|
|
|
|
|
|
|
|
|
if (more.length === 0)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
data.value.push(...more)
|
|
|
|
|
el.value?.scrollTo(0, lastPostion)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function featchList() {
|
|
|
|
|
loading = true
|
|
|
|
|
try {
|
|
|
|
|
const result = await getConditionList({ ...pagination })
|
|
|
|
|
const { data, pageCount } = result
|
|
|
|
|
pagination.pageNo += 1
|
|
|
|
|
canloadMore = pageCount >= pagination.pageNo
|
|
|
|
|
const searchParam: FilterSearchParam = { search_searchname: { value: keyword.value, op: 'like', type: 'string' } }
|
|
|
|
|
const result = await getConditionList(pagination, searchParam)
|
|
|
|
|
const { data } = result
|
|
|
|
|
// pagination.pageNo += 1
|
|
|
|
|
// canloadMore = pageCount >= pagination.pageNo
|
|
|
|
|
const entityList = generateFilterEntityList(data)
|
|
|
|
|
return entityList
|
|
|
|
|
}
|
|
|
|
@ -124,8 +124,11 @@ function selectHandler(item: FilterEntity) {
|
|
|
|
|
emit('select', item.filterList)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const inputHandler = debounce((keyword) => {
|
|
|
|
|
// 调用后端接口,搜索
|
|
|
|
|
const inputHandler = debounce((word) => {
|
|
|
|
|
keyword.value = word
|
|
|
|
|
featchList().then((list) => {
|
|
|
|
|
data.value = list
|
|
|
|
|
})
|
|
|
|
|
}, 300)
|
|
|
|
|
|
|
|
|
|
function favoriteHandler(event: MouseEvent, item: any) {
|
|
|
|
|