|
@@ -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>
|