mirror of
https://gitee.com/beecue/fastbee.git
synced 2026-03-23 15:04:52 +08:00
更新
This commit is contained in:
@@ -3,22 +3,25 @@
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="日志类型" prop="logType">
|
||||
<el-select v-model="queryParams.logType" placeholder="请选择类型" clearable size="small">
|
||||
<el-option v-for="dict in dict.type.iot_device_log_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
<el-option v-for="dict in dict.type.iot_event_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="标识符" prop="identity">
|
||||
<el-input v-model="queryParams.identity" placeholder="请输入标识符" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="时间范围">
|
||||
<el-date-picker v-model="daterangeTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="deviceLogList" size="mini">
|
||||
<el-table v-loading="loading" :data="deviceLogList" size="mini">
|
||||
<el-table-column label="类型" align="center" prop="logType" width="120">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_device_log_type" :value="scope.row.logType" />
|
||||
<dict-tag :options="dict.type.iot_event_type" :value="scope.row.logType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="模式" align="center" prop="logType" width="120">
|
||||
@@ -56,15 +59,12 @@
|
||||
|
||||
<script>
|
||||
import {
|
||||
listDeviceLog
|
||||
} from "@/api/iot/deviceLog";
|
||||
import {
|
||||
cacheJsonThingsModel
|
||||
} from "@/api/iot/model";
|
||||
listEventLog
|
||||
} from "../../../api/iot/eventLog";
|
||||
|
||||
export default {
|
||||
name: "DeviceLog",
|
||||
dicts: ['iot_device_log_type', "iot_yes_no"],
|
||||
dicts: ['iot_event_type', "iot_yes_no"],
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
@@ -76,10 +76,10 @@ export default {
|
||||
device: function (newVal, oldVal) {
|
||||
this.deviceInfo = newVal;
|
||||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||||
this.queryParams.deviceId = this.deviceInfo.deviceId;
|
||||
this.queryParams.serialNumber = this.deviceInfo.serialNumber;
|
||||
this.getList();
|
||||
// 获取物模型
|
||||
this.getCacheThingsModdel(this.deviceInfo.productId);
|
||||
// 解析缓存物模型
|
||||
this.thingsModel = this.deviceInfo.cacheThingsModel;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -101,20 +101,24 @@ export default {
|
||||
logType: null,
|
||||
logValue: null,
|
||||
deviceId: null,
|
||||
serialNumber: null,
|
||||
deviceName: null,
|
||||
identity: null,
|
||||
isMonitor: null,
|
||||
},
|
||||
// 时间范围
|
||||
daterangeTime: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
||||
this.queryParams.serialNumber = this.device.serialNumber;
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询设备日志列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDeviceLog(this.queryParams).then(response => {
|
||||
listEventLog(this.addDateRange(this.queryParams, this.daterangeTime)).then(response => {
|
||||
this.deviceLogList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
@@ -128,20 +132,14 @@ export default {
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.daterangeTime=[];
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('iot/deviceLog/export', {
|
||||
this.download('iot/event/export', {
|
||||
...this.queryParams
|
||||
}, `deviceLog_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 获取物模型*/
|
||||
getCacheThingsModdel(productId) {
|
||||
// 获取缓存的Json物模型
|
||||
cacheJsonThingsModel(productId).then(response => {
|
||||
this.thingsModel = JSON.parse(response.data);
|
||||
});
|
||||
}, `eventLog_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 格式化显示数据定义 */
|
||||
formatValueDisplay(row) {
|
||||
@@ -149,17 +147,29 @@ export default {
|
||||
if (row.logType == 1) {
|
||||
let propertyItem = this.getThingsModelItem(1, row.identity);
|
||||
if (propertyItem != "") {
|
||||
return propertyItem.name + ': <span style="color:#409EFF;">' + this.getThingsModelItemValue(propertyItem, row.logValue) + ' ' + (propertyItem.datatype.unit != undefined ? propertyItem.datatype.unit : '') + '</span>';
|
||||
return (propertyItem.parentName ? '[' + propertyItem.parentName + (propertyItem.arrayIndex ? propertyItem.arrayIndex : '') + '] ' : '') +
|
||||
propertyItem.name +
|
||||
': <span style="color:#409EFF;">' + this.getThingsModelItemValue(propertyItem, row.logValue) + ' ' +
|
||||
(propertyItem.datatype.unit != undefined ? propertyItem.datatype.unit : '') + '</span>';
|
||||
}
|
||||
} else if (row.logType == 2) {
|
||||
let functionItem = this.getThingsModelItem(2, row.identity);
|
||||
if (functionItem != "") {
|
||||
return functionItem.name + ': <span style="color:#409EFF">' + this.getThingsModelItemValue(functionItem, row.logValue) + ' ' + (functionItem.datatype.unit != undefined ? functionItem.datatype.unit : '') + '</span>';
|
||||
return (functionItem.parentName ? '[' + functionItem.parentName + (functionItem.arrayIndex ? functionItem.arrayIndex : '') + '] ' : '') +
|
||||
functionItem.name +
|
||||
': <span style="color:#409EFF">' + this.getThingsModelItemValue(functionItem, row.logValue) + ' ' +
|
||||
(functionItem.datatype.unit != undefined ? functionItem.datatype.unit : '') + '</span>';
|
||||
}
|
||||
} else if (row.logType == 3) {
|
||||
let eventItem = this.getThingsModelItem(3, row.identity);
|
||||
if (eventItem != "") {
|
||||
return eventItem.name + ': <span style="color:#409EFF">' + this.getThingsModelItemValue(eventItem, row.logValue) + ' ' + (eventItem.datatype.unit != undefined ? eventItem.datatype.unit : '') + '</span>';
|
||||
return (eventItem.parentName ? '[' + eventItem.parentName + (eventItem.arrayIndex ? eventItem.arrayIndex : '') + '] ' : '') +
|
||||
eventItem.name +
|
||||
': <span style="color:#409EFF">' + this.getThingsModelItemValue(eventItem, row.logValue) + ' ' +
|
||||
(eventItem.datatype.unit != undefined ? eventItem.datatype.unit : '') + '</span>';
|
||||
}
|
||||
else {
|
||||
return row.logValue;
|
||||
}
|
||||
} else if (row.logType == 4) {
|
||||
return '<span style="font-weight:bold">设备升级</span>';
|
||||
@@ -172,6 +182,7 @@ export default {
|
||||
},
|
||||
/** 获取物模型项中的值*/
|
||||
getThingsModelItemValue(item, oldValue) {
|
||||
// 枚举和布尔转换为文字
|
||||
if (item.datatype.type == "bool") {
|
||||
if (oldValue == "0") {
|
||||
return item.datatype.falseText;
|
||||
@@ -191,15 +202,95 @@ export default {
|
||||
getThingsModelItem(type, identity) {
|
||||
if (type == 1 && this.thingsModel.properties) {
|
||||
for (let i = 0; i < this.thingsModel.properties.length; i++) {
|
||||
//普通类型 integer/decimal/string/emum//bool
|
||||
if (this.thingsModel.properties[i].id == identity) {
|
||||
return this.thingsModel.properties[i];
|
||||
}
|
||||
// 对象 object
|
||||
if (this.thingsModel.properties[i].datatype.type == "object") {
|
||||
for (let j = 0; j < this.thingsModel.properties[i].datatype.params.length; j++) {
|
||||
if (this.thingsModel.properties[i].datatype.params[j].id == identity) {
|
||||
this.thingsModel.properties[i].datatype.params[j].parentName = this.thingsModel.properties[i].name;
|
||||
return this.thingsModel.properties[i].datatype.params[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 数组 array
|
||||
if (this.thingsModel.properties[i].datatype.type == "array" && this.thingsModel.properties[i].datatype.arrayType) {
|
||||
if (this.thingsModel.properties[i].datatype.arrayType == "object") {
|
||||
// 数组元素格式:array_01_parentId_humidity,array_01_前缀终端上报时加上,物模型中没有
|
||||
let realIdentity = identity;
|
||||
let arrayIndex = 0;
|
||||
if (identity.indexOf("array_") > -1) {
|
||||
arrayIndex = identity.substring(6, 8);
|
||||
realIdentity = identity.substring(9);
|
||||
}
|
||||
for (let j = 0; j < this.thingsModel.properties[i].datatype.params.length; j++) {
|
||||
if (this.thingsModel.properties[i].datatype.params[j].id == realIdentity) {
|
||||
// 标注索引和父级名称
|
||||
this.thingsModel.properties[i].datatype.params[j].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.properties[i].datatype.params[j].parentName = this.thingsModel.properties[i].name;
|
||||
return this.thingsModel.properties[i].datatype.params[j];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 普通类型
|
||||
for (let j = 0; j < this.thingsModel.properties[i].datatype.arrayCount.length; j++) {
|
||||
if (this.thingsModel.properties[i].id == realIdentity) {
|
||||
this.thingsModel.properties[i].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.properties[i].parentName = "元素";
|
||||
return this.thingsModel.properties[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else if (type == 2 && this.thingsModel.functions) {
|
||||
for (let i = 0; i < this.thingsModel.functions.length; i++) {
|
||||
//普通类型 integer/decimal/string/emum/bool
|
||||
if (this.thingsModel.functions[i].id == identity) {
|
||||
return this.thingsModel.functions[i];
|
||||
}
|
||||
// 对象 object
|
||||
if (this.thingsModel.functions[i].datatype.type == "object") {
|
||||
for (let j = 0; j < this.thingsModel.functions[i].datatype.params.length; j++) {
|
||||
if (this.thingsModel.functions[i].datatype.params[j].id == identity) {
|
||||
this.thingsModel.functions[i].datatype.params[j].parentName = this.thingsModel.functions[i].name;
|
||||
return this.thingsModel.functions[i].datatype.params[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 数组 array
|
||||
if (this.thingsModel.functions[i].datatype.type == "array" && this.thingsModel.functions[i].datatype.arrayType) {
|
||||
// 数组元素格式:array_01_parentId_humidity,array_01_前缀终端上报时加上,物模型中没有
|
||||
let realIdentity = identity;
|
||||
let arrayIndex = 0;
|
||||
if (identity.indexOf("array_") > -1) {
|
||||
arrayIndex = identity.substring(6, 8);
|
||||
realIdentity = identity.substring(9);
|
||||
}
|
||||
if (this.thingsModel.functions[i].datatype.arrayType == "object") {
|
||||
for (let j = 0; j < this.thingsModel.functions[i].datatype.params.length; j++) {
|
||||
if (this.thingsModel.functions[i].datatype.params[j].id == realIdentity) {
|
||||
// 标注索引和父级名称
|
||||
this.thingsModel.functions[i].datatype.params[j].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.functions[i].datatype.params[j].parentName = this.thingsModel.functions[i].name;
|
||||
return this.thingsModel.functions[i].datatype.params[j];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 普通类型
|
||||
for (let j = 0; j < this.thingsModel.functions[i].datatype.arrayCount.length; j++) {
|
||||
if (this.thingsModel.functions[i].id == realIdentity) {
|
||||
this.thingsModel.functions[i].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.functions[i].parentName = "元素";
|
||||
return this.thingsModel.functions[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else if (type == 3 && this.thingsModel.events) {
|
||||
for (let i = 0; i < this.thingsModel.events.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user