Commit c5a0225a by wuwx

修复计算问题

1 parent 469bd713
......@@ -143,7 +143,7 @@
</div>
<div class="footer">
<span style="margin-right: 276px;color: #0196FA;">设备在线率:{{hasPermission('data_doard_offLine') ? number(staticInfo.onlineRate) + number(staticInfo.fakeOfflineRate) : staticInfo.onlineRate}}%</span>
<span style="margin-right: 276px;color: #0196FA;">设备在线率:{{hasPermission('data_doard_offLine') ? addSub(staticInfo.onlineRate, staticInfo.fakeOfflineRate) : staticInfo.onlineRate}}%</span>
<span style="color: #F47F13;">设备离线率:{{hasPermission('data_doard_offLine') ? accSub(staticInfo.offlineRate, staticInfo.fakeOfflineRate) : staticInfo.offlineRate}}%</span>
</div>
</div>
......@@ -271,10 +271,6 @@ export default {
this.getStatic();
},
methods: {
// 转number类型
number(a) {
return Number(a)
},
// 是否有权限
hasPermission(id) {
let list = this.$root.parentCommon.getAuthData();
......@@ -306,7 +302,7 @@ export default {
m = []
const a = this.accSub(100, obj.onlineRate)
m.push({ value: this.accSub(a, obj.fakeOfflineRate), name: "" });
m.push({ value: Number(obj.onlineRate) + Number(obj.fakeOfflineRate), name: "" });
m.push({ value: this.addSub(obj.onlineRate, obj.fakeOfflineRate), name: "" });
}
this.createBindChart("onlineChart", m);
......@@ -317,8 +313,9 @@ export default {
if (this.hasPermission('data_doard_offLine')) {
n = []
const b = this.accSub(100, obj.offlineRate)
n.push({ value: this.accSub(obj.offlineRate, obj.fakeOfflineRate), name: "" });
n.push({ value: Number(this.accSub(100, obj.offlineRate)) + Number(obj.fakeOfflineRate), name: "" });
n.push({ value: this.addSub(b, obj.fakeOfflineRate), name: "" });
}
this.createBindChart("offlineChart", n);
......@@ -332,22 +329,19 @@ export default {
this.maskFlag = false
});
},
// 计算函数
// 减法计算函数
accSub(arg1, arg2) {
let r1, r2, m, n
try {
r1 = arg1.toString().split('.')[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.toString().split('.')[1].length
} catch (e) {
r2 = 0
}
m = Math.pow(10, Math.max(r1, r2))
n = r1 >= r2 ? r1 : r2
return ((arg1 * m - arg2 * m) / m).toFixed(n)
let a = arg1 - arg2
a = Math.round((a) * 100) / 100
a.toFixed(2)
return a
},
// 加法计算函数
addSub(arg1, arg2) {
let b = Number(arg1) + Number(arg2)
b = Math.round((b) * 100) / 100
b.toFixed(2)
return b
},
// 获取警情统计
getAlarm() {
......@@ -436,6 +430,7 @@ export default {
show: false,
},
data: data,
// minAngle: 20
},
],
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!