Эх сурвалжийг харах

feat: 可将光转红外自动刷新

WANGKANG 5 сар өмнө
parent
commit
6f0d1cdc6d

+ 1 - 0
.gitignore

@@ -24,3 +24,4 @@ stats.html
 *.njsproj
 *.sln
 *.sw?
+*.mjs

+ 2 - 2
src/api/modules/demo/toInfrared.ts

@@ -11,8 +11,8 @@ import { ToInfraredVO, ToInfraredForm, ToInfraredQuery } from '@/api/interface/d
  * @param query 参数
  * @returns 返回列表
  */
-export const listToInfraredApi = (query: ToInfraredQuery) => {
-  return http.get<ToInfraredVO[]>('/demo/toInfrared/list', query, { loading: true })
+export const listToInfraredApi = (query: ToInfraredQuery, loading = true) => {
+  return http.get<ToInfraredVO[]>('/demo/toInfrared/list', query, { loading: loading })
 }
 
 /**

+ 6 - 3
src/hooks/useTable.ts

@@ -9,7 +9,7 @@ import { reactive, computed, toRefs } from 'vue'
  * @param {Function} dataCallBack 对后台返回的数据进行处理的方法 (非必传)
  * */
 export const useTable = (
-  api?: (params: any) => Promise<any>,
+  api?: (params: any, loading?: boolean) => Promise<any>,
   initParam: object = {},
   isPageable: boolean = true,
   dataCallBack?: (data: any) => any,
@@ -54,12 +54,15 @@ export const useTable = (
    * @description 获取表格数据
    * @return void
    * */
-  const getTableList = async () => {
+  const getTableList = async (loading: undefined | boolean) => {
     if (!api) return
     try {
       // 先把初始化参数和分页参数放到总参数里面
       Object.assign(state.totalParam, initParam, isPageable ? pageParam.value : {})
-      let { data } = await api({ ...state.searchInitParam, ...state.totalParam })
+      let { data } =
+        loading === undefined
+          ? await api({ ...state.searchInitParam, ...state.totalParam })
+          : await api({ ...state.searchInitParam, ...state.totalParam }, loading)
       dataCallBack && (data = dataCallBack(data))
       state.tableData = isPageable ? data.list : data
       // 解构后台返回的分页数据 (如果有分页更新分页信息)

+ 35 - 3
src/views/demo/toInfrared/index.vue

@@ -167,11 +167,43 @@ import statusEnums from '@/utils/status'
 import { AlgorithmType, SubSystem, SubSystem__, enumsAlgorithmType, enumsSubSystem, AlgorithmType2 } from '@/views/demo/utils'
 import PreviewImages from '@/views/demo/components/PreviewImages.vue'
 import PreviewCompareImages from '@/views/demo/components/PreviewCompareImages.vue'
-
 import { addAlgorithmModelTrackApi } from '@/api/modules/demo/AlgorithmModelTrack'
-
 import ViewLog from '@/views/demo/components/ViewLog.vue'
 
+import { Status } from '@/views/demo/utils'
+
+const timerRefreshTable = ref()
+const clearTimerRefreshTable = () => {
+  if (timerRefreshTable.value) {
+    clearInterval(timerRefreshTable.value)
+  }
+}
+const refreshTable = () => {
+  clearTimerRefreshTable()
+  timerRefreshTable.value = setInterval(async () => {
+    await proTable.value?.getTableList(false)
+    console.log('refresh table')
+    const tableData = proTable.value?.tableData
+    let flag = false
+    if (tableData) {
+      console.log(tableData)
+      for (const item of tableData) {
+        if (item.status === Status['运行中']) {
+          flag = true
+          break
+        }
+      }
+    }
+    if (!flag) {
+      clearTimerRefreshTable()
+    }
+  }, 2500)
+}
+
+onMounted(() => {
+  refreshTable()
+})
+
 const previewImagesRef = ref()
 const dialogVisible = ref(false)
 const imageUrls = ref([])
@@ -327,7 +359,7 @@ const startToInfrared = async (params: any) => {
   } else {
     ElMessage.error('任务开始失败,请检查!')
   }
-  proTable.value?.getTableList()
+  refreshTable()
 }
 
 const stopToInfrared = async (params: any) => {

+ 8 - 0
src/views/demo/utils.ts

@@ -8,6 +8,14 @@
  * Copyright 2024 WANGKANG, All Rights Reserved.
  */
 
+export const Status = {
+  未开始: '0',
+  运行中: '1',
+  完成: '2',
+  失败: '3',
+  中断: '4'
+}
+
 export const AlgorithmType = {
   '0': '训练',
   '1': '测试',

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 426
vite.config.ts.timestamp-1728903656862-499f9b40dc949.mjs


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 426
vite.config.ts.timestamp-1729079247820-0269fb76961da.mjs


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 426
vite.config.ts.timestamp-1729825048745-c3bfefa8ddefc.mjs


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно