Explorar el Código

feat: 新要求的更改、修复表单验证bug、提交数据转化为字符串

Rmengdi hace 11 meses
padre
commit
5890d124ee
Se han modificado 1 ficheros con 66 adiciones y 99 borrados
  1. 66 99
      src/views/taais/homePage/createTask.vue

+ 66 - 99
src/views/taais/homePage/createTask.vue

@@ -145,14 +145,12 @@ 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,
@@ -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'] = params
               // (参数信息,第几页,数组名称)
-              addForm(params, 5, 'train[0]', 0)
+              addForm(params, 5, 'train[0]')
             }
           })
         })
@@ -617,7 +585,7 @@ let items = reactive<ProForm.ItemsOptions[]>([
         if (val === 1) {
           return
         } else {
-          getAgloParams(4, 'testDataEnhancement', 7, val, 0)
+          getAgloParams(4, 'testDataEnhancement', 7, val)
         }
       }
     }
@@ -659,17 +627,17 @@ let items = reactive<ProForm.ItemsOptions[]>([
         if (val === 1) {
           return
         } else {
-          getAgloParams(5, 'testDataExpansion', 8, val, 0)
+          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
     },
@@ -686,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
     },
@@ -704,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'] = params
               // (参数信息,第几页,数组名称)
-              addForm(params, 9, 'test[0]', 0)
+              addForm(params, 9, 'test[0]')
             }
           })
         })
@@ -756,7 +719,7 @@ let items = reactive<ProForm.ItemsOptions[]>([
         if (val === 1) {
           return
         } else {
-          getAgloParams(4, 'reasoningDataEnhancement', 11, val, 0)
+          getAgloParams(4, 'reasoningDataEnhancement', 11, val)
         }
       }
     }
@@ -798,17 +761,17 @@ let items = reactive<ProForm.ItemsOptions[]>([
         if (val === 1) {
           return
         } else {
-          getAgloParams(5, 'reasoningDataExpansion', 12, val, 0)
+          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
     },
@@ -825,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
     },
@@ -842,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'] = params
               // (参数信息,第几页,数组名称)
-              addForm(params, 13, 'reasoning[0]', 0)
+              addForm(params, 13, 'reasoning[0]')
             }
           })
         })
@@ -946,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'] = params
-                            addForm(params, pageNum, `${arrayName}[${agloIndex}]`, agloIndex)
+                            addForm(params, pageNum, `${arrayName}[${agloIndex}]`)
                           }
                         })
                       }
@@ -1015,14 +968,17 @@ const addNewData = () => {
   }
 }
 // 增加表单事件
-const addForm = (params, index, arrayName, paramsIndex) => {
+const addForm = (params, index, arrayName) => {
   params.forEach(item => {
-    // model.value[`${arrayName}${item.name}${paramsIndex}`]=item.defaultValue
+    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
       },
@@ -1049,7 +1005,9 @@ const addForm = (params, index, arrayName, paramsIndex) => {
         }
       }
     })
+    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)
@@ -1074,21 +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)
       }
     })
   })
@@ -1115,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
@@ -1208,17 +1161,31 @@ const findParams = obj => {
       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'])
+        }
       }
-    } else if (key === 'params') {
-      obj[key] = JSON.stringify(obj[key])
     }
   }
 }
@@ -1312,7 +1279,7 @@ watch(
         }
         break
       case 3:
-        title.value = '训练数据增'
+        title.value = '训练数据增广'
         getAlgo('trainEnhanceAlgo', 4)
         break
       case 4:
@@ -1324,7 +1291,7 @@ watch(
         getAlgo('trainAlgo', 1)
         break
       case 6:
-        title.value = '测试数据选择'
+        title.value = '验证数据选择'
         if (testActiveTab.value) {
           handleClick(testActiveTab.value)
         }
@@ -1338,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)
         }
@@ -1357,7 +1324,7 @@ watch(
         nextBtnText.value = '下一步'
         break
       case 13:
-        title.value = '推理算法选择'
+        title.value = '测试算法选择'
         getAlgo('reasoningAlgo', 3)
         break
       default: