2024-04-29 23:12:14 +08:00
|
|
|
<script setup lang="ts">
|
2024-05-08 10:53:24 +08:00
|
|
|
import { onBeforeUnmount, ref } from 'vue';
|
2024-04-29 23:12:14 +08:00
|
|
|
import { $t } from '@/locales';
|
|
|
|
import { tagColor } from '@/utils/common';
|
|
|
|
import { retryTaskStatusTypeRecord, retryTaskTypeRecord } from '@/constants/business';
|
2024-05-08 10:53:24 +08:00
|
|
|
import { fetchRetryLogList } from '@/service/api/log';
|
2024-04-29 23:12:14 +08:00
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
name: 'SceneDetailDrawer'
|
|
|
|
});
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
/** row data */
|
|
|
|
rowData?: Api.RetryTask.RetryTask | null;
|
|
|
|
}
|
|
|
|
|
2024-05-08 10:53:24 +08:00
|
|
|
const props = defineProps<Props>();
|
|
|
|
|
2024-04-29 23:12:14 +08:00
|
|
|
const visible = defineModel<boolean>('visible', {
|
|
|
|
default: false
|
|
|
|
});
|
|
|
|
|
2024-05-08 10:53:24 +08:00
|
|
|
const logList = ref<Api.JobLog.JobMessage[]>([]);
|
|
|
|
const interval = ref<NodeJS.Timeout>();
|
|
|
|
const controller = new AbortController();
|
|
|
|
const finished = ref<boolean>(false);
|
|
|
|
let startId = '0';
|
|
|
|
let fromIndex: number = 0;
|
|
|
|
|
|
|
|
async function getLogList() {
|
|
|
|
const { data: logData, error } = await fetchRetryLogList({
|
|
|
|
groupName: props.rowData!.groupName,
|
|
|
|
uniqueId: props.rowData!.uniqueId!,
|
|
|
|
startId,
|
|
|
|
fromIndex,
|
|
|
|
size: 50
|
|
|
|
});
|
|
|
|
if (!error) {
|
|
|
|
finished.value = logData.finished;
|
|
|
|
startId = logData.nextStartId;
|
|
|
|
fromIndex = logData.fromIndex;
|
|
|
|
if (logData.message) {
|
|
|
|
logList.value.push(...logData.message);
|
|
|
|
logList.value.sort((a, b) => Number.parseInt(a.time_stamp, 10) - Number.parseInt(b.time_stamp, 10));
|
|
|
|
}
|
|
|
|
if (!finished.value) {
|
|
|
|
clearTimeout(interval.value);
|
|
|
|
interval.value = setTimeout(getLogList, 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const handleUpdateTab = async (value: number) => {
|
|
|
|
if (value === 1 && logList.value.length === 0) {
|
|
|
|
await getLogList();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const stopLog = () => {
|
|
|
|
finished.value = true;
|
|
|
|
controller.abort();
|
|
|
|
clearTimeout(interval.value);
|
|
|
|
interval.value = undefined;
|
|
|
|
};
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
stopLog();
|
|
|
|
});
|
2024-04-29 23:12:14 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<OperateDrawer v-model="visible" :title="$t('page.retryTask.detail')">
|
2024-05-08 10:53:24 +08:00
|
|
|
<NTabs type="segment" animated @update:value="handleUpdateTab">
|
|
|
|
<NTabPane :name="0" :tab="$t('page.log.info')">
|
|
|
|
<NDescriptions label-placement="top" bordered :column="2">
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.uniqueId')" :span="2">
|
|
|
|
{{ rowData?.uniqueId }}
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.groupName')" :span="2">
|
|
|
|
{{ rowData?.groupName }}
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.sceneName')" :span="2">
|
|
|
|
{{ rowData?.sceneName }}
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.nextTriggerAt')" :span="1">
|
|
|
|
{{ rowData?.nextTriggerAt }}
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.retryCount')" :span="1">
|
|
|
|
{{ rowData?.retryCount }}
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.retryStatus')" :span="1">
|
|
|
|
<NTag :type="tagColor(rowData?.retryStatus!)">
|
|
|
|
{{ $t(retryTaskStatusTypeRecord[rowData?.retryStatus!]) }}
|
|
|
|
</NTag>
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.taskType')" :span="1">
|
|
|
|
<NTag :type="tagColor(rowData?.taskType!)">{{ $t(retryTaskTypeRecord[rowData?.taskType!]) }}</NTag>
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.bizNo')" :span="2">{{ rowData?.bizNo }}</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.idempotentId')" :span="2">
|
|
|
|
{{ rowData?.idempotentId }}
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.executorName')" :span="2">
|
|
|
|
{{ rowData?.executorName }}
|
|
|
|
</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('page.retryTask.argsStr')" :span="2">{{ rowData?.argsStr }}</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('common.createDt')" :span="1">{{ rowData?.createDt }}</NDescriptionsItem>
|
|
|
|
<NDescriptionsItem :label="$t('common.updateDt')" :span="1">{{ rowData?.updateDt }}</NDescriptionsItem>
|
|
|
|
</NDescriptions>
|
|
|
|
</NTabPane>
|
|
|
|
<NTabPane :name="1" :tab="$t('page.log.title')" display-directive="if">
|
2024-06-26 15:27:43 +08:00
|
|
|
<LogDrawer :drawer="false" type="retry" :task-data="rowData!" />
|
2024-05-08 10:53:24 +08:00
|
|
|
</NTabPane>
|
|
|
|
</NTabs>
|
2024-04-29 23:12:14 +08:00
|
|
|
</OperateDrawer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped></style>
|