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) { export function fetchDeleteGroup(id: string) {
return request<boolean>({ return request<boolean>({
url: `/group/${id}`, url: `/group/${id}`,

View File

@ -31,3 +31,20 @@ export function fetchJobBatchRetry(jobId: string) {
method: 'post' 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 */ /** trigger Job by id */
export function fetchTriggerJob(jobId: string) { export function fetchTriggerJob(jobId: string) {
return request<boolean>({ 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) { export function fetchStopWorkflowBatch(id: string) {
return request({ return request({
url: `/workflow/batch/stop/${id}`, url: `/workflow/batch/stop/${id}`,
@ -118,3 +126,18 @@ export function fetchNodeStop(nodeId: string, taskBatchId: string) {
method: 'post' 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 groupStatus: null
}, },
columns: () => [ columns: () => [
{
type: 'selection',
align: 'center',
width: 48
},
{ {
key: 'id', key: 'id',
title: $t('common.index'), title: $t('common.index'),
@ -207,10 +202,9 @@ function handleExport() {
<template #header-extra> <template #header-extra>
<TableHeaderOperation <TableHeaderOperation
v-model:columns="columnChecks" v-model:columns="columnChecks"
:disabled-delete="checkedRowKeys.length === 0"
:loading="loading" :loading="loading"
:show-delete="false"
:show-add="hasAuth('R_ADMIN')" :show-add="hasAuth('R_ADMIN')"
:show-delete="false"
@add="handleAdd" @add="handleAdd"
@refresh="getData" @refresh="getData"
> >

View File

@ -2,10 +2,16 @@
import { NButton, NPopconfirm, NTag, NTooltip } from 'naive-ui'; import { NButton, NPopconfirm, NTag, NTooltip } from 'naive-ui';
import { useBoolean } from '@sa/hooks'; import { useBoolean } from '@sa/hooks';
import { ref } from 'vue'; 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 { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app'; 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 { operationReasonRecord, taskBatchStatusRecord, taskTypeRecord } from '@/constants/business';
import { monthRangeISO8601, tagColor } from '@/utils/common'; import { monthRangeISO8601, tagColor } from '@/utils/common';
import SvgIcon from '@/components/custom/svg-icon.vue'; import SvgIcon from '@/components/custom/svg-icon.vue';
@ -39,6 +45,9 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
taskBatchStatus taskBatchStatus
}, },
columns: () => [ columns: () => [
{
type: 'selection'
},
{ {
key: 'id', key: 'id',
align: 'center', align: 'center',
@ -158,7 +167,7 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
key: 'operate', key: 'operate',
title: $t('common.operate'), title: $t('common.operate'),
align: 'center', align: 'center',
width: 130, width: 170,
render: row => { render: row => {
const stopBtn = () => { const stopBtn = () => {
if (row.taskBatchStatus === 1 || row.taskBatchStatus === 2) { if (row.taskBatchStatus === 1 || row.taskBatchStatus === 2) {
@ -208,6 +217,17 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
</NButton> </NButton>
{stopBtn()} {stopBtn()}
{retryBtn()} {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> </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) { function handleLog(row: Api.JobBatch.JobBatch) {
detailData.value = row; detailData.value = row;
setDetailLog(true); setDetailLog(true);
@ -251,13 +290,15 @@ async function handleStopJob(id: string) {
<template #header-extra> <template #header-extra>
<TableHeaderOperation <TableHeaderOperation
v-model:columns="columnChecks" v-model:columns="columnChecks"
:disabled-delete="checkedRowKeys.length === 0"
:loading="loading" :loading="loading"
:show-delete="false"
:show-add="false" :show-add="false"
@delete="handleBatchDelete"
@refresh="getData" @refresh="getData"
/> />
</template> </template>
<NDataTable <NDataTable
v-model:checked-row-keys="checkedRowKeys"
:columns="columns" :columns="columns"
:data="data" :data="data"
:flex-height="!appStore.isMobile" :flex-height="!appStore.isMobile"

View File

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

View File

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

View File

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

View File

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

View File

@ -114,16 +114,15 @@ const {
editingData, editingData,
handleAdd, handleAdd,
handleEdit, handleEdit,
checkedRowKeys checkedRowKeys,
onBatchDeleted
// closeDrawer // closeDrawer
} = useTableOperate(data, getData); } = useTableOperate(data, getData);
async function handleBatchDelete() { async function handleBatchDelete() {
const { error } = await fetchDeleteNotifyRecipient(checkedRowKeys.value); const { error } = await fetchDeleteNotifyRecipient(checkedRowKeys.value);
if (!error) { if (error) return;
window.$message?.success($t('common.deleteSuccess')); onBatchDeleted();
getData();
}
} }
async function handleDelete(id: string) { 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() { async function handleBatchDelete() {
// request // request
@ -145,8 +145,8 @@ async function handleBatchDelete() {
groupName: searchParams.groupName! groupName: searchParams.groupName!
}); });
if (error) return; if (error) return;
window.$message?.success($t('common.deleteSuccess')); if (error) return;
getData(); onBatchDeleted();
} }
async function handleBatchRollback() { async function handleBatchRollback() {
@ -163,8 +163,7 @@ async function handleBatchRollback() {
async function handleDelete(row: Api.RetryDeadLetter.DeadLetter) { async function handleDelete(row: Api.RetryDeadLetter.DeadLetter) {
const { error } = await fetchDeleteRetryDeadLetter({ ids: [row.id!], groupName: row.groupName! }); const { error } = await fetchDeleteRetryDeadLetter({ ids: [row.id!], groupName: row.groupName! });
if (error) return; if (error) return;
window.$message?.success($t('common.deleteSuccess')); onDeleted();
getData();
} }
async function loadRetryInfo(row: Api.RetryDeadLetter.DeadLetter) { 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() { async function handleBatchDelete() {
const { error } = await fetchBatchDeleteRetryLog(checkedRowKeys.value as any[]); const { error } = await fetchBatchDeleteRetryLog(checkedRowKeys.value as any[]);
if (!error) { if (error) return;
window.$message?.success($t('common.deleteSuccess')); onBatchDeleted();
getData();
}
} }
async function handleDelete(id: any) { async function handleDelete(id: any) {
await fetchDeleteRetryLog(id); const { error } = await fetchDeleteRetryLog(id);
window.$message?.success($t('common.deleteSuccess')); if (error) return;
getData(); onDeleted();
} }
async function loadRetryInfo(row: Api.RetryLog.RetryLog) { 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) { async function handleDelete(groupName: string, id: string) {
const { error } = await fetchBatchDeleteRetryTask({ groupName, ids: [id] }); const { error } = await fetchBatchDeleteRetryTask({ groupName, ids: [id] });
if (error) return; if (error) return;
onDeleted(); onDeleted();
} }
@ -274,7 +273,6 @@ async function handleBatchDelete() {
const groupName = data.value[0].groupName; const groupName = data.value[0].groupName;
const { error } = await fetchBatchDeleteRetryTask({ groupName, ids }); const { error } = await fetchBatchDeleteRetryTask({ groupName, ids });
if (error) return; if (error) return;
onBatchDeleted(); 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, data,
getData getData
); );
@ -152,8 +152,7 @@ const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedR
async function handleDelete(id: string) { async function handleDelete(id: string) {
const { error } = await fetchDelUser(id as any); const { error } = await fetchDelUser(id as any);
if (error) return; if (error) return;
getData(); onDeleted();
window.$message?.success($t('common.deleteSuccess'));
} }
function edit(id: string) { function edit(id: string) {

View File

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

View File

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