|
|
@@ -550,6 +550,23 @@
|
|
|
return (number > 0 ? "+" : "") + formatNumber(number);
|
|
|
}
|
|
|
|
|
|
+ async function readJsonResponse(response, fallbackMessage) {
|
|
|
+ const text = await response.text();
|
|
|
+ try {
|
|
|
+ return JSON.parse(text);
|
|
|
+ } catch (_) {
|
|
|
+ const error = new Error(fallbackMessage);
|
|
|
+ if (/<!DOCTYPE html|loginStatus\s*=\s*["']0["']|输入您的密码/i.test(text)) {
|
|
|
+ error.message = "登录状态已失效,请刷新页面并重新登录";
|
|
|
+ error.sessionExpired = true;
|
|
|
+ } else if (/没有服务授权/i.test(text)) {
|
|
|
+ error.message = "当前账号没有星级班报表权限,请联系管理员";
|
|
|
+ error.noPermission = true;
|
|
|
+ }
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
async function postDetail(payload) {
|
|
|
const body = new URLSearchParams();
|
|
|
Object.keys(payload).forEach(function (key) {
|
|
|
@@ -567,7 +584,7 @@
|
|
|
body: body.toString()
|
|
|
}
|
|
|
);
|
|
|
- const result = await response.json();
|
|
|
+ const result = await readJsonResponse(response, "明细加载失败");
|
|
|
if (result.ssCode !== 0)
|
|
|
throw new Error(result.ssMsg || "明细加载失败");
|
|
|
return result.ssData;
|
|
|
@@ -955,7 +972,8 @@
|
|
|
body: body.toString()
|
|
|
}
|
|
|
);
|
|
|
- const result = await response.json();
|
|
|
+ const result = await readJsonResponse(
|
|
|
+ response, "月结报表加载失败");
|
|
|
if (result.ssCode !== 0)
|
|
|
throw new Error(result.ssMsg || "月结报表加载失败");
|
|
|
applyReport(result.ssData);
|