Просмотр исходного кода

Merge branch 'dev-rmd' into develop_Allen

allen 11 месяцев назад
Родитель
Сommit
0b3a23d56d
1 измененных файлов с 128 добавлено и 112 удалено
  1. 128 112
      src/views/taais/homePage/createTask.vue

+ 128 - 112
src/views/taais/homePage/createTask.vue

@@ -145,48 +145,46 @@ let initParam3 = reactive({ type: 3 })
 let initParam4 = reactive({ type: 4 })
 const proTable = ref<ProTableInstance>()
 let model = ref({
-  taskType: '1',
-  enhanceModel: '',
-  pretreatmentModel: ''
+  taskType: '1'
 })
 
 let formItem = reactive({
   taskName: '',
-  selectTask: [2, 5],
+  selectTask: [2, 5] as any,
   trainDataSelect: [] as any[],
   trainDataEnhancement: {
     algorithmId: null,
     modelId: null,
-    params: {}
+    params: []
   },
   trainDataExpansion: {
     algorithmId: null,
     modelId: null,
-    params: {}
+    params: []
   },
   train: [{}],
   testDataSelect: [] as any[],
   testDataEnhancement: {
     algorithmId: null,
     modelId: null,
-    params: {}
+    params: []
   },
   testDataExpansion: {
     algorithmId: null,
     modelId: null,
-    params: {}
+    params: []
   },
   test: [{}],
   reasoningDataSelect: [] as any[],
   reasoningDataEnhancement: {
     algorithmId: null,
     modelId: null,
-    params: {}
+    params: []
   },
   reasoningDataExpansion: {
     algorithmId: null,
     modelId: null,
-    params: {}
+    params: []
   },
   reasoning: [{}]
 })
@@ -214,12 +212,7 @@ const data1 = [
       },
       {
         id: 3,
-        label: '训练数据增强',
-        children: []
-      },
-      {
-        id: 4,
-        label: '训练数据扩充',
+        label: '训练数据增广',
         children: []
       },
       {
@@ -231,54 +224,34 @@ const data1 = [
   },
   {
     id: 99,
-    label: '测试',
+    label: '验证',
     disabled: true,
     children: [
       {
         id: 6,
-        label: '测试数据选择',
-        children: []
-      },
-      {
-        id: 7,
-        label: '测试数据增强',
-        children: []
-      },
-      {
-        id: 8,
-        label: '测试数据扩充',
+        label: '验证数据选择',
         children: []
       },
       {
         id: 9,
-        label: '测试',
+        label: '验证',
         children: []
       }
     ]
   },
   {
     id: 100,
-    label: '推理',
+    label: '测试',
     disabled: true,
     children: [
       {
         id: 10,
-        label: '推理数据选择',
-        children: []
-      },
-      {
-        id: 11,
-        label: '推理数据增强',
-        children: []
-      },
-      {
-        id: 12,
-        label: '推理数据扩充',
+        label: '测试数据选择',
         children: []
       },
       {
         id: 13,
-        label: '推理',
+        label: '测试',
         children: []
       }
     ]
@@ -286,11 +259,11 @@ const data1 = [
 ]
 const taskTypeData = [
   {
-    label: '多数据单任务',
+    label: '多数据单算法',
     value: '1'
   },
   {
-    label: '单数据多任务',
+    label: '单数据多算法',
     value: '2'
   }
 ]
@@ -451,10 +424,10 @@ let items = reactive<ProForm.ItemsOptions[]>([
   },
   // 3
   {
-    label: '选择增算法',
+    label: '选择增广算法',
     prop: 'trainEnhanceAlgo',
     span: 14,
-    rules: [{ required: true, message: '选择增算法' }],
+    rules: [{ required: true, message: '选择增广算法' }],
     show: () => {
       return pageIndex.value === 3 ? true : false
     },
@@ -470,10 +443,10 @@ let items = reactive<ProForm.ItemsOptions[]>([
     }
   },
   {
-    label: '选择增模型',
+    label: '选择增广模型',
     prop: 'trainEnhanceModel',
     span: 14,
-    rules: [{ required: true, message: '选择增模型' }],
+    rules: [{ required: true, message: '选择增广模型' }],
     show: () => {
       return pageIndex.value === 3 ? true : false
     },
@@ -483,7 +456,7 @@ let items = reactive<ProForm.ItemsOptions[]>([
       valueKey: 'id',
       enum: null,
       onChange: val => {
-        getAgloParams(4, 'trainDataEnhancement', 3, val, 0)
+        getAgloParams(4, 'trainDataEnhancement', 3, val)
       }
     }
   },
@@ -521,7 +494,7 @@ let items = reactive<ProForm.ItemsOptions[]>([
       valueKey: 'id',
       enum: null,
       onChange: val => {
-        getAgloParams(5, 'trainDataExpansion', 4, val, 0)
+        getAgloParams(5, 'trainDataExpansion', 4, val)
       }
     }
   },
@@ -565,15 +538,10 @@ let items = reactive<ProForm.ItemsOptions[]>([
           res.data.forEach(item => {
             if (item.id === selectTrainAgloId) {
               const params = eval('(' + item.parameterConfig + ')')
-              params.forEach(config => {
-                if (config.validate == '/d') {
-                  config.validate = '\\d'
-                }
-              })
               formItem.train[0]['modelId'] = val
-              formItem.train[0]['params'] = {}
+              formItem.train[0]['params'] = params
               // (参数信息,第几页,数组名称)
-              addForm(params, 5, 'train[0]', 0)
+              addForm(params, 5, 'train[0]')
             }
           })
         })
@@ -614,7 +582,11 @@ let items = reactive<ProForm.ItemsOptions[]>([
       valueKey: 'id',
       enum: null,
       onChange: val => {
-        getAgloParams(4, 'testDataEnhancement', 7, val, 0)
+        if (val === 1) {
+          return
+        } else {
+          getAgloParams(4, 'testDataEnhancement', 7, val)
+        }
       }
     }
   },
@@ -652,16 +624,20 @@ let items = reactive<ProForm.ItemsOptions[]>([
       valueKey: 'id',
       enum: null,
       onChange: val => {
-        getAgloParams(5, 'testDataExpansion', 8, val, 0)
+        if (val === 1) {
+          return
+        } else {
+          getAgloParams(5, 'testDataExpansion', 8, val)
+        }
       }
     }
   },
   // 9
   {
-    label: '选择测试算法',
+    label: '选择验证算法',
     prop: 'testAlgo',
     span: 14,
-    rules: [{ required: true, message: '请选择测试算法' }],
+    rules: [{ required: true, message: '请选择验证算法' }],
     show: () => {
       return pageIndex.value === 9 ? true : false
     },
@@ -678,10 +654,10 @@ let items = reactive<ProForm.ItemsOptions[]>([
     }
   },
   {
-    label: '选择测试模型',
+    label: '选择验证模型',
     prop: 'testModel',
     span: 14,
-    rules: [{ required: true, message: '请选择测试模型' }],
+    rules: [{ required: true, message: '请选择验证模型' }],
     show: () => {
       return pageIndex.value === 9 ? true : false
     },
@@ -696,15 +672,10 @@ let items = reactive<ProForm.ItemsOptions[]>([
           res.data.forEach(item => {
             if (item.id === selectTestAgloId) {
               const params = eval('(' + item.parameterConfig + ')')
-              params.forEach(config => {
-                if (config.validate == '/d') {
-                  config.validate = '\\d'
-                }
-              })
               formItem.test[0]['modelId'] = val
-              formItem.test[0]['params'] = {}
+              formItem.test[0]['params'] = params
               // (参数信息,第几页,数组名称)
-              addForm(params, 9, 'test[0]', 0)
+              addForm(params, 9, 'test[0]')
             }
           })
         })
@@ -745,7 +716,11 @@ let items = reactive<ProForm.ItemsOptions[]>([
       valueKey: 'id',
       enum: null,
       onChange: val => {
-        getAgloParams(4, 'reasoningDataEnhancement', 11, val, 0)
+        if (val === 1) {
+          return
+        } else {
+          getAgloParams(4, 'reasoningDataEnhancement', 11, val)
+        }
       }
     }
   },
@@ -783,16 +758,20 @@ let items = reactive<ProForm.ItemsOptions[]>([
       valueKey: 'id',
       enum: null,
       onChange: val => {
-        getAgloParams(5, 'reasoningDataExpansion', 12, val, 0)
+        if (val === 1) {
+          return
+        } else {
+          getAgloParams(5, 'reasoningDataExpansion', 12, val)
+        }
       }
     }
   },
   // 13
   {
-    label: '选择推理算法',
+    label: '选择测试算法',
     prop: 'reasoningAlgo',
     span: 14,
-    rules: [{ required: true, message: '请选择推理算法' }],
+    rules: [{ required: true, message: '请选择测试算法' }],
     show: () => {
       return pageIndex.value === 13 ? true : false
     },
@@ -809,10 +788,10 @@ let items = reactive<ProForm.ItemsOptions[]>([
     }
   },
   {
-    label: '选择推理模型',
+    label: '选择测试模型',
     prop: 'reasoningModel',
     span: 14,
-    rules: [{ required: true, message: '请选择推理模型' }],
+    rules: [{ required: true, message: '请选择测试模型' }],
     show: () => {
       return pageIndex.value === 13 ? true : false
     },
@@ -826,15 +805,10 @@ let items = reactive<ProForm.ItemsOptions[]>([
           res.data.forEach(item => {
             if (item.id === selectReasoningAgloId) {
               const params = eval('(' + item.parameterConfig + ')')
-              params.forEach(config => {
-                if (config.validate == '/d') {
-                  config.validate = '\\d'
-                }
-              })
               formItem.reasoning[0]['modelId'] = val
-              formItem.reasoning[0]['params'] = {}
+              formItem.reasoning[0]['params'] = params
               // (参数信息,第几页,数组名称)
-              addForm(params, 13, 'reasoning[0]', 0)
+              addForm(params, 13, 'reasoning[0]')
             }
           })
         })
@@ -930,14 +904,9 @@ const onAdd = pageNum => {
                         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)
+                            formItem[`${arrayName}`][`${agloIndex}`]['params'] = params
+                            addForm(params, pageNum, `${arrayName}[${agloIndex}]`)
                           }
                         })
                       }
@@ -999,13 +968,17 @@ const addNewData = () => {
   }
 }
 // 增加表单事件
-const addForm = (params, index, arrayName, paramsIndex) => {
+const addForm = (params, index, arrayName) => {
   params.forEach(item => {
+    let i = formItems.value[0].items.length
     formItems.value[0].items.push({
       label: item.name,
-      prop: `${arrayName}${item.name}${paramsIndex}`,
+      prop: `task${i}`,
       span: 12,
-      rules: [{ required: item.required, pattern: item.validate }],
+      rules: [
+        { required: item.required, message: `${item.name}不能为空` },
+        { pattern: new RegExp(`${item.validate}`), message: item.prompt }
+      ],
       show: () => {
         return pageIndex.value === index ? true : false
       },
@@ -1019,21 +992,34 @@ const addForm = (params, index, arrayName, paramsIndex) => {
             // 截取数组和下标
             let array = arrayName.slice(0, -3)
             let index = arrayName.slice(-2, -1)
-            console.log(`formItem[${array}][${index}]['params'][${label}]`)
-            formItem[`${array}`][`${index}`]['params'][`${label}`] = val1
+            const item = formItem[`${array}`][`${index}`]['params'].find(item => item.name === label)
+            if (item) {
+              item.value = val1
+            }
           } else {
-            formItem[`${arrayName}`]['params'][`${label}`] = val1
+            const item1 = formItem[`${arrayName}`]['params'].find(item => item.name === label)
+            if (item1) {
+              item1.value = val1
+            }
           }
         }
       }
     })
+    formItems.value[0].model[`task${i}`] = item.defaultValue
   })
+  console.log('formItems', formItems)
 }
 const agloChange = (propName, agloId) => {
   const Column = formItems.value[0].items.find(column => column.prop === propName)
   if (Column) {
     getModelApi(agloId).then(res => {
       Column.compOptions.enum = res.data as any[]
+      // Column.compOptions.enum.unshift({
+      //   algorithmId: null,
+      //   id: 1,
+      //   modelAddress: null,
+      //   modelName: '基于训练生成的模型'
+      // })
     })
   }
 }
@@ -1046,20 +1032,16 @@ const getAlgo = (propName, type) => {
   }
 }
 // 算法类型:1-5、算法类型名称:如训练数据增强、页码、模型Id、模型的参数下标
-const getAgloParams = (agloType, agloTypeName, page, modelId, paramIndex) => {
+const getAgloParams = (agloType, agloTypeName, page, modelId) => {
   const algoId = formItem[agloTypeName].algorithmId
   getAlgorithmApi(agloType, subSystem).then(res => {
     res.data.forEach(item => {
       if (item.id === algoId) {
         const params = eval('(' + item.parameterConfig + ')')
-        params.forEach(config => {
-          if (config.validate == '/d') {
-            config.validate = '\\d'
-          }
-        })
         formItem[agloTypeName].modelId = modelId
+        formItem[agloTypeName].params = params
         // (参数信息,第几页,数组名称)
-        addForm(params, page, agloTypeName, paramIndex)
+        addForm(params, page, agloTypeName)
       }
     })
   })
@@ -1086,7 +1068,7 @@ const onNext = () => {
         else if (pageIndex.value === 10) dataName = 'reasoningDataSelect'
         formItem[dataName] = []
         for (let i = 0; i <= 3; i++) {
-          if (Object.keys(proTable.value![i].searchParam).length !== 0) {
+          if (Object.values(proTable.value![i].searchParam).some(v => v !== '')) {
             formItem[dataName].push({
               conditionSelected: true,
               condition: proTable.value![i].searchParam
@@ -1166,13 +1148,47 @@ const delNumber = (start, end, dataList) => {
   return dataList.filter(number => !(number >= start && number <= end)).sort((a, b) => a - b)
 }
 const onSubmit = () => {
-  // const data = Object.assign(val, formItem)
-  console.log('formItem', formItem)
-  // console.log('ssssss', val)
+  findParams(formItem)
+  console.log('111', formItem)
   createTaskApi(formItem).then(res => {
     console.log('createTask', res)
   })
 }
+const findParams = obj => {
+  for (const key in obj) {
+    if (obj[key] !== null && typeof obj[key] === 'object') {
+      // 如果值是数组,则遍历数组中的每个元素
+      if (Array.isArray(obj[key])) {
+        obj[key].forEach(item => {
+          if (item.params) {
+            item.params.forEach(paramItem => {
+              if (!paramItem.value) {
+                paramItem.value = paramItem.defaultValue
+              }
+            })
+            item.params = JSON.stringify(item.params)
+          }
+          if (item.condition) {
+            item.condition = JSON.stringify(item.condition)
+          }
+        })
+      } else {
+        // 如果值是对象
+        if (obj[key]['params']) {
+          obj[key]['params'].forEach(paramItem => {
+            if (!paramItem.value) {
+              paramItem.value = paramItem.defaultValue
+            }
+          })
+          obj[key]['params'] = JSON.stringify(obj[key]['params'])
+        }
+        if (obj[key]['condition']) {
+          obj[key]['condition'] = JSON.stringify(obj[key]['condition'])
+        }
+      }
+    }
+  }
+}
 const beforeTabLeave = (activeName, oldActiveName) => {
   let dataSelect1
   if (pageIndex.value === 2) {
@@ -1263,7 +1279,7 @@ watch(
         }
         break
       case 3:
-        title.value = '训练数据增'
+        title.value = '训练数据增广'
         getAlgo('trainEnhanceAlgo', 4)
         break
       case 4:
@@ -1275,7 +1291,7 @@ watch(
         getAlgo('trainAlgo', 1)
         break
       case 6:
-        title.value = '测试数据选择'
+        title.value = '验证数据选择'
         if (testActiveTab.value) {
           handleClick(testActiveTab.value)
         }
@@ -1289,11 +1305,11 @@ watch(
         getAlgo('testExpansionAlgo', 5)
         break
       case 9:
-        title.value = '测试算法选择'
+        title.value = '验证算法选择'
         getAlgo('testAlgo', 2)
         break
       case 10:
-        title.value = '推理数据选择'
+        title.value = '测试数据选择'
         if (reasoningActiveTab.value) {
           handleClick(reasoningActiveTab.value)
         }
@@ -1308,7 +1324,7 @@ watch(
         nextBtnText.value = '下一步'
         break
       case 13:
-        title.value = '推理算法选择'
+        title.value = '测试算法选择'
         getAlgo('reasoningAlgo', 3)
         break
       default: