From 1e8729918b4335784b7e56172fb098802e1081ca Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 24 Apr 2024 17:51:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E8=A1=A8):=20=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=85=B3=E8=81=94=E6=97=B6=E9=97=B4=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E7=BB=84=E4=BB=B6=E5=90=8C=E6=97=B6=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5=E8=B7=B3=E8=BD=AC=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=BB=91=E5=AE=9A=E8=B7=B3=E8=BD=AC=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E7=9A=84=E6=97=A5=E6=9C=9F=E5=AD=97=E6=AE=B5=E5=B9=B6=E4=BA=A7?= =?UTF-8?q?=E7=94=9F=E8=81=94=E5=8A=A8=E6=95=88=E6=9E=9C=20#8661?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/src/store/index.js | 4 +++ core/frontend/src/utils/timeUitils.js | 30 +++++++++++++++++++ .../src/views/panel/linkJumpSet/index.vue | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/core/frontend/src/store/index.js b/core/frontend/src/store/index.js index dcc237eb76..a0fa4c2a1b 100644 --- a/core/frontend/src/store/index.js +++ b/core/frontend/src/store/index.js @@ -481,6 +481,10 @@ const data = { if (element.options.manualModify) { element.options.manualModify = false } + // 去掉动态时间 + if (element.options.attrs?.default?.isDynamic) { + element.options.attrs.default.isDynamic = false + } // 去掉首选项 if (element.options?.attrs?.selectFirst) { element.options.attrs.selectFirst = false diff --git a/core/frontend/src/utils/timeUitils.js b/core/frontend/src/utils/timeUitils.js index 1e28837e2f..4a94c8dad7 100644 --- a/core/frontend/src/utils/timeUitils.js +++ b/core/frontend/src/utils/timeUitils.js @@ -22,6 +22,19 @@ export const getRange = (selectValue, timeGranularity) => { } } +export const getTimeBegin = (selectValue, timeGranularity) => { + switch (timeGranularity) { + case 'year': + return getYearEnd(selectValue) + case 'month': + return getMonthEnd(selectValue) + case 'date': + return getDayEnd(selectValue) + default: + return selectValue + } +} + const getYearEnd = timestamp => { const time = new Date(timestamp) return [ @@ -50,3 +63,20 @@ const getMinuteEnd = timestamp => { return [+new Date(timestamp), +new Date(timestamp) + 60 * 1000 - 1000] } +const getYearBegin = timestamp => { + const time = new Date(timestamp) + return +new Date(time.getFullYear(), 0, 1) +} + +const getMonthBegin = timestamp => { + const time = new Date(timestamp) + const date = new Date(time.getFullYear(), time.getMonth(), 1) + date.setDate(1) + date.setMonth(date.getMonth() + 1) + return +new Date(time.getFullYear(), time.getMonth(), 1) +} + +const getDayBegin = timestamp => { + return +new Date(timestamp) +} + diff --git a/core/frontend/src/views/panel/linkJumpSet/index.vue b/core/frontend/src/views/panel/linkJumpSet/index.vue index 93623e8c33..38fa1c1270 100644 --- a/core/frontend/src/views/panel/linkJumpSet/index.vue +++ b/core/frontend/src/views/panel/linkJumpSet/index.vue @@ -478,7 +478,7 @@ export default { completeSingle: false // 当匹配只有一项的时候是否自动补全 } }, - widgetSubjectsFilter: ['textSelectWidget', 'textSelectGridWidget', 'textInputWidget', 'textSelectTreeWidget', 'numberSelectWidget', 'numberSelectGridWidget'], + widgetSubjectsFilter: ['timeYearWidget', 'timeMonthWidget', 'timeDateWidget', 'textSelectWidget', 'textSelectGridWidget', 'textInputWidget', 'textSelectTreeWidget', 'numberSelectWidget', 'numberSelectGridWidget'], widgetSubjectsTrans: { timeYearWidget: '年份过滤组件', timeMonthWidget: '年月过滤组件',