Browse Source

fix: 1. 可见光转红外新增、更新完成 2. 修正若干逻辑 3. 删掉无用方法

WANGKANG 3 months ago
parent
commit
cf96a0a712
1 changed files with 132 additions and 102 deletions
  1. 132 102
      src/views/demo/toInfrared/index.vue

+ 132 - 102
src/views/demo/toInfrared/index.vue

@@ -24,10 +24,11 @@
       </template>
       <!-- 表格操作 -->
       <template #operation="scope">
-        <el-button type="primary" link icon="View" v-if="scope.row.algorithmModelId != null" @click="openModelDialog(scope.row)">
+        <el-button type="primary" link icon="View" v-if="scope.row.algorithmModelId != null" @click="openDialog_detail(scope.row, false)">
           <!--@click="openStartDialog(scope.row)"  -->
           详情
         </el-button>
+        <el-button type="primary" link icon="EditPen" v-auth="['demo:toInfrared:edit']" @click="openDialog_detail(scope.row, true)"> 编辑 </el-button>
         <el-button
           type="primary"
           link
@@ -94,8 +95,6 @@
         >
           日志
         </el-button>
-        <!-- <el-button type="primary" link icon="View" v-auth="['demo:toInfrared:query']" @click="openDialog(3, '查看', scope.row)"> 查看 </el-button> -->
-        <!-- <el-button type="primary" link icon="EditPen"v-auth="['demo:toInfrared:edit']" @click="openDialog(2, '编辑', scope.row)"> 编辑 </el-button> -->
         <el-button
           type="primary"
           link
@@ -184,6 +183,133 @@ import ViewLog from '@/views/demo/components/ViewLog.vue'
 import useWebSocketStore from '@/stores/modules/websocket'
 import { resetHeart } from '@/utils/websocket'
 
+const openDialog_detail = async (row: any, edit: boolean = false) => {
+  let res = {}
+  if (row?.id) {
+    res = await getToInfraredApi(row.id || null)
+    const params = JSON.parse(res.data['algorithmParameters'])
+    if (params.otherParams) {
+      res.data = { ...res.data, ...params.otherParams }
+    }
+  }
+  // 重置表单
+  setItemsOptions_edit()
+  const itemsOptions = await updateItemsOptions(row.algorithmId)
+  const params = {
+    title: '编辑',
+    width: 600,
+    isEdit: edit,
+    itemsOptions: itemsOptions,
+    model: res.data,
+    api: updateToInfraredApi,
+    getTableList: proTable.value?.getTableList
+  }
+  formDialogRef.value?.openDialog(params)
+}
+
+const setItemsOptions_edit = () => {
+  itemsOptions = [
+    {
+      label: '任务名称',
+      prop: 'name',
+      rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
+      compOptions: {
+        elTagName: 'input',
+        placeholder: '请输入任务名称'
+      }
+    },
+    {
+      label: '选择数据集',
+      prop: 'inputOssId',
+      rules: [{ required: false, message: '数据集不能为空', trigger: 'blur' }],
+      compOptions: {
+        elTagName: 'select',
+        placeholder: '请选择或者上传数据集',
+        enum: getImageDataList,
+        clearable: true
+      }
+    },
+    {
+      label: '上传数据集',
+      prop: 'inputOssId',
+      rules: [{ required: false, message: '数据集不能为空', trigger: 'blur' }],
+      compOptions: {
+        elTagName: 'file-upload',
+        fileSize: 4096,
+        fileType: ['zip'],
+        placeholder: '请上传数据集'
+      }
+    },
+    {
+      label: '选择算法',
+      prop: 'algorithmId',
+      rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
+      compOptions: {
+        disabled: true,
+        elTagName: 'select',
+        placeholder: '请选择算法',
+        enum: enumsAlgorithmConfigTrack,
+        clearable: true,
+        onChange: async (value: any) => {
+          if (value != undefined && value != null && value != '') {
+            await updateItemsOptions(value)
+          }
+        }
+      }
+    },
+    {
+      label: '任务类型',
+      prop: 'type',
+      rules: [{ required: true, message: '任务类型不能为空', trigger: 'blur' }],
+      compOptions: {
+        disabled: true,
+        elTagName: 'select',
+        placeholder: '请选择模任务类型',
+        enum: enumsAlgorithmType,
+        clearable: true,
+        value: ''
+      },
+      show: params => {
+        if (params.value.algorithmId != undefined) {
+          for (let i = 0; i < enumsAlgorithmConfigTrack.value.length; i++) {
+            if (enumsAlgorithmConfigTrack.value[i]['value'] === params.value.algorithmId) {
+              params.value.type = enumsAlgorithmConfigTrack.value[i]['type']
+              return true
+            }
+          }
+        }
+        return false
+      }
+    },
+    {
+      label: '选择模型',
+      prop: 'algorithmModelId',
+      rules: [{ required: true, message: '模型不能为空', trigger: 'blur' }],
+      show: params => {
+        if (params.value.type == AlgorithmType2['预测/推理']) {
+          return true
+        }
+        return false
+      },
+      compOptions: {
+        elTagName: 'select',
+        placeholder: '请选择模型',
+        enum: enumsAlgorithmModelTrack,
+        clearable: true
+      }
+    },
+    {
+      label: '备注',
+      prop: 'remarks',
+      rules: [],
+      compOptions: {
+        elTagName: 'input',
+        placeholder: '请输入备注'
+      }
+    }
+  ]
+}
+
 import ShowStatisticResult from '@/views/demo/components/ShowStatisticResult.vue'
 
 const showStatisticResultRef = ref()
@@ -335,24 +461,6 @@ const showToInfraredModel = async (id: any) => {
 
 const viewLogRef = ref()
 
-const openModelDialog = async row => {
-  const algorithmModelId = row.algorithmModelId
-  const result: any = await getAlgorithmModelTrackApi(algorithmModelId)
-
-  // console.log(result.data)
-  setItemsOptionsModel()
-  const params = {
-    title: '模型',
-    width: 580,
-    isEdit: false,
-    itemsOptions: itemsOptions,
-    model: result.data,
-    api: updateToInfraredApi,
-    getTableList: proTable.value?.getTableList
-  }
-  formDialogRef.value?.openDialog(params)
-}
-
 const startToInfrared = async (params: any) => {
   const res: any = await startToInfraredApi(params.id)
   if (res.code === 200) {
@@ -556,9 +664,9 @@ const columns = reactive<ColumnProps<any>[]>([
 
 const remove_unnecessary_parameters = (itemsOptions: ProForm.ItemsOptions[]): ProForm.ItemsOptions[] => {
   try {
-    const endIndex = itemsOptions.findIndex(option => option['label'] === 'end')
+    const endIndex = itemsOptions.findIndex(option => option['label'] === '备注')
     if (endIndex !== -1) {
-      itemsOptions = itemsOptions.slice(0, endIndex)
+      itemsOptions = itemsOptions.slice(0, endIndex + 1)
     }
     return itemsOptions
   } catch (error) {
@@ -592,6 +700,7 @@ const updateItemsOptions = async (algorithmId: any) => {
         })
       }
       formDialogRef.value?.updateItemOptions(itemsOptions_new)
+      return itemsOptions_new
     }
   } catch (err) {
     console.log(err)
@@ -698,14 +807,6 @@ const setItemsOptions = () => {
         elTagName: 'input',
         placeholder: '请输入备注'
       }
-    },
-    {
-      label: 'end',
-      prop: '----',
-      show: false,
-      compOptions: {
-        elTagName: 'input'
-      }
     }
   ]
 }
@@ -792,75 +893,4 @@ const setItemsOptions2 = () => {
     }
   ]
 }
-
-const setItemsOptionsModel = () => {
-  itemsOptions = [
-    {
-      label: '算法ID',
-      prop: 'algorithmId',
-      rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
-      compOptions: {
-        elTagName: 'input',
-        disabled: true,
-        placeholder: '请输入算法'
-      }
-    },
-    {
-      label: '算法类型',
-      prop: 'algorithmType',
-      rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
-      compOptions: {
-        disabled: true,
-        elTagName: 'select',
-        placeholder: '请输入算法',
-        enum: enumsAlgorithmConfigTrack
-      }
-    },
-    {
-      label: '算法参数',
-      prop: 'parameterConfig',
-      rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
-      compOptions: {
-        elTagName: 'input',
-        placeholder: '请输入模型名称'
-      }
-    },
-    {
-      label: '模型ID',
-      prop: 'id',
-      rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
-      compOptions: {
-        elTagName: 'input',
-        placeholder: '请输入模型名称'
-      }
-    },
-    {
-      label: '模型名称',
-      prop: 'modelName',
-      rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
-      compOptions: {
-        elTagName: 'input',
-        placeholder: '请输入模型名称'
-      }
-    },
-    {
-      label: '模型保存路径',
-      prop: 'modelAddress',
-      rules: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
-      compOptions: {
-        elTagName: 'input',
-        placeholder: '请输入模型名称'
-      }
-    },
-    {
-      label: '备注',
-      prop: 'remarks',
-      rules: [{ required: false, message: '备注不能为空', trigger: 'blur' }],
-      compOptions: {
-        elTagName: 'input',
-        placeholder: '请输入备注'
-      }
-    }
-  ]
-}
 </script>