|
|
@@ -0,0 +1,360 @@
|
|
|
+import type {
|
|
|
+ OnActionClickFn,
|
|
|
+ VbenFormSchema,
|
|
|
+ VxeTableGridOptions,
|
|
|
+} from '#/adapter';
|
|
|
+
|
|
|
+import { h } from 'vue';
|
|
|
+
|
|
|
+import { JobTriggerApi } from '#/api';
|
|
|
+import { boolOptions } from '#/api/model';
|
|
|
+import { BcCrontab } from '#/components/bc-crontab';
|
|
|
+
|
|
|
+export const triggerStatusOptions = [
|
|
|
+ { color: '#3399CC', label: '积压', value: 0 },
|
|
|
+ { color: '#FFCC99', label: '就绪', value: 1 },
|
|
|
+ { color: '#99CCCC', label: '正在运行', value: 2 },
|
|
|
+ { color: '#3399CC', label: '暂停', value: 3 },
|
|
|
+ { color: '#FFCC99', label: '阻塞', value: 4 },
|
|
|
+ { color: '#99CCCC', label: '由失败进入就绪', value: 5 },
|
|
|
+ { color: '#3399CC', label: '归档', value: 6 },
|
|
|
+ { color: '#FFCC99', label: '崩溃', value: 7 },
|
|
|
+ { color: '#99CCCC', label: '超限', value: 8 },
|
|
|
+ { color: '#3399CC', label: '无触发时间', value: 9 },
|
|
|
+ { color: '#FFCC99', label: '未启动', value: 10 },
|
|
|
+ { color: '#99CCCC', label: '未知作业触发器', value: 11 },
|
|
|
+ { color: '#99CCCC', label: '未知作业处理程序', value: 12 },
|
|
|
+];
|
|
|
+
|
|
|
+export const triggerTypeOptions = [
|
|
|
+ { color: '#3399CC', label: '间隔', value: 'Furion.Schedule.PeriodTrigger' },
|
|
|
+ {
|
|
|
+ color: '#FFCC99',
|
|
|
+ label: 'Cron表达式',
|
|
|
+ value: 'Furion.Schedule.CronTrigger',
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+export function useColumns(
|
|
|
+ onActionClick?: OnActionClickFn<JobTriggerApi.RecordItem>,
|
|
|
+): VxeTableGridOptions<JobTriggerApi.RecordItem>['columns'] {
|
|
|
+ return [
|
|
|
+ { title: '序号', type: 'seq', width: 50 },
|
|
|
+ {
|
|
|
+ align: 'left',
|
|
|
+ field: 'triggerId',
|
|
|
+ title: '触发器编号',
|
|
|
+ width: 120,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ align: 'center',
|
|
|
+ field: 'triggerType',
|
|
|
+ title: '类型',
|
|
|
+ width: 90,
|
|
|
+ cellRender: {
|
|
|
+ name: 'CellTag',
|
|
|
+ options: triggerTypeOptions,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { align: 'left', field: 'args', title: '参数', width: 200 },
|
|
|
+ { align: 'left', field: 'description', title: '描述', minWidth: 200 },
|
|
|
+ {
|
|
|
+ align: 'center',
|
|
|
+ field: 'status',
|
|
|
+ title: '状态',
|
|
|
+ width: 90,
|
|
|
+ cellRender: {
|
|
|
+ name: 'CellTag',
|
|
|
+ options: triggerStatusOptions,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ align: 'left',
|
|
|
+ field: 'startTime',
|
|
|
+ title: '起始时间',
|
|
|
+ width: 150,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ align: 'left',
|
|
|
+ field: 'endTime',
|
|
|
+ title: '结束时间',
|
|
|
+ width: 150,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'group1',
|
|
|
+ title: '运行时间',
|
|
|
+ headerAlign: 'center',
|
|
|
+ children: [
|
|
|
+ { field: 'lastRunTime', title: '最近', width: 150, align: 'left' },
|
|
|
+ { field: 'nextRunTime', title: '下一次', width: 150, align: 'left' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'group2',
|
|
|
+ title: '触发',
|
|
|
+ headerAlign: 'center',
|
|
|
+ children: [
|
|
|
+ { field: 'numberOfRuns', title: '次数', width: 80, align: 'right' },
|
|
|
+ { field: 'maxNumberOfRuns', title: '最大', width: 80, align: 'right' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'group3',
|
|
|
+ title: '出错',
|
|
|
+ headerAlign: 'center',
|
|
|
+ children: [
|
|
|
+ { field: 'numberOfErrors', title: '次数', width: 80, align: 'right' },
|
|
|
+ {
|
|
|
+ field: 'maxNumberOfErrors',
|
|
|
+ title: '最大',
|
|
|
+ width: 80,
|
|
|
+ align: 'right',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'group4',
|
|
|
+ title: '重试',
|
|
|
+ headerAlign: 'center',
|
|
|
+ children: [
|
|
|
+ { field: 'numRetries', title: '次数', width: 80, align: 'right' },
|
|
|
+ { field: 'retryTimeout', title: '间隔ms', width: 80, align: 'right' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'startNow',
|
|
|
+ title: '立即启动',
|
|
|
+ align: 'center',
|
|
|
+ width: 80,
|
|
|
+ cellRender: {
|
|
|
+ name: 'CellTag',
|
|
|
+ options: boolOptions,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'runOnStart',
|
|
|
+ title: '启动时执行一次',
|
|
|
+ align: 'center',
|
|
|
+ width: 120,
|
|
|
+ cellRender: {
|
|
|
+ name: 'CellTag',
|
|
|
+ options: boolOptions,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'resetOnlyOnce',
|
|
|
+ title: '重置触发次数',
|
|
|
+ align: 'center',
|
|
|
+ width: 100,
|
|
|
+ cellRender: {
|
|
|
+ name: 'CellTag',
|
|
|
+ options: boolOptions,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ align: 'right',
|
|
|
+ cellRender: {
|
|
|
+ attrs: {
|
|
|
+ nameField: 'triggerId',
|
|
|
+ nameTitle: '触发器',
|
|
|
+ onClick: onActionClick,
|
|
|
+ },
|
|
|
+ name: 'CellAction',
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ code: 'execute',
|
|
|
+ label: '执行',
|
|
|
+ auth: ['jog-trigger:execute'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'edit',
|
|
|
+ auth: ['jog-trigger:edit'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'start',
|
|
|
+ label: '启动触发器',
|
|
|
+ auth: ['jog-trigger:start'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'pause',
|
|
|
+ label: '暂停触发器',
|
|
|
+ auth: ['jog-trigger:pause'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'cancel',
|
|
|
+ label: '取消触发器',
|
|
|
+ auth: ['jog-trigger:cancel'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'record',
|
|
|
+ label: '执行记录',
|
|
|
+ auth: ['jog-record:view'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'delete',
|
|
|
+ auth: ['jog-trigger:delete'],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ field: 'operation',
|
|
|
+ fixed: 'right',
|
|
|
+ headerAlign: 'center',
|
|
|
+ showOverflow: false,
|
|
|
+ title: '操作',
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+}
|
|
|
+
|
|
|
+export const useSchema = (): VbenFormSchema[] => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ },
|
|
|
+ fieldName: 'triggerId',
|
|
|
+ label: '触发器编号',
|
|
|
+ rules: 'required',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Select',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请选择',
|
|
|
+ options: triggerTypeOptions,
|
|
|
+ },
|
|
|
+ fieldName: 'triggerType',
|
|
|
+ label: '触发器类型',
|
|
|
+ rules: 'required',
|
|
|
+ defaultValue: triggerTypeOptions[0]?.value,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'InputNumber',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ addonAfter: 'ms',
|
|
|
+ },
|
|
|
+ fieldName: 'periodValue',
|
|
|
+ label: '间隔时间',
|
|
|
+ rules: 'required',
|
|
|
+ dependencies: {
|
|
|
+ show: (values) => {
|
|
|
+ return values.triggerType === triggerTypeOptions[0]?.value;
|
|
|
+ },
|
|
|
+ triggerFields: ['triggerType'],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: h(BcCrontab, { placeholder: '请输入' }),
|
|
|
+ fieldName: 'cronValue',
|
|
|
+ label: 'Cron表达式',
|
|
|
+ rules: 'required',
|
|
|
+ dependencies: {
|
|
|
+ show: (values) => {
|
|
|
+ return values.triggerType === triggerTypeOptions[1]?.value;
|
|
|
+ },
|
|
|
+ triggerFields: ['triggerType'],
|
|
|
+ },
|
|
|
+ formItemClass: 'col-span-2',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'DatePicker',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ showTime: true,
|
|
|
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
|
+ },
|
|
|
+ fieldName: 'startTime',
|
|
|
+ label: '起始时间',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'DatePicker',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ showTime: true,
|
|
|
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
|
+ },
|
|
|
+ fieldName: 'endTime',
|
|
|
+ label: '结束时间',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'InputNumber',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ },
|
|
|
+ fieldName: 'maxNumberOfRuns',
|
|
|
+ label: '最大触发次数',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'InputNumber',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ },
|
|
|
+ fieldName: 'maxNumberOfErrors',
|
|
|
+ label: '最大出错次数',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'InputNumber',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ },
|
|
|
+ fieldName: 'numRetries',
|
|
|
+ label: '重试次数',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'InputNumber',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ addonAfter: 'ms',
|
|
|
+ },
|
|
|
+ fieldName: 'retryTimeout',
|
|
|
+ label: '重试间隔',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'RadioGroup',
|
|
|
+ componentProps: {
|
|
|
+ optionType: 'button',
|
|
|
+ buttonStyle: 'solid',
|
|
|
+ autoSelect: 'first',
|
|
|
+ options: boolOptions,
|
|
|
+ },
|
|
|
+ fieldName: 'startNow',
|
|
|
+ label: '立即启动',
|
|
|
+ defaultValue: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'RadioGroup',
|
|
|
+ componentProps: {
|
|
|
+ optionType: 'button',
|
|
|
+ buttonStyle: 'solid',
|
|
|
+ autoSelect: 'first',
|
|
|
+ options: boolOptions,
|
|
|
+ },
|
|
|
+ fieldName: 'runOnStart',
|
|
|
+ label: '启动时执行一次',
|
|
|
+ defaultValue: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'RadioGroup',
|
|
|
+ componentProps: {
|
|
|
+ optionType: 'button',
|
|
|
+ buttonStyle: 'solid',
|
|
|
+ autoSelect: 'first',
|
|
|
+ options: boolOptions,
|
|
|
+ },
|
|
|
+ fieldName: 'resetOnlyOnce',
|
|
|
+ label: '重置触发次数',
|
|
|
+ help: '是否在启动时重置最大触发次数等于一次的作业,解决因持久化数据已完成一次触发但启动时不再执行的问题',
|
|
|
+ defaultValue: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ },
|
|
|
+ fieldName: 'description',
|
|
|
+ label: '描述信息',
|
|
|
+ formItemClass: 'col-span-2',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+};
|