feat: 定时任务添加[停止][执行]按钮
This commit is contained in:
parent
cd928ef59b
commit
bb3d1d7e9a
@ -56,13 +56,17 @@ const local: App.I18n.Schema = {
|
||||
resume: 'Resume',
|
||||
pause: 'Pause',
|
||||
finish: 'Finish',
|
||||
retry: 'Retry',
|
||||
running: 'Running',
|
||||
operateSuccess: 'Operate successfully',
|
||||
operateFailed: 'Operate failed',
|
||||
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?',
|
||||
confirmFinish: 'Are you sure you want to finishe?',
|
||||
confirmRetry: 'Are you sure you want to retry?',
|
||||
yesOrNo: {
|
||||
yes: 'Yes',
|
||||
no: 'No'
|
||||
|
@ -56,13 +56,17 @@ const local: App.I18n.Schema = {
|
||||
resume: '恢复',
|
||||
pause: '暂停',
|
||||
finish: '完成',
|
||||
retry: '重试',
|
||||
running: '运行中',
|
||||
operateSuccess: '操作成功',
|
||||
operateFailed: '操作失败',
|
||||
executeSuccess: '执行成功',
|
||||
executeFailed: '执行失败',
|
||||
confirmExecute: '确认执行吗?',
|
||||
confirmResume: '确认恢复吗?',
|
||||
confirmPause: '确认暂停吗?',
|
||||
confirmFinish: '确认完成吗?',
|
||||
confirmRetry: '确认重试吗?',
|
||||
yesOrNo: {
|
||||
yes: '是',
|
||||
no: '否'
|
||||
|
@ -15,3 +15,19 @@ export function fetchGetJobBatchDetail(id: string) {
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/** stop job */
|
||||
export function fetchJobBatchStop(jobId: string) {
|
||||
return request<boolean>({
|
||||
url: `/job/batch/stop/${jobId}`,
|
||||
method: 'post'
|
||||
});
|
||||
}
|
||||
|
||||
/** retry job */
|
||||
export function fetchJobBatchRetry(jobId: string) {
|
||||
return request<boolean>({
|
||||
url: `/job/batch/retry/${jobId}`,
|
||||
method: 'post'
|
||||
});
|
||||
}
|
||||
|
4
src/typings/app.d.ts
vendored
4
src/typings/app.d.ts
vendored
@ -306,13 +306,17 @@ declare namespace App {
|
||||
resume: string;
|
||||
pause: string;
|
||||
finish: string;
|
||||
retry: string;
|
||||
running: string;
|
||||
operateSuccess: string;
|
||||
operateFailed: string;
|
||||
executeSuccess: string;
|
||||
executeFailed: string;
|
||||
confirmExecute: string;
|
||||
confirmResume: string;
|
||||
confirmPause: string;
|
||||
confirmFinish: string;
|
||||
confirmRetry: string;
|
||||
yesOrNo: {
|
||||
yes: string;
|
||||
no: string;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NTag } from 'naive-ui';
|
||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { fetchGetJobBatchList, fetchGetJobNameList } from '@/service/api';
|
||||
import { fetchGetJobBatchList, fetchGetJobNameList, fetchJobBatchRetry, fetchJobBatchStop } from '@/service/api';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable } from '@/hooks/common/table';
|
||||
@ -87,17 +87,54 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
|
||||
width: 130,
|
||||
render: row => (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="primary" ghost size="small" onClick={() => detail(row.id!)}>
|
||||
{$t('common.detail')}
|
||||
</NButton>
|
||||
{row.taskBatchStatus === 1 || row.taskBatchStatus === 2 ? (
|
||||
<NPopconfirm onPositiveClick={() => handleStopJob(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmStop'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.stop')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{row.taskBatchStatus === 4 || row.taskBatchStatus === 5 || row.taskBatchStatus === 6 ? (
|
||||
<NPopconfirm onPositiveClick={() => handleRetryJob(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmRetry'),
|
||||
trigger: () => (
|
||||
<NButton type="warning" ghost size="small">
|
||||
{$t('common.retry')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
function detail(id: string) {
|
||||
console.log(id);
|
||||
async function handleRetryJob(id: string) {
|
||||
const { error } = await fetchJobBatchRetry(id);
|
||||
if (!error) {
|
||||
window.$message?.success($t('common.operateSuccess'));
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
async function handleStopJob(id: string) {
|
||||
const { error } = await fetchJobBatchStop(id);
|
||||
if (!error) {
|
||||
window.$message?.success($t('common.operateSuccess'));
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
/** 处理路由 query 参数变化 */
|
||||
|
Loading…
Reference in New Issue
Block a user