Commit ca2c4302 authored by wanli's avatar wanli

🐞 fix(): 更新前端

parent cca4da40
This diff is collapsed.
...@@ -393,7 +393,8 @@ import { ...@@ -393,7 +393,8 @@ import {
getMonitorData, getMonitorData,
getReport, getReport,
getTemplate, getTemplate,
} from "@/api/index"; setTemplate,
} from "@/api/app-store";
import EvmChart from "./components/EvmChart"; import EvmChart from "./components/EvmChart";
import LvglChart from "./components/LvglChart"; import LvglChart from "./components/LvglChart";
import SystemChart from "./components/SystemChart"; import SystemChart from "./components/SystemChart";
...@@ -419,7 +420,7 @@ const dbObject = { ...@@ -419,7 +420,7 @@ const dbObject = {
], ],
}; };
const indexedDb = Database(); const indexedDb = Database(), jsonFile = "evue-monitor.json";
let monitor = new indexedDb(dbObject); let monitor = new indexedDb(dbObject);
function resetResult() { function resetResult() {
...@@ -581,21 +582,26 @@ export default { ...@@ -581,21 +582,26 @@ export default {
item.lvgl item.lvgl
) )
); );
});
appList = appList.concat(item.image.map((img) => { appList = appList.concat(
this.imageList.map((img) => {
if (img.png_detail && img.png_detail.length) { if (img.png_detail && img.png_detail.length) {
result.imageList = result.imageList.concat( result.imageList = result.imageList.concat(
img.png_detail.map((p) => { img.png_detail.map((p) => {
p.page = item.uri; p.page = img.uri;
return p; return p;
}) })
); );
} }
return Object.assign({ ts: Date.parse(item.system.timestamp), ...img }) return Object.assign({
})); ts: Date.parse(this.globalData.system.timestamp),
}); ...img,
});
})
);
result.appList = appList result.appList = appList;
Object.keys(evm).forEach((k) => { Object.keys(evm).forEach((k) => {
result.evmFirst[k] = 0; result.evmFirst[k] = 0;
...@@ -638,7 +644,7 @@ export default { ...@@ -638,7 +644,7 @@ export default {
return item[k]; return item[k];
}); });
result.lvglMax[k] = Math.max.apply(null, t); result.lvglMax[k] = Math.max.apply(null, t);
result.lvglMin[k] = Math.min.apply(null, t); result.lvglMin[k] = Math.min.apply(null, t);
result.lvglAvg[k] = Math.ceil( result.lvglAvg[k] = Math.ceil(
t.reduce((prev, curr) => prev + curr) / t.length t.reduce((prev, curr) => prev + curr) / t.length
...@@ -662,37 +668,36 @@ export default { ...@@ -662,37 +668,36 @@ export default {
return item[k]; return item[k];
}); });
result.systemMax[k] = Math.max.apply(null, t); result.systemMax[k] = Math.max.apply(null, t);
result.systemMin[k] = Math.min.apply(null, t); result.systemMin[k] = Math.min.apply(null, t);
result.systemAvg[k] = Math.ceil( result.systemAvg[k] = Math.ceil(
t.reduce((prev, curr) => prev + curr) / t.length t.reduce((prev, curr) => prev + curr) / t.length
); );
}); });
result.imei = this.globalData.imei result.imei = this.globalData.imei;
result.timestamp = this.globalData.system.timestamp result.timestamp = this.globalData.system.timestamp;
let params = { return getReport({
templateName: "evue-monitor.json", templateJson: jsonFile,
dataJson: result, dataJson: result,
}; });
return getReport(params);
}) })
.then((res) => { .then((res) => {
if (res.retcode == 0) { if (res.code == 200) {
download(res.message.file, res.message.url).then(res => { download(res.data.file, res.data.url)
console.log(res) .then((res) => {
}).catch(err => { console.log(res);
console.log(err) })
}) .catch((err) => {
this.$message.success("success") console.error(err);
});
} }
console.log(res); this.$message.success(res.msg);
}) })
.catch((err) => { .catch((err) => {
// this.$message.error(err.msg); this.$message.error(err.msg);
console.log(err); console.error(err);
}); });
}, },
tableRowClassName({ row }) { tableRowClassName({ row }) {
...@@ -787,7 +792,6 @@ export default { ...@@ -787,7 +792,6 @@ export default {
// 将设备发送过来的消息存储到浏览器中 // 将设备发送过来的消息存储到浏览器中
// 这里可以优化,将所有数据,保存到indexed datebase中 // 这里可以优化,将所有数据,保存到indexed datebase中
const m = deepClone(msg); const m = deepClone(msg);
if (monitor.db) monitor.set(msg);
if (!this.deviceList) { if (!this.deviceList) {
this.deviceList = []; this.deviceList = [];
...@@ -801,17 +805,23 @@ export default { ...@@ -801,17 +805,23 @@ export default {
else this.device = msg.imei; else this.device = msg.imei;
} }
// 处理单位
this.processData(m);
if (monitor.db) monitor.set(m);
// 如果接收到的数据不是当前选中的设备,那么则直接丢弃 // 如果接收到的数据不是当前选中的设备,那么则直接丢弃
if (msg.imei != this.device) { if (msg.imei != this.device) {
return null; return null;
} }
// 处理单位
this.processData(m);
this.globalData = msg; this.globalData = msg;
this.resetData(m); this.resetData(m);
}, },
processData(msg) { processData(msg) {
function isNumber(value) {
return typeof value === "number" && !isNaN(value);
}
if (!msg) return null; if (!msg) return null;
Object.keys(msg).forEach((item) => { Object.keys(msg).forEach((item) => {
if (this.form[item]) { if (this.form[item]) {
...@@ -820,7 +830,8 @@ export default { ...@@ -820,7 +830,8 @@ export default {
var k = keys[i]; var k = keys[i];
if (item == "image") { if (item == "image") {
for (var j = 0; j < msg[item].length; j++) { for (var j = 0; j < msg[item].length; j++) {
msg[item][j][k] = Math.ceil(msg[item][j][k] / 1024); if (isNumber(msg[item][j][k]))
msg[item][j][k] = Math.ceil(msg[item][j][k] / 1024);
} }
} else { } else {
msg[item][k] = Math.ceil(msg[item][k] / 1024); msg[item][k] = Math.ceil(msg[item][k] / 1024);
...@@ -828,6 +839,17 @@ export default { ...@@ -828,6 +839,17 @@ export default {
} }
} }
}); });
msg.image.forEach((item) => {
if (item.png_detail && item.png_detail.length) {
item.png_detail = item.png_detail.map((png) => {
png.ratio = Math.floor(png.ratio * 100) / 100;
png.filesize = Math.floor(png.filesize / 1024);
png.uncompressed_size = Math.floor(png.uncompressed_size / 1024);
return png;
});
}
});
}, },
onSelectChange(res) { onSelectChange(res) {
this.device = res; this.device = res;
...@@ -891,11 +913,11 @@ export default { ...@@ -891,11 +913,11 @@ export default {
} }
}); });
if (this.globalData) { if (m) {
if (this.globalData.evm) this.evm = this.globalData.evm; if (m.evm) this.evm = m.evm;
if (this.globalData.lvgl) this.lvgl = this.globalData.lvgl; if (m.lvgl) this.lvgl = m.lvgl;
if (this.globalData.image) this.image = this.globalData.image; if (m.image) this.image = m.image;
if (this.globalData.system) this.system = this.globalData.system; if (m.system) this.system = m.system;
} }
}, },
}, },
...@@ -950,6 +972,12 @@ export default { ...@@ -950,6 +972,12 @@ export default {
.catch((err) => { .catch((err) => {
console.log(err); console.log(err);
}); });
setTemplate({ templateName: jsonFile }).then(res => {
console.log(res.msg)
}).catch(err => {
console.log(err.msg)
})
}, },
}; };
</script> </script>
......
''' '''
Author: your name Author: your name
Date: 2021-07-22 19:01:41 Date: 2021-07-22 19:01:41
LastEditTime: 2021-07-26 03:23:07 LastEditTime: 2021-07-26 10:22:30
LastEditors: Please set LastEditors LastEditors: Please set LastEditors
Description: In User Settings Edit Description: In User Settings Edit
FilePath: \evm-store\tools\build_out\tests\http_interval.py FilePath: \evm-store\tools\build_out\tests\http_interval.py
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment