diff --git a/src/assets/css/common.scss b/src/assets/css/common.scss index 281fc413..d8349ab7 100644 --- a/src/assets/css/common.scss +++ b/src/assets/css/common.scss @@ -14,6 +14,27 @@ body { cursor: default !important; } +/*---滚动条默认显示样式--*/ +::-webkit-scrollbar-thumb { + background-color: #ddd; + border-radius: 6px; + border: 2px solid #fff; +} +/*---鼠标点击滚动条显示样式--*/ +::-webkit-scrollbar-thumb:hover { + background-color: #c8c8c8; + border-radius: 6px; +} +/*---滚动条大小--*/ +::-webkit-scrollbar { + width: 14px; + height: 14px; +} +/*---滚动框背景样式--*/ +::-webkit-scrollbar-track-piece { + background-color: transparent; +} + .myDatePicker .el-picker-panel__footer{ .el-button{ display: none; diff --git a/src/components/charts/ChartTable.vue b/src/components/charts/ChartTable.vue index d161ade0..68051b75 100644 --- a/src/components/charts/ChartTable.vue +++ b/src/components/charts/ChartTable.vue @@ -10,8 +10,9 @@
@@ -29,6 +31,7 @@
diff --git a/src/components/charts/ChartTablePagination.vue b/src/components/charts/ChartTablePagination.vue new file mode 100644 index 00000000..81ae5409 --- /dev/null +++ b/src/components/charts/ChartTablePagination.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/components/charts/panel.scss b/src/components/charts/panel.scss index a3e64483..93a51e61 100644 --- a/src/components/charts/panel.scss +++ b/src/components/charts/panel.scss @@ -167,6 +167,37 @@ .option__button.icon-group-item:last-of-type:not(:first-of-type) { padding: 0 0 0 5px; } + .option__select { + .el-input__inner { + padding-right: 20px; + width: 120px; + border: none; + height: 100%; + line-height: 20px; + color: $--color-primary; + } + .el-input__prefix > div { + font-weight: normal; + line-height: 19px; + color: $--color-primary; + } + .el-input__suffix { + display: flex; + .el-input__suffix-inner { + line-height: 14px; + .el-select__caret { + line-height: 14px; + width: 16px; + color: $--color-primary; + } + } + } + } + .option__select.select__topn { + .el-input__inner { + width: 80px; + } + } .icon-group-divide { height: 14px; width: 1px; @@ -204,4 +235,11 @@ } } } -} \ No newline at end of file +} +.option__topn-popper { + .el-select-dropdown__item { + height: 24px; + line-height: 24px; + font-size: 12px; + } +} diff --git a/src/main.js b/src/main.js index 6037c1d2..413f8d88 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,4 @@ import { createApp } from 'vue' -import _ from 'lodash' import router from '@/router' import store from '@/store' import App from '@/App.vue' @@ -16,6 +15,9 @@ import utc from 'dayjs/plugin/utc' // dependent on utc plugin import timezone from 'dayjs/plugin/timezone' import advancedFormat from 'dayjs/plugin/advancedFormat' import weekday from 'dayjs/plugin/weekday' + +const _ = require('lodash') // lodash工具 + dayjs.extend(utc) dayjs.extend(timezone) dayjs.extend(advancedFormat) @@ -29,13 +31,14 @@ app.use(store) app.use(ElementPlus) app.use(i18n) // app.use(VueGridLayout) -app.use(_) app.directive('has', hasPermission) // 注册指令 app.directive('click-outside', clickOutside) app.directive('ele-click-outside', ClickOutside) app.directive('cancel', cancelWithChange) +app.config.globalProperties.$_ = _ + app.mixin(commonMixin) app.mount('#app') diff --git a/src/utils/constants.js b/src/utils/constants.js index 64c446c3..5f49c33d 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -20,3 +20,6 @@ export const position = { normal: 'calc(100% - 48px)' // 常规高度,特例在下方定义 } } + +export const chartTableDefaultPageSize = 10 // table类型图表默认每页数据量 +export const chartTableTopOptions = [10, 50, 100] // table类型图表的TOP-N选项 diff --git a/src/views/charts/Chart.vue b/src/views/charts/Chart.vue index ae8f0d67..eca6196d 100644 --- a/src/views/charts/Chart.vue +++ b/src/views/charts/Chart.vue @@ -21,8 +21,8 @@ @@ -30,8 +30,29 @@
-
-
+
+ + TOP {{item}} + + +
+
+ + {{item}} + +
@@ -41,6 +62,12 @@
+
@@ -50,6 +77,8 @@ import { isEcharts, isSingleValue, isTable, getOption, getTypeCategory, getLayou import EchartsFrame from '@/components/charts/EchartsFrame' import SingleValue from '@/components/charts/ChartSingleValue' import Table from '@/components/charts/ChartTable' +import ChartTablePagination from '@/components/charts/ChartTablePagination' +import { chartTableDefaultPageSize, chartTableTopOptions } from '@/utils/constants' import { get } from '@/utils/http' let myChart // echarts实例 @@ -62,12 +91,19 @@ export default { components: { EchartsFrame, SingleValue, + ChartTablePagination, 'chart-table': Table }, data () { return { - tableColumns: [], - tableData: [] + table: { + pageSize: chartTableDefaultPageSize, + limit: chartTableTopOptions[0], // top-n + orderBy: '', + tableColumns: [], // table字段 + tableData: [], // table的所有数据 + currentPageData: [] // table当前页的数据 + } } }, methods: { @@ -88,8 +124,10 @@ export default { tableColumns.add(k) }) }) - this.tableColumns = Array.from(tableColumns) - this.tableData = tableResponse.data + this.table.tableColumns = Array.from(tableColumns) + this.table.orderBy = this.table.tableColumns[0] + this.table.tableData = tableResponse.data + this.table.currentPageData = this.getTargetPageData(1, this.table.pageSize, this.table.tableData) /* get(params.url, { startTime: now - 3600000, endTime: now, order: params.order ? params.order : null, limit: params.limit ? params.limit : null }).then(response => { if (response.code === 200) { const tableColumns = new Set() @@ -98,13 +136,18 @@ export default { tableColumns.add(k) }) }) - this.tableColumns = tableColumns - this.tableData = response.data - console.info(this.tableColumns, this.tableData) + this.table.tableColumns = tableColumns + this.table.tableData = response.data } }) */ } } + }, + pageJump (val) { + this.table.currentPageData = this.getTargetPageData(val, this.table.pageSize, this.table.tableData) + }, + getTargetPageData (pageNum, pageSize, tableData) { + return this.$_.slice(tableData, (pageNum - 1) * pageSize, pageNum * pageSize) } }, computed: { @@ -126,6 +169,7 @@ export default { return { chartInfo, layoutConstant, + chartTableTopOptions, chartOption: getOption(props.chart.type), isEcharts: isEcharts(props.chart.type), isSingleValue: isSingleValue(props.chart.type),