feat(sj_1.0.0): 定时任务接入删除/执行两个接口
This commit is contained in:
parent
5383e41ac3
commit
fbee1276c1
@ -50,6 +50,8 @@ const local: App.I18n.Schema = {
|
||||
pause: 'Pause',
|
||||
finish: 'Finish',
|
||||
running: 'Running',
|
||||
executeSuccess: 'Execute successfully',
|
||||
executeFailed: 'Execute failed',
|
||||
confirmExecute: 'Are you sure you want to execute?',
|
||||
confirmResume: 'Are you sure you want to resume?',
|
||||
confirmPause: 'Are you sure you want to pause?',
|
||||
|
@ -50,6 +50,8 @@ const local: App.I18n.Schema = {
|
||||
pause: '暂停',
|
||||
finish: '完成',
|
||||
running: '运行中',
|
||||
executeSuccess: '执行成功',
|
||||
executeFailed: '执行失败',
|
||||
confirmExecute: '确认执行吗?',
|
||||
confirmResume: '确认恢复吗?',
|
||||
confirmPause: '确认暂停吗?',
|
||||
|
@ -27,7 +27,7 @@ export function fetchEditJob(data: Api.Job.Job) {
|
||||
});
|
||||
}
|
||||
|
||||
/** edit Job */
|
||||
/** edit Job status */
|
||||
export function fetchUpdateJobStatus(data: Api.Job.JobUpdateJobStatusRequestVO) {
|
||||
return request<boolean>({
|
||||
url: '/job/status',
|
||||
@ -35,3 +35,19 @@ export function fetchUpdateJobStatus(data: Api.Job.JobUpdateJobStatusRequestVO)
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** delete Job by id */
|
||||
export function fetchDeleteJob(id: string) {
|
||||
return request<boolean>({
|
||||
url: `/job/${id}`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
/** trigger Job by id */
|
||||
export function fetchTriggerJob(jobId: string) {
|
||||
return request<boolean>({
|
||||
url: `/job/trigger/${jobId}`,
|
||||
method: 'post'
|
||||
});
|
||||
}
|
||||
|
2
src/typings/app.d.ts
vendored
2
src/typings/app.d.ts
vendored
@ -296,6 +296,8 @@ declare namespace App {
|
||||
pause: string;
|
||||
finish: string;
|
||||
running: string;
|
||||
executeSuccess: string;
|
||||
executeFailed: string;
|
||||
confirmExecute: string;
|
||||
confirmResume: string;
|
||||
confirmPause: string;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||
import { fetchGetJobPage, fetchUpdateJobStatus } from '@/service/api';
|
||||
import { fetchDeleteJob, fetchGetJobPage, fetchTriggerJob, fetchUpdateJobStatus } from '@/service/api';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
@ -11,7 +11,7 @@ import JobTaskSearch from './modules/job-task-search.vue';
|
||||
|
||||
const appStore = useAppStore();
|
||||
|
||||
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
|
||||
const { columns, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
|
||||
apiFn: fetchGetJobPage,
|
||||
apiParams: {
|
||||
page: 1,
|
||||
@ -21,11 +21,6 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
jobStatus: null
|
||||
},
|
||||
columns: () => [
|
||||
{
|
||||
type: 'selection',
|
||||
align: 'center',
|
||||
width: 48
|
||||
},
|
||||
{
|
||||
key: 'index',
|
||||
title: $t('common.index'),
|
||||
@ -65,11 +60,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
callback();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<StatusSwitch v-model:value={row.jobStatus} onFetch={fetchFn} />
|
||||
</>
|
||||
);
|
||||
return <StatusSwitch v-model:value={row.jobStatus} onFetch={fetchFn} />;
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -167,6 +158,16 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
<NPopconfirm onPositiveClick={() => handleTriggerJob(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmExecute'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.execute')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -180,28 +181,28 @@ const {
|
||||
handleAdd,
|
||||
handleEdit,
|
||||
checkedRowKeys,
|
||||
onBatchDeleted,
|
||||
onDeleted
|
||||
// closeDrawer
|
||||
} = useTableOperate(data, getData);
|
||||
|
||||
async function handleBatchDelete() {
|
||||
// request
|
||||
console.log(checkedRowKeys.value);
|
||||
|
||||
onBatchDeleted();
|
||||
}
|
||||
|
||||
function handleDelete(id: string) {
|
||||
// request
|
||||
console.log(id);
|
||||
|
||||
async function handleDelete(id: string) {
|
||||
const { error } = await fetchDeleteJob(id);
|
||||
if (error) return;
|
||||
onDeleted();
|
||||
}
|
||||
|
||||
function edit(id: string) {
|
||||
handleEdit(id);
|
||||
}
|
||||
|
||||
async function handleTriggerJob(id: string) {
|
||||
const { error } = await fetchTriggerJob(id);
|
||||
if (error) {
|
||||
window.$message?.success($t('common.executeSuccess'));
|
||||
} else {
|
||||
window.$message?.error($t('common.executeFailed'));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -215,14 +216,7 @@ function edit(id: string) {
|
||||
header-class="view-card-header"
|
||||
>
|
||||
<template #header-extra>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
:disabled-delete="checkedRowKeys.length === 0"
|
||||
:loading="loading"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@refresh="getData"
|
||||
/>
|
||||
<TableHeaderOperation :loading="loading" :show-delete="false" @add="handleAdd" @refresh="getData" />
|
||||
</template>
|
||||
<NDataTable
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
|
Loading…
Reference in New Issue
Block a user