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