From d114a844ed7c4e14113a296f6a35e1ec162e1902 Mon Sep 17 00:00:00 2001
From: opensnail <598092184@qq.com>
Date: Wed, 24 Apr 2024 21:44:33 +0800
Subject: [PATCH] =?UTF-8?q?feat(sj=5F1.0.0):=20=E5=AE=9A=E4=B9=89job?=
=?UTF-8?q?=E7=8A=B6=E6=80=81=E5=92=8C=E6=93=8D=E4=BD=9C=E5=8E=9F=E5=9B=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/common/operation-reason.vue | 29 ++++++++++
src/components/common/route-key.vue | 29 ++++++++++
src/components/common/task-batch-status.vue | 29 ++++++++++
src/constants/business.ts | 47 ++++++++++++++--
src/locales/langs/en-us.ts | 56 ++++++++++++++++---
src/locales/langs/zh-cn.ts | 56 ++++++++++++++++---
src/service/api/job-task.ts | 8 +--
src/typings/api.d.ts | 34 +++++++----
src/typings/app.d.ts | 54 ++++++++++++++++--
.../task/modules/job-task-operate-drawer.vue | 4 +-
.../job/task/modules/job-task-search.vue | 2 +-
.../scene/modules/scene-operate-drawer.vue | 17 ++----
.../retry/scene/modules/scene-search.vue | 39 -------------
.../batch/modules/workflow-batch-search.vue | 9 +--
src/views/workflow/task/index.vue | 23 +++++++-
.../workflow/task/modules/workflow-search.vue | 4 +-
16 files changed, 336 insertions(+), 104 deletions(-)
create mode 100644 src/components/common/operation-reason.vue
create mode 100644 src/components/common/route-key.vue
create mode 100644 src/components/common/task-batch-status.vue
diff --git a/src/components/common/operation-reason.vue b/src/components/common/operation-reason.vue
new file mode 100644
index 0000000..1bb3628
--- /dev/null
+++ b/src/components/common/operation-reason.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
diff --git a/src/components/common/route-key.vue b/src/components/common/route-key.vue
new file mode 100644
index 0000000..679a1ad
--- /dev/null
+++ b/src/components/common/route-key.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
diff --git a/src/components/common/task-batch-status.vue b/src/components/common/task-batch-status.vue
new file mode 100644
index 0000000..a84af72
--- /dev/null
+++ b/src/components/common/task-batch-status.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
diff --git a/src/constants/business.ts b/src/constants/business.ts
index c6e5b9d..27eb553 100644
--- a/src/constants/business.ts
+++ b/src/constants/business.ts
@@ -116,11 +116,11 @@ export const backOffRecord: Record = {
};
export const backOffRecordOptions = transformRecordToNumberOption(backOffRecord, true);
-export const routeKeyRecord: Record = {
- 1: 'page.retryScene.routeKeyItem.consistentHash',
- 2: 'page.retryScene.routeKeyItem.random',
- 3: 'page.retryScene.routeKeyItem.lru',
- 4: 'page.retryScene.routeKeyItem.round'
+export const routeKeyRecord: Record = {
+ 1: 'common.routeKey.items.consistentHash',
+ 2: 'common.routeKey.items.random',
+ 3: 'common.routeKey.items.lru',
+ 4: 'common.routeKey.items.round'
};
export const routeKeyRecordOptions = transformRecordToNumberOption(routeKeyRecord, true);
@@ -153,3 +153,40 @@ export const DelayLevel: Record = {
25: '11h',
26: '12h'
};
+
+export const triggerTypeRecord: Record = {
+ 2: 'page.jobTask.triggerTypeItem.fixed',
+ 3: 'page.jobTask.triggerTypeItem.cron',
+ // 只会在定时任务中使用
+ 99: 'page.jobTask.triggerTypeItem.workflow'
+};
+export const triggerTypeOptions = transformRecordToNumberOption(triggerTypeRecord, true);
+
+export const taskBatchStatusRecord: Record = {
+ 1: 'common.taskBatchStatus.items.waiting',
+ 2: 'common.taskBatchStatus.items.running',
+ 3: 'common.taskBatchStatus.items.success',
+ 4: 'common.taskBatchStatus.items.fail',
+ 5: 'common.taskBatchStatus.items.stop',
+ 6: 'common.taskBatchStatus.items.cancel'
+};
+export const taskBatchStatusRecordOptions = transformRecordToNumberOption(taskBatchStatusRecord, true);
+
+export const operationReasonRecord: Record = {
+ 0: 'common.jobOperationReason.items.none',
+ 1: 'common.jobOperationReason.items.taskExecutionTimeout',
+ 2: 'common.jobOperationReason.items.notClient',
+ 3: 'common.jobOperationReason.items.closed',
+ 4: 'common.jobOperationReason.items.discard',
+ 5: 'common.jobOperationReason.items.overlay',
+ 6: 'common.jobOperationReason.items.notExecutionTask',
+ 7: 'common.jobOperationReason.items.taskExecutionError',
+ 8: 'common.jobOperationReason.items.mannerStop',
+ 9: 'common.jobOperationReason.items.workflowConditionNodeExecutionError',
+ 10: 'common.jobOperationReason.items.jobTaskInterrupted',
+ 11: 'common.jobOperationReason.items.workflowCallbackNodeExecutionError',
+ 12: 'common.jobOperationReason.items.workflowNodeNoRequired',
+ 13: 'common.jobOperationReason.items.workflowNodeClosedSkipExecution',
+ 14: 'common.jobOperationReason.items.workflowDecisionFailed'
+};
+export const operationReasonOptions = transformRecordToNumberOption(operationReasonRecord, true);
diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts
index c369910..731e679 100644
--- a/src/locales/langs/en-us.ts
+++ b/src/locales/langs/en-us.ts
@@ -62,6 +62,49 @@ const local: App.I18n.Schema = {
callback: 'Callback task',
job: 'Job task',
workflow: 'Workflow'
+ },
+ routeKey: {
+ routeLabel: '路由策略',
+ routeForm: '请输入路由策略',
+ items: {
+ consistentHash: '一致性哈希',
+ random: '随机',
+ lru: 'LRU',
+ round: '轮询'
+ }
+ },
+ taskBatchStatus: {
+ label: '执行状态',
+ form: '请选择执行状态',
+ items: {
+ waiting: '待处理',
+ running: '运行中',
+ success: '处理成功',
+ fail: '处理失败',
+ stop: '任务停止',
+ cancel: '取消'
+ }
+ },
+ jobOperationReason: {
+ label: '操作原因',
+ form: '请选择执行状态',
+ items: {
+ none: '',
+ taskExecutionTimeout: '任务执行超时',
+ notClient: '无客户端节点',
+ closed: '任务已关闭',
+ discard: '任务丢弃',
+ overlay: '任务被覆盖',
+ notExecutionTask: '无可执行任务项',
+ taskExecutionError: '任务执行期间发生非预期异常',
+ mannerStop: '手动停止',
+ workflowConditionNodeExecutionError: '条件节点执行异常',
+ jobTaskInterrupted: '任务中断',
+ workflowCallbackNodeExecutionError: '回调节点执行异常',
+ workflowNodeNoRequired: '无需处理',
+ workflowNodeClosedSkipExecution: '节点关闭跳过执行',
+ workflowDecisionFailed: '判定未通过'
+ }
}
},
request: {
@@ -695,12 +738,6 @@ const local: App.I18n.Schema = {
fixed: '固定时间',
cron: 'CRON表达式',
random: '随机等待'
- },
- routeKeyItem: {
- consistentHash: '一致性哈希',
- random: '随机',
- lru: 'LRU',
- round: '轮询'
}
},
workflowBatch: {
@@ -778,7 +815,12 @@ const local: App.I18n.Schema = {
retryInterval: 'Please enter retry interval'
},
addJobTask: 'Add job task',
- editJobTask: 'Edit job task'
+ editJobTask: 'Edit job task',
+ triggerTypeItem: {
+ fixed: '固定时间',
+ cron: 'CRON表达式',
+ workflow: '工作流'
+ }
}
},
form: {
diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts
index 98fddb1..51e91c1 100644
--- a/src/locales/langs/zh-cn.ts
+++ b/src/locales/langs/zh-cn.ts
@@ -62,6 +62,49 @@ const local: App.I18n.Schema = {
callback: '回调任务',
job: '定时任务',
workflow: '工作流'
+ },
+ routeKey: {
+ routeLabel: '路由策略',
+ routeForm: '请输入路由策略',
+ items: {
+ consistentHash: '一致性哈希',
+ random: '随机',
+ lru: 'LRU',
+ round: '轮询'
+ }
+ },
+ taskBatchStatus: {
+ label: '执行状态',
+ form: '请选择执行状态',
+ items: {
+ waiting: '待处理',
+ running: '运行中',
+ success: '处理成功',
+ fail: '处理失败',
+ stop: '任务停止',
+ cancel: '取消'
+ }
+ },
+ jobOperationReason: {
+ label: '操作原因',
+ form: '请选择执行状态',
+ items: {
+ none: '',
+ taskExecutionTimeout: '任务执行超时',
+ notClient: '无客户端节点',
+ closed: '任务已关闭',
+ discard: '任务丢弃',
+ overlay: '任务被覆盖',
+ notExecutionTask: '无可执行任务项',
+ taskExecutionError: '任务执行期间发生非预期异常',
+ mannerStop: '手动停止',
+ workflowConditionNodeExecutionError: '条件节点执行异常',
+ jobTaskInterrupted: '任务中断',
+ workflowCallbackNodeExecutionError: '回调节点执行异常',
+ workflowNodeNoRequired: '无需处理',
+ workflowNodeClosedSkipExecution: '节点关闭跳过执行',
+ workflowDecisionFailed: '判定未通过'
+ }
}
},
request: {
@@ -691,12 +734,6 @@ const local: App.I18n.Schema = {
fixed: '固定时间',
cron: 'CRON表达式',
random: '随机等待'
- },
- routeKeyItem: {
- consistentHash: '一致性哈希',
- random: '随机',
- lru: 'LRU',
- round: '轮询'
}
},
workflow: {
@@ -774,7 +811,12 @@ const local: App.I18n.Schema = {
retryInterval: '请输入重试间隔'
},
addJobTask: '新增定时任务',
- editJobTask: '编辑定时任务'
+ editJobTask: '编辑定时任务',
+ triggerTypeItem: {
+ fixed: '固定时间',
+ cron: 'CRON表达式',
+ workflow: '工作流'
+ }
}
},
form: {
diff --git a/src/service/api/job-task.ts b/src/service/api/job-task.ts
index a320986..36245e4 100644
--- a/src/service/api/job-task.ts
+++ b/src/service/api/job-task.ts
@@ -1,8 +1,8 @@
import { request } from '../request';
/** get JobTask page */
-export function fetchGetJobTaskPage(params?: Api.JobTask.JobTaskSearchParams) {
- return request({
+export function fetchGetJobTaskPage(params?: Api.Job.JobSearchParams) {
+ return request({
url: '/job/page/list',
method: 'get',
params
@@ -10,7 +10,7 @@ export function fetchGetJobTaskPage(params?: Api.JobTask.JobTaskSearchParams) {
}
/** add JobTask */
-export function fetchAddJobTask(params?: Api.JobTask.JobTask) {
+export function fetchAddJobTask(params?: Api.Job.Job) {
return request({
url: '/job/page/list',
method: 'post',
@@ -19,7 +19,7 @@ export function fetchAddJobTask(params?: Api.JobTask.JobTask) {
}
/** edit JobTask */
-export function fetchEditJobTask(params?: Api.JobTask.JobTask) {
+export function fetchEditJobTask(params?: Api.Job.Job) {
return request({
url: '/job/page/list',
method: 'put',
diff --git a/src/typings/api.d.ts b/src/typings/api.d.ts
index 917f3f7..d72ba06 100644
--- a/src/typings/api.d.ts
+++ b/src/typings/api.d.ts
@@ -69,6 +69,18 @@ declare namespace Api {
/** record status */
status?: EnableStatus | null;
} & T;
+
+ /** 1: 一致性Hash 2: 随机 3: LRU 4: 轮询 */
+ type RouteKey = 1 | 2 | 3 | 4;
+
+ /** 1、待处理 2、运行中 3、成功 4、失败 5、停止 6、取消 */
+ type TaskBatchStatus = 1 | 2 | 3 | 4 | 5 | 6;
+
+ /**
+ * 1、任务执行超时 2、无客户端节点 3、JOB已关闭 4、任务丢弃 5、任务被覆盖 6、无可执行任务项 7、任务执行期间发生非预期异常 8、手动停止 9、条件节点执行异常 10、任务中断 11、回调节点执行异常 12、无需处理
+ * 13、节点关闭跳过执行 14、判定未通过
+ */
+ type OperationReason = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14;
}
/**
@@ -730,7 +742,7 @@ declare namespace Api {
/** 退避策略 */
backOff: BackOff;
/** 路由策略 */
- routeKey: RouteKey;
+ routeKey: Common.RouteKey;
/** 最大重试次数 */
maxRetryCount: number;
/** 间隔时间 */
@@ -766,9 +778,6 @@ declare namespace Api {
/** 1: 延迟等级 2: 固定时间 3: CRON表达式 4: 随机等待 */
type BackOff = 1 | 2 | 3 | 4;
-
- /** 1: 一致性Hash 2: 随机 3: LRU 4: 轮询 */
- type RouteKey = 1 | 2 | 3 | 4;
}
/**
@@ -791,7 +800,7 @@ declare namespace Api {
/** 状态 */
workflowStatus: EnableStatusNumber;
/** 触发类型 */
- triggerType: number;
+ triggerType: Job.TriggerType;
/** 间隔时长 */
triggerInterval: string;
/** 超时时间 */
@@ -812,11 +821,11 @@ declare namespace Api {
*
* backend api module: "jobTask"
*/
- namespace JobTask {
+ namespace Job {
type CommonSearchParams = Pick;
- /** JobTask */
- type JobTask = Common.CommonRecord<{
+ /** Job */
+ type Job = Common.CommonRecord<{
/** 组名称 */
groupName: string;
/** 任务名称 */
@@ -858,9 +867,9 @@ declare namespace Api {
}>;
/** JobTask search params */
- type JobTaskSearchParams = CommonType.RecordNullable<
+ type JobSearchParams = CommonType.RecordNullable<
Pick<
- Api.JobTask.JobTask,
+ Api.Job.Job,
| 'groupName'
| 'jobName'
| 'argsStr'
@@ -882,7 +891,10 @@ declare namespace Api {
>;
/** JobTask list */
- type JobTaskList = Common.PaginatingQueryRecord;
+ type JobList = Common.PaginatingQueryRecord;
+
+ /** 2、固定时间 3、CRON表达式 99、工作流 */
+ type TriggerType = 2 | 3 | 99;
}
/**
diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts
index a7a7979..31efad4 100644
--- a/src/typings/app.d.ts
+++ b/src/typings/app.d.ts
@@ -309,6 +309,49 @@ declare namespace App {
job: string;
workflow: string;
};
+ routeKey: {
+ routeLabel: string;
+ routeForm: string;
+ items: {
+ consistentHash: string;
+ random: string;
+ lru: string;
+ round: string;
+ };
+ };
+ taskBatchStatus: {
+ label: string;
+ form: string;
+ items: {
+ waiting: string;
+ running: string;
+ success: string;
+ fail: string;
+ stop: string;
+ cancel: string;
+ };
+ };
+ jobOperationReason: {
+ label: string;
+ form: string;
+ items: {
+ none: string;
+ taskExecutionTimeout: string;
+ notClient: string;
+ closed: string;
+ discard: string;
+ overlay: string;
+ notExecutionTask: string;
+ taskExecutionError: string;
+ mannerStop: string;
+ workflowConditionNodeExecutionError: string;
+ jobTaskInterrupted: string;
+ workflowCallbackNodeExecutionError: string;
+ workflowNodeNoRequired: string;
+ workflowNodeClosedSkipExecution: string;
+ workflowDecisionFailed: string;
+ };
+ };
};
request: {
logout: string;
@@ -859,12 +902,6 @@ declare namespace App {
cron: string;
random: string;
};
- routeKeyItem: {
- consistentHash: string;
- random: string;
- lru: string;
- round: string;
- };
};
workflow: {
title: string;
@@ -942,6 +979,11 @@ declare namespace App {
};
addJobTask: string;
editJobTask: string;
+ triggerTypeItem: {
+ fixed: string;
+ cron: string;
+ workflow: string;
+ };
};
};
form: {
diff --git a/src/views/job/task/modules/job-task-operate-drawer.vue b/src/views/job/task/modules/job-task-operate-drawer.vue
index 51bf6f1..e1474e4 100644
--- a/src/views/job/task/modules/job-task-operate-drawer.vue
+++ b/src/views/job/task/modules/job-task-operate-drawer.vue
@@ -13,7 +13,7 @@ interface Props {
/** the type of operation */
operateType: NaiveUI.TableOperateType;
/** the edit row data */
- rowData?: Api.JobTask.JobTask | null;
+ rowData?: Api.Job.Job | null;
}
const props = defineProps();
@@ -40,7 +40,7 @@ const title = computed(() => {
});
type Model = Pick<
- Api.JobTask.JobTask,
+ Api.Job.Job,
| 'groupName'
| 'jobName'
| 'argsStr'
diff --git a/src/views/job/task/modules/job-task-search.vue b/src/views/job/task/modules/job-task-search.vue
index 99e2a2b..0718679 100644
--- a/src/views/job/task/modules/job-task-search.vue
+++ b/src/views/job/task/modules/job-task-search.vue
@@ -12,7 +12,7 @@ interface Emits {
const emit = defineEmits();
-const model = defineModel('model', { required: true });
+const model = defineModel('model', { required: true });
function reset() {
emit('reset');
diff --git a/src/views/retry/scene/modules/scene-operate-drawer.vue b/src/views/retry/scene/modules/scene-operate-drawer.vue
index 451d934..85cbec8 100644
--- a/src/views/retry/scene/modules/scene-operate-drawer.vue
+++ b/src/views/retry/scene/modules/scene-operate-drawer.vue
@@ -3,14 +3,10 @@ import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
import CronInput from '@sa/cron-input';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue';
+import RouteKey from '@/components/common/route-key.vue';
import { $t } from '@/locales';
import { fetchAddRetryScene, fetchEditRetryScene, fetchGetAllGroupNameList } from '@/service/api';
-import {
- DelayLevel,
- backOffRecordOptions,
- enableStatusNumberOptions,
- routeKeyRecordOptions
-} from '@/constants/business';
+import { DelayLevel, backOffRecordOptions, enableStatusNumberOptions } from '@/constants/business';
import { translateOptions, translateOptions2 } from '@/utils/common';
import { useAppStore } from '@/store/modules/app';
@@ -265,13 +261,8 @@ watch(
clearable
/>
-
-
+
+
();
const model = defineModel('model', { required: true });
-/** 组列表 */
-// const groupNameList = ref([]);
-/** 场景列表 */
-// const sceneNameList = ref([]);
-
-// async function getGroupNameList() {
-// const res = await fetchGetAllGroupNameList();
-// groupNameList.value = res.data as string[];
-// }
-
function reset() {
emit('reset');
}
@@ -33,43 +23,14 @@ function reset() {
function search() {
emit('search');
}
-
-// async function handleGroupNameUpdate(groupName: string) {
-// if (groupName) {
-// const res = await fetchGetRetrySceneList({ groupName });
-// sceneNameList.value = res.data!.map((scene: Api.RetryScene.Scene) => scene.sceneName);
-// } else {
-// model.value.sceneName = '';
-// sceneNameList.value = [];
-// }
-// }
-
-// onMounted(() => {
-// getGroupNameList();
-// });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/views/workflow/batch/modules/workflow-batch-search.vue b/src/views/workflow/batch/modules/workflow-batch-search.vue
index 54c80f0..65adea4 100644
--- a/src/views/workflow/batch/modules/workflow-batch-search.vue
+++ b/src/views/workflow/batch/modules/workflow-batch-search.vue
@@ -2,6 +2,7 @@
import { ref } from 'vue';
import { $t } from '@/locales';
import SelectGroup from '@/components/common/select-group.vue';
+import TaskBatchStatus from '@/components/common/task-batch-status.vue';
import { fetchGetWorkflowNameList } from '@/service/api';
@@ -36,10 +37,10 @@ async function groupNameUpdate(groupName: string) {
-
+
-
+
-
-
+
+
diff --git a/src/views/workflow/task/index.vue b/src/views/workflow/task/index.vue
index cba9fa2..6327d31 100644
--- a/src/views/workflow/task/index.vue
+++ b/src/views/workflow/task/index.vue
@@ -1,9 +1,10 @@