From f6ca45708cdcc4b58a6d729dc717ef22fbd59c75 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Mon, 18 Mar 2024 18:16:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=BF=87=E6=BB=A4=E7=BB=84=E4=BB=B6):=20?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E7=AD=9B=E9=80=89=E7=BB=84=E4=BB=B6=E5=8F=AF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=9F=A5=E8=AF=A2=E7=9A=84=E8=B5=B7=E5=A7=8B?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=20#6005?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/package.json | 1 + .../panel/filter/filterMain/FilterControl.vue | 62 +- .../filter/filterMain/RangeFilterTime.vue | 553 ++++++++++++++++++ .../filter/filterMain/time-format-dayjs.js | 22 + 4 files changed, 635 insertions(+), 3 deletions(-) create mode 100644 core/frontend/src/views/panel/filter/filterMain/RangeFilterTime.vue create mode 100644 core/frontend/src/views/panel/filter/filterMain/time-format-dayjs.js diff --git a/core/frontend/package.json b/core/frontend/package.json index d854c81583..7ad64a112a 100644 --- a/core/frontend/package.json +++ b/core/frontend/package.json @@ -41,6 +41,7 @@ "@tinymce/tinymce-vue": "^3.2.8", "axios": "^1.6.1", "core-js": "^2.6.5", + "dayjs": "^1.11.10", "echarts": "^5.0.1", "element-resize-detector": "^1.2.3", "element-ui": "2.15.7", diff --git a/core/frontend/src/views/panel/filter/filterMain/FilterControl.vue b/core/frontend/src/views/panel/filter/filterMain/FilterControl.vue index dfef530c91..b34bb50f5f 100644 --- a/core/frontend/src/views/panel/filter/filterMain/FilterControl.vue +++ b/core/frontend/src/views/panel/filter/filterMain/FilterControl.vue @@ -70,12 +70,32 @@
- + + {{ $t('panel.show_empty') }} - + 设置时间筛选范围 + + + + + + + import FilterSort from './FilterSort' +import RangeFilterTime from '@/views/panel/filter/filterMain/RangeFilterTime.vue' export default { name: 'FilterControl', - components: { FilterSort }, + components: { FilterSort, RangeFilterTime }, props: { widget: { type: Object, @@ -370,6 +391,22 @@ export default { created() { this.attrs = this.controlAttrs + if (!this.attrs.timeRange) { + this.$set(this.attrs, 'timeRange', { + intervalType: "none", + dynamicWindow: false, + maximumSingleQuery: 0, + regularOrTrends: "fixed", + regularOrTrendsValue: "", + relativeToCurrent: "custom", + timeNum: 0, + relativeToCurrentType: "year", + around: "f", + timeNumRange: 0, + relativeToCurrentTypeRange: "year", + aroundRange: "f", + }) + } if (this.widget.isTimeWidget) { this.showParams = true this.isRangeParamWidget = this.widget.isRangeParamWidget && this.widget.isRangeParamWidget() @@ -461,6 +498,25 @@ export default { justify-content: flex-end; flex-wrap: nowrap; height: 50px; + .more-select-btn { + display: inline-flex; + width: 56px; + height: 26px; + border-radius: 4px; + color: #3370FF; + font-size: 14px; + font-weight: 400; + line-height: 22px; + align-items: center; + justify-content: center; + &:hover { + background: #3370FF1A; + } + + &.icon-icon-more::before { + margin-right: 4px; + } + } } .i-filter { diff --git a/core/frontend/src/views/panel/filter/filterMain/RangeFilterTime.vue b/core/frontend/src/views/panel/filter/filterMain/RangeFilterTime.vue new file mode 100644 index 0000000000..a3467ede73 --- /dev/null +++ b/core/frontend/src/views/panel/filter/filterMain/RangeFilterTime.vue @@ -0,0 +1,553 @@ + + + + + diff --git a/core/frontend/src/views/panel/filter/filterMain/time-format-dayjs.js b/core/frontend/src/views/panel/filter/filterMain/time-format-dayjs.js new file mode 100644 index 0000000000..610598962c --- /dev/null +++ b/core/frontend/src/views/panel/filter/filterMain/time-format-dayjs.js @@ -0,0 +1,22 @@ +import dayjs from 'dayjs' +function getThisStart(val = 'month') { + return new Date(dayjs().startOf(val).format('YYYY/MM/DD HH:mm:ss')) +} + +function getThisEnd(val = 'month') { + return new Date(dayjs().endOf(val).format('YYYY/MM/DD HH:mm:ss')) +} + +function getLastStart(val = 'month') { + return new Date(dayjs().subtract(1, val).startOf(val).format('YYYY/MM/DD HH:mm:ss')) +} + +function getLastEnd(val = 'month') { + return new Date(dayjs().subtract(1, val).endOf(val).format('YYYY/MM/DD HH:mm:ss')) +} + +function getAround(val = 'month', type = 'add', num = 0) { + return new Date(dayjs()[type](num, val).startOf('day').format('YYYY/MM/DD HH:mm:ss')) +} + +export { getThisStart, getThisEnd, getLastStart, getLastEnd, getAround }