feat: 修改质量报表
This commit is contained in:
parent
ae3e6aa1ec
commit
56334fc718
|
@ -34,6 +34,7 @@
|
|||
"html2canvas": "^1.4.1",
|
||||
"json-editor-vue3": "^1.0.6",
|
||||
"jspdf": "^2.5.1",
|
||||
"moment": "^2.30.1",
|
||||
"node-polyfill-webpack-plugin": "^4.0.0",
|
||||
"nprogress": "0.2.0",
|
||||
"print-js": "^1.6.0",
|
||||
|
|
|
@ -26,6 +26,13 @@ export default {
|
|||
return await http.post(this.url, data);
|
||||
},
|
||||
},
|
||||
updateQuastatGoal: {
|
||||
url: `${config.API_URL}/qm/quastat/update_rate_pass_t/`,
|
||||
name: "更新合格率目标值",
|
||||
post: async function (data = {}) {
|
||||
return await http.post(this.url, data);
|
||||
},
|
||||
},
|
||||
//质检项目
|
||||
getTestItem: {
|
||||
url: `${config.API_URL}/qm/testitem/`,
|
||||
|
|
|
@ -101,13 +101,13 @@
|
|||
width="120"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
<!-- <el-table-column
|
||||
label="合计"
|
||||
prop="sum"
|
||||
width="130"
|
||||
fixed="right"
|
||||
>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
</el-table>
|
||||
<el-table
|
||||
v-if="query.type==1"
|
||||
|
@ -116,7 +116,7 @@
|
|||
style="width: 100%"
|
||||
border
|
||||
:height="tableHeight"
|
||||
@cell-click="handleCellClick1"
|
||||
|
||||
>
|
||||
<el-table-column
|
||||
label="分类"
|
||||
|
@ -135,13 +135,13 @@
|
|||
width="120"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
<!-- <el-table-column
|
||||
label="合计"
|
||||
prop="sum"
|
||||
width="130"
|
||||
fixed="right"
|
||||
>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
</el-table>
|
||||
<el-table
|
||||
v-if="query.type==2"
|
||||
|
@ -150,7 +150,7 @@
|
|||
style="width: 100%"
|
||||
border
|
||||
:height="tableHeight"
|
||||
@cell-click="handleCellClick_month"
|
||||
|
||||
>
|
||||
<el-table-column
|
||||
label="分类"
|
||||
|
@ -169,13 +169,13 @@
|
|||
width="120"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
<!-- <el-table-column
|
||||
label="合计"
|
||||
prop="sum"
|
||||
width="130"
|
||||
fixed="right"
|
||||
>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
</el-table>
|
||||
<el-table
|
||||
v-if="query.type==3"
|
||||
|
@ -184,7 +184,7 @@
|
|||
style="width: 100%"
|
||||
border
|
||||
:height="tableHeight"
|
||||
@cell-click="handleCellClick_range"
|
||||
|
||||
>
|
||||
<el-table-column
|
||||
label="分类"
|
||||
|
@ -242,9 +242,49 @@
|
|||
<script>
|
||||
let legend = {
|
||||
top: "2%",
|
||||
data: ["碳排放量(t)"],
|
||||
data: ["碳排放量(t)", "碳排放强度(t/t)"],
|
||||
};
|
||||
let colors = ["##36492E", "#4BA328", "#C6F47D"];
|
||||
let grid = {
|
||||
right: "11%",
|
||||
left: "11%",
|
||||
top: "27%",
|
||||
};
|
||||
let colors = ["#518A3A", "#2DAEEF", "#C6F47D"];
|
||||
let yAxis = [
|
||||
{
|
||||
type: "value",
|
||||
name: "碳排放量(t)",
|
||||
position: "left",
|
||||
alignTicks: true,
|
||||
nameRotate: 50,
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: colors[0],
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
formatter: "{value}",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "value",
|
||||
name: "碳排放强度(t/t)",
|
||||
position: "right",
|
||||
alignTicks: true,
|
||||
nameRotate: 50,
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: colors[1],
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
formatter: "{value}",
|
||||
},
|
||||
}
|
||||
|
||||
];
|
||||
import scEcharts from "@/components/scEcharts";
|
||||
export default {
|
||||
components: {
|
||||
|
@ -278,7 +318,6 @@ export default {
|
|||
{id:0,name:'日统计'},
|
||||
{id:1,name:'月统计'},
|
||||
{id:2,name:'年统计'},
|
||||
{id:3,name:'时间段'},
|
||||
],
|
||||
tableDatas2: [],
|
||||
tableDatas_day:[],
|
||||
|
@ -389,13 +428,14 @@ export default {
|
|||
xAxisData_month: [],
|
||||
xTtimeRange: [],
|
||||
gyhourlyData : [],
|
||||
lvhourlyData : [],
|
||||
mpointList_code:"3750125939653558272,3759456603624382464,3636975194725527552",
|
||||
StrengthData : [],
|
||||
shhourlyData : [], // 用于存储每小时的数据
|
||||
gyhourlyData_month : [],
|
||||
lvhourlyData_month : [],
|
||||
shhourlyData_month : [], // 用于存储每小时的数据
|
||||
StrengthData_month : [],
|
||||
ProductionData_month : [], // 用于存储每小时的数据
|
||||
gyhourlyData_year : [],
|
||||
lvhourlyData_year : [],
|
||||
StrengthData_year : [],
|
||||
shhourlyData_year : [], // 用于存储每小时的数据
|
||||
};
|
||||
},
|
||||
|
@ -450,10 +490,10 @@ export default {
|
|||
},
|
||||
changeDate(){
|
||||
let obj = {};
|
||||
obj.type = "day";
|
||||
obj.type = "hour";
|
||||
obj.start_time = this.daterange[0];
|
||||
obj.end_time = this.daterange[1];
|
||||
obj.mpoint__in = "3750125939653558272";
|
||||
obj.mpoint__in = '3750125939653558272,3759456603624382464';
|
||||
obj.page = 0;
|
||||
this.$API.enm.mpointstat.groupValues.req(obj).then((res) => {
|
||||
//处理res数组中的 total_val 字段 保留两位
|
||||
|
@ -501,7 +541,7 @@ export default {
|
|||
// enabled: 1,
|
||||
// need_display: 1,
|
||||
ordering: "report_sortstr",
|
||||
code__in: "tpfl",
|
||||
code__in: "tanpfqd, tpfl",
|
||||
query: "{ id, name, nickname, mgroup_name, unit, report_sortstr }",
|
||||
})
|
||||
.then((res) => {
|
||||
|
@ -518,6 +558,7 @@ export default {
|
|||
_nameLength = [],
|
||||
indexList = [];
|
||||
let mgroupObj = {};
|
||||
console.log(that.mpointList);
|
||||
that.mpointList.forEach((item, index) => {
|
||||
let indexs = _mgroup.indexOf(item.mgroup_name);
|
||||
if (indexs > -1) {
|
||||
|
@ -551,12 +592,14 @@ export default {
|
|||
that.tableDatas2.push(obj);
|
||||
that.getData(item.id, index);
|
||||
});
|
||||
that.updateChart(that.gyhourlyData, that.shhourlyData, that.lvhourlyData);
|
||||
that.updateChart(that.gyhourlyData, that.StrengthData);
|
||||
that.mgroupObj = mgroupObj;
|
||||
that.indexList = indexList;
|
||||
},
|
||||
getData(id, index) {
|
||||
let that = this;
|
||||
that.StrengthData = [];
|
||||
that.gyhourlyData = [];
|
||||
let obj = {};
|
||||
obj.type = "hour";
|
||||
obj.year = that.year;
|
||||
|
@ -574,6 +617,10 @@ export default {
|
|||
that.tableDatas2[index][keyName] = item.val;
|
||||
if (item.mpoint_nickname == "碳排放量"){
|
||||
that.gyhourlyData[item.hour] = item.val;
|
||||
}else if(
|
||||
item.mpoint_nickname == "碳排放强度"
|
||||
){
|
||||
that.StrengthData[item.hour] = item.val;
|
||||
}
|
||||
});
|
||||
sum = sum * 100;
|
||||
|
@ -585,11 +632,12 @@ export default {
|
|||
that.$forceUpdate();
|
||||
});
|
||||
},
|
||||
updateChart(gyhourlyData, shhourlyData, lvhourlyData) {
|
||||
updateChart(gyhourlyData, StrengthData) {
|
||||
let that = this;
|
||||
// 创建 ECharts 配置
|
||||
let option = {
|
||||
legend: legend,
|
||||
grid: grid,
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
|
@ -600,19 +648,28 @@ export default {
|
|||
type: 'category',
|
||||
data: ['0时', '1时', '2时', '3时', '4时', '5时', '6时', '7时', '8时', '9时', '10时', '11时', '12时', '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时', '21时', '22时', '23时'],
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
name: ''
|
||||
},
|
||||
yAxis: yAxis,
|
||||
series: [{
|
||||
name: '碳排放量(t)', // 此处修改为对应分类的名称
|
||||
type: 'bar',
|
||||
data: gyhourlyData, // 每小时的用水量
|
||||
data: gyhourlyData,
|
||||
yAxisIndex: 0,
|
||||
itemStyle: {
|
||||
color: '#518A3A',
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
name: '碳排放强度(t/t)',
|
||||
type: 'bar',
|
||||
data: StrengthData,
|
||||
yAxisIndex: 1,
|
||||
itemStyle: {
|
||||
color: colors[1],
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
]
|
||||
};
|
||||
that.optionHour = option;
|
||||
|
@ -621,9 +678,7 @@ export default {
|
|||
let that = this;
|
||||
that.tableDatas = [];
|
||||
that.tableDatas_day = [];
|
||||
let _mgroup = [],
|
||||
_nameLength = [],
|
||||
indexList = [];
|
||||
let _mgroup = [], _nameLength = [], indexList = [];
|
||||
let mgroupObj = {};
|
||||
that.mpointList.forEach((item, index) => {
|
||||
let indexs = _mgroup.indexOf(item.mgroup_name);
|
||||
|
@ -638,42 +693,39 @@ export default {
|
|||
for (let i = 0; i < _mgroup.length; i++) {
|
||||
mgroupObj[_mgroup[i]] = _nameLength[i];
|
||||
}
|
||||
|
||||
let arr = [];
|
||||
arr[0] =
|
||||
item.mgroup_name != null
|
||||
? item.mgroup_name
|
||||
: item.nickname != null
|
||||
? item.nickname
|
||||
: item.name;
|
||||
arr[0] = item.mgroup_name != null ? item.mgroup_name : item.nickname != null ? item.nickname : item.name;
|
||||
arr[1] = item.nickname != null ? item.nickname : item.name;
|
||||
arr[2] = item.unit;
|
||||
for (let i = 0; i < that.days; i++) {
|
||||
arr[i + 2] = 0;
|
||||
}
|
||||
|
||||
that.tableDatas.push(arr);
|
||||
let obj = {};
|
||||
obj.mgroupName =
|
||||
item.mgroup_name != null ? item.mgroup_name : item.name;
|
||||
obj.nickname =
|
||||
item.nickname != null && item.nickname != ""
|
||||
? item.nickname
|
||||
: item.name;
|
||||
obj.mgroupName = item.mgroup_name != null ? item.mgroup_name : item.name;
|
||||
obj.nickname = item.nickname != null && item.nickname != "" ? item.nickname : item.name;
|
||||
obj.unit = item.unit;
|
||||
|
||||
that.tableDatas_day.push(obj);
|
||||
that.getData1(item.id, index);
|
||||
|
||||
// 在每次循环调用 getData1(index),确保异步操作独立
|
||||
that.getData1(index);
|
||||
});
|
||||
that.updateMonthChart(that.gyhourlyData_month);
|
||||
|
||||
that.updateMonthChart(that.gyhourlyData_month, that.StrengthData_month, that.ProductionData_month);
|
||||
that.mgroupObj = mgroupObj;
|
||||
that.indexList = indexList;
|
||||
|
||||
},
|
||||
|
||||
updateMonthChart(gyhourlyData) {
|
||||
|
||||
updateMonthChart(gyhourlyData, StrengthData, ) {
|
||||
let that = this;
|
||||
// 创建 ECharts 配置
|
||||
let option1 = {
|
||||
legend: legend,
|
||||
grid: grid,
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
|
@ -684,45 +736,79 @@ export default {
|
|||
type: 'category',
|
||||
data: [],
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
name: ''
|
||||
},
|
||||
yAxis: yAxis,
|
||||
series: [{
|
||||
name: '碳排放量(t)', // 此处修改为对应分类的名称
|
||||
name: '碳排放量(t)',
|
||||
type: 'bar',
|
||||
data: gyhourlyData, // 每小时的用水量
|
||||
data: gyhourlyData,
|
||||
yAxisIndex: 0,
|
||||
itemStyle: {
|
||||
color: '#518A3A',
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
name: '碳排放强度(t/t)',
|
||||
type: 'bar',
|
||||
data: StrengthData,
|
||||
yAxisIndex: 1,
|
||||
itemStyle: {
|
||||
color: colors[1],
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
]
|
||||
};
|
||||
option1.xAxis.data = that.xAxisData_day;
|
||||
that.optionDay = option1;
|
||||
},
|
||||
getData1(id, index) {
|
||||
getData1(index) {
|
||||
let that = this;
|
||||
that.StrengthData_month = [];
|
||||
that.gyhourlyData_month = [];
|
||||
let carbonEmission = []; // 存储每一天的碳排放量
|
||||
let outputKiln = []; // 存储每一天的出窑熟料产量
|
||||
let emissionIntensity = []; // 存储每一天的碳排放强度
|
||||
let obj = {};
|
||||
obj.type = "day";
|
||||
obj.year = that.year;
|
||||
obj.month = that.month;
|
||||
obj.mpoint = id;
|
||||
obj.mpoint__in = this.mpointList_code;
|
||||
obj.page = 0;
|
||||
|
||||
this.$API.enm.mpoint.stat.req(obj).then((res) => {
|
||||
let sum = 0;
|
||||
res.forEach((item) => {
|
||||
let ind = item.day + 2;
|
||||
that.tableDatas[index][ind] = item.val;
|
||||
sum += Number(item.val);
|
||||
let keyName = item.day + "日";
|
||||
that.tableDatas_day[index][keyName] = item.val;
|
||||
if (item.mpoint_nickname === "碳排放量") {
|
||||
carbonEmission[item.day - 1] = item.val; // 存储每日的碳排放量
|
||||
} else if (item.mpoint_nickname === "出窑熟料产量") {
|
||||
outputKiln[item.day - 1] = item.val; // 存储每日的出窑熟料产量
|
||||
}
|
||||
if(item.mpoint_nickname == "碳排放强度"){
|
||||
return;
|
||||
}
|
||||
// that.tableDatas_day[index][keyName] = item.val;
|
||||
if (item.mpoint_nickname == "碳排放量"){
|
||||
that.gyhourlyData_month[item.day - 1] = item.val;
|
||||
} else if(item.mpoint_nickname == "出窑熟料产量"){
|
||||
that.ProductionData_month[item.day - 1] = item.val;
|
||||
}
|
||||
});
|
||||
// 计算碳排放强度:碳排放量 / 出窑熟料产量
|
||||
for (let i = 0; i < carbonEmission.length; i++) {
|
||||
let keyName = i + 1 + "日";
|
||||
if(index==1 && carbonEmission[i] && outputKiln[i]){
|
||||
emissionIntensity[i] = carbonEmission[i] / outputKiln[i]; // 计算碳排放强度
|
||||
that.StrengthData_month[i] = emissionIntensity[i].toFixed(2); // 存入 StrengthData_month
|
||||
that.tableDatas_day[index][keyName] = emissionIntensity[i].toFixed(2); // 存入 tableDatas_day
|
||||
} else if(index==0 && carbonEmission[i]){
|
||||
that.tableDatas_day[index][keyName] = carbonEmission[i];
|
||||
}
|
||||
}
|
||||
sum = sum * 100;
|
||||
sum = Math.round(sum);
|
||||
sum = sum / 100;
|
||||
|
@ -733,6 +819,7 @@ export default {
|
|||
that.$forceUpdate();
|
||||
});
|
||||
},
|
||||
|
||||
dataLoop_month() {
|
||||
let that = this;
|
||||
that.tableDatas = [];
|
||||
|
@ -772,16 +859,17 @@ export default {
|
|||
: item.name;
|
||||
obj.unit = item.unit;
|
||||
that.tableDatas_month.push(obj);
|
||||
that.getData_month(item.id, index);
|
||||
that.getData_month(index);
|
||||
});
|
||||
that.updateMonthChart_month(that.gyhourlyData_year, that.shhourlyData_year, that.lvhourlyData_year);
|
||||
that.updateMonthChart_month(that.gyhourlyData_year, that.StrengthData_year);
|
||||
that.mgroupObj = mgroupObj;
|
||||
that.indexList = indexList;
|
||||
},
|
||||
updateMonthChart_month(gyhourlyData) {
|
||||
updateMonthChart_month(gyhourlyData_year, StrengthData_year) {
|
||||
let that = this;
|
||||
let option2 = {
|
||||
legend: legend,
|
||||
grid: grid,
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
|
@ -792,30 +880,42 @@ export default {
|
|||
type: 'category',
|
||||
data: [],
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
name: ''
|
||||
},
|
||||
yAxis: yAxis,
|
||||
series: [{
|
||||
name: '工业水', // 此处修改为对应分类的名称
|
||||
name: '碳排放量(t)',
|
||||
type: 'bar',
|
||||
data: gyhourlyData, // 每小时的用水量
|
||||
data: gyhourlyData_year,
|
||||
yAxisIndex: 0,
|
||||
itemStyle: {
|
||||
color: '#518A3A',
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
name: '碳排放强度(t/t)',
|
||||
type: 'bar',
|
||||
data: StrengthData_year,
|
||||
yAxisIndex: 1,
|
||||
itemStyle: {
|
||||
color: colors[1],
|
||||
},
|
||||
}
|
||||
|
||||
]
|
||||
};
|
||||
option2.xAxis.data = that.xAxisData_month;
|
||||
that.optionMonth = option2;
|
||||
},
|
||||
getData_month(id, index) {
|
||||
getData_month(index) {
|
||||
let that = this;
|
||||
that.StrengthData_year = [];
|
||||
that.gyhourlyData_year = [];
|
||||
let carbonEmission = []; // 存储每一天的碳排放量
|
||||
let outputKiln = []; // 存储每一天的出窑熟料产量
|
||||
let emissionIntensity = []; // 存储每一天的碳排放强度
|
||||
let obj = {};
|
||||
obj.type = "month";
|
||||
obj.year = that.year;
|
||||
obj.mpoint = id;
|
||||
obj.mpoint__in = that.mpointList_code;
|
||||
obj.page = 0;
|
||||
this.$API.enm.mpoint.stat.req(obj).then((res) => {
|
||||
let sum = 0;
|
||||
|
@ -824,11 +924,34 @@ export default {
|
|||
that.tableDatas[index][ind] = item.val;
|
||||
sum += Number(item.val);
|
||||
let keyName = item.month + "月";
|
||||
that.tableDatas_month[index][keyName] = item.val;
|
||||
// that.tableDatas_month[index][keyName] = item.val;
|
||||
if (item.mpoint_nickname === "碳排放量") {
|
||||
carbonEmission[item.month - 1] = item.val; // 存储每日的碳排放量
|
||||
} else if (item.mpoint_nickname === "出窑熟料产量") {
|
||||
outputKiln[item.month - 1] = item.val; // 存储每日的出窑熟料产量
|
||||
}
|
||||
if(item.mpoint_nickname == "碳排放强度"){
|
||||
return;
|
||||
}
|
||||
if (item.mpoint_nickname == "碳排放量"){
|
||||
that.gyhourlyData_year[item.month-1] = item.val;
|
||||
}else if(item.mpoint_nickname == "碳排放强度"){
|
||||
that.StrengthData_year[item.month-1] = item.val;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
// 计算碳排放强度:碳排放量 / 出窑熟料产量
|
||||
for (let i = 0; i < carbonEmission.length; i++) {
|
||||
let keyName = i + 1 + "月";
|
||||
if(index==1 && carbonEmission[i] && outputKiln[i]){
|
||||
emissionIntensity[i] = carbonEmission[i] / outputKiln[i]; // 计算碳排放强度
|
||||
that.StrengthData_year[i] = emissionIntensity[i].toFixed(2); // 存入 StrengthData_month
|
||||
that.tableDatas_month[index][keyName] = emissionIntensity[i].toFixed(2); // 存入 tableDatas_day
|
||||
} else if(index==0 && carbonEmission[i]){
|
||||
that.tableDatas_month[index][keyName] = carbonEmission[i];
|
||||
}
|
||||
}
|
||||
sum = sum * 100;
|
||||
sum = Math.round(sum);
|
||||
sum = sum / 100;
|
||||
|
@ -853,9 +976,10 @@ export default {
|
|||
handleCellClick1(row, column, cell, event) {
|
||||
let that = this;
|
||||
let index = that.tableDatas_day.indexOf(row);
|
||||
console.log('row', row)
|
||||
that.tableName = `${row.nickname}-电量日统计`
|
||||
let lineData = that.tableDatas[index].slice(3, that.days + 3);
|
||||
console.log("row", row, that.tableDatas_day, index);
|
||||
that.tableName = `${row.nickname}`
|
||||
console.log("tableDatas", that.tableDatas);
|
||||
let lineData = that.tableDatas_day[index].slice(2, 13);
|
||||
that.option.xAxis.data = that.xAxisData_day;
|
||||
that.option.series[0].data = lineData;
|
||||
this.itemVisible = true;
|
||||
|
@ -863,7 +987,7 @@ export default {
|
|||
handleCellClick_month(row, column, cell, event) {
|
||||
let that = this;
|
||||
let index = that.tableDatas_month.indexOf(row);
|
||||
that.tableName = `${row.nickname}-电量日统计`
|
||||
that.tableName = `${row.nickname}`
|
||||
//获取图数据
|
||||
let lineData = that.tableDatas[index].slice(2, 13);
|
||||
that.option.xAxis.data = that.xAxisData_month;
|
||||
|
|
|
@ -338,6 +338,7 @@
|
|||
</template>
|
||||
<script>
|
||||
const colors = ["#5b9bd5", "#ed7d31", "#70ad47", "#ffc000", "#5f6694", "#cb9bff", "#7DDA58"];
|
||||
const colors_hour = ["#5b9bd5", "#ffc000", "#5f6694", "#cb9bff", "#7DDA58"];
|
||||
// 产量/台时/运转率/分布电耗/单位产品标煤耗/成本
|
||||
let tooltip = {
|
||||
show: true,
|
||||
|
@ -723,7 +724,7 @@ export default {
|
|||
{id:2,name:'年统计'}
|
||||
],
|
||||
option1: {
|
||||
color: colors,
|
||||
color: colors_hour,
|
||||
tooltip: tooltip,
|
||||
grid: grid,
|
||||
toolbox: toolbox,
|
||||
|
|
|
@ -290,7 +290,8 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
const colors = ["#5b9bd5", "#cbd3fe", "#91CC75", "#EE6666", "#CC00CC", "#7DDA58", "#BCB69D"];
|
||||
const colors = ["#5b9bd5", "#cbd3fe", "#B79C2C", "#EE6666", "#CC00CC", "#7DDA58", "#BCB69D","#0AF2FA", "#48D311"];
|
||||
const colors1 = ["#5b9bd5", "#cbd3fe", "#B79C2C", "#EE6666", "#CC00CC", "#726691", "#48D311"];
|
||||
let tooltip = {
|
||||
show: true,
|
||||
trigger: "axis",
|
||||
|
@ -337,7 +338,7 @@ let yAxis = [
|
|||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: colors[0],
|
||||
color: colors[7],
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
|
@ -353,7 +354,7 @@ let yAxis = [
|
|||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: colors[1],
|
||||
color: colors[8],
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
|
@ -478,12 +479,18 @@ export default {
|
|||
yAxisIndex: 0,
|
||||
data: [],
|
||||
},
|
||||
{
|
||||
name: "分布电耗",
|
||||
type: "bar",
|
||||
yAxisIndex: 1,
|
||||
data: [],
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
},
|
||||
option2: {
|
||||
color: colors,
|
||||
color: colors1,
|
||||
tooltip: tooltip,
|
||||
legend: Object.assign(legend, {data:["袋装合计", "散装合计", "熟料出厂合计", "出厂水泥合计", "复合水泥合计", "分布电耗目标值","分布电耗"]}),
|
||||
grid: grid,
|
||||
|
@ -550,7 +557,7 @@ export default {
|
|||
{
|
||||
name: "分布电耗",
|
||||
type: "bar",
|
||||
yAxisIndex: 0,
|
||||
yAxisIndex: 1,
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
|
@ -878,7 +885,8 @@ export default {
|
|||
seriesData2 = [],
|
||||
seriesData3 = [],
|
||||
seriesData4 = [],
|
||||
seriesData5 = [];
|
||||
seriesData5 = [],
|
||||
seriesData6 = [];
|
||||
let data = response;
|
||||
data.forEach((item) => {
|
||||
let ind = item.day_s - 1;
|
||||
|
@ -892,6 +900,8 @@ export default {
|
|||
seriesData4[ind] = item.val;
|
||||
}else if (item.mpoint_name == "复合水泥合计" || item.mpoint_name == "复合硅酸盐水泥;42.5R;袋装水泥") {
|
||||
seriesData5[ind] = item.val;
|
||||
}else if(item.mpoint_name == "包装进线"){
|
||||
seriesData6[ind] = item.elec_consume_unit;
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -901,6 +911,7 @@ export default {
|
|||
options.series[2].data = seriesData3;
|
||||
options.series[3].data = seriesData4;
|
||||
options.series[4].data = seriesData5;
|
||||
options.series[5].data = seriesData6;
|
||||
let dayXAxis = [];
|
||||
for (let i = 1; i <= that.days; i++) {
|
||||
let item = i + "日";
|
||||
|
|
|
@ -70,16 +70,6 @@
|
|||
</el-header>
|
||||
<el-card style="margin-top:5px">
|
||||
<div class="tableContainer">
|
||||
<!-- <div>
|
||||
<label for="threshold">输入合格率阈值:</label>
|
||||
<input
|
||||
type="text"
|
||||
id="threshold"
|
||||
v-model="currentThreshold"
|
||||
placeholder="例如:80%"
|
||||
@input="updateThreshold"
|
||||
/>
|
||||
</div> -->
|
||||
<table border="1" cellspacing="0" :key="timeStamp" id="myTable" class="myTable">
|
||||
<thead class="myTableHead">
|
||||
<tr>
|
||||
|
@ -128,6 +118,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
@ -144,8 +135,7 @@
|
|||
],
|
||||
titleLength:1,
|
||||
mgroupOptions:[],
|
||||
threshold: 80, // 数值类型的阈值
|
||||
currentThreshold: "80%", // 当前编辑的阈值
|
||||
currentThreshold: null, // 当前编辑的阈值
|
||||
tableTime:'',
|
||||
deptName:'',
|
||||
typeName:'质检日报表',
|
||||
|
@ -183,6 +173,12 @@
|
|||
dialogVisible: false, // 控制对话框显示
|
||||
currentColumnIndex: null, // 当前编辑的列索引
|
||||
thresholds: {}, // 存储每列的阈值,key 为列索引
|
||||
thresholdobj:{},
|
||||
materialTestItemMap:{},
|
||||
currentMaterialNameClass: '',
|
||||
currentMaterialName: '', // 当前物料名称
|
||||
currentTestItemName: '', // 当前检测项名称
|
||||
currentTestItemNameClass: '', // 当前检测项名称
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
|
@ -217,11 +213,30 @@
|
|||
that.tableName = that.deptName+that.typeName;
|
||||
},
|
||||
updateThreshold() {
|
||||
const num = parseFloat(this.currentThreshold.replace("%", ""));
|
||||
const num = parseFloat(this.currentThreshold);
|
||||
if (!isNaN(num)){
|
||||
// 保存阈值
|
||||
this.thresholds[this.currentColumnIndex] = num;
|
||||
const key = `${this.currentMaterialName}-${this.currentTestItemName}`;
|
||||
console.log("---------------key", key, this.materialTestItemMap)
|
||||
const mapEntry = this.materialTestItemMap[key];
|
||||
if (!mapEntry) {
|
||||
return;
|
||||
}
|
||||
const payload = {
|
||||
material_id: mapEntry.material_id,
|
||||
testitem_id: mapEntry.testitem_id,
|
||||
rate_pass_t: num,
|
||||
update_start_time: mapEntry.update_start_time,
|
||||
update_end_time: mapEntry.update_end_time,
|
||||
};
|
||||
this.$API.qm.updateQuastatGoal.post(payload)
|
||||
.then((res) => {
|
||||
this.$message.success("阈值更新成功");
|
||||
this.thresholds[this.currentColumnIndex] = res.rate_pass_t; // 更新本地阈值
|
||||
this.dialogVisible = false; // 关闭对话框
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$message.error("阈值更新失败:" + error.message);
|
||||
});
|
||||
}else {
|
||||
this.$message.error("请输入有效的阈值,例如:80%");
|
||||
}
|
||||
|
@ -233,13 +248,36 @@
|
|||
},
|
||||
// 动态样式计算
|
||||
getCellClass(cell, cellIndex) {
|
||||
if (cellIndex > 0 && ((cellIndex - 1) % 4 === 3)) {
|
||||
let that = this;
|
||||
if (typeof cell === 'string' && cell.includes('%')) {
|
||||
// 假设合格率在每组数据的第四列
|
||||
const cellValue = String(cell);
|
||||
const value = parseFloat(cellValue.replace("%", ""));
|
||||
const threshold = this.thresholds[cellIndex] || 0; // 获取对应列的阈值
|
||||
if (!isNaN(value)) {
|
||||
return value > threshold ? "green-text" : "red-text";
|
||||
this.currentColumnIndex = cellIndex;
|
||||
const header4Index = cellIndex - 1; // 假设第 0 列是日期列
|
||||
const header3Index = Math.floor(header4Index / 4);
|
||||
let cumulativeLength = 0;
|
||||
let header2Index = -1;
|
||||
for (let i = 0; i < this.header2Obj.length; i++) {
|
||||
cumulativeLength += this.header2Obj[i].lengths * 4;
|
||||
if (header4Index < cumulativeLength) {
|
||||
header2Index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (header2Index !== -1 && header3Index !== -1){
|
||||
that.currentMaterialNameClass = this.header2Obj[header2Index].name; // header2Obj
|
||||
that.currentTestItemNameClass = this.header3[header3Index]; // header3
|
||||
}else {
|
||||
this.currentMaterialNameClass = '';
|
||||
this.currentTestItemNameClass = '';
|
||||
}
|
||||
const keyName = `${that.currentMaterialNameClass}-${that.currentTestItemNameClass}`;
|
||||
const rate_g = that.thresholdobj[keyName] || 0;
|
||||
if (rate_g >= value) {
|
||||
return 'red-text';
|
||||
} else {
|
||||
return 'green-text';
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
@ -264,16 +302,38 @@
|
|||
});
|
||||
},
|
||||
handleCellClick(cell, rowIndex, cellIndex){
|
||||
if ((cellIndex - 1) % 4 === 3) { //合格率列
|
||||
this.currentColumnIndex = cellIndex; // 记录列索引
|
||||
this.currentThreshold = this.thresholds[cellIndex] || ""; // 获取当前阈值
|
||||
this.dialogVisible = true; // 显示对话框
|
||||
let that = this;
|
||||
this.currentColumnIndex = cellIndex;
|
||||
const header4Index = cellIndex - 1 ; // 假设第 0 列是日期列
|
||||
const header3Index = Math.floor(header4Index / 4) ;
|
||||
let cumulativeLength = 0;
|
||||
let header2Index = -1;
|
||||
// 根据每个物料有多少个检测项,计算检测项目开始结束索引是否在当前列中
|
||||
for (let i = 0; i < this.header2Obj.length; i++) {
|
||||
cumulativeLength += this.header2Obj[i].lengths * 4;
|
||||
if (header4Index < cumulativeLength) {
|
||||
header2Index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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(){
|
||||
let that = this;
|
||||
that.tableDatas3 = [];
|
||||
|
||||
that.materialTestItemMap = {};
|
||||
that.header3 = [];
|
||||
if(that.deptName=='原料车间'){
|
||||
that.header2Obj=[{name:'辅料',lengths:3},{name:'干混生料',lengths:4}];
|
||||
|
@ -307,10 +367,30 @@
|
|||
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}`;
|
||||
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){//日统计
|
||||
ind = item.day_s-1;
|
||||
}else if(that.query.type==1){//月统计
|
||||
|
@ -321,12 +401,15 @@
|
|||
wrapArr[ind] = [];
|
||||
}
|
||||
if(that.deptName=='原料车间'){
|
||||
wrapArr[ind].push(item)
|
||||
|
||||
if (item.mgroup_name=='生料工序(二次配料)'){
|
||||
wrapArr[ind][0]=item
|
||||
}else if(item.mgroup_name=='原料磨'){
|
||||
wrapArr[ind][1]=item
|
||||
}
|
||||
}else if(that.deptName=='烧成车间'){
|
||||
if(item.mgroup_name=='回转窑'){
|
||||
wrapArr[ind][1]=item
|
||||
}else{
|
||||
}else if(item.mgroup_name=='煤磨'){
|
||||
wrapArr[ind][0]=item
|
||||
}
|
||||
}else{
|
||||
|
@ -339,12 +422,15 @@
|
|||
wrapArr.forEach((item1,index1)=>{
|
||||
if(item1!=undefined){//一天的数据
|
||||
let itemArr = [];
|
||||
// 物料名称_检测项为唯一标识
|
||||
let header2tem=[],header2Objtem=[],header3tem=[],header4tem=[];
|
||||
let time =item1[0].day_s!=null? item1[0].year_s+'.'+item1[0].month_s+'.'+item1[0].day_s:item1[0].year_s+'.'+item1[0].month_s;
|
||||
itemArr.push(time)
|
||||
//遍历每个工段
|
||||
item1.forEach(item2=>{
|
||||
|
||||
let data2 =item2.qua_data;
|
||||
// console.log("-----data2-----", data2)
|
||||
//遍历一个工段的物料检验数据
|
||||
data2.forEach((item3,index3)=>{
|
||||
//item3一个检验数据
|
||||
|
@ -356,6 +442,7 @@
|
|||
header2Objtem.push({name:item3.material_name,lengths:1})
|
||||
}
|
||||
header3tem.push(item3.testitem_name)
|
||||
|
||||
header4tem.push('平均值')
|
||||
header4tem.push('检次')
|
||||
header4tem.push('合次')
|
||||
|
@ -369,7 +456,6 @@
|
|||
}else{
|
||||
itemArr[ind] = 0;
|
||||
}
|
||||
// itemArr[ind] = (item3.val_avg).toFixed(2);
|
||||
itemArr.push(item3.num_test)
|
||||
itemArr.push(item3.num_ok)
|
||||
let pass = 0;
|
||||
|
@ -380,8 +466,9 @@
|
|||
pass = Number(item3.rate_pass).toFixed(2) + '%';
|
||||
itemArr.push(pass)
|
||||
}
|
||||
|
||||
// pass= pass+'%';
|
||||
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));
|
||||
|
@ -389,6 +476,9 @@
|
|||
itemArr.push(item3.num_ok)
|
||||
let pass = Number(item3.rate_pass).toFixed(2);
|
||||
pass= pass+'%';
|
||||
if(!that.thresholdobj[item3.material_name+"-"+item3.testitem_name]){
|
||||
that.thresholdobj[item3.material_name+"-"+item3.testitem_name] = item3.rate_g;
|
||||
}
|
||||
itemArr.push(pass)
|
||||
}
|
||||
that.titleLength =itemArr.length;
|
||||
|
|
|
@ -691,7 +691,6 @@ export default {
|
|||
|
||||
let form = this.$TOOL.data.get("sflogItem");
|
||||
this.form = JSON.parse(form);
|
||||
console.log('----------------',this.form);
|
||||
this.querystlog.mgroup = this.mgroupId;
|
||||
this.querystlog.sflogs = this.form.id;
|
||||
this.apiObjStlog = this.$API.wpm.stlog.list;
|
||||
|
@ -903,7 +902,6 @@ export default {
|
|||
},
|
||||
//点击stlog,展示sflogexp
|
||||
stlogRowClick(row) {
|
||||
console.log(row);
|
||||
this.clickItem = row;
|
||||
this.getSflogexp(row.id);
|
||||
},
|
||||
|
|
|
@ -1164,7 +1164,7 @@ export default {
|
|||
);
|
||||
that.tableDatas[6][5] =
|
||||
data1.production_cost_unit;
|
||||
that.tableDatas[6][9] = precen(
|
||||
that.tableDatas[6][9] = consume_precen(
|
||||
(that.tableDatas[6][8] - that.tableDatas[6][5]),
|
||||
that.tableDatas[6][8]
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue