Browse Source

perf: 优化样式

master
kiki 2 years ago
parent
commit
184462bf2d
  1. 14
      src/utils/ruoyi.js
  2. 552
      src/views/data-view/components/data-view-echart.vue
  3. 61
      src/views/data-view/components/data-view-layout.vue
  4. 28
      src/views/data-view/components/data-view-table.vue
  5. 27
      src/views/data-view/data-view.vue

14
src/utils/ruoyi.js

@ -413,13 +413,13 @@ export function amountFriendlyFormat(amount, unit) {
} }
} }
// 百 // 百
if (amount >= 100 || unit === '百') { // if (amount >= 100 || unit === '百') {
return { // return {
unit: '百', // unit: '百',
amount: amount / 100, // amount: amount / 100,
display: `${amount / 100}` // display: `${amount / 100}百`
} // }
} // }
return { return {
unit: '', unit: '',
amount: amount, amount: amount,

552
src/views/data-view/components/data-view-echart.vue

@ -1,7 +1,7 @@
<template> <template>
<div <div
ref="charts" ref="charts"
style="min-width: 12vw;max-height:220px;height:220px;" style="width: 18vw;height:23vh;"
/> />
</template> </template>
@ -9,6 +9,24 @@
import * as echarts from 'echarts' import * as echarts from 'echarts'
import { debounce } from '@/utils' import { debounce } from '@/utils'
function fontSize(res){
let clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
if (!clientWidth) return;
let fontSize = 100 * (clientWidth / 1920);
return res*fontSize;
}
function fontSize2(res){
let height = document.documentElement.clientHeight
if (!height) return;
let fontSize = 100 * (height / 1080);
return res*fontSize;
}
function max(v1, v2) {
return v1 > v2 ? v2 : v1
}
export default { export default {
props: { props: {
config: Object config: Object
@ -26,19 +44,43 @@ export default {
}, },
data() { data() {
return { return {
chart: null chart: null,
} }
}, },
computed: { mounted() {
option() { window.addEventListener('resize', debounce(() => {
this.chart?.resize()
setTimeout(() => {
this.chart?.setOption(this.getOption())
}, 200)
}, 200))
},
methods: {
getOption() {
console.log("reseize")
let percent = 0 let percent = 0
if (this.config.total === 0) { if (this.config.total === 0) {
percent = 0 percent = 0
} else { } else {
percent = ((this.config.value / this.config.total) * 100).toFixed(2) percent = ((this.config.value / this.config.total) * 100).toFixed(2)
percent = percent > 100 ? 100 : percent
} }
const center = ['50%', '55%'] const center = ['50%', '45%']
const self = this const self = this
//
const outSideFontSize = max(fontSize2(0.22), 16)
//
const outSideTextHeight = max(fontSize2(0.3), 26)
//
const insideFontSize = max(fontSize2(0.18), 18)
//
const insideTextHeight = 0
//
const insideBigFontSize = max(fontSize2(0.38), 40)
//
const insideBigTextHeight = max(fontSize2(0.70), 70)
return { return {
grid: { grid: {
left: '0', left: '0',
@ -70,7 +112,7 @@ export default {
// //
polar: { polar: {
center: center, center: center,
radius: '100%' radius: '145%'
}, },
series: [ series: [
@ -80,7 +122,7 @@ export default {
name: '内部透明起始结束的圆边', name: '内部透明起始结束的圆边',
type: 'gauge', type: 'gauge',
center: center, center: center,
radius: '80%', radius: '90%',
splitNumber: 10, splitNumber: 10,
axisLine: { axisLine: {
lineStyle: { lineStyle: {
@ -141,15 +183,15 @@ export default {
rich: { rich: {
t1: { t1: {
fontFamily: 'PingFang TC', fontFamily: 'PingFang TC',
fontSize: '5%', fontSize: outSideFontSize,
color: '#C6CEEC', color: '#C6CEEC',
lineHeight: 18 lineHeight: outSideTextHeight
}, },
t2: { t2: {
fontFamily: 'PingFang TC', fontFamily: 'PingFang TC',
fontSize: '10%', fontSize: outSideFontSize,
color: '#FFFFFF', color: '#FFFFFF',
lineHeight: 18 lineHeight: outSideTextHeight
} }
} }
}, },
@ -172,156 +214,156 @@ export default {
}, },
// //
{ // {
name: 'border', // name: 'border',
type: 'pie', // type: 'pie',
clockWise: false, // clockWise: false,
radius: '70%', // radius: '70%',
center: center, // center: center,
animation: false, // animation: false,
z: 0, // z: 0,
data: [{ // data: [{
value: 0, // value: 0,
color: 'transparent', // color: 'transparent',
label: { // label: {
show: false // show: false
}, // },
labelLine: { // labelLine: {
show: false // show: false
}, // },
emphasis: { // emphasis: {
disabled: true // disabled: true
}, // },
select: { // select: {
disabled: true // disabled: true
}, // },
tooltip: { // tooltip: {
show: false // show: false
}, // },
itemStyle: { // itemStyle: {
color: '#071422', // color: '#071422',
shadowColor: this.config.shadowColor, // shadowColor: this.config.shadowColor,
shadowBlur: 25, // shadowBlur: 25,
shadowOffsetX: 0, // shadowOffsetX: 0,
shadowOffsetY: -15 // shadowOffsetY: -15
} // }
}] // }]
}, // },
// () // ()
{ // {
name: '阴影的边框(中间)', // name: '()',
type: 'gauge', // type: 'gauge',
center: center, // center: center,
radius: '70%', // radius: '70%',
axisLine: { // axisLine: {
lineStyle: { // lineStyle: {
color: [ // color: [
// /// // // ///
[ // [
0.6, // 0.6,
new echarts.graphic.LinearGradient( // new echarts.graphic.LinearGradient(
0, 0, 1, 0, // 0, 0, 1, 0,
[ // [
{ // {
offset: 0.2, // offset: 0.2,
color: this.config.opacityBorder[0] // color: this.config.opacityBorder[0]
}, // },
{ // {
offset: 0.7, // offset: 0.7,
color: this.config.opacityBorder[1] // color: this.config.opacityBorder[1]
}, // },
{ // {
offset: 1, // offset: 1,
color: this.config.opacityBorder[0] // color: this.config.opacityBorder[0]
} // }
] // ]
) // )
] // ]
], // ],
width: 2 // width: 2
} // }
}, // },
z: 4, // z: 4,
axisLabel: { // axisLabel: {
show: false // show: false
}, // },
axisTick: { // axisTick: {
show: false // show: false
}, // },
splitLine: { // splitLine: {
show: false // show: false
}, // },
detail: { // detail: {
show: false // show: false
}, // },
label: { // label: {
show: false // show: false
}, // },
pointer: { // pointer: {
show: false // show: false
}, // },
title: { // title: {
// // //
show: false // show: false
}, // },
data: [ // data: [
{ // {
name: percent + '%', // name: percent + '%',
value: percent // value: percent
} // }
] // ]
}, // },
// //
{ // {
name: '外部刻度', // name: '',
type: 'gauge', // type: 'gauge',
center: center, // center: center,
radius: '75%', // radius: '75%',
min: 0, // // min: 0, //
max: 100, // // max: 100, //
splitNumber: 10, // // splitNumber: 10, //
startAngle: 225, // startAngle: 225,
endAngle: -45, // endAngle: -45,
axisLine: { // axisLine: {
show: false, // show: false,
lineStyle: { // lineStyle: {
width: 1, // width: 1,
color: [ // color: [
[1, 'rgba(0,0,0,0)'] // [1, 'rgba(0,0,0,0)']
] // ]
} // }
}, // },
//线 // //线
axisLabel: { // axisLabel: {
show: false // show: false
}, // // }, //
axisTick: { // axisTick: {
show: true, // show: true,
splitNumber: 4, // splitNumber: 4,
lineStyle: { // lineStyle: {
// // //
color: '#6DCBFF', // color: '#6DCBFF',
width: 1 // width: 1
}, // },
length: 1 // length: 1
}, // },
// // //
splitLine: { // splitLine: {
show: true, // show: true,
length: 2, // length: 2,
lineStyle: { // lineStyle: {
// // //
color: '#6DCBFF' // color: '#6DCBFF'
} // }
}, //线 // }, //线
detail: { // detail: {
show: false // show: false
}, // },
pointer: { // pointer: {
show: false // show: false
} // }
}, // },
// , // ,
{ {
@ -373,89 +415,89 @@ export default {
z: 1 z: 1
}, },
{ // {
name: '内部透明起始结束的圆边', // name: '',
type: 'gauge', // type: 'gauge',
center: center, // center: center,
radius: '40%', // radius: '40%',
splitNumber: 10, // splitNumber: 10,
axisLine: { // axisLine: {
lineStyle: { // lineStyle: {
color: [ // color: [
[0, new echarts.graphic.LinearGradient( // [0, new echarts.graphic.LinearGradient(
0, 1, 0, 0, // 0, 1, 0, 0,
[{ // [{
offset: 0, // offset: 0,
color: this.config.circle2Color[0] // color: this.config.circle2Color[0]
}, { // }, {
offset: 1, // offset: 1,
color: this.config.circle2Color[1] // color: this.config.circle2Color[1]
}] // }]
)], // )],
[0.2, new echarts.graphic.LinearGradient( // [0.2, new echarts.graphic.LinearGradient(
0, 1, 0, 0, // 0, 1, 0, 0,
[{ // [{
offset: 0, // offset: 0,
color: this.config.circle2Color[0] // color: this.config.circle2Color[0]
}, { // }, {
offset: 1, // offset: 1,
color: this.config.circle2Color[1] // color: this.config.circle2Color[1]
}] // }]
)], // )],
[0.8, new echarts.graphic.LinearGradient( // [0.8, new echarts.graphic.LinearGradient(
0, 0, 1, 0, // 0, 0, 1, 0,
[{ // [{
offset: 0, // offset: 0,
color: this.config.circle2Color[1] // color: this.config.circle2Color[1]
}, { // }, {
offset: 1, // offset: 1,
color: this.config.circle2Color[1] // color: this.config.circle2Color[1]
}] // }]
)], // )],
[1, new echarts.graphic.LinearGradient( // [1, new echarts.graphic.LinearGradient(
0, 0, 0, 1, // 0, 0, 0, 1,
[{ // [{
offset: 0, // offset: 0,
color: this.config.circle2Color[1] // color: this.config.circle2Color[1]
}, { // }, {
offset: 1, // offset: 1,
color: this.config.circle2Color[0] // color: this.config.circle2Color[0]
}] // }]
)] // )]
], // ],
width: 1 // width: 1
} // }
}, // },
z: 4, // z: 4,
axisLabel: { // axisLabel: {
show: false // show: false
}, // },
axisTick: { // axisTick: {
show: false // show: false
}, // },
splitLine: { // splitLine: {
show: false // show: false
}, // },
detail: { // detail: {
show: false // show: false
}, // },
label: { // label: {
show: false // show: false
}, // },
pointer: { // pointer: {
show: false // show: false
}, // },
title: { // title: {
// // //
show: false // show: false
}, // },
data: [ // data: [
{ // {
name: percent + '%', // name: percent + '%',
value: percent // value: percent
} // }
] // ]
}, // },
// //
{ {
@ -463,7 +505,7 @@ export default {
type: 'pie', type: 'pie',
clockWise: false, clockWise: false,
hoverAnimation: false, hoverAnimation: false,
radius: ['35%', '35%'],// radius: ['55%', '55%'],//
center: center,// center: center,//
tooltip: { tooltip: {
show: false show: false
@ -487,7 +529,7 @@ export default {
// //
{ {
type: 'pie', type: 'pie',
radius: '35%', radius: '55%',
center: center, center: center,
z: 1, z: 1,
itemStyle: { itemStyle: {
@ -522,26 +564,26 @@ export default {
show: true, show: true,
position: 'center', position: 'center',
color: '#4c4a4a', color: '#4c4a4a',
formatter: `{t1|${percent}%}\n{t2|${this.config.value}}\n{t3|${this.config.unit}}`, formatter: `{t1| ${percent}%}\n{t2|${this.config.value}}\n{t3|${this.config.unit}}`,
rich: { rich: {
t1: { t1: {
fontFamily: 'PingFang TC', fontFamily: 'PingFang TC',
fontSize: '5%', fontSize: insideFontSize,
color: '#C6CEEC', color: '#C6CEEC',
lineHeight: 14 lineHeight: insideTextHeight
}, },
t2: { t2: {
fontFamily: 'PingFang TC', fontFamily: 'PingFang TC',
fontSize: '10%', fontSize: insideBigFontSize,
color: '#FFFFFF', color: '#FFFFFF',
lineHeight: 14, lineHeight: insideBigTextHeight,
fontWeight: 600 fontWeight: 600
}, },
t3: { t3: {
fontFamily: 'PingFang TC', fontFamily: 'PingFang TC',
fontSize: '5%', fontSize: insideFontSize,
color: '#C6CEEC', color: '#C6CEEC',
lineHeight: 14 lineHeight: insideTextHeight
} }
} }
}, },
@ -556,20 +598,12 @@ export default {
} }
] ]
} }
}
}, },
mounted() {
window.addEventListener('resize', debounce(() => {
this.chart?.resize()
}, 200))
},
methods: {
init() { init() {
if (!this.chart) { if (!this.chart) {
this.chart = echarts.init(this.$refs.charts) this.chart = echarts.init(this.$refs.charts)
} }
this.chart.setOption(this.option) this.chart.setOption(this.getOption())
} }
} }
} }

61
src/views/data-view/components/data-view-layout.vue

@ -10,18 +10,25 @@
> >
<div class="identifier data-view-header-item"> <div class="identifier data-view-header-item">
<img style="width: 23px; height: 23px;" :src="icon" alt=""> <img style="width: 23px; height: 23px;" :src="icon" alt="">
<span style="padding-left: 10px;">{{identifier}}</span> <span style="padding-left: 10px;">{{ identifier }}</span>
</div> </div>
<h1 class="YouSheBiaoTiHei data-view-header-title data-view-header-item" style="text-align: center;">{{ title }}</h1> <h1 class="YouSheBiaoTiHei data-view-header-title data-view-header-item" style="text-align: center;">{{
title
}}</h1>
<div class="data-view-header-time data-view-header-item"> <div class="data-view-header-time data-view-header-item">
<img @click="$emit('leave')" style="width: 26px; height: 26px; cursor: pointer;" :src="ICUNFullscreen" alt=""> <img @click="$emit('leave')" style="width: 26px; height: 26px; cursor: pointer;" :src="ICUNFullscreen" alt="">
<div style="width: 26px;"/> <div style="width: 26px;"/>
<span>{{date}}</span> <span>{{ date }}</span>
</div> </div>
</div> </div>
<!-- 中间的图表 -->
<div class="data-view-charts-body">
<slot name="charts"></slot>
</div>
<!-- 内容 --> <!-- 内容 -->
<div class="data-view-body"> <div class="data-view-tables-body">
<!-- 左边的表格 --> <!-- 左边的表格 -->
<div class="left-table"> <div class="left-table">
<slot name="left-table"/> <slot name="left-table"/>
@ -29,15 +36,9 @@
<!-- 中间的内容 --> <!-- 中间的内容 -->
<div class="middle"> <div class="middle">
<!-- 中间的图表 -->
<div class="middle-charts">
<slot name="middle-charts"></slot>
</div>
<!-- 中间的表格 --> <!-- 中间的表格 -->
<div class="middle-table">
<slot name="middle-table"/> <slot name="middle-table"/>
</div> </div>
</div>
<!-- 右边的表格 --> <!-- 右边的表格 -->
<div class="right-table"> <div class="right-table">
@ -54,9 +55,8 @@ import DataViewHeaderBg from '@/assets/images/data-view-header-bg.png'
import ICUNFullscreen from '@/assets/images/ic_unfullscreen.png' import ICUNFullscreen from '@/assets/images/ic_unfullscreen.png'
import { getWeek, parseTime } from '@/utils/ruoyi' import { getWeek, parseTime } from '@/utils/ruoyi'
export default { export default {
components: { }, components: {},
props: { props: {
// //
identifier: { identifier: {
@ -76,13 +76,13 @@ export default {
ICUNFullscreen, ICUNFullscreen,
DataViewBG, DataViewBG,
DataViewHeaderBg, DataViewHeaderBg,
date: parseTime(new Date(), `{y}-{m}-{d} {h}:{i}:{s}`) + " " + getWeek() date: parseTime(new Date(), `{y}-{m}-{d} {h}:{i}:{s}`) + ' ' + getWeek()
} }
}, },
mounted() { mounted() {
// //
setInterval(() => { setInterval(() => {
this.date = parseTime(new Date(), `{y}-{m}-{d} {h}:{i}:{s}`) + " " + getWeek() this.date = parseTime(new Date(), `{y}-{m}-{d} {h}:{i}:{s}`) + ' ' + getWeek()
}, 1000) }, 1000)
} }
} }
@ -142,37 +142,36 @@ export default {
} }
.data-view-body { .data-view-charts-body {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
margin-top: 40px; margin-top: 10px;
padding: 0 20px 0 20px; width: 75vw;
} align-self: center;
.left-table {
width: 23.5%;
} }
.middle { .data-view-tables-body {
width: 50%;
.middle-charts {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
} margin-top: 30px;
padding: 0 20px 20px 20px;
overflow: hidden;
height: 100%;
.middle-table { .left-table {
margin-top: max(0.5vh, 25px); width: 23.5%;
} }
} .middle {
width: 50%;
}
.right-table { .right-table {
width: 23.5%; width: 23.5%;
}
} }
</style> </style>

28
src/views/data-view/components/data-view-table.vue

@ -126,7 +126,8 @@ export default {
<style scoped lang="scss"> <style scoped lang="scss">
.data-view-table { .data-view-table {
height: 100%;
overflow: hidden;
table { table {
/*设置相邻单元格的边框间的距离*/ /*设置相邻单元格的边框间的距离*/
@ -136,20 +137,16 @@ export default {
text-align: center; text-align: center;
} }
table tbody {
display: block;
overflow-y: scroll;
}
table tbody::-webkit-scrollbar { table tbody::-webkit-scrollbar {
display: none; /* Chrome Safari */ display: none; /* Chrome Safari */
} }
table tbody { table > tbody {
scrollbar-width: none; /* firefox */ scrollbar-width: none; /* firefox */
-ms-overflow-style: none; /* IE 10+ */ -ms-overflow-style: none; /* IE 10+ */
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: scroll;
height: 48vh;
} }
.data-view-table-body { .data-view-table-body {
@ -239,21 +236,6 @@ export default {
} }
.data-view-table--large {
table tbody {
height: 40vh;
}
}
.data-view-table--middle {
table tbody {
height: 65vh;
}
}
.data-view-table-body-header { .data-view-table-body-header {

27
src/views/data-view/data-view.vue

@ -6,6 +6,14 @@
@leave="handleLeave" @leave="handleLeave"
ref="layout" ref="layout"
> >
<template #charts>
<data-view-echart :config="chart1"/>
<data-view-echart :config="chart2"/>
<data-view-echart :config="chart3"/>
<data-view-echart :config="chart4"/>
</template>
<template #left-table> <template #left-table>
<data-view-table <data-view-table
title="商户数据" title="商户数据"
@ -23,13 +31,6 @@
/> />
</template> </template>
<template #middle-charts>
<data-view-echart :config="chart1"/>
<data-view-echart :config="chart2"/>
<data-view-echart :config="chart3"/>
<data-view-echart :config="chart4"/>
</template>
<template #middle-table> <template #middle-table>
<data-view-table <data-view-table
title="在线卡数据" title="在线卡数据"
@ -130,7 +131,7 @@ export default {
value: 0, value: 0,
total: 0, total: 0,
unit: "单", unit: "单",
progressBar: ["#4494FF", '#EFA83E'], progressBar: ["#42EA9A", '#EFA83E'],
progressBarBG: '#0A2F28', progressBarBG: '#0A2F28',
circle2Color: ['#30BE7900', '#30BE79'], circle2Color: ['#30BE7900', '#30BE79'],
innerCircle: ['#2EB87642', '#2EB87642', '#2AA56C'], innerCircle: ['#2EB87642', '#2EB87642', '#2AA56C'],
@ -144,7 +145,7 @@ export default {
value: 0, value: 0,
total: 0, total: 0,
unit: "元", unit: "元",
progressBar: ["#4494FF", '#EFA83E'], progressBar: ["#42EA9A", '#EFA83E'],
progressBarBG: '#0A2F28', progressBarBG: '#0A2F28',
circle2Color: ['#30BE7900', '#30BE79'], circle2Color: ['#30BE7900', '#30BE79'],
innerCircle: ['#2EB87642', '#2EB87642', '#2AA56C'], innerCircle: ['#2EB87642', '#2EB87642', '#2AA56C'],
@ -210,18 +211,18 @@ export default {
this.chart2.totalLabel = '总金额:' + chart2Total.display this.chart2.totalLabel = '总金额:' + chart2Total.display
const chart3Total = amountFriendlyFormat(statisticsPush.transferSuccessQty) const chart3Total = amountFriendlyFormat(statisticsPush.transferTotalQty)
const chart3Value = amountFriendlyFormat(statisticsPush.transferTotalQty, chart3Total.unit) const chart3Value = amountFriendlyFormat(statisticsPush.transferSuccessQty, chart3Total.unit)
this.chart3.value = chart3Value.amount this.chart3.value = chart3Value.amount
this.chart3.unit = chart3Value.unit + "单" this.chart3.unit = chart3Value.unit + "单"
this.chart3.total = chart3Total.amount this.chart3.total = chart3Total.amount
this.chart3.totalLabel = '总订单:' + chart3Total.display this.chart3.totalLabel = '总订单:' + chart3Total.display
const transferSuccessAmount = statisticsPush.transferSuccessAmount const transferSuccessAmount = statisticsPush.transferSuccessAmount
const transferTotalAmount = statisticsPush.transferTotalAmount const transferTotalAmount = statisticsPush.transferTotalAmount
const chart4Total = amountFriendlyFormat(transferTotalAmount) const chart4Total = amountFriendlyFormat(transferTotalAmount)
const chart4Value = amountFriendlyFormat(transferSuccessAmount, chart4Total.unit) const chart4Value = amountFriendlyFormat(transferSuccessAmount, chart4Total.unit)
this.chart4.value = chart4Value.amount this.chart4.value = chart4Value.amount
this.chart4.unit = chart4Value.unit + "元" this.chart4.unit = chart4Value.unit + "元"
this.chart4.total = chart4Total.amount this.chart4.total = chart4Total.amount
@ -261,7 +262,7 @@ export default {
this.data3 = carddealer.map(i => { this.data3 = carddealer.map(i => {
return { return {
username: i.username, username: i.username,
dayMargin: (amountFormat({ amount: i.dayMargin }) || "0") + (amountFormat({ amount: i.margin }) || "0"), dayMargin: (amountFormat({ amount: i.dayMargin }) || "0") + "/" + (amountFormat({ amount: i.margin }) || "0"),
toDayTotal: amountFormat({ amount: i.toDayTotal }) || "0", toDayTotal: amountFormat({ amount: i.toDayTotal }) || "0",
turnoverRate: (i.turnoverRate * 100).toFixed(2) + "%", turnoverRate: (i.turnoverRate * 100).toFixed(2) + "%",
balanceWarning: i.balanceWarning, balanceWarning: i.balanceWarning,

Loading…
Cancel
Save