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-config/index.vue |   88 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/src/views/bi/decision/kpi-config/index.vue b/src/views/bi/decision/kpi-config/index.vue
new file mode 100644
index 0000000..d1dc6bc
--- /dev/null
+++ b/src/views/bi/decision/kpi-config/index.vue
@@ -0,0 +1,88 @@
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { DecisionKpiApi } from '#/api/bi/decision/kpi';
+
+import { Page, useVbenModal } from '@vben/common-ui';
+
+import { message, Tag } from 'ant-design-vue';
+
+import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
+import { deleteKpiDefinition, getKpiDefinitionPage } from '#/api/bi/decision/kpi';
+
+import { CATEGORY_MAP, useGridColumns, useGridFormSchema } from './data';
+import Form from './modules/form.vue';
+
+defineOptions({ name: 'DecisionKpiConfig' });
+
+const [FormModal, formModalApi] = useVbenModal({
+  connectedComponent: Form,
+  destroyOnClose: true,
+});
+
+const [Grid, gridApi] = useVbenVxeGrid({
+  formOptions: {
+    schema: useGridFormSchema(),
+  },
+  gridOptions: {
+    columns: useGridColumns(),
+    height: 'auto',
+    proxyConfig: {
+      ajax: {
+        query: async ({ page, form }: any) => {
+          const res = await getKpiDefinitionPage({ ...page, ...form });
+          return res;
+        },
+      },
+    },
+  } as VxeTableGridOptions<DecisionKpiApi.KpiDefinition>,
+});
+
+function handleRefresh() {
+  gridApi.query();
+}
+
+function handleCreate() {
+  formModalApi.setData(null).open();
+}
+
+function handleEdit(row: DecisionKpiApi.KpiDefinition) {
+  formModalApi.setData(row).open();
+}
+
+async function handleDelete(row: DecisionKpiApi.KpiDefinition) {
+  const hide = message.loading(`姝e湪鍒犻櫎銆�${row.name}銆�...`, 0);
+  try {
+    await deleteKpiDefinition(row.id!);
+    message.success(`鍒犻櫎銆�${row.name}銆嶆垚鍔焋);
+    handleRefresh();
+  } finally {
+    hide();
+  }
+}
+</script>
+
+<template>
+  <Page :auto-content-height="true">
+    <div class="mb-3 flex items-center justify-between">
+      <span class="text-lg font-bold">KPI鎸囨爣瀹氫箟</span>
+      <a-button type="primary" @click="handleCreate">鏂板</a-button>
+    </div>
+    <Grid>
+      <template #categorySlot="{ row }">
+        <Tag color="blue">{{ CATEGORY_MAP[row.category] || row.category }}</Tag>
+      </template>
+      <template #statusSlot="{ row }">
+        <Tag :color="row.status === 1 ? 'green' : 'default'">{{ row.status === 1 ? '鍚敤' : '绂佺敤' }}</Tag>
+      </template>
+      <template #actionSlot="{ row }">
+        <TableAction
+          :actions="[
+            { label: '缂栬緫', type: 'link', icon: ACTION_ICON.EDIT, onClick: handleEdit.bind(null, row) },
+            { label: '鍒犻櫎', type: 'link', danger: true, icon: ACTION_ICON.DELETE, onClick: handleDelete.bind(null, row) },
+          ]"
+        />
+      </template>
+    </Grid>
+    <FormModal />
+  </Page>
+</template>
\ No newline at end of file

--
Gitblit v1.9.3