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