feat(sj_1.0.0): 完成重试日志接入

This commit is contained in:
opensnail 2024-04-29 17:46:07 +08:00
parent 792c419ec9
commit cf7658fad7
7 changed files with 127 additions and 15 deletions

View File

@ -836,6 +836,7 @@ const local: App.I18n.Schema = {
idempotentId: 'Idempotent ID',
bizNo: 'Business Number',
createDt: 'Creation time',
form: {
groupName: 'Please enter Group name',
idempotentId: 'Please enter Idempotent ID',

View File

@ -9,6 +9,14 @@ export function fetchGetRetryTaskList(params?: Api.RetryTask.RetryTaskSearchPara
});
}
/** get retryTask */
export function fetchGetRetryTaskById(id: string, groupName: string) {
return request<Api.RetryTask.RetryTask>({
url: `/retry-task/${id}?groupName=${groupName}`,
method: 'get'
});
}
/** add retryTask */
export function fetchAddRetryTask(data: Api.RetryTask.RetryTask) {
return request<boolean>({

View File

@ -44,7 +44,7 @@ export function fetchUpdateSceneStatus(id: string, status: Api.Common.EnableStat
});
}
/** update retry log list */
/** get retry log list */
export function fetchRetryLogPageList(params?: Api.RetryLog.RetryLogSearchParams) {
return request<Api.RetryLog.RetryLogList>({
url: '/retry-task-log/list',
@ -53,6 +53,14 @@ export function fetchRetryLogPageList(params?: Api.RetryLog.RetryLogSearchParams
});
}
/** get retry log list */
export function fetchRetryLogById(id: string) {
return request<Api.RetryLog.RetryLog>({
url: `/retry-task-log/${id}`,
method: 'get'
});
}
/** delete retry log */
export function fetchDeleteRetryLog(id: number) {
return request<boolean>({

10
src/typings/api.d.ts vendored
View File

@ -1067,6 +1067,16 @@ declare namespace Api {
bizNo: string;
/** 创建时间 */
createDt: string;
/** 执行器名称 */
executorName: string;
/** 执行方法参数 */
argsStr: string;
/** 扩展字段 */
extAttrs?: string;
/** 下次触发时间 */
nextTriggerAt?: string;
/** 重试次数 */
retryCount?: number;
}>;
/** retryLog search params */

View File

@ -78,5 +78,9 @@ export function tagColor(index: number) {
4: 'default'
};
if (index === null || index < 0) {
return tagMap[1];
}
return tagMap[index % 5];
}

View File

@ -1,13 +1,20 @@
<script setup lang="tsx">
import { NButton, NPopconfirm, NTag } from 'naive-ui';
import { fetchBatchDeleteRetryLog, fetchDeleteRetryLog, fetchRetryLogPageList } from '@/service/api';
import { ref } from 'vue';
import { fetchBatchDeleteRetryLog, fetchDeleteRetryLog, fetchRetryLogById, fetchRetryLogPageList } from '@/service/api';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
import { useTable, useTableOperate } from '@/hooks/common/table';
import { retryTaskStatusTypeRecord, retryTaskTypeRecord } from '@/constants/business';
import { tagColor } from '@/utils/common';
import RetryLogSearch from './modules/retry-log-search.vue';
import RetryLogDetailDrawer from './modules/retry-log-detail-drawer.vue';
const appStore = useAppStore();
const detailData = ref();
const detailVisible = defineModel<boolean>('detailVisible', {
default: false
});
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
apiFn: fetchRetryLogPageList,
@ -39,7 +46,19 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
key: 'uniqueId',
title: $t('page.retryLog.UniqueId'),
align: 'left',
minWidth: 120
minWidth: 120,
render: row => {
async function showDetailDrawer() {
await loadRetryInfo(row);
detailVisible.value = true;
}
return (
<n-button text tag="a" type="primary" onClick={showDetailDrawer} class="ws-normal">
{row.uniqueId}
</n-button>
);
}
},
{
key: 'groupName',
@ -62,15 +81,9 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
if (row.retryStatus === null) {
return null;
}
const tagMap: Record<Api.RetryTask.RetryStatusType, NaiveUI.ThemeColor> = {
0: 'info',
1: 'success',
2: 'error',
3: 'warning'
};
const label = $t(retryTaskStatusTypeRecord[row.retryStatus!]);
return <NTag type={tagMap[row.retryStatus!]}>{label}</NTag>;
return <NTag type={tagColor(row.retryStatus!)}>{label}</NTag>;
}
},
{
@ -82,13 +95,9 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
if (row.taskType === null) {
return null;
}
const tagMap: Record<Api.RetryTask.TaskType, NaiveUI.ThemeColor> = {
1: 'warning',
2: 'error'
};
const label = $t(retryTaskTypeRecord[row.taskType!]);
return <NTag type={tagMap[row.taskType!]}>{label}</NTag>;
return <NTag type={tagColor(row.taskType!)}>{label}</NTag>;
}
},
{
@ -155,6 +164,11 @@ async function handleDelete(id: any) {
getData();
}
async function loadRetryInfo(row: Api.RetryLog.RetryLog) {
const res = await fetchRetryLogById(row.id!);
detailData.value = (res.data as Api.RetryLog.RetryLog) || null;
}
function edit(id: any) {
handleEdit(id);
}
@ -193,6 +207,7 @@ function edit(id: any) {
class="sm:h-full"
/>
</NCard>
<RetryLogDetailDrawer v-model:visible="detailVisible" :row-data="detailData" />
</div>
</template>

View File

@ -0,0 +1,66 @@
<script setup lang="ts">
import { watch } from 'vue';
import { $t } from '@/locales';
import { tagColor } from '@/utils/common';
import { retryTaskStatusTypeRecord, retryTaskTypeRecord } from '@/constants/business';
defineOptions({
name: 'SceneDetailDrawer'
});
interface Props {
/** row data */
rowData?: Api.RetryLog.RetryLog | null;
}
const visible = defineModel<boolean>('visible', {
default: false
});
const props = defineProps<Props>();
watch(
() => props.rowData,
() => {
console.log(props.rowData);
},
{ immediate: true }
);
</script>
<template>
<OperateDrawer v-model="visible" :title="$t('page.retryScene.detail')">
<NDescriptions label-placement="top" bordered :column="6">
<NDescriptionsItem :label="$t('page.retryLog.UniqueId')">
{{ rowData?.uniqueId }}
</NDescriptionsItem>
</NDescriptions>
<NDescriptions label-placement="top" bordered :column="6">
<NDescriptionsItem :label="$t('page.retryLog.groupName')">{{ rowData?.groupName }}</NDescriptionsItem>
</NDescriptions>
<NDescriptions label-placement="top" bordered :column="6">
<NDescriptionsItem :label="$t('page.retryLog.sceneName')">{{ rowData?.sceneName }}</NDescriptionsItem>
</NDescriptions>
<NDescriptions label-placement="top" bordered :column="6">
<NDescriptionsItem :label="$t('page.retryLog.retryStatus')">
<NTag :type="tagColor(rowData?.retryStatus!)">
{{ $t(retryTaskStatusTypeRecord[rowData?.retryStatus!]) }}
</NTag>
</NDescriptionsItem>
</NDescriptions>
<NDescriptions label-placement="top" bordered :column="6">
<NDescriptionsItem :label="$t('page.retryLog.taskType')">
<NTag :type="tagColor(rowData?.taskType!)">{{ $t(retryTaskTypeRecord[rowData?.taskType!]) }}</NTag>
</NDescriptionsItem>
</NDescriptions>
<NDescriptions label-placement="top" bordered :column="6">
<NDescriptionsItem :label="$t('page.retryLog.bizNo')">{{ rowData?.bizNo }}</NDescriptionsItem>
</NDescriptions>
<NDescriptions label-placement="top" bordered :column="6">
<NDescriptionsItem :label="$t('page.retryLog.idempotentId')">
{{ rowData?.idempotentId }}
</NDescriptionsItem>
</NDescriptions>
</OperateDrawer>
</template>
<style scoped></style>