2026-07-31 15:17:21 +08:00
|
|
|
const getApiHost = () => {
|
|
|
|
|
if (typeof window !== 'undefined' && window.process?.env?.app?.API_HOST) {
|
|
|
|
|
return window.process.env.app.API_HOST;
|
|
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
};
|
|
|
|
|
|
2026-08-03 15:48:45 +08:00
|
|
|
// 与 @cqsjjb/jjb-common-lib http 层保持一致:从 sessionStorage 读取 token 并以同名请求头传递
|
|
|
|
|
function getTokenHeader() {
|
|
|
|
|
const token = window.sessionStorage.getItem('token');
|
|
|
|
|
return token ? { token } : {};
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-31 15:17:21 +08:00
|
|
|
async function request(path, params = {}) {
|
|
|
|
|
const apiHost = getApiHost();
|
|
|
|
|
const url = new URL(path, apiHost);
|
|
|
|
|
Object.entries(params).forEach(([k, v]) => {
|
|
|
|
|
if (v !== undefined && v !== null && v !== '') {
|
|
|
|
|
url.searchParams.append(k, v);
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-08-03 15:48:45 +08:00
|
|
|
const response = await fetch(url.toString(), { headers: getTokenHeader() });
|
2026-07-31 15:17:21 +08:00
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error(`HTTP ${response.status}`);
|
|
|
|
|
}
|
|
|
|
|
const json = await response.json();
|
|
|
|
|
if (json.code !== '0') {
|
|
|
|
|
throw new Error(json.errMessage || json.message || 'API error');
|
|
|
|
|
}
|
|
|
|
|
return json.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 资质全生命周期管理
|
|
|
|
|
export function fetchQualificationOverview(year) {
|
|
|
|
|
return request('/safetyEval/regulator/cockpit/qualification-overview', { year });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 核心KPI指标
|
|
|
|
|
export function fetchKpi(cycle, year) {
|
|
|
|
|
return request('/safetyEval/regulator/cockpit/kpi', { cycle, year });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 区域地图分布
|
|
|
|
|
export function fetchRegionDistribution() {
|
|
|
|
|
return request('/safetyEval/regulator/cockpit/region-distribution');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 执业全过程管控 + 项目流程
|
|
|
|
|
export function fetchProcessOverview() {
|
|
|
|
|
return request('/safetyEval/regulator/cockpit/process-overview');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 评价类型趋势
|
|
|
|
|
export function fetchEvalTypeTrend(period, year) {
|
|
|
|
|
return request('/safetyEval/regulator/cockpit/eval-type-trend', { period, year });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 复盘评估改进提效
|
|
|
|
|
export function fetchReviewSummary(year) {
|
|
|
|
|
return request('/safetyEval/regulator/cockpit/review-summary', { year });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 项目实时监控
|
|
|
|
|
export function fetchProjectMonitor(month) {
|
|
|
|
|
return request('/safetyEval/regulator/cockpit/project-monitor', { month });
|
|
|
|
|
}
|