feat(1.4.0-beta1): 1. 修复删除失败问题 2. 更正文件和方法名

This commit is contained in:
opensnail 2025-02-22 21:32:29 +08:00
parent 30e79efb27
commit c6793e0382
7 changed files with 110 additions and 79 deletions

View File

@ -1,7 +1,7 @@
import { request } from '../request';
/** get retry log list */
export function fetchRetryLogPageList(params?: Api.RetryTask.RetryTaskSearchParams) {
/** get retry task list */
export function fetchRetryTaskPageList(params?: Api.RetryTask.RetryTaskSearchParams) {
return request<Api.RetryTask.RetryTaskList>({
url: '/retry-task/list',
method: 'get',
@ -9,27 +9,35 @@ export function fetchRetryLogPageList(params?: Api.RetryTask.RetryTaskSearchPara
});
}
/** get retry log list */
export function fetchRetryLogById(id: string) {
/** get retry task list */
export function fetchRetryTaskById(id: string) {
return request<Api.RetryTask.RetryTask>({
url: `/retry-task/${id}`,
method: 'get'
});
}
/** delete retry log */
export function fetchDeleteRetryLog(id: number) {
/** delete retry task */
export function fetchDeleteRetryTask(id: number) {
return request<boolean>({
url: `/retry-task/${id}`,
method: 'delete'
});
}
/** delete retry log */
export function fetchBatchDeleteRetryLog(ids: number[]) {
/** delete retry task */
export function fetchBatchDeleteRetryTask(ids: number[]) {
return request<boolean>({
url: `/retry-task/ids`,
method: 'delete',
data: ids
});
}
/** delete retry task */
export function fetchStopRetryTask(id: number) {
return request<boolean>({
url: `/retry-task/stop/${id}`,
method: 'post'
});
}

View File

@ -1,7 +1,7 @@
import { request } from '../request';
/** get retryTask list */
export function fetchGetRetryTaskList(params?: Api.Retry.RetrySearchParams) {
export function fetchGetRetryList(params?: Api.Retry.RetrySearchParams) {
return request<Api.Retry.RetryList>({
url: '/retry/list',
method: 'get',
@ -10,7 +10,7 @@ export function fetchGetRetryTaskList(params?: Api.Retry.RetrySearchParams) {
}
/** get retryTask */
export function fetchGetRetryTaskById(id: string, groupName: string) {
export function fetchGetRetryById(id: string, groupName: string) {
return request<Api.Retry.Retry>({
url: `/retry/${id}?groupName=${groupName}`,
method: 'get'
@ -18,7 +18,7 @@ export function fetchGetRetryTaskById(id: string, groupName: string) {
}
/** add retryTask */
export function fetchAddRetryTask(data: Api.Retry.Retry) {
export function fetchAddRetry(data: Api.Retry.Retry) {
return request<boolean>({
url: '/retry',
method: 'post',
@ -27,7 +27,7 @@ export function fetchAddRetryTask(data: Api.Retry.Retry) {
}
/** batch add retryTask */
export function fetchBatchAddRetryTask(data: Api.Retry.RetryTaskBatchAdd) {
export function fetchBatchAddRetry(data: Api.Retry.RetryBatchAdd) {
return request<boolean>({
url: '/retry/batch',
method: 'post',
@ -45,7 +45,7 @@ export function fetchEditRetryTask(data: Api.Retry.Retry) {
}
/** update retryTask status */
export function fetchUpdateRetryTaskStatus(data: Api.Retry.RetryTaskUpdateStatusRequest) {
export function fetchUpdateRetryStatus(data: Api.Retry.RetryUpdateStatusRequest) {
return request<boolean>({
url: '/retry/status',
method: 'put',
@ -54,7 +54,7 @@ export function fetchUpdateRetryTaskStatus(data: Api.Retry.RetryTaskUpdateStatus
}
/** manual execute retryTask */
export function fetchExecuteRetryTask(data: Api.Retry.ManualTriggerTaskRequestVO) {
export function fetchExecuteRetry(data: Api.Retry.ManualTriggerRequestVO) {
return request<boolean>({
url: '/retry/manual/trigger/retry/task',
method: 'post',
@ -62,17 +62,8 @@ export function fetchExecuteRetryTask(data: Api.Retry.ManualTriggerTaskRequestVO
});
}
/** manual execute callbackTask */
export function fetchExecuteCallbackTask(data: Api.Retry.ManualTriggerTaskRequestVO) {
return request<boolean>({
url: '/retry/manual/trigger/callback/task',
method: 'post',
data
});
}
/** batch delete retryTask */
export function fetchBatchDeleteRetryTask(data: Api.Retry.BatchDeleteRetryTaskVO) {
export function fetchBatchDeleteRetry(data: Api.Retry.BatchDeleteRetryVO) {
return request<number>({
url: '/retry/batch',
method: 'delete',

View File

@ -780,7 +780,7 @@ declare namespace Api {
taskType?: TaskType;
}>;
type RetryTaskBatchAdd = {
type RetryBatchAdd = {
/** 组名称 */
groupName: string;
/** 重试状态 0、重试中 1、重试完成 2、最大次数 3、暂停 */
@ -789,19 +789,20 @@ declare namespace Api {
logStr: string;
};
type RetryTaskUpdateStatusRequest = {
type RetryUpdateStatusRequest = {
/** id */
id: number;
/** 重试状态 0、重试中 1、重试完成 2、最大次数 3、暂停 */
retryStatus: RetryStatusType;
};
type ManualTriggerTaskRequestVO = {
type ManualTriggerRequestVO = {
groupName: string;
retryIds: number[];
};
type BatchDeleteRetryTaskVO = {
type BatchDeleteRetryVO = {
groupName: string;
ids: string[];
};

View File

@ -3,13 +3,12 @@ import { NButton, NDropdown, NPopconfirm, NTag, NTooltip } from 'naive-ui';
import { onMounted, ref } from 'vue';
import { useBoolean } from '~/packages/hooks';
import {
fetchBatchDeleteRetryTask,
fetchExecuteCallbackTask,
fetchExecuteRetryTask,
fetchBatchDeleteRetry,
fetchExecuteRetry,
fetchGetAllGroupNameList,
fetchGetRetryTaskById,
fetchGetRetryTaskList,
fetchUpdateRetryTaskStatus
fetchGetRetryById,
fetchGetRetryList,
fetchUpdateRetryStatus
} from '@/service/api';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
@ -33,7 +32,7 @@ const appStore = useAppStore();
const retryStatus = history.state.retryStatus;
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
apiFn: fetchGetRetryTaskList,
apiFn: fetchGetRetryList,
apiParams: {
page: 1,
size: 10,
@ -189,7 +188,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
render: () => (
<div class="flex-center">
<NPopconfirm
onPositiveClick={() => handleExecute(row.groupName!, row.id! as any, row.taskType!)}
onPositiveClick={() => handleExecute(row.groupName!, row.id! as any)}
v-if="row.retryStatus !== 1 && row.retryStatus !== 2"
>
{{
@ -288,7 +287,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
key: 'delete',
render: () => (
<div class="flex-center">
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
<NPopconfirm onPositiveClick={() => handleDelete(row.groupName!, row.id!)}>
{{
default: () => $t('common.confirmDelete'),
trigger: () => (
@ -343,21 +342,22 @@ const {
const { bool: batchAddDrawerVisible, setTrue: openBatchAddDrawer } = useBoolean();
async function handleDelete(id: string) {
const { error } = await fetchBatchDeleteRetryTask({ ids: [id] });
async function handleDelete(groupName: string, id: string) {
const { error } = await fetchBatchDeleteRetry({ groupName, ids: [id] });
if (error) return;
onDeleted();
}
async function loadRetryInfo(row: Api.Retry.Retry) {
const res = await fetchGetRetryTaskById(row.id!, row.groupName!);
const res = await fetchGetRetryById(row.id!, row.groupName!);
detailData.value = (res.data as Api.Retry.Retry) || null;
}
async function handleBatchDelete() {
const ids: string[] = checkedRowKeys.value as string[];
if (ids.length === 0) return;
const { error } = await fetchBatchDeleteRetryTask({ ids });
const groupName = data.value[0].groupName;
const { error } = await fetchBatchDeleteRetry({ groupName, ids });
if (error) return;
onBatchDeleted();
}
@ -366,15 +366,8 @@ function handleBatchAdd() {
openBatchAddDrawer();
}
function handleExecute(groupName: string, retryId: number, type: Api.Retry.TaskType) {
if (type === 1) {
fetchExecuteRetryTask({ groupName, retryIds: [retryId] });
return;
}
if (type === 2) {
fetchExecuteCallbackTask({ groupName, retryIds: [retryId] });
}
function handleExecute(groupName: string, retryId: number) {
fetchExecuteRetry({ groupName, retryIds: [retryId] });
}
function handleResume(id: number) {
@ -390,7 +383,7 @@ function handleFinish(id: number) {
}
async function updateRetryTaskStatus(id: number, status: Api.Retry.RetryStatusType) {
const { error } = await fetchUpdateRetryTaskStatus({ id, retryStatus: status });
const { error } = await fetchUpdateRetryStatus({ id, retryStatus: status });
if (error) return;
window.$message?.success($t('common.updateSuccess'));
getData();

View File

@ -3,7 +3,7 @@ import { reactive, watch } from 'vue';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales';
import { fetchBatchAddRetryTask } from '@/service/api';
import { fetchBatchAddRetry } from '@/service/api';
import { translateOptions } from '@/utils/common';
import { retryStatusTypeOptions } from '@/constants/business';
import SelectGroup from '@/components/common/select-group.vue';
@ -25,7 +25,7 @@ const visible = defineModel<boolean>('visible', {
const { formRef, validate, restoreValidation } = useNaiveForm();
const { defaultRequiredRule } = useFormRules();
type Model = Pick<Api.Retry.RetryTaskBatchAdd, 'groupName' | 'retryStatus' | 'logStr'>;
type Model = Pick<Api.Retry.RetryBatchAdd, 'groupName' | 'retryStatus' | 'logStr'>;
const model: Model = reactive(createDefaultModel());
@ -53,7 +53,7 @@ async function handleSubmit() {
await validate();
const { groupName, retryStatus, logStr } = model;
const { error } = await fetchBatchAddRetryTask({ groupName, retryStatus, logStr });
const { error } = await fetchBatchAddRetry({ groupName, retryStatus, logStr });
if (error) return;
window.$message?.success($t('common.addSuccess'));

View File

@ -3,7 +3,7 @@ import { computed, reactive, ref, watch } from 'vue';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales';
import { fetchAddRetryTask, fetchIdempotentIdGenerate } from '@/service/api';
import { fetchAddRetry, fetchIdempotentIdGenerate } from '@/service/api';
import { translateOptions } from '@/utils/common';
import { retryStatusTypeOptions } from '@/constants/business';
import CodeMirror from '@/components/common/code-mirror.vue';
@ -120,7 +120,7 @@ async function handleSubmit() {
if (props.operateType === 'add') {
const { groupName, sceneName, idempotentId, bizNo, executorName, retryStatus } = model;
const { error } = await fetchAddRetryTask({
const { error } = await fetchAddRetry({
groupName,
sceneName,
idempotentId,

View File

@ -2,7 +2,13 @@
import { NButton, NPopconfirm, NTag, NTooltip } from 'naive-ui';
import { ref } from 'vue';
import { useBoolean } from '~/packages/hooks';
import { fetchBatchDeleteRetryLog, fetchDeleteRetryLog, fetchRetryLogById, fetchRetryLogPageList } from '@/service/api';
import {
fetchBatchDeleteRetryTask,
fetchDeleteRetryTask,
fetchRetryTaskById,
fetchRetryTaskPageList,
fetchStopRetryTask
} from '@/service/api';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
import { useTable, useTableOperate } from '@/hooks/common/table';
@ -21,7 +27,7 @@ const { bool: detailVisible, setTrue: openDetail } = useBoolean(false);
const retryId = history.state.retryId;
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
apiFn: fetchRetryLogPageList,
apiFn: fetchRetryTaskPageList,
apiParams: {
page: 1,
size: 10,
@ -157,9 +163,32 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
title: $t('common.operate'),
align: 'center',
width: 80,
render: row => (
render: row => {
const stopBtn = () => {
if (row.taskStatus === 1 || row.taskStatus === 2) {
return (
<>
<n-divider vertical />
<NPopconfirm onPositiveClick={() => handleStopRetry(row.id!)}>
{{
default: () => $t('common.confirmStop'),
trigger: () => (
<NButton type="error" text ghost size="small">
{$t('common.stop')}
</NButton>
)
}}
</NPopconfirm>
<n-divider vertical />
</>
);
}
return null;
};
return (
<div class="flex-center gap-8px">
{row.taskStatus === 1 || row.taskStatus === 2 ? (
{stopBtn()}
{row.taskStatus !== 1 && row.taskStatus !== 2 ? (
<NPopconfirm onPositiveClick={() => handleDelete(row.id)}>
{{
default: () => $t('common.confirmDelete'),
@ -174,7 +203,8 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
''
)}
</div>
)
);
}
}
]
});
@ -182,21 +212,29 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
const { checkedRowKeys, onDeleted, onBatchDeleted } = useTableOperate(data, getData);
async function handleBatchDelete() {
const { error } = await fetchBatchDeleteRetryLog(checkedRowKeys.value as any[]);
const { error } = await fetchBatchDeleteRetryTask(checkedRowKeys.value as any[]);
if (error) return;
onBatchDeleted();
}
async function handleDelete(id: any) {
const { error } = await fetchDeleteRetryLog(id);
const { error } = await fetchDeleteRetryTask(id);
if (error) return;
onDeleted();
}
async function loadRetryInfo(row: Api.RetryTask.RetryTask) {
const res = await fetchRetryLogById(row.id!);
const res = await fetchRetryTaskById(row.id!);
detailData.value = (res.data as Api.RetryTask.RetryTask) || null;
}
async function handleStopRetry(id: string) {
const { error } = await fetchStopRetryTask(id! as any);
if (!error) {
window.$message?.success($t('common.operateSuccess'));
getData();
}
}
</script>
<template>