Ver código fonte

feat: 与算法流程相关页面的更改

Rmengdi 11 meses atrás
pai
commit
e09e871fa7

+ 1 - 1
.env

@@ -1,5 +1,5 @@
 # title
-VITE_GLOB_APP_TITLE = 目标精确捕获系统
+VITE_GLOB_APP_TITLE = 算法任务系统
 
 # 本地运行端口号
 VITE_PORT = 8848

+ 4 - 0
src/api/interface/task/subtask.ts

@@ -89,6 +89,10 @@ export interface SubtaskForm {
 }
 
 export interface SubtaskQuery extends PageQuery {
+  /**
+   * 任务名称
+   */
+  taskId?: string
   /**
    * 任务名称
    */

+ 1 - 1
src/api/modules/task/bizProcess.ts

@@ -6,7 +6,7 @@ import { BizProcessVO, BizProcessForm, BizProcessQuery } from '@/api/interface/t
  * @returns 返回列表
  */
 export const listBizProcessApi = (query: BizProcessQuery) => {
-  return http.get<BizProcessVO[]>('/task/bizProcess/list', query, { loading: true })
+  return http.get<BizProcessVO[]>('/task/bizProcess/list', query, { loading: false })
 }
 
 /**

+ 1 - 1
src/api/modules/task/subtask.ts

@@ -6,7 +6,7 @@ import { SubtaskVO, SubtaskForm, SubtaskQuery } from '@/api/interface/task/subta
  * @returns 返回列表
  */
 export const listSubtaskApi = (query: SubtaskQuery) => {
-  return http.get<SubtaskVO[]>('/task/subtask/list', query, { loading: true })
+  return http.get<SubtaskVO[]>('/task/subtask/list', query, { loading: false })
 }
 
 /**

+ 4 - 3
src/views/taais/homePage/createTask.vue

@@ -197,7 +197,7 @@ const reasoningActiveTab = ref()
 let pageIndex = ref<number>(1)
 const selectTaskTreeRef = ref<InstanceType<typeof ElTree>>()
 
-let title = ref('目标精准捕获任务选择')
+let title = ref('算法任务选择')
 let nextBtnText = ref('下一步')
 const data1 = [
   {
@@ -1176,9 +1176,10 @@ const delNumber = (start, end, dataList) => {
 }
 const onSubmit = () => {
   findParams(formItem)
-  console.log('111', formItem)
   createTaskApi(formItem).then(res => {
     console.log('createTask', res)
+    // const taskId=res
+    router.push({ path: `/task/subtask/`, query: { id: res.data } })
   })
 }
 const findParams = obj => {
@@ -1296,7 +1297,7 @@ watch(
   value => {
     switch (value) {
       case 1:
-        title.value = '任务创建:目标精准捕获任务选择'
+        title.value = '任务创建:算法任务选择'
         nextBtnText.value = '下一步'
         break
       case 2:

+ 13 - 12
src/views/taais/homePage/index.scss

@@ -70,7 +70,6 @@
 }
 %box-basic {
   width: 90%;
-  height: 700px;
   padding: 20px;
   margin: 0 auto;
 }
@@ -101,18 +100,22 @@
 
   position: relative;
   width: 90%;
-  margin-top: 50px;
   .btn {
-    margin-top: 10px;
-    margin-left: 100px;
+    margin-top: 20px;
+
+    // margin-left: 100px;
+  }
+  .prev {
+    position: absolute;
+    left: 150px;
   }
   .next {
     position: absolute;
-    right: 120px;
+    right: 150px;
   }
   .log {
     width: 90%;
-    height: 550px; /* 根据需要调整 */
+    height: 65vh; /* 根据需要调整 */
     padding: 10px;
 
     // padding-bottom: 80px;
@@ -128,20 +131,18 @@
     border-left: 3px solid #4aff84;
   }
 }
-
-// :deep(.dv-border-box-1 .border-box-content) {
-//   text-align: left;
-// }
+:deep(.dv-border-box-1 .border-box-content) {
+  text-align: left;
+}
 .trainResult-container {
   @extend %box-basic;
 
   width: 90%;
   padding: 3px 20px;
-  margin-top: 15px;
   .table {
     position: relative;
     width: 100%;
-    height: 600px;
+    height: 70vh;
     margin-top: -15px;
     .btn {
       margin-top: 10px;

+ 1 - 1
src/views/taais/homePage/inferResult.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="bigBox">
-    <dv-border-box1 ref="borderRef" style="width: 1200px; height: 730px; margin: 0 auto">
+    <dv-border-box1 ref="borderRef" style="width: 80%; height: 100%; margin: 0 auto">
       <div class="trainResult-container">
         <h4>推理结果</h4>
         <div class="table">

+ 2 - 2
src/views/taais/homePage/logPage.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="bigBox">
-    <dv-border-box1 ref="borderRef" style="width: 1200px; height: 700px; margin: 0 auto">
+    <dv-border-box1 ref="borderRef" style="width: 80%; height: 100%; margin: 0 auto">
       <div class="logPage-container">
         <el-divider content-position="left">
           <span style="font-size: 18px; font-weight: 700">{{ title }}</span>
@@ -8,7 +8,7 @@
         <div class="log">
           <div class="p" v-for="(item, index) in logInfo" :key="index">{{ item }}</div>
         </div>
-        <el-button class="btn" @click="goTrainResult()"> 上一步 </el-button>
+        <el-button class="btn prev" @click="goTrainResult()"> 上一步 </el-button>
         <el-button type="primary" v-if="over" class="btn next" @click="onResult()"> 查看结果 </el-button>
       </div>
     </dv-border-box1>

+ 115 - 5
src/views/task/bizProcess/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="table-box">
-    <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listBizProcessApi">
+    <ProTable ref="proTable" :columns="columns" row-key="id" :data="bizProcessList">
       <!-- 表格 header 按钮 -->
       <template #tableHeader="scope">
         <el-button type="primary" v-auth="['task:bizProcess:add']" icon="CirclePlus" @click="openDialog(1, '算法业务处理新增')"> 新增 </el-button>
@@ -16,6 +16,7 @@
         >
           批量删除
         </el-button>
+        <el-button type="primary" v-auth="['task:bizProcess:add']" icon="CirclePlus" @click="contrastResults()"> 对比结果 </el-button>
       </template>
       <!-- 表格操作 -->
       <template #operation="scope">
@@ -26,18 +27,24 @@
           编辑
         </el-button>
         <el-button type="primary" link icon="Delete" v-auth="['task:bizProcess:remove']" @click="deleteBizProcess(scope.row)"> 删除 </el-button>
+        <el-button type="primary" link icon="View" v-auth="['task:bizProcess:query']" @click="viewLog(scope.row)"> 查看日志 </el-button>
       </template>
     </ProTable>
     <FormDialog ref="formDialogRef" />
     <ImportExcel ref="dialogRef" />
+    <el-dialog v-model="dialogVisible" title="日志" width="70%">
+      <div class="log">
+        <div class="p" v-for="(item, index) in logInfo" :key="index">{{ item }}</div>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script setup lang="tsx" name="BizProcess">
-import { ref, reactive } from 'vue'
+import { ref, reactive, onMounted, onUnmounted, nextTick, watch } from 'vue'
 import { useHandleData } from '@/hooks/useHandleData'
 import { useDownload } from '@/hooks/useDownload'
-import { ElMessageBox } from 'element-plus'
+import { ElMessageBox, ElMessage } from 'element-plus'
 import ProTable from '@/components/ProTable/index.vue'
 import ImportExcel from '@/components/ImportExcel/index.vue'
 import FormDialog from '@/components/FormDialog/index.vue'
@@ -52,10 +59,35 @@ import {
   exportBizProcessApi,
   getBizProcessApi
 } from '@/api/modules/task/bizProcess'
-
+import { useRoute } from 'vue-router'
+const route = useRoute()
+const subTaskId = route.query.id as string
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
+const dialogVisible = ref(false)
+let logInfo = ref([] as string[])
 
+let bizProcessList = ref()
+// 每隔10秒请求一下列表
+const timer = ref() // 定时器
+const refreshList = () => {
+  setTimeout(() => {
+    listBizProcessApi({
+      pageNum: 1,
+      pageSize: 100,
+      subTaskId
+    }).then(res => {
+      bizProcessList.value = res.data['list']
+    })
+  }, 0)
+}
+onMounted(() => {
+  // timer
+  refreshList()
+  timer.value = setInterval(() => {
+    refreshList()
+  }, 100000)
+})
 // 删除算法业务处理信息
 const deleteBizProcess = async (params: any) => {
   await useHandleData(delBizProcessApi, params.id, '删除【' + params.id + '】算法业务处理')
@@ -88,6 +120,54 @@ const batchAdd = () => {
   dialogRef.value?.acceptParams(params)
 }
 
+// 对比结果
+const contrastResults = () => {
+  console.log('对比结果')
+}
+// 查看日志
+const viewLog = row => {
+  fetchLogFile(row.log)
+    .then(text => {
+      console.log('text', text)
+      info(text)
+      dialogVisible.value = true
+    })
+    .catch(error => {
+      console.error('Failed to fetch the log file:', error)
+      ElMessage.error('日志读取错误')
+    })
+}
+
+const fetchLogFile = async url => {
+  console.log('url', url)
+  try {
+    const response = await fetch(url, { method: 'GET' })
+    if (!response.ok) {
+      throw new Error(`HTTP error! status: ${response.status}`)
+    }
+    return await response.text()
+  } catch (error) {
+    throw error
+  }
+}
+let timer2 = ref()
+const info = logText => {
+  let index = 0
+  const logContainer = document.querySelector('.log')
+  timer2.value = setInterval(() => {
+    if (index < logText.length) {
+      logInfo.value.push(logText[index])
+      index++
+      nextTick(() => {
+        if (logContainer) {
+          logContainer.scrollTop = logContainer.scrollHeight
+        }
+      })
+    } else {
+      clearInterval(timer2.value)
+    }
+  }, 50)
+}
 const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
 // 打开弹框的功能
 const openDialog = async (type: number, title: string, row?: any) => {
@@ -108,7 +188,18 @@ const openDialog = async (type: number, title: string, row?: any) => {
   }
   formDialogRef.value?.openDialog(params)
 }
-
+onUnmounted(() => {
+  clearInterval(timer.value)
+  timer.value = null
+})
+watch(
+  () => dialogVisible.value,
+  val => {
+    if (!val) {
+      clearInterval(timer2.value)
+    }
+  }
+)
 // 表格配置项
 const columns = reactive<ColumnProps<any>[]>([
   { type: 'selection', fixed: 'left', width: 70 },
@@ -310,3 +401,22 @@ const setItemsOptions = () => {
   ]
 }
 </script>
+<style scoped lang="scss">
+.log {
+  width: 90%;
+  height: 60vh; /* 根据需要调整 */
+  padding: 10px;
+
+  // padding-bottom: 80px;
+  margin-left: 50px;
+  overflow-y: auto;
+  font-family: 'Courier New', monospace;
+  color: #4aff84;
+  background-color: #1e1e1e;
+}
+.p {
+  padding-left: 10px;
+  margin-bottom: 5px;
+  border-left: 3px solid #4aff84;
+}
+</style>

+ 41 - 16
src/views/task/subtask/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="table-box">
-    <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listSubtaskApi">
+    <ProTable ref="proTable" :is-show-search="false" :columns="columns" row-key="id" :data="subTaskList">
       <!-- 表格 header 按钮 -->
       <template #tableHeader="scope">
         <el-button type="primary" v-auth="['task:subtask:add']" icon="CirclePlus" @click="openDialog(1, '算法子任务新增')"> 新增 </el-button>
@@ -19,9 +19,7 @@
       </template>
       <!-- 表格操作 -->
       <template #operation="scope">
-        <el-button type="primary" link icon="View" v-auth="['task:subtask:query']" @click="openDialog(3, '算法子任务查看', scope.row)">
-          查看
-        </el-button>
+        <el-button type="primary" link icon="View" v-auth="['task:subtask:query']" @click="viewDetails(scope.row)"> 查看详情 </el-button>
         <el-button type="primary" link icon="EditPen" v-auth="['task:subtask:edit']" @click="openDialog(2, '算法子任务编辑', scope.row)">
           编辑
         </el-button>
@@ -34,13 +32,14 @@
 </template>
 
 <script setup lang="tsx" name="Subtask">
-import { ref, reactive } from 'vue'
+import { ref, reactive, onUnmounted, onMounted } from 'vue'
 import { useHandleData } from '@/hooks/useHandleData'
 import { useDownload } from '@/hooks/useDownload'
 import { ElMessageBox } from 'element-plus'
 import ProTable from '@/components/ProTable/index.vue'
 import ImportExcel from '@/components/ImportExcel/index.vue'
 import FormDialog from '@/components/FormDialog/index.vue'
+import { useRoute, useRouter } from 'vue-router'
 import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
 import {
   listSubtaskApi,
@@ -53,10 +52,37 @@ import {
   getSubtaskApi
 } from '@/api/modules/task/subtask'
 import { getDictsApi } from '@/api/modules/system/dictData'
-
+const router = useRouter()
+const route = useRoute()
+const taskId = route.query.id as string
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
+let subTaskList = ref()
 
+// 每隔10秒请求一下列表
+const timer = ref() // 定时器
+const refreshList = () => {
+  setTimeout(() => {
+    listSubtaskApi({
+      pageNum: 1,
+      pageSize: 100,
+      taskId: taskId
+    }).then(res => {
+      subTaskList.value = res.data['list']
+    })
+  }, 0)
+}
+onMounted(() => {
+  // timer
+  refreshList()
+  timer.value = setInterval(() => {
+    refreshList()
+  }, 10000)
+})
+// 查看详情
+const viewDetails = row => {
+  router.push({ path: `/task/bizProcess/`, query: { id: row.id } })
+}
 // 删除算法子任务信息
 const deleteSubtask = async (params: any) => {
   await useHandleData(delSubtaskApi, params.id, '删除【' + params.id + '】算法子任务')
@@ -109,7 +135,10 @@ const openDialog = async (type: number, title: string, row?: any) => {
   }
   formDialogRef.value?.openDialog(params)
 }
-
+onUnmounted(() => {
+  clearInterval(timer.value)
+  timer.value = null
+})
 // 表格配置项
 const columns = reactive<ColumnProps<any>[]>([
   { type: 'selection', fixed: 'left', width: 70 },
@@ -119,8 +148,7 @@ const columns = reactive<ColumnProps<any>[]>([
     label: '任务名称',
     search: {
       el: 'input'
-    },
-    width: 120
+    }
   },
   {
     prop: 'status',
@@ -137,13 +165,11 @@ const columns = reactive<ColumnProps<any>[]>([
     label: '任务类型',
     search: {
       el: 'input'
-    },
-    width: 120
+    }
   },
   {
     prop: 'parameters',
-    label: '调用算法时所用的参数',
-    width: 120
+    label: '调用算法时所用的参数'
   },
   {
     prop: 'startTime',
@@ -165,10 +191,9 @@ const columns = reactive<ColumnProps<any>[]>([
   },
   {
     prop: 'costSecond',
-    label: '耗时',
-    width: 120
+    label: '耗时'
   },
-  { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
+  { prop: 'operation', label: '操作', width: 270, fixed: 'right' }
 ])
 // 表单配置项
 let itemsOptions: ProForm.ItemsOptions[] = []

+ 8 - 7
src/views/task/task/index.vue

@@ -19,7 +19,7 @@
       </template>
       <!-- 表格操作 -->
       <template #operation="scope">
-        <el-button type="primary" link icon="View" v-auth="['task:task:query']" @click="openDialog(3, '算法任务查看', scope.row)"> 查看 </el-button>
+        <el-button type="primary" link icon="View" v-auth="['task:task:query']" @click="viewDetails(scope.row)"> 查看详情 </el-button>
         <el-button type="primary" link icon="EditPen" v-auth="['task:task:edit']" @click="openDialog(2, '算法任务编辑', scope.row)"> 编辑 </el-button>
         <el-button type="primary" link icon="Delete" v-auth="['task:task:remove']" @click="deleteTask(scope.row)"> 删除 </el-button>
       </template>
@@ -34,6 +34,7 @@ import { ref, reactive } from 'vue'
 import { useHandleData } from '@/hooks/useHandleData'
 import { useDownload } from '@/hooks/useDownload'
 import { ElMessageBox } from 'element-plus'
+import { useRouter } from 'vue-router'
 import ProTable from '@/components/ProTable/index.vue'
 import ImportExcel from '@/components/ImportExcel/index.vue'
 import FormDialog from '@/components/FormDialog/index.vue'
@@ -49,7 +50,7 @@ import {
   getTaskApi
 } from '@/api/modules/task/task'
 import { getDictsApi } from '@/api/modules/system/dictData'
-
+const router = useRouter()
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
 
@@ -105,6 +106,10 @@ const openDialog = async (type: number, title: string, row?: any) => {
   }
   formDialogRef.value?.openDialog(params)
 }
+// 查看详情
+const viewDetails = row => {
+  router.push({ path: `/task/subtask/`, query: { id: row.id } })
+}
 
 // 表格配置项
 const columns = reactive<ColumnProps<any>[]>([
@@ -153,7 +158,7 @@ const columns = reactive<ColumnProps<any>[]>([
     },
     width: 120
   },
-  { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
+  { prop: 'operation', label: '操作', width: 270, fixed: 'right' }
 ])
 // 表单配置项
 let itemsOptions: ProForm.ItemsOptions[] = []
@@ -170,10 +175,6 @@ const setItemsOptions = () => {
     {
       label: '任务状态',
       prop: 'status',
-      options: {
-        labelKey: 'dictLabel',
-        valueKey: 'dictValue'
-      },
       compOptions: {
         elTagName: 'select',
         labelKey: 'dictLabel',