Files
console-dev/app/lib/invoice.js
T
2026-11-06 00:04:38 +08:00

29 lines
946 B
JavaScript

async function e(e) {
let t = [],
n = new Set();
for (let r = 1; ; r++) {
let i = await e(r, 50);
if (!i || !Array.isArray(i.list))
throw Error(`发票资料格式异常,请重新加载`);
let a = i.count === void 0 ? null : Number(i.count);
if (a !== null && (!Number.isSafeInteger(a) || a < 0))
throw Error(`发票资料分页信息异常,请重新加载`);
let o = t.length;
for (let e of i.list) {
if (
!e ||
![`number`, `string`].includes(typeof e.id) ||
!String(e.id).trim()
)
throw Error(`发票资料格式异常,请重新加载`);
let r = String(e.id);
n.has(r) || (n.add(r), t.push(e));
}
if ((a !== null && t.length >= a) || (a === null && i.list.length < 50))
return t;
if (t.length === o)
throw Error(`未能加载完整发票资料,分页数据可能已变化,请重试`);
}
}
export { e as t };