feat: fix 修改质量报表
This commit is contained in:
parent
56334fc718
commit
2a75517a19
|
@ -118,7 +118,6 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment';
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -135,33 +134,33 @@ import moment from 'moment';
|
||||||
],
|
],
|
||||||
titleLength:1,
|
titleLength:1,
|
||||||
mgroupOptions:[],
|
mgroupOptions:[],
|
||||||
currentThreshold: null, // 当前编辑的阈值
|
currentThreshold: 80, // 当前编辑的阈值
|
||||||
tableTime:'',
|
tableTime:'',
|
||||||
deptName:'',
|
deptName:'',
|
||||||
typeName:'质检日报表',
|
typeName:'质检日报表',
|
||||||
tableName:'',
|
tableName:'',
|
||||||
tableDatas:[
|
// tableDatas:[
|
||||||
['原料车间','辅料','细度', , , , , , ],
|
// ['原料车间','辅料','细度', , , , , , ],
|
||||||
['原料车间','辅料','Fe2O3', , , , , , ],
|
// ['原料车间','辅料','Fe2O3', , , , , , ],
|
||||||
['原料车间','辅料','水分', , , , , , ],
|
// ['原料车间','辅料','水分', , , , , , ],
|
||||||
['原料车间','干混生料','细度', , , , , , ],
|
// ['原料车间','干混生料','细度', , , , , , ],
|
||||||
['原料车间','干混生料','Fe2O3', , , , , , ],
|
// ['原料车间','干混生料','Fe2O3', , , , , , ],
|
||||||
['原料车间','干混生料','水分', , , , , , ],
|
// ['原料车间','干混生料','水分', , , , , , ],
|
||||||
['原料车间','干混生料','CaO', , , , , , ],
|
// ['原料车间','干混生料','CaO', , , , , , ],
|
||||||
|
|
||||||
['烧成车间','入窑生料','CaO', , , , , , ],
|
// ['烧成车间','入窑生料','CaO', , , , , , ],
|
||||||
['烧成车间','入窑生料','Fe2O3', , , , , , ],
|
// ['烧成车间','入窑生料','Fe2O3', , , , , , ],
|
||||||
['烧成车间','入窑生料','细度'],
|
// ['烧成车间','入窑生料','细度'],
|
||||||
['烧成车间','入窑生料','水分'],
|
// ['烧成车间','入窑生料','水分'],
|
||||||
['烧成车间','熟料','立升重'],
|
// ['烧成车间','熟料','立升重'],
|
||||||
['烧成车间','熟料','f-CaO'],
|
// ['烧成车间','熟料','f-CaO'],
|
||||||
['烧成车间','煤粉','细度'],
|
// ['烧成车间','煤粉','细度'],
|
||||||
['烧成车间','煤粉','水分'],
|
// ['烧成车间','煤粉','水分'],
|
||||||
|
|
||||||
['水泥车间','出磨水泥','比表面积'],
|
// ['水泥车间','出磨水泥','比表面积'],
|
||||||
['水泥车间','出磨水泥','SO3'],
|
// ['水泥车间','出磨水泥','SO3'],
|
||||||
['水泥车间','出磨水泥','掺量'],
|
// ['水泥车间','出磨水泥','掺量'],
|
||||||
],
|
// ],
|
||||||
tableDatas3:[],
|
tableDatas3:[],
|
||||||
exportLoading:false,
|
exportLoading:false,
|
||||||
header2:[],
|
header2:[],
|
||||||
|
@ -172,7 +171,7 @@ import moment from 'moment';
|
||||||
deptOptions:[],
|
deptOptions:[],
|
||||||
dialogVisible: false, // 控制对话框显示
|
dialogVisible: false, // 控制对话框显示
|
||||||
currentColumnIndex: null, // 当前编辑的列索引
|
currentColumnIndex: null, // 当前编辑的列索引
|
||||||
thresholds: {}, // 存储每列的阈值,key 为列索引
|
// thresholds: {}, // 存储每列的阈值,key 为列索引
|
||||||
thresholdobj:{},
|
thresholdobj:{},
|
||||||
materialTestItemMap:{},
|
materialTestItemMap:{},
|
||||||
currentMaterialNameClass: '',
|
currentMaterialNameClass: '',
|
||||||
|
@ -181,13 +180,6 @@ import moment from 'moment';
|
||||||
currentTestItemNameClass: '', // 当前检测项名称
|
currentTestItemNameClass: '', // 当前检测项名称
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
header3: {
|
|
||||||
handler(newV, OldV) {
|
|
||||||
this.header3 = newV;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
var myDate = new Date();
|
var myDate = new Date();
|
||||||
let month = myDate.getMonth()+1;
|
let month = myDate.getMonth()+1;
|
||||||
|
@ -207,7 +199,7 @@ import moment from 'moment';
|
||||||
let that = this;
|
let that = this;
|
||||||
if(value==1){
|
if(value==1){
|
||||||
this.typeName = '质检日报表'
|
this.typeName = '质检日报表'
|
||||||
}else if(value==1){
|
}else if(value==0){
|
||||||
this.typeName = '质检月报表'
|
this.typeName = '质检月报表'
|
||||||
}
|
}
|
||||||
that.tableName = that.deptName+that.typeName;
|
that.tableName = that.deptName+that.typeName;
|
||||||
|
@ -216,7 +208,6 @@ import moment from 'moment';
|
||||||
const num = parseFloat(this.currentThreshold);
|
const num = parseFloat(this.currentThreshold);
|
||||||
if (!isNaN(num)){
|
if (!isNaN(num)){
|
||||||
const key = `${this.currentMaterialName}-${this.currentTestItemName}`;
|
const key = `${this.currentMaterialName}-${this.currentTestItemName}`;
|
||||||
console.log("---------------key", key, this.materialTestItemMap)
|
|
||||||
const mapEntry = this.materialTestItemMap[key];
|
const mapEntry = this.materialTestItemMap[key];
|
||||||
if (!mapEntry) {
|
if (!mapEntry) {
|
||||||
return;
|
return;
|
||||||
|
@ -231,7 +222,7 @@ import moment from 'moment';
|
||||||
this.$API.qm.updateQuastatGoal.post(payload)
|
this.$API.qm.updateQuastatGoal.post(payload)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.$message.success("阈值更新成功");
|
this.$message.success("阈值更新成功");
|
||||||
this.thresholds[this.currentColumnIndex] = res.rate_pass_t; // 更新本地阈值
|
// this.thresholds[this.currentColumnIndex] = res.rate_pass_t; // 更新本地阈值
|
||||||
this.dialogVisible = false; // 关闭对话框
|
this.dialogVisible = false; // 关闭对话框
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
@ -275,7 +266,7 @@ import moment from 'moment';
|
||||||
const keyName = `${that.currentMaterialNameClass}-${that.currentTestItemNameClass}`;
|
const keyName = `${that.currentMaterialNameClass}-${that.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';
|
||||||
} else {
|
} else {
|
||||||
return 'green-text';
|
return 'green-text';
|
||||||
}
|
}
|
||||||
|
@ -318,16 +309,13 @@ import moment from 'moment';
|
||||||
}
|
}
|
||||||
if (header2Index !== -1 && header3Index !== -1){
|
if (header2Index !== -1 && header3Index !== -1){
|
||||||
that.currentMaterialName = this.header2Obj[header2Index].name; // header2Obj
|
that.currentMaterialName = this.header2Obj[header2Index].name; // header2Obj
|
||||||
console.log('that.currentMaterialName', that.currentMaterialName, header2Index)
|
|
||||||
that.currentTestItemName = this.header3[header3Index]; // header3
|
that.currentTestItemName = this.header3[header3Index]; // header3
|
||||||
console.log("--that.currentTestItemName--", this.header3, that.currentTestItemName, header3Index)
|
|
||||||
}else {
|
}else {
|
||||||
this.currentMaterialName = '';
|
this.currentMaterialName = '';
|
||||||
this.currentTestItemName = '';
|
this.currentTestItemName = '';
|
||||||
}
|
}
|
||||||
const keyName = `${that.currentMaterialName}-${that.currentTestItemName}`;
|
const keyName = `${that.currentMaterialName}-${that.currentTestItemName}`;
|
||||||
this.currentThreshold = that.thresholdobj[keyName] || 0;
|
this.currentThreshold = that.thresholdobj[keyName] || 0;
|
||||||
console.log("-----------this.currentThreshold------", this.currentThreshold, )
|
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
},
|
},
|
||||||
getTableData(){
|
getTableData(){
|
||||||
|
@ -335,24 +323,27 @@ import moment from 'moment';
|
||||||
that.tableDatas3 = [];
|
that.tableDatas3 = [];
|
||||||
that.materialTestItemMap = {};
|
that.materialTestItemMap = {};
|
||||||
that.header3 = [];
|
that.header3 = [];
|
||||||
|
debugger;
|
||||||
if(that.deptName=='原料车间'){
|
if(that.deptName=='原料车间'){
|
||||||
that.header2Obj=[{name:'辅料',lengths:3},{name:'干混生料',lengths:4}];
|
that.header2Obj=[{name:'辅料',lengths:3},{name:'干混生料',lengths:4}];
|
||||||
that.header2 = ['辅料','干混生料'];//物料
|
that.header2 = ['辅料','干混生料'];//物料
|
||||||
// that.header3 = ['细度','Fe2O3','水分','细度','Fe2O3','水分','CaO'];//检测项
|
// that.header3 = ['细度','Fe2O3','水分','细度','Fe2O3','水分','CaO'];//检测项
|
||||||
that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//检测项
|
// that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//检测项
|
||||||
}else if(that.deptName=='烧成车间'){
|
}else if(that.deptName=='烧成车间'){
|
||||||
that.header2Obj=[{name:'入窑生料',lengths:4},{name:'熟料',lengths:4}];
|
that.header2Obj=[{name:'入窑生料',lengths:4},{name:'熟料',lengths:4}];
|
||||||
that.header2 = ['入窑生料','熟料'];//物料
|
that.header2 = ['入窑生料','熟料'];//物料
|
||||||
// that.header3 = ['CaO','Fe2O3','细度','水分','立升重','f-CaO','细度','水分'];//检测项
|
// that.header3 = ['CaO','Fe2O3','细度','水分','立升重','f-CaO','细度','水分'];//检测项
|
||||||
that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//检测项
|
// that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//检测项
|
||||||
}else{
|
}else{
|
||||||
that.header2Obj=[{name:'出磨水泥',lengths:3}];
|
that.header2Obj=[{name:'出磨水泥',lengths:3}];
|
||||||
that.header2 = ['出磨水泥'];//物料
|
that.header2 = ['出磨水泥'];//物料
|
||||||
// that.header3 = ['比表面积','SO3','掺量'];//检测项
|
// that.header3 = ['比表面积','SO3','掺量'];//检测项
|
||||||
that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//检测项
|
// that.header4 = ['平均值','检次','合次','合格率','平均值','检次','合次','合格率','平均值','检次','合次','合格率'];//检测项
|
||||||
}
|
}
|
||||||
let params = {page: 0};
|
let params = {page: 0};
|
||||||
let arr = [];
|
let arr = [];
|
||||||
|
let update_start_time = '';
|
||||||
|
let update_end_time = '';
|
||||||
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];
|
||||||
|
@ -363,22 +354,24 @@ import moment from 'moment';
|
||||||
params.year_s = that.query.year;
|
params.year_s = that.query.year;
|
||||||
}
|
}
|
||||||
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 = [];
|
||||||
let innerArr = [];
|
let innerArr = [];
|
||||||
let update_start_time = '';
|
|
||||||
let update_end_time = '';
|
|
||||||
let ind = 0;
|
let ind = 0;
|
||||||
//1、将相同日期或月份/年份的数据放到一组
|
//1、将相同日期或月份/年份的数据放到一组
|
||||||
let header2=[],header2Obj=[],header3=[],header4=[];
|
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 => {
|
data.forEach(item => {
|
||||||
item.qua_data.forEach((qua)=>{
|
item.qua_data.forEach((qua)=>{
|
||||||
let key = `${qua.material_name}-${qua.testitem_name}`;
|
let key = `${qua.material_name}-${qua.testitem_name}`;
|
||||||
|
@ -416,9 +409,7 @@ import moment from 'moment';
|
||||||
wrapArr[ind].push(item)
|
wrapArr[ind].push(item)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
wrapArr = wrapArr.filter(item=>{
|
wrapArr = wrapArr.filter(item => item && item.length > 0);
|
||||||
return item
|
|
||||||
})
|
|
||||||
wrapArr.forEach((item1,index1)=>{
|
wrapArr.forEach((item1,index1)=>{
|
||||||
if(item1!=undefined){//一天的数据
|
if(item1!=undefined){//一天的数据
|
||||||
let itemArr = [];
|
let itemArr = [];
|
||||||
|
@ -428,9 +419,7 @@ import moment from 'moment';
|
||||||
itemArr.push(time)
|
itemArr.push(time)
|
||||||
//遍历每个工段
|
//遍历每个工段
|
||||||
item1.forEach(item2=>{
|
item1.forEach(item2=>{
|
||||||
|
|
||||||
let data2 =item2.qua_data;
|
let data2 =item2.qua_data;
|
||||||
// console.log("-----data2-----", data2)
|
|
||||||
//遍历一个工段的物料检验数据
|
//遍历一个工段的物料检验数据
|
||||||
data2.forEach((item3,index3)=>{
|
data2.forEach((item3,index3)=>{
|
||||||
//item3一个检验数据
|
//item3一个检验数据
|
||||||
|
@ -442,7 +431,6 @@ import moment from 'moment';
|
||||||
header2Objtem.push({name:item3.material_name,lengths:1})
|
header2Objtem.push({name:item3.material_name,lengths:1})
|
||||||
}
|
}
|
||||||
header3tem.push(item3.testitem_name)
|
header3tem.push(item3.testitem_name)
|
||||||
|
|
||||||
header4tem.push('平均值')
|
header4tem.push('平均值')
|
||||||
header4tem.push('检次')
|
header4tem.push('检次')
|
||||||
header4tem.push('合次')
|
header4tem.push('合次')
|
||||||
|
@ -469,7 +457,6 @@ import moment from 'moment';
|
||||||
if(!that.thresholdobj[item3.material_name+"-"+item3.testitem_name]){
|
if(!that.thresholdobj[item3.material_name+"-"+item3.testitem_name]){
|
||||||
that.thresholdobj[item3.material_name+"-"+item3.testitem_name] = item3.rate_g;
|
that.thresholdobj[item3.material_name+"-"+item3.testitem_name] = item3.rate_g;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
itemArr.push(Number(item3.val_avg).toFixed(2));
|
itemArr.push(Number(item3.val_avg).toFixed(2));
|
||||||
itemArr.push(item3.num_test);
|
itemArr.push(item3.num_test);
|
||||||
|
@ -509,7 +496,6 @@ import moment from 'moment';
|
||||||
if(header4.length>0){
|
if(header4.length>0){
|
||||||
that.header4 = header4;
|
that.header4 = header4;
|
||||||
}
|
}
|
||||||
this.$forceUpdate();
|
|
||||||
innerArr.forEach(item=>{
|
innerArr.forEach(item=>{
|
||||||
if(item.length>1){
|
if(item.length>1){
|
||||||
that.tableDatas3.push(item)
|
that.tableDatas3.push(item)
|
||||||
|
|
Loading…
Reference in New Issue