Flask + SQLite 后端,免构建 React + ECharts 前端,含合成样例数据。 测试参考数据(FOR-TEST-ONLY)与运行时数据库不入库。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
2.7 KiB
JavaScript
53 lines
2.7 KiB
JavaScript
import {html} from 'vendor';
|
||
import {useApp, useFetch} from '../api.js';
|
||
import {accentMax, fixed, num} from '../format.js';
|
||
import {EChart} from '../components/EChart.js';
|
||
import {DataTable} from '../components/DataTable.js';
|
||
import {Kpi, Loading, Section} from '../components/ui.js';
|
||
|
||
const BENCH_COLUMNS = [
|
||
{key: 'scene', title: '场景'}, {key: 'sites', title: '站点数'}, {key: 'count', title: '退服次数'},
|
||
{key: 'total_h', title: '累计时长(h)'}, {key: 'avg_min', title: '平均时长(min)'}, {key: 'outage_rate', title: '退服率(%)'},
|
||
{key: 'availability', title: '可用率(%)'}, {key: 'long_ratio', title: '超长占比(%)'}, {key: 'repeat_rate', title: '重复退服率(%)'},
|
||
{key: 'users', title: '受影响用户', render: num}, {key: 'loss_gb', title: '业务损失(GB)', render: num},
|
||
];
|
||
|
||
/** 场景柱状图配置:最大的场景用强调色标出 */
|
||
const sceneBar = (bench, values) => ({
|
||
tooltip: {trigger: 'axis', axisPointer: {type: 'shadow'}},
|
||
xAxis: {type: 'category', data: bench.map(x => x.scene)},
|
||
yAxis: {type: 'value'},
|
||
series: [{type: 'bar', barMaxWidth: 34, label: {show: true, position: 'top'}, data: accentMax(values)}],
|
||
});
|
||
|
||
export default function Impact() {
|
||
const {filters} = useApp();
|
||
const {data} = useFetch('/api/dashboard', filters);
|
||
if (!data) return html`<${Loading}/>`;
|
||
const {kpi: k, bench} = data;
|
||
|
||
return html`
|
||
<div className="grid">
|
||
<${Section} title="影响评估">
|
||
<div className="kpis">
|
||
<${Kpi} title="受影响用户" value=${num(k.users)} unit="人次" sub="小区数 × 单小区在线用户 × 忙闲时系数"/>
|
||
<${Kpi} title="业务损失" value=${num(k.loss_gb)} unit="GB" sub="小区话务 × 退服时长"/>
|
||
<${Kpi} title="退服率" value=${fixed(k.outage_rate)} unit="%"/>
|
||
<${Kpi} title="网络可用率" value=${fixed(k.availability)} unit="%"/>
|
||
<${Kpi} title="平均退服时长" value=${k.avg_min} unit="min"/>
|
||
<${Kpi} title="超长退服占比" value=${fixed(k.long_ratio)} unit="%"/>
|
||
<${Kpi} title="重复退服率" value=${fixed(k.repeat_rate)} unit="%"/>
|
||
</div>
|
||
</${Section}>
|
||
<${Section} span=${6} title="分场景退服率" hint="单位:%">
|
||
<${EChart} option=${sceneBar(bench, bench.map(x => x.outage_rate))}/>
|
||
</${Section}>
|
||
<${Section} span=${6} title="分场景受影响用户" hint="单位:万人次">
|
||
<${EChart} option=${sceneBar(bench, bench.map(x => +(x.users / 1e4).toFixed(1)))}/>
|
||
</${Section}>
|
||
<${Section} title="通信场景运维考核指标横向对标">
|
||
<${DataTable} rowKey="scene" columns=${BENCH_COLUMNS} rows=${bench}/>
|
||
</${Section}>
|
||
</div>`;
|
||
}
|