flat: 修改

This commit is contained in:
史典卓
2025-08-20 13:38:47 +08:00
parent 58c36c01a0
commit 07b2aa5f80
12 changed files with 184 additions and 35 deletions

View File

@@ -49,7 +49,7 @@ export function usePagination(
const fetchData = async (type = 'refresh') => {
if (loading.value) return Promise.resolve()
console.log(type)
loading.value = true
error.value = false
@@ -77,17 +77,17 @@ export function usePagination(
}
const params = {
...pageState.search,
[pageField]: pageState.page,
[sizeField]: pageState.pageSize,
...pageState.search
}
try {
const res = await requestFn(params)
const rawData = res[dataKey]
const total = res[totalKey]
const total = res[totalKey] || 99999999
console.log(total, rawData)
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
if (type === 'refresh') {
@@ -137,10 +137,10 @@ export function usePagination(
if (autoWatchSearch && isRef(search)) {
watch(search, (newVal) => {
pageState.search = newVal
// clearTimeout(debounceTimer)
// debounceTimer = setTimeout(() => {
// refresh()
// }, debounceTime)
clearTimeout(debounceTimer)
debounceTimer = setTimeout(() => {
refresh()
}, debounceTime)
}, {
deep: true
})