| | |
| | | <template> |
| | | <div>工作统计图</div> |
| | | <div class="work-main" style="overflow: scroll;width:100%;height:100vh"> |
| | | <div class="work-head"> |
| | | <el-row :gutter="10"> |
| | | <el-col :span="24"> |
| | | <el-card> |
| | | <el-form :rules="rules" ref="formInline" :inline="true" |
| | | :model="formInline" class="demo-form-inline"> |
| | | <el-form-item prop="date" label="检测日期:"> |
| | | <el-date-picker |
| | | size="small" |
| | | v-model="formInline.date" |
| | | format="yyyy-MM-dd" |
| | | value-format="yyyy-MM-dd" |
| | | type="daterange" |
| | | range-separator="至" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item prop="type" label="检验类型:"> |
| | | <el-select size="small" v-model="formInline.type" placeholder="采购入库"> |
| | | <el-option label="原材料" value="0"></el-option> |
| | | <el-option label="成品" value="1"></el-option> |
| | | <el-option label="委托品" value="2"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item class="buttons"> |
| | | <el-button size="small" @click="resetForm('formInline')">清空</el-button> |
| | | <el-button size="small" type="primary" @click="onSubmit('formInline')">查询</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | <div class="work-center" > |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-card> |
| | | <p>负责人统计</p> |
| | | <div id="leaderStati" style="width:100%;height:400px;"></div> |
| | | </el-card> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-card> |
| | | <p>实验员统计</p> |
| | | <div id="testerStati" style="width:100%;height:400px;"></div> |
| | | </el-card> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-card> |
| | | <p>负责人及时率</p> |
| | | <div id="leaderTimely" style="width:100%;height:400px;"></div> |
| | | </el-card> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-card> |
| | | <p>实验员及时率</p> |
| | | <div id="testerTimely" style="width:100%;height:400px;"></div> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | <div class="work-foot"> |
| | | <el-button size="small" type="primary">数据导出</el-button> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import * as echarts from 'echarts'; |
| | | import { getDutyMater,getDutyTimely,getExecuteMater,getExecuteTimely |
| | | } from '@/api/chart/work/index' |
| | | export default { |
| | | data() { |
| | | return { |
| | | formInline: { |
| | | date: null, |
| | | type: '' |
| | | }, |
| | | rules: { |
| | | type: [ |
| | | { required: true, message: '请选择检测类型', trigger: 'change' } |
| | | ], |
| | | date: [ |
| | | {required: true, message: '请选择日期', trigger: 'change' } |
| | | ] |
| | | }, |
| | | } |
| | | }, |
| | | mounted(){ |
| | | this.queryData(); |
| | | }, |
| | | methods: { |
| | | async queryData(){ |
| | | let date = []; |
| | | let type; |
| | | if(this.formInline.date == null || this.formInline.date == ""){ |
| | | let currentDate = new Date(); |
| | | let year = currentDate.getFullYear(); |
| | | let month = currentDate.getMonth() + 1; |
| | | let day = currentDate.getDate(); |
| | | date.push(year +"-" + month + "-01"); |
| | | date.push(year +"-" + month + "-" + day); |
| | | type = 0; |
| | | }else{ |
| | | date = this.formInline.date; |
| | | type = this.formInline.type; |
| | | } |
| | | let obj = { |
| | | startTime : date[0], |
| | | endTime : date[1], |
| | | type : type |
| | | } |
| | | const dutyMater = await getDutyMater(obj); |
| | | const dutyTimely = await getDutyTimely(obj); |
| | | const executeMater = await getExecuteMater(obj); |
| | | const executeTimely = await getExecuteTimely(obj); |
| | | this.initLeaderStatiChart("leaderStati",dutyMater.data); |
| | | this.initLeaderTimelyChart("leaderTimely",dutyTimely.data); |
| | | this.initTesterStatiChart("testerStati",executeMater.data); |
| | | this.initTesterTimelyChart("testerTimely",executeTimely.data); |
| | | }, |
| | | onSubmit(formName) { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | this.queryData(); |
| | | } else { |
| | | console.log('error submit!!'); |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | resetForm(formName) { |
| | | this.formInline.date = null; |
| | | this.formInline.type = null; |
| | | this.$refs[formName].resetFields(); |
| | | }, |
| | | initLeaderStatiChart(id,dutyMater){ |
| | | var chartDom = document.getElementById(id); |
| | | var myChart = echarts.init(chartDom); |
| | | window.addEventListener('resize', function() { |
| | | myChart.resize(); |
| | | }); |
| | | var option; |
| | | let max = 0; |
| | | let xAxisData = []; |
| | | let data1 = []; |
| | | let data2 = []; |
| | | for(let i=0;i<dutyMater.length;i++){ |
| | | xAxisData.push(dutyMater[i].name); |
| | | data1.push(dutyMater[i].finsh); |
| | | data2.push(dutyMater[i].unfinish); |
| | | let sum = dutyMater[i].finsh + dutyMater[i].unfinish; |
| | | if( sum > max ){ |
| | | max = sum; |
| | | } |
| | | } |
| | | var emphasisStyle = { |
| | | itemStyle: { |
| | | shadowBlur: 10, |
| | | shadowColor: 'rgba(0,0,0,0.3)' |
| | | } |
| | | }; |
| | | option = { |
| | | legend: { |
| | | data: ['已完成', '未完成'], |
| | | left: 'center' |
| | | }, |
| | | tooltip: {}, |
| | | xAxis: { |
| | | data: xAxisData, |
| | | name: '姓名', |
| | | axisLine: { onZero: true }, |
| | | splitLine: { show: false }, |
| | | splitArea: { show: false } |
| | | }, |
| | | yAxis: { |
| | | min: 0, |
| | | max: max, |
| | | interval: max, |
| | | }, |
| | | grid: { |
| | | bottom: 100 |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '已完成', |
| | | barWidth: '30%', |
| | | type: 'bar', |
| | | stack: 'one', |
| | | emphasis: emphasisStyle, |
| | | data: data1, |
| | | itemStyle: { |
| | | color: '#80d9c5' |
| | | } |
| | | }, |
| | | { |
| | | name: '未完成', |
| | | barWidth: '20%', |
| | | type: 'bar', |
| | | stack: 'one', |
| | | emphasis: emphasisStyle, |
| | | data: data2, |
| | | itemStyle: { |
| | | color: '#f2d09d' |
| | | }, |
| | | } |
| | | ] |
| | | }; |
| | | option && myChart.setOption(option); |
| | | }, |
| | | initTesterStatiChart(id,executeMater){ |
| | | var chartDom = document.getElementById(id); |
| | | var myChart = echarts.init(chartDom); |
| | | window.addEventListener('resize', function() { |
| | | myChart.resize(); |
| | | }); |
| | | var option; |
| | | let max = 0; |
| | | let xAxisData = []; |
| | | let data1 = []; |
| | | let data2 = []; |
| | | for(let i=0;i<executeMater.length;i++){ |
| | | xAxisData.push(executeMater[i].name); |
| | | data1.push(executeMater[i].finsh); |
| | | data2.push(executeMater[i].unfinsh); |
| | | let sum = executeMater[i].finsh + executeMater[i].unfinsh; |
| | | if(sum > max){ |
| | | max = sum; |
| | | } |
| | | } |
| | | var emphasisStyle = { |
| | | itemStyle: { |
| | | shadowBlur: 10, |
| | | shadowColor: 'rgba(0,0,0,0.3)' |
| | | } |
| | | }; |
| | | option = { |
| | | legend: { |
| | | data: ['数据1', '数据2'], |
| | | left: 'center' |
| | | }, |
| | | tooltip: {}, |
| | | xAxis: { |
| | | data: xAxisData, |
| | | name: '姓名', |
| | | axisLine: { onZero: true }, |
| | | splitLine: { show: false }, |
| | | splitArea: { show: false } |
| | | }, |
| | | yAxis: { |
| | | min: 0, |
| | | max: max, |
| | | interval: 1, |
| | | }, |
| | | grid: { |
| | | bottom: 100 |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '数据1', |
| | | type: 'bar', |
| | | stack: 'one', |
| | | barWidth: '30%', |
| | | emphasis: emphasisStyle, |
| | | data: data1, |
| | | itemStyle:{ |
| | | color: "#d97559" |
| | | } |
| | | }, |
| | | { |
| | | name: '数据2', |
| | | type: 'bar', |
| | | stack: 'one', |
| | | barWidth: '30%', |
| | | emphasis: emphasisStyle, |
| | | data: data2, |
| | | itemStyle:{ |
| | | color: "#e4c477" |
| | | } |
| | | } |
| | | ] |
| | | }; |
| | | option && myChart.setOption(option); |
| | | }, |
| | | initLeaderTimelyChart(id,dutyTimely){ |
| | | var chartDom = document.getElementById(id); |
| | | var myChart = echarts.init(chartDom); |
| | | window.addEventListener('resize', function() { |
| | | myChart.resize(); |
| | | }); |
| | | var option; |
| | | let xAxisData = []; |
| | | let data1 = []; |
| | | let data2 = []; |
| | | let yAxisData1 = 0; |
| | | for(let i=0;i<dutyTimely.length;i++){ |
| | | xAxisData.push(dutyTimely[i].name); |
| | | data1.push(dutyTimely[i].total); |
| | | data2.push(dutyTimely[i].timely); |
| | | if(dutyTimely[i].total > yAxisData1){ |
| | | yAxisData1 = dutyTimely[i].total; |
| | | } |
| | | } |
| | | option = { |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'cross', |
| | | crossStyle: { |
| | | color: '#999' |
| | | } |
| | | } |
| | | }, |
| | | legend: { |
| | | data: ['样品数', '完成及时率'] |
| | | }, |
| | | xAxis: [ |
| | | { |
| | | name: '姓名', |
| | | type: 'category', |
| | | data: xAxisData, |
| | | axisPointer: { |
| | | type: 'shadow' |
| | | }, |
| | | nameTextStyle:{ |
| | | padding:20 |
| | | } |
| | | } |
| | | ], |
| | | yAxis: [ |
| | | { |
| | | type: 'value', |
| | | name: '数量', |
| | | min: 0, |
| | | max: yAxisData1, |
| | | interval: 1, |
| | | axisLabel: { |
| | | formatter: '{value}' |
| | | } |
| | | }, |
| | | { |
| | | type: 'value', |
| | | name: '百分比', |
| | | min: 0, |
| | | max: 100, |
| | | interval: 10, |
| | | axisLabel: { |
| | | formatter: '{value} %' |
| | | } |
| | | } |
| | | ], |
| | | series: [ |
| | | { |
| | | name: '样品数', |
| | | type: 'bar', |
| | | barWidth: '30%', |
| | | tooltip: { |
| | | valueFormatter: function (value) { |
| | | return value; |
| | | } |
| | | }, |
| | | data: data1, |
| | | itemStyle: { |
| | | color: '#9fceff' |
| | | } |
| | | }, |
| | | { |
| | | name: '完成及时率', |
| | | type: 'line', |
| | | yAxisIndex: 1, |
| | | tooltip: { |
| | | valueFormatter: function (value) { |
| | | return value + ' %'; |
| | | } |
| | | }, |
| | | data: data2, |
| | | itemStyle: { |
| | | color: '#d2eec5' |
| | | } |
| | | }, |
| | | ] |
| | | }; |
| | | option && myChart.setOption(option); |
| | | }, |
| | | initTesterTimelyChart(id,executeTimely){ |
| | | var chartDom = document.getElementById(id); |
| | | var myChart = echarts.init(chartDom); |
| | | window.addEventListener('resize', function() { |
| | | myChart.resize(); |
| | | }); |
| | | var option; |
| | | let xAxisData = []; |
| | | let data1 = []; |
| | | let data2 = []; |
| | | let yAxisData1 = 0; |
| | | for(let i=0;i<executeTimely.length;i++){ |
| | | xAxisData.push(executeTimely[i].name); |
| | | data1.push(executeTimely[i].total); |
| | | data2.push(executeTimely[i].timely); |
| | | if(executeTimely[i].total > yAxisData1){ |
| | | yAxisData1 = executeTimely[i].total; |
| | | } |
| | | } |
| | | option = { |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'cross', |
| | | crossStyle: { |
| | | color: '#999' |
| | | } |
| | | } |
| | | }, |
| | | legend: { |
| | | data: ['项目数', '完成及时率'], |
| | | show: true |
| | | }, |
| | | xAxis: [ |
| | | { |
| | | type: 'category', |
| | | data: xAxisData, |
| | | axisPointer: { |
| | | type: 'shadow' |
| | | } |
| | | } |
| | | ], |
| | | yAxis: [ |
| | | { |
| | | type: 'value', |
| | | name: '', |
| | | min: 0, |
| | | max: yAxisData1, |
| | | interval: 1, |
| | | axisLabel: { |
| | | formatter: '{value}' |
| | | } |
| | | }, |
| | | { |
| | | type: 'value', |
| | | name: '', |
| | | min: 0, |
| | | max: 100, |
| | | interval: 10, |
| | | axisLabel: { |
| | | formatter: '{value} %' |
| | | } |
| | | } |
| | | ], |
| | | series: [ |
| | | { |
| | | name: '项目数', |
| | | type: 'bar', |
| | | barWidth: '30%', |
| | | tooltip: { |
| | | valueFormatter: function (value) { |
| | | return value ; |
| | | } |
| | | }, |
| | | data: data1, |
| | | itemStyle: { |
| | | color: '#5087ec' |
| | | } |
| | | }, |
| | | { |
| | | name: '完成及时率', |
| | | type: 'line', |
| | | yAxisIndex: 1, |
| | | tooltip: { |
| | | valueFormatter: function (value) { |
| | | return value + ' %'; |
| | | } |
| | | }, |
| | | data: data2, |
| | | itemStyle: { |
| | | color: '#68bbc4' |
| | | } |
| | | } |
| | | ] |
| | | }; |
| | | |
| | | option && myChart.setOption(option); |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | |
| | | .work-main{ |
| | | width:100%; |
| | | margin:0; |
| | | padding: 0; |
| | | .work-head{ |
| | | width:94%; |
| | | height:100px; |
| | | margin: 5px 10px; |
| | | position: fixed; |
| | | z-index: 10; |
| | | .demo-form-inline{ |
| | | margin: 0px 10px; |
| | | .buttons{ |
| | | margin-left: 10%; |
| | | } |
| | | } |
| | | } |
| | | .work-center{ |
| | | margin: 0px 0px 150px 10px; |
| | | padding: 13vh 0px 5px 0px; |
| | | .el-card{ |
| | | margin: 5px 0px; |
| | | height:500px; |
| | | p{ |
| | | font-size: 22px; |
| | | margin: 0; |
| | | padding: 0; |
| | | } |
| | | } |
| | | } |
| | | .work-foot{ |
| | | width:100%; |
| | | height:50px; |
| | | position: fixed; |
| | | bottom: 0px; |
| | | z-index: 10; |
| | | text-align: right; |
| | | .el-button{ |
| | | margin-right: 7%; |
| | | } |
| | | } |
| | | } |
| | | </style> |