flat: 修改
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
Reference in New Issue
Block a user