feat(sj_1.1.0-beta3): 定时任务与工作流新增删除功能

This commit is contained in:
xlsea 2024-07-09 10:39:34 +08:00
parent 66496636e8
commit 67cf8e7ea4
17 changed files with 197 additions and 71 deletions

View File

@ -60,7 +60,7 @@ export function fetchGetAllGroupConfigList(data: string[]) {
});
}
/** delete Group by id */
/** delete group by id */
export function fetchDeleteGroup(id: string) {
return request<boolean>({
url: `/group/${id}`,

View File

@ -31,3 +31,20 @@ export function fetchJobBatchRetry(jobId: string) {
method: 'post'
});
}
/** delete job */
export function fetchDeleteJobBatch(id: string) {
return request<boolean>({
url: `/job/batch/${id}`,
method: 'delete'
});
}
/** delete job */
export function fetchBatchDeleteJobBatch(data: string[]) {
return request<boolean>({
url: '/job/batch/ids',
method: 'delete',
data
});
}

View File

@ -79,6 +79,15 @@ export function fetchDeleteJob(id: string) {
});
}
/** batch delete Job by id */
export function fetchBatchDeleteJob(data: string[]) {
return request<boolean>({
url: '/job/ids',
method: 'delete',
data
});
}
/** trigger Job by id */
export function fetchTriggerJob(jobId: string) {
return request<boolean>({

View File

@ -50,6 +50,14 @@ export function fetchDelWorkflow(id: string) {
});
}
export function fetchBatchDeleteWorkflow(data: string[]) {
return request({
url: '/workflow/ids',
method: 'delete',
data
});
}
export function fetchStopWorkflowBatch(id: string) {
return request({
url: `/workflow/batch/stop/${id}`,
@ -118,3 +126,18 @@ export function fetchNodeStop(nodeId: string, taskBatchId: string) {
method: 'post'
});
}
export function fetchDeleteWorkflowBatch(id: string) {
return request({
url: `/workflow/batch/${id}`,
method: 'delete'
});
}
export function fetchBatchDeleteWorkflowBatch(data: string[]) {
return request({
url: '/workflow/batch/ids',
method: 'delete',
data
});
}

View File

@ -31,11 +31,6 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
groupStatus: null
},
columns: () => [
{
type: 'selection',
align: 'center',
width: 48
},
{
key: 'id',
title: $t('common.index'),
@ -207,10 +202,9 @@ function handleExport() {
<template #header-extra>
<TableHeaderOperation
v-model:columns="columnChecks"
:disabled-delete="checkedRowKeys.length === 0"
:loading="loading"
:show-delete="false"
:show-add="hasAuth('R_ADMIN')"
:show-delete="false"
@add="handleAdd"
@refresh="getData"
>

View File

@ -2,10 +2,16 @@
import { NButton, NPopconfirm, NTag, NTooltip } from 'naive-ui';
import { useBoolean } from '@sa/hooks';
import { ref } from 'vue';
import { fetchGetJobBatchList, fetchJobBatchRetry, fetchJobBatchStop } from '@/service/api';
import {
fetchBatchDeleteJobBatch,
fetchDeleteJobBatch,
fetchGetJobBatchList,
fetchJobBatchRetry,
fetchJobBatchStop
} from '@/service/api';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
import { useTable } from '@/hooks/common/table';
import { useTable, useTableOperate } from '@/hooks/common/table';
import { operationReasonRecord, taskBatchStatusRecord, taskTypeRecord } from '@/constants/business';
import { monthRangeISO8601, tagColor } from '@/utils/common';
import SvgIcon from '@/components/custom/svg-icon.vue';
@ -39,6 +45,9 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
taskBatchStatus
},
columns: () => [
{
type: 'selection'
},
{
key: 'id',
align: 'center',
@ -158,7 +167,7 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
key: 'operate',
title: $t('common.operate'),
align: 'center',
width: 130,
width: 170,
render: row => {
const stopBtn = () => {
if (row.taskBatchStatus === 1 || row.taskBatchStatus === 2) {
@ -208,6 +217,17 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
</NButton>
{stopBtn()}
{retryBtn()}
<n-divider vertical />
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
{{
default: () => $t('common.confirmDelete'),
trigger: () => (
<NButton type="error" text ghost size="small">
{$t('common.delete')}
</NButton>
)
}}
</NPopconfirm>
</div>
);
}
@ -215,6 +235,25 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
]
});
const {
checkedRowKeys,
onDeleted,
onBatchDeleted
// closeDrawer
} = useTableOperate(data, getData);
async function handleDelete(id: string) {
const { error } = await fetchDeleteJobBatch(id);
if (error) return;
onDeleted();
}
async function handleBatchDelete() {
const { error } = await fetchBatchDeleteJobBatch(checkedRowKeys.value);
if (error) return;
onBatchDeleted();
}
function handleLog(row: Api.JobBatch.JobBatch) {
detailData.value = row;
setDetailLog(true);
@ -251,13 +290,15 @@ async function handleStopJob(id: string) {
<template #header-extra>
<TableHeaderOperation
v-model:columns="columnChecks"
:disabled-delete="checkedRowKeys.length === 0"
:loading="loading"
:show-delete="false"
:show-add="false"
@delete="handleBatchDelete"
@refresh="getData"
/>
</template>
<NDataTable
v-model:checked-row-keys="checkedRowKeys"
:columns="columns"
:data="data"
:flex-height="!appStore.isMobile"

View File

@ -3,6 +3,7 @@ import { ref } from 'vue';
import { executorTypeRecord, operationReasonRecord, taskBatchStatusRecord } from '@/constants/business';
import { $t } from '@/locales';
import { tagColor } from '@/utils/common';
import { fetchJobBatchRetry } from '@/service/api';
defineOptions({
name: 'JobBatchDetailDrawer'
@ -14,7 +15,7 @@ interface Props {
log?: boolean;
}
withDefaults(defineProps<Props>(), {
const props = withDefaults(defineProps<Props>(), {
log: false,
rowData: null
});
@ -30,6 +31,13 @@ async function openLog(row: Api.Job.JobTask) {
logShow.value = true;
taskData.value = row;
}
async function retry() {
const { error } = await fetchJobBatchRetry(props.rowData!.id!);
if (!error) {
window.$message?.success($t('common.operateSuccess'));
}
}
</script>
<template>
@ -62,7 +70,7 @@ async function openLog(row: Api.Job.JobTask) {
</NDescriptions>
</NTabPane>
<NTabPane :name="1" :tab="$t('page.log.title')" display-directive="if">
<JobTaskListTable :row-data="rowData" @show-log="openLog" />
<JobTaskListTable :row-data="rowData" @show-log="openLog" @retry="retry" />
</NTabPane>
</NTabs>
</DetailDrawer>

View File

@ -2,7 +2,13 @@
import { NButton, NPopconfirm, NTag } from 'naive-ui';
import { useBoolean } from '@sa/hooks';
import { ref } from 'vue';
import { fetchDeleteJob, fetchGetJobPage, fetchTriggerJob, fetchUpdateJobStatus } from '@/service/api';
import {
fetchBatchDeleteJob,
fetchDeleteJob,
fetchGetJobPage,
fetchTriggerJob,
fetchUpdateJobStatus
} from '@/service/api';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
import { useTable, useTableOperate } from '@/hooks/common/table';
@ -229,7 +235,8 @@ const {
handleAdd,
handleEdit,
checkedRowKeys,
onDeleted
onDeleted,
onBatchDeleted
// closeDrawer
} = useTableOperate(data, getData);
@ -239,6 +246,12 @@ async function handleDelete(id: string) {
onDeleted();
}
async function handleBatchDelete() {
const { error } = await fetchBatchDeleteJob(checkedRowKeys.value);
if (error) return;
onBatchDeleted();
}
function edit(id: string) {
handleEdit(id);
}
@ -285,8 +298,9 @@ function handleExport() {
<TableHeaderOperation
v-model:columns="columnChecks"
:loading="loading"
:show-delete="false"
:disabled-delete="checkedRowKeys.length === 0"
@add="handleAdd"
@delete="handleBatchDelete"
@refresh="getData"
>
<template #addAfter>

View File

@ -28,12 +28,12 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
keyword: null
},
columns: () => [
// {
// key: 'id',
// title: $t('common.index'),
// align: 'center',
// width: 64
// },
{
key: 'id',
title: $t('common.index'),
align: 'center',
width: 64
},
{
key: 'name',
title: $t('page.namespace.name'),

View File

@ -190,16 +190,15 @@ const {
editingData,
handleAdd,
handleEdit,
checkedRowKeys
checkedRowKeys,
onBatchDeleted
// closeDrawer
} = useTableOperate(data, getData);
async function handleBatchDelete() {
const { error } = await fetchBatchDeleteNotify(checkedRowKeys.value);
if (!error) {
window.$message?.success($t('common.deleteSuccess'));
getData();
}
if (error) return;
onBatchDeleted();
}
async function handleDelete(id: string) {

View File

@ -114,16 +114,15 @@ const {
editingData,
handleAdd,
handleEdit,
checkedRowKeys
checkedRowKeys,
onBatchDeleted
// closeDrawer
} = useTableOperate(data, getData);
async function handleBatchDelete() {
const { error } = await fetchDeleteNotifyRecipient(checkedRowKeys.value);
if (!error) {
window.$message?.success($t('common.deleteSuccess'));
getData();
}
if (error) return;
onBatchDeleted();
}
async function handleDelete(id: string) {

View File

@ -136,7 +136,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
]
});
const { handleAdd, checkedRowKeys } = useTableOperate(data, getData);
const { handleAdd, checkedRowKeys, onDeleted, onBatchDeleted } = useTableOperate(data, getData);
async function handleBatchDelete() {
// request
@ -145,8 +145,8 @@ async function handleBatchDelete() {
groupName: searchParams.groupName!
});
if (error) return;
window.$message?.success($t('common.deleteSuccess'));
getData();
if (error) return;
onBatchDeleted();
}
async function handleBatchRollback() {
@ -163,8 +163,7 @@ async function handleBatchRollback() {
async function handleDelete(row: Api.RetryDeadLetter.DeadLetter) {
const { error } = await fetchDeleteRetryDeadLetter({ ids: [row.id!], groupName: row.groupName! });
if (error) return;
window.$message?.success($t('common.deleteSuccess'));
getData();
onDeleted();
}
async function loadRetryInfo(row: Api.RetryDeadLetter.DeadLetter) {

View File

@ -153,20 +153,18 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
]
});
const { checkedRowKeys } = useTableOperate(data, getData);
const { checkedRowKeys, onDeleted, onBatchDeleted } = useTableOperate(data, getData);
async function handleBatchDelete() {
const { error } = await fetchBatchDeleteRetryLog(checkedRowKeys.value as any[]);
if (!error) {
window.$message?.success($t('common.deleteSuccess'));
getData();
}
if (error) return;
onBatchDeleted();
}
async function handleDelete(id: any) {
await fetchDeleteRetryLog(id);
window.$message?.success($t('common.deleteSuccess'));
getData();
const { error } = await fetchDeleteRetryLog(id);
if (error) return;
onDeleted();
}
async function loadRetryInfo(row: Api.RetryLog.RetryLog) {

View File

@ -259,7 +259,6 @@ const { bool: batchAddDrawerVisible, setTrue: openBatchAddDrawer } = useBoolean(
async function handleDelete(groupName: string, id: string) {
const { error } = await fetchBatchDeleteRetryTask({ groupName, ids: [id] });
if (error) return;
onDeleted();
}
@ -274,7 +273,6 @@ async function handleBatchDelete() {
const groupName = data.value[0].groupName;
const { error } = await fetchBatchDeleteRetryTask({ groupName, ids });
if (error) return;
onBatchDeleted();
}

View File

@ -144,7 +144,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
]
});
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys } = useTableOperate(
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onDeleted } = useTableOperate(
data,
getData
);
@ -152,8 +152,7 @@ const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedR
async function handleDelete(id: string) {
const { error } = await fetchDelUser(id as any);
if (error) return;
getData();
window.$message?.success($t('common.deleteSuccess'));
onDeleted();
}
function edit(id: string) {

View File

@ -1,7 +1,12 @@
<script setup lang="tsx">
import { NButton, NPopconfirm, NTag } from 'naive-ui';
import { useRouter } from 'vue-router';
import { fetchGetWorkflowBatchList, fetchStopWorkflowBatch } from '@/service/api';
import {
fetchBatchDeleteWorkflowBatch,
fetchDeleteWorkflowBatch,
fetchGetWorkflowBatchList,
fetchStopWorkflowBatch
} from '@/service/api';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
import { useTable, useTableOperate } from '@/hooks/common/table';
@ -35,6 +40,9 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
taskBatchStatus
},
columns: () => [
{
type: 'selection'
},
{
key: 'id',
title: $t('common.index'),
@ -121,19 +129,32 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
render: row => (
<div class="flex-center gap-8px">
{row?.taskBatchStatus === 1 || row?.taskBatchStatus === 2 ? (
<NPopconfirm onPositiveClick={() => handleStop(row.id!)}>
{{
default: () => $t('common.confirmStop'),
trigger: () => (
<NButton type="error" text ghost size="small">
{$t('common.stop')}
</NButton>
)
}}
</NPopconfirm>
<>
<NPopconfirm onPositiveClick={() => handleStop(row.id!)}>
{{
default: () => $t('common.confirmStop'),
trigger: () => (
<NButton type="error" text ghost size="small">
{$t('common.stop')}
</NButton>
)
}}
</NPopconfirm>
<n-divider vertical />
</>
) : (
''
)}
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
{{
default: () => $t('common.confirmDelete'),
trigger: () => (
<NButton type="error" text ghost size="small">
{$t('common.delete')}
</NButton>
)
}}
</NPopconfirm>
</div>
)
}
@ -142,12 +163,20 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
const {
checkedRowKeys,
onDeleted,
onBatchDeleted
// closeDrawer
} = useTableOperate(data, getData);
async function handleDelete(id: string) {
const { error } = await fetchDeleteWorkflowBatch(id);
if (error) return;
onDeleted();
}
async function handleBatchDelete() {
// requestd
const { error } = await fetchBatchDeleteWorkflowBatch(checkedRowKeys.value);
if (error) return;
onBatchDeleted();
}
@ -180,7 +209,6 @@ function detail(id: string) {
:disabled-delete="checkedRowKeys.length === 0"
:loading="loading"
:show-add="false"
:show-delete="false"
@delete="handleBatchDelete"
@refresh="getData"
/>

View File

@ -2,6 +2,7 @@
import { NButton, NDropdown, NPopconfirm, NTag } from 'naive-ui';
import { useRouter } from 'vue-router';
import {
fetchBatchDeleteWorkflow,
fetchDelWorkflow,
fetchGetWorkflowPageList,
fetchTriggerWorkflow,
@ -216,22 +217,22 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
const {
checkedRowKeys,
onBatchDeleted
onBatchDeleted,
onDeleted
// closeDrawer
} = useTableOperate(data, getData);
async function handleBatchDelete() {
// request
const { error } = await fetchBatchDeleteWorkflow(checkedRowKeys.value);
if (error) return;
onBatchDeleted();
}
async function handleDelete(id: string) {
// request
const { error } = await fetchDelWorkflow(id!);
if (!error) {
window.$message?.success($t('common.deleteSuccess'));
getData();
}
if (error) return;
onDeleted();
}
function edit(id: string) {
@ -295,7 +296,6 @@ function goToBatch(workflowId: string) {
v-model:columns="columnChecks"
:disabled-delete="checkedRowKeys.length === 0"
:loading="loading"
:show-delete="false"
@add="handleAdd"
@delete="handleBatchDelete"
@refresh="getData"