From ef17a8bd79b098e459fce31eb40f393971e49188 Mon Sep 17 00:00:00 2001 From: tk Date: Wed, 18 Dec 2024 14:00:12 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=94=A8=20=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [skip ci] --- .../Dto/Sys/Tool/ExecuteSqlReq.cs | 5 + .../Services/Sys/ToolsService.cs | 5 +- .../NetAdmin.Tests/NetAdmin.Tests.csproj | 2 +- .../admin/src/components/naSearch/index.vue | 96 ++++++++++++------- .../src/components/scSelectFilter/index.vue | 2 +- src/frontend/admin/src/config/naFormEmail.js | 2 +- src/frontend/admin/src/layout/index.vue | 8 +- .../admin/src/views/sys/job/all/save.vue | 2 +- .../admin/src/views/sys/user/save.vue | 2 +- 9 files changed, 76 insertions(+), 48 deletions(-) diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/Tool/ExecuteSqlReq.cs b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/Tool/ExecuteSqlReq.cs index a56c86b5..68a5774c 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/Tool/ExecuteSqlReq.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/Tool/ExecuteSqlReq.cs @@ -14,4 +14,9 @@ public record ExecuteSqlReq : DataAbstraction /// 超时时间(秒) /// public int TimeoutSecs { get; init; } + + /// + /// 等待结果 + /// + public bool WaitResult { get; init; } = true; } \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ToolsService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ToolsService.cs index 67a117f7..e08c0e64 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ToolsService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ToolsService.cs @@ -13,10 +13,11 @@ public sealed class ToolsService : ServiceBase, IToolsService } /// - public Task ExecuteSqlAsync(ExecuteSqlReq req) + public async Task ExecuteSqlAsync(ExecuteSqlReq req) { req.ThrowIfInvalid(); - return App.GetService().Ado.CommandFluent(req.Sql).CommandTimeout(req.TimeoutSecs).ExecuteArrayAsync(); + var cmd = App.GetService().Ado.CommandFluent(req.Sql).CommandTimeout(req.TimeoutSecs).ExecuteArrayAsync(); + return req.WaitResult ? await cmd.ConfigureAwait(false) : null; } /// diff --git a/src/backend/NetAdmin/NetAdmin.Tests/NetAdmin.Tests.csproj b/src/backend/NetAdmin/NetAdmin.Tests/NetAdmin.Tests.csproj index ff527654..df3401a5 100644 --- a/src/backend/NetAdmin/NetAdmin.Tests/NetAdmin.Tests.csproj +++ b/src/backend/NetAdmin/NetAdmin.Tests/NetAdmin.Tests.csproj @@ -5,7 +5,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/frontend/admin/src/components/naSearch/index.vue b/src/frontend/admin/src/components/naSearch/index.vue index 709fdf00..031ca245 100644 --- a/src/frontend/admin/src/components/naSearch/index.vue +++ b/src/frontend/admin/src/components/naSearch/index.vue @@ -196,58 +196,70 @@ export default { }, }, { - text: this.$t('最近三日'), + text: this.$t('本周'), value: () => { - const start = new Date() - start.setHours(0, 0, 0, 0) - start.setTime(start.getTime() - 3600 * 1000 * 24 * 2) - const end = new Date() - end.setHours(0, 0, 0, 0) - return [start, end] + // 获取当前日期对象 + const currentDate = new Date() + currentDate.setHours(0, 0, 0, 0) + + // 获取当前日期是本周的第几天(0代表周日,1代表周一,...,6代表周六) + const dayOfWeek = currentDate.getDay() + + // 获取当前日期距离本周第一天的天数差(负数代表本周之前的天数,正数或零代表本周之后的天数) + const diffToFirstDay = dayOfWeek > 0 ? -(dayOfWeek - 1) : -6 + + // 获取本周第一天的日期对象 + const firstDayOfWeek = new Date(currentDate) + firstDayOfWeek.setDate(currentDate.getDate() + diffToFirstDay) + return [firstDayOfWeek, new Date()] }, }, { - text: this.$t('最近一周'), + text: this.$t('后退一周'), value: () => { - const start = new Date() - start.setHours(0, 0, 0, 0) - start.setTime(start.getTime() - 3600 * 1000 * 24 * 6) - const end = new Date() - end.setHours(0, 0, 0, 0) - return [start, end] + try { + const start = new Date(this.form.dy[this.dateField][0]) + const end = new Date(this.form.dy[this.dateField][1]) + start.setDate(start.getDate() - 7) + end.setDate(end.getDate() - 7) + return [start, end] + } catch {} }, }, { - text: this.$t('最近一月'), + text: this.$t('本月'), value: () => { const start = new Date() start.setHours(0, 0, 0, 0) - start.setMonth(start.getMonth() - 1) - const end = new Date() - end.setHours(0, 0, 0, 0) - return [start, end] + start.setDate(1) + return [start, new Date()] }, }, { - text: this.$t('最近三月'), + text: this.$t('后退一月'), value: () => { - const start = new Date() - start.setHours(0, 0, 0, 0) - start.setMonth(start.getMonth() - 3) - const end = new Date() - end.setHours(0, 0, 0, 0) - return [start, end] - }, - }, - { - text: this.$t('最近六月'), - value: () => { - const start = new Date() - start.setHours(0, 0, 0, 0) - start.setMonth(start.getMonth() - 6) - const end = new Date() - end.setHours(0, 0, 0, 0) - return [start, end] + try { + const start = new Date(this.form.dy[this.dateField][0]) + const end = new Date(this.form.dy[this.dateField][1]) + return [ + new Date( + start.getMonth() === 0 ? start.getFullYear() - 1 : start.getFullYear(), + start.getMonth() === 0 ? 11 : start.getMonth() - 1, + start.getDate(), + start.getHours(), + start.getMinutes(), + start.getSeconds(), + ), + new Date( + end.getMonth() === 0 ? end.getFullYear() - 1 : end.getFullYear(), + end.getMonth() === 0 ? 11 : end.getMonth() - 1, + end.getDate(), + end.getHours(), + end.getMinutes(), + end.getSeconds(), + ), + ] + } catch {} }, }, ], @@ -432,6 +444,16 @@ export default { return [start, end] }, }, + { + text: this.$t('最近整点'), + value: () => { + const start = new Date() + return [ + new Date(start.getFullYear(), start.getMonth(), start.getDate(), start.getHours(), 0, 0), + new Date(start.getFullYear(), start.getMonth(), start.getDate(), start.getHours() + 1, 0, 0), + ] + }, + }, { text: this.$t('后退一时'), value: () => { diff --git a/src/frontend/admin/src/components/scSelectFilter/index.vue b/src/frontend/admin/src/components/scSelectFilter/index.vue index b3570a7b..b75292e7 100644 --- a/src/frontend/admin/src/components/scSelectFilter/index.vue +++ b/src/frontend/admin/src/components/scSelectFilter/index.vue @@ -4,7 +4,7 @@