CN-37 feat: table功能完善
This commit is contained in:
@@ -14,6 +14,27 @@ body {
|
|||||||
cursor: default !important;
|
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{
|
.myDatePicker .el-picker-panel__footer{
|
||||||
.el-button{
|
.el-button{
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -10,8 +10,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="cn-chart__body">
|
<div class="cn-chart__body">
|
||||||
<el-table
|
<el-table
|
||||||
:data="tableData"
|
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
tooltip-effect="light"
|
||||||
|
:data="tableData"
|
||||||
>
|
>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
type="index"
|
type="index"
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-for="(c, i) in tableColumns"
|
v-for="(c, i) in tableColumns"
|
||||||
|
show-overflow-tooltip
|
||||||
:key="i"
|
:key="i"
|
||||||
:prop="c"
|
:prop="c"
|
||||||
>
|
>
|
||||||
@@ -29,6 +31,7 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
<div class="cn-chart__footer">
|
<div class="cn-chart__footer">
|
||||||
|
<slot name="footer"></slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
56
src/components/charts/ChartTablePagination.vue
Normal file
56
src/components/charts/ChartTablePagination.vue
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<template>
|
||||||
|
<el-pagination
|
||||||
|
small
|
||||||
|
layout="prev,jumper,slot,next"
|
||||||
|
class="chart-table-pagination"
|
||||||
|
:total="total"
|
||||||
|
:page-size="pageSize"
|
||||||
|
@current-change="current"
|
||||||
|
>
|
||||||
|
<span>/ {{totalPage}}</span>
|
||||||
|
</el-pagination>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { chartTableDefaultPageSize } from '@/utils/constants'
|
||||||
|
export default {
|
||||||
|
name: 'ChartTablePagination',
|
||||||
|
props: {
|
||||||
|
total: Number
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
pageSize: chartTableDefaultPageSize
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
totalPage () {
|
||||||
|
const remainder = this.total % this.pageSize
|
||||||
|
if (remainder) {
|
||||||
|
return parseInt(this.total / this.pageSize) + 1
|
||||||
|
} else {
|
||||||
|
return parseInt(this.total / this.pageSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
current (val) {
|
||||||
|
this.$emit('pageJump', val)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.$el.querySelector('.el-pagination__jump').childNodes[0].nodeValue = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.chart-table-pagination.el-pagination {
|
||||||
|
padding: 12px 0 9px 0;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.el-pagination__jump {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -167,6 +167,37 @@
|
|||||||
.option__button.icon-group-item:last-of-type:not(:first-of-type) {
|
.option__button.icon-group-item:last-of-type:not(:first-of-type) {
|
||||||
padding: 0 0 0 5px;
|
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 {
|
.icon-group-divide {
|
||||||
height: 14px;
|
height: 14px;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
@@ -204,4 +235,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.option__topn-popper {
|
||||||
|
.el-select-dropdown__item {
|
||||||
|
height: 24px;
|
||||||
|
line-height: 24px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import _ from 'lodash'
|
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import App from '@/App.vue'
|
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 timezone from 'dayjs/plugin/timezone'
|
||||||
import advancedFormat from 'dayjs/plugin/advancedFormat'
|
import advancedFormat from 'dayjs/plugin/advancedFormat'
|
||||||
import weekday from 'dayjs/plugin/weekday'
|
import weekday from 'dayjs/plugin/weekday'
|
||||||
|
|
||||||
|
const _ = require('lodash') // lodash工具
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
dayjs.extend(advancedFormat)
|
dayjs.extend(advancedFormat)
|
||||||
@@ -29,13 +31,14 @@ app.use(store)
|
|||||||
app.use(ElementPlus)
|
app.use(ElementPlus)
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
// app.use(VueGridLayout)
|
// app.use(VueGridLayout)
|
||||||
app.use(_)
|
|
||||||
|
|
||||||
app.directive('has', hasPermission) // 注册指令
|
app.directive('has', hasPermission) // 注册指令
|
||||||
app.directive('click-outside', clickOutside)
|
app.directive('click-outside', clickOutside)
|
||||||
app.directive('ele-click-outside', ClickOutside)
|
app.directive('ele-click-outside', ClickOutside)
|
||||||
app.directive('cancel', cancelWithChange)
|
app.directive('cancel', cancelWithChange)
|
||||||
|
|
||||||
|
app.config.globalProperties.$_ = _
|
||||||
|
|
||||||
app.mixin(commonMixin)
|
app.mixin(commonMixin)
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
@@ -20,3 +20,6 @@ export const position = {
|
|||||||
normal: 'calc(100% - 48px)' // 常规高度,特例在下方定义
|
normal: 'calc(100% - 48px)' // 常规高度,特例在下方定义
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const chartTableDefaultPageSize = 10 // table类型图表默认每页数据量
|
||||||
|
export const chartTableTopOptions = [10, 50, 100] // table类型图表的TOP-N选项
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
</single-value>
|
</single-value>
|
||||||
<chart-table
|
<chart-table
|
||||||
v-else-if="isTable"
|
v-else-if="isTable"
|
||||||
:table-columns="tableColumns"
|
:table-columns="table.tableColumns"
|
||||||
:table-data="tableData"
|
:table-data="table.currentPageData"
|
||||||
:style="computePosition"
|
:style="computePosition"
|
||||||
>
|
>
|
||||||
<template #title>{{chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name}}</template>
|
<template #title>{{chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name}}</template>
|
||||||
@@ -30,8 +30,29 @@
|
|||||||
<div class="header__operation header__operation--table">
|
<div class="header__operation header__operation--table">
|
||||||
<span class="option__button"><i class="cn-icon cn-icon-download"></i></span>
|
<span class="option__button"><i class="cn-icon cn-icon-download"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="header__operation header__operation--table"><i class="cn-icon cn-icon-download"></i></div>
|
<div class="header__operation header__operation--table">
|
||||||
<div class="header__operation header__operation--table"><i class="cn-icon cn-icon-download"></i></div>
|
<el-select
|
||||||
|
size="mini"
|
||||||
|
v-model="table.limit"
|
||||||
|
class="option__select select__topn"
|
||||||
|
placeholder=""
|
||||||
|
popper-class="option__topn-popper"
|
||||||
|
>
|
||||||
|
<el-option v-for="item in chartTableTopOptions" :key="item" :value="item">TOP {{item}}</el-option>
|
||||||
|
<template #prefix>TOP </template>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
<div class="header__operation header__operation--table">
|
||||||
|
<el-select
|
||||||
|
size="mini"
|
||||||
|
v-model="table.orderBy"
|
||||||
|
class="option__select"
|
||||||
|
placeholder=""
|
||||||
|
popper-class="option__topn-popper"
|
||||||
|
>
|
||||||
|
<el-option v-for="item in table.tableColumns" :key="item" :value="item">{{item}}</el-option>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
<div class="header__operation header__operation--table">
|
<div class="header__operation header__operation--table">
|
||||||
<span class="option__button"><i class="cn-icon cn-icon-style"></i></span>
|
<span class="option__button"><i class="cn-icon cn-icon-style"></i></span>
|
||||||
<div class="icon-group-divide"></div>
|
<div class="icon-group-divide"></div>
|
||||||
@@ -41,6 +62,12 @@
|
|||||||
<span class="option__button"><i class="cn-icon cn-icon-full-screen"></i></span>
|
<span class="option__button"><i class="cn-icon cn-icon-full-screen"></i></span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template #footer>
|
||||||
|
<chart-table-pagination
|
||||||
|
:total="table.tableData.length"
|
||||||
|
@pageJump="pageJump"
|
||||||
|
></chart-table-pagination>
|
||||||
|
</template>
|
||||||
</chart-table>
|
</chart-table>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -50,6 +77,8 @@ import { isEcharts, isSingleValue, isTable, getOption, getTypeCategory, getLayou
|
|||||||
import EchartsFrame from '@/components/charts/EchartsFrame'
|
import EchartsFrame from '@/components/charts/EchartsFrame'
|
||||||
import SingleValue from '@/components/charts/ChartSingleValue'
|
import SingleValue from '@/components/charts/ChartSingleValue'
|
||||||
import Table from '@/components/charts/ChartTable'
|
import Table from '@/components/charts/ChartTable'
|
||||||
|
import ChartTablePagination from '@/components/charts/ChartTablePagination'
|
||||||
|
import { chartTableDefaultPageSize, chartTableTopOptions } from '@/utils/constants'
|
||||||
import { get } from '@/utils/http'
|
import { get } from '@/utils/http'
|
||||||
|
|
||||||
let myChart // echarts实例
|
let myChart // echarts实例
|
||||||
@@ -62,12 +91,19 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
EchartsFrame,
|
EchartsFrame,
|
||||||
SingleValue,
|
SingleValue,
|
||||||
|
ChartTablePagination,
|
||||||
'chart-table': Table
|
'chart-table': Table
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
tableColumns: [],
|
table: {
|
||||||
tableData: []
|
pageSize: chartTableDefaultPageSize,
|
||||||
|
limit: chartTableTopOptions[0], // top-n
|
||||||
|
orderBy: '',
|
||||||
|
tableColumns: [], // table字段
|
||||||
|
tableData: [], // table的所有数据
|
||||||
|
currentPageData: [] // table当前页的数据
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -88,8 +124,10 @@ export default {
|
|||||||
tableColumns.add(k)
|
tableColumns.add(k)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.tableColumns = Array.from(tableColumns)
|
this.table.tableColumns = Array.from(tableColumns)
|
||||||
this.tableData = tableResponse.data
|
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 => {
|
/* 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) {
|
if (response.code === 200) {
|
||||||
const tableColumns = new Set()
|
const tableColumns = new Set()
|
||||||
@@ -98,13 +136,18 @@ export default {
|
|||||||
tableColumns.add(k)
|
tableColumns.add(k)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.tableColumns = tableColumns
|
this.table.tableColumns = tableColumns
|
||||||
this.tableData = response.data
|
this.table.tableData = response.data
|
||||||
console.info(this.tableColumns, this.tableData)
|
|
||||||
}
|
}
|
||||||
}) */
|
}) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
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: {
|
computed: {
|
||||||
@@ -126,6 +169,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
chartInfo,
|
chartInfo,
|
||||||
layoutConstant,
|
layoutConstant,
|
||||||
|
chartTableTopOptions,
|
||||||
chartOption: getOption(props.chart.type),
|
chartOption: getOption(props.chart.type),
|
||||||
isEcharts: isEcharts(props.chart.type),
|
isEcharts: isEcharts(props.chart.type),
|
||||||
isSingleValue: isSingleValue(props.chart.type),
|
isSingleValue: isSingleValue(props.chart.type),
|
||||||
|
|||||||
Reference in New Issue
Block a user