feat(sj_1.0.0): 重试任务-完成初稿
This commit is contained in:
parent
d678b5acaa
commit
c9ba6efc47
@ -44,17 +44,24 @@ const local: App.I18n.Schema = {
|
||||
success: 'Success',
|
||||
fail: 'Fail',
|
||||
stop: 'Stop',
|
||||
execute: 'Execute',
|
||||
resume: 'Resume',
|
||||
pause: 'Pause',
|
||||
finish: 'Finish',
|
||||
running: 'Running',
|
||||
confirmStop: 'Are you sure you want to stop?',
|
||||
confirmExecute: 'Are you sure you want to execute?',
|
||||
confirmResume: 'Are you sure you want to resume?',
|
||||
confirmPause: 'Are you sure you want to pause?',
|
||||
confirmFinish: 'Are you sure you want to finishe?',
|
||||
yesOrNo: {
|
||||
yes: 'Yes',
|
||||
no: 'No'
|
||||
},
|
||||
systemTaskType: {
|
||||
retry: '重试任务',
|
||||
callback: '回调任务',
|
||||
job: '定时任务',
|
||||
workflow: '工作流'
|
||||
retry: 'Retry task',
|
||||
callback: 'Callback task',
|
||||
job: 'Job task',
|
||||
workflow: 'Workflow'
|
||||
}
|
||||
},
|
||||
request: {
|
||||
|
@ -44,8 +44,15 @@ const local: App.I18n.Schema = {
|
||||
success: '成功',
|
||||
fail: '失败',
|
||||
stop: '停止',
|
||||
execute: '执行',
|
||||
resume: '恢复',
|
||||
pause: '暂停',
|
||||
finish: '完成',
|
||||
running: '运行中',
|
||||
confirmStop: '确认停止吗?',
|
||||
confirmExecute: '确认执行吗?',
|
||||
confirmResume: '确认恢复吗?',
|
||||
confirmPause: '确认暂停吗?',
|
||||
confirmFinish: '确认完成吗?',
|
||||
yesOrNo: {
|
||||
yes: '是',
|
||||
no: '否'
|
||||
|
@ -44,3 +44,21 @@ export function fetchUpdateRetryTaskStatus(data: Api.RetryTask.RetryTaskUpdateSt
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** manual execute retryTask */
|
||||
export function fetchExecuteRetryTask(data: Api.RetryTask.ManualTriggerTaskRequestVO) {
|
||||
return request<boolean>({
|
||||
url: '/retry-task/manual/trigger/retry/task',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** batch delete retryTask */
|
||||
export function fetchBatchDeleteRetryTask(data: Api.RetryTask.BatchDeleteRetryTaskVO) {
|
||||
return request<number>({
|
||||
url: '/retry-task/batch',
|
||||
method: 'delete',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
12
src/typings/api.d.ts
vendored
12
src/typings/api.d.ts
vendored
@ -669,6 +669,16 @@ declare namespace Api {
|
||||
retryStatus: RetryStatusType;
|
||||
};
|
||||
|
||||
type ManualTriggerTaskRequestVO = {
|
||||
groupName: string;
|
||||
uniqueIds: string[];
|
||||
};
|
||||
|
||||
type BatchDeleteRetryTaskVO = {
|
||||
groupName: string;
|
||||
ids: string[];
|
||||
};
|
||||
|
||||
/** RetryTask search params */
|
||||
type RetryTaskSearchParams = CommonType.RecordNullable<
|
||||
Pick<Api.RetryTask.RetryTask, 'uniqueId' | 'groupName' | 'sceneName' | 'idempotentId' | 'bizNo' | 'retryStatus'> &
|
||||
@ -703,7 +713,7 @@ declare namespace Api {
|
||||
/** 最大重试次数 */
|
||||
maxRetryCount: number;
|
||||
/** 间隔时间 */
|
||||
triggerInterval: string;
|
||||
triggerInterval: number;
|
||||
/** 调用链超时时间 */
|
||||
deadlineRequest: number;
|
||||
/** 超时时间 */
|
||||
|
9
src/typings/app.d.ts
vendored
9
src/typings/app.d.ts
vendored
@ -290,8 +290,15 @@ declare namespace App {
|
||||
success: string;
|
||||
fail: string;
|
||||
stop: string;
|
||||
execute: string;
|
||||
resume: string;
|
||||
pause: string;
|
||||
finish: string;
|
||||
running: string;
|
||||
confirmStop: string;
|
||||
confirmExecute: string;
|
||||
confirmResume: string;
|
||||
confirmPause: string;
|
||||
confirmFinish: string;
|
||||
yesOrNo: {
|
||||
yes: string;
|
||||
no: string;
|
||||
|
@ -75,7 +75,7 @@ function createDefaultModel(): Model {
|
||||
sceneStatus: 1,
|
||||
backOff: 2,
|
||||
maxRetryCount: 1,
|
||||
triggerInterval: '60',
|
||||
triggerInterval: 60,
|
||||
deadlineRequest: 60000,
|
||||
executorTimeout: 60,
|
||||
description: '',
|
||||
|
@ -1,7 +1,12 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import { fetchGetRetryTaskList, fetchUpdateRetryTaskStatus } from '@/service/api';
|
||||
import {
|
||||
fetchBatchDeleteRetryTask,
|
||||
fetchExecuteRetryTask,
|
||||
fetchGetRetryTaskList,
|
||||
fetchUpdateRetryTaskStatus
|
||||
} from '@/service/api';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
@ -121,13 +126,13 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
key: 'operate',
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
width: 130,
|
||||
width: 260,
|
||||
render: row => (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.groupName!, row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
@ -137,16 +142,66 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
<NPopconfirm onPositiveClick={() => handleStop(Number(row.id!), row.groupName!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmStop'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.stop')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
{/* 非[完成,最大次数], 显示[执行]按钮 */}
|
||||
{row.retryStatus !== 1 && row.retryStatus !== 2 ? (
|
||||
<NPopconfirm onPositiveClick={() => handleExecute(row.groupName!, row.uniqueId!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmExecute'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.execute')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{/* 非[完成,最大次数], 显示[完成]按钮 */}
|
||||
{row.retryStatus !== 1 && row.retryStatus !== 2 ? (
|
||||
<NPopconfirm onPositiveClick={() => handleFinish(Number(row.id!), row.groupName!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmFinish'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.finish')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{/* 重试中, 显示[停止]按钮 */}
|
||||
{row.retryStatus === 0 ? (
|
||||
<NPopconfirm onPositiveClick={() => handlePause(Number(row.id!), row.groupName!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmPause'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.pause')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{/* 暂停, 显示[开始]按钮 */}
|
||||
{row.retryStatus === 3 ? (
|
||||
<NPopconfirm onPositiveClick={() => handleResume(Number(row.id!), row.groupName!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmResume'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.resume')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -160,19 +215,30 @@ const {
|
||||
handleAdd,
|
||||
handleEdit,
|
||||
checkedRowKeys,
|
||||
onBatchDeleted,
|
||||
onDeleted
|
||||
// closeDrawer
|
||||
} = useTableOperate(data, getData);
|
||||
|
||||
const { bool: batchAddDrawerVisible, setTrue: openBatchAddDrawer } = useBoolean();
|
||||
|
||||
function handleDelete(id: string) {
|
||||
// request
|
||||
console.log(id);
|
||||
async function handleDelete(groupName: string, id: string) {
|
||||
const { error } = await fetchBatchDeleteRetryTask({ groupName, ids: [id] });
|
||||
if (error) return;
|
||||
|
||||
onDeleted();
|
||||
}
|
||||
|
||||
async function handleBatchDelete() {
|
||||
const ids: string[] = checkedRowKeys.value as string[];
|
||||
if (ids.length === 0) return;
|
||||
const groupName = data.value[0].groupName;
|
||||
const { error } = await fetchBatchDeleteRetryTask({ groupName, ids });
|
||||
if (error) return;
|
||||
|
||||
onBatchDeleted();
|
||||
}
|
||||
|
||||
function edit(id: string) {
|
||||
handleEdit(id);
|
||||
}
|
||||
@ -181,13 +247,27 @@ function handleBatchAdd() {
|
||||
openBatchAddDrawer();
|
||||
}
|
||||
|
||||
async function handleStop(id: number, groupName: string) {
|
||||
const { error } = await fetchUpdateRetryTaskStatus({ id, groupName, retryStatus: 3 });
|
||||
if (error) {
|
||||
window.$message?.error($t('common.updateFailed'));
|
||||
return;
|
||||
}
|
||||
function handleExecute(groupName: string, uniqueId: string) {
|
||||
fetchExecuteRetryTask({ groupName, uniqueIds: [uniqueId] });
|
||||
}
|
||||
|
||||
function handleResume(id: number, groupName: string) {
|
||||
updateRetryTaskStatus(id, groupName, 0);
|
||||
}
|
||||
|
||||
function handlePause(id: number, groupName: string) {
|
||||
updateRetryTaskStatus(id, groupName, 3);
|
||||
}
|
||||
|
||||
function handleFinish(id: number, groupName: string) {
|
||||
updateRetryTaskStatus(id, groupName, 1);
|
||||
}
|
||||
|
||||
async function updateRetryTaskStatus(id: number, groupName: string, retryStatus: Api.RetryTask.RetryStatusType) {
|
||||
const { error } = await fetchUpdateRetryTaskStatus({ id, groupName, retryStatus });
|
||||
if (error) return;
|
||||
window.$message?.success($t('common.updateSuccess'));
|
||||
getData();
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -208,6 +288,7 @@ async function handleStop(id: number, groupName: string) {
|
||||
:loading="loading"
|
||||
@add="handleAdd"
|
||||
@batch-add="handleBatchAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@refresh="getData"
|
||||
/>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user