|
|
|
@ -8,57 +8,44 @@ import { useVbenVxeGrid } from '#/adapter/vxe-table'; |
|
|
|
import { columns } from './data'; |
|
|
|
import { {{entity}}Api } from '#/api/{{entity}}'; |
|
|
|
|
|
|
|
|
|
|
|
console.log('=== columns 配置 ===', columns) |
|
|
|
const [Grid, gridApi] = useVbenVxeGrid({ |
|
|
|
|
|
|
|
const gridOptions = { |
|
|
|
columns, |
|
|
|
|
|
|
|
gridOptions: { |
|
|
|
proxyConfig: { |
|
|
|
ajax: { |
|
|
|
query: async ({ page }) => { |
|
|
|
try { |
|
|
|
console.log('=== 请求参数 ===', page) |
|
|
|
|
|
|
|
const res = await userApi.page({ |
|
|
|
pageNum: page?.currentPage || 1, |
|
|
|
pageSize: page?.pageSize || 10, |
|
|
|
}) |
|
|
|
|
|
|
|
console.log('=== API 返回的数据 ===', res) |
|
|
|
const data = res.error?.result || res.result || res |
|
|
|
const result = { |
|
|
|
items: data.records, |
|
|
|
total: data.total |
|
|
|
} |
|
|
|
console.log('=== 转换后的数据 ===', result) |
|
|
|
return result |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('查询用户列表失败:', error) |
|
|
|
throw error |
|
|
|
proxyConfig: { |
|
|
|
ajax: { |
|
|
|
query: async ({ page }) => { |
|
|
|
try { |
|
|
|
const res = await userApi.page({ |
|
|
|
pageNum: page?.currentPage || 1, |
|
|
|
pageSize: page?.pageSize || 10, |
|
|
|
}) |
|
|
|
|
|
|
|
const data = res.error?.result || res.result || res |
|
|
|
|
|
|
|
return { |
|
|
|
items: data.records || [], |
|
|
|
total: data.total || 0 |
|
|
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('查询用户列表失败:', error) |
|
|
|
throw error |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
pagerConfig: { |
|
|
|
enabled: true, |
|
|
|
}, |
|
|
|
response: { |
|
|
|
result: 'items', |
|
|
|
total: 'total' |
|
|
|
} |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
pagerConfig: { |
|
|
|
enabled: true, |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions }) |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<Grid table-title="用户列表"> |
|
|
|
<template #toolbar-tools> |
|
|
|
<button @click="() => gridApi.reload()">刷新</button> |
|
|
|
</template> |
|
|
|
</Grid> |
|
|
|
</div> |
|
|
|
|
|
|
|
<template> |
|
|
|
<Grid/> |
|
|
|
</template> |