Commit c5a0225a by wuwx

修复计算问题

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