From 1668d7a10bc093cc758e1d66e13cdf466c7c7730 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E7=BA=A2=E4=B8=BD?= <1181930680@qq.com>
Date: Wed, 24 Jul 2024 17:20:40 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1+=E9=9D=99?=
=?UTF-8?q?=E6=80=81=E8=B7=AF=E7=94=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/monitor/dataSource.ts | 60 +++++++
src/api/monitor/job.ts | 132 ++++++++++++++++
src/router/base.ts | 27 ++++
src/router/router-guards.ts | 3 +-
src/views/content/adSort/index.vue | 2 +-
src/views/monitor/job/columns.ts | 48 ++++++
src/views/monitor/job/edit.vue | 194 +++++++++++++++++++++++
src/views/monitor/job/index.vue | 220 ++++++++++++++++++++++++++
src/views/monitor/job/querySchemas.ts | 38 +++++
9 files changed, 722 insertions(+), 2 deletions(-)
create mode 100644 src/api/monitor/dataSource.ts
create mode 100644 src/api/monitor/job.ts
create mode 100644 src/views/monitor/job/columns.ts
create mode 100644 src/views/monitor/job/edit.vue
create mode 100644 src/views/monitor/job/index.vue
create mode 100644 src/views/monitor/job/querySchemas.ts
diff --git a/src/api/monitor/dataSource.ts b/src/api/monitor/dataSource.ts
new file mode 100644
index 0000000..16c49b2
--- /dev/null
+++ b/src/api/monitor/dataSource.ts
@@ -0,0 +1,60 @@
+import { http } from '@/utils/http/axios';
+
+/**
+ * @description: 列表
+ */
+export function getDataSourceList(params?) {
+ return http.request({
+ url: '/data/source/page',
+ method: 'GET',
+ params,
+ });
+}
+/**
+ * @description: 根据ID获取详情
+ */
+export function getDataSourceDetail(id) {
+ return http.request({
+ url: '/data/source/detail/'+id,
+ method: 'get',
+ });
+}
+/**
+ * @description: 添加
+ */
+export function dataSourceAdd(data:any) {
+ return http.request({
+ url: '/data/source/add',
+ method: 'POST',
+ data,
+ });
+}
+/**
+ * @description: 更新
+ */
+export function dataSourceUpdate(data:any) {
+ return http.request({
+ url: '/data/source/update',
+ method: 'PUT',
+ data
+ });
+}
+/**
+ * @description: 删除
+ */
+export function dataSourceDelete(id) {
+ return http.request({
+ url: '/data/source/delete/'+id,
+ method: 'DELETE',
+ });
+}
+/**
+ * @description: 批量删除
+ */
+export function dataSourceBatchDelete(data:any) {
+ return http.request({
+ url: '/data/source/batchDelete',
+ method: 'DELETE',
+ data
+ });
+ }
\ No newline at end of file
diff --git a/src/api/monitor/job.ts b/src/api/monitor/job.ts
new file mode 100644
index 0000000..59a4a89
--- /dev/null
+++ b/src/api/monitor/job.ts
@@ -0,0 +1,132 @@
+import { http } from '@/utils/http/axios';
+
+/**
+ * @description: 定时任务列表
+ */
+export function getJobList(params?) {
+ return http.request({
+ url: '/job/page',
+ method: 'GET',
+ params,
+ });
+}
+export function getJobAllList(params?) {
+ return http.request({
+ url: '/job/list',
+ method: 'GET',
+ params,
+ });
+}
+/**
+ * @description: 根据ID获取详情
+ */
+export function getJobDetail(id) {
+ return http.request({
+ url: '/job/detail/'+id,
+ method: 'get',
+ });
+}
+/**
+ * @description: 添加定时任务
+ */
+export function jobAdd(data:any) {
+ return http.request({
+ url: '/job/add',
+ method: 'POST',
+ data,
+ });
+}
+/**
+ * @description: 更新定时任务
+ */
+export function jobUpdate(data:any) {
+ return http.request({
+ url: '/job/update',
+ method: 'PUT',
+ data
+ });
+}
+/**
+ * @description: 删除定时任务
+ */
+export function jobDelete(id) {
+ return http.request({
+ url: '/job/delete/'+id,
+ method: 'DELETE',
+ });
+}
+/**
+ * @description: 批量删除定时任务
+ */
+export function jobBatchDelete(data:any) {
+ return http.request({
+ url: '/job/batchDelete',
+ method: 'DELETE',
+ data
+ });
+}
+/**
+ * @description: 执行一次
+ */
+export function getJobRunOnce(id) {
+ return http.request({
+ url: '/job/runOnce/'+id,
+ method: 'get',
+ });
+}
+/**
+ * @description: 暂停任务
+ */
+export function getJobPause(id) {
+ return http.request({
+ url: '/job/pause/'+id,
+ method: 'get',
+ });
+}
+/**
+ * @description: 恢复任务
+ */
+export function getJobResume(id) {
+ return http.request({
+ url: '/job/resume/'+id,
+ method: 'get',
+ });
+}
+/**
+ * @description: 定时任务日志列表
+ */
+export function getJobLogList(params?) {
+ return http.request({
+ url: '/job/log/page',
+ method: 'GET',
+ params,
+ });
+}
+/**
+ * @description: 根据ID获取详情
+ */
+export function getJobLogDetail(id) {
+ return http.request({
+ url: '/job/log/detail/'+id,
+ method: 'get',
+ });
+}
+/**
+ * @description: 删除定时任务日志
+ */
+export function jobLogDelete(id) {
+ return http.request({
+ url: '/job/log/delete/'+id,
+ method: 'DELETE',
+ });
+}
+/**
+ * @description: 批量删除定时任务日志
+ */
+export function jobLogBatchDelete(data:any) {
+ return http.request({
+ url: '/job/log/batchDelete',
+ method: 'DELETE',
+ data
+ });
+}
\ No newline at end of file
diff --git a/src/router/base.ts b/src/router/base.ts
index 36b67d6..a666697 100644
--- a/src/router/base.ts
+++ b/src/router/base.ts
@@ -1,5 +1,7 @@
import type { AppRouteRecordRaw } from '@/router/types';
import { ErrorPage, RedirectName, Layout } from '@/router/constant';
+import { ProjectOutlined } from '@vicons/antd';
+import { renderIcon } from '@/utils/index';
// 404 on a page
export const ErrorPageRoute: AppRouteRecordRaw = {
@@ -23,6 +25,31 @@ export const ErrorPageRoute: AppRouteRecordRaw = {
],
};
+
+export const AboutPageRoute: AppRouteRecordRaw ={
+ path: '/about',
+ name: 'about',
+ component: Layout,
+ meta: {
+ sort: 12,
+ isRoot: true,
+ activeMenu: 'about_index',
+ alwaysShow: true,
+ icon: renderIcon(ProjectOutlined),
+ },
+ children: [
+ {
+ path: 'index',
+ name: `about_index`,
+ meta: {
+ title: '关于项目',
+ activeMenu: 'about_index',
+ },
+ component: () => import('@/views/about/index.vue'),
+ },
+ ],
+ };
+
export const RedirectRoute: AppRouteRecordRaw = {
path: '/redirect',
name: `${RedirectName}Parent`,
diff --git a/src/router/router-guards.ts b/src/router/router-guards.ts
index c89e488..59698b7 100644
--- a/src/router/router-guards.ts
+++ b/src/router/router-guards.ts
@@ -5,7 +5,7 @@ import { useAsyncRouteStoreWidthOut } from '@/store/modules/asyncRoute';
import { ACCESS_TOKEN } from '@/store/mutation-types';
import { storage } from '@/utils/Storage';
import { PageEnum } from '@/enums/pageEnum';
-import { ErrorPageRoute } from '@/router/base';
+import { ErrorPageRoute,AboutPageRoute } from '@/router/base';
import NProgress from 'nprogress';
const LOGIN_PATH = PageEnum.BASE_LOGIN;
@@ -70,6 +70,7 @@ export function createRouterGuards(router: Router) {
if (isErrorPage === -1) {
router.addRoute(ErrorPageRoute as unknown as RouteRecordRaw);
}
+ router.addRoute(AboutPageRoute as unknown as RouteRecordRaw);
const redirectPath = (from.query.redirect || to.path) as string;
const redirect = decodeURIComponent(redirectPath);
diff --git a/src/views/content/adSort/index.vue b/src/views/content/adSort/index.vue
index 891bd41..a900927 100644
--- a/src/views/content/adSort/index.vue
+++ b/src/views/content/adSort/index.vue
@@ -37,7 +37,7 @@
v-if="editVisible"
:adSortId="adSortId"
v-model:visible="editVisible"
- @success="reloadTable"
+ @success="reloadTable('noRefresh')"
>
diff --git a/src/views/monitor/job/columns.ts b/src/views/monitor/job/columns.ts
new file mode 100644
index 0000000..079f791
--- /dev/null
+++ b/src/views/monitor/job/columns.ts
@@ -0,0 +1,48 @@
+import { h } from 'vue';
+import { ElTag } from 'element-plus';
+
+export const columns = [
+ {
+ type: 'selection',
+ },
+ {
+ label: '任务名称',
+ prop: 'jobName',
+ },
+ {
+ label: '任务分组',
+ prop: 'jobGroup',
+ },
+ {
+ label: '任务触发器',
+ prop: 'jobTrigger',
+ },
+ {
+ label: 'cron执行表达式',
+ prop: 'cronExpression',
+ },
+ {
+ 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/edit.vue b/src/views/monitor/job/edit.vue
new file mode 100644
index 0000000..be90f5c
--- /dev/null
+++ b/src/views/monitor/job/edit.vue
@@ -0,0 +1,194 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 是
+ 否
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/monitor/job/index.vue b/src/views/monitor/job/index.vue
new file mode 100644
index 0000000..11d5cc6
--- /dev/null
+++ b/src/views/monitor/job/index.vue
@@ -0,0 +1,220 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 添加任务
+
+
+
+
+
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/monitor/job/querySchemas.ts b/src/views/monitor/job/querySchemas.ts
new file mode 100644
index 0000000..5ad6cd7
--- /dev/null
+++ b/src/views/monitor/job/querySchemas.ts
@@ -0,0 +1,38 @@
+import { FormSchema } from '@/components/Form/index';
+export const schemas: FormSchema[] = [
+ {
+ field: 'jobName',
+ component: 'Input',
+ label: '任务名称',
+ componentProps: {
+ placeholder: '请输入任务名称',
+ },
+ },
+ {
+ field: 'status',
+ component: 'Select',
+ label: '任务状态',
+ componentProps: {
+ placeholder: '请选择任务状态',
+ clearable: true,
+ options: [
+ {
+ label: '未发布',
+ value: 0,
+ },
+ {
+ label: '运行中',
+ value: 1,
+ },
+ {
+ label: '暂停',
+ value: 2,
+ },
+ {
+ label: '删除',
+ value: 3,
+ },
+ ],
+ },
+ },
+];