From e1e998c6cecd43a1006bfeb1bec447cf048cca57 Mon Sep 17 00:00:00 2001 From: licp <lichunping@guanfang.com.cn> Date: 星期二, 17 十二月 2024 17:08:10 +0800 Subject: [PATCH] 统计增加工时统计 --- src/components/view/b4-daily-business-statistics.vue | 186 ++++++++++++++++++++++++++++++++++++---------- 1 files changed, 146 insertions(+), 40 deletions(-) diff --git a/src/components/view/b4-daily-business-statistics.vue b/src/components/view/b4-daily-business-statistics.vue index 743edf6..04d530b 100644 --- a/src/components/view/b4-daily-business-statistics.vue +++ b/src/components/view/b4-daily-business-statistics.vue @@ -1,104 +1,126 @@ <template> <div class="daily-main" v-loading="loading"> <div class="daily-content" style="height:100%"> - <p style="font-size: 16px;padding:19.5px 0px">姣忔棩涓氬姟缁熻</p> + <div class="time" style="margin-bottom: 10px;"> + <el-radio-group v-model="type" size="small"> + <el-radio-button label="鍛�" ></el-radio-button> + <el-radio-button label="鏈�"></el-radio-button> + <el-radio-button label="骞�"></el-radio-button> + </el-radio-group> + <el-date-picker + v-model="time.week" + type="week" + format="yyyy-MM-dd" + placeholder="閫夋嫨鍛�" size="small" v-if="type=='鍛�'" @change="m=>changeTime(type,m)"> + </el-date-picker> + <el-date-picker + v-model="time.month" + type="month" + placeholder="閫夋嫨鏈�" format="yyyy-MM-dd" size="small" v-if="type=='鏈�'" @change="m=>changeTime(type,m)"> + </el-date-picker> + <el-date-picker + v-model="time.year" + type="year" + placeholder="閫夋嫨骞�" format="yyyy-MM-dd" size="small" v-if="type=='骞�'" @change="m=>changeTime(type,m)"> + </el-date-picker> + </div> <el-row :gutter="20"> - <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 30px;"> + <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;"> <div class="daily-card daily-head"> <div class="daily-head-left"> - <h4>浠婃棩浠诲姟鎺ユ敹</h4> + <h4>鏈瑊{type}}浠诲姟鎺ユ敹</h4> <span>{{ pageData.RECEIVE }}</span> <div class="daily-head-left-info"> <img :src="`../../../static/img/daliy-${pageData.RECEIVE_RATIO<0?'down':'up'}.svg`" alt=""> <span :class="{active:pageData.RECEIVE_RATIO<0}" class="num" v-html="` ${handleData(pageData.RECEIVE_RATIO)}% `"></span> - <span style="font-size: 12px;">杈冩槰澶�</span> + <span style="font-size: 12px;">杈冧笂{{type}}</span> </div> </div> <img src="../../../static/img/daliy-0.svg" alt="" srcset=""> </div> </el-col> - <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 30px;"> + <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;"> <div class="daily-card daily-head"> <div class="daily-head-left"> - <h4>浠婃棩浠诲姟瀹屾垚</h4> + <h4>鏈瑊{type}}浠诲姟瀹屾垚</h4> <span >{{ pageData.FINISHE }}</span> <div class="daily-head-left-info"> <img :src="`../../../static/img/daliy-${pageData.FINISHE_RATIO<0?'down':'up'}.svg`" alt=""> <span :class="{active:pageData.FINISHE_RATIO<0}" class="num" v-html="` ${handleData(pageData.FINISHE_RATIO)}% `"></span> - <span style="font-size: 12px;">杈冩槰澶�</span> + <span style="font-size: 12px;">杈冧笂{{type}}</span> </div> </div> <img src="../../../static/img/daliy-1.svg" alt="" srcset=""> </div> </el-col> - <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 30px;"> + <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;"> <div class="daily-card daily-head"> <div class="daily-head-left"> - <h4>浠婃棩浠诲姟鍓╀綑</h4> + <h4>鏈瑊{type}}浠诲姟鍓╀綑</h4> <span >{{ pageData.SURPLUS }}</span> <div class="daily-head-left-info"> <img :src="`../../../static/img/daliy-${pageData.SURPLUS_RATIO<0?'down':'up'}.svg`" alt=""> <span :class="{active:pageData.SURPLUS_RATIO<0}" class="num" v-html="` ${handleData(pageData.SURPLUS_RATIO)}% `"></span> - <span style="font-size: 12px;">杈冩槰澶�</span> + <span style="font-size: 12px;">杈冧笂{{type}}</span> </div> </div> <img src="../../../static/img/daliy-2.svg" alt="" srcset=""> </div> </el-col> - <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 30px;"> + <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;"> <div class="daily-card daily-head"> <div class="daily-head-left"> - <h4>浠婃棩妫�娴嬭垂鐢�</h4> - <span>锟{ pageData.PRICE }}</span> + <h4>鏈瑊{type}}妫�娴嬭垂鐢�</h4> + <span>锟{ handlePrice(pageData.PRICE) }}</span> <div class="daily-head-left-info"> <img :src="`../../../static/img/daliy-${pageData.PRICE_RATIO<0?'down':'up'}.svg`" alt=""> <span :class="{active:pageData.PRICE_RATIO}" class="num" v-html="` ${handleData(pageData.PRICE_RATIO)}% `"></span> - <span style="font-size: 12px;">杈冩槰澶�</span> + <span style="font-size: 12px;">杈冧笂{{type}}</span> </div> </div> <img src="../../../static/img/daliy-3.svg" alt="" srcset=""> </div> </el-col> - <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 30px;"> + <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;"> <div class="daily-card daily-head"> <div class="daily-head-left"> - <h4>浠婃棩妫�娴嬪伐鏃�</h4> + <h4>鏈瑊{type}}妫�娴嬪伐鏃�</h4> <span>{{pageData.COST}}</span> <div class="daily-head-left-info"> <img :src="`../../../static/img/daliy-${pageData.COST_RATIO<0?'down':'up'}.svg`" alt=""> <span :class="{active:pageData.COST_RATIO<0}" class="num" v-html="` ${handleData(pageData.COST_RATIO)}% `"></span> - <span style="font-size: 12px;">杈冩槰澶�</span> + <span style="font-size: 12px;">杈冧笂{{type}}</span> </div> </div> <img src="../../../static/img/daliy-4.svg" alt="" srcset=""> </div> </el-col> - <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 30px;"> + <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;"> <div class="daily-card daily-head"> <div class="daily-head-left"> - <h4>浠婃棩妫�娴嬩汉鍛�</h4> + <h4>鏈瑊{type}}妫�娴嬩汉鍛�</h4> <span >{{ pageData.PERSON }}</span> <div class="daily-head-left-info"> <img :src="`../../../static/img/daliy-${pageData.PERSON_RATIO<0?'down':'up'}.svg`" alt=""> <span :class="{active:pageData.PERSON_RATIO<0}" class="num" v-html="` ${handleData(pageData.PERSON_RATIO)}% `"></span> - <span style="font-size: 12px;">杈冩槰澶�</span> + <span style="font-size: 12px;">杈冧笂{{type}}</span> </div> </div> <img src="../../../static/img/daliy-5.svg" alt="" srcset=""> </div> </el-col> </el-row> - <el-row :gutter="20"> - <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-bottom: 30px;"> - <div class="daily-card chart-box"> - <h4>杩�10鏃ヤ换鍔℃帴鏀堕噺</h4> - <echart-module :id="'daily-left'" :config="chartConfig0" :datas="chartData0"></echart-module> + <el-row :gutter="20" style="height: calc(100% - 200px);"> + <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-bottom: 16px;height: 100%;"> + <div class="daily-card chart-box" style="height: 100%;"> + <h4>鏈瑊{type}}浠诲姟鎺ユ敹閲�</h4> + <echart-module :id="'daily-left'" :config="chartConfig0" :datas="chartData0" style="height: calc(100% - 32px);"></echart-module> </div> </el-col> - <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-bottom: 30px;"> - <div class="daily-card chart-box"> - <h4>杩�10鏃ュ疄闄呭畬鎴愪换鍔′笌鎺ユ敹浠诲姟瀵规瘮</h4> - <echart-module :id="'daily-right'" :config="chartConfig1" :datas="chartData1"></echart-module> + <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-bottom: 16px;height: 100%;"> + <div class="daily-card chart-box" style="height: 100%;"> + <h4>鏈瑊{type}}瀹為檯瀹屾垚浠诲姟涓庢帴鏀朵换鍔″姣�</h4> + <echart-module :id="'daily-right'" :config="chartConfig1" :datas="chartData1" style="height: calc(100% - 32px);"></echart-module> </div> </el-col> </el-row> @@ -109,12 +131,15 @@ <script> import EchartModule from '../tool/echart.vue' +import { + getYearAndMonthAndDays + } from '../../util/date' export default { components: {EchartModule}, data(){ return{ chartConfig0:{ - height: '435px', + height: '', isLoading:false, type:'line' }, @@ -128,7 +153,7 @@ ] }, chartConfig1:{ - height: '435px', + height: '', isLoading:false, type:'bar' }, @@ -136,32 +161,67 @@ xData:[], yData:[ { - title:'浠婃棩鎺ユ敹', + title:'鎺ユ敹', data:[] }, { - title:'浠婃棩瀹屾垚', + title:'瀹屾垚', data:[] }, ] }, pageData:{}, loading:false, + timers:null, + type:'鍛�', + time:{ + week:'', + month:'', + year:'', + }, + startTime:'', + endTime:'' + } + }, + watch:{ + type(val){ + switch(val){ + case '鍛�': + this.time.week = new Date() + this.changeTime(val,this.time.week) + break; + case '鏈�': + this.time.month = new Date() + this.changeTime(val,this.time.month) + break; + case '骞�': + this.time.year = new Date() + this.changeTime(val,this.time.year) + break; + } } }, mounted(){ - this.init() + this.changeTime(this.type) + // this.timers&&clearInterval(this.timers); + // setInterval(this.changeTime(this.type),1000*60*5) }, methods:{ init(){ this.chartConfig0.isLoading = false this.chartConfig1.isLoading = false this.loading = true; - this.$axios.get(this.$api.report.businessStatisticsByDay).then(res => { + this.$axios.get(this.$api.report.businessStatisticsByDay+'?startTime='+this.startTime+'&endTime='+this.endTime+'&type='+this.type).then(res => { if (res.code == 201) return this.pageData = this.HaveJson(res.data) + console.log(3333,res.data) let xData = res.data.DAYS.map(m=>{ - return `${m[1]}-${m[2]}` + let arr = m.split('-') + if(this.type=='骞�'){ + return `${arr[1]}鏈坄 + }else{ + return `${arr[1]}-${arr[2]}` + } }) this.chartData0.xData = xData this.chartData1.xData = xData @@ -175,11 +235,53 @@ }, handleData(val){ if(val){ - return Math.abs(val)*100; + let num = Math.abs(val)*100 + return num.toFixed(0); }else{ return '0' } + }, + changeTime(type,m){ + if(m){ + switch(type){ + case '鍛�': + this.startTime = getYearAndMonthAndDays(new Date(this.time.week.getTime() - 24 * 60 * 60 * 1000)) + this.endTime = getYearAndMonthAndDays(new Date(this.time.week.getTime() + 24 * 60 * 60 * 1000 * 5)) + break; + case '鏈�': + const year = new Date(this.time.month).getFullYear(); + const month = new Date(this.time.month).getMonth(); + + // 璁剧疆璧峰鏃ユ湡鍜岀粨鏉熸棩鏈� + this.startTime = new Date(year, month, 1).toISOString().slice(0, 10); // 鏈堝垵 + this.endTime = new Date(year, month + 1, 0).toISOString().slice(0, 10); // 鏈堟湯 + break; + case '骞�': + const year0 = new Date(this.time.year).getFullYear(); + this.startTime = `${year0}-01-01`; // 骞村垵 + this.endTime = `${year0}-12-31`; // 骞存湯 + break; + } + }else{ + this.startTime = getYearAndMonthAndDays(new Date((new Date).getTime() - 24 * 60 * 60 * 1000)) + this.endTime = getYearAndMonthAndDays(new Date((new Date).getTime() + 24 * 60 * 60 * 1000 * 5)) + } + this.init() + }, + handlePrice(val){ + if(val>999999){ + return (val/1000000).toFixed(2)+'鐧句竾'; + }else if(val>99999){ + return (val/100000).toFixed(2)+'鍗佷竾'; + }else if(val>9999){ + return (val/10000).toFixed(2)+'涓�'; + }else{ + return val; + } } + }, + deactivated(){ + this.timers&&clearInterval(this.timers); } } </script> @@ -189,6 +291,10 @@ height: 100%; overflow-y: auto; overflow-x: hidden; +} +.daily-content{ + padding: 20px 0; + box-sizing: border-box; } .daily-card{ width: 100%; @@ -209,7 +315,7 @@ color: #202224; font-size: 16px; font-weight: 400; - margin-bottom: 20px; + margin-bottom: 16px; opacity: 0.8; } @@ -218,7 +324,7 @@ font-weight: bold; font-size: 28px; display: inline-block; - margin-bottom: 30px; + margin-bottom: 16px; } .daily-head-left .daily-head-left-info{ @@ -236,7 +342,7 @@ } .chart-box{ - padding: 30px 24px; + padding: 16px 24px; box-sizing: border-box; } -- Gitblit v1.9.3