138 lines
3.2 KiB
Vue
138 lines
3.2 KiB
Vue
<template>
|
||
<view>
|
||
<view v-if="logList.length>0">
|
||
<view class="background-color-fff margin-bottom-10 padding-20 border-radius-15 font-color-l2 font-size-25" v-for="item in logList" :key="item.logId">
|
||
<view class="margin-bottom-10">
|
||
<text class="font-weight-bold font-size-25" style="color:#2b7">{{item.logType | transformName(logTypeList)}}</text>
|
||
</view>
|
||
<view class="">
|
||
<text class="font-weight-bold">模式:</text><text v-if="item.mode==1">影子模式</text>
|
||
<text v-else-if="item.mode==2">在线模式</text>
|
||
<text v-else>其他信息</text>
|
||
</view>
|
||
<view class="">
|
||
<text class="font-weight-bold">标志符:</text>{{item.identity}}
|
||
</view>
|
||
<view class="">
|
||
<text class="font-weight-bold">动作:</text><text v-if="item.logType==1 ||item.logType==2||item.logType==3">
|
||
{{item.remark+':'+item.logValue}}
|
||
</text>
|
||
<text v-if="item.logType==4">
|
||
设备升级
|
||
</text>
|
||
<text v-if="item.logType==5">
|
||
设备上线
|
||
</text>
|
||
<text v-if="item.logType==6">
|
||
设备离线
|
||
</text>
|
||
</view>
|
||
<view class="">
|
||
<text class="font-weight-bold">时间:</text> {{item.createTime}}
|
||
</view>
|
||
</view>
|
||
<view class="pagination" v-if="total!=0">
|
||
<uni-pagination :show-icon="true" :total="total" @change="getLog" />
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 无数据控件 -->
|
||
<u-empty v-else mode="data" icon="https://cdn.uviewui.com/uview/empty/data.png" />
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
getDict
|
||
} from "@/utils/dict.js"
|
||
export default {
|
||
name: "log",
|
||
props: {
|
||
device: {
|
||
type: Object,
|
||
default: null
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
thingsModel: {},
|
||
query: {
|
||
pageNum: 1,
|
||
pageSize: 5,
|
||
serialNumber: null
|
||
},
|
||
logList: [],
|
||
total: 0,
|
||
logTypeList: []
|
||
}
|
||
},
|
||
watch: {
|
||
// 获取到父组件传递的device后,刷新列表
|
||
device: {
|
||
handler(newVal, oldVal) {
|
||
this.deviceInfo = newVal;
|
||
if (this.deviceInfo && this.deviceInfo.deviceId != 0) {
|
||
this.query.serialNumber = this.deviceInfo.serialNumber;
|
||
this.getLog()
|
||
// 解析缓存物模型
|
||
this.thingsModel = this.deviceInfo.cacheThingsModel;
|
||
}
|
||
},
|
||
immediate: true
|
||
}
|
||
},
|
||
created() {
|
||
// this.query.serialNumber=this.device.serialNumber
|
||
// this.getLog()
|
||
getDict("iot_device_log_type").then(res => {
|
||
this.logTypeList = res
|
||
})
|
||
},
|
||
filters: {
|
||
transformName(val, logTypeList) {
|
||
let name = ""
|
||
logTypeList.forEach((item, index) => {
|
||
if (item.value == val) {
|
||
name = item.name
|
||
}
|
||
})
|
||
return name
|
||
}
|
||
},
|
||
methods: {
|
||
getLog(e) {
|
||
if (e) {
|
||
this.query.pageNum = e.current
|
||
uni.$u.http.get('/iot/deviceLog/list', {
|
||
params: {
|
||
...this.query
|
||
}
|
||
}).then(res => {
|
||
this.logList = res.rows
|
||
this.total = res.total
|
||
})
|
||
} else {
|
||
uni.$u.http.get('/iot/deviceLog/list', {
|
||
params: {
|
||
...this.query
|
||
}
|
||
}).then(res => {
|
||
this.logList = res.rows
|
||
this.total = res.total
|
||
})
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.pagination {
|
||
background-color: #fff;
|
||
padding: 20rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
</style> |