瀏覽代碼

模型统计

CzRger 1 月之前
父節點
當前提交
c4e407f08b
共有 2 個文件被更改,包括 49 次插入44 次删除
  1. 3 0
      src/api/modules/model/index.ts
  2. 46 44
      src/views/manage/model/statistic/index.vue

+ 3 - 0
src/api/modules/model/index.ts

@@ -25,3 +25,6 @@ export const pluginUpdateStatus = (params) =>
   post(`/plugin/update-status`, params, {}, proxy)
 // 模型纳管删除
 export const pluginDel = (id) => del(`/plugin/${id}`, {}, {}, proxy)
+// 模型纳管-统计
+export const pluginGetDetailInfo = (params) =>
+  get(`/plugin/get-detail-info`, params, {}, proxy)

+ 46 - 44
src/views/manage/model/statistic/index.vue

@@ -52,20 +52,47 @@
         <div class="card">
           <div class="__czr-title_1">Token调用次数</div>
           <div class="h-[9rem] w-full">
-            <lineChart :data="state.statistic.token" />
+            <template v-if="state.statistic.token?.length > 0">
+              <lineChart :data="state.statistic.token" />
+            </template>
+            <template v-else>
+              <div
+                class="flex size-full items-center justify-center opacity-65"
+              >
+                暂无数据
+              </div>
+            </template>
           </div>
         </div>
         <div class="card">
           <div class="__czr-title_1">大模型调用次数</div>
           <div class="h-[9rem] w-full">
-            <lineChart :data="state.statistic.call" />
+            <template v-if="state.statistic.call?.length > 0">
+              <lineChart :data="state.statistic.call" />
+            </template>
+            <template v-else>
+              <div
+                class="flex size-full items-center justify-center opacity-65"
+              >
+                暂无数据
+              </div>
+            </template>
           </div>
         </div>
         <div class="flex gap-4">
           <div class="card flex-1">
             <div class="__czr-title_1">调用单位占比统计</div>
             <div class="h-[16rem] w-full">
-              <pieChart :data="state.statistic.dept" />
+              <template v-if="state.statistic.dept?.length > 0">
+                <pieChart :data="state.statistic.dept" />
+              </template>
+              <template v-else>
+                <div
+                  class="flex size-full items-center justify-center opacity-65"
+                >
+                  暂无数据
+                </div>
+              </template>
             </div>
           </div>
           <div class="card flex-1">
@@ -165,7 +192,7 @@ import { useRoute, useRouter } from 'vue-router'
 import { ElMessage } from 'element-plus'
 import lineChart from './line-chart.vue'
 import pieChart from './pie-chart.vue'
-import { pluginDetail } from '@/api/modules/model'
+import { pluginDetail, pluginGetDetailInfo } from '@/api/modules/model'
 import { useDictionaryStore } from '@/stores'
 import { YMDHms } from '@/utils/czr-util'
 import toBackCom from '@/views/manage/components/to-back.vue'
@@ -180,31 +207,9 @@ const state: any = reactive({
   ID: route.params.id,
   detail: {},
   statistic: {
-    token: [
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 357 },
-      { name: '2025-05-07', value: 367 },
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 3567 },
-    ],
-    call: [
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 357 },
-      { name: '2025-05-07', value: 367 },
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 3567 },
-      { name: '2025-05-07', value: 3567 },
-    ],
-    dept: [
-      { name: '省公安厅', value: 3567 },
-      { name: '省人社厅', value: 357 },
-      { name: '省大数据局', value: 367 },
-    ],
+    token: [],
+    call: [],
+    dept: [],
     table: {
       dateType: 1,
       cusDate: [],
@@ -231,30 +236,27 @@ const initDetail = () => {
     pluginDetail(state.ID)
       .then(({ data }: any) => {
         state.detail = data
+        initStatistic()
       })
       .catch(() => {})
       .finally(() => {})
-    initStatistic()
   } else {
     router.push({ name: '86e9f5e8-285d-4038-abc2-a39b2ad7fcd1' })
   }
 }
 const initStatistic = () => {
   state.statistic.table.query.loading = true
-  setTimeout(() => {
-    const arr: any = []
-    for (let i = 1; i <= 100; i++) {
-      arr.push({
-        id: i + '',
-        p1: '文件' + i + '.md',
-      })
-    }
-    state.statistic.table.query.result.data = arr
-    // setTimeout(() => {
-    //   state.query.selected = [arr[1], arr[5]]
-    // })
-    state.statistic.table.query.loading = false
-  }, 1000)
+  pluginGetDetailInfo({ id: state.ID }).then(({ data }: any) => {
+    state.statistic.token = data?.token || []
+    state.statistic.call = data?.call || []
+    state.statistic.dept = data?.dept || []
+  })
+  initTable()
+}
+const initTable = () => {
+  state.statistic.table.query.loading = true
+  state.statistic.table.query.result.data = []
+  state.statistic.table.query.loading = false
 }
 onMounted(() => {
   initDictionary()