feat: 修改质量报表

This commit is contained in:
zty 2025-01-24 17:17:04 +08:00
parent 2a75517a19
commit 1d837b9b0a
1 changed files with 67 additions and 101 deletions

View File

@ -103,7 +103,6 @@
title="设置合格率的阈值" title="设置合格率的阈值"
v-model="dialogVisible" v-model="dialogVisible"
width="30%" width="30%"
@close="resetDialog"
> >
<div> <div>
<label>当前阈值:</label> <label>当前阈值:</label>
@ -139,28 +138,6 @@
deptName:'', deptName:'',
typeName:'质检日报表', typeName:'质检日报表',
tableName:'', tableName:'',
// tableDatas:[
// ['','','', , , , , , ],
// ['','','Fe2O3', , , , , , ],
// ['','','', , , , , , ],
// ['','','', , , , , , ],
// ['','','Fe2O3', , , , , , ],
// ['','','', , , , , , ],
// ['','','CaO', , , , , , ],
// ['','','CaO', , , , , , ],
// ['','','Fe2O3', , , , , , ],
// ['','',''],
// ['','',''],
// ['','',''],
// ['','','f-CaO'],
// ['','',''],
// ['','',''],
// ['','',''],
// ['','','SO3'],
// ['','',''],
// ],
tableDatas3:[], tableDatas3:[],
exportLoading:false, exportLoading:false,
header2:[], header2:[],
@ -170,14 +147,12 @@
header2Obj:[], header2Obj:[],
deptOptions:[], deptOptions:[],
dialogVisible: false, // dialogVisible: false, //
currentColumnIndex: null, //
// thresholds: {}, // key // thresholds: {}, // key
thresholdobj:{}, thresholdobj:{},
materialTestItemMap:{}, materialTestItemMap:{},
currentMaterialNameClass: '', currentMaterialName: null, //
currentMaterialName: '', // currentTestItemName: null, //
currentTestItemName: '', //
currentTestItemNameClass: '', //
}; };
}, },
mounted() { mounted() {
@ -205,10 +180,11 @@
that.tableName = that.deptName+that.typeName; that.tableName = that.deptName+that.typeName;
}, },
updateThreshold() { updateThreshold() {
const num = parseFloat(this.currentThreshold); let that = this;
const num = parseFloat(that.currentThreshold);
if (!isNaN(num)){ if (!isNaN(num)){
const key = `${this.currentMaterialName}-${this.currentTestItemName}`; const key = `${that.currentMaterialName}-${that.currentTestItemName}`;
const mapEntry = this.materialTestItemMap[key]; const mapEntry = that.materialTestItemMap[key];
if (!mapEntry) { if (!mapEntry) {
return; return;
} }
@ -216,27 +192,26 @@
material_id: mapEntry.material_id, material_id: mapEntry.material_id,
testitem_id: mapEntry.testitem_id, testitem_id: mapEntry.testitem_id,
rate_pass_t: num, rate_pass_t: num,
update_start_time: mapEntry.update_start_time, update_start_time: mapEntry.start_time,
update_end_time: mapEntry.update_end_time, update_end_time: mapEntry.end_time,
}; };
this.$API.qm.updateQuastatGoal.post(payload) that.$API.qm.updateQuastatGoal.post(payload)
.then((res) => { .then((res) => {
this.$message.success("阈值更新成功"); that.$message.success("阈值更新成功");
// this.thresholds[this.currentColumnIndex] = res.rate_pass_t; // // this.thresholds[this.currentColumnIndex] = res.rate_pass_t; //
this.dialogVisible = false; // that.dialogVisible = false; //
}) })
.catch((error) => { .catch((error) => {
this.$message.error("阈值更新失败:" + error.message); that.$message.error("阈值更新失败:" + error.message);
}); });
}else { }else {
this.$message.error("请输入有效的阈值例如80%"); that.$message.error("请输入有效的阈值例如80%");
} }
}, },
// //
resetDialog() { // resetDialog() {
this.currentColumnIndex = null; // this.currentThreshold = "";
this.currentThreshold = ""; // },
},
// //
getCellClass(cell, cellIndex) { getCellClass(cell, cellIndex) {
let that = this; let that = this;
@ -244,26 +219,27 @@
// //
const cellValue = String(cell); const cellValue = String(cell);
const value = parseFloat(cellValue.replace("%", "")); const value = parseFloat(cellValue.replace("%", ""));
this.currentColumnIndex = cellIndex;
const header4Index = cellIndex - 1; // 0 const header4Index = cellIndex - 1; // 0
const header3Index = Math.floor(header4Index / 4); const header3Index = Math.floor(header4Index / 4);
let cumulativeLength = 0; let cumulativeLength = 0;
let header2Index = -1; let header2Index = -1;
for (let i = 0; i < this.header2Obj.length; i++) { for (let i = 0; i < that.header2Obj.length; i++) {
cumulativeLength += this.header2Obj[i].lengths * 4; cumulativeLength += that.header2Obj[i].lengths * 4;
if (header4Index < cumulativeLength) { if (header4Index < cumulativeLength) {
header2Index = i; header2Index = i;
break; break;
} }
} }
let currentMaterialNameClass = ''
let currentTestItemNameClass = ''
if (header2Index !== -1 && header3Index !== -1){ if (header2Index !== -1 && header3Index !== -1){
that.currentMaterialNameClass = this.header2Obj[header2Index].name; // header2Obj currentMaterialNameClass = that.header2Obj[header2Index].name; // header2Obj
that.currentTestItemNameClass = this.header3[header3Index]; // header3 currentTestItemNameClass = that.header3[header3Index]; // header3
}else { }else {
this.currentMaterialNameClass = ''; currentMaterialNameClass = '';
this.currentTestItemNameClass = ''; currentTestItemNameClass = '';
} }
const keyName = `${that.currentMaterialNameClass}-${that.currentTestItemNameClass}`; const keyName = `${currentMaterialNameClass}-${currentTestItemNameClass}`;
const rate_g = that.thresholdobj[keyName] || 0; const rate_g = that.thresholdobj[keyName] || 0;
if (rate_g >= value) { if (rate_g >= value) {
return 'red-text'; return 'red-text';
@ -294,77 +270,68 @@
}, },
handleCellClick(cell, rowIndex, cellIndex){ handleCellClick(cell, rowIndex, cellIndex){
let that = this; let that = this;
this.currentColumnIndex = cellIndex; const header4Index_hd = cellIndex - 1 ; // 0
const header4Index = cellIndex - 1 ; // 0 const header3Index_hd = Math.floor(header4Index_hd / 4) ;
const header3Index = Math.floor(header4Index / 4) ;
let cumulativeLength = 0; let cumulativeLength = 0;
let header2Index = -1; let header2Index = -1;
// //
for (let i = 0; i < this.header2Obj.length; i++) { for (let i = 0; i < this.header2Obj.length; i++) {
cumulativeLength += this.header2Obj[i].lengths * 4; cumulativeLength += this.header2Obj[i].lengths * 4;
if (header4Index < cumulativeLength) { if (header4Index_hd < cumulativeLength) {
header2Index = i; header2Index = i;
break; break;
} }
} }
if (header2Index !== -1 && header3Index !== -1){ if (header2Index !== -1 && header3Index_hd !== -1){
that.currentMaterialName = this.header2Obj[header2Index].name; // header2Obj that.currentMaterialName = this.header2Obj[header2Index].name; // header2Obj
that.currentTestItemName = this.header3[header3Index]; // header3 that.currentTestItemName = this.header3[header3Index_hd]; // header3
}else { }else {
this.currentMaterialName = ''; that.currentMaterialName = '';
this.currentTestItemName = ''; that.currentTestItemName = '';
} }
const keyName = `${that.currentMaterialName}-${that.currentTestItemName}`; const keyName = `${that.currentMaterialName}-${that.currentTestItemName}`;
this.currentThreshold = that.thresholdobj[keyName] || 0; that.currentThreshold = that.thresholdobj[keyName] || 0;
this.dialogVisible = true; that.dialogVisible = true;
}, },
getTableData(){ getTableData(){
let that = this; let that = this;
that.tableDatas3 = []; that.tableDatas3 = [];
that.materialTestItemMap = {}; that.materialTestItemMap = {};
that.thresholdobj = {};
that.header3 = []; that.header3 = [];
debugger;
if(that.deptName=='原料车间'){
that.header2Obj=[{name:'辅料',lengths:3},{name:'干混生料',lengths:4}];
that.header2 = ['辅料','干混生料'];//
// that.header3 = ['','Fe2O3','','','Fe2O3','','CaO'];//
// that.header4 = ['','','','','','','','','','','','','','','','','','','','','','','','','','','',''];//
}else if(that.deptName=='烧成车间'){
that.header2Obj=[{name:'入窑生料',lengths:4},{name:'熟料',lengths:4}];
that.header2 = ['入窑生料','熟料'];//
// that.header3 = ['CaO','Fe2O3','','','','f-CaO','',''];//
// that.header4 = ['','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',''];//
}else{
that.header2Obj=[{name:'出磨水泥',lengths:3}];
that.header2 = ['出磨水泥'];//
// that.header3 = ['','SO3',''];//
// that.header4 = ['','','','','','','','','','','',''];//
}
let params = {page: 0};
let arr = []; let arr = [];
let update_start_time = ''; let update_start_time = '';
let update_end_time = ''; let update_end_time = '';
if(that.deptName=='原料车间'){
that.header2Obj=[{name:'辅料',lengths:3},{name:'干混生料',lengths:4}];
that.header2 = ['辅料','干混生料'];//
}else if(that.deptName=='烧成车间'){
that.header2Obj=[{name:'入窑生料',lengths:4},{name:'熟料',lengths:4}];
that.header2 = ['入窑生料','熟料'];//
}else{
that.header2Obj=[{name:'出磨水泥',lengths:3}];
that.header2 = ['出磨水泥'];//
}
let params = {page: 0};
if(that.query.type==0){// if(that.query.type==0){//
arr = that.query.month.split('-'); arr = that.query.month.split('-');
params.year_s = arr[0]; params.year_s = arr[0];
params.month_s = arr[1]; params.month_s = parseInt(arr[1]);
params.type = 'day_s' params.type = 'day_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(that.query.type==1){// }else if(that.query.type==1){//
params.type = 'month_s' params.type = 'month_s'
params.year_s = that.query.year; params.year_s = that.query.year;
// 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];
} }
params.mgroup__belong_dept = that.query.belong_dept; 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) => { this.$API.enm.enstat.req(params).then((res) => {
let data = res; let data = res;
let wrapArr = []; let wrapArr = [];
@ -373,17 +340,6 @@
//1/ //1/
let header2=[],header2Obj=[],header3=[],header4=[]; let header2=[],header2Obj=[],header3=[],header4=[];
data.forEach(item => { data.forEach(item => {
item.qua_data.forEach((qua)=>{
let key = `${qua.material_name}-${qua.testitem_name}`;
if (!that.materialTestItemMap[key]) {
that.materialTestItemMap[key] = {
material_id: qua.material,
testitem_id: qua.testitem,
update_start_time:update_start_time,
update_end_time:update_end_time
};
}
})
if(that.query.type==0){// if(that.query.type==0){//
ind = item.day_s-1; ind = item.day_s-1;
}else if(that.query.type==1){// }else if(that.query.type==1){//
@ -410,6 +366,7 @@
} }
}); });
wrapArr = wrapArr.filter(item => item && item.length > 0); wrapArr = wrapArr.filter(item => item && item.length > 0);
console.log(wrapArr, "-------------wrapArr")
wrapArr.forEach((item1,index1)=>{ wrapArr.forEach((item1,index1)=>{
if(item1!=undefined){// if(item1!=undefined){//
let itemArr = []; let itemArr = [];
@ -423,6 +380,15 @@
// //
data2.forEach((item3,index3)=>{ data2.forEach((item3,index3)=>{
//item3 //item3
let key = `${item3.material_name}-${item3.testitem_name}`;
if (!that.materialTestItemMap[key]) {
that.materialTestItemMap[key] = {
material_id: item3.material,
testitem_id: item3.testitem,
month_s:params.month_s,
// end_time:update_end_time
};
}
if(header2tem.indexOf(item3.material_name)>-1){ if(header2tem.indexOf(item3.material_name)>-1){
let indexObj = header2tem.indexOf(item3.material_name); let indexObj = header2tem.indexOf(item3.material_name);
header2Objtem[indexObj].lengths = header2Objtem[indexObj].lengths+1; header2Objtem[indexObj].lengths = header2Objtem[indexObj].lengths+1;