Browse Source

大屏 档案借阅/档案类型表每隔1分钟刷新一次

master
x_ying 2 years ago
parent
commit
9637f43074
  1. 22
      src/views/components/echarts/lendAcross.vue
  2. 24
      src/views/components/echarts/typePie.vue
  3. 6
      src/views/environmentalScreen/index.vue

22
src/views/components/echarts/lendAcross.vue

@ -24,11 +24,17 @@ export default {
height: { height: {
type: String, type: String,
default: '100%' default: '100%'
},
refreshtime: {
type: Number,
default: null //
} }
}, },
data() { data() {
return { return {
chart: null
chart: null,
timer: null
} }
}, },
watch: { watch: {
@ -43,11 +49,22 @@ export default {
} }
}, },
mounted() { mounted() {
this.drawChart()
// this.drawChart()
this.refreshEchart()
}, },
beforeDestroy() { beforeDestroy() {
clearInterval(this.timer)
}, },
methods: { methods: {
refreshEchart() {
if (this.refreshtime) {
this.timer = setInterval(() => {
this.drawChart()
}, this.refreshtime)
} else {
this.drawChart()
}
},
drawChart() { drawChart() {
const chartDom = document.getElementById('mainlend') const chartDom = document.getElementById('mainlend')
this.chart = echarts.init(chartDom) this.chart = echarts.init(chartDom)
@ -144,6 +161,7 @@ export default {
} }
] ]
} }
this.chart.clear()
option && this.chart.setOption(option) option && this.chart.setOption(option)
} }

24
src/views/components/echarts/typePie.vue

@ -25,11 +25,16 @@ export default {
height: { height: {
type: String, type: String,
default: '100%' default: '100%'
},
refreshtime: {
type: Number,
default: null //
} }
}, },
data() { data() {
return { return {
chart: null
chart: null,
timer: null
} }
}, },
watch: { watch: {
@ -44,9 +49,22 @@ export default {
} }
}, },
mounted() { mounted() {
this.drawChart()
// this.drawChart()
this.refreshEchart()
},
beforeDestroy() {
clearInterval(this.timer)
}, },
methods: { methods: {
refreshEchart() {
if (this.refreshtime) {
this.timer = setInterval(() => {
this.drawChart()
}, this.refreshtime)
} else {
this.drawChart()
}
},
drawChart() { drawChart() {
const chartDom = document.getElementById('maintype') const chartDom = document.getElementById('maintype')
this.chart = echarts.init(chartDom, 'light') this.chart = echarts.init(chartDom, 'light')
@ -100,7 +118,7 @@ export default {
} }
] ]
} }
this.chart.clear()
option && this.chart.setOption(option) option && this.chart.setOption(option)
} }
} }

6
src/views/environmentalScreen/index.vue

@ -180,15 +180,15 @@
<span class="left-bottom-line" /> <span class="left-bottom-line" />
<h3><i class="iconfont icon-zhenglishi" />档案借阅</h3> <h3><i class="iconfont icon-zhenglishi" />档案借阅</h3>
<div class="chart-wrapper" style="height: calc(100% - 40px);"> <div class="chart-wrapper" style="height: calc(100% - 40px);">
<lend-across :lend-data="lendData" />
<lend-across :lend-data="lendData" :refreshtime="60000" />
</div> </div>
</div> </div>
<div class="env-item container-wrap"> <div class="env-item container-wrap">
<span class="right-top-line" /> <span class="right-top-line" />
<span class="left-bottom-line" /> <span class="left-bottom-line" />
<h3><i class="iconfont icon-zhenglishi" />整理室</h3>
<h3><i class="iconfont icon-zhenglishi" />档案类型</h3>
<div v-if="typeData.length !== 0" class="chart-wrapper" style="height: calc(100% - 40px);"> <div v-if="typeData.length !== 0" class="chart-wrapper" style="height: calc(100% - 40px);">
<type-pie :type-data="typeData" />
<type-pie :type-data="typeData" :refreshtime="60000" />
</div> </div>
<div v-else class="empty-main"> <div v-else class="empty-main">
<svg-icon icon-class="empty" class-name="empty-img" /> <svg-icon icon-class="empty" class-name="empty-img" />

Loading…
Cancel
Save