生产统计数据调试

This commit is contained in:
shijing 2024-01-04 19:09:24 +08:00
parent 8e5fca3daf
commit d741746c7f
3 changed files with 498 additions and 342 deletions

View File

@ -2,7 +2,7 @@
<el-container>
<el-header>
<div class="right-panel">
<el-select v-model="queryType" clearable @change="queryTypeChange">
<el-select v-model="queryType" @change="queryTypeChange">
<el-option v-for="item in typeOptions"
:key="item"
:label="item"
@ -36,18 +36,77 @@
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<scEcharts height="300px" :option="option"></scEcharts>
<div id="bachart1" style="width:100%;height:300px;"></div>
<!-- <scEcharts height="300px" :option="option"></scEcharts> -->
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never">
<el-table :data="tableData">
<el-table :data="tableData7">
<el-table-column type="index" width="50" />
<el-table-column label="日期" prop="date">
<el-table-column label="物料名" prop="物料名">
</el-table-column>
<el-table-column label="规格" prop="name">
<el-table-column label="月份" prop="月" v-if="queryType=='年'">
</el-table-column>
<el-table-column label="型号" prop="name">
<el-table-column label="周" prop="周" v-else>
</el-table-column>
<el-table-column label="规格" prop="规格">
</el-table-column>
<el-table-column label="型号" prop="型号">
</el-table-column>
<el-table-column label="合格数" prop="合格数">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<el-card shadow="never" style="margin-bottom: 8px;">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="bachart2" style="width:100%;height:300px;"></div>
<!-- <scEcharts height="300px" :option="option2"></scEcharts> -->
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never">
<el-table :data="tableData10">
<el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="物料名">
</el-table-column>
<el-table-column label="月份" prop="月" v-if="queryType=='年'">
</el-table-column>
<el-table-column label="周" prop="周" v-else>
</el-table-column>
<el-table-column label="规格" prop="规格">
</el-table-column>
<el-table-column label="型号" prop="型号">
</el-table-column>
<el-table-column label="合格数" prop="合格数">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<el-card shadow="never" style="margin-bottom: 8px;">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="bachart3" style="width:100%;height:300px;"></div>
<!-- <scEcharts height="300px" :option="option3"></scEcharts> -->
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never">
<el-table :data="tableDataAVG">
<el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="物料名">
</el-table-column>
<el-table-column label="月份" prop="月" v-if="queryType=='年'">
</el-table-column>
<el-table-column label="周" prop="周" v-else>
</el-table-column>
<el-table-column label="合格数" prop="count_ok">
</el-table-column>
@ -60,62 +119,19 @@
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<scEcharts height="300px" :option="option2"></scEcharts>
<div id="bachart4" style="width:100%;height:300px;"></div>
<!-- <scEcharts height="300px" :option="option4"></scEcharts> -->
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never">
<el-table :data="tableData">
<el-table :data="tableData6">
<el-table-column type="index" width="50" />
<el-table-column label="日期" prop="date">
<el-table-column label="物料名" prop="物料名">
</el-table-column>
<el-table-column label="规格" prop="name">
<el-table-column label="月份" prop="月" v-if="queryType=='年'">
</el-table-column>
<el-table-column label="型号" prop="name">
</el-table-column>
<el-table-column label="合格数" prop="count_ok">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<el-card shadow="never" style="margin-bottom: 8px;">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<scEcharts height="300px" :option="option3"></scEcharts>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never">
<el-table :data="tableData">
<el-table-column type="index" width="50" />
<el-table-column label="日期" prop="date">
</el-table-column>
<el-table-column label="规格" prop="name">
</el-table-column>
<el-table-column label="型号" prop="name">
</el-table-column>
<el-table-column label="合格数" prop="count_ok">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<el-card shadow="never" style="margin-bottom: 8px;">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<scEcharts height="300px" :option="option4"></scEcharts>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never">
<el-table :data="tableData">
<el-table-column type="index" width="50" />
<el-table-column label="日期" prop="date">
<el-table-column label="周" prop="周" v-else>
</el-table-column>
<el-table-column label="规格" prop="name">
</el-table-column>
@ -132,8 +148,13 @@
</el-container>
</template>
<script>
import * as echarts from "echarts";
import T from '@/components/scEcharts/echarts-theme-T.js';
echarts.registerTheme('T', T);
import scEcharts from '@/components/scEcharts';
const xAxisData = ['第一周','第二周','第三周','第四周'];
function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj));
}
export default {
name: 'chart',
components: {
@ -147,11 +168,13 @@
end_date:'',
currentYear:'',
currentMonth:'',
xAxisData:['第一周','第二周','第三周','第四周'],
xAxisOrigin:[],
xAxisData:[],
typeOptions:['月','年'],
option: {
basicOption: {
backgroundColor: 'transparent',
title: {
text: '预制棒7车间',
text: '',
},
grid: {
top: '80px'
@ -161,222 +184,301 @@
},
xAxis: {
type: 'category',
data: xAxisData
data: []
},
yAxis: {
type: 'value'
},
lenged:[],
// toolbox: {
// show: true,
// orient: 'vertical',
// left: 'right',
// top: 'center',
// feature: {
// mark: { show: true },
// dataView: { show: true, readOnly: false },
// magicType: { show: true, type: ['line', 'bar', 'stack'] },
// restore: { show: true },
// saveAsImage: { show: true }
// }
// },
series: [{
data: [120, 200, 150, 80, 70, 110, 130, 200, 150, 80, 70, 110],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
},
{
data: [110, 180, 120, 120, 60, 90, 110, 120, 120, 60, 90, 110],
data: [0, 0, 0, 0, 0, 0, 0],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
}]
},
option2: {
title: {
text: '预制管10车间',
},
grid: {
top: '80px'
},
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
data: xAxisData
},
yAxis: {
type: 'value'
},
series: [{
data: [120, 200, 150, 80, 70, 110, 130],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
},
{
data: [110, 180, 120, 120, 60, 90, 110],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
}]
},
option3: {
title: {
text: 'AVG',
},
grid: {
top: '80px'
},
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
data: xAxisData
},
yAxis: {
type: 'value'
},
series: [{
data: [120, 200, 150, 80, 70, 110, 130],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
},
{
data: [110, 180, 120, 120, 60, 90, 110],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
}]
},
option4: {
title: {
text: '6车间',
},
grid: {
top: '80px'
},
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
data: xAxisData
},
yAxis: {
type: 'value'
},
series: [{
data: [120, 200, 150, 80, 70, 110, 130],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
},
{
data: [110, 180, 120, 120, 60, 90, 110],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
}]
},
tableData:[
{id:1,date:'2023-12-11',name:'ZJ2-1',count_ok:200},
{id:1,date:'2023-12-11',name:'ZJ2-2',count_ok:200},
{id:1,date:'2023-12-11',name:'ZJ2-3',count_ok:200},
{id:1,date:'2023-12-11',name:'ZJ2-4',count_ok:200},
],
tableData6:[],
tableData7:[],
tableData10:[],
tableDataAVG:[],
firstWeekNum:1,
endWeekNum:4,
monthList:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
}
},
mounted(){
let that =this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth()+1;
let days = new Date(year, month, 0).getDate();
this.currentYear = year;
this.currentMonth = month;
this.start_date =year+'-'+month+'-01';
this.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
this.queryDate = year+'-'+month;
this.getData6();
this.getData7();
this.getData10();
that.currentYear = year;
that.currentMonth = month;
that.start_date =year+'-'+month+'-01';
that.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
let month1=month;
if(month1<10){month1='0'+month1}
that.queryDate = year+'-'+month1;
that.firstWeekNum = that.getWeekOfYear(new Date('2024-1-01'));
that.endWeekNum = that.getWeekOfYear(new Date('2024-1-31'));
let duration = that.endWeekNum - that.firstWeekNum + 1;
for(let i =1;i<=duration;i++ ){
that.xAxisOrigin.push('第'+i+'周');
}
that.xAxisData = that.xAxisOrigin;
that.getData6();
that.getData7();
that.getData10();
that.getDataDAVG();
},
methods:{
setChart(name, option = null) {
// name , optionoption
var myChart = echarts.getInstanceByDom(document.getElementById(name));
if (myChart == undefined) {
myChart = echarts.init(document.getElementById(name), 'T');
}
if (option == null) {
option = Object.assign({}, this.basicOption)
}
setTimeout(() => {
try {
myChart.setOption(option);
} catch (error) { }
}, 500)
},
queryTypeChange(value){
console.log(value)
this.queryDate = '';
if(value=='月'){
this.xAxisData = ['第一周','第二周','第三周','第四周'];
},
getWeekOfYear(date) {
var target = new Date(date.getFullYear(), date.getMonth(), date.getDate()); //
var firstDayOfYear = new Date(target.getFullYear(), 0, 1); //
if(target.getTime()==firstDayOfYear.getTime()){
return 1;
}else{
this.xAxisData = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
return Math.ceil((target - firstDayOfYear + 8 * (firstDayOfYear.getTimezoneOffset() / 480)) / 604800000);
}
this.option.xAxis.data = this.xAxisData;
this.option2.xAxis.data = this.xAxisData;
this.option3.xAxis.data = this.xAxisData;
this.option4.xAxis.data = this.xAxisData;
//
},
getData6(){
let that = this;
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = '6车间';
let exec = that.queryType=='月'?'productStatisticWeek':'productStatisticYear';
let obj = {
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "6车间" },
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "6车间" },
};
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
console.log('6生产车间统计:',doInRes);
debugger;
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('6:',res);
let tableData6 = res.data2.ds0;
if(tableData6.length>0){
option.series = [];
let seriesData = [],nameList = [];
tableData6.forEach(ite=>{
if(nameList.indexOf(ite.物料名)>-1){}else{
nameList.push(ite.物料名);
seriesData.push([])
}
})
if(that.queryType=='月'){
tableData6.forEach(item => {
let indexX = nameList.indexOf(item.物料名);
let indexY = item.-that.firstWeekNum;
seriesData[indexX][indexY]=item.合格数;
});
}else{
tableData6.forEach(item => {
let indexX = nameList.indexOf(item.物料名);
let indexY = item.month-1;
seriesData[indexX][indexY]=item.合格数;
});
}
for(let n=0;n<seriesData.length;n++){
let obj = {};
obj.name= nameList[n];
obj.stack= 'Ad';
obj.type= 'bar';
obj.barWidth= '15px';
obj.data= seriesData[n];
option.series.push(obj)
}
that.setChart("bachart3", option);
}else{
that.setChart("bachart3", option);
}
});
},
getData7(){
let that = this;
let obj = {
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "7车间" },
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "7车间" },
};
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = '预制棒7车间';
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
console.log('7生产车间统计:',doInRes);
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
console.log('7生产车间统计:',res);
let tableData7 = res.data2.ds0;
that.tableData7 = tableData7;
debugger;
if(tableData7.length>0){
debugger;
option.series = [];
let seriesData = [],nameList = [];
tableData7.forEach(ite=>{
if(nameList.indexOf(ite.物料名)>-1){}else{
nameList.push(ite.物料名);
seriesData.push([])
}
})
tableData7.forEach(item => {
let indexX=0,indexY=0;
if(that.queryType=='月'){
indexX = nameList.indexOf(item.物料名);
indexY = item.-that.firstWeekNum;
}else{
indexX = nameList.indexOf(item.物料名);
indexY = item.-1;
}
seriesData[indexX][indexY]=item.合格数;
});
for(let n=0;n<seriesData.length;n++){
let obj = {};
obj.name= nameList[n];
obj.stack= 'Ad';
obj.type= 'bar';
obj.barWidth= '15px';
obj.data= seriesData[n];
option.series.push(obj)
}
that.setChart("bachart1", option);
}else{
that.setChart("bachart1", option);
}
});
},
getData10(){
let that = this;
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = '预制管10车间';
let obj = {
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "10·车间" },
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "10车间" },
};
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
console.log('10生产车间统计:',doInRes);
debugger;
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('10:',res);
let tableData10 = res.data2.ds0;
that.tableData10 = tableData10;
if(tableData10.length>0){
option.series = [];
let seriesData = [],nameList = [];
tableData10.forEach(ite=>{
if(nameList.indexOf(ite.物料名)>-1){}else{
nameList.push(ite.物料名);
seriesData.push([])
}
})
tableData10.forEach(item => {
let indexX=0,indexY=0;
if(that.queryType=='月'){
indexX = nameList.indexOf(item.物料名);
indexY = item.-that.firstWeekNum;
}else{
indexX = nameList.indexOf(item.物料名);
indexY = item.-1;
}
seriesData[indexX][indexY]=item.合格数;
});
for(let n=0;n<seriesData.length;n++){
let obj = {};
obj.name= nameList[n];
obj.stack= 'Ad';
obj.type= 'bar';
obj.barWidth= '15px';
obj.data= seriesData[n];
option.series.push(obj)
}
that.setChart("bachart2", option);
}else{
that.setChart("bachart2", option);
}
});
},
getDataDAVG(){
let that = this;
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = 'AVG';
let obj = {
query: { start_date: that.start_date, end_date: that.end_date},
};
let exec = that.queryType=='月'?'AVGWeek':'AVGMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('AVG:',res);
let tableDataAVG = res.data2.ds0;
let seriesData = [];
if(tableDataAVG.length>0){
tableDataAVG.forEach(item => {
let index=0;
if(that.queryType=='月'){
index = item.month-1;
}else{
index = item.-that.firstWeekNum;
}
seriesData[index]=item.合格数;
});
let obj = {};
obj.name= 'AVG';
obj.type= 'bar';
obj.barWidth= '15px';
obj.data= seriesData;
option.series.push(obj)
that.setChart("bachart4", option);
}else{
that.setChart("bachart4", option);
}
});
},
handleQuery(){
if(this.queryDate!==''){
if(this.queryType=='月'){
let that = this;
if(this.queryType=='月'){
if(this.queryDate!==''&&this.queryDate!==null){
this.start_date =this.queryDate+'-01';
let arr = this.queryDate.split('-');
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
this.firstWeekNum = this.getWeekOfYear(new Date(this.start_date));
this.endWeekNum = this.getWeekOfYear(new Date(this.end_date));
let duration = this.endWeekNum - this.firstWeekNum + 1;
let xAxisData = [];
for(let i =1;i<=duration;i++ ){
xAxisData.push('第'+i+'周');
}
that.xAxisData = xAxisData;
}else{
this.start_date = this.queryDate+'-01-01';
this.end_date = this.queryDate+'-12-31';
}
}else{
if(this.queryType=='月'){
this.start_date =this.currentYear+'-'+this.currentMonth+'-01';
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate();
let date = new Date(this.start_date);
this.firstWeekNum = this.getWeekOfYear(date);
this.xAxisData = this.xAxisOrigin;
}
}else{
if(this.queryDate!==''&&this.queryDate!==null){
this.start_date = this.queryDate+'-01-01';
this.end_date = this.queryDate+'-12-31';
}else{
this.start_date = this.currentYear+'-01-01';
this.end_date = this.currentYear+'-12-31';
}
that.xAxisData = that.monthList;
}
debugger;
console.log(this.query)
this.getData6();
this.getData7();
this.getData10();
this.getDataDAVG();
},
},
}

View File

@ -2,7 +2,7 @@
<el-container>
<el-header>
<div class="right-panel">
<el-select v-model="queryType" clearable @change="queryTypeChange">
<el-select v-model="queryType" @change="queryTypeChange">
<el-option v-for="item in typeOptions"
:key="item"
:label="item"
@ -31,8 +31,7 @@
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div>
</el-header>
<el-main>
<!-- <el-alert title="生产统计" type="success" style="margin-bottom:20px;"></el-alert> -->
<el-main id="elMain">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
@ -41,18 +40,22 @@
</el-col>
<el-col :lg="12">
<el-card shadow="never">
<el-table :data="tableData">
<el-table :data="tableData" :height="tableHeight">
<el-table-column type="index" width="50" />
<el-table-column label="工序" prop="process">
<el-table-column label="工序" prop="mgroup_name">
</el-table-column>
<el-table-column label="规格" prop="name">
<template #default="scope">
<span v-if="scope.row.material_out_">{{ scope.row.material_out_.specification }}</span>
</template>
</el-table-column>
<el-table-column label="型号" prop="name">
<template #default="scope">
<span v-if="scope.row.material_out_">{{ scope.row.material_out_.model }}</span>
</template>
</el-table-column>
<el-table-column label="合格数" prop="count_ok">
</el-table-column>
<!-- <el-table-column label="产品编号" prop="number">
</el-table-column> -->
</el-table>
</el-card>
</el-col>
@ -63,7 +66,6 @@
<script>
import scEcharts from '@/components/scEcharts';
const xAxisData = ['平头','粘头','粗磨','中磨','细磨','抛光','开槽','配管'];
export default {
name: 'chart',
components: {
@ -71,6 +73,7 @@
},
data() {
return {
tableHeight:0,
queryType:'月',
queryDate:'',
start_date:'',
@ -90,45 +93,47 @@
},
xAxis: {
type: 'category',
data:xAxisData
data:[]
},
yAxis: {
type: 'value'
},
series: [{
data: [120, 200, 150, 80, 70, 110, 130],
type: 'bar',
barWidth: '15px',
},
{
data: [110, 180, 120, 120, 60, 90, 110],
data: [0,0,0,0,0,0,0,0],
type: 'bar',
barWidth: '15px',
}]
},
tableData:[
{id:1,process:'平头',date:'2023-12-11',name:'ZJ2-1',count_ok:200},
{id:1,process:'粘头',date:'2023-12-11',name:'ZJ2-2',count_ok:200},
{id:1,process:'粗磨',date:'2023-12-11',name:'ZJ2-3',count_ok:200},
{id:1,process:'中磨',date:'2023-12-11',name:'ZJ2-4',count_ok:200},
{id:1,process:'细磨',date:'2023-12-11',name:'ZJ2-1',count_ok:200},
{id:1,process:'抛光',date:'2023-12-11',name:'ZJ2-2',count_ok:200},
{id:1,process:'开槽',date:'2023-12-11',name:'ZJ2-3',count_ok:200},
{id:1,process:'配管',date:'2023-12-11',name:'ZJ2-4',count_ok:200},
],
processData:[],
xAxisData:[],
tableData:[],
}
},
mounted(){
let that = this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth()+1;
let days = new Date(year, month, 0).getDate();
this.currentYear = year;
this.currentMonth = month;
this.start_date =year+'-'+month+'-01';
this.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
this.queryDate = year+'-'+month;
this.getData6();
that.currentYear = year;
that.currentMonth = month>9?month:'0'+month;
that.start_date =year+'-'+month+'-01';
that.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
let month1 = month>9?month:'0'+month;
that.queryDate = year+'-'+month1;
that.tableHeight= document.getElementById('elMain').clientHeight-40;
that.$API.mtm.process.list.req( {page:0,cate:'粗加工'}).then((res) => {
console.log('6车间process:',res)
that.processData = res;
let xAxisData=[];
res.forEach(item => {
xAxisData.push(item.name);
});
that.xAxisData = xAxisData;
that.getData6();
})
},
methods:{
queryTypeChange(value){
@ -137,19 +142,50 @@
},
getData6(){
let that = this;
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
let obj = {
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "6车间" },
};
that.$API.bi.dataset.exec.req(exec, obj).then((doInRes) => {
console.log('6生产车间统计:',doInRes);
debugger;
});
console.log('xAxisData:',that.xAxisData);
that.option.xAxis.data = that.xAxisData;
let obj = {page:0,start_date__gte: this.start_date, end_date__lte: this.end_date, mgroup__belong_dept__name: "6车间"};
that.$API.pm.mtask.list.req( obj).then((res) => {
that.tableData = res;
let xAxisData=that.xAxisData;
if(res.length>0){
let arr = [],nameList=[],seriesData=[];
xAxisData.forEach(ite=>{
arr.push([]);
})
for (let i = 0; i < res.length; i++) {
if(nameList.indexOf(res[i].material_out_.name)>-1){}else{
nameList.push(res[i].material_out_.name);
}
}
that.lengedData = nameList;
res.forEach(item => {
let indexRow = nameList.indexOf(item.material_out_.name);
let indexCol = xAxisData.indexOf(item.mgroup_name);
if(arr[indexRow][indexCol]>0){
arr[indexRow][indexCol] = arr[indexRow][indexCol]+item.count_ok;
}else{
arr[indexRow][indexCol] = item.count_ok;
}
});
console.log('arr:',arr)
arr.forEach((arritem,index) => {
let obj = {};
obj.name= nameList[index];
obj.type= 'bar';
obj.barWidth= '15px';
obj.data= arritem;
seriesData.push(obj)
});
that.option.series = seriesData;
}else{
that.lengedData = [];
}
})
},
handleQuery(){
if(this.queryDate!==''){
if(this.queryDate!==''&&this.queryDate!==null){
if(this.queryType=='月'){
this.start_date =this.queryDate+'-01';
let arr = this.queryDate.split('-');
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();

View File

@ -2,7 +2,7 @@
<el-container>
<el-header>
<div class="right-panel">
<el-select v-model="queryType" clearable @change="queryTypeChange">
<el-select v-model="queryType" @change="queryTypeChange">
<el-option v-for="item in typeOptions"
:key="item"
:label="item"
@ -31,8 +31,8 @@
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div>
</el-header>
<el-main>
<el-row :gutter="10">
<el-main id="elMain">
<el-row :gutter="10" id="elCol">
<el-col :lg="8">
<el-card shadow="never">
<scEcharts height="300px" :option="option1"></scEcharts>
@ -48,9 +48,11 @@
<scEcharts height="300px" :option="option3"></scEcharts>
</el-card>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :lg="8">
<el-card shadow="never">
<el-table :data="tableData1">
<el-table :data="tableData1" :height="tableHeight">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number">
</el-table-column>
@ -58,17 +60,14 @@
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率">
<template #default="scope">
{{ scope.row.count_ok/scope.row.count*100}}%
</template>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :lg="8">
<el-card shadow="never">
<el-table :data="tableData2">
<el-table :data="tableData2" :height="tableHeight">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number">
</el-table-column>
@ -76,17 +75,14 @@
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率">
<template #default="scope">
{{ scope.row.count_ok/scope.row.count*100}}%
</template>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :lg="8">
<el-card shadow="never">
<el-table :data="tableData3">
<el-table :data="tableData3" :height="tableHeight">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number">
</el-table-column>
@ -94,10 +90,7 @@
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率">
<template #default="scope">
{{ scope.row.count_ok/scope.row.count*100}}%
</template>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
@ -115,13 +108,13 @@
},
data() {
return {
tableHeight:0,
queryType:'月',
queryDate:'',
start_date:'',
end_date:'',
currentYear:'',
currentMonth:'',
xAxisData:['第一周','第二周','第三周','第四周'],
typeOptions:['月','年'],
option1: {
title: {
@ -138,8 +131,8 @@
center: ['50%', '60%'],
label: false,
data: [
{value: 20, name: '已完成'},
{value: 3, name: '未完成'},
{value: 0, name: '已完成'},
{value: 0, name: '未完成'},
]
}
},
@ -159,8 +152,8 @@
center: ['50%', '60%'],
label: false,
data: [
{value: 10, name: '已完成'},
{value: 3, name: '未完成'},
{value: 0, name: '已完成'},
{value: 0, name: '未完成'},
]
}
},
@ -179,32 +172,31 @@
center: ['50%', '60%'],
label: false,
data: [
{value: 15, name: '已完成'},
{value: 3, name: '未完成'},
{value: 0, name: '已完成'},
{value: 0, name: '未完成'},
]
}
},
// tableData:[
// {id:1,number:'20231210',count:300,count_rate:83,count_ok:250},
// {id:1,number:'20231211',count:300,count_rate:66,count_ok:200},
// {id:1,number:'20231212',count:300,count_rate:93,count_ok:280},
// {id:1,number:'20231213',count:300,count_rate:0,count_ok:0},
// ],
tableData1:[],
tableData2:[],
tableData3:[],
}
},
mounted(){
let that = this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth()+1;
let days = new Date(year, month, 0).getDate();
this.currentYear = year;
this.currentMonth = month;
this.currentMonth = month>9?month:'0'+month;
this.start_date =year+'-'+month+'-01';
this.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
this.queryDate = year+'-'+month;
let month1 = month>9?month:'0'+month;
this.queryDate = year+'-'+month1;
let height= document.getElementById('elMain').clientHeight-40;
let chartheight= document.getElementById('elCol').clientHeight;
that.tableHeight = height-chartheight;
this.getData6();
this.getData7();
this.getData10();
@ -213,97 +205,123 @@
queryTypeChange(){
this.queryDate = '';
},
getData6(){
let that = this;
let obj={};
obj.belong_dept__name = '6车间';
obj.start_date__gte = this.start_date;
obj.end_date__lte = this.end_date;
that.$API.pm.utask.list.req( obj).then((res) => {
console.log('utask:',res);
this.tableData1 = res.results;
let count_ok1 = 0;
let count_notok1 = 0;
res.results.forEach(item => {
if(item.count_ok>=item.count){
count_ok1++;
}else{
count_notok1++;
}
});
this.option1.series.data[0].value = count_ok1;
this.option1.series.data[1].value = count_notok1;
});
},
getData7(){
let that = this;
that.tableData1=[];
that.option1.series.data[0].value = 0;
that.option1.series.data[1].value = 0;
let obj={};
obj.belong_dept__name = '7车间';
obj.page = 0;
obj.mgroup__belong_dept__name = '7车间';
obj.start_date__gte = this.start_date;
obj.end_date__lte = this.end_date;
that.$API.pm.utask.list.req( obj).then((res) => {
console.log('utask:',res);
this.tableData2 = res.results;
let count_ok2 = 0;
let count_notok2 = 0;
res.results.forEach(item => {
if(item.count_ok>=item.count){
count_ok2++;
}else{
count_notok2++;
}
});
this.option2.series.data[0].value = count_ok2;
this.option2.series.data[1].value = count_notok2;
let data = [];
let count_ok1 = 0;
let count_notok1 = 0;
if(res.length>0){
res.forEach(item => {
let obj = item;
obj.rate = (item.count_ok/item.count*100).toFixed(2)+'%';
if(item.count_ok>=item.count){
count_ok1++;
}else{
count_notok1++;
}
data.push(obj);
});
that.tableData1 = data
that.option1.series.data[0].value = count_ok1;
}
this.option1.series.data[0].value = count_ok1;
this.option1.series.data[1].value = count_notok1;
});
},
getData10(){
async getData10(){
let that = this;
that.tableData2=[];
that.option2.series.data[0].value = 0;
that.option2.series.data[1].value = 0;
let obj={};
obj.belong_dept__name = '10车间';
obj.page = 0;
obj.mgroup__belong_dept__name = '10车间';
obj.start_date__gte = this.start_date;
obj.end_date__lte = this.end_date;
that.$API.pm.utask.list.req( obj).then((res) => {
await that.$API.pm.utask.list.req( obj).then((res) => {
console.log('utask:',res);
this.tableData3 = res.results;
let data = [];
let count_ok2 = 0;
let count_notok2 = 0;
if(res.length>0){
res.forEach(item => {
let obj = item;
obj.rate = (item.count_ok/item.count*100).toFixed(2)+'%';
if(item.count_ok>=item.count){
count_ok2++;
}else{
count_notok2++;
}
data.push(obj);
});
that.tableData2 = data;
that.option2.series.data[0].value = count_ok2;
that.option2.series.data[1].value = count_notok2;
}
});
},
async getData6(){
let that = this;
that.tableData3=[];
that.option3.series.data[0].value = 0;
that.option3.series.data[1].value = 0;
let obj={};
obj.page = 0;
obj.mgroup__belong_dept__name = '6车间';
obj.start_date__gte = this.start_date;
obj.end_date__lte = this.end_date;
await that.$API.pm.utask.list.req( obj).then((res) => {
console.log('utask:',res);
let data = [];
let count_ok3 = 0;
let count_notok3 = 0;
res.results.forEach(item => {
if(item.count_ok>=item.count){
count_ok3++;
}else{
count_notok3++;
}
});
this.option3.series.data[0].value = count_ok3;
this.option3.series.data[1].value = count_notok3;
if(res.length>0){
res.forEach(item => {
let obj = item;
obj.rate = (item.count_ok/item.count*100).toFixed(2)+'%';
if(item.count_ok>=item.count){
count_ok3++;
}else{
count_notok3++;
}
data.push(obj);
});
that.tableData3= data
that.option3.series.data[0].value = count_ok3;
that.option3.series.data[1].value = count_notok3;
}
});
},
handleQuery(){
if(this.queryDate!==''){
if(this.queryDate!==''&&this.queryDate!==null){
if(this.queryType=='月'){
this.xAxisData = ['第一周','第二周','第三周','第四周'];
this.start_date =this.queryDate+'-01';
let arr = this.queryDate.split('-');
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
}else{
this.start_date = this.queryDate+'-01-01';
this.end_date = this.queryDate+'-12-31';
this.xAxisData = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
}
}else{
if(this.queryType=='月'){
this.xAxisData = ['第一周','第二周','第三周','第四周'];
this.start_date =this.currentYear+'-'+this.currentMonth+'-01';
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate();
}else{
this.start_date = this.currentYear+'-01-01';
this.end_date = this.currentYear+'-12-31';
this.xAxisData = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
}
}
debugger;
console.log(this.query)
this.getData6();
this.getData7();
this.getData10();