Browse Source

feat: 修改数据选择、标签激活的问题、根据任务类型调整了代码、动态增加算法的bug

Rmengdi 11 months ago
parent
commit
11f2832a7b
1 changed files with 110 additions and 63 deletions
  1. 110 63
      src/views/taais/homePage/createTask.vue

+ 110 - 63
src/views/taais/homePage/createTask.vue

@@ -47,7 +47,7 @@
                     </ProTable>
                   </div>
                 </el-tab-pane>
-                <el-tab-pane label="数据二" name="two">
+                <el-tab-pane label="数据二" name="two" :disabled="tabTwo">
                   <div class="table-box">
                     <ProTable
                       ref="proTable"
@@ -61,7 +61,7 @@
                     </ProTable>
                   </div>
                 </el-tab-pane>
-                <el-tab-pane label="数据三" name="three">
+                <el-tab-pane label="数据三" name="three" :disabled="tabThree">
                   <div class="table-box">
                     <ProTable
                       ref="proTable"
@@ -75,7 +75,7 @@
                     </ProTable>
                   </div>
                 </el-tab-pane>
-                <el-tab-pane label="数据四" name="four">
+                <el-tab-pane label="数据四" name="four" :disabled="tabFour">
                   <div class="table-box">
                     <ProTable
                       ref="proTable"
@@ -91,19 +91,28 @@
                 </el-tab-pane>
               </el-tabs>
             </template>
-            <template #operation="{ formModel }">
+            <template #operation="{}">
               <div class="footBtn">
                 <el-button class="btn back" v-if="pageIndex === 1" @click="onReturn()"> 返回 </el-button>
                 <el-button class="btn back" v-else @click="onBack()"> 上一步 </el-button>
                 <el-button
                   class="btn add"
+                  type="primary"
+                  v-if="(pageIndex === 2 || pageIndex === 6 || pageIndex === 10) && model.taskType === '1'"
                   style="margin-left: -15px"
-                  v-if="pageIndex === 5 || pageIndex === 9 || pageIndex === 13"
+                  @click="addNewData()"
+                >
+                  增加新一组数据
+                </el-button>
+                <el-button
+                  class="btn add"
+                  style="margin-left: -15px"
+                  v-if="(pageIndex === 5 || pageIndex === 9 || pageIndex === 13) && model.taskType === '2'"
                   @click="onAdd(pageIndex)"
                 >
                   增加算法
                 </el-button>
-                <el-button class="btn next" type="success" @click="nextBtnText === '提交' ? onSubmit(formModel) : onNext()">
+                <el-button class="btn next" type="success" @click="nextBtnText === '提交' ? onSubmit() : onNext()">
                   {{ nextBtnText }}
                 </el-button>
               </div>
@@ -118,7 +127,7 @@
 import { ref, ComputedRef, computed, watch, reactive } from 'vue'
 import ProForm from '@/components/ProForm/index.vue'
 import { useRouter } from 'vue-router'
-import { getModelApi, getAlgorithmApi } from '@/api/modules/taais/task'
+import { getModelApi, getAlgorithmApi, createTaskApi } from '@/api/modules/taais/task'
 import ProTable from '@/components/ProTable/index.vue'
 import { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
 import { listDataApi } from '@/api/modules/demo/data'
@@ -127,6 +136,9 @@ import { getDictsApi } from '@/api/modules/system/dictData'
 import type { TabsPaneContext } from 'element-plus'
 // :request-api="getImageApi(1)" getImageApi,, Select, TabsPaneContext
 const activeName = ref('one')
+let tabTwo = ref(true)
+let tabThree = ref(true)
+let tabFour = ref(true)
 let initParam1 = reactive({ type: 1 })
 let initParam2 = reactive({ type: 2 })
 let initParam3 = reactive({ type: 3 })
@@ -189,20 +201,6 @@ const selectTaskTreeRef = ref<InstanceType<typeof ElTree>>()
 
 let title = ref('目标精准捕获任务选择')
 let nextBtnText = ref('下一步')
-// const enumData = [
-//   {
-//     label: 'rtdetr',
-//     value: '1'
-//   },
-//   {
-//     label: 'yolov5',
-//     value: '2'
-//   },
-//   {
-//     label: 'yolov8',
-//     value: '3'
-//   }
-// ]
 const data1 = [
   {
     id: 98,
@@ -393,7 +391,10 @@ let items = reactive<ProForm.ItemsOptions[]>([
     compOptions: {
       elTagName: 'input',
       clearable: true,
-      placeholder: '请输入任务名称'
+      placeholder: '请输入任务名称',
+      onChange: val => {
+        formItem.taskName = val
+      }
     }
   },
   {
@@ -889,9 +890,11 @@ const onAdd = pageNum => {
   if (!formEl) return
   formEl.validate(valid => {
     if (valid) {
+      if (agloIndex >= 4) {
+        ElMessage.warning('最多选择四种算法,已选择了四种')
+        return
+      }
       getAlgorithmApi(type, subSystem).then(res1 => {
-        console.log('agloIndex', agloIndex)
-
         formItems.value[0].items.push({
           label: '选择训练算法',
           prop: `${arrayName}Aglo${agloIndex}`,
@@ -907,42 +910,50 @@ const onAdd = pageNum => {
             enum: res1.data,
             onChange: agloId => {
               formItem[`${arrayName}`].push({})
-              console.log(`formItem[${arrayName}][${agloIndex}]['algorithmId']`)
-              formItem[`${arrayName}`][`${agloIndex}`]['algorithmId'] = agloId
-              getModelApi(agloId).then(res2 => {
-                formItems.value[0].items.push({
-                  label: '选择训练模型',
-                  prop: `${arrayName}Model${agloIndex}`,
-                  span: 14,
-                  rules: [{ required: true, message: '请选择训练模型' }],
-                  show: () => {
-                    return pageIndex.value === pageNum ? true : false
-                  },
-                  compOptions: {
-                    elTagName: 'select',
-                    labelKey: 'modelName',
-                    valueKey: 'id',
-                    enum: res2.data,
-                    onChange: modelId => {
-                      console.log(res1.data, agloId)
-
-                      res1.data.forEach(agloItem => {
-                        if (agloItem.id === agloId) {
-                          const params = eval('(' + agloItem.parameterConfig + ')')
-                          params.forEach(config => {
-                            if (config.validate == '/d') {
-                              config.validate = '\\d'
-                            }
-                          })
-                          formItem[`${arrayName}`][`${agloIndex}`]['modelId'] = modelId
-                          formItem[`${arrayName}`][`${agloIndex}`]['params'] = {}
-                          addForm(params, pageNum, `${arrayName}[${agloIndex}]`, agloIndex)
-                        }
-                      })
+              if (!formItem[`${arrayName}`][`${agloIndex}`]['algorithmId']) {
+                formItem[`${arrayName}`][`${agloIndex}`]['algorithmId'] = agloId
+                getModelApi(agloId).then(res2 => {
+                  formItems.value[0].items.push({
+                    label: '选择训练模型',
+                    prop: `${arrayName}Model${agloIndex}`,
+                    span: 14,
+                    rules: [{ required: true, message: '请选择训练模型' }],
+                    show: () => {
+                      return pageIndex.value === pageNum ? true : false
+                    },
+                    compOptions: {
+                      elTagName: 'select',
+                      labelKey: 'modelName',
+                      valueKey: 'id',
+                      enum: res2.data,
+                      onChange: modelId => {
+                        res1.data.forEach(agloItem => {
+                          if (agloItem.id === agloId) {
+                            const params = eval('(' + agloItem.parameterConfig + ')')
+                            params.forEach(config => {
+                              if (config.validate == '/d') {
+                                config.validate = '\\d'
+                              }
+                            })
+                            formItem[`${arrayName}`][`${agloIndex}`]['modelId'] = modelId
+                            formItem[`${arrayName}`][`${agloIndex}`]['params'] = {}
+                            addForm(params, pageNum, `${arrayName}[${agloIndex}]`, agloIndex)
+                          }
+                        })
+                      }
                     }
-                  }
+                  })
                 })
-              })
+              } else {
+                formItem[`${arrayName}`].splice(-1, 1)
+                formItem[`${arrayName}`][`${agloIndex}`]['algorithmId'] = agloId
+                const column = formItems.value[0].items.find(column => column.prop === `${arrayName}Model${agloIndex}`)
+                if (column) {
+                  getModelApi(agloId).then(newRes => {
+                    column.compOptions.enum = newRes.data
+                  })
+                }
+              }
             }
           }
         })
@@ -953,6 +964,40 @@ const onAdd = pageNum => {
     }
   })
 }
+// 增加新数据
+const addNewData = () => {
+  switch (activeName.value) {
+    case 'one':
+      const table0Ref = proTable.value![0]
+      if (Object.keys(table0Ref.searchParam).length !== 0 && table0Ref.tableData.length !== 0) {
+        tabTwo.value = false
+        activeName.value = 'two'
+      } else {
+        ElMessage.warning('请正确选择该组数据')
+      }
+      break
+    case 'two':
+      const table1Ref = proTable.value![1]
+      if (Object.keys(table1Ref.searchParam).length !== 0 && table1Ref.tableData.length !== 0) {
+        tabThree.value = false
+        activeName.value = 'three'
+      } else {
+        ElMessage.warning('请正确选择该组数据')
+      }
+      break
+    case 'three':
+      const table2Ref = proTable.value![2]
+      if (Object.keys(table2Ref.searchParam).length !== 0 && table2Ref.tableData.length !== 0) {
+        tabFour.value = false
+        activeName.value = 'four'
+      } else {
+        ElMessage.warning('请正确选择该组数据')
+      }
+      break
+    default:
+      break
+  }
+}
 // 增加表单事件
 const addForm = (params, index, arrayName, paramsIndex) => {
   params.forEach(item => {
@@ -1048,7 +1093,7 @@ const onNext = () => {
             })
           }
         }
-        console.log('formItem.trainDataSelect', formItem.trainDataSelect)
+        activeName.value = 'one'
       }
       if (pageIndex.value === formItem.selectTask[formItem.selectTask.length - 2]) {
         nextBtnText.value = '提交'
@@ -1120,11 +1165,13 @@ const changeTree = (newVal, allVal) => {
 const delNumber = (start, end, dataList) => {
   return dataList.filter(number => !(number >= start && number <= end)).sort((a, b) => a - b)
 }
-const onSubmit = val => {
-  const data = Object.assign(val, formItem)
+const onSubmit = () => {
+  // const data = Object.assign(val, formItem)
   console.log('formItem', formItem)
-
-  console.log('ssssss', data)
+  // console.log('ssssss', val)
+  createTaskApi(formItem).then(res => {
+    console.log('createTask', res)
+  })
 }
 const beforeTabLeave = (activeName, oldActiveName) => {
   let dataSelect1