feat: 修改质量报表

This commit is contained in:
zty 2025-01-23 14:24:02 +08:00
parent ae3e6aa1ec
commit 56334fc718
8 changed files with 405 additions and 173 deletions

View File

@ -34,6 +34,7 @@
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"json-editor-vue3": "^1.0.6", "json-editor-vue3": "^1.0.6",
"jspdf": "^2.5.1", "jspdf": "^2.5.1",
"moment": "^2.30.1",
"node-polyfill-webpack-plugin": "^4.0.0", "node-polyfill-webpack-plugin": "^4.0.0",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"print-js": "^1.6.0", "print-js": "^1.6.0",

View File

@ -26,6 +26,13 @@ export default {
return await http.post(this.url, data); 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: { getTestItem: {
url: `${config.API_URL}/qm/testitem/`, url: `${config.API_URL}/qm/testitem/`,

View File

@ -101,13 +101,13 @@
width="120" width="120"
> >
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
label="合计" label="合计"
prop="sum" prop="sum"
width="130" width="130"
fixed="right" fixed="right"
> >
</el-table-column> </el-table-column> -->
</el-table> </el-table>
<el-table <el-table
v-if="query.type==1" v-if="query.type==1"
@ -116,7 +116,7 @@
style="width: 100%" style="width: 100%"
border border
:height="tableHeight" :height="tableHeight"
@cell-click="handleCellClick1"
> >
<el-table-column <el-table-column
label="分类" label="分类"
@ -135,13 +135,13 @@
width="120" width="120"
> >
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
label="合计" label="合计"
prop="sum" prop="sum"
width="130" width="130"
fixed="right" fixed="right"
> >
</el-table-column> </el-table-column> -->
</el-table> </el-table>
<el-table <el-table
v-if="query.type==2" v-if="query.type==2"
@ -150,7 +150,7 @@
style="width: 100%" style="width: 100%"
border border
:height="tableHeight" :height="tableHeight"
@cell-click="handleCellClick_month"
> >
<el-table-column <el-table-column
label="分类" label="分类"
@ -169,13 +169,13 @@
width="120" width="120"
> >
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
label="合计" label="合计"
prop="sum" prop="sum"
width="130" width="130"
fixed="right" fixed="right"
> >
</el-table-column> </el-table-column> -->
</el-table> </el-table>
<el-table <el-table
v-if="query.type==3" v-if="query.type==3"
@ -184,7 +184,7 @@
style="width: 100%" style="width: 100%"
border border
:height="tableHeight" :height="tableHeight"
@cell-click="handleCellClick_range"
> >
<el-table-column <el-table-column
label="分类" label="分类"
@ -242,9 +242,49 @@
<script> <script>
let legend = { let legend = {
top: "2%", 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"; import scEcharts from "@/components/scEcharts";
export default { export default {
components: { components: {
@ -278,7 +318,6 @@ export default {
{id:0,name:'日统计'}, {id:0,name:'日统计'},
{id:1,name:'月统计'}, {id:1,name:'月统计'},
{id:2,name:'年统计'}, {id:2,name:'年统计'},
{id:3,name:'时间段'},
], ],
tableDatas2: [], tableDatas2: [],
tableDatas_day:[], tableDatas_day:[],
@ -389,13 +428,14 @@ export default {
xAxisData_month: [], xAxisData_month: [],
xTtimeRange: [], xTtimeRange: [],
gyhourlyData : [], gyhourlyData : [],
lvhourlyData : [], mpointList_code:"3750125939653558272,3759456603624382464,3636975194725527552",
StrengthData : [],
shhourlyData : [], // shhourlyData : [], //
gyhourlyData_month : [], gyhourlyData_month : [],
lvhourlyData_month : [], StrengthData_month : [],
shhourlyData_month : [], // ProductionData_month : [], //
gyhourlyData_year : [], gyhourlyData_year : [],
lvhourlyData_year : [], StrengthData_year : [],
shhourlyData_year : [], // shhourlyData_year : [], //
}; };
}, },
@ -450,10 +490,10 @@ export default {
}, },
changeDate(){ changeDate(){
let obj = {}; let obj = {};
obj.type = "day"; obj.type = "hour";
obj.start_time = this.daterange[0]; obj.start_time = this.daterange[0];
obj.end_time = this.daterange[1]; obj.end_time = this.daterange[1];
obj.mpoint__in = "3750125939653558272"; obj.mpoint__in = '3750125939653558272,3759456603624382464';
obj.page = 0; obj.page = 0;
this.$API.enm.mpointstat.groupValues.req(obj).then((res) => { this.$API.enm.mpointstat.groupValues.req(obj).then((res) => {
//res total_val //res total_val
@ -501,7 +541,7 @@ export default {
// enabled: 1, // enabled: 1,
// need_display: 1, // need_display: 1,
ordering: "report_sortstr", ordering: "report_sortstr",
code__in: "tpfl", code__in: "tanpfqd, tpfl",
query: "{ id, name, nickname, mgroup_name, unit, report_sortstr }", query: "{ id, name, nickname, mgroup_name, unit, report_sortstr }",
}) })
.then((res) => { .then((res) => {
@ -518,6 +558,7 @@ export default {
_nameLength = [], _nameLength = [],
indexList = []; indexList = [];
let mgroupObj = {}; let mgroupObj = {};
console.log(that.mpointList);
that.mpointList.forEach((item, index) => { that.mpointList.forEach((item, index) => {
let indexs = _mgroup.indexOf(item.mgroup_name); let indexs = _mgroup.indexOf(item.mgroup_name);
if (indexs > -1) { if (indexs > -1) {
@ -551,12 +592,14 @@ export default {
that.tableDatas2.push(obj); that.tableDatas2.push(obj);
that.getData(item.id, index); that.getData(item.id, index);
}); });
that.updateChart(that.gyhourlyData, that.shhourlyData, that.lvhourlyData); that.updateChart(that.gyhourlyData, that.StrengthData);
that.mgroupObj = mgroupObj; that.mgroupObj = mgroupObj;
that.indexList = indexList; that.indexList = indexList;
}, },
getData(id, index) { getData(id, index) {
let that = this; let that = this;
that.StrengthData = [];
that.gyhourlyData = [];
let obj = {}; let obj = {};
obj.type = "hour"; obj.type = "hour";
obj.year = that.year; obj.year = that.year;
@ -574,6 +617,10 @@ export default {
that.tableDatas2[index][keyName] = item.val; that.tableDatas2[index][keyName] = item.val;
if (item.mpoint_nickname == "碳排放量"){ if (item.mpoint_nickname == "碳排放量"){
that.gyhourlyData[item.hour] = item.val; that.gyhourlyData[item.hour] = item.val;
}else if(
item.mpoint_nickname == "碳排放强度"
){
that.StrengthData[item.hour] = item.val;
} }
}); });
sum = sum * 100; sum = sum * 100;
@ -585,11 +632,12 @@ export default {
that.$forceUpdate(); that.$forceUpdate();
}); });
}, },
updateChart(gyhourlyData, shhourlyData, lvhourlyData) { updateChart(gyhourlyData, StrengthData) {
let that = this; let that = this;
// ECharts // ECharts
let option = { let option = {
legend: legend, legend: legend,
grid: grid,
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
@ -600,80 +648,84 @@ export default {
type: 'category', 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时'], 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: { yAxis: yAxis,
type: 'value',
name: ''
},
series: [{ series: [{
name: '碳排放量(t)', // name: '碳排放量(t)', //
type: 'bar', type: 'bar',
data: gyhourlyData, // data: gyhourlyData,
yAxisIndex: 0,
itemStyle: { itemStyle: {
color: '#518A3A', color: '#518A3A',
}, },
}, },
{
name: '碳排放强度(t/t)',
type: 'bar',
data: StrengthData,
yAxisIndex: 1,
itemStyle: {
color: colors[1],
},
},
] ]
}; };
that.optionHour = option; that.optionHour = option;
}, },
dataLoop1() { dataLoop1() {
let that = this; let that = this;
that.tableDatas = []; that.tableDatas = [];
that.tableDatas_day = []; that.tableDatas_day = [];
let _mgroup = [], let _mgroup = [], _nameLength = [], indexList = [];
_nameLength = [], let mgroupObj = {};
indexList = []; that.mpointList.forEach((item, index) => {
let mgroupObj = {}; let indexs = _mgroup.indexOf(item.mgroup_name);
that.mpointList.forEach((item, index) => { if (indexs > -1) {
let indexs = _mgroup.indexOf(item.mgroup_name); _nameLength[indexs] += 1;
if (indexs > -1) { } else {
_nameLength[indexs] += 1; _mgroup.push(item.mgroup_name);
} else { _nameLength.push(1);
_mgroup.push(item.mgroup_name); indexList.push(index);
_nameLength.push(1); }
indexList.push(index);
}
for (let i = 0; i < _mgroup.length; i++) { for (let i = 0; i < _mgroup.length; i++) {
mgroupObj[_mgroup[i]] = _nameLength[i]; mgroupObj[_mgroup[i]] = _nameLength[i];
} }
let arr = [];
arr[0] = let arr = [];
item.mgroup_name != null arr[0] = item.mgroup_name != null ? item.mgroup_name : item.nickname != null ? item.nickname : item.name;
? item.mgroup_name arr[1] = item.nickname != null ? item.nickname : item.name;
: item.nickname != null arr[2] = item.unit;
? item.nickname for (let i = 0; i < that.days; i++) {
: item.name; arr[i + 2] = 0;
arr[1] = item.nickname != null ? item.nickname : item.name; }
arr[2] = item.unit;
for (let i = 0; i < that.days; i++) { that.tableDatas.push(arr);
arr[i + 2] = 0; let obj = {};
} obj.mgroupName = item.mgroup_name != null ? item.mgroup_name : item.name;
that.tableDatas.push(arr); obj.nickname = item.nickname != null && item.nickname != "" ? item.nickname : item.name;
let obj = {}; obj.unit = item.unit;
obj.mgroupName =
item.mgroup_name != null ? item.mgroup_name : item.name; that.tableDatas_day.push(obj);
obj.nickname =
item.nickname != null && item.nickname != "" // getData1(index)
? item.nickname that.getData1(index);
: item.name; });
obj.unit = item.unit;
that.updateMonthChart(that.gyhourlyData_month, that.StrengthData_month, that.ProductionData_month);
that.mgroupObj = mgroupObj;
that.indexList = indexList;
},
that.tableDatas_day.push(obj);
that.getData1(item.id, index);
});
that.updateMonthChart(that.gyhourlyData_month);
that.mgroupObj = mgroupObj;
that.indexList = indexList;
},
updateMonthChart(gyhourlyData) { updateMonthChart(gyhourlyData, StrengthData, ) {
let that = this; let that = this;
// ECharts // ECharts
let option1 = { let option1 = {
legend: legend, legend: legend,
grid: grid,
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
@ -684,55 +736,90 @@ export default {
type: 'category', type: 'category',
data: [], data: [],
}, },
yAxis: { yAxis: yAxis,
type: 'value',
name: ''
},
series: [{ series: [{
name: '碳排放量(t)', // name: '碳排放量(t)',
type: 'bar', type: 'bar',
data: gyhourlyData, // data: gyhourlyData,
yAxisIndex: 0,
itemStyle: { itemStyle: {
color: '#518A3A', color: '#518A3A',
}, },
}, },
{
name: '碳排放强度(t/t)',
type: 'bar',
data: StrengthData,
yAxisIndex: 1,
itemStyle: {
color: colors[1],
},
},
] ]
}; };
option1.xAxis.data = that.xAxisData_day; option1.xAxis.data = that.xAxisData_day;
that.optionDay = option1; that.optionDay = option1;
}, },
getData1(id, index) { getData1(index) {
let that = this; let that = this;
let obj = {}; that.StrengthData_month = [];
obj.type = "day"; that.gyhourlyData_month = [];
obj.year = that.year; let carbonEmission = []; //
obj.month = that.month; let outputKiln = []; //
obj.mpoint = id; let emissionIntensity = []; //
obj.page = 0; let obj = {};
this.$API.enm.mpoint.stat.req(obj).then((res) => { obj.type = "day";
let sum = 0; obj.year = that.year;
res.forEach((item) => { obj.month = that.month;
let ind = item.day+2; obj.mpoint__in = this.mpointList_code;
that.tableDatas[index][ind] = item.val; obj.page = 0;
sum += Number(item.val);
let keyName = item.day + "日"; this.$API.enm.mpoint.stat.req(obj).then((res) => {
that.tableDatas_day[index][keyName] = item.val; let sum = 0;
if (item.mpoint_nickname == "碳排放量"){ res.forEach((item) => {
that.gyhourlyData_month[item.day-1] = item.val; let ind = item.day + 2;
} that.tableDatas[index][ind] = item.val;
}); sum += Number(item.val);
sum = sum * 100; if (item.mpoint_nickname === "碳排放量") {
sum = Math.round(sum); carbonEmission[item.day - 1] = item.val; //
sum = sum / 100; } else if (item.mpoint_nickname === "出窑熟料产量") {
let dayss = 0; outputKiln[item.day - 1] = item.val; //
dayss = this.days + 3; }
that.tableDatas[index][dayss] = sum.toFixed(2); if(item.mpoint_nickname == "碳排放强度"){
that.tableDatas_day[index].sum = sum.toFixed(2); return;
that.$forceUpdate(); }
}); // 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;
let dayss = 0;
dayss = this.days + 3;
that.tableDatas[index][dayss] = sum.toFixed(2);
that.tableDatas_day[index].sum = sum.toFixed(2);
that.$forceUpdate();
});
},
dataLoop_month() { dataLoop_month() {
let that = this; let that = this;
that.tableDatas = []; that.tableDatas = [];
@ -772,16 +859,17 @@ export default {
: item.name; : item.name;
obj.unit = item.unit; obj.unit = item.unit;
that.tableDatas_month.push(obj); 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.mgroupObj = mgroupObj;
that.indexList = indexList; that.indexList = indexList;
}, },
updateMonthChart_month(gyhourlyData) { updateMonthChart_month(gyhourlyData_year, StrengthData_year) {
let that = this; let that = this;
let option2 = { let option2 = {
legend: legend, legend: legend,
grid: grid,
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
@ -792,30 +880,42 @@ export default {
type: 'category', type: 'category',
data: [], data: [],
}, },
yAxis: { yAxis: yAxis,
type: 'value',
name: ''
},
series: [{ series: [{
name: '工业水', // name: '碳排放量(t)',
type: 'bar', type: 'bar',
data: gyhourlyData, // data: gyhourlyData_year,
yAxisIndex: 0,
itemStyle: { itemStyle: {
color: '#518A3A', color: '#518A3A',
}, },
},
{
name: '碳排放强度(t/t)',
type: 'bar',
data: StrengthData_year,
yAxisIndex: 1,
itemStyle: {
color: colors[1],
},
} }
] ]
}; };
option2.xAxis.data = that.xAxisData_month; option2.xAxis.data = that.xAxisData_month;
that.optionMonth = option2; that.optionMonth = option2;
}, },
getData_month(id, index) { getData_month(index) {
let that = this; let that = this;
that.StrengthData_year = [];
that.gyhourlyData_year = [];
let carbonEmission = []; //
let outputKiln = []; //
let emissionIntensity = []; //
let obj = {}; let obj = {};
obj.type = "month"; obj.type = "month";
obj.year = that.year; obj.year = that.year;
obj.mpoint = id; obj.mpoint__in = that.mpointList_code;
obj.page = 0; obj.page = 0;
this.$API.enm.mpoint.stat.req(obj).then((res) => { this.$API.enm.mpoint.stat.req(obj).then((res) => {
let sum = 0; let sum = 0;
@ -824,11 +924,34 @@ export default {
that.tableDatas[index][ind] = item.val; that.tableDatas[index][ind] = item.val;
sum += Number(item.val); sum += Number(item.val);
let keyName = item.month + "月"; 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 == "碳排放量"){ if (item.mpoint_nickname == "碳排放量"){
that.gyhourlyData_year[item.month-1] = item.val; 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 = sum * 100;
sum = Math.round(sum); sum = Math.round(sum);
sum = sum / 100; sum = sum / 100;
@ -853,9 +976,10 @@ export default {
handleCellClick1(row, column, cell, event) { handleCellClick1(row, column, cell, event) {
let that = this; let that = this;
let index = that.tableDatas_day.indexOf(row); let index = that.tableDatas_day.indexOf(row);
console.log('row', row) console.log("row", row, that.tableDatas_day, index);
that.tableName = `${row.nickname}-电量日统计` that.tableName = `${row.nickname}`
let lineData = that.tableDatas[index].slice(3, that.days + 3); console.log("tableDatas", that.tableDatas);
let lineData = that.tableDatas_day[index].slice(2, 13);
that.option.xAxis.data = that.xAxisData_day; that.option.xAxis.data = that.xAxisData_day;
that.option.series[0].data = lineData; that.option.series[0].data = lineData;
this.itemVisible = true; this.itemVisible = true;
@ -863,7 +987,7 @@ export default {
handleCellClick_month(row, column, cell, event) { handleCellClick_month(row, column, cell, event) {
let that = this; let that = this;
let index = that.tableDatas_month.indexOf(row); let index = that.tableDatas_month.indexOf(row);
that.tableName = `${row.nickname}-电量日统计` that.tableName = `${row.nickname}`
// //
let lineData = that.tableDatas[index].slice(2, 13); let lineData = that.tableDatas[index].slice(2, 13);
that.option.xAxis.data = that.xAxisData_month; that.option.xAxis.data = that.xAxisData_month;

View File

@ -338,6 +338,7 @@
</template> </template>
<script> <script>
const colors = ["#5b9bd5", "#ed7d31", "#70ad47", "#ffc000", "#5f6694", "#cb9bff", "#7DDA58"]; const colors = ["#5b9bd5", "#ed7d31", "#70ad47", "#ffc000", "#5f6694", "#cb9bff", "#7DDA58"];
const colors_hour = ["#5b9bd5", "#ffc000", "#5f6694", "#cb9bff", "#7DDA58"];
// ///// // /////
let tooltip = { let tooltip = {
show: true, show: true,
@ -723,7 +724,7 @@ export default {
{id:2,name:'年统计'} {id:2,name:'年统计'}
], ],
option1: { option1: {
color: colors, color: colors_hour,
tooltip: tooltip, tooltip: tooltip,
grid: grid, grid: grid,
toolbox: toolbox, toolbox: toolbox,

View File

@ -290,7 +290,8 @@
</div> </div>
</template> </template>
<script> <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 = { let tooltip = {
show: true, show: true,
trigger: "axis", trigger: "axis",
@ -337,7 +338,7 @@ let yAxis = [
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: colors[0], color: colors[7],
}, },
}, },
axisLabel: { axisLabel: {
@ -353,7 +354,7 @@ let yAxis = [
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: colors[1], color: colors[8],
}, },
}, },
axisLabel: { axisLabel: {
@ -478,12 +479,18 @@ export default {
yAxisIndex: 0, yAxisIndex: 0,
data: [], data: [],
}, },
{
name: "分布电耗",
type: "bar",
yAxisIndex: 1,
data: [],
},
], ],
}, },
option2: { option2: {
color: colors, color: colors1,
tooltip: tooltip, tooltip: tooltip,
legend: Object.assign(legend, {data:["袋装合计", "散装合计", "熟料出厂合计", "出厂水泥合计", "复合水泥合计", "分布电耗目标值","分布电耗"]}), legend: Object.assign(legend, {data:["袋装合计", "散装合计", "熟料出厂合计", "出厂水泥合计", "复合水泥合计", "分布电耗目标值","分布电耗"]}),
grid: grid, grid: grid,
@ -550,7 +557,7 @@ export default {
{ {
name: "分布电耗", name: "分布电耗",
type: "bar", type: "bar",
yAxisIndex: 0, yAxisIndex: 1,
data: [], data: [],
}, },
], ],
@ -878,7 +885,8 @@ export default {
seriesData2 = [], seriesData2 = [],
seriesData3 = [], seriesData3 = [],
seriesData4 = [], seriesData4 = [],
seriesData5 = []; seriesData5 = [],
seriesData6 = [];
let data = response; let data = response;
data.forEach((item) => { data.forEach((item) => {
let ind = item.day_s - 1; let ind = item.day_s - 1;
@ -892,6 +900,8 @@ export default {
seriesData4[ind] = item.val; seriesData4[ind] = item.val;
}else if (item.mpoint_name == "复合水泥合计" || item.mpoint_name == "复合硅酸盐水泥;42.5R;袋装水泥") { }else if (item.mpoint_name == "复合水泥合计" || item.mpoint_name == "复合硅酸盐水泥;42.5R;袋装水泥") {
seriesData5[ind] = item.val; 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[2].data = seriesData3;
options.series[3].data = seriesData4; options.series[3].data = seriesData4;
options.series[4].data = seriesData5; options.series[4].data = seriesData5;
options.series[5].data = seriesData6;
let dayXAxis = []; let dayXAxis = [];
for (let i = 1; i <= that.days; i++) { for (let i = 1; i <= that.days; i++) {
let item = i + "日"; let item = i + "日";

View File

@ -70,16 +70,6 @@
</el-header> </el-header>
<el-card style="margin-top:5px"> <el-card style="margin-top:5px">
<div class="tableContainer"> <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"> <table border="1" cellspacing="0" :key="timeStamp" id="myTable" class="myTable">
<thead class="myTableHead"> <thead class="myTableHead">
<tr> <tr>
@ -128,6 +118,7 @@
</div> </div>
</template> </template>
<script> <script>
import moment from 'moment';
export default { export default {
data() { data() {
return { return {
@ -144,8 +135,7 @@
], ],
titleLength:1, titleLength:1,
mgroupOptions:[], mgroupOptions:[],
threshold: 80, // currentThreshold: null, //
currentThreshold: "80%", //
tableTime:'', tableTime:'',
deptName:'', deptName:'',
typeName:'质检日报表', typeName:'质检日报表',
@ -183,6 +173,12 @@
dialogVisible: false, // dialogVisible: false, //
currentColumnIndex: null, // currentColumnIndex: null, //
thresholds: {}, // key thresholds: {}, // key
thresholdobj:{},
materialTestItemMap:{},
currentMaterialNameClass: '',
currentMaterialName: '', //
currentTestItemName: '', //
currentTestItemNameClass: '', //
}; };
}, },
watch: { watch: {
@ -217,14 +213,33 @@
that.tableName = that.deptName+that.typeName; that.tableName = that.deptName+that.typeName;
}, },
updateThreshold() { updateThreshold() {
const num = parseFloat(this.currentThreshold.replace("%", "")); const num = parseFloat(this.currentThreshold);
if (!isNaN(num)) { if (!isNaN(num)){
// const key = `${this.currentMaterialName}-${this.currentTestItemName}`;
this.thresholds[this.currentColumnIndex] = num; console.log("---------------key", key, this.materialTestItemMap)
this.dialogVisible = false; // const mapEntry = this.materialTestItemMap[key];
} else { if (!mapEntry) {
this.$message.error("请输入有效的阈值例如80%"); 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%");
}
}, },
// //
resetDialog() { resetDialog() {
@ -233,15 +248,38 @@
}, },
// //
getCellClass(cell, cellIndex) { getCellClass(cell, cellIndex) {
if (cellIndex > 0 && ((cellIndex - 1) % 4 === 3)) { let that = this;
if (typeof cell === 'string' && cell.includes('%')) {
// //
const cellValue = String(cell); const cellValue = String(cell);
const value = parseFloat(cellValue.replace("%", "")); const value = parseFloat(cellValue.replace("%", ""));
const threshold = this.thresholds[cellIndex] || 0; // this.currentColumnIndex = cellIndex;
if (!isNaN(value)) { const header4Index = cellIndex - 1; // 0
return value > threshold ? "green-text" : "red-text"; 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 ""; return "";
}, },
deptChange(e){ deptChange(e){
@ -264,16 +302,38 @@
}); });
}, },
handleCellClick(cell, rowIndex, cellIndex){ handleCellClick(cell, rowIndex, cellIndex){
if ((cellIndex - 1) % 4 === 3) { // let that = this;
this.currentColumnIndex = cellIndex; // this.currentColumnIndex = cellIndex;
this.currentThreshold = this.thresholds[cellIndex] || ""; // const header4Index = cellIndex - 1 ; // 0
this.dialogVisible = true; // 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(){ getTableData(){
let that = this; let that = this;
that.tableDatas3 = []; that.tableDatas3 = [];
that.materialTestItemMap = {};
that.header3 = []; that.header3 = [];
if(that.deptName=='原料车间'){ if(that.deptName=='原料车间'){
that.header2Obj=[{name:'辅料',lengths:3},{name:'干混生料',lengths:4}]; that.header2Obj=[{name:'辅料',lengths:3},{name:'干混生料',lengths:4}];
@ -307,10 +367,30 @@
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)=>{
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){//
@ -321,12 +401,15 @@
wrapArr[ind] = []; wrapArr[ind] = [];
} }
if(that.deptName=='原料车间'){ 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=='烧成车间'){ }else if(that.deptName=='烧成车间'){
if(item.mgroup_name=='回转窑'){ if(item.mgroup_name=='回转窑'){
wrapArr[ind][1]=item wrapArr[ind][1]=item
}else{ }else if(item.mgroup_name=='煤磨'){
wrapArr[ind][0]=item wrapArr[ind][0]=item
} }
}else{ }else{
@ -339,12 +422,15 @@
wrapArr.forEach((item1,index1)=>{ wrapArr.forEach((item1,index1)=>{
if(item1!=undefined){// if(item1!=undefined){//
let itemArr = []; let itemArr = [];
// _
let header2tem=[],header2Objtem=[],header3tem=[],header4tem=[]; 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; 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) 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
@ -356,6 +442,7 @@
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('合次')
@ -369,7 +456,6 @@
}else{ }else{
itemArr[ind] = 0; itemArr[ind] = 0;
} }
// itemArr[ind] = (item3.val_avg).toFixed(2);
itemArr.push(item3.num_test) itemArr.push(item3.num_test)
itemArr.push(item3.num_ok) itemArr.push(item3.num_ok)
let pass = 0; let pass = 0;
@ -380,8 +466,9 @@
pass = Number(item3.rate_pass).toFixed(2) + '%'; pass = Number(item3.rate_pass).toFixed(2) + '%';
itemArr.push(pass) itemArr.push(pass)
} }
if(!that.thresholdobj[item3.material_name+"-"+item3.testitem_name]){
// pass= pass+'%'; 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));
@ -389,6 +476,9 @@
itemArr.push(item3.num_ok) itemArr.push(item3.num_ok)
let pass = Number(item3.rate_pass).toFixed(2); let pass = Number(item3.rate_pass).toFixed(2);
pass= pass+'%'; 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) itemArr.push(pass)
} }
that.titleLength =itemArr.length; that.titleLength =itemArr.length;

View File

@ -691,7 +691,6 @@ export default {
let form = this.$TOOL.data.get("sflogItem"); let form = this.$TOOL.data.get("sflogItem");
this.form = JSON.parse(form); this.form = JSON.parse(form);
console.log('----------------',this.form);
this.querystlog.mgroup = this.mgroupId; this.querystlog.mgroup = this.mgroupId;
this.querystlog.sflogs = this.form.id; this.querystlog.sflogs = this.form.id;
this.apiObjStlog = this.$API.wpm.stlog.list; this.apiObjStlog = this.$API.wpm.stlog.list;
@ -903,7 +902,6 @@ export default {
}, },
//stlogsflogexp //stlogsflogexp
stlogRowClick(row) { stlogRowClick(row) {
console.log(row);
this.clickItem = row; this.clickItem = row;
this.getSflogexp(row.id); this.getSflogexp(row.id);
}, },

View File

@ -1164,7 +1164,7 @@ export default {
); );
that.tableDatas[6][5] = that.tableDatas[6][5] =
data1.production_cost_unit; 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] - that.tableDatas[6][5]),
that.tableDatas[6][8] that.tableDatas[6][8]
); );