Procházet zdrojové kódy

Merge branch 'develop' of http://47.108.150.237:10000/www/taais-web into develop

ajax před 8 měsíci
rodič
revize
e7ff89e08c

+ 71 - 38
src/components/ImportPicDataset/index.vue

@@ -1,6 +1,6 @@
 <template>
   <el-dialog v-model="dialogVisible" :width="parameter.width" :top="parameter.top" :title="`${parameter.title}`" :destroy-on-close="true" draggable>
-    <el-form class="drawer-multiColumn-form" label-width="100px">
+    <el-form class="drawer-multiColumn-form" label-width="100px" :model="formModel" :rules="rules" ref="formRef">
       <el-form-item label="图片数据集压缩文件上传">
         <el-upload
           action="#"
@@ -78,7 +78,7 @@
 </template>
 
 <script setup lang="ts" name="ImportPicDataset">
-import { ref } from 'vue'
+import { ref, defineExpose, onMounted } from 'vue'
 import { ElNotification, UploadRequestOptions, UploadRawFile } from 'element-plus'
 
 export interface ParameterProps {
@@ -97,7 +97,6 @@ export interface ParameterProps {
 
 const formModel = ref({
   batchNum: '',
-  name: '',
   objectType: '',
   objectSubtype: '',
   scene: '',
@@ -107,11 +106,13 @@ const formModel = ref({
   dataType: '',
   labeled: false
 })
+
 const dataTypes = ref([
   { dictValue: '1', dictLabel: '训练' },
   { dictValue: '2', dictLabel: '测试' }
   // 添加更多数据类型
 ])
+
 const dialogVisible = ref(false)
 const parameter = ref<ParameterProps>({
   title: '',
@@ -124,12 +125,27 @@ const parameter = ref<ParameterProps>({
   ZipFileType: ['application/zip', 'application/x-zip-compressed', 'application/x-rar-compressed']
 })
 
+// 定义表单校验规则
+const rules = ref({
+  batchNum: [{ required: true, message: '批次号不能为空', trigger: 'blur' }],
+  objectType: [{ required: true, message: '目标类型不能为空', trigger: 'blur' }],
+  objectSubtype: [{ required: true, message: '目标子类型不能为空', trigger: 'blur' }],
+  scene: [{ required: true, message: '场景不能为空', trigger: 'blur' }],
+  dataSource: [{ required: true, message: '数据源不能为空', trigger: 'blur' }],
+  gatherSpot: [{ required: true, message: '采集地点不能为空', trigger: 'blur' }],
+  gatherTime: [{ required: true, message: '采集时间不能为空', trigger: 'change' }],
+  dataType: [{ required: true, message: '数据类型不能为空', trigger: 'change' }]
+})
+
+// 用于存储表单引用
+const formRef = ref(null)
+
+// 接收参数并初始化对话框
 const acceptParams = (params: ParameterProps) => {
   parameter.value = { ...parameter.value, ...params }
   dialogVisible.value = true
   formModel.value = {
     batchNum: '',
-    name: '',
     objectType: '',
     objectSubtype: '',
     scene: '',
@@ -140,41 +156,56 @@ const acceptParams = (params: ParameterProps) => {
     labeled: false
   }
 }
+
 const formData = new FormData()
+
 const handleSubmit = async () => {
-  const zipFile = formData.get('file')
-  console.log(zipFile)
-  if (!zipFile) {
-    ElNotification({
-      title: '温馨提示',
-      message: '请上传一个压缩文件!',
-      type: 'warning'
-    })
-    return
-  }
-  const formDataInfo = new FormData()
-  formDataInfo.append('file', zipFile)
-  for (const key in formModel.value) {
-    if (Object.prototype.hasOwnProperty.call(formModel.value, key)) {
-      formDataInfo.append(key, formModel.value[key])
+  // 先进行表单验证
+  formRef.value.validate(async valid => {
+    if (!valid) {
+      ElNotification({
+        title: '温馨提示',
+        message: '请检查表单的输入项!',
+        type: 'warning'
+      })
+      return
     }
-  }
-  try {
-    await parameter.value.importApi!(formDataInfo)
-    ElNotification({
-      title: '温馨提示',
-      message: `文件上传成功`,
-      type: 'success'
-    })
-    parameter.value.getTableList && parameter.value.getTableList()
-    dialogVisible.value = false
-  } catch (error) {
-    // ElNotification({
-    //   // title: '温馨提示',
-    //   // message: `文件上传失败,请重新上传`,
-    //   // type: 'error'
-    // })
-  }
+
+    const zipFile = formData.get('file')
+    if (!zipFile) {
+      ElNotification({
+        title: '温馨提示',
+        message: '请上传一个压缩文件!',
+        type: 'warning'
+      })
+      return
+    }
+
+    const formDataInfo = new FormData()
+    formDataInfo.append('file', zipFile)
+    for (const key in formModel.value) {
+      if (Object.prototype.hasOwnProperty.call(formModel.value, key)) {
+        formDataInfo.append(key, formModel.value[key])
+      }
+    }
+
+    try {
+      await parameter.value.importApi!(formDataInfo)
+      ElNotification({
+        title: '温馨提示',
+        message: `文件上传成功`,
+        type: 'success'
+      })
+      parameter.value.getTableList && parameter.value.getTableList()
+      dialogVisible.value = false
+    } catch (error) {
+      ElNotification({
+        title: '温馨提示',
+        message: `文件上传失败,请重新上传`,
+        type: 'error'
+      })
+    }
+  })
 }
 
 const uploadZip = (param: UploadRequestOptions) => {
@@ -184,13 +215,14 @@ const uploadZip = (param: UploadRequestOptions) => {
 const beforeZipUpload = (file: UploadRawFile) => {
   const isZip = parameter.value.ZipFileType!.includes(file.type as File.ZipMimeType)
   const fileSize = file.size / 1024 / 1024 < parameter.value.fileSize!
-  if (!isZip)
+  if (!isZip) {
     ElNotification({
       title: '温馨提示',
       message: '上传文件只能是 zip 格式!',
       type: 'warning'
     })
-  if (!fileSize)
+  }
+  if (!fileSize) {
     setTimeout(() => {
       ElNotification({
         title: '温馨提示',
@@ -198,6 +230,7 @@ const beforeZipUpload = (file: UploadRawFile) => {
         type: 'warning'
       })
     }, 0)
+  }
   return isZip && fileSize
 }
 

+ 9 - 1
src/views/demo/data/index.vue

@@ -3,7 +3,7 @@
     <el-image-viewer v-if="imgViewVisible" :url-list="['/api' + imageUrl]" @close="imgViewVisible = false" />
     <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listDataApi" :init-param="initParam">
       <template #yuan="scope">
-        <el-image style=" width: 200px;height: 200px" :src="'/api' + scope.row.url" @click="loadImg(scope.row.url)"></el-image>
+        <el-image style="width: 200px; height: 200px" :src="'/api' + scope.row.url" @click="loadImg(scope.row.url)"></el-image>
         <!--        <uploadImg :is-show-data="true" :disabled="true" :image-url="scope.row.url" @click="loadImg(scope.row.url)"/>-->
         <!--        <el-image style="width: 100px" :src="'/api' + scope.row.url" @click="markImg(scope.row)" />-->
       </template>
@@ -12,6 +12,8 @@
         <el-button type="primary" v-auth="['demo:data:add']" :icon="CirclePlus" @click="openDialog(1, '数据新增')"> 新增 </el-button>
         <el-button type="primary" v-auth="['demo:data:import']" :icon="Upload" plain @click="batchAdd"> 导入数据集 </el-button>
         <el-button type="primary" v-auth="['demo:data:export']" :icon="Download" plain @click="downloadFile(scope.selectedListIds)"> 导出 </el-button>
+        <el-button type="primary" v-auth="['system:user:add']" :icon="CirclePlus" @click="dataAmplify()"> 数据增广 </el-button>
+
         <el-button
           type="danger"
           v-auth="['demo:data:remove']"
@@ -77,6 +79,7 @@ import {
 import { listDataApi as listDictDataApi } from '@/api/modules/system/dictData'
 import { uploadPure } from '@/api/modules/upload'
 import http from '@/api'
+import { useRouter } from 'vue-router'
 
 onMounted(() => {
   state.cacheData.url = 'http://localhost:9090/profile/upload/2024/08/08/144745610/test.png'
@@ -358,6 +361,11 @@ const batchAdd = () => {
   dialogRef.value?.acceptParams(params)
 }
 
+const router = useRouter()
+const dataAmplify = () => {
+  router.push(`/data/amplify`)
+}
+
 const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
 // 打开弹框的功能
 const openDialog = async (type: number, title: string, row?: any) => {

+ 7 - 7
src/views/taais/homePage/task/index.vue

@@ -222,12 +222,12 @@ const valid = data => {
       return ret
     }
   }
-  if (data.hasTrainAugmentation) {
-    if (!data.trainAugmentationParams || data.trainAugmentationParams.length === 0) {
-      ret.message = '请配置扩增参数'
-      return ret
-    }
-  }
+  // if (data.hasTrainAugmentation) {
+  //   if (!data.trainAugmentationParams || data.trainAugmentationParams.length === 0) {
+  //     ret.message = '请配置扩增参数'
+  //     return ret
+  //   }
+  // }
   ret.code = 200
   return ret
 }
@@ -242,7 +242,7 @@ const submit = () => {
     trainBatchNumList: formData.data,
     testBatchNumList: formData.testData,
     hasTrainAugmentation: formData.expandData,
-    trainAugmentationParams: formData.expandConfig
+    trainAugmentationParams: null
   }
   let result = valid(params)
   // console.log(result)