Эх сурвалжийг харах

🎸定时任务增加组名称过滤

KaneLeung 1 жил өмнө
parent
commit
47be9f6ea5

+ 5 - 0
Admin.NET/Admin.NET.Core/Service/Job/Dto/JobDetailInput.cs

@@ -21,6 +21,11 @@ public class PageJobDetailInput : BasePageInput
     /// </summary>
     public string JobId { get; set; }
 
+    /// <summary>
+    /// 组名称
+    /// </summary>
+    public string GroupName { get; set; }
+
     /// <summary>
     /// 描述信息
     /// </summary>

+ 12 - 2
Admin.NET/Admin.NET.Core/Service/Job/SysJobService.cs

@@ -41,8 +41,9 @@ public class SysJobService : IDynamicApiController, ITransient
     public async Task<SqlSugarPagedList<JobDetailOutput>> PageJobDetail(PageJobDetailInput input)
     {
         var jobDetails = await _sysJobDetailRep.AsQueryable()
-            .WhereIF(!string.IsNullOrWhiteSpace(input.JobId), u => u.JobId.Contains(input.JobId))
-            .WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description))
+            .WhereIF(!string.IsNullOrWhiteSpace(input.JobId), u => u.JobId.Contains(input.JobId.Trim()))
+            .WhereIF(!string.IsNullOrWhiteSpace(input.GroupName), u => u.GroupName.Contains(input.GroupName.Trim()))
+            .WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
             .Select(d => new JobDetailOutput
             {
                 JobDetail = d,
@@ -64,6 +65,15 @@ public class SysJobService : IDynamicApiController, ITransient
         return jobDetails;
     }
 
+    /// <summary>
+    /// 获取作业组名称集合 ⏰
+    /// </summary>
+    [DisplayName("获取作业组名称集合")]
+    public async Task<List<string>> ListJobGroup()
+    {
+        return await _sysJobDetailRep.AsQueryable().Distinct().Select(e => e.GroupName).ToListAsync();
+    }
+
     /// <summary>
     /// 添加作业 ⏰
     /// </summary>

+ 29 - 16
Web/src/views/system/job/index.vue

@@ -5,6 +5,11 @@
 				<el-form-item label="作业编号">
 					<el-input v-model="state.queryParams.jobId" placeholder="作业编号" clearable />
 				</el-form-item>
+				<el-form-item label="组名称">
+					<el-select v-model="state.queryParams.groupName" placeholder="组名称" clearable>
+						<el-option v-for="item in state.groupsData" :key="item" :label="item" :value="item" />
+					</el-select>
+				</el-form-item>
 				<el-form-item label="描述信息">
 					<el-input v-model="state.queryParams.description" placeholder="描述信息" clearable />
 				</el-form-item>
@@ -265,7 +270,7 @@
 </template>
 
 <script lang="ts" setup name="sysJob">
-import { onMounted, reactive, ref } from 'vue';
+import { nextTick, onMounted, reactive, ref } from 'vue';
 import { ElMessageBox, ElMessage } from 'element-plus';
 import { useRouter } from 'vue-router';
 import { Timer } from '@element-plus/icons-vue';
@@ -286,6 +291,7 @@ const state = reactive({
 	jobData: [] as Array<JobDetailOutput>,
 	queryParams: {
 		jobId: undefined,
+		groupName: undefined,
 		description: undefined,
 	},
 	tableParams: {
@@ -304,10 +310,16 @@ const state = reactive({
 	isVisibleDrawer: false,
 	triggerRecordData: [] as any,
 	currentJob: {} as any,
+	groupsData: [] as Array<string>,
 });
 
 onMounted(async () => {
-	handleQuery();
+	await handleQuery();
+	// 获取组名称下拉集合
+	nextTick(async () => {
+		const { data } = await getAPI(SysJobApi).apiSysJobListJobGroupPost();
+		state.groupsData = data.result ?? [];
+	});
 });
 
 // 查询操作
@@ -321,10 +333,11 @@ const handleQuery = async () => {
 };
 
 // 重置操作
-const resetQuery = () => {
+const resetQuery = async () => {
 	state.queryParams.jobId = undefined;
+	state.queryParams.groupName = undefined;
 	state.queryParams.description = undefined;
-	handleQuery();
+	await handleQuery();
 };
 
 // 打开新增作业页面
@@ -348,7 +361,7 @@ const delJobDetail = (row: JobDetailOutput) => {
 	})
 		.then(async () => {
 			await getAPI(SysJobApi).apiSysJobDeleteJobDetailPost({ jobId: row.jobDetail?.jobId });
-			handleQuery();
+			await handleQuery();
 			ElMessage.success('删除成功');
 		})
 		.catch(() => {});
@@ -382,22 +395,22 @@ const delJobTrigger = (row: SysJobTrigger) => {
 	})
 		.then(async () => {
 			await getAPI(SysJobApi).apiSysJobDeleteJobTriggerPost({ jobId: row.jobId, triggerId: row.triggerId });
-			handleQuery();
+			await handleQuery();
 			ElMessage.success('删除成功');
 		})
 		.catch(() => {});
 };
 
 // 改变页面容量
-const handleSizeChange = (val: number) => {
+const handleSizeChange = async (val: number) => {
 	state.tableParams.pageSize = val;
-	handleQuery();
+	await handleQuery();
 };
 
 // 改变页码序号
-const handleCurrentChange = (val: number) => {
+const handleCurrentChange = async (val: number) => {
 	state.tableParams.page = val;
-	handleQuery();
+	await handleQuery();
 };
 
 // 启动所有作业
@@ -497,11 +510,11 @@ const getHttpMethodDesc = (httpMethodStr: string | undefined | null): string =>
 };
 
 // 打开作业触发器运行记录
-const openJobTriggerRecord = (row: any) => {
+const openJobTriggerRecord = async (row: any) => {
 	state.currentJob = row;
 	state.recordPageParam.jobId = row?.jobDetail?.jobId;
 	state.isVisibleDrawer = true;
-	handleQuery2();
+	await handleQuery2();
 };
 
 // 作业触发器运行记录查询操作
@@ -515,15 +528,15 @@ const handleQuery2 = async () => {
 };
 
 // 作业触发器运行记录-改变页面容量
-const handleSizeChange2 = (val: number) => {
+const handleSizeChange2 = async (val: number) => {
 	state.tableParams2.pageSize = val;
-	handleQuery2();
+	await handleQuery2();
 };
 
 // 作业触发器运行记录-改变页码序号
-const handleCurrentChange2 = (val: number) => {
+const handleCurrentChange2 = async (val: number) => {
 	state.tableParams2.page = val;
-	handleQuery2();
+	await handleQuery2();
 };
 </script>