CzRger hai 2 semanas
pai
achega
b0d3c2bf84

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

@@ -20,3 +20,8 @@ export const pluginUpdateInstance = (params) =>
   put('/plugin/update-instance', params, {}, proxy)
 // 模型纳管详情
 export const pluginDetail = (id) => get(`/plugin/${id}`, {}, {}, proxy)
+// 模型纳管状态修改
+export const pluginUpdateStatus = (params) =>
+  post(`/plugin/update-status`, params, {}, proxy)
+// 模型纳管删除
+export const pluginDel = (id) => del(`/plugin/${id}`, {}, {}, proxy)

+ 10 - 3
src/views/manage/model/detail.vue

@@ -169,9 +169,16 @@ const initDictionary = () => {
 }
 const initData = () => {
   state.loading = true
-  pluginDetail(props.transfer.id).then(({ data }: any) => {
-    state.form = data
-  })
+  pluginDetail(props.transfer.id)
+    .then(({ data }: any) => {
+      state.form = data
+    })
+    .catch(({ message }: any) => {
+      ElMessage.error(message)
+    })
+    .finally(() => {
+      state.loading = false
+    })
 }
 const onSubmit = () => {
   ref_form.value

+ 69 - 38
src/views/manage/model/index.vue

@@ -69,19 +69,19 @@
               />
               <div class="flex flex-1 flex-col justify-around overflow-hidden">
                 <div class="text-[1.25rem] font-bold text-[#2E3238]" v-title>
-                  {{ row.basicConfigs.model }}
+                  {{ row.name }}
                 </div>
                 <div class="flex">
                   <div
                     class="flex h-[1.25rem] items-center justify-center rounded-[0.13rem] bg-gradient-to-r from-[#FF9E2D] to-[#FFB92D] px-[0.38rem] text-[0.63rem] font-bold text-[#ffffff]"
                   >
-                    大预言模型
+                    {{ DictionaryStore.modelTypes.map.get(row.type) }}
                   </div>
                 </div>
               </div>
               <div class="mt-[0.25rem] ml-auto">
                 <div
-                  v-if="row.enable"
+                  v-if="row.status == 1"
                   class="flex h-[1.56rem] w-[3.75rem] items-center justify-center rounded-[1.25rem] bg-gradient-to-r from-[#D5F9FE] to-[#E0DAFF] text-[0.75rem] font-bold text-[#1E3F92]"
                 >
                   已启用
@@ -93,49 +93,52 @@
               style="line-height: 1.4rem"
               v-title="{ lines: 2 }"
             >
-              {{ row.p3 }}
+              {{ row.description }}
             </div>
             <div
               class="mt-[0.5rem] flex items-center gap-[var(--czr-gap)] text-[0.75rem] text-[#6F7889]"
             >
-              <div>(模型厂商)</div>
-              <div>|</div>
-              <div>上下文长度:{{ row.p5 }}</div>
+              <div>
+                {{ DictionaryStore.modelProvides.map.get(row.pluginClass) }}
+              </div>
               <div>|</div>
               <div>(创建单位)</div>
               <div>|</div>
               <div>(创建人)</div>
               <div>|</div>
-              <div>(更新时间)</div>
+              <div>{{ YMDHms(row.updateTime) }}</div>
             </div>
             <div
               class="mt-[0.5rem] flex items-center gap-[var(--czr-gap)] text-[0.75rem] text-[#6F7889]"
             >
-              <div>URL:74.10.28.118:8080</div>
-              <div class="ml-auto" @click.stop="onSwitch(row)">
+              <div class="ml-auto" @click.capture.stop="onSwitch(row)">
                 <a-switch
-                  v-model:checked="row.enable"
+                  v-model:checked="row.status"
                   checked-children="启用"
                   un-checked-children="停用"
+                  :checked-value="1"
+                  :un-checked-value="0"
                   size="small"
                 />
               </div>
-              <el-tooltip content="编辑" effect="light" placement="top">
-                <SvgIcon
-                  name="czr_edit"
-                  size="14"
-                  class="__hover"
-                  @click.stop="onEdit(row)"
-                />
-              </el-tooltip>
-              <el-tooltip content="删除" effect="light" placement="top">
-                <SvgIcon
-                  name="czr_del"
-                  size="16"
-                  class="__hover"
-                  @click.stop="onDel(row)"
-                />
-              </el-tooltip>
+              <template v-if="row.status == 0">
+                <el-tooltip content="编辑" effect="light" placement="top">
+                  <SvgIcon
+                    name="czr_edit"
+                    size="14"
+                    class="__hover"
+                    @click.stop="onEdit(row)"
+                  />
+                </el-tooltip>
+                <el-tooltip content="删除" effect="light" placement="top">
+                  <SvgIcon
+                    name="czr_del"
+                    size="16"
+                    class="__hover"
+                    @click.stop="onDel(row)"
+                  />
+                </el-tooltip>
+              </template>
             </div>
           </div>
         </template>
@@ -156,7 +159,12 @@ import { debounce } from 'lodash'
 import { useAppStore, useDialogStore, useDictionaryStore } from '@/stores'
 import { ElMessage } from 'element-plus'
 import detailCom from './detail.vue'
-import { pluginGetInstanceList } from '@/api/modules/model'
+import {
+  pluginDel,
+  pluginGetInstanceList,
+  pluginUpdateStatus,
+} from '@/api/modules/model'
+import { YMDHms } from '@/utils/czr-util'
 
 const AppStore = useAppStore()
 const DialogStore = useDialogStore()
@@ -264,27 +272,49 @@ const onDel = (row: any) => {
     title: '删除确认',
     content: `${row.p6}个应用正在使用该大模型,删除将导致不可用,请确认是否删除`,
     onSubmit: () => {
-      ElMessage.success('删除成功!')
-      onSearch()
+      pluginDel(row.id)
+        .then(() => {
+          ElMessage.success('删除成功!')
+        })
+        .catch(({ message }: any) => {
+          ElMessage.error(message)
+        })
+        .finally(() => {
+          onSearch()
+        })
     },
   })
 }
 const onSwitch = (row) => {
-  if (!row.enable) {
+  if (row.status == 1) {
     DialogStore.confirm({
       title: '停用确认',
       content: `${row.p6}个应用正在使用该大模型,停用将导致不可用,请确认是否停用`,
       onSubmit: () => {
-        ElMessage.success('停用成功!')
-        onSearch()
-      },
-      onCancel: () => {
-        row.enable = !row.enable
+        pluginUpdateStatus({ ids: [row.id], status: 0 })
+          .then(() => {
+            ElMessage.success('停用成功!')
+          })
+          .catch(({ message }: any) => {
+            ElMessage.error(message)
+          })
+          .finally(() => {
+            onSearch()
+          })
       },
+      onCancel: () => {},
     })
   } else {
-    ElMessage.success('启用成功!')
-    onSearch()
+    pluginUpdateStatus({ ids: [row.id], status: 1 })
+      .then(() => {
+        ElMessage.success('启用成功!')
+      })
+      .catch(({ message }: any) => {
+        ElMessage.error(message)
+      })
+      .finally(() => {
+        onSearch()
+      })
   }
 }
 onMounted(() => {
@@ -293,6 +323,7 @@ onMounted(() => {
 })
 const initDictionary = () => {
   DictionaryStore.initModelTypes()
+  DictionaryStore.initModelProvides()
 }
 </script>