|
@@ -401,6 +401,25 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 数据变更后刷新:重拉筛选选项与聚合数据,不重建图表 */
|
|
|
|
|
+ async function refresh() {
|
|
|
|
|
+ const { body } = await api('/api/ops/summary');
|
|
|
|
|
+ if (!body || !body.enabled) return;
|
|
|
|
|
+ // 清理已不存在于新数据的筛选值
|
|
|
|
|
+ const schoolNames = new Set((body.schools || []).map((s) => s.name));
|
|
|
|
|
+ if (state.schools) {
|
|
|
|
|
+ const next = new Set([...state.schools].filter((name) => schoolNames.has(name)));
|
|
|
|
|
+ state.schools = next.size ? next : null;
|
|
|
|
|
+ }
|
|
|
|
|
+ const shopKeys = new Set((body.shops || []).map((s) => String(s.key || s.shopId)));
|
|
|
|
|
+ if (state.shops) {
|
|
|
|
|
+ const next = new Set([...state.shops].filter((key) => shopKeys.has(key)));
|
|
|
|
|
+ state.shops = next.size ? next : null;
|
|
|
|
|
+ }
|
|
|
|
|
+ mountFilters(body);
|
|
|
|
|
+ await loadData();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async function init() {
|
|
async function init() {
|
|
|
if (state.inited) return;
|
|
if (state.inited) return;
|
|
|
state.inited = true;
|
|
state.inited = true;
|
|
@@ -423,6 +442,10 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ window.addEventListener('ops:data-changed', () => {
|
|
|
|
|
+ if (state.inited) refresh();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
window.shanCockpitInit = function () {
|
|
window.shanCockpitInit = function () {
|
|
|
init();
|
|
init();
|
|
|
const refresh = $('btnCockpitRefresh');
|
|
const refresh = $('btnCockpitRefresh');
|