工序合格数统计
This commit is contained in:
parent
fa87c5fdce
commit
a57fa2f750
|
@ -3,30 +3,14 @@
|
|||
<el-header>
|
||||
<div class="right-panel">
|
||||
<el-select v-model="queryType" @change="queryTypeChange">
|
||||
<el-option v-for="item in typeOptions"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"
|
||||
>
|
||||
<el-option v-for="item in typeOptions" :key="item" :label="item" :value="item">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-date-picker
|
||||
v-if="queryType=='月'"
|
||||
v-model="queryDate"
|
||||
type="month"
|
||||
placeholder="查询月期"
|
||||
value-format="YYYY-MM"
|
||||
style="width:100%"
|
||||
>
|
||||
<el-date-picker v-if="queryType == '月'" v-model="queryDate" type="month" placeholder="查询月期"
|
||||
value-format="YYYY-MM" style="width:100%">
|
||||
</el-date-picker>
|
||||
<el-date-picker
|
||||
v-if="queryType=='年'"
|
||||
v-model="queryDate"
|
||||
type="year"
|
||||
placeholder="查询年份"
|
||||
value-format="YYYY"
|
||||
style="width:100%"
|
||||
>
|
||||
<el-date-picker v-if="queryType == '年'" v-model="queryDate" type="year" placeholder="查询年份"
|
||||
value-format="YYYY" style="width:100%">
|
||||
</el-date-picker>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
|
||||
</div>
|
||||
|
@ -42,19 +26,13 @@
|
|||
<el-card shadow="never">
|
||||
<el-table :data="tableData" :height="tableHeight">
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="工序" prop="mgroup_name">
|
||||
<el-table-column label="工段" prop="工段">
|
||||
</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 label="物料名称" prop="物料名称">
|
||||
</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 label="计划数" prop="计划数">
|
||||
</el-table-column>
|
||||
<el-table-column label="合格数" prop="count_ok">
|
||||
<el-table-column label="合格数" prop="合格数">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
@ -65,148 +43,132 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import scEcharts from '@/components/scEcharts';
|
||||
export default {
|
||||
name: 'chart',
|
||||
components: {
|
||||
scEcharts
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableHeight:0,
|
||||
queryType:'月',
|
||||
queryDate:'',
|
||||
start_date:'',
|
||||
end_date:'',
|
||||
currentYear:'',
|
||||
currentMonth:'',
|
||||
typeOptions:['月','年'],
|
||||
option: {
|
||||
title: {
|
||||
text: '本周生产数量',
|
||||
},
|
||||
grid: {
|
||||
top: '80px'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data:[]
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [{
|
||||
data: [0,0,0,0,0,0,0,0],
|
||||
import scEcharts from '@/components/scEcharts';
|
||||
export default {
|
||||
name: 'chart',
|
||||
components: {
|
||||
scEcharts
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableHeight: 0,
|
||||
queryType: '月',
|
||||
queryDate: '',
|
||||
start_date: '',
|
||||
end_date: '',
|
||||
currentYear: '',
|
||||
currentMonth: '',
|
||||
typeOptions: ['月', '年'],
|
||||
option: {
|
||||
title: {
|
||||
text: '生产数量',
|
||||
},
|
||||
grid: {
|
||||
top: '80px'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '光纤预制棒',
|
||||
data: [0, 0, 0, 0, 0, 0, 0, 0],
|
||||
type: 'bar',
|
||||
barWidth: '15px',
|
||||
}]
|
||||
},
|
||||
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();
|
||||
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){
|
||||
console.log(value)
|
||||
this.queryDate = '';
|
||||
}, {
|
||||
name: '光纤预制管',
|
||||
data: [0, 0, 0, 0, 0, 0, 0, 0],
|
||||
type: 'bar',
|
||||
barWidth: '15px',
|
||||
}
|
||||
]
|
||||
},
|
||||
getData6(){
|
||||
let that = this;
|
||||
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 = [];
|
||||
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();
|
||||
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.getData6();
|
||||
|
||||
},
|
||||
methods: {
|
||||
queryTypeChange(value) {
|
||||
console.log(value)
|
||||
this.queryDate = '';
|
||||
},
|
||||
getData6() {
|
||||
let that = this;
|
||||
let obj = {
|
||||
query: { start_date: this.start_date, end_date: this.end_date, dept_name: "6车间" },
|
||||
};
|
||||
let xAxisData = [], data1 = [], data0 = [];
|
||||
that.$API.bi.dataset.exec.req('mgroupWeek', obj).then((res) => {
|
||||
let data = res.data2.ds0;
|
||||
that.tableData = data;
|
||||
data.forEach(item => {
|
||||
if (xAxisData.indexOf(item.工段) > -1) { } else {
|
||||
xAxisData.push(item.工段);
|
||||
}
|
||||
let index = xAxisData.indexOf(item.工段);
|
||||
if (item.物料名称.indexOf('棒') > -1) {
|
||||
data0[index] = item.合格数;
|
||||
} else {
|
||||
data1[index] = item.合格数;
|
||||
}
|
||||
})
|
||||
},
|
||||
handleQuery(){
|
||||
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();
|
||||
}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();
|
||||
}else{
|
||||
this.start_date = this.currentYear+'-01-01';
|
||||
this.end_date = this.currentYear+'-12-31';
|
||||
}
|
||||
}
|
||||
this.getData6();
|
||||
},
|
||||
that.xAxisData = xAxisData;
|
||||
|
||||
})
|
||||
console.log('xAxisData:', that.xAxisData);
|
||||
that.option.xAxis.data = that.xAxisData;
|
||||
that.option.series[0].data = data0;
|
||||
that.option.series[1].data = data1;
|
||||
// that.chart.setOption(that.option);
|
||||
},
|
||||
}
|
||||
handleQuery() {
|
||||
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();
|
||||
} 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();
|
||||
} else {
|
||||
this.start_date = this.currentYear + '-01-01';
|
||||
this.end_date = this.currentYear + '-12-31';
|
||||
}
|
||||
}
|
||||
this.getData6();
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<style></style>
|
||||
|
|
Loading…
Reference in New Issue