From 7984e0d8cebf4179f7ee3e2046207edd12398cf6 Mon Sep 17 00:00:00 2001
From: quanyawei <401863037@qq.com>
Date: Thu, 09 Nov 2023 14:47:09 +0800
Subject: [PATCH] fix:小程序详情修改
---
pages/actionChange/secondLevelData/index.vue | 247 +++++++++++++++++++++++++++++--------------------
1 files changed, 145 insertions(+), 102 deletions(-)
diff --git a/pages/actionChange/secondLevelData/index.vue b/pages/actionChange/secondLevelData/index.vue
index e6b8a30..0b640e4 100644
--- a/pages/actionChange/secondLevelData/index.vue
+++ b/pages/actionChange/secondLevelData/index.vue
@@ -1,41 +1,61 @@
<template>
<view class="rootBg">
<view class="">
- <view class="ridoa">
+ <view class="ridoaBox">
<u-radio-group v-model="value" placement="row" :size='radioOption.size'
:labelColor='radioOption.labelColor' :labelSize='radioOption.labelSize' @change='changeSearchType'>
- <u-radio activeColor="#19be6b" label="������������������" name="0" :labelSize='radioOption.labelSize'
+ <u-radio activeColor="#19be6b" label="Mac���/������������" name="1" :labelSize='radioOption.labelSize'
:labelColor='radioOption.labelColor'></u-radio>
- <u-radio activeColor="#19be6b" label="������������������" name="1" :labelSize='radioOption.labelSize'
+ <u-radio activeColor="#19be6b" label="������" name="0" :labelSize='radioOption.labelSize'
+ :labelColor='radioOption.labelColor'></u-radio>
+ <u-radio activeColor="#19be6b" label="������������" name="2" :labelSize='radioOption.labelSize'
:labelColor='radioOption.labelColor'></u-radio>
</u-radio-group>
</view>
<view class="" v-if="value==='1'">
- <u-input placeholder="���������Mac���" :placeholderStyle='placeholderStyle' color="#fff" v-model='macName'>
+ <u-input placeholder="���������Mac���/������������" :placeholderStyle='placeholderStyle' color="#fff"
+ customStyle="margin: 0 5px;" v-model='macName'>
<template slot="suffix">
<u-button @tap="searchMacList" text="������" type="success" size="small"></u-button>
</template>
</u-input>
</view>
- <view class="" v-else>
+ <view class="orgSearch" v-else-if="value==='0'">
<u-form ref="uForm" label-width="80" :model="form">
<u-form-item border-bottom @click="showeEscalationTime = true ;hideKeyboard('orgName','orgId')">
- <u-input v-model="form.orgName" disabled disabled-color="#ffffff" placeholder="���������������"
- type="select" />
+ <u-input v-model="form.orgName" disabled disabled-color="#ffffff" customStyle="margin: 0 5px;"
+ placeholder="���������������" type="select" />
</u-form-item>
<u-form-item border-bottom @click="selectSite">
- <u-input v-model="form.siteName" disabled disabled-color="#ffffff" placeholder="���������������"
- type="select" />
+ <u-input v-model="form.siteName" disabled disabled-color="#ffffff" customStyle="margin: 0 5px;"
+ placeholder="���������������" type="select" />
+ </u-form-item>
+ </u-form>
+ <u-picker :show="showeEscalationTime" :columns="columns" @confirm="selectBack" keyName="name"
+ @cancel="showeEscalationTime = false"></u-picker>
+ </view>
+ <view class="" v-else-if="value==='2'">
+ <u-form ref="uForm" label-width="80" :model="form">
+ <u-form-item border-bottom @click="selecSpecial">
+ <u-input v-model="form.specialName" disabled disabled-color="#ffffff"
+ customStyle="margin: 0 5px;" placeholder="���������������" type="select" />
</u-form-item>
</u-form>
<u-picker :show="showeEscalationTime" :columns="columns" @confirm="selectBack" keyName="name"
@cancel="showeEscalationTime = false"></u-picker>
</view>
</view>
- <view v-if="wsData2">
- <u-cell title="���������" :value="windDirData"></u-cell>
+ <view class="timeStyle">
+ {{currentTime}}
+ </view>
+ <view>
+ <u-cell title="������:" :value="orgMacName"></u-cell>
</view>
<view class="boxPadd">
+ <view class="windDirBox" v-if="showData.length>0">
+ <view class=""> ��������� </view>
+ <view class=""> {{windDirData}} </view>
+ </view>
<u-list v-if="showData.length>0">
<u-list-item v-for="(item, index) in showData" :key="index">
<u-row customStyle="margin-bottom: 10px">
@@ -52,16 +72,18 @@
</u-list-item>
</u-list>
</view>
- <u-toast ref="uToast"></u-toast>
<u-modal :show="showModel" title='���������Mac���' showCancelButton @cancel='showModel=false' @confirm='selectMac'>
<view class="slot-content">
- <u-radio-group v-model="modeleMacSelect" iconPlacement="right" placement='column' borderBottom='true'>
+ <u-radio-group v-model="modeleMacSelect" iconPlacement="right" placement='column' borderBottom='true'
+ @change='clickMac'>
<view v-for="(item,index) in macList" :key="index" class="ridioBox">
- <u-radio activeColor="#19be6b" :label="item.mac" :name="item.mac"></u-radio>
+ <u-radio activeColor="#19be6b" :label="`${item.typeName}: ${item.name} \\n Mac���:${item.mac}`"
+ :name="item.mac"></u-radio>
</view>
</u-radio-group>
</view>
</u-modal>
+ <u-toast ref="uToast"></u-toast>
</view>
</template>
<script>
@@ -71,7 +93,7 @@
data() {
return {
modeleMacSelect: '',
- value: '0',
+ value: '1',
showModel: false,
showeEscalationTime: false,
columns: [],
@@ -79,7 +101,9 @@
orgName: '',
orgId: '',
siteName: '',
- siteId: ''
+ siteId: '',
+ specialName: '',
+ specialid: ''
},
selectForm: {
name: '',
@@ -89,10 +113,11 @@
radioOption: {
size: '20px',
labelColor: '#fff',
- labelSize: '18px'
+ labelSize: '18px',
},
placeholderStyle: 'color: #fff',
macName: '',
+ orgMacName: '',
defaultMonitorItems: [],
chartSensorKey: [],
coreMonitorItems: [],
@@ -101,7 +126,7 @@
alarmLevel: null,
aqi: 0,
baseUrl: '',
- windDir: 'null',
+ windDir: '',
windDeg: 180,
wsData2: null,
// ���������������
@@ -111,7 +136,9 @@
// ������������������
alarmBg: {},
timer: '',
- isLoading: true
+ currentTime: new Date(),
+ isLoading: true,
+ specialType: '3'
}
},
filters: {
@@ -123,19 +150,19 @@
},
computed: {
windDirData() {
- if (this.wsData2) {
- console.log('this.windDir', this.windDir)
+ if (this.wsData2 && this.windDir) {
return `${this.windDir} (${this.wsData2.a01008})`
} else {
return ''
}
},
showData() {
- return [...this.defaultMonitorItems, ...this.coreMonitorItems]
+ return [...this.coreMonitorItems, ...this.defaultMonitorItems]
}
},
created() {
this.getOrgs()
+ this.getTime()
},
onUnload() {
let that = this
@@ -144,19 +171,48 @@
that.timer = ''
},
methods: {
+ getTime() {
+ var _this = this // ������������������������Vue������this������������������������
+ this.timer = setInterval(function() {
+ _this.currentTime = // ������������date
+ _this.appendZero(new Date().getFullYear()) + '-' + _this.appendZero(new Date().getMonth() +
+ 1) + '-' + _this.appendZero(new Date().getDate()) + ' ' + _this.appendZero(new Date()
+ .getHours()) + ': ' + _this.appendZero(new Date().getMinutes()) + ': ' + _this
+ .appendZero(new Date().getSeconds())
+ }, 1000)
+ },
+ appendZero(obj) {
+ return obj < 10 ? '0' + obj : obj
+ },
+ clickMac(e) {
+ this.macName = ''
+ this.orgMacName = ''
+ this.specialType = this.macList.find(item => item.mac === e).specialType
+ console.log('specialType', this.specialType)
+ },
getData() {
this.queryAlarmByMac()
this.getHourlyAqi()
this.sensorLayout()
},
changeSearchType() {
- this.macName = ''
+ if (this.value === '2') {
+ this.getSpeciallist()
+ }
+ if (this.value === '0') {
+ this.getOrgs()
+ }
+ if (this.value === '1') {
+ this.macName = ''
+ }
},
selectMac() {
this.macName = this.modeleMacSelect
+ this.orgMacName = this.macList.find(item => item.mac === this.modeleMacSelect).name
+ console.log('this.orgMacName', this.orgMacName)
this.showModel = false
if (this.socketTask) {
- this.socketTask.onClose()
+ this.socketTask.close()
}
this.getData()
},
@@ -164,9 +220,13 @@
this.$http.httpGet('/AppDevice/fuzzySearch', {
mac: this.macName
}).then(res => {
- this.showModel = true
- if (res.data && res.data.length > 10) {
- this.macList = res.data.slice(0, 10)
+ this.macList = []
+ this.modeleMacSelect = ''
+ if (res.data && res.data.length > 0) {
+ this.macList = res.data
+ this.showModel = true
+ } else {
+ uni.$u.toast('������������')
}
}).catch(res => {
uni.$u.toast(res)
@@ -186,6 +246,13 @@
this.getSites()
}
},
+ selecSpecial() {
+ this.selectForm = {
+ name: 'specialName',
+ id: 'specialId'
+ }
+ this.showeEscalationTime = true
+ },
hideKeyboard(name, id) {
this.selectForm = {
'name': name,
@@ -203,13 +270,16 @@
}
} else {
this.macName = e.value[0].mac
+ this.orgMacName = e.value[0].name
+ console.log('e', e)
if (this.socketTask) {
- this.socketTask.onClose()
+ this.socketTask.close()
}
this.getData()
}
this.form[this.selectForm.name] = e.value[0].name
this.form[this.selectForm.id] = e.value[0].id
+ this.specialType = e.value[0].specialType
this.showeEscalationTime = false
},
getOrgs() {
@@ -222,16 +292,14 @@
},
getSites() {
let params = {
- organizationId: this.form.orgId
+ monitorPointId: this.form.orgId
}
this.$http.httpGet('/AppDevice/selectDevice', params).then(res => {
- console.log(res)
this.columns = []
this.columns.push(res.data)
this.showeEscalationTime = true
}).catch(res => {
uni.$u.toast(res)
- console.log(res)
})
},
sensorLayout() {
@@ -245,8 +313,21 @@
this.fixedMonitorItems = res.data.fixedMonitorItems
this.totalArray.push(...this.coreMonitorItems, ...this.defaultMonitorItems, ...this
.fixedMonitorItems)
- this.getSensorMonthAvg()
- this.connectSocket()
+ if (this.chartSensorKey.length > 0) {
+ this.getSensorMonthAvg()
+ this.connectSocket()
+ } else {
+ uni.$u.toast('������������')
+ }
+ }).catch(res => {
+ uni.$u.toast(res)
+ })
+ },
+ // ������������������
+ getSpeciallist() {
+ this.$http.httpGet('/AppDevice/specialDevice').then(res => {
+ this.columns = []
+ this.columns.push(res.data)
}).catch(res => {
uni.$u.toast(res)
console.log(res)
@@ -418,8 +499,6 @@
this.totalArray[i].alarm = this.alarmProgress[key]
}
}
- console.log('this.totalArray', this.totalArray)
- console.log('this.alarmColour', this.alarmColour)
for (const key in this.alarmColour) {
if (this.totalArray[i].sensorCode === key) {
this.totalArray[i].colour = this.alarmColour[key]
@@ -434,15 +513,18 @@
},
//������websocket
connectSocket() {
- if (!this.isLoading) {
+ if (this.socketTask) {
this.socketTask.close()
this.socketTask = null
}
this.baseUrl = this.$storage.get('baseUrl')
let that = this
let socketUrl = this.baseUrl + '/singleDevice/' + this.macName
+ if (this.specialType === '0') {
+ socketUrl = this.baseUrl + '/cruiserWebsocket/' + this.macName
+ }
socketUrl = socketUrl.replace('https', 'wss').replace('http', 'ws')
- console.log('������������websocket')
+ console.log('������������websocket', socketUrl)
this.socketTask = uni.connectSocket({
url: socketUrl,
success(res) {
@@ -463,77 +545,16 @@
console.log('������������������������' + res.data)
that.handlerMsg(res) //������������������������������������������
})
- this.socketTask.onError(function(res) {
- console.log('WebSocket���������������������������������')
- console.log(res)
- // this.isSuccess = false
- // that.connectSocket()
- //������������������
- that.reconnect()
- })
// // ������������������ -
this.socketTask.onClose(e => {
console.log('WebSocket���������������')
- clearInterval(that.timer)
- that.timer = ''
- if (!that.isClose) {
- that.reconnect()
- }
})
console.log(this.socketTask)
- },
- //������������������
- reconnect() {
- console.log('������������������')
- this.socketTask.close()
- this.socketTask = null
- if (this.isLoading) {
- this.connectSocket()
- }
- },
- //������������
- sendSocketMessage(msg) {
- console.log('������������')
- console.log(msg)
- return new Promise((reslove, reject) => {
- this.socketTask.send({
- data: msg,
- success(res) {
- console.log('������������')
- reslove(res)
- },
- fail(res) {
- console.log('������������')
- console.log(res)
- reject(res)
- }
- })
- })
- },
- //������
- heart() {
- let that = this
- clearInterval(this.timer)
- this.timer = ''
- let msg = {
- 'type': 'heartbeat',
- }
- this.timer = setInterval(() => {
- that.sendSocketMessage(JSON.stringify(msg)).then(res => {
- console.log('������������')
- }).catch(res => {
- console.log('������������')
- console.log((res))
- })
- }, 2000)
},
beforeDestroy() {
if (this.socketTask) {
this.socketTask.close()
this.socketTask = null
- }
- if (this.timer) {
- clearInterval(this.timer) // ���Vue������������������������������������������
}
},
}
@@ -566,7 +587,7 @@
justify-content: center;
}
- .ridoa {
+ .ridoaBox {
text-align: center;
padding: 10px 0px;
}
@@ -575,9 +596,11 @@
color: #fff;
}
- /deep/.u-form {
- display: flex;
- justify-content: space-evenly;
+ .orgSearch {
+ /deep/.u-form {
+ display: flex;
+ justify-content: space-evenly;
+ }
}
.slot-content {
@@ -593,4 +616,24 @@
.ridioBox {
margin-bottom: 10px;
}
+
+ /deep/.u-modal__content {
+ max-height: 300px;
+ overflow: auto;
+ }
+
+ .windDirBox {
+ display: flex;
+ justify-content: space-between;
+ padding: 5px;
+ margin-bottom: 5px;
+ border-bottom: 1px solid;
+ }
+
+ .timeStyle {
+ text-align: center;
+ margin: 5px;
+ font-size: 18px;
+ color: #ef9790;
+ }
</style>
\ No newline at end of file
--
Gitblit v1.8.0