From 27c8277d717b34b55f3ea967027b53b067f77df3 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 20 八月 2026 16:58:49 +0800
Subject: [PATCH] feat 功能变更
---
src/views/bi/decision/kpi-dashboard/index.vue | 90 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 90 insertions(+), 0 deletions(-)
diff --git a/src/views/bi/decision/kpi-dashboard/index.vue b/src/views/bi/decision/kpi-dashboard/index.vue
new file mode 100644
index 0000000..a41563a
--- /dev/null
+++ b/src/views/bi/decision/kpi-dashboard/index.vue
@@ -0,0 +1,90 @@
+<script lang="ts" setup>
+import { onMounted, ref } from 'vue';
+
+import { Page } from '@vben/common-ui';
+
+import { Spin, Tag } from 'ant-design-vue';
+
+import { getKpiOverview } from '#/api/bi/decision/kpi';
+import type { DecisionKpiApi } from '#/api/bi/decision/kpi';
+
+defineOptions({ name: 'DecisionKpiDashboard' });
+
+const loading = ref(true);
+const overview = ref<DecisionKpiApi.KpiOverview>({ kpis: [], total: 0 });
+
+async function loadData() {
+ loading.value = true;
+ try {
+ overview.value = await getKpiOverview();
+ } catch {
+ // ignore
+ } finally {
+ loading.value = false;
+ }
+}
+
+const CATEGORY_MAP: Record<string, string> = {
+ power_supply: '渚涚數閲�',
+ device_operation: '璁惧杩愯',
+ production: '鐢熶骇',
+ quality: '璐ㄩ噺',
+ procurement: '閲囪喘',
+ safety: '瀹夊叏',
+};
+
+const CATEGORY_COLORS: Record<string, string> = {
+ power_supply: '#1677ff',
+ device_operation: '#722ed1',
+ production: '#13c2c2',
+ quality: '#52c41a',
+ procurement: '#fa8c16',
+ safety: '#ff4d4f',
+};
+
+function alertStatusColor(status: string): string {
+ if (status === 'critical') return 'red';
+ if (status === 'warn') return 'orange';
+ return 'green';
+}
+
+function alertStatusText(status: string): string {
+ if (status === 'critical') return '涓ラ噸';
+ if (status === 'warn') return '璀﹀憡';
+ return '姝e父';
+}
+
+onMounted(loadData);
+</script>
+
+<template>
+ <Page :auto-content-height="true">
+ <Spin :spinning="loading">
+ <div class="p-4">
+ <h2 class="mb-4 text-lg font-bold">鐢靛姏 KPI 鐪嬫澘</h2>
+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
+ <div
+ v-for="kpi in overview.kpis"
+ :key="kpi.code"
+ class="rounded-lg border p-4 shadow-sm transition-shadow hover:shadow-md"
+ :style="{ borderTop: `3px solid ${CATEGORY_COLORS[kpi.category] || '#1677ff'}` }"
+ >
+ <div class="mb-1 flex items-center justify-between">
+ <span class="text-xs text-gray-500">{{ CATEGORY_MAP[kpi.category] || kpi.category }}</span>
+ <Tag :color="alertStatusColor(kpi.alertStatus)">
+ {{ alertStatusText(kpi.alertStatus) }}
+ </Tag>
+ </div>
+ <div class="mb-1 text-2xl font-bold">
+ {{ kpi.value ?? '-' }}
+ </div>
+ <div class="flex items-center justify-between">
+ <span class="text-sm font-medium">{{ kpi.name }}</span>
+ <span class="text-xs text-gray-400">{{ kpi.unit || '' }}</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </Spin>
+ </Page>
+</template>
\ No newline at end of file
--
Gitblit v1.9.3