Commit 9799e376 authored by 王礼鸿 Baimax Wang's avatar 王礼鸿 Baimax Wang

饼图和占比定时刷新

parent ddb6e597
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<display-board class="trade_left" title="订单量占比" title_size="large"> <display-board class="trade_left" title="订单量占比" title_size="large">
<winners-list style="height: 96%;overflow: auto;" id="ar_company_list" :rows="currentDetailData" :show-icon="false" :columns-style="{'title':{'width':'50%'},'订单量(万吨)':{'width':'30%'}}" :col-formatter="{'1':(v)=>v+'%'}"/> <winners-list style="height: 96%;overflow: auto;" id="ar_company_list" :rows="currentDetailData" :show-icon="false" :columns-style="{'title':{'width':'50%'},'订单量(万吨)':{'width':'30%'}}" :col-formatter="{'1':(v)=>v+'%'}"/>
</display-board> </display-board>
<line-bar-chart style="width: 75%;height: 100%;" :data="currentDetailData" x="company" y="value" :title="chartTitle" :formatter="formatter" :line-formatter="lineFormatter" bar-formatter="{@value}万元"/> <line-bar-chart ref="chart" style="width: 75%;height: 100%;" :data="currentDetailData" x="company" y="value" :title="chartTitle" :formatter="formatter" :line-formatter="lineFormatter" bar-formatter="{@value}万元"/>
</div> </div>
</div> </div>
</template> </template>
...@@ -95,7 +95,7 @@ export default { ...@@ -95,7 +95,7 @@ export default {
getHeadData({cur_day: this.today,time_type:this.currentBtn.date,group_type:this.currentBtn.subdivide}, getHeadData({cur_day: this.today,time_type:this.currentBtn.date,group_type:this.currentBtn.subdivide},
(res) => { (res) => {
this.currentHeadData = res; this.currentHeadData = res;
if (type !== "date"){ if (type && type !== "date"){
this.currentCard = res[0]?res[0].key:null; this.currentCard = res[0]?res[0].key:null;
this.chartTitle = res[0]?(res[0].title + '委托单位占比'):null; this.chartTitle = res[0]?(res[0].title + '委托单位占比'):null;
} }
...@@ -128,16 +128,26 @@ export default { ...@@ -128,16 +128,26 @@ export default {
}, },
calcCardWidth(){ calcCardWidth(){
this.listCardStyle.width = "calc((100% - 4rem) / " + this.currentHeadData.length + ")"; this.listCardStyle.width = "calc((100% - 4rem) / " + this.currentHeadData.length + ")";
} },
refreshData(){
this.getHeadData();
},
}, },
mounted() { mounted() {
this.changeDimension(); this.changeDimension();
setTimeout(() => {
let chartDom = this.$refs.chart;
this.chart = echarts.init(chartDom);
this.chart.setOption(this.chartOption);
}, 500)
}, },
watch:{
countDown(n,o){
if (n === 1){
this.refreshData();
}
},
},
props:{
countDown:{
type: Number
}
}
} }
</script> </script>
<style scoped> <style scoped>
......
...@@ -528,6 +528,18 @@ export default { ...@@ -528,6 +528,18 @@ export default {
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener("resize", this.resizeChart); window.removeEventListener("resize", this.resizeChart);
},
watch:{
countDown(n,o){
if (n === 1){
this.refreshData();
}
},
},
props:{
countDown:{
type: Number
}
} }
}; };
</script> </script>
......
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
<div class="head" @click="goIndex"> <div class="head" @click="goIndex">
<div class="text_left"> <div class="text_left">
<input class="btn" type="button" value="返回上级" v-if="$route.fullPath !== '/index'" @click="goIndex"> <input class="btn" type="button" value="返回上级" v-if="$route.fullPath !== '/index'" @click="goIndex">
<span>2023-08-01</span> <span>{{ currentDate }}</span>
<span>17:18:29</span> <span>{{ currentTime }}</span>
<span>星期三</span> <span>{{ currentWeek }}</span>
</div> </div>
<div class="text_right"> <div class="text_right">
<span>刷新时间:{{ countDown }}s</span> <span>刷新时间:{{ countDown }}s</span>
</div> </div>
</div> </div>
<router-view style="height: 90%" v-if="isRouterAlive"></router-view> <router-view style="height: 90%" v-if="isRouterAlive" :countDown="countDown"></router-view>
</div> </div>
</template> </template>
...@@ -24,14 +24,17 @@ export default { ...@@ -24,14 +24,17 @@ export default {
name: 'app', name: 'app',
data() { data() {
return { return {
countDown: 10000, countDown: 10,
currentDate: null,
currentTime: null,
currentWeek: null,
isRouterAlive: true, isRouterAlive: true,
countDownTimer: null, countDownTimer: null,
week: ['星期天','星期一','星期二','星期三','星期四','星期五'],
} }
}, },
methods: { methods: {
goIndex() { goIndex() {
console.log(this.$router)
this.$router.push({path: '/'}) this.$router.push({path: '/'})
}, },
reload() { reload() {
...@@ -40,15 +43,21 @@ export default { ...@@ -40,15 +43,21 @@ export default {
this.isRouterAlive = true this.isRouterAlive = true
}) })
}, },
setCurrentDateTime(){
let now = new Date();
this.currentDate = now.getFullYear() + "-" + now.getMonth() + "-" + now.getDate();
this.currentTime = now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
this.currentWeek = this.week[now.getDay()];
},
}, },
mounted() { mounted() {
// 倒计时器 // 倒计时器
this.countDownTimer = setInterval(() => { this.countDownTimer = setInterval(() => {
this.countDown-- this.countDown--
if (this.countDown <= 0) { if (this.countDown <= 0) {
// this.reload() this.countDown = 10;
this.countDown = 10
} }
this.setCurrentDateTime();
}, 1000) }, 1000)
}, },
beforeDestroy() { beforeDestroy() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment