Quellcode durchsuchen

feat: result expoer

28968 vor 8 Monaten
Ursprung
Commit
ce21ec87c5

+ 35 - 10
src/components/DataAugmentationFormDialog/index.vue

@@ -79,7 +79,32 @@ const setModelAddr = res => {
   console.log(res)
   modelAddr.value = res
 }
+//属性选择逻辑
+const mergeWithCondition = (formModel, parameterModel) => {
+  const result = {}
+  // 获取所有可能的属性名
+  const allKeys = new Set([...Object.keys(formModel), ...Object.keys(parameterModel)])
+
+  allKeys.forEach(key => {
+    // 检查 formModel 中的属性值
+    if (formModel.hasOwnProperty(key) && formModel[key] !== null && formModel[key] !== '' && formModel[key] !== undefined) {
+      result[key] = formModel[key]
+    } else {
+      // 使用 parameterModel 中的属性值
+      result[key] = parameterModel[key]
+    }
+  })
+
+  return result
+}
+
+const isFloat = str => {
+  // 正则表达式匹配浮点数
+  const floatRegex = /^-?\d+(\.\d+)?$/
 
+  // 使用正则表达式测试字符串
+  return floatRegex.test(str)
+}
 const proFormRef = ref<InstanceType<typeof ProFrom> | null>(null)
 // 表单提交校验
 const handleSubmit = () => {
@@ -96,19 +121,21 @@ const handleSubmit = () => {
       if (algorithmModelId.value) {
         data = { ...formModel, ...parameter.value.model, algorithmId: algorithmModelId.value }
       } else {
-        data = { ...formModel, ...parameter.value.model }
+        // data = { ...formModel, ...parameter.value.model }
+        data = mergeWithCondition(formModel, parameter.value.model)
       }
-
       let excludedKeys = ['name', 'taskType', 'inputOssId', 'remarks', 'modelAddress']
-      for (const key in data) {
+      for (let key in data) {
         if (data.hasOwnProperty(key) && !excludedKeys.includes(key)) {
-          let num = parseFloat(data[key])
-          if (isNaN(num) || !isFinite(num)) {
-            ElMessage.error('${key}参数设置不合理!')
+          if (!isFloat(data[key])) {
+            ElMessage.error(key + '参数设置不合理!')
+            butLoading.value = false
             return
           } else {
+            let num = parseFloat(data[key])
             if (key == 's_v' && Number.isInteger(num) && num % 2 == 0) {
-              ElMessage.error('${key}参数只能为奇数!')
+              ElMessage.error(key + '参数只能为奇数!')
+              butLoading.value = false
               return
             }
           }
@@ -116,17 +143,15 @@ const handleSubmit = () => {
       }
       // 使用 Object.fromEntries 从指定的键值对创建新的对象
       let hyperparameters = Object.fromEntries(Object.entries(data).filter(([key, _]) => !excludedKeys.includes(key)))
-
       // 将 hyperparameters 对象转换为 JSON 字符串
       let hyperparameterConfigurationStr = JSON.stringify(hyperparameters)
-
       // 向 data 对象中新增 hyperparameterConfiguration 属性
       data.hyperparameterConfiguration = hyperparameterConfigurationStr
       // 删除 modelAddress 属性,如果它存在
       if (data.hasOwnProperty('modelAddress')) {
         delete data.modelAddress
       }
-      console.log(data)
+      // console.log(data)
       parameter.value.api!(data).then(res => {
         if (res.code == 200) {
           proFormRef.value?.resetForm(formEl)

+ 32 - 8
src/views/demo/dataAugmentation/index.vue

@@ -5,7 +5,7 @@
       <template #tableHeader="scope">
         <el-button type="primary" v-auth="['demo:DataAugmentation:add']" icon="CirclePlus" @click="openDialog(1, '任务新增')"> 新增 </el-button>
         <!-- <el-button type="primary" v-auth="['demo:DataAugmentation:import']" icon="Upload" plain @click="batchAdd"> 导入</el-button> -->
-        <el-button type="primary" v-auth="['demo:DataAugmentation:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
+        <!-- <el-button type="primary" v-auth="['demo:DataAugmentation:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
         <el-button
           type="danger"
           v-auth="['demo:DataAugmentation:remove']"
@@ -34,10 +34,20 @@
           </template>
         </el-popconfirm>
         <el-button type="primary" link icon="View" @click="compareDataAugmentation(scope.row)" v-if="scope.row.status == '2'"> 预览 </el-button>
+        <el-button type="primary" link icon="View" @click="downloadFile(scope.row)" v-if="scope.row.status == '2'"> 导出 </el-button>
         <el-button type="primary" link icon="View" v-auth="['demo:DataAugmentation:query']" @click="openDialog(3, '任务查看', scope.row)">
           查看
         </el-button>
-        <el-button type="primary" link icon="View" v-auth="['demo:DataAugmentation:query']" @click="openLogDialog(scope.row.id)"> 日志 </el-button>
+        <el-button
+          type="primary"
+          link
+          icon="View"
+          v-auth="['demo:DataAugmentation:query']"
+          @click="openLogDialog(scope.row.id)"
+          v-if="scope.row.status != '0'"
+        >
+          日志
+        </el-button>
         <el-button type="primary" link icon="Delete" v-auth="['demo:DataAugmentation:remove']" @click="deleteDataAugmentation(scope.row)">
           删除
         </el-button>
@@ -112,7 +122,7 @@ const taskType = ref([])
 const taskTypeEnums: EnumProps[] = []
 
 const hyperparameterConfiguration = []
-const hyperparameter = ref('')
+
 const logDialogVisible = ref(false)
 const logDialog = ref('')
 const openLogDialog = async (id: string | number) => {
@@ -141,6 +151,7 @@ const getTaskType = async () => {
         tagType: 'default'
       })
     })
+    console.log(taskTypeEnums)
     for (let i = 0; i < taskType.value.length; i++) {
       let dictValue = taskType.value[i].value
       const res: any = await listDataApi({
@@ -198,6 +209,10 @@ const loadImageData = async (taskId: string, imageIdx: number) => {
 }
 
 const compareDataAugmentation = async (params: any) => {
+  if (taskId.value !== '' && taskId.value !== null && taskId.value !== undefined && taskId.value == params.id) {
+    dialogVisible.value = true
+    return
+  }
   taskId.value = params.id
   imageIdx.value = 0
   cacheImages.value = {}
@@ -266,9 +281,9 @@ const batchDelete = async (ids: string[]) => {
 }
 
 // 导出视频去抖动列表
-const downloadFile = async () => {
+const downloadFile = async task => {
   ElMessageBox.confirm('确认导出任务数据?', '温馨提示', { type: 'warning' }).then(() =>
-    useDownload(exportDataAugmentationApi, '任务列表', proTable.value?.searchParam)
+    useDownload(exportDataAugmentationApi, 'export', task.outputPath)
   )
 }
 
@@ -483,6 +498,7 @@ const setItemsOptions = () => {
     itemsOptions.splice(4) // 如果里面有新增参数,删除,重新添加
   }
 }
+const hyperparameter = ref({})
 const addParams = params => {
   setItemsOptions()
   if (params == 'null') {
@@ -491,16 +507,24 @@ const addParams = params => {
   let validJsonString = params.replace(/'/g, '"')
   try {
     const obj: { [key: string]: number } = JSON.parse(validJsonString)
+    // hyperparameter.value = { ...obj };
     Object.keys(obj).forEach(key => {
-      // model.value[key] = obj[key]
+      model.value[key] = obj[key]
+      // hyperparameter[key] = obj[key]
       itemsOptions.push({
         label: key,
         prop: key,
-        rules: [{ required: true, trigger: 'blur' }],
+        rules: [{ trigger: 'blur' }],
         compOptions: {
           type: 'input',
           clearable: true,
-          placeholder: obj[key]
+          placeholder: '默认值为' + obj[key]
+          // value: hyperparameter.value[key],
+          // onChange: (value) => {
+          //   hyperparameter.value[key] = value
+          //   console.log(hyperparameter)
+          //   // model.value[key] = value
+          // }
         }
       })
     })

Datei-Diff unterdrückt, da er zu groß ist
+ 426 - 0
vite.config.ts.timestamp-1729825048745-c3bfefa8ddefc.mjs


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.