|
@@ -3,10 +3,11 @@ |
|
|
<!-- 搜索工作栏 --> |
|
|
<!-- 搜索工作栏 --> |
|
|
<search-bar |
|
|
<search-bar |
|
|
:formConfigs="formConfig" |
|
|
:formConfigs="formConfig" |
|
|
ref="searchBarForm" |
|
|
|
|
|
@headBtnClick="buttonClick" /> |
|
|
@headBtnClick="buttonClick" /> |
|
|
<base-table |
|
|
<base-table |
|
|
class="sectionProductionTable1" |
|
|
class="sectionProductionTable1" |
|
|
|
|
|
ref="sectionProductionTable11" |
|
|
|
|
|
id="sectionProductionTable1" |
|
|
:table-props="tableProp" |
|
|
:table-props="tableProp" |
|
|
:table-data="tableData" |
|
|
:table-data="tableData" |
|
|
:span-method="objectSpanMethod" |
|
|
:span-method="objectSpanMethod" |
|
@@ -15,10 +16,11 @@ |
|
|
<search-bar |
|
|
<search-bar |
|
|
style="margin-top: 10px" |
|
|
style="margin-top: 10px" |
|
|
:formConfigs="formConfig2" |
|
|
:formConfigs="formConfig2" |
|
|
ref="searchBarForm" |
|
|
|
|
|
@headBtnClick="buttonClick2" /> |
|
|
@headBtnClick="buttonClick2" /> |
|
|
<base-table |
|
|
<base-table |
|
|
class="sectionProductionTable2" |
|
|
class="sectionProductionTable2" |
|
|
|
|
|
ref="sectionProductionTable22" |
|
|
|
|
|
id="sectionProductionTable2" |
|
|
:table-props="tableProp2" |
|
|
:table-props="tableProp2" |
|
|
:table-data="tableData2" |
|
|
:table-data="tableData2" |
|
|
:span-method="objectSpanMethod2" |
|
|
:span-method="objectSpanMethod2" |
|
@@ -30,17 +32,18 @@ const tableProp1 = [ |
|
|
{ |
|
|
{ |
|
|
prop: 'lineName', |
|
|
prop: 'lineName', |
|
|
label: '生产线', |
|
|
label: '生产线', |
|
|
width: 110, |
|
|
|
|
|
|
|
|
width: 80, |
|
|
fixed: true, |
|
|
fixed: true, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
label: '时间', |
|
|
label: '时间', |
|
|
fixed: true, |
|
|
fixed: true, |
|
|
width: 110, |
|
|
|
|
|
|
|
|
width: 140, |
|
|
children: [ |
|
|
children: [ |
|
|
{ |
|
|
{ |
|
|
prop: 'procedure', |
|
|
prop: 'procedure', |
|
|
label: '工序', |
|
|
label: '工序', |
|
|
|
|
|
fixed: true, |
|
|
width: 140, |
|
|
width: 140, |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
@@ -132,13 +135,13 @@ export default { |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
|
queryParams: { |
|
|
queryParams: { |
|
|
startTime: '1706114700000', |
|
|
|
|
|
endTime: '1706190300000', |
|
|
|
|
|
|
|
|
startTime: '', |
|
|
|
|
|
endTime: '', |
|
|
lineId: '', |
|
|
lineId: '', |
|
|
}, |
|
|
}, |
|
|
queryParams2: { |
|
|
queryParams2: { |
|
|
startTime: '1706114700000', |
|
|
|
|
|
endTime: '1706190300000', |
|
|
|
|
|
|
|
|
startTime: '', |
|
|
|
|
|
endTime: '', |
|
|
lineId: '', |
|
|
lineId: '', |
|
|
}, |
|
|
}, |
|
|
tableProp1, |
|
|
tableProp1, |
|
@@ -166,6 +169,11 @@ export default { |
|
|
this.getLine(); |
|
|
this.getLine(); |
|
|
this.tableProp = this.tableProp1; |
|
|
this.tableProp = this.tableProp1; |
|
|
this.tableProp2 = this.tableProp1; |
|
|
this.tableProp2 = this.tableProp1; |
|
|
|
|
|
let arr = this.getTime('1'); |
|
|
|
|
|
this.queryParams.startTime = arr[0]; |
|
|
|
|
|
this.queryParams.endTime = arr[1]; |
|
|
|
|
|
this.queryParams2.startTime = arr[0]; |
|
|
|
|
|
this.queryParams2.endTime = arr[1]; |
|
|
this.getList(); |
|
|
this.getList(); |
|
|
this.getList2(); |
|
|
this.getList2(); |
|
|
}, |
|
|
}, |
|
@@ -185,8 +193,8 @@ export default { |
|
|
// 获取数据 |
|
|
// 获取数据 |
|
|
originalSection({ ...this.queryParams }).then((res) => { |
|
|
originalSection({ ...this.queryParams }).then((res) => { |
|
|
let data = res.data; |
|
|
let data = res.data; |
|
|
let timeArr = this.uniqueTime(data, 'timeStr'); |
|
|
|
|
|
this.tableProp = []; |
|
|
this.tableProp = []; |
|
|
|
|
|
let timeArr = this.uniqueTime(data, 'timeStr'); |
|
|
let arr = []; |
|
|
let arr = []; |
|
|
timeArr.map((item) => { |
|
|
timeArr.map((item) => { |
|
|
let obj = {}; |
|
|
let obj = {}; |
|
@@ -200,34 +208,44 @@ export default { |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
getTime(val) { |
|
|
getTime(val) { |
|
|
|
|
|
let nowTime = moment().valueOf(); |
|
|
|
|
|
let dTime = moment(moment().format('YYYY-MM-DD') + ' 07:00:00').valueOf(); |
|
|
switch (val) { |
|
|
switch (val) { |
|
|
case '1': |
|
|
case '1': |
|
|
let nowTime = moment().valueOf(); |
|
|
|
|
|
let dTime = moment( |
|
|
|
|
|
moment().format('YYYY-MM-DD') + ' 07:00:00' |
|
|
|
|
|
|
|
|
let fTime = moment( |
|
|
|
|
|
moment(moment().valueOf() - 86400000).format('YYYY-MM-DD') + |
|
|
|
|
|
' 19:00:00' |
|
|
).valueOf(); |
|
|
).valueOf(); |
|
|
let nTime = moment( |
|
|
let nTime = moment( |
|
|
moment().format('YYYY-MM-DD') + ' 19:00:00' |
|
|
moment().format('YYYY-MM-DD') + ' 19:00:00' |
|
|
).valueOf(); |
|
|
).valueOf(); |
|
|
let fTime = |
|
|
|
|
|
moment(moment().valueOf() - 86400).format('YYYY-MM-DD') + |
|
|
|
|
|
' 19:00:00'; |
|
|
|
|
|
console.log(fTime); |
|
|
|
|
|
// if (nowTime >= dTime) { |
|
|
|
|
|
// return [dTime, nowTime] |
|
|
|
|
|
// }else if (){ |
|
|
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
if (nowTime <= dTime) { |
|
|
|
|
|
return [fTime, nowTime]; |
|
|
|
|
|
} else if (nowTime > dTime && nowTime <= nTime) { |
|
|
|
|
|
return [dTime, nowTime]; |
|
|
|
|
|
} else { |
|
|
|
|
|
return [nTime, nowTime]; |
|
|
|
|
|
} |
|
|
break; |
|
|
break; |
|
|
case '2': |
|
|
case '2': |
|
|
|
|
|
let lastTime = nowTime - 86400000; |
|
|
|
|
|
return [lastTime, nowTime]; |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
|
|
|
let f1Time = dTime - 86400000 * 2; |
|
|
|
|
|
let f2Time = dTime - 86400000; |
|
|
|
|
|
if (nowTime <= dTime) { |
|
|
|
|
|
return [f1Time, f2Time]; |
|
|
|
|
|
} else { |
|
|
|
|
|
return [f2Time, dTime]; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
buttonClick(val) { |
|
|
buttonClick(val) { |
|
|
if (val.btnName === 'search') { |
|
|
if (val.btnName === 'search') { |
|
|
this.queryParams.lineId = val.lineId; |
|
|
this.queryParams.lineId = val.lineId; |
|
|
this.getTime(val.timeType); |
|
|
|
|
|
|
|
|
this.queryParams.startTime = this.getTime(val.timeType)[0]; |
|
|
|
|
|
this.queryParams.endTime = this.getTime(val.timeType)[1]; |
|
|
this.getList(); |
|
|
this.getList(); |
|
|
} else { |
|
|
} else { |
|
|
//导出 |
|
|
//导出 |
|
@@ -268,39 +286,61 @@ export default { |
|
|
transferData(data) { |
|
|
transferData(data) { |
|
|
let tempData = []; |
|
|
let tempData = []; |
|
|
let lineNum = 0; //第一条产线 |
|
|
let lineNum = 0; //第一条产线 |
|
|
|
|
|
let sumArr = []; |
|
|
for (let i = 0; i < data.length; i++) { |
|
|
for (let i = 0; i < data.length; i++) { |
|
|
if (i === 0) { |
|
|
if (i === 0) { |
|
|
this.procedureName.map((item) => { |
|
|
this.procedureName.map((item) => { |
|
|
let obj = {}; |
|
|
let obj = {}; |
|
|
obj.lineName = data[i].lineName; |
|
|
obj.lineName = data[i].lineName; |
|
|
obj.procedure = item.name; |
|
|
obj.procedure = item.name; |
|
|
|
|
|
obj.eName = item.ename; |
|
|
obj[data[i].timeStr] = data[i][item.ename]; |
|
|
obj[data[i].timeStr] = data[i][item.ename]; |
|
|
tempData.push(obj); |
|
|
tempData.push(obj); |
|
|
}); |
|
|
}); |
|
|
lineNum++; |
|
|
lineNum++; |
|
|
} else { |
|
|
} else { |
|
|
if (data[i].lineName === data[i - 1].lineName) { |
|
|
|
|
|
//相同产线,添加列 |
|
|
|
|
|
let startNum = 5 * (lineNum - 1); |
|
|
|
|
|
let endNum = 5 * lineNum - 1; |
|
|
|
|
|
for (let k = startNum; k <= endNum; k++) { |
|
|
|
|
|
let str = this.procedureName[k % 5]; |
|
|
|
|
|
tempData[k][data[i].timeStr] = data[i][str.ename]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (data[i].timeStr === '总计') { |
|
|
|
|
|
sumArr.push(data[i]); |
|
|
} else { |
|
|
} else { |
|
|
//不同产线,同时添加5行 |
|
|
|
|
|
this.procedureName.map((item) => { |
|
|
|
|
|
let obj = {}; |
|
|
|
|
|
obj.lineName = data[i].lineName; |
|
|
|
|
|
obj.procedure = item.name; |
|
|
|
|
|
obj[data[i].timeStr] = data[i][item.ename]; |
|
|
|
|
|
tempData.push(obj); |
|
|
|
|
|
}); |
|
|
|
|
|
lineNum++; |
|
|
|
|
|
|
|
|
if (data[i].lineName === data[i - 1].lineName) { |
|
|
|
|
|
//相同产线,添加列 |
|
|
|
|
|
let startNum = 5 * (lineNum - 1); |
|
|
|
|
|
let endNum = 5 * lineNum - 1; |
|
|
|
|
|
for (let k = startNum; k <= endNum; k++) { |
|
|
|
|
|
let str = this.procedureName[k % 5]; |
|
|
|
|
|
tempData[k][data[i].timeStr] = data[i][str.ename]; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
//不同产线,同时添加5行 |
|
|
|
|
|
this.procedureName.map((item) => { |
|
|
|
|
|
let obj = {}; |
|
|
|
|
|
obj.lineName = data[i].lineName; |
|
|
|
|
|
obj.procedure = item.name; |
|
|
|
|
|
obj.eName = item.ename; |
|
|
|
|
|
obj[data[i].timeStr] = data[i][item.ename]; |
|
|
|
|
|
tempData.push(obj); |
|
|
|
|
|
}); |
|
|
|
|
|
lineNum++; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
for (let j = 0; j < tempData.length; j++) { |
|
|
|
|
|
sumArr.map((item) => { |
|
|
|
|
|
tempData[j]['总计'] = item[tempData[j].eName]; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
this.tableData = tempData; |
|
|
this.tableData = tempData; |
|
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
this.reTable1(); |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
reTable1() { |
|
|
|
|
|
this.$refs.sectionProductionTable11.doLayout('sectionProductionTable1'); |
|
|
|
|
|
}, |
|
|
|
|
|
reTable2() { |
|
|
|
|
|
this.$refs.sectionProductionTable22.doLayout('sectionProductionTable2'); |
|
|
}, |
|
|
}, |
|
|
// 时间去重 |
|
|
// 时间去重 |
|
|
uniqueTime(arr, prop) { |
|
|
uniqueTime(arr, prop) { |
|
@@ -357,12 +397,17 @@ export default { |
|
|
arr.push({ prop: 'sum', label: '合计' }); |
|
|
arr.push({ prop: 'sum', label: '合计' }); |
|
|
this.tableProp2 = this.tableProp1.concat(arr); //表头 |
|
|
this.tableProp2 = this.tableProp1.concat(arr); //表头 |
|
|
this.getSpanArr(this.tableData2); |
|
|
this.getSpanArr(this.tableData2); |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
this.reTable2(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
// 表格2 |
|
|
// 表格2 |
|
|
buttonClick2(val) { |
|
|
buttonClick2(val) { |
|
|
if (val.btnName === 'search') { |
|
|
if (val.btnName === 'search') { |
|
|
this.queryParams2.lineId = val.lineId; |
|
|
this.queryParams2.lineId = val.lineId; |
|
|
|
|
|
this.queryParams2.startTime = this.getTime(val.timeType)[0]; |
|
|
|
|
|
this.queryParams2.endTime = this.getTime(val.timeType)[1]; |
|
|
this.getList2(); |
|
|
this.getList2(); |
|
|
} else { |
|
|
} else { |
|
|
this.exportTable('.sectionProductionTable2', '深加工工段数据.xlsx', 1); |
|
|
this.exportTable('.sectionProductionTable2', '深加工工段数据.xlsx', 1); |
|
|