mirror of
https://gitee.com/beecue/fastbee.git
synced 2026-03-23 15:04:52 +08:00
feat(国际化): 新增国际化
This commit is contained in:
@@ -1,75 +1,80 @@
|
||||
<template>
|
||||
<div style="padding-left:20px;">
|
||||
<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_event_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="标识符" prop="identify">
|
||||
<el-input v-model="queryParams.identify" 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>
|
||||
<div style="padding-left: 20px">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item :label="$t('device.device-log.798283-0')" prop="logType">
|
||||
<el-select v-model="queryParams.logType" :placeholder="$t('device.device-log.798283-1')" clearable size="small">
|
||||
<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="$t('device.device-log.798283-2')" prop="identify">
|
||||
<el-input v-model="queryParams.identify" :placeholder="$t('device.device-log.798283-3')" clearable size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('device.device-log.798283-4')">
|
||||
<el-date-picker
|
||||
v-model="daterangeTime"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
:start-placeholder="$t('device.device-log.798283-5')"
|
||||
:end-placeholder="$t('device.device-log.798283-6')"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('device.device-log.798283-7') }}</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('device.device-log.798283-8') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<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_event_type" :value="scope.row.logType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="模式" align="center" prop="logType" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="primary" v-if="scope.row.mode==1">影子模式</el-tag>
|
||||
<el-tag type="success" v-else-if="scope.row.mode==2">在线模式</el-tag>
|
||||
<el-tag type="info" v-else>其他信息</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="时间" align="center" prop="createTime" width="150">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.createTime }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标识符" align="center" prop="identify" />
|
||||
<el-table-column label="动作" align="left" header-align="center" prop="logValue">
|
||||
<template slot-scope="scope">
|
||||
<div v-html="formatValueDisplay(scope.row)"></div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table v-loading="loading" :data="deviceLogList" size="mini">
|
||||
<el-table-column :label="$t('device.device-log.798283-9')" align="center" prop="logType" width="120">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.iot_event_type" :value="scope.row.logType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('device.device-log.798283-10')" align="center" prop="logType" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="primary" v-if="scope.row.mode == 1">{{ $t('device.device-log.798283-11') }}</el-tag>
|
||||
<el-tag type="success" v-else-if="scope.row.mode == 2">{{ $t('device.device-log.798283-12') }}</el-tag>
|
||||
<el-tag type="info" v-else>{{ $t('device.device-log.798283-13') }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('device.device-log.798283-14')" align="center" prop="createTime" width="150">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.createTime }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标识符" align="center" prop="identify" />
|
||||
<el-table-column label="动作" align="left" header-align="center" prop="logValue">
|
||||
<template slot-scope="scope">
|
||||
<div v-html="formatValueDisplay(scope.row)"></div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="备注" header-align="center" align="left" prop="remark">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.remark==null ?"无":scope.row.remark}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
</el-table>
|
||||
<div style="height:40px;">
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
<el-table-column :label="$t('device.device-log.798283-16')" header-align="center" align="left" prop="remark">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.remark == null ? '无' : scope.row.remark }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div style="height: 40px">
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
listEventLog
|
||||
} from "../../../api/iot/eventLog";
|
||||
import { listEventLog } from '../../../api/iot/eventLog';
|
||||
|
||||
export default {
|
||||
name: "DeviceLog",
|
||||
dicts: ['iot_event_type', "iot_yes_no"],
|
||||
name: 'DeviceLog',
|
||||
dicts: ['iot_event_type', 'iot_yes_no'],
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
// 获取到父组件传递的device后,刷新列表
|
||||
@@ -81,7 +86,7 @@ export default {
|
||||
// 解析缓存物模型
|
||||
this.thingsModel = this.deviceInfo.cacheThingsModel;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -118,7 +123,7 @@ export default {
|
||||
/** 查询设备日志列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listEventLog(this.addDateRange(this.queryParams, this.daterangeTime)).then(response => {
|
||||
listEventLog(this.addDateRange(this.queryParams, this.daterangeTime)).then((response) => {
|
||||
this.deviceLogList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
@@ -131,65 +136,83 @@ export default {
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.daterangeTime=[];
|
||||
this.resetForm('queryForm');
|
||||
this.daterangeTime = [];
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('iot/event/export', {
|
||||
...this.queryParams
|
||||
}, `eventLog_${new Date().getTime()}.xlsx`)
|
||||
this.download(
|
||||
'iot/event/export',
|
||||
{
|
||||
...this.queryParams,
|
||||
},
|
||||
`eventLog_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
},
|
||||
/** 格式化显示数据定义 */
|
||||
formatValueDisplay(row) {
|
||||
// 类型(1=属性上报,2=调用功能,3=事件上报,4=设备升级,5=设备上线,6=设备离线)
|
||||
if (row.logType == 1) {
|
||||
let propertyItem = this.getThingsModelItem(1, row.identify);
|
||||
if (propertyItem != "") {
|
||||
return (propertyItem.parentName ? '[' + propertyItem.parentName + (propertyItem.arrayIndex ? propertyItem.arrayIndex : '') + '] ' : '') +
|
||||
if (propertyItem != '') {
|
||||
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>';
|
||||
': <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.identify);
|
||||
if (functionItem != "") {
|
||||
return (functionItem.parentName ? '[' + functionItem.parentName + (functionItem.arrayIndex ? functionItem.arrayIndex : '') + '] ' : '') +
|
||||
if (functionItem != '') {
|
||||
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>';
|
||||
': <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.identify);
|
||||
if (eventItem != "") {
|
||||
return (eventItem.parentName ? '[' + eventItem.parentName + (eventItem.arrayIndex ? eventItem.arrayIndex : '') + '] ' : '') +
|
||||
if (eventItem != '') {
|
||||
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 {
|
||||
': <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>';
|
||||
return '<span style="font-weight:bold">' + this.$t('device.device-log.798283-18') + '</span>';
|
||||
} else if (row.logType == 5) {
|
||||
return '<span style="font-weight:bold">设备上线</span>';
|
||||
return '<span style="font-weight:bold">' + this.$t('device.device-log.798283-19') + '</span>';
|
||||
} else if (row.logType == 6) {
|
||||
return '<span style="font-weight:bold">设备离线</span>';
|
||||
return '<span style="font-weight:bold">' + this.$t('device.device-log.798283-20') + '</span>';
|
||||
}
|
||||
return "";
|
||||
return '';
|
||||
},
|
||||
/** 获取物模型项中的值*/
|
||||
getThingsModelItemValue(item, oldValue) {
|
||||
// 枚举和布尔转换为文字
|
||||
if (item.datatype.type == "bool") {
|
||||
if (oldValue == "0") {
|
||||
if (item.datatype.type == 'bool') {
|
||||
if (oldValue == '0') {
|
||||
return item.datatype.falseText;
|
||||
} else if (oldValue == "1") {
|
||||
} else if (oldValue == '1') {
|
||||
return item.datatype.trueText;
|
||||
}
|
||||
} else if (item.datatype.type == "enum") {
|
||||
} else if (item.datatype.type == 'enum') {
|
||||
for (let i = 0; i < item.datatype.enumList.length; i++) {
|
||||
if (oldValue == item.datatype.enumList[i].value) {
|
||||
return item.datatype.enumList[i].text;
|
||||
@@ -207,7 +230,7 @@ export default {
|
||||
return this.thingsModel.properties[i];
|
||||
}
|
||||
// 对象 object
|
||||
if (this.thingsModel.properties[i].datatype.type == "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 == identify) {
|
||||
this.thingsModel.properties[i].datatype.params[j].parentName = this.thingsModel.properties[i].name;
|
||||
@@ -216,12 +239,12 @@ export default {
|
||||
}
|
||||
}
|
||||
// 数组 array
|
||||
if (this.thingsModel.properties[i].datatype.type == "array" && this.thingsModel.properties[i].datatype.arrayType) {
|
||||
if (this.thingsModel.properties[i].datatype.arrayType == "object") {
|
||||
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 realidentify = identify;
|
||||
let arrayIndex = 0;
|
||||
if (identify.indexOf("array_") > -1) {
|
||||
if (identify.indexOf('array_') > -1) {
|
||||
arrayIndex = identify.substring(6, 8);
|
||||
realidentify = identify.substring(9);
|
||||
}
|
||||
@@ -238,12 +261,11 @@ export default {
|
||||
for (let j = 0; j < this.thingsModel.properties[i].datatype.arrayCount.length; j++) {
|
||||
if (this.thingsModel.properties[i].id == realidentify) {
|
||||
this.thingsModel.properties[i].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.properties[i].parentName = "元素";
|
||||
this.thingsModel.properties[i].parentName = this.$t('device.device-log.798283-21');
|
||||
return this.thingsModel.properties[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else if (type == 2 && this.thingsModel.functions) {
|
||||
@@ -253,7 +275,7 @@ export default {
|
||||
return this.thingsModel.functions[i];
|
||||
}
|
||||
// 对象 object
|
||||
if (this.thingsModel.functions[i].datatype.type == "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 == identify) {
|
||||
this.thingsModel.functions[i].datatype.params[j].parentName = this.thingsModel.functions[i].name;
|
||||
@@ -262,15 +284,15 @@ export default {
|
||||
}
|
||||
}
|
||||
// 数组 array
|
||||
if (this.thingsModel.functions[i].datatype.type == "array" && this.thingsModel.functions[i].datatype.arrayType) {
|
||||
if (this.thingsModel.functions[i].datatype.type == 'array' && this.thingsModel.functions[i].datatype.arrayType) {
|
||||
// 数组元素格式:array_01_parentId_humidity,array_01_前缀终端上报时加上,物模型中没有
|
||||
let realidentify = identify;
|
||||
let arrayIndex = 0;
|
||||
if (identify.indexOf("array_") > -1) {
|
||||
if (identify.indexOf('array_') > -1) {
|
||||
arrayIndex = identify.substring(6, 8);
|
||||
realidentify = identify.substring(9);
|
||||
}
|
||||
if (this.thingsModel.functions[i].datatype.arrayType == "object") {
|
||||
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 == realidentify) {
|
||||
// 标注索引和父级名称
|
||||
@@ -284,23 +306,22 @@ export default {
|
||||
for (let j = 0; j < this.thingsModel.functions[i].datatype.arrayCount.length; j++) {
|
||||
if (this.thingsModel.functions[i].id == realidentify) {
|
||||
this.thingsModel.functions[i].arrayIndex = Number(arrayIndex) + 1;
|
||||
this.thingsModel.functions[i].parentName = "元素";
|
||||
this.thingsModel.functions[i].parentName = this.$t('device.device-log.798283-21');
|
||||
return this.thingsModel.functions[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else if (type == 3 && this.thingsModel.events) {
|
||||
for (let i = 0; i < this.thingsModel.events.length; i++) {
|
||||
if (this.thingsModel.events[i].id == identify) {
|
||||
if (this.ththingsModel.events[i].id == identify) {
|
||||
return this.thingsModel.events[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return '';
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user