diff --git a/apps/web-antd/src/views/infra/job/data.ts b/apps/web-antd/src/views/infra/job/data.ts
index 83a7dfe6b..ef38a68b4 100644
--- a/apps/web-antd/src/views/infra/job/data.ts
+++ b/apps/web-antd/src/views/infra/job/data.ts
@@ -133,14 +133,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'id',
title: '任务编号',
+ minWidth: 80,
},
{
field: 'name',
title: '任务名称',
+ minWidth: 120,
},
{
field: 'status',
title: '任务状态',
+ minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_JOB_STATUS },
@@ -149,14 +152,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'handlerName',
title: '处理器的名字',
+ minWidth: 180,
},
{
field: 'handlerParam',
title: '处理器的参数',
+ minWidth: 140,
},
{
field: 'cronExpression',
title: 'CRON 表达式',
+ minWidth: 120,
},
{
title: '操作',
diff --git a/apps/web-antd/src/views/infra/job/index.vue b/apps/web-antd/src/views/infra/job/index.vue
index 05ed776da..f7514202f 100644
--- a/apps/web-antd/src/views/infra/job/index.vue
+++ b/apps/web-antd/src/views/infra/job/index.vue
@@ -39,7 +39,7 @@ const [DetailModal, detailModalApi] = useVbenModal({
});
/** 刷新表格 */
-function onRefresh() {
+function handleRefresh() {
gridApi.query();
}
@@ -72,24 +72,33 @@ async function handleUpdateStatus(row: InfraJobApi.Job) {
: InfraJobStatusEnum.STOP;
const statusText = status === InfraJobStatusEnum.NORMAL ? '启用' : '停用';
- confirm({
- content: `确定${statusText} ${row.name} 吗?`,
- }).then(async () => {
- await updateJobStatus(row.id as number, status);
- // 提示成功
- message.success($t('ui.actionMessage.operationSuccess'));
- onRefresh();
+ await confirm(`确定${statusText} ${row.name} 吗?`);
+ const hideLoading = message.loading({
+ content: `正在${statusText}中...`,
+ duration: 0,
});
+ try {
+ await updateJobStatus(row.id!, status);
+ message.success($t('ui.actionMessage.operationSuccess'));
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
}
/** 执行一次任务 */
async function handleTrigger(row: InfraJobApi.Job) {
- confirm({
- content: `确定执行一次 ${row.name} 吗?`,
- }).then(async () => {
- await runJob(row.id as number);
- message.success($t('ui.actionMessage.operationSuccess'));
+ await confirm(`确定执行一次 ${row.name} 吗?`);
+ const hideLoading = message.loading({
+ content: '正在执行中...',
+ duration: 0,
});
+ try {
+ await runJob(row.id!);
+ message.success($t('ui.actionMessage.operationSuccess'));
+ } finally {
+ hideLoading();
+ }
}
/** 跳转到任务日志 */
@@ -105,12 +114,28 @@ async function handleDelete(row: InfraJobApi.Job) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]),
duration: 0,
- key: 'action_process_msg',
});
try {
- await deleteJob(row.id as number);
+ await deleteJob(row.id!);
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
- onRefresh();
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+/** 批量删除任务 */
+async function handleDeleteBatch() {
+ await confirm($t('ui.actionMessage.deleteBatchConfirm'));
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deletingBatch'),
+ duration: 0,
+ });
+ try {
+ await deleteJobList(checkedIds.value);
+ checkedIds.value = [];
+ message.success($t('ui.actionMessage.deleteSuccess'));
+ handleRefresh();
} finally {
hideLoading();
}
@@ -121,23 +146,6 @@ function handleRowCheckboxChange({ records }: { records: InfraJobApi.Job[] }) {
checkedIds.value = records.map((item) => item.id!);
}
-/** 批量删除任务 */
-async function handleDeleteBatch() {
- const hideLoading = message.loading({
- content: $t('ui.actionMessage.deleting'),
- duration: 0,
- key: 'action_process_msg',
- });
- try {
- await deleteJobList(checkedIds.value);
- checkedIds.value = [];
- message.success($t('ui.actionMessage.deleteSuccess'));
- onRefresh();
- } finally {
- hideLoading();
- }
-}
-
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
@@ -181,7 +189,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
-
+
@@ -205,15 +213,15 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: '执行日志',
type: 'primary',
icon: 'lucide:history',
- auth: ['infra:job:export'],
- onClick: handleLog,
+ auth: ['infra:job:query'],
+ onClick: () => handleLog(undefined),
},
{
- label: '批量删除',
+ label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
- disabled: isEmpty(checkedIds),
icon: ACTION_ICON.DELETE,
+ disabled: isEmpty(checkedIds),
auth: ['infra:job:delete'],
onClick: handleDeleteBatch,
},
diff --git a/apps/web-ele/src/views/infra/job/data.ts b/apps/web-ele/src/views/infra/job/data.ts
index 007d80efe..14e0f1c78 100644
--- a/apps/web-ele/src/views/infra/job/data.ts
+++ b/apps/web-ele/src/views/infra/job/data.ts
@@ -1,13 +1,9 @@
import type { VbenFormSchema } from '#/adapter/form';
-import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
-import type { InfraJobApi } from '#/api/infra/job';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
-import { useAccess } from '@vben/access';
-import { DICT_TYPE, InfraJobStatusEnum } from '@vben/constants';
+import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
-const { hasAccessByCodes } = useAccess();
-
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
@@ -34,10 +30,12 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'Input',
componentProps: {
placeholder: '请输入处理器的名字',
- // readonly: ({ values }) => !!values.id,
+ },
+ dependencies: {
+ triggerFields: ['id'],
+ disabled: (values) => !!values.id,
},
rules: 'required',
- // TODO @芋艿:在修改场景下,禁止调整
},
{
fieldName: 'handlerParam',
@@ -124,9 +122,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
}
/** 表格列配置 */
-export function useGridColumns(
- onActionClick: OnActionClickFn,
-): VxeTableGridOptions['columns'] {
+export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{ type: 'checkbox', width: 40 },
{
@@ -164,59 +160,10 @@ export function useGridColumns(
minWidth: 120,
},
{
- field: 'operation',
title: '操作',
- width: 280,
+ width: 240,
fixed: 'right',
- align: 'center',
- cellRender: {
- attrs: {
- nameField: 'name',
- nameTitle: '任务',
- onClick: onActionClick,
- },
- name: 'CellOperation',
- options: [
- {
- code: 'edit',
- show: hasAccessByCodes(['infra:job:update']),
- },
- {
- code: 'update-status',
- text: '开启',
- show: (row: any) =>
- hasAccessByCodes(['infra:job:update']) &&
- row.status === InfraJobStatusEnum.STOP,
- },
- {
- code: 'update-status',
- text: '暂停',
- show: (row: any) =>
- hasAccessByCodes(['infra:job:update']) &&
- row.status === InfraJobStatusEnum.NORMAL,
- },
- {
- code: 'trigger',
- text: '执行',
- show: hasAccessByCodes(['infra:job:trigger']),
- },
- // TODO @芋艿:增加一个“更多”选项
- {
- code: 'detail',
- text: '详细',
- show: hasAccessByCodes(['infra:job:query']),
- },
- {
- code: 'log',
- text: '日志',
- show: hasAccessByCodes(['infra:job:query']),
- },
- {
- code: 'delete',
- show: hasAccessByCodes(['infra:job:delete']),
- },
- ],
- },
+ slots: { default: 'actions' },
},
];
}
diff --git a/apps/web-ele/src/views/infra/job/index.vue b/apps/web-ele/src/views/infra/job/index.vue
index ae1400568..47b7affe2 100644
--- a/apps/web-ele/src/views/infra/job/index.vue
+++ b/apps/web-ele/src/views/infra/job/index.vue
@@ -1,8 +1,5 @@