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'; import { request } from '../request';
/** get retry log list */ /** get retry task list */
export function fetchRetryLogPageList(params?: Api.RetryTask.RetryTaskSearchParams) { export function fetchRetryTaskPageList(params?: Api.RetryTask.RetryTaskSearchParams) {
return request<Api.RetryTask.RetryTaskList>({ return request<Api.RetryTask.RetryTaskList>({
url: '/retry-task/list', url: '/retry-task/list',
method: 'get', method: 'get',
@ -9,27 +9,35 @@ export function fetchRetryLogPageList(params?: Api.RetryTask.RetryTaskSearchPara
}); });
} }
/** get retry log list */ /** get retry task list */
export function fetchRetryLogById(id: string) { export function fetchRetryTaskById(id: string) {
return request<Api.RetryTask.RetryTask>({ return request<Api.RetryTask.RetryTask>({
url: `/retry-task/${id}`, url: `/retry-task/${id}`,
method: 'get' method: 'get'
}); });
} }
/** delete retry log */ /** delete retry task */
export function fetchDeleteRetryLog(id: number) { export function fetchDeleteRetryTask(id: number) {
return request<boolean>({ return request<boolean>({
url: `/retry-task/${id}`, url: `/retry-task/${id}`,
method: 'delete' method: 'delete'
}); });
} }
/** delete retry log */ /** delete retry task */
export function fetchBatchDeleteRetryLog(ids: number[]) { export function fetchBatchDeleteRetryTask(ids: number[]) {
return request<boolean>({ return request<boolean>({
url: `/retry-task/ids`, url: `/retry-task/ids`,
method: 'delete', method: 'delete',
data: ids 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'; import { request } from '../request';
/** get retryTask list */ /** get retryTask list */
export function fetchGetRetryTaskList(params?: Api.Retry.RetrySearchParams) { export function fetchGetRetryList(params?: Api.Retry.RetrySearchParams) {
return request<Api.Retry.RetryList>({ return request<Api.Retry.RetryList>({
url: '/retry/list', url: '/retry/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function fetchGetRetryTaskList(params?: Api.Retry.RetrySearchParams) {
} }
/** get retryTask */ /** get retryTask */
export function fetchGetRetryTaskById(id: string, groupName: string) { export function fetchGetRetryById(id: string, groupName: string) {
return request<Api.Retry.Retry>({ return request<Api.Retry.Retry>({
url: `/retry/${id}?groupName=${groupName}`, url: `/retry/${id}?groupName=${groupName}`,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function fetchGetRetryTaskById(id: string, groupName: string) {
} }
/** add retryTask */ /** add retryTask */
export function fetchAddRetryTask(data: Api.Retry.Retry) { export function fetchAddRetry(data: Api.Retry.Retry) {
return request<boolean>({ return request<boolean>({
url: '/retry', url: '/retry',
method: 'post', method: 'post',
@ -27,7 +27,7 @@ export function fetchAddRetryTask(data: Api.Retry.Retry) {
} }
/** batch add retryTask */ /** batch add retryTask */
export function fetchBatchAddRetryTask(data: Api.Retry.RetryTaskBatchAdd) { export function fetchBatchAddRetry(data: Api.Retry.RetryBatchAdd) {
return request<boolean>({ return request<boolean>({
url: '/retry/batch', url: '/retry/batch',
method: 'post', method: 'post',
@ -45,7 +45,7 @@ export function fetchEditRetryTask(data: Api.Retry.Retry) {
} }
/** update retryTask status */ /** update retryTask status */
export function fetchUpdateRetryTaskStatus(data: Api.Retry.RetryTaskUpdateStatusRequest) { export function fetchUpdateRetryStatus(data: Api.Retry.RetryUpdateStatusRequest) {
return request<boolean>({ return request<boolean>({
url: '/retry/status', url: '/retry/status',
method: 'put', method: 'put',
@ -54,7 +54,7 @@ export function fetchUpdateRetryTaskStatus(data: Api.Retry.RetryTaskUpdateStatus
} }
/** manual execute retryTask */ /** manual execute retryTask */
export function fetchExecuteRetryTask(data: Api.Retry.ManualTriggerTaskRequestVO) { export function fetchExecuteRetry(data: Api.Retry.ManualTriggerRequestVO) {
return request<boolean>({ return request<boolean>({
url: '/retry/manual/trigger/retry/task', url: '/retry/manual/trigger/retry/task',
method: 'post', 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 */ /** batch delete retryTask */
export function fetchBatchDeleteRetryTask(data: Api.Retry.BatchDeleteRetryTaskVO) { export function fetchBatchDeleteRetry(data: Api.Retry.BatchDeleteRetryVO) {
return request<number>({ return request<number>({
url: '/retry/batch', url: '/retry/batch',
method: 'delete', method: 'delete',

View File

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

View File

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

View File

@ -3,7 +3,7 @@ import { reactive, watch } from 'vue';
import { useFormRules, useNaiveForm } from '@/hooks/common/form'; import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue'; import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales'; import { $t } from '@/locales';
import { fetchBatchAddRetryTask } from '@/service/api'; import { fetchBatchAddRetry } from '@/service/api';
import { translateOptions } from '@/utils/common'; import { translateOptions } from '@/utils/common';
import { retryStatusTypeOptions } from '@/constants/business'; import { retryStatusTypeOptions } from '@/constants/business';
import SelectGroup from '@/components/common/select-group.vue'; import SelectGroup from '@/components/common/select-group.vue';
@ -25,7 +25,7 @@ const visible = defineModel<boolean>('visible', {
const { formRef, validate, restoreValidation } = useNaiveForm(); const { formRef, validate, restoreValidation } = useNaiveForm();
const { defaultRequiredRule } = useFormRules(); 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()); const model: Model = reactive(createDefaultModel());
@ -53,7 +53,7 @@ async function handleSubmit() {
await validate(); await validate();
const { groupName, retryStatus, logStr } = model; const { groupName, retryStatus, logStr } = model;
const { error } = await fetchBatchAddRetryTask({ groupName, retryStatus, logStr }); const { error } = await fetchBatchAddRetry({ groupName, retryStatus, logStr });
if (error) return; if (error) return;
window.$message?.success($t('common.addSuccess')); 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 { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue'; import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales'; import { $t } from '@/locales';
import { fetchAddRetryTask, fetchIdempotentIdGenerate } from '@/service/api'; import { fetchAddRetry, fetchIdempotentIdGenerate } from '@/service/api';
import { translateOptions } from '@/utils/common'; import { translateOptions } from '@/utils/common';
import { retryStatusTypeOptions } from '@/constants/business'; import { retryStatusTypeOptions } from '@/constants/business';
import CodeMirror from '@/components/common/code-mirror.vue'; import CodeMirror from '@/components/common/code-mirror.vue';
@ -120,7 +120,7 @@ async function handleSubmit() {
if (props.operateType === 'add') { if (props.operateType === 'add') {
const { groupName, sceneName, idempotentId, bizNo, executorName, retryStatus } = model; const { groupName, sceneName, idempotentId, bizNo, executorName, retryStatus } = model;
const { error } = await fetchAddRetryTask({ const { error } = await fetchAddRetry({
groupName, groupName,
sceneName, sceneName,
idempotentId, idempotentId,

View File

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