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 }