Bläddra i källkod

feat: 添加子系统、算法类型

WANGKANG 9 månader sedan
förälder
incheckning
f50597d73f

+ 42 - 32
src/views/demo/AlgorithmConfigTrack/index.vue

@@ -62,6 +62,7 @@ import {
   exportAlgorithmConfigTrackApi,
   getAlgorithmConfigTrackApi
 } from '@/api/modules/demo/AlgorithmConfigTrack'
+import {enumsAlgorithmType, enumsSubSystem} from "@/views/demo/utils";
 
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
@@ -123,14 +124,16 @@ const openDialog = async (type: number, title: string, row?: any) => {
 const columns = reactive<ColumnProps<any>[]>([
   { type: 'selection', fixed: 'left', width: 70 },
   { prop: 'id', label: '主键ID' },
-  //   {
-  //     prop: 'type',
-  //     label: '类型',
-  //     search: {
-  //       el: 'input'
-  //     },
-  //     width: 120
-  //   },
+  {
+    prop: 'type',
+    label: '类型',
+    tag: true,
+    enum: enumsAlgorithmType,
+    search: {
+      el: 'select'
+    },
+    width: 120
+  },
   //   {
   //     prop: 'parentId',
   //     label: '父id',
@@ -139,14 +142,16 @@ const columns = reactive<ColumnProps<any>[]>([
   //     },
   //     width: 120
   //   },
-  //   {
-  //     prop: 'subsystem',
-  //     label: '分系统',
-  //     search: {
-  //       el: 'input'
-  //     },
-  //     width: 120
-  //   },
+  {
+    prop: 'subsystem',
+    label: '分系统',
+    tag: true,
+    enum: enumsSubSystem,
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
   {
     prop: 'algorithmName',
     label: '算法名称',
@@ -184,18 +189,21 @@ const columns = reactive<ColumnProps<any>[]>([
   //   },
   { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
 ])
+
 // 表单配置项
 let itemsOptions: ProForm.ItemsOptions[] = []
 const setItemsOptions = () => {
   itemsOptions = [
-    // {
-    //   label: '类型',
-    //   prop: 'type',
-    //   rules: [{ required: true, message: '类型不能为空', trigger: 'blur' }],
-    //   compOptions: {
-    //     placeholder: '请输入类型'
-    //   }
-    // },
+    {
+      label: '类型',
+      prop: 'type',
+      rules: [{ required: true, message: '算法类型不能为空', trigger: 'blur' }],
+      compOptions: {
+        elTagName: 'select',
+        enum: enumsAlgorithmType,
+        placeholder: '请选择算法类型'
+      }
+    },
     // {
     //   label: '父id',
     //   prop: 'parentId',
@@ -204,14 +212,16 @@ const setItemsOptions = () => {
     //     placeholder: '请输入父id'
     //   }
     // },
-    // {
-    //   label: '分系统',
-    //   prop: 'subsystem',
-    //   rules: [{ required: true, message: '分系统不能为空', trigger: 'blur' }],
-    //   compOptions: {
-    //     placeholder: '请输入分系统'
-    //   }
-    // },
+    {
+      label: '分系统',
+      prop: 'subsystem',
+      rules: [{ required: true, message: '分系统不能为空', trigger: 'blur' }],
+      compOptions: {
+        elTagName: 'select',
+        enum: enumsSubSystem,
+        placeholder: '请选择分系统'
+      }
+    },
     {
       label: '算法名称',
       prop: 'algorithmName',

+ 39 - 23
src/views/demo/AlgorithmModelTrack/index.vue

@@ -3,7 +3,8 @@
     <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listAlgorithmModelTrackApi">
       <!-- 表格 header 按钮 -->
       <template #tableHeader="scope">
-        <el-button type="primary" v-auth="['demo:AlgorithmModelTrack:add']" icon="CirclePlus" @click="openDialog(1, '算法模型配置新增')">
+        <el-button type="primary" v-auth="['demo:AlgorithmModelTrack:add']" icon="CirclePlus"
+                   @click="openDialog(1, '算法模型配置新增')">
           新增
         </el-button>
         <!-- <el-button type="primary" v-auth="['demo:AlgorithmModelTrack:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
@@ -21,7 +22,8 @@
       </template>
       <!-- 表格操作 -->
       <template #operation="scope">
-        <el-button type="primary" link icon="View" v-auth="['demo:AlgorithmModelTrack:query']" @click="openDialog(3, '算法模型配置查看', scope.row)">
+        <el-button type="primary" link icon="View" v-auth="['demo:AlgorithmModelTrack:query']"
+                   @click="openDialog(3, '算法模型配置查看', scope.row)">
           查看
         </el-button>
         <el-button
@@ -33,25 +35,26 @@
         >
           编辑
         </el-button>
-        <el-button type="primary" link icon="Delete" v-auth="['demo:AlgorithmModelTrack:remove']" @click="deleteAlgorithmModelTrack(scope.row)">
+        <el-button type="primary" link icon="Delete" v-auth="['demo:AlgorithmModelTrack:remove']"
+                   @click="deleteAlgorithmModelTrack(scope.row)">
           删除
         </el-button>
       </template>
     </ProTable>
-    <FormDialog ref="formDialogRef" />
-    <ImportExcel ref="dialogRef" />
+    <FormDialog ref="formDialogRef"/>
+    <ImportExcel ref="dialogRef"/>
   </div>
 </template>
 
 <script setup lang="tsx" name="AlgorithmModelTrack">
-import { ref, reactive, onMounted } from 'vue'
-import { useHandleData } from '@/hooks/useHandleData'
-import { useDownload } from '@/hooks/useDownload'
-import { ElMessageBox } from 'element-plus'
+import {ref, reactive, onMounted} from 'vue'
+import {useHandleData} from '@/hooks/useHandleData'
+import {useDownload} from '@/hooks/useDownload'
+import {ElMessageBox} from 'element-plus'
 import ProTable from '@/components/ProTable/index.vue'
 import ImportExcel from '@/components/ImportExcel/index.vue'
 import FormDialog from '@/components/FormDialog/index.vue'
-import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
+import {ProTableInstance, ColumnProps} from '@/components/ProTable/interface'
 import {
   listAlgorithmModelTrackApi,
   delAlgorithmModelTrackApi,
@@ -63,7 +66,8 @@ import {
   getAlgorithmModelTrackApi
 } from '@/api/modules/demo/AlgorithmModelTrack'
 
-import { enumAlgorithmConfigTrackApi } from '@/api/modules/demo/AlgorithmConfigTrack'
+import {enumAlgorithmConfigTrackApi} from '@/api/modules/demo/AlgorithmConfigTrack'
+import {AlgorithmType, SubSystem} from "@/views/demo/utils";
 
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
@@ -83,7 +87,7 @@ const batchDelete = async (ids: string[]) => {
 
 // 导出算法模型配置列表
 const downloadFile = async () => {
-  ElMessageBox.confirm('确认导出算法模型配置数据?', '温馨提示', { type: 'warning' }).then(() =>
+  ElMessageBox.confirm('确认导出算法模型配置数据?', '温馨提示', {type: 'warning'}).then(() =>
     useDownload(exportAlgorithmModelTrackApi, '算法模型配置列表', proTable.value?.searchParam)
   )
 }
@@ -103,7 +107,7 @@ const batchAdd = () => {
 const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
 // 打开弹框的功能
 const openDialog = async (type: number, title: string, row?: any) => {
-  let res = { data: {} }
+  let res = {data: {}}
   if (row?.id) {
     res = await getAlgorithmModelTrackApi(row?.id || null)
   }
@@ -123,8 +127,8 @@ const openDialog = async (type: number, title: string, row?: any) => {
 
 // 表格配置项
 const columns = reactive<ColumnProps<any>[]>([
-  { type: 'selection', fixed: 'left', width: 70 },
-  { prop: 'id', label: '主键ID' },
+  {type: 'selection', fixed: 'left', width: 70},
+  {prop: 'id', label: '主键ID'},
   {
     prop: 'algorithmType',
     label: '算法',
@@ -179,7 +183,7 @@ const columns = reactive<ColumnProps<any>[]>([
   //     },
   //     width: 120
   //   },
-  { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
+  {prop: 'operation', label: '操作', width: 230, fixed: 'right'}
 ])
 // 表单配置项
 let itemsOptions: ProForm.ItemsOptions[] = []
@@ -187,9 +191,21 @@ let itemsOptions: ProForm.ItemsOptions[] = []
 const enumsAlgorithmConfigTrack = ref<any>([])
 
 onMounted(async () => {
-  const result = await enumAlgorithmConfigTrackApi()
-  console.log(result)
-  console.log(result['data'])
+  const result: any = await enumAlgorithmConfigTrackApi()
+  // console.log(result)
+  // console.log(result['data'])
+  for (let item of result['data']) {
+    // console.log(item)
+    // console.log(item['type'])
+    // console.log(item['subsystem'])
+    // console.log(AlgorithmType[item['type']])
+    // console.log(SubSystem[item['subsystem']])
+    // console.log(AlgorithmType)
+    // console.log(SubSystem)
+    // console.log('-------------------')
+    item['label'] = item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']];
+  }
+
   enumsAlgorithmConfigTrack.value = result['data']
   return result['data']
 })
@@ -199,7 +215,7 @@ const setItemsOptions = () => {
     {
       label: '算法',
       prop: 'algorithmId_',
-      rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
+      rules: [{required: true, message: '算法不能为空', trigger: 'blur'}],
       compOptions: {
         elTagName: 'select',
         placeholder: '请输入算法',
@@ -209,7 +225,7 @@ const setItemsOptions = () => {
     {
       label: '模型名称',
       prop: 'modelName',
-      rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
+      rules: [{required: true, message: '模型名称不能为空', trigger: 'blur'}],
       compOptions: {
         placeholder: '请输入模型名称'
       }
@@ -217,7 +233,7 @@ const setItemsOptions = () => {
     {
       label: '模型',
       prop: 'modelInputOssId',
-      rules: [{ required: true, message: '模型文件不能为空', trigger: 'blur' }],
+      rules: [{required: true, message: '模型文件不能为空', trigger: 'blur'}],
       compOptions: {
         elTagName: 'file-upload',
         fileSize: 4096,
@@ -244,7 +260,7 @@ const setItemsOptions = () => {
     {
       label: '备注',
       prop: 'remarks',
-      rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
+      rules: [{required: false, message: '备注不能为空', trigger: 'blur'}],
       compOptions: {
         placeholder: '请输入备注'
       }

+ 33 - 0
src/views/demo/utils.ts

@@ -0,0 +1,33 @@
+/*
+ * @Datetime : 2024/9/28 15:51
+ * @Author   : WANGKANG
+ * @Email    : 1686617586@qq.com
+ * @Blog     :
+ * @File     : utils.vue
+ * @brief    : 组件工具包
+ * Copyright 2024 WANGKANG, All Rights Reserved.
+ */
+
+export const AlgorithmType = {
+  '0': '训练',
+  '1': '测试',
+  '2': '预测/推理'
+}
+
+export const SubSystem = {
+  '0': '可见光转红外',
+  '1': '目标检测',
+  '2': '注释轨迹序列'
+}
+
+export const enumsAlgorithmType = [
+  { label: '训练', value: '0' },
+  { label: '测试', value: '1' },
+  { label: '预测/推理', value: '2' }
+]
+
+export const enumsSubSystem = [
+  { label: '可见光转红外', value: '0' },
+  { label: '目标检测', value: '1' },
+  { label: '注释轨迹序列', value: '2' }
+]