| | |
| | | import { fetchDevices, fetchDeviceStatus } from '../../../../services/inspection/fetchDevice'; |
| | | |
| | | /** |
| | | * 设备信息管理 |
| | | */ |
| | |
| | | ], |
| | | }, |
| | | methods: { |
| | | fetchDeviceInfo(deviceTypeId) { |
| | | const { scene } = this.data; |
| | | fetchDevices(scene.guid, deviceTypeId).then(res => { |
| | | this.setData({ |
| | | [`categories[${deviceTypeId}].items`]: res.data, |
| | | }); |
| | | }); |
| | | }, |
| | | onSideBarChange(e) { |
| | | const { value } = e.detail; |
| | | this.fetchDeviceInfo(this.data.categories[value].type) |
| | | this.setData({ sideBarIndex: value }); |
| | | }, |
| | | addNewDevice(e) { |
| | |
| | | mode: 'add', |
| | | }); |
| | | }, |
| | | events: { |
| | | updateDeviceInfoOver: () => { |
| | | this.fetchDeviceInfo(this.data.categories[this.data.sideBarIndex].type) |
| | | }, |
| | | }, |
| | | }); |
| | | }, |
| | | updateDevice(e) { |
| | | const { type, index } = e.currentTarget.dataset; |
| | | const { scene, categories } = this.data; |
| | | const [i0, i1] = index; |
| | | const deviceInfo = categories[i0].items[i1]; |
| | | wx.navigateTo({ |
| | | url: `/pages/inspection/scene/info/device-info/index`, |
| | | success: function (res) { |
| | | // 通过 eventChannel 向被打开页面传送数据 |
| | | res.eventChannel.emit('acceptDeviceData', { |
| | | type, |
| | | scene, |
| | | mode: 'update', |
| | | deviceInfo, |
| | | }); |
| | | }, |
| | | events: { |
| | | updateDeviceInfoOver: () => { |
| | | this.fetchDeviceInfo(this.data.categories[this.data.sideBarIndex].type) |
| | | }, |
| | | }, |
| | | }); |
| | | }, |
| | | |
| | | updateStatus(e) { |
| | | const { type, index } = e.currentTarget.dataset; |
| | | const { scene, categories } = this.data; |
| | | const [i0, i1] = index; |
| | | const deviceInfo = categories[i0].items[i1]; |
| | | wx.navigateTo({ |
| | | url: `/pages/inspection/scene/info/device-status/index`, |
| | | success: function (res) { |
| | | // 通过 eventChannel 向被打开页面传送数据 |
| | | res.eventChannel.emit('acceptDeviceStatusData', { |
| | | type, |
| | | scene, |
| | | deviceInfo, |
| | | }); |
| | | }, |
| | | events: { |
| | | updateDeviceStatusOver: () => { |
| | | this.fetchDeviceInfo(this.data.categories[this.data.sideBarIndex].type) |
| | | }, |
| | | }, |
| | | }); |
| | | } |
| | | }, |
| | | }); |