接口对接修改
This commit is contained in:
@@ -1,44 +1,22 @@
|
||||
<template>
|
||||
<Cn-page :loading='loading' noPadding>
|
||||
<view slot='body'>
|
||||
<view class='detail'>
|
||||
<Cn-page :loading="loading" noPadding>
|
||||
<view slot="body">
|
||||
<view class="detail">
|
||||
<view class="detail-header">
|
||||
<Cn-htmlToImg domId="header" @renderFinish="renderFinish">
|
||||
<view class="header" ref="header" @click="previewImg">
|
||||
<img src="http://ruuf2hujc.bkt.clouddn.com/%E7%94%B5%E8%B7%AF%E5%9B%BE.svg"
|
||||
style="width: 100%;height:475rpx;object-fit:cover" />
|
||||
<view class="point" :style="{ left: '480rpx', top: '80rpx' }">负载THDI(%)
|
||||
<view class="grid-card mt10">
|
||||
<view class="grid-card-content-2">
|
||||
<view class="item">L1</view>
|
||||
<view class="item">
|
||||
558.2
|
||||
</view>
|
||||
<view class="item">L2</view>
|
||||
<view class="item">
|
||||
883.7
|
||||
</view>
|
||||
<view class="item">L3</view>
|
||||
<view class="item">
|
||||
403.4
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="point" :style="{ left: '200rpx', top: '80rpx' }">电网THDI(%)
|
||||
<view class="grid-card mt10">
|
||||
<view class="grid-card-content-2">
|
||||
<view class="item">L1</view>
|
||||
<view class="item">
|
||||
55.3
|
||||
</view>
|
||||
<view class="item">L2</view>
|
||||
<view class="item">
|
||||
61.4
|
||||
</view>
|
||||
<view class="item">L3</view>
|
||||
<view class="item">
|
||||
55.2
|
||||
<image :src="deviceInfo.filePath" style="width: 375px" mode="widthFix" />
|
||||
<view
|
||||
class="point"
|
||||
:style="{ left: item.lat + 'px', top: item.lng + 'px' }"
|
||||
v-for="(item, index) in showtTarget"
|
||||
:key="index"
|
||||
>
|
||||
<view class="grid-card mt10" style="width: fit-content">
|
||||
<view class="grid-card-content-1">
|
||||
<view class="item">{{ item.label }}</view>
|
||||
<view class="item" v-for="(child, childIndex) in item.value" :key="childIndex">
|
||||
{{ child.showText }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -49,42 +27,26 @@
|
||||
<view class="item">模块一</view>
|
||||
<view class="item">
|
||||
<view class="status-point-success mr10"></view>
|
||||
<view style="width:30rpx">
|
||||
15
|
||||
</view>
|
||||
<view>
|
||||
°C
|
||||
</view>
|
||||
<view style="width: 30rpx"> 15 </view>
|
||||
<view> °C </view>
|
||||
</view>
|
||||
<view class="item">模块二</view>
|
||||
<view class="item">
|
||||
<view class="status-point-error mr10"></view>
|
||||
<view style="width:30rpx">
|
||||
0
|
||||
</view>
|
||||
<view>
|
||||
°C
|
||||
</view>
|
||||
<view style="width: 30rpx"> 0 </view>
|
||||
<view> °C </view>
|
||||
</view>
|
||||
<view class="item">模块三</view>
|
||||
<view class="item">
|
||||
<view class="status-point-success mr10"></view>
|
||||
<view style="width:30rpx">
|
||||
15
|
||||
</view>
|
||||
<view>
|
||||
°C
|
||||
</view>
|
||||
<view style="width: 30rpx"> 15 </view>
|
||||
<view> °C </view>
|
||||
</view>
|
||||
<view class="item">模块四</view>
|
||||
<view class="item">
|
||||
<view class="status-point-success mr10"></view>
|
||||
<view style="width:30rpx">
|
||||
15
|
||||
</view>
|
||||
<view>
|
||||
°C
|
||||
</view>
|
||||
<view style="width: 30rpx"> 15 </view>
|
||||
<view> °C </view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -95,43 +57,56 @@
|
||||
<text>设备基础信息</text>
|
||||
<text class="ml10">设备状态</text>
|
||||
</view> -->
|
||||
<view class="nav" style="margin-top:-10rpx">
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': navMenuActive == index }"
|
||||
v-for="(item, index) in navMenuList" :key="index" @click="navMenuClick(index)">{{ item.text }}
|
||||
<view class="nav" style="margin-top: -10rpx">
|
||||
<view
|
||||
class="nav-menu"
|
||||
:class="{ 'nav-menu-active': navMenuActive == index }"
|
||||
v-for="(item, index) in navMenuList"
|
||||
:key="index"
|
||||
@click="navMenuClick(index)"
|
||||
>{{ item.text }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view v-if="navMenuActive == 0">
|
||||
<basic></basic>
|
||||
<basic :deviceInfo="deviceInfo"></basic>
|
||||
</view>
|
||||
<view v-else-if="navMenuActive == 1">
|
||||
<xieBo></xieBo>
|
||||
</view>
|
||||
<view v-else-if="navMenuActive == 2">
|
||||
<power></power>
|
||||
<power :deviceInfo="deviceInfo"></power>
|
||||
</view>
|
||||
<view v-else-if="navMenuActive == 3">
|
||||
<oscillogram></oscillogram>
|
||||
</view>
|
||||
<view v-else-if="navMenuActive == 4">
|
||||
<IO></IO>
|
||||
<IO :deviceInfo="deviceInfo"></IO>
|
||||
</view>
|
||||
<view style="height:20rpx"></view>
|
||||
<view style="height: 20rpx"></view>
|
||||
</view>
|
||||
<uni-fab ref="fab" direction="vertical" horizontal="right" vertical="bottom" :content="content"
|
||||
@trigger="trigger" />
|
||||
<uni-fab
|
||||
ref="fab"
|
||||
direction="vertical"
|
||||
horizontal="right"
|
||||
vertical="bottom"
|
||||
:content="content"
|
||||
@trigger="trigger"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import basic from "./comp/basic.vue";
|
||||
import xieBo from "./comp/xieBo.vue";
|
||||
import power from "./comp/power.vue";
|
||||
import oscillogram from "./comp/oscillogram.vue";
|
||||
import IO from "./comp/IO.vue";
|
||||
|
||||
import basic from './comp/basic.vue'
|
||||
import xieBo from './comp/xieBo.vue'
|
||||
import power from './comp/power.vue'
|
||||
import oscillogram from './comp/oscillogram.vue'
|
||||
import IO from './comp/IO.vue'
|
||||
import { queryTopologyDiagram } from '@/common/api/device'
|
||||
import { MQTT_IP, MQTT_OPTIONS } from '@/common/js/mqtt.js'
|
||||
import mqtt from 'mqtt/dist/mqtt.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -141,39 +116,67 @@ export default {
|
||||
oscillogram,
|
||||
IO,
|
||||
},
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
loading: true,
|
||||
deviceInfo: {},
|
||||
navMenuActive: 0,
|
||||
navHeight: 0,
|
||||
img: '',
|
||||
navMenuList: [{
|
||||
text: '基本'
|
||||
}, {
|
||||
text: '谐波'
|
||||
}, {
|
||||
text: '功率'
|
||||
}, {
|
||||
text: '波形'
|
||||
}, {
|
||||
text: 'I/O'
|
||||
}],
|
||||
content: [{
|
||||
iconPath: '/static/report.png',
|
||||
text: '告警',
|
||||
}, {
|
||||
iconPath: '/static/record.png',
|
||||
text: '记录',
|
||||
}, {
|
||||
iconPath: '/static/about.png',
|
||||
text: '关于',
|
||||
},
|
||||
]
|
||||
navMenuList: [
|
||||
{
|
||||
text: '基本',
|
||||
},
|
||||
{
|
||||
text: '谐波',
|
||||
},
|
||||
{
|
||||
text: '功率',
|
||||
},
|
||||
{
|
||||
text: '波形',
|
||||
},
|
||||
{
|
||||
text: 'I/O',
|
||||
},
|
||||
],
|
||||
content: [
|
||||
{
|
||||
iconPath: '/static/report.png',
|
||||
text: '告警',
|
||||
},
|
||||
{
|
||||
iconPath: '/static/record.png',
|
||||
text: '记录',
|
||||
},
|
||||
{
|
||||
iconPath: '/static/about.png',
|
||||
text: '关于',
|
||||
},
|
||||
],
|
||||
client: null,
|
||||
timer: null,
|
||||
devId: '',
|
||||
dictData: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
showtTarget() {
|
||||
if (this.loading) {
|
||||
return
|
||||
}
|
||||
let arr = JSON.parse(JSON.stringify(this.deviceInfo.appsLineTopologyDiagramPO))
|
||||
arr.forEach((item) => {
|
||||
item.value = item.value?.filter((item2) => {
|
||||
return item2.showText
|
||||
})
|
||||
})
|
||||
return arr
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
trigger (e) {
|
||||
console.log(e);
|
||||
trigger(e) {
|
||||
console.log(e)
|
||||
if (e.item.text === '分享') {
|
||||
this.$refs.share.open()
|
||||
} else if (e.item.text === '删除') {
|
||||
@@ -186,8 +189,8 @@ export default {
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
})
|
||||
} else if (e.item.text === '下载') {
|
||||
this.$util.toast('下载成功')
|
||||
} else if (e.item.text === '记录') {
|
||||
@@ -211,100 +214,215 @@ export default {
|
||||
}
|
||||
this.$refs.fab.close()
|
||||
},
|
||||
navMenuClick (idx) {
|
||||
navMenuClick(idx) {
|
||||
this.navMenuActive = idx
|
||||
uni.pageScrollTo({ scrollTop: 0, duration: 0 })
|
||||
},
|
||||
init () {
|
||||
init() {
|
||||
let userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
|
||||
console.log(userInfo.authorities);
|
||||
console.log(userInfo.authorities)
|
||||
switch (userInfo.authorities) {
|
||||
case 1:
|
||||
this.content.splice(0, 1)
|
||||
this.content.splice(0, 0, {
|
||||
iconPath: '/static/version.png',
|
||||
text: '版本',
|
||||
}, {
|
||||
iconPath: '/static/template.png',
|
||||
text: '模版',
|
||||
})
|
||||
break;
|
||||
this.content.splice(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
iconPath: '/static/version.png',
|
||||
text: '版本',
|
||||
},
|
||||
{
|
||||
iconPath: '/static/template.png',
|
||||
text: '模版',
|
||||
},
|
||||
)
|
||||
break
|
||||
case 2:
|
||||
this.content.splice(0, 1)
|
||||
break;
|
||||
break
|
||||
case 3:
|
||||
this.content.splice(0, 0, {
|
||||
iconPath: '/static/transfer.png',
|
||||
text: '移交',
|
||||
})
|
||||
break;
|
||||
break
|
||||
case 4:
|
||||
this.content.splice(1, 0, {
|
||||
iconPath: '/static/delate.png',
|
||||
text: '报表',
|
||||
}, {
|
||||
iconPath: '/static/table.png',
|
||||
text: '删除',
|
||||
}, {
|
||||
iconPath: '/static/feedback.png',
|
||||
text: '反馈',
|
||||
})
|
||||
break;
|
||||
this.content.splice(
|
||||
1,
|
||||
0,
|
||||
{
|
||||
iconPath: '/static/delate.png',
|
||||
text: '报表',
|
||||
},
|
||||
{
|
||||
iconPath: '/static/table.png',
|
||||
text: '删除',
|
||||
},
|
||||
{
|
||||
iconPath: '/static/feedback.png',
|
||||
text: '反馈',
|
||||
},
|
||||
)
|
||||
break
|
||||
case 5:
|
||||
this.content.splice(2, 0, {
|
||||
iconPath: '/static/table.png',
|
||||
text: '报表',
|
||||
}, {
|
||||
iconPath: '/static/feedback.png',
|
||||
text: '反馈',
|
||||
})
|
||||
break;
|
||||
this.content.splice(
|
||||
2,
|
||||
0,
|
||||
{
|
||||
iconPath: '/static/table.png',
|
||||
text: '报表',
|
||||
},
|
||||
{
|
||||
iconPath: '/static/feedback.png',
|
||||
text: '反馈',
|
||||
},
|
||||
)
|
||||
break
|
||||
default:
|
||||
break;
|
||||
|
||||
break
|
||||
}
|
||||
setTimeout(() => {
|
||||
// 获取nav高度
|
||||
uni.createSelectorQuery().select('.nav').boundingClientRect((rect) => {
|
||||
this.navHeight = rect.height
|
||||
}).exec()
|
||||
}, 1000);
|
||||
},
|
||||
renderFinish (e) {
|
||||
renderFinish(e) {
|
||||
this.img = e
|
||||
},
|
||||
previewImg () {
|
||||
previewImg() {
|
||||
if (!this.img) {
|
||||
uni.showLoading({
|
||||
title: '图片生成中',
|
||||
mask: false
|
||||
mask: false,
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.previewImg()
|
||||
}, 500);
|
||||
}, 500)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.previewImage({
|
||||
urls: [this.img],
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
initMqtt() {
|
||||
MQTT_OPTIONS.clientId = uni.getStorageSync('devCode')
|
||||
// #ifdef APP-PLUS
|
||||
this.client = mqtt.connect('wx://' + MQTT_IP, MQTT_OPTIONS)
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
this.client = mqtt.connect('ws://' + MQTT_IP, MQTT_OPTIONS)
|
||||
// #endif
|
||||
this.client
|
||||
.on('connect', () => {
|
||||
console.log('连接成功')
|
||||
this.client.subscribe(`/zl/devData/${this.devId}`, (err) => {
|
||||
if (!err) {
|
||||
console.log(`订阅成功:/zl/devData/${this.devId}`)
|
||||
this.client.publish(`/zl/askDevData/${this.devId}`)
|
||||
this.timer = setInterval(() => {
|
||||
this.client.publish(`/zl/askDevData/${this.devId}`)
|
||||
}, 10000)
|
||||
}
|
||||
})
|
||||
})
|
||||
.on('reconnect', function (error) {
|
||||
console.log(error)
|
||||
console.log('正在重连...', that.topic)
|
||||
})
|
||||
.on('error', function (error) {
|
||||
console.log('连接失败...', error)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.log('连接断开')
|
||||
})
|
||||
.on('message', (topic, message) => {
|
||||
console.log('接收推送信息:', message.toString())
|
||||
this.loading = false
|
||||
let dataList = []
|
||||
this.deviceInfo.appsLineTopologyDiagramPO.forEach((element) => {
|
||||
element.value = []
|
||||
})
|
||||
JSON.parse(message.toString()).forEach((item) => {
|
||||
this.deviceInfo.appsLineTopologyDiagramPO.forEach((element) => {
|
||||
if (element.linePostion === item.position) {
|
||||
// element.value.push({
|
||||
// label: item.statisticalName,
|
||||
// value: item.statisticalData,
|
||||
// })
|
||||
element.value.push({
|
||||
...item,
|
||||
showText:
|
||||
item.statisticalName.indexOf('ThdPh') > -1 && item.phase === 'avg'
|
||||
? item.statisticalName + ':' + item.statisticalData
|
||||
: '',
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
this.$forceUpdate()
|
||||
console.log(this.deviceInfo.appsLineTopologyDiagramPO)
|
||||
})
|
||||
},
|
||||
},
|
||||
onLoad (options) {
|
||||
// 页面销毁
|
||||
onUnload() {
|
||||
clearInterval(this.timer)
|
||||
this.client.end()
|
||||
},
|
||||
onLoad(options) {
|
||||
this.dictData = uni.getStorageSync(this.$cacheKey.dictData)
|
||||
this.devId = options.id
|
||||
this.init()
|
||||
queryTopologyDiagram(options.id).then((res) => {
|
||||
this.deviceInfo = res.data
|
||||
console.log(this.dictData);
|
||||
this.dictData.forEach((item) => {
|
||||
if (item.code == 'Line_Position') {
|
||||
item.children.forEach((item2) => {
|
||||
this.deviceInfo.appsLineTopologyDiagramPO.forEach((element) => {
|
||||
if (element.linePostion === item2.id) {
|
||||
element.label = item2.name
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
this.initMqtt()
|
||||
console.log(this.loading, 'loading')
|
||||
// this.$nextTick(() => {
|
||||
// // 获取nav高度
|
||||
// uni.createSelectorQuery()
|
||||
// .select('.nav')
|
||||
// .boundingClientRect((rect) => {
|
||||
// this.navHeight = rect.height
|
||||
// })
|
||||
// .exec()
|
||||
// })
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
<style lang="scss">
|
||||
.detail {
|
||||
|
||||
// background: $uni-theme-white;
|
||||
.header-bg {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
.header {
|
||||
position: relative;
|
||||
width: 375px;
|
||||
margin: 0 auto;
|
||||
|
||||
image {
|
||||
image-rendering: -moz-crisp-edges;
|
||||
image-rendering: -o-crisp-edges;
|
||||
image-rendering: -webkit-optimize-contrast;
|
||||
image-rendering: crisp-edges;
|
||||
-ms-interpolation-mode: nearest-neighbor;
|
||||
}
|
||||
.point {
|
||||
position: absolute;
|
||||
color: #111;
|
||||
@@ -314,11 +432,13 @@ export default {
|
||||
width: 110rpx;
|
||||
font-size: 16rpx;
|
||||
|
||||
.grid-card-content-2 {
|
||||
.grid-card-content-2,
|
||||
.grid-card-content-1 {
|
||||
font-size: 16rpx;
|
||||
|
||||
.item {
|
||||
min-height: unset;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,7 +449,8 @@ export default {
|
||||
right: 20rpx;
|
||||
width: 200rpx;
|
||||
|
||||
.grid-card-content-2 {
|
||||
.grid-card-content-2,
|
||||
.grid-card-content-1 {
|
||||
font-size: 16rpx;
|
||||
|
||||
.item {
|
||||
@@ -348,7 +469,6 @@ export default {
|
||||
.content {
|
||||
box-sizing: border-box;
|
||||
padding: 0 20rpx;
|
||||
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
@@ -358,6 +478,5 @@ export default {
|
||||
z-index: 2;
|
||||
background: #f3f4f5;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user