Skip to content

Commit

Permalink
fix(other): 修复设备列表参数不更新
Browse files Browse the repository at this point in the history
  • Loading branch information
h7ml committed Jun 21, 2022
1 parent 93ce252 commit 66ab792
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
21 changes: 12 additions & 9 deletions src/views/DeviceCloud/manage/devicelist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
</el-dialog>
</div>
<el-table
:key="upkey"
ref="tableSort"
v-loading="listLoading"
:border="border"
Expand Down Expand Up @@ -507,6 +508,7 @@
popoverVisible: false,
deciceCompany: '',
bmLabel: false,
upkey: moment(new Date()).valueOf() + '',
mapLabel: {
content: '我爱北京天安门',
style: {
Expand Down Expand Up @@ -1082,19 +1084,20 @@
await this.subAllDevice()
},
async subAllDevice() {
await this.$subscribe('$dg/user/devicestate/#')
this.$dgiotBus.$on('/$dg/user/devicestate', (Msg) => {
console.log('收到消息', Msg)
let _this = this
await _this.$subscribe('$dg/user/devicestate/#')
_this.$dgiotBus.$off(_this.$mqttInfo.topicKey)
_this.$dgiotBus.$on(_this.$mqttInfo.topicKey, (Msg) => {
const parseString = JSON.parse(Msg.payloadString)
console.log('收到消息', parseString)
if (parseString) {
const topicsKeys = Object.keys(parseString)
console.log(topicsKeys)
topicsKeys.forEach((t) => {
this.list.forEach((i) => {
if (i.objectId == t) {
const mergeInfo = _.merge(i, parseString[t])
console.log(`更新设备${i.name}`, mergeInfo)
_this.list.forEach((t) => {
topicsKeys.forEach((j) => {
if (t.objectId == j) {
const mergeInfo = _.merge(t, parseString[j])
console.log(`更新设备${t.name}`, mergeInfo, parseString[j])
_this.upkey = moment(new Date()).valueOf() + ''
}
})
})
Expand Down
21 changes: 12 additions & 9 deletions src/views/DeviceCloud/manage/home_index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
</dgiot-query-form>

<el-table
:key="upkey"
ref="tableSort"
v-loading="listLoading"
border
Expand Down Expand Up @@ -638,6 +639,7 @@
},
data() {
return {
upkey: moment(new Date()).valueOf() + '',
dialog_device: false,
mapLabel: {
content: '我爱北京天安门',
Expand Down Expand Up @@ -1215,19 +1217,20 @@
await this.subAllDevice()
},
async subAllDevice() {
await this.$subscribe('$dg/user/devicestate/#')
this.$dgiotBus.$on('/$dg/user/devicestate', (Msg) => {
console.log('收到消息', Msg)
let _this = this
await _this.$subscribe('$dg/user/devicestate/#')
_this.$dgiotBus.$off(_this.$mqttInfo.topicKey)
_this.$dgiotBus.$on(_this.$mqttInfo.topicKey, (Msg) => {
const parseString = JSON.parse(Msg.payloadString)
console.log('收到消息', parseString)
if (parseString) {
const topicsKeys = Object.keys(parseString)
console.log(topicsKeys)
topicsKeys.forEach((t) => {
this.list.forEach((i) => {
if (i.objectId == t) {
const mergeInfo = _.merge(i, parseString[t])
console.log(`更新设备${i.name}`, mergeInfo)
_this.list.forEach((t) => {
topicsKeys.forEach((j) => {
if (t.objectId == j) {
const mergeInfo = _.merge(t, parseString[j])
console.log(`更新设备${t.name}`, mergeInfo, parseString[j])
_this.upkey = moment(new Date()).valueOf() + ''
}
})
})
Expand Down

0 comments on commit 66ab792

Please sign in to comment.