feat:余额排序
This commit is contained in:
1 parent
528f2e0b3d
commit
cf7d21cd04
3 files changed
+50
-6
No files matched your search
@@ -26,7 +26,12 @@ function load(source, mocks) {
|
||||
function mount() {
|
||||
const requests = []
|
||||
const lists = []
|
||||
const listRequests = []
|
||||
const errors = []
|
||||
const api = load(fs.readFileSync(path.join(root, "api/wallet/wallet-manage.ts"), "utf8"), {
|
||||
"/@/utils/request": options => { listRequests.push(options); return Promise.resolve({ data: { records: [], total: 100 } }) },
|
||||
"/@/api/asyncTask": {},
|
||||
})
|
||||
const table = load(fs.readFileSync(path.join(root, "hooks/table.ts"), "utf8"), {
|
||||
"element-plus": { ElMessage: { error: message => errors.push(message) } },
|
||||
"/@/utils/other": {}, "../utils/formatTime": {},
|
||||
@@ -34,7 +39,7 @@ function mount() {
|
||||
const page = load(source, {
|
||||
"/@/hooks/table": table,
|
||||
"/@/api/wallet/wallet-manage": {
|
||||
fetchListJoinQb: query => { lists.push(query); return Promise.resolve({ data: { records: [], total: 100 } }) },
|
||||
fetchListJoinQb: query => { lists.push(query); return api.fetchListJoinQb(query) },
|
||||
qbTotal: (query, signal) => new Promise((resolve, reject) => requests.push({ query, signal, resolve, reject })),
|
||||
},
|
||||
"/@/hooks/batchExport": { useBatchExport: () => ({}) },
|
||||
@@ -53,12 +58,40 @@ function mount() {
|
||||
setup() { state = page.default.setup({}, { expose() {} }); return () => null },
|
||||
})
|
||||
app.mount({})
|
||||
return { state, requests, lists, errors, close: () => app.unmount() }
|
||||
return { state, requests, lists, listRequests, errors, close: () => app.unmount() }
|
||||
}
|
||||
|
||||
const settle = () => new Promise(resolve => setImmediate(resolve))
|
||||
const result = total => ({ code: 0, data: { total, eatTotal: total, payTotal: 0, topupTotal: 0 } })
|
||||
|
||||
test("余额排序经真实表格 hook 和 API 传至后端,切换回首页、翻页保留筛选且取消后恢复默认", async () => {
|
||||
const page = mount()
|
||||
try {
|
||||
await settle()
|
||||
Object.assign(page.state.state.queryForm, { deptIds: ["11"], walletTypeIdList: ["21"], isInclude: false })
|
||||
page.state.currentChangeHandle(3)
|
||||
await settle()
|
||||
await page.state.handleBalanceSortChange({ prop: "balance", order: "ascending" })
|
||||
const ascending = page.listRequests.at(-1)
|
||||
assert.equal(ascending.url, "/wallet/wallet-manage/page-join-qb")
|
||||
assert.equal(ascending.method, "post")
|
||||
assert.deepEqual(ascending.params, { current: 1, size: 10, ascs: "balance", descs: undefined })
|
||||
assert.equal(ascending.data.walletRecordMonth, "2026-10")
|
||||
assert.deepEqual(ascending.data.deptIds, ["11"])
|
||||
assert.deepEqual(ascending.data.walletTypeIdList, ["21"])
|
||||
assert.equal(ascending.data.isInclude, false)
|
||||
page.state.currentChangeHandle(2)
|
||||
await settle()
|
||||
assert.deepEqual(page.listRequests.at(-1).params, { current: 2, size: 10, ascs: "balance", descs: undefined })
|
||||
await page.state.handleBalanceSortChange({ prop: "balance", order: "descending" })
|
||||
await page.state.handleBalanceSortChange({ prop: "balance", order: "descending" })
|
||||
assert.deepEqual(page.listRequests.at(-1).params, { current: 1, size: 10, ascs: undefined, descs: "balance" })
|
||||
await page.state.handleBalanceSortChange({ order: null })
|
||||
assert.deepEqual(page.listRequests.at(-1).params, { current: 1, size: 10, ascs: undefined, descs: undefined })
|
||||
assert.equal(page.requests.length, 0)
|
||||
} finally { page.close() }
|
||||
})
|
||||
|
||||
test("列表首次加载、筛选和翻页均不触发全量余额统计", async () => {
|
||||
const page = mount()
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user