From 184ca551ce98b6b54c1d21649eea3e7220b9caab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E7=BA=A2=E4=B8=BD?= <1181930680@qq.com>
Date: Mon, 29 Jul 2024 09:08:37 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/monitor/job.ts | 10 ++++
src/views/monitor/job/columns.ts | 47 +++++++++--------
src/views/monitor/job/index.vue | 88 ++++++++++++++++++--------------
3 files changed, 86 insertions(+), 59 deletions(-)
diff --git a/src/api/monitor/job.ts b/src/api/monitor/job.ts
index 59a4a89..3bcdcbf 100644
--- a/src/api/monitor/job.ts
+++ b/src/api/monitor/job.ts
@@ -74,6 +74,16 @@ export function getJobRunOnce(id) {
method: 'get',
});
}
+/**
+ * @description: 设置状态
+ */
+export function setJobStatus(data:any) {
+ return http.request({
+ url: '/job/status',
+ method: 'post',
+ data
+ });
+}
/**
* @description: 暂停任务
*/
diff --git a/src/views/monitor/job/columns.ts b/src/views/monitor/job/columns.ts
index 079f791..c7a24e6 100644
--- a/src/views/monitor/job/columns.ts
+++ b/src/views/monitor/job/columns.ts
@@ -23,26 +23,31 @@ export const columns = [
},
{
label: '状态',
- prop: 'status',
- render(record) {
- let typeText = ''
- switch (record.row.status) {
- case 0:
- typeText='未发布'
- break;
- case 1:
- typeText='运行中'
- break;
- case 2:
- typeText='暂停'
- break;
- case 3:
- typeText='删除'
- break;
- default:
- break;
- }
- return h('span', typeText || '-');
- },
+ isSlot:true,
+ value:'status'
},
+ // {
+ // label: '状态',
+ // prop: 'status',
+ // render(record) {
+ // let typeText = ''
+ // switch (record.row.status) {
+ // case 0:
+ // typeText='未发布'
+ // break;
+ // case 1:
+ // typeText='运行中'
+ // break;
+ // case 2:
+ // typeText='暂停'
+ // break;
+ // case 3:
+ // typeText='删除'
+ // break;
+ // default:
+ // break;
+ // }
+ // return h('span', typeText || '-');
+ // },
+ // },
];
diff --git a/src/views/monitor/job/index.vue b/src/views/monitor/job/index.vue
index 903996c..0771f21 100644
--- a/src/views/monitor/job/index.vue
+++ b/src/views/monitor/job/index.vue
@@ -13,7 +13,7 @@
@selection-change="onSelectionChange"
>
-
+
@@ -21,7 +21,7 @@
添加任务
-
+
@@ -30,9 +30,9 @@
删除
-
+
+
+
@@ -57,7 +57,7 @@
import { schemas } from './querySchemas';
import { useForm } from '@/components/Form/index';
import { TableAction } from '@/components/Table';
- import { getJobList,jobDelete,jobBatchDelete,getJobRunOnce,getJobPause,getJobResume } from '@/api/monitor/job';
+ import { getJobList,jobDelete,jobBatchDelete,getJobRunOnce,setJobStatus,getJobPause,getJobResume } from '@/api/monitor/job';
import { columns } from './columns';
import { PlusOutlined } from '@vicons/antd';
import {message,confirm} from "@/utils/auth";
@@ -87,56 +87,57 @@ const selectionData = ref([])
return h(TableAction, {
style: 'button',
actions: [
-
- {
- label: '编辑',
- type: 'warning',
- onClick: handleEdit.bind(null, record),
- ifShow: () => {
- return true;
- },
- // auth: ['basic_list'],
- },
- {
- label: '删除',
- type: 'danger',
- onClick: handleDelete.bind(null, record),
- // 根据业务控制是否显示 isShow 和 auth 是并且关系
- ifShow: () => {
- return true;
- },
- // 根据权限控制是否显示: 有权限,会显示,支持多个
- // auth: ['basic_list'],
- },
- ],
- dropDownActions: [
- {
+ {
label: '启动',
- key: 'resume',
+ type: 'success',
+ onClick: handelChangeStatus.bind(null, record),
+ auth:['sys:job:resume'],
ifShow: () => {
return record.row.status==0 ||record.row.status==2;
},
},
{
label: '暂停',
- key: 'pause',
+ type: 'warning',
+ onClick: handelChangeStatus.bind(null, record),
+ auth:['sys:job:pause'],
ifShow: () => {
return record.row.status==1;
},
},
+ {
+ label: '编辑',
+ type: 'warning',
+ onClick: handleEdit.bind(null, record),
+ disabled:record.row.status==1,
+ auth: ['sys:job:update'],
+ },
+ {
+ label: '删除',
+ type: 'danger',
+ onClick: handleDelete.bind(null, record),
+ // 根据权限控制是否显示: 有权限,会显示,支持多个
+ auth: ['sys:job:update'],
+ },
+ ],
+ dropDownActions: [
{
label: '执行一次',
- key: 'runOnce'
+ key: 'runOnce',
+ disabled:true,
+ auth: ['sys:job:runOnce'],
+ ifShow: () => {
+ return record.row.status==2;
+ },
},
{
label: '调度日志',
- key: 'jobLog'
+ key: 'jobLog',
+ auth:['sys:job:jobLog']
},
],
select: (key) => {
- if(key=='resume' || key=='pause') {
- handelChangeStatus(record)
- } else if(key=='runOnce') {
+ if(key=='runOnce') {
handelRunOnce(record)
} else if(key=='jobLog'){
handleJobLog(record)
@@ -148,6 +149,13 @@ const selectionData = ref([])
const loadDataTable = async (res: any) => {
const result = await getJobList({ ...formParams, ...res });
+ result.records.map(item=>{
+ if(item.status==0) {
+ item.realStatus = false
+ } else {
+ item.realStatus = true
+ }
+ })
return result;
};
@@ -179,7 +187,11 @@ const selectionData = ref([])
await nextTick();
editVisible.value=true
};
-
+const handelSetStatus = async(row)=>{
+ await setJobStatus({id:row.id,status:row.realStatus?1:0})
+ message("设置成功");
+ reloadTable('noRefresh')
+}
const handleEdit = async (record: Recordable) => {
jobId.value=record.row.id
await nextTick();