feat: fix 修改质量报表

This commit is contained in:
zty 2025-01-24 09:21:52 +08:00
parent 56334fc718
commit 2a75517a19
1 changed files with 43 additions and 57 deletions

View File

@ -118,7 +118,6 @@
</div>
</template>
<script>
import moment from 'moment';
export default {
data() {
return {
@ -135,33 +134,33 @@ import moment from 'moment';
],
titleLength:1,
mgroupOptions:[],
currentThreshold: null, //
currentThreshold: 80, //
tableTime:'',
deptName:'',
typeName:'质检日报表',
tableName:'',
tableDatas:[
['原料车间','辅料','细度', , , , , , ],
['原料车间','辅料','Fe2O3', , , , , , ],
['原料车间','辅料','水分', , , , , , ],
['原料车间','干混生料','细度', , , , , , ],
['原料车间','干混生料','Fe2O3', , , , , , ],
['原料车间','干混生料','水分', , , , , , ],
['原料车间','干混生料','CaO', , , , , , ],
// tableDatas:[
// ['','','', , , , , , ],
// ['','','Fe2O3', , , , , , ],
// ['','','', , , , , , ],
// ['','','', , , , , , ],
// ['','','Fe2O3', , , , , , ],
// ['','','', , , , , , ],
// ['','','CaO', , , , , , ],
['烧成车间','入窑生料','CaO', , , , , , ],
['烧成车间','入窑生料','Fe2O3', , , , , , ],
['烧成车间','入窑生料','细度'],
['烧成车间','入窑生料','水分'],
['烧成车间','熟料','立升重'],
['烧成车间','熟料','f-CaO'],
['烧成车间','煤粉','细度'],
['烧成车间','煤粉','水分'],
// ['','','CaO', , , , , , ],
// ['','','Fe2O3', , , , , , ],
// ['','',''],
// ['','',''],
// ['','',''],
// ['','','f-CaO'],
// ['','',''],
// ['','',''],
['水泥车间','出磨水泥','比表面积'],
['水泥车间','出磨水泥','SO3'],
['水泥车间','出磨水泥','掺量'],
],
// ['','',''],
// ['','','SO3'],
// ['','',''],
// ],
tableDatas3:[],
exportLoading:false,
header2:[],
@ -172,7 +171,7 @@ import moment from 'moment';
deptOptions:[],
dialogVisible: false, //
currentColumnIndex: null, //
thresholds: {}, // key
// thresholds: {}, // key
thresholdobj:{},
materialTestItemMap:{},
currentMaterialNameClass: '',
@ -181,13 +180,6 @@ import moment from 'moment';
currentTestItemNameClass: '', //
};
},
watch: {
header3: {
handler(newV, OldV) {
this.header3 = newV;
}
}
},
mounted() {
var myDate = new Date();
let month = myDate.getMonth()+1;
@ -207,7 +199,7 @@ import moment from 'moment';
let that = this;
if(value==1){
this.typeName = '质检日报表'
}else if(value==1){
}else if(value==0){
this.typeName = '质检月报表'
}
that.tableName = that.deptName+that.typeName;
@ -216,7 +208,6 @@ import moment from 'moment';
const num = parseFloat(this.currentThreshold);
if (!isNaN(num)){
const key = `${this.currentMaterialName}-${this.currentTestItemName}`;
console.log("---------------key", key, this.materialTestItemMap)
const mapEntry = this.materialTestItemMap[key];
if (!mapEntry) {
return;
@ -231,7 +222,7 @@ import moment from 'moment';
this.$API.qm.updateQuastatGoal.post(payload)
.then((res) => {
this.$message.success("阈值更新成功");
this.thresholds[this.currentColumnIndex] = res.rate_pass_t; //
// this.thresholds[this.currentColumnIndex] = res.rate_pass_t; //
this.dialogVisible = false; //
})
.catch((error) => {
@ -275,7 +266,7 @@ import moment from 'moment';
const keyName = `${that.currentMaterialNameClass}-${that.currentTestItemNameClass}`;
const rate_g = that.thresholdobj[keyName] || 0;
if (rate_g >= value) {
return 'red-text';
return 'red-text';
} else {
return 'green-text';
}
@ -318,16 +309,13 @@ import moment from 'moment';
}
if (header2Index !== -1 && header3Index !== -1){
that.currentMaterialName = this.header2Obj[header2Index].name; // header2Obj
console.log('that.currentMaterialName', that.currentMaterialName, header2Index)
that.currentTestItemName = this.header3[header3Index]; // header3
console.log("--that.currentTestItemName--", this.header3, that.currentTestItemName, header3Index)
}else {
this.currentMaterialName = '';
this.currentTestItemName = '';
}
const keyName = `${that.currentMaterialName}-${that.currentTestItemName}`;
this.currentThreshold = that.thresholdobj[keyName] || 0;
console.log("-----------this.currentThreshold------", this.currentThreshold, )
this.dialogVisible = true;
},
getTableData(){
@ -335,24 +323,27 @@ import moment from 'moment';
that.tableDatas3 = [];
that.materialTestItemMap = {};
that.header3 = [];
debugger;
if(that.deptName=='原料车间'){
that.header2Obj=[{name:'辅料',lengths:3},{name:'干混生料',lengths:4}];
that.header2 = ['辅料','干混生料'];//
// that.header3 = ['','Fe2O3','','','Fe2O3','','CaO'];//
that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//
// that.header4 = ['','','','','','','','','','','','','','','','','','','','','','','','','','','',''];//
}else if(that.deptName=='烧成车间'){
that.header2Obj=[{name:'入窑生料',lengths:4},{name:'熟料',lengths:4}];
that.header2 = ['入窑生料','熟料'];//
// that.header3 = ['CaO','Fe2O3','','','','f-CaO','',''];//
that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//
// that.header4 = ['','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',''];//
}else{
that.header2Obj=[{name:'出磨水泥',lengths:3}];
that.header2 = ['出磨水泥'];//
// that.header3 = ['','SO3',''];//
that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//
// that.header4 = ['','','','','','','','','','','',''];//
}
let params = {page: 0};
let arr = [];
let update_start_time = '';
let update_end_time = '';
if(that.query.type==0){//
arr = that.query.month.split('-');
params.year_s = arr[0];
@ -363,22 +354,24 @@ import moment from 'moment';
params.year_s = that.query.year;
}
params.mgroup__belong_dept = that.query.belong_dept;
if(params.month_s){
const updateStartDate = new Date(params.year_s, params.month_s - 1, 1); // 0
const updateEndDate = new Date(params.year_s, params.month_s, 0);
update_start_time = updateStartDate.toISOString().split('T')[0]; // 'YYYY-MM-DD'
update_end_time = updateEndDate.toISOString().split('T')[0]; //
}else if(params.year_s){
const updateStartDate = new Date(params.year_s, 0, 1); // 1 1
const updateEndDate = new Date(params.year_s, 11, 31); // 12 31
update_start_time = updateStartDate.toISOString().split('T')[0]; // 'YYYY-MM-DD'
update_end_time = updateEndDate.toISOString().split('T')[0];
}
this.$API.enm.enstat.req(params).then((res) => {
let data = res;
let wrapArr = [];
let innerArr = [];
let update_start_time = '';
let update_end_time = '';
let ind = 0;
//1/
let header2=[],header2Obj=[],header3=[],header4=[];
if(params.month_s){
update_start_time = moment(params.year_s + '-' + params.month_s + '-01').format('YYYY-MM-DD');
update_end_time = moment(params.year_s + '-' + params.month_s + '-01').endOf('month').format('YYYY-MM-DD');
}else if(params.year_s){
update_start_time = moment(params.year_s + '-01-01').format('YYYY-MM-DD');
update_end_time = moment(params.year_s + '-12-01').endOf('month').format('YYYY-MM-DD');
}
data.forEach(item => {
item.qua_data.forEach((qua)=>{
let key = `${qua.material_name}-${qua.testitem_name}`;
@ -416,9 +409,7 @@ import moment from 'moment';
wrapArr[ind].push(item)
}
});
wrapArr = wrapArr.filter(item=>{
return item
})
wrapArr = wrapArr.filter(item => item && item.length > 0);
wrapArr.forEach((item1,index1)=>{
if(item1!=undefined){//
let itemArr = [];
@ -428,9 +419,7 @@ import moment from 'moment';
itemArr.push(time)
//
item1.forEach(item2=>{
let data2 =item2.qua_data;
// console.log("-----data2-----", data2)
//
data2.forEach((item3,index3)=>{
//item3
@ -442,7 +431,6 @@ import moment from 'moment';
header2Objtem.push({name:item3.material_name,lengths:1})
}
header3tem.push(item3.testitem_name)
header4tem.push('平均值')
header4tem.push('检次')
header4tem.push('合次')
@ -469,7 +457,6 @@ import moment from 'moment';
if(!that.thresholdobj[item3.material_name+"-"+item3.testitem_name]){
that.thresholdobj[item3.material_name+"-"+item3.testitem_name] = item3.rate_g;
}
}else{
itemArr.push(Number(item3.val_avg).toFixed(2));
itemArr.push(item3.num_test);
@ -509,7 +496,6 @@ import moment from 'moment';
if(header4.length>0){
that.header4 = header4;
}
this.$forceUpdate();
innerArr.forEach(item=>{
if(item.length>1){
that.tableDatas3.push(item)