From d7fc693650259d8ad50aaf69504b991343f4694b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A7=8B=E5=B8=86?= <201379873@qq.com>
Date: Sat, 3 Aug 2024 20:09:06 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AF=A6=E6=83=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/schedule/log/LogDetailModal.vue | 154 +++++++++++++++++-----
1 file changed, 118 insertions(+), 36 deletions(-)
diff --git a/src/views/schedule/log/LogDetailModal.vue b/src/views/schedule/log/LogDetailModal.vue
index 9e788e2..4992c00 100644
--- a/src/views/schedule/log/LogDetailModal.vue
+++ b/src/views/schedule/log/LogDetailModal.vue
@@ -1,24 +1,26 @@
-
-
-
-
-
-
- {{ item.clientInfo.split('@')[1] }}
-
-
-
-
-
+
+
+
+
+
+
+
{{ item.clientInfo.split('@')[1] }}
+
+ {{ statusList[item.taskStatus].title
+ }}
+
+
+
+
+
+
-
-
+
+
+
@@ -31,18 +33,47 @@ const { width } = useWindowSize()
const queryForm = reactive({})
const dataList = ref([])
const loading = ref(false)
-// 查询列表数据
-const getInstanceList = async (query: JobInstanceQuery = { ...queryForm }) => {
- try {
- loading.value = true
- const res = await listJobInstance(query)
- dataList.value = res.data
- } finally {
- loading.value = false
+const activeId = ref('')
+const statusList = {
+ '1': {
+ title: '待处理',
+ color: 'gray'
+ },
+ '2': {
+ title: '运行中',
+ color: 'cyan'
+ },
+ '3': {
+ title: '成功',
+ color: 'green'
+ },
+ '4': {
+ title: '已失败',
+ color: 'red'
+ },
+ '5': {
+ title: '已停止',
+ color: 'purple'
+ },
+ '6': {
+ title: '已取消',
+ color: 'orange'
}
}
+
const visible = ref(false)
+
+// 格式化日志
+const formatLog = (log: any) => {
+ const date = new Date(Number.parseInt(log.time_stamp))
+ return `${dayjs(date).format('YYYY-MM-DD HH:mm:ss')} ${log.level} [${log.thread}] ${log.location} - ${log.message}`
+}
+
+const content = ref('')
+const setIntervalNode = ref()
+
+
// 详情
const onDetail = (record: JobLogResp) => {
visible.value = true
@@ -52,15 +83,9 @@ const onDetail = (record: JobLogResp) => {
getInstanceList()
}
-// 格式化日志
-const formatLog = (log: any) => {
- const date = new Date(Number.parseInt(log.time_stamp))
- return `${dayjs(date).format('YYYY-MM-DD HH:mm:ss')} ${log.level} [${log.thread}] ${log.location} - ${log.message}`
-}
-
-const content = ref('')
// 日志输出
const onLogDetail = async (record: JobInstanceResp) => {
+ activeId.value = record?.id
// todo startId根据第一次查询 如果有返回!=0则需要在查一次
const res = await listJobInstanceLog({
taskBatchId: record.taskBatchId,
@@ -72,8 +97,65 @@ const onLogDetail = async (record: JobInstanceResp) => {
})
content.value = res.data.message.map(formatLog).join('\n')
}
-
+const onStartInfo = (record: JobInstanceResp) => {
+ content.value = ''
+ clearInterval(setIntervalNode.value)
+ setIntervalNode.value = setInterval(() => {
+ onLogDetail(record)
+ }, 1000)
+}
+// 查询列表数据
+const getInstanceList = async (query: JobInstanceQuery = { ...queryForm }) => {
+ try {
+ loading.value = true
+ const res = await listJobInstance(query)
+ dataList.value = res.data
+ onStartInfo(dataList.value[0])
+ } finally {
+ loading.value = false
+ }
+}
+const closed = () => {
+ clearInterval(setIntervalNode.value)
+}
+onUnmounted(() => {
+ clearInterval(setIntervalNode.value)
+})
defineExpose({ onDetail })
-
+