1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
| import { fetchDevices, fetchDeviceStatus } from '../../../../services/inspection/fetchDevice';
|
| /**
| * 设备信息管理
| */
| export const useDeviceList = Behavior({
| data: {
| sideBarIndex: 0,
| categories: [
| {
| label: '监测设备',
| type: 0,
| badgeProps: {},
| items: [],
| },
| {
| label: '治理设备',
| type: 1,
| badgeProps: {},
| items: [],
| },
| {
| label: '生产设备',
| type: 2,
| badgeProps: {},
| items: [],
| },
| ],
| },
| 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) {
| const { type } = e.currentTarget.dataset;
| const { scene } = this.data;
| wx.navigateTo({
| url: `/pages/inspection/scene/info/device-info/index`,
| success: function (res) {
| // 通过 eventChannel 向被打开页面传送数据
| res.eventChannel.emit('acceptDeviceData', {
| type,
| scene,
| 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)
| },
| },
| });
| }
| },
| });
|
|