feat(sj_1.0.0): 重试日志新增删除功能和功能完善

This commit is contained in:
opensnail 2024-04-25 18:31:38 +08:00
parent 620553d32e
commit ac9b427731
9 changed files with 93 additions and 69 deletions

View File

@ -21,6 +21,7 @@ const local: App.I18n.Schema = {
deleteSuccess: 'Delete Success', deleteSuccess: 'Delete Success',
confirmDelete: 'Are you sure you want to delete?', confirmDelete: 'Are you sure you want to delete?',
edit: 'Edit', edit: 'Edit',
detail: 'Detail',
index: 'Index', index: 'Index',
keywordSearch: 'Please enter keyword', keywordSearch: 'Please enter keyword',
logout: 'Logout', logout: 'Logout',

View File

@ -21,6 +21,7 @@ const local: App.I18n.Schema = {
deleteSuccess: '删除成功', deleteSuccess: '删除成功',
confirmDelete: '确认删除吗?', confirmDelete: '确认删除吗?',
edit: '编辑', edit: '编辑',
detail: '详情',
index: '序号', index: '序号',
keywordSearch: '请输入关键词搜索', keywordSearch: '请输入关键词搜索',
logout: '退出登录', logout: '退出登录',

View File

@ -426,7 +426,8 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.retry_log', component: 'view.retry_log',
meta: { meta: {
title: 'retry_log', title: 'retry_log',
i18nKey: 'route.retry_log' i18nKey: 'route.retry_log',
icon: 'tabler:logs'
} }
}, },
{ {

View File

@ -48,7 +48,24 @@ export function fetchUpdateSceneStatus(id: number, status: number) {
export function fetchRetryLogPageList(params?: Api.RetryLog.RetryLogSearchParams) { export function fetchRetryLogPageList(params?: Api.RetryLog.RetryLogSearchParams) {
return request<Api.RetryLog.RetryLogList>({ return request<Api.RetryLog.RetryLogList>({
url: '/retry-task-log/list', url: '/retry-task-log/list',
method: 'put', method: 'get',
params params
}); });
} }
/** delete retry log */
export function fetchDeleteRetryLog(id: number) {
return request<boolean>({
url: `/retry-task-log/${id}`,
method: 'delete'
});
}
/** delete retry log */
export function fetchBatchDeleteRetryLog(ids: number[]) {
return request<boolean>({
url: `/retry-task-log/ids`,
method: 'delete',
data: ids
});
}

View File

@ -965,7 +965,7 @@ declare namespace Api {
/** retryLog */ /** retryLog */
type RetryLog = Common.CommonRecord<{ type RetryLog = Common.CommonRecord<{
/** UniqueId */ /** UniqueId */
UniqueId: string; uniqueId: string;
/** 组名称 */ /** 组名称 */
groupName: string; groupName: string;
/** 场景名称 */ /** 场景名称 */
@ -984,7 +984,7 @@ declare namespace Api {
/** retryLog search params */ /** retryLog search params */
type RetryLogSearchParams = CommonType.RecordNullable< type RetryLogSearchParams = CommonType.RecordNullable<
Pick<Api.RetryLog.RetryLog, 'UniqueId' | 'groupName' | 'sceneName' | 'idempotentId' | 'bizNo'> & Pick<Api.RetryLog.RetryLog, 'uniqueId' | 'groupName' | 'sceneName' | 'idempotentId' | 'bizNo'> &
CommonSearchParams CommonSearchParams
>; >;

View File

@ -267,6 +267,7 @@ declare namespace App {
deleteSuccess: string; deleteSuccess: string;
confirmDelete: string; confirmDelete: string;
edit: string; edit: string;
detail: string;
index: string; index: string;
keywordSearch: string; keywordSearch: string;
logout: string; logout: string;

View File

@ -1,9 +1,10 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { NButton, NPopconfirm } from 'naive-ui'; import { NButton, NPopconfirm, NTag } from 'naive-ui';
import { fetchRetryLogPageList } from '@/service/api'; import { fetchBatchDeleteRetryLog, fetchDeleteRetryLog, fetchRetryLogPageList } 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';
import { retryTaskStatusTypeRecord, retryTaskTypeRecord } from '@/constants/business';
import RetryLogSearch from './modules/retry-log-search.vue'; import RetryLogSearch from './modules/retry-log-search.vue';
const appStore = useAppStore(); const appStore = useAppStore();
@ -15,7 +16,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
size: 10, size: 10,
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null // if you want to use the searchParams in Form, you need to define the following properties, and the value is null
// the value can not be undefined, otherwise the property in Form will not be reactive // the value can not be undefined, otherwise the property in Form will not be reactive
UniqueId: null, uniqueId: null,
groupName: null, groupName: null,
sceneName: null, sceneName: null,
idempotentId: null, idempotentId: null,
@ -34,7 +35,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
width: 64 width: 64
}, },
{ {
key: 'UniqueId', key: 'uniqueId',
title: $t('page.retryLog.UniqueId'), title: $t('page.retryLog.UniqueId'),
align: 'left', align: 'left',
minWidth: 120 minWidth: 120
@ -55,13 +56,39 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
key: 'retryStatus', key: 'retryStatus',
title: $t('page.retryLog.retryStatus'), title: $t('page.retryLog.retryStatus'),
align: 'left', align: 'left',
minWidth: 120 minWidth: 120,
render: row => {
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>;
}
}, },
{ {
key: 'taskType', key: 'taskType',
title: $t('page.retryLog.taskType'), title: $t('page.retryLog.taskType'),
align: 'left', align: 'left',
minWidth: 120 minWidth: 120,
render: row => {
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>;
}
}, },
{ {
key: 'idempotentId', key: 'idempotentId',
@ -89,8 +116,9 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
render: row => ( render: row => (
<div class="flex-center gap-8px"> <div class="flex-center gap-8px">
<NButton type="primary" ghost size="small" onClick={() => edit(row.id)}> <NButton type="primary" ghost size="small" onClick={() => edit(row.id)}>
{$t('common.edit')} {$t('common.detail')}
</NButton> </NButton>
{row.retryStatus === 1 ? (
<NPopconfirm onPositiveClick={() => handleDelete(row.id)}> <NPopconfirm onPositiveClick={() => handleDelete(row.id)}>
{{ {{
default: () => $t('common.confirmDelete'), default: () => $t('common.confirmDelete'),
@ -101,33 +129,29 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
) )
}} }}
</NPopconfirm> </NPopconfirm>
) : (
''
)}
</div> </div>
) )
} }
] ]
}); });
const { const { handleAdd, handleEdit, checkedRowKeys } = useTableOperate(data, getData);
handleAdd,
handleEdit,
checkedRowKeys,
onBatchDeleted,
onDeleted
// closeDrawer
} = useTableOperate(data, getData);
async function handleBatchDelete() { async function handleBatchDelete() {
// request const { error } = await fetchBatchDeleteRetryLog(checkedRowKeys.value as any[]);
console.log(checkedRowKeys.value); if (!error) {
window.$message?.success($t('common.deleteSuccess'));
onBatchDeleted(); getData();
}
} }
function handleDelete(id: any) { async function handleDelete(id: any) {
// request await fetchDeleteRetryLog(id);
console.log(id); window.$message?.success($t('common.deleteSuccess'));
getData();
onDeleted();
} }
function edit(id: any) { function edit(id: any) {

View File

@ -1,5 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { $t } from '@/locales'; import { $t } from '@/locales';
import SelectGroup from '@/components/common/select-group.vue';
import SelectScene from '@/components/common/select-scene.vue';
defineOptions({ defineOptions({
name: 'RetryLogSearch' name: 'RetryLogSearch'
@ -26,13 +28,13 @@ function search() {
<template> <template>
<SearchForm :model="model" @search="search" @reset="reset"> <SearchForm :model="model" @search="search" @reset="reset">
<NFormItemGi span="24 s:12 m:6" :label="$t('page.retryLog.groupName')" path="groupName" class="pr-24px"> <NFormItemGi span="24 s:12 m:6" :label="$t('page.retryLog.groupName')" path="groupName" class="pr-24px">
<NInput v-model:value="model.groupName" :placeholder="$t('page.retryLog.form.groupName')" /> <SelectGroup v-model="model.groupName" />
</NFormItemGi> </NFormItemGi>
<NFormItemGi span="24 s:12 m:6" :label="$t('page.retryLog.sceneName')" path="sceneName" class="pr-24px"> <NFormItemGi span="24 s:12 m:6" :label="$t('page.retryLog.sceneName')" path="sceneName" class="pr-24px">
<NInput v-model:value="model.sceneName" :placeholder="$t('page.retryLog.form.sceneName')" /> <SelectScene v-model:value="model.sceneName" :group-name="model.groupName as string" />
</NFormItemGi> </NFormItemGi>
<NFormItemGi span="24 s:12 m:6" :label="$t('page.retryLog.UniqueId')" path="UniqueId" class="pr-24px"> <NFormItemGi span="24 s:12 m:6" :label="$t('page.retryLog.UniqueId')" path="UniqueId" class="pr-24px">
<NInput v-model:value="model.UniqueId" :placeholder="$t('page.retryLog.form.UniqueId')" /> <NInput v-model:value="model.uniqueId" :placeholder="$t('page.retryLog.form.UniqueId')" />
</NFormItemGi> </NFormItemGi>
<NFormItemGi span="24 s:12 m:6" :label="$t('page.retryLog.idempotentId')" path="idempotentId" class="pr-24px"> <NFormItemGi span="24 s:12 m:6" :label="$t('page.retryLog.idempotentId')" path="idempotentId" class="pr-24px">
<NInput v-model:value="model.idempotentId" :placeholder="$t('page.retryLog.form.idempotentId')" /> <NInput v-model:value="model.idempotentId" :placeholder="$t('page.retryLog.form.idempotentId')" />

View File

@ -1,5 +1,5 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { NButton, NPopconfirm, NSwitch, NTag } from 'naive-ui'; import { NButton, NSwitch, NTag } from 'naive-ui';
import { ref } from 'vue'; import { ref } from 'vue';
import { fetchGetRetryScenePageList, fetchUpdateSceneStatus } from '@/service/api'; import { fetchGetRetryScenePageList, fetchUpdateSceneStatus } from '@/service/api';
import { $t } from '@/locales'; import { $t } from '@/locales';
@ -131,39 +131,16 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}> <NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
{$t('common.edit')} {$t('common.edit')}
</NButton> </NButton>
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
{{
default: () => $t('common.confirmDelete'),
trigger: () => (
<NButton type="error" ghost size="small">
{$t('common.delete')}
</NButton>
)
}}
</NPopconfirm>
</div> </div>
) )
} }
] ]
}); });
const { const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys } = useTableOperate(
drawerVisible, data,
operateType, getData
editingData, );
handleAdd,
handleEdit,
checkedRowKeys,
onDeleted
// closeDrawer
} = useTableOperate(data, getData);
function handleDelete(id: string) {
// request
console.log(id);
onDeleted();
}
function edit(id: string) { function edit(id: string) {
handleEdit(id); handleEdit(id);