feat:tkx fix bug

This commit is contained in:
zty 2024-10-15 14:36:31 +08:00
parent cb0a492bbc
commit 6e4a817324
4 changed files with 45 additions and 23 deletions

View File

@ -113,14 +113,34 @@ export default {
if (res.length > 0) { if (res.length > 0) {
res.forEach((item) => { res.forEach((item) => {
if (item.goal_cate_name == "单位产品分布电耗KW·h/t") { if (item.goal_cate_name == "单位产品分布电耗KW·h/t") {
that.getData(item); that.getGoalData();
} }
}) })
} }
}); });
}); });
}, },
methods: { methods: {
getGoalData() {
const self = this;
let params = {};
params.page = 0;
params.year = self.query.year_s;
params.mgroup = self.query.mgroup;
this.$API.mtm.goal.list.req(params).then((res) => {
if (res.length > 0) {
res.forEach((item) => {
if (item.goal_cate_name == "单位产品分布电耗KW·h/t") {
this.getData(item);
}
})
}
})
.catch((error) => {
console.error('获取目标数据失败:', error);
});
},
getData(goalData) { getData(goalData) {
let that = this; let that = this;
let query0 = {}; let query0 = {};
@ -320,7 +340,7 @@ export default {
}, },
handleQuery() { handleQuery() {
this.tableDatas = []; this.tableDatas = [];
this.getData(this.goalDatas); this.getGoalData();
}, },
itemClick(type, item) { itemClick(type, item) {
this.type = type; this.type = type;

View File

@ -14,7 +14,6 @@
v-model="query.type" v-model="query.type"
placeholder="查询类型" placeholder="查询类型"
clearable clearable
@change="typeCange"
> >
<el-option <el-option
v-for="item in options" v-for="item in options"
@ -97,7 +96,7 @@
:key="1" :key="1"
id="myTable" id="myTable"
class="myTable" class="myTable"
v-else v-if="query.type == 2"
> >
<thead class="myTableHead"> <thead class="myTableHead">
<tr> <tr>
@ -128,7 +127,7 @@
class="numCell" class="numCell"
> >
<div :class="bindClass(item1, ind)"> <div :class="bindClass(item1, ind)">
<span v-if="item1 < 0 && ind == 6" <span v-if="item1 > 0 && ind == 6"
></span ></span
> >
<span v-if="item1 < 0 && ind == 6" <span v-if="item1 < 0 && ind == 6"
@ -314,6 +313,10 @@ export default {
that.monthGoal[ind] !== undefined that.monthGoal[ind] !== undefined
? that.monthGoal[ind] ? that.monthGoal[ind]
: "/"; : "/";
arr.push(item.cen_consume_unit); //KW·h/t
arr[4] = that.monthGoal2[ind] !== undefined
? that.monthGoal2[ind]
: "/";
wrapArr.push(arr); wrapArr.push(arr);
}); });
wrapArr.forEach((item, index) => { wrapArr.forEach((item, index) => {
@ -380,26 +383,23 @@ export default {
} }
arrs[8] = sameRate; arrs[8] = sameRate;
wrapArrs.push(arrs); wrapArrs.push(arrs);
arrs2[0] = item[0]; arrs2[0] = item[0];
arrs2[1] = item.cen_consume_unit; arrs2[1] = item[3];
arrs2[2] = arrs2[2] = item[4];
that.monthGoal2[ind] !== undefined
? that.monthGoal2[ind]
: "/";
arrs2[3] = 80; arrs2[3] = 80;
arrs2[4] = 87; arrs2[4] = 87;
arrs2[5] = 94; arrs2[5] = 94;
//KW·h/t //KW·h/t
let lastNum2 = 0, let lastNum2 = 0,
lastDiff2 = 0; lastDiff2 = 0;
if (index > 1) { if (index >= 1) {
let num = index - 1; let num = index - 1;
if ( if (
wrapArr[num] && wrapArr[num] &&
wrapArr[num].cen_consume_unit wrapArr[num][3]
) { ) {
lastNum2 = wrapArr[num].cen_consume_unit; lastNum2 = wrapArr[num][3];
} else { } else {
lastNum2 = "/"; lastNum2 = "/";
} }
@ -409,7 +409,7 @@ export default {
: "/"; : "/";
} }
if (arrs2[1] !== "/" && lastNum2 !== "/") { if (arrs2[1] !== "/" && lastNum2 !== "/") {
lastDiff2 = arrs2[1] - lastNum2; lastDiff2 = (arrs2[1] - lastNum2).toFixed(2);
} else { } else {
lastDiff2 = "/"; lastDiff2 = "/";
} }
@ -417,7 +417,7 @@ export default {
//% //%
let lastRate2 = 0; let lastRate2 = 0;
if ( if (
lastDiff2 == "/" && lastDiff2 !== "/" &&
lastNum2 !== "/" && lastNum2 !== "/" &&
lastNum2 !== 0 lastNum2 !== 0
) { ) {
@ -456,8 +456,8 @@ export default {
}, },
handleQuery() { handleQuery() {
this.getMonthGoal(); this.getMonthGoal();
this.getData();
}, },
typeCange() {},
handlePrint() { handlePrint() {
this.$PRINT("#myReport"); this.$PRINT("#myReport");
}, },

View File

@ -267,7 +267,8 @@ export default {
if ( if (
lastDiff !== "/" && lastDiff !== "/" &&
lastNum !== "/" && lastNum !== "/" &&
lastNum !== 0 lastNum != 0 &&
lastDiff != 0
) { ) {
lastRate = ((lastDiff / lastNum) * 100).toFixed(2); lastRate = ((lastDiff / lastNum) * 100).toFixed(2);
} else { } else {

View File

@ -166,7 +166,8 @@ export default {
bindClass(item, index) { bindClass(item, index) {
let classInfo = { redColor: false, greenColor: false }; let classInfo = { redColor: false, greenColor: false };
if (index == 3 || index == 5) { if (index == 3 || index == 5) {
if (typeof item == "number") { if ( item != "/") {
item = Number(item);
if (item > 0) { if (item > 0) {
classInfo.greenColor = true; classInfo.greenColor = true;
classInfo.redColor = false; classInfo.redColor = false;
@ -227,7 +228,7 @@ export default {
//KW·h/t //KW·h/t
let diff = 0; let diff = 0;
if (item[2] !== "/") { if (item[2] !== "/") {
diff = item[1] - item[2]; diff = (item[1] - item[2]).toFixed(2);
} else { } else {
diff = "/"; diff = "/";
} }
@ -262,11 +263,11 @@ export default {
//% //%
let lastRate = 0; let lastRate = 0;
if ( if (
lastDiff == "/" && lastDiff !== "/" &&
lastNum !== "/" && lastNum !== "/" &&
lastNum !== 0 lastNum != 0
) { ) {
lastRate = (lastDiff / lastNum) * 100; lastRate = ((lastDiff / lastNum) * 100).toFixed(2);
} else { } else {
lastRate = "/"; lastRate = "/";
} }