Browse Source

feat: 状态刷新

28968 5 months ago
parent
commit
ede9a563ec

+ 1 - 1
.vscode/settings.json

@@ -8,7 +8,7 @@
   "files.eol": "\n",
   "typescript.tsdk": "node_modules/typescript/lib",
   "[vue]": {
-    "editor.defaultFormatter": "esbenp.prettier-vscode"
+    "editor.defaultFormatter": "Vue.volar"
   },
   "[typescript]": {
     "editor.defaultFormatter": "esbenp.prettier-vscode"

+ 8 - 1
src/api/modules/demo/dataAugmentation.ts

@@ -1,13 +1,20 @@
 import http from '@/api'
 import { DataAugmentationVO, DataAugmentationForm, DataAugmentationQuery } from '@/api/interface/demo/dataAugmentation'
 
+/**
+ * @name 查询任务字典数据
+ * @returns 返回列表
+ */
+export const getTaskDictData = () => {
+  return http.get<any>('/demo/dataAugmentation/getTaskDictData', { loading: true })
+}
 /**
  * @name 查询视频去抖动列表
  * @param query 参数
  * @returns 返回列表
  */
 export const listDataAugmentationApi = (query: DataAugmentationQuery) => {
-  return http.get<DataAugmentationVO[]>('/demo/dataAugmentation/list', query, { loading: true })
+  return http.get<DataAugmentationVO[]>('/demo/dataAugmentation/list', query, { loading: false })
 }
 
 /**

+ 13 - 6
src/components/DataAugmentationFormDialog/index.vue

@@ -24,7 +24,7 @@
 </template>
 
 <script setup lang="ts" name="FormDialog">
-import { ref, ComputedRef, computed, reactive } from 'vue'
+import { ref, ComputedRef, computed, reactive, nextTick } from 'vue'
 import ProFrom from '@/components/ProForm/index.vue'
 import { ElMessage } from 'element-plus'
 import FileUpload from '@/components/Upload/File.vue'
@@ -54,7 +54,7 @@ export interface FormParameterProps {
 
 // dialog状态
 const dialogVisible = ref(false)
-const butLoading = ref(false)
+
 // 父组件传过来的参数
 const parameter = ref<FormParameterProps>({
   title: '',
@@ -107,14 +107,22 @@ const isFloat = str => {
 }
 const proFormRef = ref<InstanceType<typeof ProFrom> | null>(null)
 // 表单提交校验
+const butLoading = ref(false)
 const handleSubmit = () => {
+  butLoading.value = true
+  console.log(butLoading.value)
+  nextTick(() => {
+    console.log('Component updated')
+  })
   const formEl = proFormRef.value?.proFormRef
   const formModel = proFormRef.value?.formModel
   formModel.modelAddress = modelAddr.value
   //console.log('formModel', formModel)
 
-  butLoading.value = true
-  if (!formEl) return
+  if (!formEl) {
+    butLoading.value = false
+    return
+  }
   formEl.validate(valid => {
     if (valid) {
       let data = {}
@@ -165,10 +173,9 @@ const handleSubmit = () => {
           //console.log('message', res.message)
         }
       })
-      butLoading.value = false
     }
-    butLoading.value = false
   })
+  butLoading.value = false
 }
 // mittBus.on('data:fileName', (fileName: string) => {
 //   if (fileName !== undefined && fileName !== null) {

+ 35 - 59
src/views/demo/dataAugmentation/index.vue

@@ -86,7 +86,7 @@
 </template>
 
 <script setup lang="tsx" name="DataAugmentation">
-import { ref, reactive, onMounted, computed } from 'vue'
+import { ref, reactive, onMounted, computed, onUnmounted, onBeforeMount } from 'vue'
 import { useHandleData } from '@/hooks/useHandleData'
 import { useDownload } from '@/hooks/useDownload'
 import { ElMessageBox, ElMessage } from 'element-plus'
@@ -107,9 +107,10 @@ import {
   stopDataAugmentationApi,
   getCompareImageApi,
   getCompareImageCountApi,
-  getDialogApi
+  getDialogApi,
+  getTaskDictData
 } from '@/api/modules/demo/dataAugmentation'
-import { listDataApi } from '@/api/modules/system/dictData'
+// import {  } from '@/api/modules/system/dictData'
 import { S } from 'vite/dist/node/types.d-aGj9QkWt'
 import { servicesVersion } from 'typescript'
 const dialogVisible = ref(false)
@@ -151,52 +152,38 @@ const openLogDialog = async (id: string | number) => {
   logDialogVisible.value = true
 }
 const getTaskType = async () => {
-  const res: any = await listDataApi({
-    dictName: '',
-    dictType: 'biz_data_augmentation',
-    dictLabel: '任务类型',
-    pageNum: 0,
-    pageSize: 1000
-  })
-  if (res.data.list.length != 0) {
-    taskType.value = res.data.list.map(item => ({
-      label: item.dictValue,
-      value: item.dictValue
+  const res: any = await getTaskDictData()
+  if (res.data.length != 0) {
+    taskType.value = res.data.map(item => ({
+      label: item.taskType,
+      value: item.taskType
     }))
-    res.data.list.forEach(item => {
+    res.data.forEach(item => {
       taskTypeEnums.push({
-        label: item.dictValue,
-        value: item.dictValue,
+        label: item.taskType,
+        value: item.taskType,
         disabled: false,
         tagType: 'default'
       })
+      let obj = {}
+      obj[item.taskType] = item.hyperparameterConfiguration
+      hyperparameterConfiguration.push(obj)
     })
-    console.log(taskTypeEnums)
-    for (let i = 0; i < taskType.value.length; i++) {
-      let dictValue = taskType.value[i].value
-      const res: any = await listDataApi({
-        dictName: '',
-        dictType: 'biz_data_augmentation',
-        dictLabel: dictValue + '超参配置',
-        pageNum: 0,
-        pageSize: 1000
-      })
-      if (res.data.list.length != 0) {
-        //console.log(res.data.list[0].dictValue)
-        let obj = {}
-        obj[dictValue] = res.data.list[0].dictValue
-        hyperparameterConfiguration.push(obj)
-      } else {
-        ElMessage.error('${dictValue}未在数据字典中设置超参!')
-      }
-    }
-  } else {
-    ElMessage.error('task_type为空,请在数据字典中设置具体的任务类型!')
   }
-
-  // console.log(taskType.value)
 }
+let intervalId: NodeJS.Timeout | null = null
+
+onUnmounted(() => {
+  // 组件卸载时清除定时器
+  if (intervalId !== null) {
+    clearInterval(intervalId)
+  }
+})
+
 onMounted(() => {
+  intervalId = setInterval(async () => {
+    proTable.value?.getTableList()
+  }, 5000)
   getTaskType()
 })
 
@@ -263,7 +250,12 @@ const compareDataAugmentation = async (params: any) => {
     }
   }
   // console.log(cacheImages.value[0])
-  dialogTitle.value = '预览: 第1个样本 共' + fileCount.value + '个样本'
+  if (fileCount.value > 0) {
+    dialogTitle.value = '预览: 第1个样本 共' + fileCount.value + '个样本'
+  } else {
+    dialogTitle.value = '无结果预览'
+  }
+
   // next_picture()
 }
 const next_picture = async () => {
@@ -310,15 +302,6 @@ const downloadFile = async task => {
 
 // 批量添加视频去抖动
 const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
-const batchAdd = () => {
-  const params = {
-    title: '视频去抖动',
-    tempApi: importTemplateApi,
-    importApi: importDataAugmentationDataApi,
-    getTableList: proTable.value?.getTableList
-  }
-  dialogRef.value?.acceptParams(params)
-}
 
 const formDialogRef = ref<InstanceType<typeof DataAugmentationFormDialog> | null>(null)
 // 打开弹框的功能
@@ -519,7 +502,7 @@ const setItemsOptions = () => {
     itemsOptions.splice(4) // 如果里面有新增参数,删除,重新添加
   }
 }
-const hyperparameter = ref({})
+
 const addParams = params => {
   setItemsOptions()
   if (params == 'null') {
@@ -528,10 +511,9 @@ 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]
-      // hyperparameter[key] = obj[key]
+
       itemsOptions.push({
         label: key,
         prop: key,
@@ -540,12 +522,6 @@ const addParams = params => {
           type: 'input',
           clearable: true,
           placeholder: '默认值为' + obj[key]
-          // value: hyperparameter.value[key],
-          // onChange: (value) => {
-          //   hyperparameter.value[key] = value
-          //   console.log(hyperparameter)
-          //   // model.value[key] = value
-          // }
         }
       })
     })