@ganwei-web/gw-base-components-plus 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1560 @@
1
+ import { createBlock as S, createCommentVNode as d, createElementBlock as l, createElementVNode as q, createTextVNode as k, createVNode as C, mergeProps as $, normalizeClass as G, normalizeStyle as O, openBlock as n, resolveComponent as g, toDisplayString as b, toHandlers as T, withCtx as w, withModifiers as M } from "vue";
2
+ import I from "vue3-virtual-scroll-list";
3
+ import * as x from "@aspnet/signalr";
4
+
5
+ import "./style.css";
6
+ class _ {
7
+ // 分组节点扁平化对象、设备扁平化对象、window缓存设备扁平化对象
8
+ constructor(e, t, i) {
9
+ this.groupNodeObject = e, this.nodesMap = t, this.controlObject = i;
10
+ }
11
+ // 增加映射
12
+ addNodesMap(e) {
13
+ e && e.forEach((t) => {
14
+ this.nodesMap[t.key] = t;
15
+ });
16
+ }
17
+ // 移除映射
18
+ removeNodesMap(e) {
19
+ e && e.forEach((t) => {
20
+ delete this.nodesMap[t.key];
21
+ });
22
+ }
23
+ // 回收所有分组节点缓存
24
+ recycleAllNodeCache(e) {
25
+ for (let t in this.groupNodeObject) { this.groupNodeObject[t].expand = !1, this.groupNodeObject[t].count = 0, this.recycleGroupCache(this.groupNodeObject[t].key), e && delete this.groupNodeObject[t]; }
26
+ }
27
+ // 回收分组节点内存
28
+ recycleGroupCache(e) {
29
+ if (this.groupNodeObject[e]) {
30
+ this.groupNodeObject[e].children = [], this.removeNodesMap(this.groupNodeObject[e].equips), this.groupNodeObject[e].equips = [], this.groupNodeObject[e].equips.length = 0, this.groupNodeObject[e].expand = !1;
31
+ for (let t in this.groupNodeObject) { this.groupNodeObject[t].groupId == e && this.recycleGroupCache(this.groupNodeObject[t].key); }
32
+ }
33
+ }
34
+ // 关闭兄弟分组节点及回收内存
35
+ closeBrotherNode(e) {
36
+ if (e && this.groupNodeObject[e]) {
37
+ let t = this.groupNodeObject[e].groupId;
38
+ for (let i in this.groupNodeObject) { this.groupNodeObject[i].groupId == t && this.groupNodeObject[i].key != e && this.groupNodeObject[i].expand && (this.groupNodeObject[i].expand = !1, this.recycleGroupCache(this.groupNodeObject[i].key)); }
39
+ }
40
+ }
41
+ }
42
+ class N {
43
+ constructor() {
44
+ this.window = window;
45
+ try {
46
+ window.top.equipGroup, this.window = window.top;
47
+ } catch {
48
+ this.window = window;
49
+ }
50
+ }
51
+ }
52
+ const m = {
53
+ data() {
54
+ return {
55
+ window: null
56
+ };
57
+ },
58
+ created() {
59
+ this.window = window;
60
+ try {
61
+ window.top.equipGroup, this.window = window.top;
62
+ } catch {
63
+ this.window = window;
64
+ }
65
+ }
66
+ };
67
+ class L extends N {
68
+ constructor(e, t, i, o, u, a) {
69
+ super(), this.equipControllObject = i, this.groupNodeObject = e, this.nodesMap = t, this.controlObject = o, this.equipCheckObject = u, this.isSearchStatus = !1, this.searchStatusGroupObject = {}, this.aliasName = a;
70
+ }
71
+ resetCheckedStatus() {
72
+ Object.values(this.nodesMap).forEach((e) => {
73
+ this.setCheckStatus(e.key, !1, !1), e.isGroup && !e.isEquip && (this.clearCheckedEquips(e.key), this.updateEquipSelectCount(e.key, !0)), e.halfCheckedEquips && (e.halfCheckedEquips = []);
74
+ }), Object.keys(this.equipCheckObject).forEach((e) => {
75
+ this.setEquipCheckObject(e, !1, !1, this.equipCheckObject[e].groupId);
76
+ });
77
+ }
78
+ // 搜索状态下,更新分组选中状态
79
+ /**
80
+ * 1:备份原有选中的设备数据量,父级分组Id
81
+ * 2:清空之前分组的设备选中数量
82
+ * 3:依照搜索结果,重新计算分组选中的设备数据量
83
+ * */
84
+ reComputedCheckNum(e) {
85
+ this.isSearchStatus = e, this.isSearchStatus ? (Object.values(this.groupNodeObject).forEach((t) => {
86
+ this.searchStatusGroupObject[t.key] = {
87
+ groupId: t.groupId,
88
+ equipSelectCount: t.equipSelectCount,
89
+ halfCheckedEquips: t.halfCheckedEquips,
90
+ ...this.searchStatusGroupObject[t.key]
91
+ };
92
+ }), Object.values(this.groupNodeObject).forEach((t) => {
93
+ this.updateEquipSelectCount(t.key, !0), t.halfCheckedEquips = [];
94
+ }), Object.values(this.groupNodeObject).forEach((t) => {
95
+ (this.window[`group-${t.key}-search`] || []).forEach((o) => {
96
+ this.equipCheckObject[o.equipNo] && this.equipCheckObject[o.equipNo].checked ? this.updateEquipSelectCount(t.key, !1, 1) : this.equipCheckObject[o.equipNo] && this.equipCheckObject[o.equipNo].indeterminate && t.halfCheckedEquips.push(o.equipNo);
97
+ });
98
+ })) : (Object.values(this.groupNodeObject).forEach((t) => {
99
+ let i = this.searchStatusGroupObject[t.key];
100
+ i && (t.equipSelectCount = i.equipSelectCount, t.halfCheckedEquips = [...i.halfCheckedEquips, ...t.halfCheckedEquips], t.halfCheckedEquips = [...new Set(t.halfCheckedEquips)]);
101
+ }), this.searchStatusGroupObject = {});
102
+ }
103
+ // 根据传过来的设备选中数据、回显选中状态
104
+ /**
105
+ * 1:记录进全局设备选中状态
106
+ * 2:设备设备选中状态
107
+ * 3:更新分组选中的设备数量
108
+ * 4:更新展开的设备控制项选中状态
109
+ * 5:更新分组选中状态
110
+ * */
111
+ updateCheckedStatusWithEquips(e) {
112
+ window.setTimeout(() => {
113
+ for (let t = 0, i = e.length; t < i; t++) {
114
+ let o = this.window.equipCache && this.window.equipCache[e[t]];
115
+ o && o.groupId && (this.setEquipCheckObject(e[t], !0, !1, o.groupId), this.setCheckStatus(`${o.groupId}-${e[t]}`, !0, !1), this.updateEquipSelectCount(o.groupId, !1, 1), this.updateExpandControlCheckStatus(o.groupId, e[t]));
116
+ }
117
+ this.updateGroupCheckStatus();
118
+ }, 200);
119
+ }
120
+ // 更新展开的设备控制项选中状态
121
+ updateExpandControlCheckStatus(e, t) {
122
+ let i = this.nodesMap[`${e}-${t}`];
123
+ i && i.settings && i.settings.length && i.settings.forEach((o) => {
124
+ this.nodesMap[`${e}-${t}-${o.setNo}`] && this.setCheckStatus(`${e}-${t}-${o.setNo}`, !0, !1);
125
+ });
126
+ }
127
+ // 根据传过来的设备控制项,回显设备分组选中状态
128
+ /**
129
+ * 1:记录全局设备控制项选中
130
+ * 2:设置设备和设备控制项选中状态
131
+ * 3:记录分组的半选设备
132
+ * 4:记录全局设备半选状态
133
+ * 5:更新分组选中状态
134
+ * */
135
+ updateCheckedStatusWithControls(e) {
136
+ window.setTimeout(() => {
137
+ for (let t = 0, i = e.length; t < i; t++) {
138
+ let o = e[t].split("."), u = o[0], a = o[1];
139
+ if (this.equipControllObject[u] || (this.equipControllObject[u] = []), this.equipControllObject[u].push(Number(a)), this.window.equipCache && this.window.equipCache[u]) {
140
+ let r = this.window.equipCache[u].groupId, h = `${r}-${u}-${a}`;
141
+ this.nodesMap[h] && this.setCheckStatus(h, !0, !1), this.nodesMap[`${r}-${u}`] && this.setCheckStatus(`${r}-${u}`, !1, !0), this.nodesMap[`${r}`].halfCheckedEquips && this.nodesMap[`${r}`].halfCheckedEquips.push(u), this.setEquipCheckObject(u, !1, !0, r);
142
+ }
143
+ }
144
+ this.updateGroupCheckStatus();
145
+ }, 100);
146
+ }
147
+ // 更新分组选中状态
148
+ updateGroupCheckStatus() {
149
+ Object.values(this.groupNodeObject).forEach((e) => {
150
+ e.count > 0 && e.count == e.equipSelectCount ? this.setCheckStatus(e.key, !0, !1) : e.count && e.equipSelectCount && e.count > e.equipSelectCount || e.halfCheckedEquips.length ? this.setGroupHalfChecked(e.key) : this.setCheckStatus(e.key, !1, !1);
151
+ });
152
+ }
153
+ // 设置父级分组半选状态
154
+ setGroupHalfChecked(e) {
155
+ this.nodesMap[e] && this.setCheckStatus(e, !1, !0), this.nodesMap[e].groupId && this.setGroupHalfChecked(this.nodesMap[e].groupId);
156
+ }
157
+ // 设置设备控制项状态
158
+ setControlStatus(e, t, i, o) {
159
+ e && e.forEach((u) => {
160
+ this.nodesMap[`${t}-${i}-${u.setNo}`] && this.setCheckStatus(`${t}-${i}-${u.setNo}`, o, !1);
161
+ });
162
+ }
163
+ // 更新设备控制项选中状态
164
+ updateControlCheckStatus() {
165
+ Object.keys(this.controlObject).forEach((e) => {
166
+ let t = this.nodesMap[`${this.controlObject[e].groupId}-${e}`];
167
+ if (t) {
168
+ if (t.checked) {
169
+ let i = t.settings;
170
+ this.setControlStatus(i, this.controlObject[e].groupId, e, !0);
171
+ } else if (!t.checked && !t.indeterminate) {
172
+ let i = t.settings;
173
+ this.setControlStatus(i, this.controlObject[e].groupId, e, !1);
174
+ } else {
175
+ this.equipControllObject[e] && this.equipControllObject[e].forEach((i) => {
176
+ let o = `${this.controlObject[e].groupId}-${e}-${i}`;
177
+ this.nodesMap[o] && this.setCheckStatus(o, !0, !1);
178
+ });
179
+ }
180
+ }
181
+ });
182
+ }
183
+ // 获取选中的分组
184
+ getGroupChecked() {
185
+ let e = [];
186
+ return Object.keys(this.groupNodeObject).forEach((t) => {
187
+ this.groupNodeObject[t].checked && e.push(t);
188
+ }), e;
189
+ }
190
+ // 获取选中设备
191
+ getEquipSelectd() {
192
+ let e = [];
193
+ return Object.keys(this.equipCheckObject).forEach((t) => {
194
+ this.equipCheckObject[t].checked && e.push(Number(t));
195
+ }), e;
196
+ }
197
+ // 获取选中的设备控制箱
198
+ getControlSelected() {
199
+ let e = [];
200
+ return Object.keys(this.equipControllObject).forEach((t) => {
201
+ e.push(...this.equipControllObject[t].map((i) => `${t}.${i}`));
202
+ }), e;
203
+ }
204
+ // 点击选中
205
+ /**
206
+ * 1:如果是分组选择,触发分组选中事件
207
+ * 2:如果是设备选择,触发设备选中事件
208
+ * 3:如果是设备控制项选择,触发设备控制项选中事件
209
+ * */
210
+ onChecked(e, t) {
211
+ this.isSearchStatus = t || !1, e.isGroup && !e.isEquip ? this.selectGroup(e) : e.isEquip ? this.selectEquip(e) : e.isSetting && this.selectControl(e);
212
+ }
213
+ // 从全局映射中,设置节点选中状态
214
+ setCheckStatus(e, t, i) {
215
+ this.nodesMap[e] && (this.nodesMap[e].checked = t, this.nodesMap[e].isGroup && (this.nodesMap[e].indeterminate = i));
216
+ }
217
+ // 清除选中的设备
218
+ clearCheckedEquips(e) {
219
+ this.groupNodeObject[e] && (this.groupNodeObject[e].equipSelectCount = 0, this.groupNodeObject[e].halfCheckedEquips && this.groupNodeObject[e].halfCheckedEquips.forEach((t) => {
220
+ this.equipControllObject[t] && this.equipControllObject[t].forEach((i) => {
221
+ this.setCheckStatus(`${e}-${t}-${i}`, !1, !1);
222
+ });
223
+ }), this.groupNodeObject[e].halfCheckedEquips = [], this.groupNodeObject[e].groupId && this.clearCheckedEquips(this.groupNodeObject[e].groupId));
224
+ }
225
+ // 搜索状态下,更新分组选中的设备数量
226
+ updateSearchStatusObject(e, t) {
227
+ this.searchStatusGroupObject[e] && (this.searchStatusGroupObject[e].equipSelectCount = this.searchStatusGroupObject[e].equipSelectCount + t, this.searchStatusGroupObject[e].groupId && this.updateSearchStatusObject(this.searchStatusGroupObject[e].groupId, t));
228
+ }
229
+ // 更新分组设备选中数量
230
+ updateEquipSelectCount(e, t, i) {
231
+ this.nodesMap[e] && (t ? this.nodesMap[e].equipSelectCount = 0 : this.nodesMap[e].equipSelectCount = this.nodesMap[e].equipSelectCount + i, this.nodesMap[e].groupId && this.updateEquipSelectCount(this.nodesMap[e].groupId, t, i));
232
+ }
233
+ // 保存全局设备选中状态
234
+ setEquipCheckObject(e, t, i, o) {
235
+ this.equipCheckObject[e] || (this.equipCheckObject[e] = {}), this.equipCheckObject[e].checked = t, this.equipCheckObject[e].indeterminate = i, this.equipCheckObject[e].groupId = o;
236
+ }
237
+ // 更新当前展开的分组所选中的设备、设置分组选中的设备数量、更新选中状态(已经实例化的节点)
238
+ updateEquipSelect(e, t, i, o) {
239
+ this.nodesMap[e] && t.length && t.forEach((u) => {
240
+ i ? (this.setEquipCheckObject(u.equipNo, !0, !1, e), this.nodesMap[`${e}-${u.equipNo}`] && this.setCheckStatus(`${e}-${u.equipNo}`, !0, !1)) : (this.setEquipCheckObject(u.equipNo, !1, !1, e), this.nodesMap[`${e}-${u.equipNo}`] && this.setCheckStatus(`${e}-${u.equipNo}`, !1, !1)), this.equipControllObject[u.equipNo] && delete this.equipControllObject[u.equipNo], this.nodesMap[e].halfCheckedEquips.includes(u.equipNo) && (this.nodesMap[e].halfCheckedEquips = this.nodesMap[e].halfCheckedEquips.filter((a) => a != u.equipNo), this.searchStatusGroupObject[e] && (this.searchStatusGroupObject[e].halfCheckedEquips = this.nodesMap[e].halfCheckedEquips));
241
+ });
242
+ }
243
+ // 根据分组更新选中的设备,全选分组或者取消选择分组时调用
244
+ /**
245
+ * 1:统计需要更新的设备数量
246
+ * 2:把所有子孙分组设备全部统计,并且记录所有当前分组选中的设备,更新除分组之外的选中状态(已经实例化的节点)
247
+ * 3:更新自身设备选择数量、向上级分组累加已经选中的设备数量
248
+ * 4:更新搜索状态下分组副本数据
249
+ * */
250
+ // list(Array):所要更新的分组,type(String):更新类型,add为新增,delete为删除;
251
+ updateGroupSelect(e, t) {
252
+ e.forEach((i) => {
253
+ if (this.groupNodeObject[i]) {
254
+ this.groupNodeObject[i].groups && this.groupNodeObject[i].groups.length > 0 && this.updateGroupSelect(this.groupNodeObject[i].groups.map((h) => h.key), t);
255
+ let o = this.window[`group-${i}${this.aliasName}`] || [];
256
+ this.isSearchStatus && (o = this.window[`group-${i}-search`] || []);
257
+ let u = 0, a = 0;
258
+ o.forEach((h) => {
259
+ let p = this.equipCheckObject[h.equipNo];
260
+ !p || !p.checked ? u++ : a--;
261
+ });
262
+ let r = t ? u : a;
263
+ this.updateEquipSelect(i, o, t, r), console.log(i, !1, r), this.updateEquipSelectCount(i, !1, r), this.updateSearchStatusObject(i, r);
264
+ }
265
+ });
266
+ }
267
+ // 清除分组挂载的半选设备
268
+ clearHalfCheckedEquips(e) {
269
+ e.forEach((t) => {
270
+ this.groupNodeObject[t].halfCheckedEquips && this.groupNodeObject[t].halfCheckedEquips.forEach((i) => {
271
+ this.equipControllObject[i] && this.equipControllObject[i].forEach((o) => {
272
+ this.setCheckStatus(`${t}-${i}-${o}`, !1, !1);
273
+ });
274
+ }), this.groupNodeObject[t].halfCheckedEquips = [], this.groupNodeObject[t].groups && this.groupNodeObject[t].groups.length > 0 && this.clearHalfCheckedEquips(this.groupNodeObject[t].groups.map((i) => i.key));
275
+ });
276
+ }
277
+ // 触发分组选择
278
+ /**
279
+ * 1:清除之前半选设备
280
+ * 2:更新分组中设备选择
281
+ * 3:更新所有分组选中状态
282
+ * 4:更新控制项选中状态
283
+ * */
284
+ selectGroup(e) {
285
+ this.clearHalfCheckedEquips([e.key]), this.updateGroupSelect([e.key], e.checked), this.updateControlCheckStatus(), this.updateGroupCheckStatus();
286
+ }
287
+ // 触发设备选择
288
+ /**
289
+ * 1:更新分组选择的设备
290
+ * 2:更新分组所选择的设备数量
291
+ * 3:更新控制项选中状态
292
+ * 4:更新分组状态
293
+ * */
294
+ selectEquip(e) {
295
+ if (this.nodesMap[e.groupId]) {
296
+ let t = [{ equipNo: e.equipNo }], i = (e.checked ? 1 : -1) * t.length;
297
+ this.updateEquipSelect(e.groupId, t, e.checked, i), this.updateEquipSelectCount(e.groupId, !1, i), this.updateSearchStatusObject(e.groupId, i), this.updateControlCheckStatus(), this.updateGroupCheckStatus();
298
+ }
299
+ }
300
+ // 更新设备控制项存储
301
+ updateEquipControl(e, t, i) {
302
+ this.equipControllObject[e] || (this.equipControllObject[e] = []), i ? this.equipControllObject[e].push(t) : this.equipControllObject[e] = this.equipControllObject[e].filter((o) => o != t);
303
+ }
304
+ // 触发控制项选择
305
+ /**
306
+ * 1:更新设备控制项
307
+ * 2:更新设备选中状态
308
+ (1)选择情况下:
309
+ 1)如果设备即将全选,清除分组中半选设备、清除设备控制项记录(equipControllObject),分组全选设备数组+1,半选设备数组中有则-1,设置设备全选
310
+ 2) 如果之前设备没选择情况下(非半选情况下),分组中半选设备数组+1,设置设备半选
311
+ 3)如果设备是半选状态。不做处理
312
+ (2)取消选择情况下
313
+ 1)如果设备是全选情况下、分组全选设备数组-1
314
+ 1)如果不仅有一个测点,设备半选分组+1,设备控制项(equipControllObject)记录剩余设备,设置设备半选
315
+ 2)如果仅有一个测点,设置设备不选
316
+ 2) 如果设备是半选情况下,如果还是半选,不做处理,如果从半选到不选情况下,分组挂载的半选分组-1,设备控制项有则-1,设置设备不选
317
+ * 3:更新分组状态
318
+ * */
319
+ selectControl(e) {
320
+ let t = this.nodesMap[`${e.groupId}-${e.equipNo}`];
321
+ t && (this.updateEquipControl(e.equipNo, e.setNo, e.checked), e.checked ? t.settings && t.settings.length == this.equipControllObject[e.equipNo].length ? (delete this.equipControllObject[e.equipNo], this.updateEquipSelectCount(e.groupId, !1, 1), this.updateSearchStatusObject(e.groupId, 1), this.nodesMap[e.groupId].halfCheckedEquips = this.nodesMap[e.groupId].halfCheckedEquips.filter((i) => i != e.equipNo), this.setEquipCheckObject(e.equipNo, !0, !1, e.groupId), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !0, !1)) : t && !t.indeterminate && (this.nodesMap[`${e.groupId}`].halfCheckedEquips.push(e.equipNo), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !1, !0), this.setEquipCheckObject(e.equipNo, !1, !0, e.groupId)) : t.checked ? (this.updateEquipSelectCount(e.groupId, !1, -1), this.updateSearchStatusObject(e.groupId, -1), t.settings.length > 1 ? (this.nodesMap[e.groupId].halfCheckedEquips.push(e.equipNo), t.settings.map((o) => o.setNo).filter((o) => o != e.setNo).forEach((o) => {
322
+ this.updateEquipControl(e.equipNo, o, !0);
323
+ }), this.setEquipCheckObject(e.equipNo, !1, !0, e.groupId), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !1, !0)) : (this.setEquipCheckObject(e.equipNo, !1, !1, e.groupId), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !1, !1))) : t.indeterminate && this.equipControllObject[e.equipNo] && !this.equipControllObject[e.equipNo].length && (this.nodesMap[e.groupId].halfCheckedEquips = this.nodesMap[e.groupId].halfCheckedEquips.filter((i) => i != e.equipNo), this.setEquipCheckObject(e.equipNo, !1, !1, e.groupId), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !1, !1)), this.updateGroupCheckStatus());
324
+ }
325
+ }
326
+ class v extends N {
327
+ // 分组节点扁平化对象、设备扁平化对象、window缓存设备扁平化对象
328
+ constructor(e, t) {
329
+ super(), this.aliasName = t, this.groupNodeObject = e;
330
+ }
331
+ // 重新计算分组设备数量
332
+ resetGroupNum(e) {
333
+ this.clearAllEquipNum();
334
+ for (let t in this.groupNodeObject) {
335
+ let i = [];
336
+ e ? i = this.window[`group-${t}-search`] : i = this.window[`group-${t}${this.aliasName}`];
337
+ let o = i ? i.length : 0;
338
+ o && (this.groupNodeObject[t].equipCount = o, this.setGroupNum(t, o));
339
+ }
340
+ }
341
+ clearAllEquipNum() {
342
+ for (let e in this.groupNodeObject) { this.groupNodeObject[e].equipCount = 0, this.groupNodeObject[e].count = 0; }
343
+ }
344
+ // 设置分组设备数量
345
+ setGroupNum(e, t) {
346
+ this.groupNodeObject[e] && (this.groupNodeObject[e].count = Number(this.groupNodeObject[e].count) + Number(t), this.setGroupNum(this.groupNodeObject[e].groupId, t));
347
+ }
348
+ // 获取设备总数
349
+ getAllEquipsNum() {
350
+ let e = 0;
351
+ for (let t in this.groupNodeObject) { this.window[`group-${this.groupNodeObject[t].key}${this.aliasName}`] && (e = e + this.window[`group-${this.groupNodeObject[t].key}${this.aliasName}`].length); }
352
+ return e;
353
+ }
354
+ }
355
+ class y {
356
+ constructor(e, t, i) {
357
+ this.url = e, this.connectionId = t, this.equipNo = i, this.signalr = null;
358
+ }
359
+ openConnect() {
360
+ return this.signalr && (this.signalr.stop(), this.signalr = null), this.signalr = new x.HubConnectionBuilder().withUrl(this.url).build(), this.signalr.serverTimeoutInMilliseconds = 5e8, this.signalr.keepaliveintervalinmilliseconds = 5e8, new Promise((e) => {
361
+ this.signalr.start().then(() => {
362
+ this.connectionId && this.send(), e(this.signalr);
363
+ }).catch((t) => {
364
+ console.log(t);
365
+ });
366
+ });
367
+ }
368
+ async send() {
369
+ try {
370
+ await this.signalr.invoke(this.connectionId, this.equipNo);
371
+ } catch (e) {
372
+ console.log("connectHub 连接失败" + e);
373
+ }
374
+ }
375
+ }
376
+ class A extends N {
377
+ constructor(e, t, i, o, u) {
378
+ super(), this.equipStatusObject = t, this.groupNodeObject = i, this.aleadyUpdateStatus = {}, this.isGetAllEquipStatus = !1, this.nodesMap = e, this.statusChange = o, this.openSignlr(), this.aliasName = u;
379
+ }
380
+ openSignlr() {
381
+ this.equipStatusSignlr = new y("/equipStatusMonitor", "", ""), this.equipStatusSignlr.openConnect().then((e) => {
382
+ try {
383
+ e.invoke("GetAllEquipStatus");
384
+ } catch (t) {
385
+ console.log(t);
386
+ }
387
+ this.subscribeTo(e, "GetAllEquipStatus");
388
+ try {
389
+ e.invoke("GetEquipChangeStatus");
390
+ } catch (t) {
391
+ console.log(t);
392
+ }
393
+ e.onclose(() => {
394
+ this.openSignlr();
395
+ }), this.subscribeTo(e, "GetEquipChangeStatus");
396
+ });
397
+ }
398
+ subscribeTo(e, t) {
399
+ e.off(t), e.on(t, (i) => {
400
+ i && i.isSuccess && i.data && (this[t] ? this[t](i.data) : this.notice({ func: t, data: i.data, key: i.groupId }));
401
+ });
402
+ }
403
+ GetAllEquipStatus(e) {
404
+ this.isGetAllEquipStatus = !0, this.resetGroupStatus(), Object.keys(e).forEach((t) => {
405
+ this.equipStatusObject[t] = e[t];
406
+ }), Object.keys(this.groupNodeObject).forEach((t) => {
407
+ this.updateByGroup(t);
408
+ });
409
+ }
410
+ updateByGroup(e) {
411
+ if (!this.aleadyUpdateStatus[e]) {
412
+ let t = this.window[`group-${e}${this.aliasName}`] || [];
413
+ t.length && (this.aleadyUpdateStatus[e] = !0, t.forEach((i) => {
414
+ this.equipStatusObject[i.equipNo] == 0 || this.equipStatusObject[i.equipNo] == 2 ? this.setGroupStatus(e, !0, 2) : this.equipStatusObject[i.equipNo] == 6 && this.setGroupStatus(e, !0, 6), this.nodesMap[`${e}-${i.equipNo}`] && (this.nodesMap[`${e}-${i.equipNo}`].status = this.equipStatusObject[i.equipNo]);
415
+ }));
416
+ }
417
+ }
418
+ updateGroupStatus(e) {
419
+ this.isGetAllEquipStatus && this.updateByGroup(e);
420
+ }
421
+ GetEquipChangeStatus(e) {
422
+ this.setStatus(e);
423
+ }
424
+ // 设置分组状态 key:扁平化数据中节点索引;type:类型(增加,减少);status:状态(报警2、双机热备6)
425
+ setGroupStatus(e, t, i) {
426
+ t ? i == 2 ? (this.nodesMap[e].alarmCounts = this.nodesMap[e].alarmCounts + 1, this.nodesMap[e].alarmCounts > 0 && (this.nodesMap[e].status = 2)) : (this.nodesMap[e].backUpCounts = this.nodesMap[e].backUpCounts + 1, this.nodesMap[e].alarmCounts == 0 && this.nodesMap[e].backUpCounts > 0 && (this.nodesMap[e].status = 6)) : i == 2 ? (this.nodesMap[e].alarmCounts = this.nodesMap[e].alarmCounts - 1, this.nodesMap[e].alarmCounts == 0 && (this.nodesMap[e].status = 1)) : (this.nodesMap[e].backUpCounts = this.nodesMap[e].backUpCounts - 1, this.nodesMap[e].alarmCounts == 0 && (this.nodesMap[e].backUpCounts == 0 ? this.nodesMap[e].status = 1 : this.nodesMap[e].status = 6)), this.nodesMap[e].groupId && this.setGroupStatus(this.nodesMap[e].groupId, t, i);
427
+ }
428
+ setStatus(e) {
429
+ let t = this.equipStatusObject[e.equipNo], i = this.window.equipCache && this.window.equipCache[e.equipNo] && this.window.equipCache[e.equipNo].groupId;
430
+ if (e.status != 3 && i) {
431
+ switch (e.status) {
432
+ case 0:
433
+ t != 0 && this.setGroupStatus(i, !0, 2), t == 6 && this.setGroupStatus(i, !1, 6);
434
+ break;
435
+ case 1:
436
+ t == 6 ? this.setGroupStatus(i, !1, 6) : (t == 2 || t == 0) && this.setGroupStatus(i, !1, 2);
437
+ break;
438
+ case 2:
439
+ t != 2 && this.setGroupStatus(i, !0, 2), t == 6 && this.setGroupStatus(i, !1, 6);
440
+ break;
441
+ case 6:
442
+ (t == 2 || t == 0) && this.setGroupStatus(i, !1, 2), t != 6 && this.setGroupStatus(i, !0, 6);
443
+ break;
444
+ }
445
+ this.equipStatusObject[e.equipNo] = e.status;
446
+ let o = `${i}-${e.equipNo}`;
447
+ this.nodesMap[o] && (this.nodesMap[o].status = e.status), this.statusChange(i, e.equipNo, e.status);
448
+ }
449
+ }
450
+ // 重置分组状态
451
+ resetGroupStatus() {
452
+ for (let e in this.groupNodeObject) { this.groupNodeObject[e].alarmCounts = 0, this.groupNodeObject[e].backUpCount = 0; }
453
+ }
454
+ }
455
+ const B = {
456
+ getSetParm(s) {
457
+ if (window.AxiosBuilder.axios) {
458
+ return window.AxiosBuilder.axios({
459
+ method: "post",
460
+ url: "/IoT/api/v3/EquipList/GetFullSetParmByEquipNo",
461
+ params: s,
462
+ data: s,
463
+ headers: {
464
+ "Content-Type": "application/json;charset=UTF-8",
465
+ "Accept-Language": window.sessionStorage.languageType || "zh-CN"
466
+ }
467
+ });
468
+ }
469
+ }
470
+ }, U = Object.assign(
471
+ {},
472
+ B
473
+ );
474
+ class W {
475
+ constructor(e, t) {
476
+ this.nodesMap = e, this.equipControllObject = t;
477
+ }
478
+ // 获取设备控制项
479
+ async getSetting(e, t, i, o) {
480
+ let [u, a] = String(e).split("-"), r = {
481
+ equipNo: a
482
+ };
483
+ await U.getSetParm(r).then((h) => {
484
+ if (h.data.code == 200) {
485
+ let p = h && h.data && h.data.data && h.data.data.rows || [];
486
+ this.nodesMap[e].settings || (this.nodesMap[e].settings = []), p && p.length > 0 && this.nodesMap[e] && (p.forEach((c) => {
487
+ c.title = c.setNm, c.key = `${u}-${a}-${c.setNo}`, c.level = Number(i) + 1, c.checked = o || this.equipControllObject[a] && this.equipControllObject[a].includes(c.setNo), c.isSetting = !0, c.equipNo = a, c.groupId = u, c.equipName = t;
488
+ }), this.nodesMap[e].settings = [...p]);
489
+ }
490
+ });
491
+ }
492
+ }
493
+ class f {
494
+ static formateList(e, t) {
495
+ let i = [];
496
+ for (const o of e) {
497
+ let u = {};
498
+ u.count = 0, u.equipSelectCount = 0, u.controlSelectCount = 0, u.equipCount = o.equipCount || 0, u.title = o.name, u.key = o.id, u.isGroup = !0, u.children = [], u.status = 1, u.level = t || 1, u.expand = !t, u.equips = [], u.groupId = o.parentId, u.groups = [], u.alarmCounts = 0, u.backUpCounts = 0, u.indeterminate = !1, u.checked = !1, u.visible = !0, u.nodeEquipSelectCount = 0, u.checkedEquips = [], u.halfCheckedEquips = [], u.selectControlCount = 0, o.children && o.children.length > 0 && (u.groups = [
499
+ ...this.formateList(o.children, t ? t + 1 : 2)
500
+ ]), i.push(u);
501
+ }
502
+ return i;
503
+ }
504
+ static deepClone(e, t, i, o, u, a) {
505
+ let r = [];
506
+ if (e) {
507
+ for (let h = 0, p = e.length; h < p; h++) {
508
+ r.push(
509
+ {
510
+ isGroup: i,
511
+ key: `${o}-${e[h].id}`,
512
+ status: a[e[h].id] || 0,
513
+ title: e[h].title,
514
+ level: t,
515
+ expand: !1,
516
+ isEquip: !0,
517
+ loading: !1,
518
+ indeterminate: u[e[h].equipNo] && u[e[h].equipNo].indeterminate || !1,
519
+ checked: u[e[h].equipNo] && u[e[h].equipNo].checked || !1,
520
+ groupId: o,
521
+ equipNo: e[h].id,
522
+ visible: !0,
523
+ settings: []
524
+ }
525
+ );
526
+ }
527
+ }
528
+ return r;
529
+ }
530
+ static copyOrigin(e) {
531
+ let t = [];
532
+ return e.forEach((i) => {
533
+ t.push({ ...i });
534
+ }), t;
535
+ }
536
+ // 获取分组位置
537
+ static getPosition(e, t) {
538
+ let i = 0;
539
+ for (let o = 0, u = t.length; o < u; o++) {
540
+ if (t[o].key == e) {
541
+ i = o - 30;
542
+ break;
543
+ }
544
+ }
545
+ return i;
546
+ }
547
+ // 扁平化
548
+ static flattern(e, t) {
549
+ e.forEach((i) => {
550
+ i.isGroup && (t[`${i.key}`] = null, t[`${i.key}`] = i), i.groups && i.groups.length && this.flattern(i.groups, t);
551
+ });
552
+ }
553
+
554
+ /**
555
+ * @description 生成唯一Id
556
+ * @param {} 不用传参
557
+ * @return {string}
558
+ */
559
+ static generateUUID() {
560
+ let e = (/* @__PURE__ */ new Date()).getTime();
561
+ return window.performance && typeof window.performance.now == "function" && (e += performance.now()), "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(i) {
562
+ let o = (e + Math.random() * 16) % 16 | 0;
563
+ return e = Math.floor(e / 16), (i === "x" ? o : o & 3 | 8).toString(16);
564
+ });
565
+ }
566
+
567
+ /**
568
+ * @description 将普通列表转换为树结构的列表
569
+ * @param {list} 可构建树形结构的普通列表
570
+ * @return {string}
571
+ */
572
+ static listToTreeList(e) {
573
+ const t = e, i = [], o = {};
574
+ return t.forEach((u) => {
575
+ o[u.id] = u;
576
+ }), t.forEach((u) => {
577
+ const a = o[u.parentId];
578
+ a ? (a.children || (a.children = [])).push(u) : i.push(u);
579
+ }), i;
580
+ }
581
+ }
582
+ class D extends N {
583
+ // 分组节点扁平化对象、设备扁平化对象、window缓存设备扁平化对象
584
+ constructor(e, t, i) {
585
+ super(), this.showSettings = t, this.groupNodeObject = e, this.aliasName = i;
586
+ }
587
+ // 触发搜索
588
+ filterMethod(e) {
589
+ for (let t in this.groupNodeObject) { e && this.updateBySearch(t, e); }
590
+ }
591
+ // 搜索状态将搜索的结果存放缓存中
592
+ updateBySearch(e, t) {
593
+ let i = this.window[`group-${this.groupNodeObject[e].key}${this.aliasName}`];
594
+ i && (i = i.filter((o) => o.title.includes(t)), this.window[`group-${this.groupNodeObject[e].key}-search`] = f.copyOrigin(i));
595
+ }
596
+ }
597
+ const E = (s, e) => {
598
+ const t = s.__vccOpts || s;
599
+ for (const [i, o] of e) { t[i] = o; }
600
+ return t;
601
+ }, K = {
602
+ props: {
603
+ source: {
604
+ type: Object
605
+ },
606
+ groupEditAndNew: {
607
+ type: Function
608
+ },
609
+ deleteGroup: {
610
+ type: Function
611
+ }
612
+ }
613
+ }, F = { class: "operates" };
614
+ function J(s, e, t, i, o, u) {
615
+ const a = g("el-button"), r = g("el-button-group"), h = g("el-popover");
616
+ return n(), l("div", F, [
617
+ C(h, {
618
+ placement: "bottom",
619
+ trigger: "hover"
620
+ }, {
621
+ reference: w(() => e[3] || (e[3] = [
622
+ q("i", { class: "el-icon-more" }, null, -1)
623
+ ])),
624
+ default: w(() => [
625
+ C(r, { class: "new-button-group setModule" }, {
626
+ default: w(() => [
627
+ C(a, {
628
+ type: "text",
629
+ size: "small",
630
+ class: "elBtn",
631
+ icon: " iconfont icon-tubiao20_bianji",
632
+ onClick: e[0] || (e[0] = M((p) => t.groupEditAndNew(!1, t.source), ["stop"]))
633
+ }, {
634
+ default: w(() => [
635
+ k(b(s.$t("equipInfo.poverTips.rename")), 1)
636
+ ]),
637
+ _: 1
638
+ }),
639
+ C(a, {
640
+ type: "text",
641
+ size: "small",
642
+ class: "elBtn",
643
+ icon: " iconfont icon-gw-icon-tianjia1",
644
+ onClick: e[1] || (e[1] = (p) => t.groupEditAndNew(!0, t.source))
645
+ }, {
646
+ default: w(() => [
647
+ k(b(s.$t("equipInfo.poverTips.newChildGroup")), 1)
648
+ ]),
649
+ _: 1
650
+ }),
651
+ t.source.level != 1 ? (n(), S(a, {
652
+ key: 0,
653
+ type: "danger",
654
+ size: "small",
655
+ onClick: e[2] || (e[2] = M((p) => t.deleteGroup(t.source), ["stop"])),
656
+ icon: " iconfont icon-tubiao20_shanchu"
657
+ }, {
658
+ default: w(() => [
659
+ k(b(s.$t("publics.button.deletes")), 1)
660
+ ]),
661
+ _: 1
662
+ })) : d("", !0)
663
+ ]),
664
+ _: 1
665
+ })
666
+ ]),
667
+ _: 1
668
+ })
669
+ ]);
670
+ }
671
+ const V = /* @__PURE__ */ E(K, [["render", J]]), R = {
672
+ name: "ElTreeVirtualNode",
673
+ componentName: "ElTreeVirtualNode",
674
+ props: {
675
+ searchName: {
676
+ type: String,
677
+ default: ""
678
+ },
679
+ expanding: {
680
+ type: Boolean,
681
+ default: !1
682
+ },
683
+ aleadyLoadAll: {
684
+ type: Boolean,
685
+ default: !1
686
+ },
687
+ groupLoading: {
688
+ type: Boolean,
689
+ default: !1
690
+ },
691
+ source: {
692
+ type: Object
693
+ },
694
+ showCheckbox: {
695
+ type: Boolean,
696
+ default: !1
697
+ },
698
+ showStatus: {
699
+ type: Boolean,
700
+ default: !1
701
+ },
702
+ filterEquip: {
703
+ type: Boolean,
704
+ default: !1
705
+ },
706
+ showOperate: {
707
+ type: Boolean,
708
+ default: !1
709
+ },
710
+ currentSelect: {
711
+ type: [Number, String],
712
+ default: -1
713
+ },
714
+ nodeClick: {
715
+ type: Function
716
+ },
717
+ onChecked: {
718
+ type: Function
719
+ },
720
+ groupEditAndNew: {
721
+ type: Function
722
+ },
723
+ deleteGroup: {
724
+ type: Function
725
+ },
726
+ childrenResetGroupNum: {
727
+ type: Function
728
+ },
729
+ getEquipStatus: {
730
+ type: Function
731
+ },
732
+ colorConfig: {
733
+ type: Object
734
+ },
735
+ index: {
736
+ type: Number,
737
+ default: -1
738
+ }
739
+ },
740
+ components: {
741
+ oparate: V
742
+ },
743
+ computed: {
744
+ filterEquip() {
745
+ return this.filterEquip ? this.source.isGroup && this.source.count !== 0 && this.source.status === 2 || !this.source.isGroup && (this.source.status === 2 || this.source.status === 0) : !0;
746
+ }
747
+ },
748
+ watch: {
749
+ filterEquip(s) {
750
+ s ? (this.setAlarmEqupGroup(), this.childrenResetGroupNum(!0)) : this.childrenResetGroupNum(!1);
751
+ }
752
+ },
753
+ data() {
754
+ return {
755
+ indent: 13
756
+ };
757
+ },
758
+ methods: {
759
+ getColor(s) {
760
+ let e;
761
+ switch (s) {
762
+ case 0:
763
+ e = this.colorConfig.noComm;
764
+ break;
765
+ case 1:
766
+ e = this.colorConfig.normal;
767
+ break;
768
+ case 2:
769
+ e = this.colorConfig.alarm;
770
+ break;
771
+ case 3:
772
+ e = this.colorConfig.lsSet;
773
+ break;
774
+ case 4:
775
+ e = this.colorConfig.initialize;
776
+ break;
777
+ case 5:
778
+ e = this.colorConfig.withdraw;
779
+ break;
780
+ case 6:
781
+ e = this.colorConfig.BackUp;
782
+ break;
783
+ default:
784
+ e = this.colorConfig.noComm;
785
+ break;
786
+ }
787
+ return e;
788
+ },
789
+ clickFunction() {
790
+ this.source.expand = !this.source.expand, this.nodeClick(this.source, this.index, this.source.level, this.source.checked);
791
+ },
792
+ checkedChange(s) {
793
+ this.onChecked(this.source);
794
+ },
795
+ setAlarmEqupGroup() {
796
+ window.groupList.forEach((s) => {
797
+ window[`group-${s.id}-search`] = window["group-" + s.id].filter((e) => this.getEquipStatus(e.equipNo) === 2 || this.getEquipStatus(e.equipNo) === 0);
798
+ });
799
+ }
800
+ }
801
+ }, P = { class: "el-tree-node__content" }, H = { class: "nodeContent" }, z = {
802
+ key: 1,
803
+ class: "circle"
804
+ }, Q = { class: "label" }, X = {
805
+ key: 2,
806
+ class: "equipNumber"
807
+ }, Y = {
808
+ key: 4,
809
+ class: "el-tree-node__loading-icon el-icon-loading"
810
+ };
811
+ function Z(s, e, t, i, o, u) {
812
+ const a = g("el-checkbox"), r = g("oparate");
813
+ return u.filterEquip ? (n(), l("div", {
814
+ key: 0,
815
+ class: G(["el-tree-node", {
816
+ parent_tag: t.source.isGroup,
817
+ child_tags: !t.source.isGroup,
818
+ selectedColor: t.currentSelect === t.source.key && !t.source.isGroup
819
+ }]),
820
+ onClick: e[1] || (e[1] = (...h) => u.clickFunction && u.clickFunction(...h))
821
+ }, [
822
+ q("div", P, [
823
+ q("span", {
824
+ class: "el-tree__indent",
825
+ "aria-hidden": "true",
826
+ style: O({ width: (t.source.level - 1) * o.indent + "px" })
827
+ }, null, 4),
828
+ t.source.isGroup ? (n(), l("span", {
829
+ key: 0,
830
+ class: G([
831
+ {
832
+ "is-leaf": !t.source.isGroup,
833
+ expanded: t.source.isGroup && t.source.expand
834
+ },
835
+ "el-tree-node__expand-icon",
836
+ "iconfont icon-fangxiangL"
837
+ ])
838
+ }, null, 2)) : d("", !0),
839
+ q("div", H, [
840
+ t.showCheckbox ? (n(), S(a, {
841
+ key: 0,
842
+ modelValue: t.source.checked,
843
+ "onUpdate:modelValue": e[0] || (e[0] = (h) => t.source.checked = h),
844
+ indeterminate: t.source.indeterminate,
845
+ onChange: u.checkedChange
846
+ }, null, 8, ["modelValue", "indeterminate", "onChange"])) : d("", !0),
847
+ t.showStatus ? (n(), l("span", z, [
848
+ t.source.status != 6 ? (n(), l("span", {
849
+ key: 0,
850
+ class: "yd",
851
+ style: O({ backgroundColor: u.getColor(t.source.status) })
852
+ }, null, 4)) : (n(), l("i", {
853
+ key: 1,
854
+ style: O({ color: t.colorConfig.BackUp }),
855
+ class: "iconfont icon-gw-icon-beiji2"
856
+ }, null, 4))
857
+ ])) : d("", !0),
858
+ q("span", Q, b(t.source.title), 1),
859
+ t.source.isGroup && !t.source.isEquip || t.source.isGroup && !t.source.isEquip ? (n(), l("span", X, b(t.source.count), 1)) : d("", !0),
860
+ t.source.isGroup && t.showOperate ? (n(), S(r, {
861
+ key: 3,
862
+ source: t.source,
863
+ groupEditAndNew: t.groupEditAndNew,
864
+ deleteGroup: t.deleteGroup
865
+ }, null, 8, ["source", "groupEditAndNew", "deleteGroup"])) : d("", !0),
866
+ t.source.loading ? (n(), l("span", Y)) : d("", !0)
867
+ ])
868
+ ])
869
+ ], 2)) : d("", !0);
870
+ }
871
+ const ee = /* @__PURE__ */ E(R, [["render", Z]]), te = {
872
+ components: {
873
+ VirtualList: I
874
+ },
875
+ mixins: [m],
876
+ data() {
877
+ return {
878
+ itemComponent: ee,
879
+ //节点组件
880
+ visibleList: [],
881
+ //虚拟滚动所需要的列表
882
+ currentSelect: -1,
883
+ //当前选中的节点(不包含分组节点)
884
+ equipStatusManage: null,
885
+ //设备状态管理工具
886
+ cacheManage: null,
887
+ //内存管理工具
888
+ searchManage: null,
889
+ //搜索管理工具
890
+ equipNumManage: null,
891
+ //设备数量管理工具
892
+ requestManage: null,
893
+ //请求管理工具
894
+ checkStatusManage: null,
895
+ //请求管理工具
896
+ groupNodeObject: {},
897
+ //所有分组扁平化所保存的存储的地方
898
+ nodesMap: {},
899
+ //所有实例化对象映射
900
+ equipCheckObject: {},
901
+ //设备选中状态记录 equipCheckObject:{xxx设备号:{indeterminate: false,checked: false,groupId:xxx}}
902
+ equipStatusObject: {},
903
+ //记录设备状态,从后台推送的初始化全量状态,增量更新需要实时维护
904
+ controlObject: {},
905
+ //展开的控制项,controlObject:{xxx设备号:{groupId:xxx}}用于设置当前展开设置选中,如果依赖与equipControlObject筛选设置选中,性能差
906
+ isSearchStatus: !1,
907
+ //是否是搜索状态
908
+ equipControllObject: {},
909
+ //绑定所有的已选中的设备控制项
910
+ expandGroup: [],
911
+ //记录已展开的分组
912
+ updateJob: null
913
+ };
914
+ },
915
+ props: {
916
+ data: {
917
+ //分组列表
918
+ type: Array
919
+ },
920
+ selectEquips: {
921
+ //设备选中列表,用于回显,如权限管理
922
+ type: Array,
923
+ default: () => []
924
+ },
925
+ controllList: {
926
+ //控制项选中列表,用于回显,如权限管理
927
+ type: Array,
928
+ default: () => []
929
+ },
930
+ showSettings: {
931
+ //是否需要加载设备控制项,如权限管理
932
+ type: Boolean,
933
+ default: !1
934
+ },
935
+ showSelectNum: {
936
+ //是否在树形结构顶部展示已选设备数量,如设备管理
937
+ type: Boolean,
938
+ default() {
939
+ return !1;
940
+ }
941
+ },
942
+ showCheckbox: {
943
+ //是否展示checkbox
944
+ type: Boolean,
945
+ default: !1
946
+ },
947
+ showStatus: {
948
+ //是否展示设备状态
949
+ type: Boolean,
950
+ default: !1
951
+ },
952
+ filterEquip: {
953
+ //是否过滤
954
+ type: Boolean,
955
+ default: !1
956
+ },
957
+ showOperate: {
958
+ // 是否展示操作按钮
959
+ type: Boolean,
960
+ default: !1
961
+ },
962
+ defaultExpandAll: {
963
+ type: Boolean,
964
+ default: !1
965
+ },
966
+ currentNodeKey: [String, Number],
967
+ colorConfig: {
968
+ type: Object,
969
+ default: () => ({
970
+ noComm: "#a0a0a0",
971
+ normal: "#63e03f",
972
+ alarm: "#f22433",
973
+ lsSet: "#bebcaa",
974
+ initialize: "#289ac0",
975
+ withdraw: "#ffc0cb",
976
+ BackUp: "#f8901c"
977
+ })
978
+ },
979
+ treeType: {
980
+ type: String,
981
+ default: ""
982
+ },
983
+ buildTree: {
984
+ type: Function
985
+ },
986
+ filterData: {
987
+ type: Function
988
+ },
989
+ alias: {
990
+ type: String,
991
+ default: ""
992
+ }
993
+ },
994
+ watch: {
995
+ data(s) {
996
+ s && s.length && (f.flattern(this.data, this.groupNodeObject), this.cacheManage.addNodesMap(Object.values(this.groupNodeObject).map((e) => e)), this.init());
997
+ },
998
+ controllList(s) {
999
+ this.updateCheckedStatusWithControls();
1000
+ },
1001
+ selectEquips(s) {
1002
+ this.updateCheckedStatusWithEquips();
1003
+ },
1004
+ filterEquip(s) {
1005
+ this.$nextTick(() => {
1006
+ this.$refs.virtualList.scrollToIndex(0);
1007
+ });
1008
+ }
1009
+ },
1010
+ computed: {
1011
+ aliasName() {
1012
+ return this.alias ? `-${this.alias}` : "";
1013
+ }
1014
+ },
1015
+ created() {
1016
+ this.showCheckbox && (this.checkStatusManage = new L(this.groupNodeObject, this.nodesMap, this.equipControllObject, this.controlObject, this.equipCheckObject, this.aliasName)), this.cacheManage = new _(this.groupNodeObject, this.nodesMap, this.controlObject, this.equipCheckObject), this.searchManage = new D(this.groupNodeObject, this.showSettings, this.aliasName), this.equipNumManage = new v(this.groupNodeObject, this.aliasName), this.requestManage = new W(this.nodesMap, this.equipControllObject);
1017
+ },
1018
+ mounted() {
1019
+ this.updateCheckedStatusWithControls(), this.updateCheckedStatusWithEquips(), window.addEventListener("message", (s) => {
1020
+ s.data.type && this[s.data.type] && this[s.data.type](s.data.data);
1021
+ });
1022
+ },
1023
+ methods: {
1024
+ // 初始化
1025
+ init() {
1026
+ this.data[0].expand = !0, this.updateTreeList(), setTimeout(() => {
1027
+ Object.values(this.groupNodeObject).forEach((s) => {
1028
+ !s.expand && this.expandGroup.includes(s.key) && (s.expand = !0), this.filterWithAlias(s.key), this.updateGroupEquips(s.key, !0);
1029
+ }), this.equipNumManage.resetGroupNum(this.isSearchStatus), this.showStatus && !this.equipStatusManage && (this.equipStatusManage = new A(this.nodesMap, this.equipStatusObject, this.groupNodeObject, this.statusChange, this.aliasName));
1030
+ }, 500);
1031
+ },
1032
+ // 根据条件过滤
1033
+ filterWithAlias(s) {
1034
+ if (this.aliasName) {
1035
+ let e = this.window[`group-${s}`] || [];
1036
+ this.window[`group-${s}${this.aliasName}`] = this.filterData(e);
1037
+ }
1038
+ },
1039
+ // 更新当前选中
1040
+ updateCurrentSelect() {
1041
+ this.window.equipCache && this.window.equipCache[this.currentNodeKey] && (this.currentSelect = `${this.window.equipCache[this.currentNodeKey].groupId}-${this.currentNodeKey}`);
1042
+ },
1043
+ // 设备状态变化
1044
+ statusChange(s, e, t) {
1045
+ this.currentSelect == `${s}-${e}` && this.$emit("statusChange", e, t);
1046
+ },
1047
+ // 更新checkbox选中状态
1048
+ updateCheckWidthJob() {
1049
+ this.showCheckbox && (this.checkStatusManage.resetCheckedStatus(), this.updateCheckedStatusWithControls(), this.updateCheckedStatusWithEquips());
1050
+ },
1051
+ // 通过外框更新设备
1052
+ updateGroupEquips(s, e) {
1053
+ if (!this.isSearchStatus && this.groupNodeObject[s]) {
1054
+ let t = this.equipNumManage.getAllEquipsNum();
1055
+ this.$emit("getTotal", t);
1056
+ }
1057
+ this.groupNodeObject[s].expand && this.updateList(s, this.groupNodeObject[s].level, null, !1);
1058
+ },
1059
+ // 展开的时候从缓存中拿设备数据到equips中并更新视图
1060
+ updateList(s) {
1061
+ if (this.groupNodeObject[s]) {
1062
+ let e = [];
1063
+ this.isSearchStatus ? (e = this.window[`group-${s}-search`], this.groupNodeObject[s].equips = [...f.deepClone(e, Number(this.groupNodeObject[s].level) + 1, this.showSettings, s, this.equipCheckObject, this.equipStatusObject)]) : (e = this.window[`group-${s}${this.aliasName}`], this.groupNodeObject[s].equips = [...f.deepClone(e, Number(this.groupNodeObject[s].level) + 1, this.showSettings, s, this.equipCheckObject, this.equipStatusObject)]), this.cacheManage.addNodesMap(this.groupNodeObject[s].equips), this.cacheManage.closeBrotherNode(s), this.visibleList = [], this.updateTreeList(this.data), this.showStatus && this.equipStatusManage && this.equipStatusManage.updateGroupStatus(s), this.updateCurrentSelect();
1064
+ }
1065
+ },
1066
+ // 更新整个树形结构
1067
+ updateTreeList(s) {
1068
+ s && s.forEach((e) => {
1069
+ this.visibleList.push(e), e.expand ? e.isEquip ? (e.children || (e.children = []), e.settings && (e.children = [...e.settings || []])) : e.children = [...e.equips || [], ...e.groups || []] : e.children = [], this.updateTreeList(e.children || []);
1070
+ });
1071
+ },
1072
+ // 节点点击事件
1073
+ nodeClick(s, e, t, i) {
1074
+ this.$emit("node-click", { ...s, key: s.isEquip ? s.equipNo : s.key }), s.isGroup ? s.isEquip ? this.equipClick(s, e, i) : this.groupClick(s, e, i) : this.currentSelect = s.key;
1075
+ },
1076
+ groupClick(s, e, t) {
1077
+ s.expand ? this.updateList(s.key, s.level, e, t) : (this.cacheManage.recycleGroupCache(s.key), this.visibleList = [], this.updateTreeList(this.data));
1078
+ },
1079
+ async equipClick(s, e, t) {
1080
+ this.showSettings && (s.expand ? (s.loading = !0, await this.requestManage.getSetting(s.key, s.title, s.level, t), this.controlObject[s.equipNo] = { groupId: s.groupId }, s.loading = !1, this.visibleList.splice(e + 1, 0, ...this.nodesMap[s.key].settings), this.cacheManage.addNodesMap(this.nodesMap[s.key].settings)) : (this.visibleList.splice(e + 1, this.nodesMap[s.key].settings.length), this.cacheManage.removeNodesMap(this.nodesMap[s.key].settings), this.nodesMap[s.key].settings = [], delete this.controlObject[s.equipNo]));
1081
+ },
1082
+ onChecked(s) {
1083
+ this.checkStatusManage && this.checkStatusManage.onChecked(s, this.isSearchStatus), this.$emit("onCheck");
1084
+ },
1085
+ groupEditAndNew(s, e) {
1086
+ this.$emit("groupEditAndNew", { isGroupNew: s, node: e });
1087
+ },
1088
+ deleteGroup(s) {
1089
+ this.$emit("deleteGroup", s);
1090
+ },
1091
+ updateCheckedStatusWithControls() {
1092
+ this.controllList && this.controllList.length && this.checkStatusManage && this.checkStatusManage && this.checkStatusManage.updateCheckedStatusWithControls(this.controllList);
1093
+ },
1094
+ updateCheckedStatusWithEquips() {
1095
+ this.selectEquips && this.selectEquips.length && this.checkStatusManage && this.checkStatusManage && this.checkStatusManage.updateCheckedStatusWithEquips(this.selectEquips);
1096
+ },
1097
+ resetCheckedStatus() {
1098
+ this.checkStatusManage && this.checkStatusManage.resetCheckedStatus();
1099
+ },
1100
+
1101
+ /**
1102
+ * @description 获取选择的设备
1103
+ * @return Array
1104
+ */
1105
+ getEquipSelectd() {
1106
+ return this.checkStatusManage && this.checkStatusManage.getEquipSelectd();
1107
+ },
1108
+
1109
+ /**
1110
+ * @description 获取选择的设备控制项
1111
+ * @return Array
1112
+ */
1113
+ getControlSelected() {
1114
+ return this.checkStatusManage && this.checkStatusManage.getControlSelected();
1115
+ },
1116
+
1117
+ /**
1118
+ * @description 记录已展开的分组
1119
+ * @return 无
1120
+ */
1121
+ recordExpandGroup() {
1122
+ this.expandGroup = [], Object.values(this.groupNodeObject).forEach((s) => {
1123
+ s.expand && this.expandGroup.push(s.key);
1124
+ });
1125
+ },
1126
+
1127
+ /**
1128
+ * @description 清除已展开的分组
1129
+ * @return
1130
+ */
1131
+ removeExpandGroup() {
1132
+ this.$nextTick(() => {
1133
+ this.expandGroup = [];
1134
+ });
1135
+ },
1136
+
1137
+ /**
1138
+ * @description 搜索设备
1139
+ * 1:清除所有节点缓存
1140
+ 2: 设置搜索状态为true,搜索状态下所有操作全部不更新
1141
+ 3: 非搜索状态,需要清除搜索缓存
1142
+ * @param {searchName} 搜索名称
1143
+ * @return 无返回值
1144
+ */
1145
+ filterMethod(s) {
1146
+ this.visibleList = [], this.cacheManage.recycleAllNodeCache(), s ? (this.isSearchStatus = !0, this.searchManage.filterMethod(s)) : this.isSearchStatus = !1, this.init(), this.$nextTick(() => {
1147
+ this.$refs.virtualList.scrollToIndex(0);
1148
+ }), this.equipNumManage.resetGroupNum(this.isSearchStatus), this.showCheckbox && (this.checkStatusManage && this.checkStatusManage.reComputedCheckNum(this.isSearchStatus), this.checkStatusManage && this.checkStatusManage.updateGroupCheckStatus());
1149
+ },
1150
+ // 重新构建树
1151
+ rebuildTree() {
1152
+ this.recordExpandGroup(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus(), this.cacheManage.recycleAllNodeCache(!0), this.$nextTick(() => {
1153
+ this.buildTree(), this.removeExpandGroup();
1154
+ });
1155
+ },
1156
+ // 树形结构销毁
1157
+ destroyTree() {
1158
+ this.cacheManage.recycleAllNodeCache(!0), this.visibleList = [], this.updateTreeList(this.data);
1159
+ },
1160
+ // 通过外框事件更新树形结构数据--start
1161
+ /**
1162
+ * @description 获取分组设备
1163
+ * @param {data} {分组Id}
1164
+ * @return 无返回值
1165
+ */
1166
+ GetGroupEquips(s) {
1167
+ s.groupId && this.groupNodeObject[s.groupId] && !this.isSearchStatus && (this.updateGroupEquips(s.groupId, !0), this.updateJob && clearTimeout(this.updateJob), this.updateJob = setTimeout(() => {
1168
+ this.updateCheckWidthJob();
1169
+ }, 500));
1170
+ },
1171
+
1172
+ /**
1173
+ * @description 删除设备
1174
+ * @param {data} {groupId,equips}
1175
+ * @return 无返回值
1176
+ */
1177
+ DeleteEquip(s) {
1178
+ const { groupId: e, equips: t } = s || {};
1179
+ e && this.groupNodeObject[e] && (this.updateGroupEquips(s.groupId), this.equipNumManage.resetGroupNum(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus()), t.length && t.forEach((i) => {
1180
+ let o = this.nodesMap[`${e}-${i.id}`];
1181
+ o && (this.currentSelect.toString().includes(i.id) && this.$emit("currentDelete"), this.showStatus && (o.status == 2 || o.status == 0 ? this.equipStatusManage.setGroupStatus(e, !1, 2) : o.status == 6 && this.equipStatusManage.setGroupStatus(e, !1, 6)), delete this.nodesMap[`${e}-${i.id}`], delete this.equipCheckObject[i.id]), delete this.equipStatusObject[i.id];
1182
+ });
1183
+ },
1184
+
1185
+ /**
1186
+ * @description 移动设备
1187
+ * @param {data} {updateGroups} 需要更新的分组列表
1188
+ * @return 无返回值
1189
+ */
1190
+ moveEquips(s) {
1191
+ const { updateGroups: e, buildTree: t } = s || {};
1192
+ !t && e ? e.forEach((i) => {
1193
+ i && this.groupNodeObject[i] && (this.updateGroupEquips(i), this.equipNumManage.resetGroupNum(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus());
1194
+ }) : t && this.rebuildTree();
1195
+ },
1196
+
1197
+ /**
1198
+ * @description 删除分组
1199
+ * @param {data} {groupId,parentGroupId}
1200
+ * @return 无返回值
1201
+ */
1202
+ DeleteEquipGroup(s) {
1203
+ s.forEach((e) => {
1204
+ e.groupId && this.nodesMap[e.groupId] && (this.isSearchStatus || this.rebuildTree());
1205
+ });
1206
+ },
1207
+
1208
+ /**
1209
+ * @description 新增分组
1210
+ * @param {data} {groupId,parentGroupId}
1211
+ * @return 无返回值
1212
+ */
1213
+ AddEquipGroup(s) {
1214
+ const { parentGroupId: e, groupId: t } = s || {};
1215
+ t && this.nodesMap[e] && this.treeType && (this.isSearchStatus || this.rebuildTree());
1216
+ },
1217
+
1218
+ /** 编辑分组
1219
+ * @description 新增分组
1220
+ * @param {data} {groupId,parentGroupId}
1221
+ * @return 无返回值
1222
+ */
1223
+ EditEquipGroup(s) {
1224
+ const { groupId: e, groupName: t } = s;
1225
+ this.nodesMap[e] && (this.nodesMap[e].title = t);
1226
+ },
1227
+
1228
+ /**
1229
+ * @description 新增分组设备
1230
+ * @param {data} {分组Id,设备}
1231
+ * @return 无返回值
1232
+ */
1233
+ AddEquip(s) {
1234
+ const { groupId: e } = s || {};
1235
+ e && (this.isSearchStatus || this.rebuildTree());
1236
+ },
1237
+
1238
+ /**
1239
+ * @description 新增分组设备
1240
+ * @param {data} {分组Id,设备}
1241
+ * @return 无返回值
1242
+ */
1243
+ EditEquip(s) {
1244
+ const { equipNo: e, groupId: t, equipName: i } = s || {};
1245
+ this.nodesMap[`${t}-${e}`] && (this.isSearchStatus || (this.nodesMap[`${t}-${e}`].title = i));
1246
+ },
1247
+
1248
+ /**
1249
+ * @description 重置分组数量
1250
+ * @param {isSearchStatus} {是否查询状态}
1251
+ * @return 无返回值
1252
+ */
1253
+ childrenResetGroupNum(s) {
1254
+ this.equipNumManage.resetGroupNum(s);
1255
+ },
1256
+
1257
+ /**
1258
+ * @description 获取设备状态
1259
+ * @param {data} {equipNo}
1260
+ * @return arry[equipNo]
1261
+ */
1262
+ getEquipStatus(s) {
1263
+ return this.equipStatusManage.equipStatusObject[s];
1264
+ }
1265
+ // 通过外框事件更新树形结构数据--end
1266
+ }
1267
+ }, ie = {
1268
+ class: "gw-tree",
1269
+ style: { height: "100%" }
1270
+ }, se = {
1271
+ class: "tree",
1272
+ style: { height: "100%" }
1273
+ };
1274
+ function oe(s, e, t, i, o, u) {
1275
+ const a = g("virtual-list", !0);
1276
+ return n(), l("div", ie, [
1277
+ q("div", se, [
1278
+ C(a, {
1279
+ ref: "virtualList",
1280
+ class: "virtualList",
1281
+ "data-key": "key",
1282
+ "data-sources": o.visibleList,
1283
+ "data-component": o.itemComponent,
1284
+ keeps: 40,
1285
+ "extra-props": {
1286
+ currentSelect: o.currentSelect,
1287
+ nodeClick: u.nodeClick,
1288
+ showStatus: t.showStatus,
1289
+ filterEquip: t.filterEquip,
1290
+ showSettings: t.showSettings,
1291
+ showCheckbox: t.showCheckbox,
1292
+ onChecked: u.onChecked,
1293
+ showOperate: t.showOperate,
1294
+ groupEditAndNew: u.groupEditAndNew,
1295
+ deleteGroup: u.deleteGroup,
1296
+ colorConfig: t.colorConfig,
1297
+ childrenResetGroupNum: u.childrenResetGroupNum,
1298
+ getEquipStatus: u.getEquipStatus
1299
+ }
1300
+ }, null, 8, ["data-sources", "data-component", "extra-props"])
1301
+ ])
1302
+ ]);
1303
+ }
1304
+ const ue = /* @__PURE__ */ E(te, [["render", oe]]);
1305
+ class ae {
1306
+ constructor() {
1307
+ this.eGroupNotify = new y("/eGroupNotify", "", ""), this.alreadyUpdate = {}, this.notify = null, this.window = window;
1308
+ try {
1309
+ window.top.equipGroup, this.window = window.top;
1310
+ } catch {
1311
+ this.window = window;
1312
+ }
1313
+ }
1314
+ stop() {
1315
+ this.notify && this.notify.stop();
1316
+ }
1317
+ Init() {
1318
+ this.eGroupNotify.openConnect().then((e) => {
1319
+ this.notify = e;
1320
+ try {
1321
+ e.invoke("GetEquipGroupTree"), e.invoke("GetAllEquipGroupTree");
1322
+ } catch (t) {
1323
+ console.log(t);
1324
+ }
1325
+ this.subscribeTo(e, "GetEquipGroupTree"), this.subscribeTo(e, "AddEquipGroup"), this.subscribeTo(e, "EditEquipGroup"), this.subscribeTo(e, "DeleteEquipGroup");
1326
+ try {
1327
+ e.invoke("GetGroupEquips");
1328
+ } catch (t) {
1329
+ console.log(t);
1330
+ }
1331
+ this.subscribeTo(e, "GetGroupEquips"), this.subscribeTo(e, "AddEquip"), this.subscribeTo(e, "DeleteEquip"), this.subscribeTo(e, "EditEquip"), this.subscribeTo(e, "moveEquips"), this.subscribeTo(e, "GetAllEquipGroupTree"), e.onclose((t) => {
1332
+ try {
1333
+ this.Init();
1334
+ } catch (i) {
1335
+ console.log(i);
1336
+ }
1337
+ console.log("重连", t);
1338
+ });
1339
+ }).catch((e) => {
1340
+ console.error(e);
1341
+ });
1342
+ }
1343
+ subscribeTo(e, t) {
1344
+ e.off(t), e.on(t, (i) => {
1345
+ i && i.isSuccess && (this[t] ? this[t](i.data) : this.notice({ func: t, data: i.data, key: i.groupId }));
1346
+ });
1347
+ }
1348
+ // 获取分组---无权限管理的分组列表--空设备分组不展示
1349
+ GetEquipGroupTree(e) {
1350
+ this.window.groupList || (this.window.groupList = e, this.notice({ type: "GetEquipGroupTree" }));
1351
+ }
1352
+ // 获取全量分组---设备管理使用
1353
+ GetAllEquipGroupTree(e) {
1354
+ this.window.groupList_manageMent || (this.window.groupList_manageMent = e, this.notice({ type: "GetEquipGroupTreeWidthTreeType" }));
1355
+ }
1356
+ // 新增分组
1357
+ AddEquipGroup(e) {
1358
+ const { parentGroupId: t, groupId: i, groupName: o } = e || {};
1359
+ i && (this.window.groupList_manageMent || (this.window.groupList_manageMent = []), this.window.groupList_manageMent.push({
1360
+ parentId: t,
1361
+ id: i,
1362
+ name: o,
1363
+ equipCount: 0
1364
+ }), this.notice({ type: "AddEquipGroup", data: e }));
1365
+ }
1366
+ // 编辑分组
1367
+ EditEquipGroup(e) {
1368
+ const { groupId: t, groupName: i } = e;
1369
+ this.window.groupList && window.groupList.forEach((o) => {
1370
+ o.id == t && (o.name = i);
1371
+ }), this.window.groupList_manageMent && window.groupList_manageMent.forEach((o) => {
1372
+ o.id == t && (o.name = i);
1373
+ }), this.notice({ type: "EditEquipGroup", data: e });
1374
+ }
1375
+ deleteChildGroup(e, t) {
1376
+ let i = [];
1377
+ t.forEach((o) => {
1378
+ o.parentId == e && i.push(o.id);
1379
+ }), i.forEach((o) => {
1380
+ let u = t.findIndex((a) => a.id == o);
1381
+ u > -1 && t.splice(u, 1), this.deleteChildGroup(o, t);
1382
+ });
1383
+ }
1384
+ // 删除分组
1385
+ DeleteEquipGroup(e) {
1386
+ e.forEach((t) => {
1387
+ if (this.window.groupList) {
1388
+ let i = this.window.groupList.findIndex((o) => o.id == t.groupId);
1389
+ i > -1 && this.window.groupList.splice(i, 1), this.deleteChildGroup(t.groupId, this.window.groupList);
1390
+ }
1391
+ if (this.window.groupList_manageMent) {
1392
+ let i = this.window.groupList_manageMent.findIndex((o) => o.id == t.groupId);
1393
+ i > -1 && this.window.groupList_manageMent.splice(i, 1), this.deleteChildGroup(t.groupId, this.window.groupList_manageMent);
1394
+ }
1395
+ }), this.notice({ type: "DeleteEquipGroup", data: e });
1396
+ }
1397
+ // 获取设备
1398
+ GetGroupEquips(e) {
1399
+ const { groupId: t, equips: i } = e || {};
1400
+ this.alreadyUpdate[t] || (this.window.groupCache || (this.window.groupCache = {}), this.window.groupCache[t] = {}, t && i && i instanceof Array && (i.forEach((o) => {
1401
+ o.title = o.name, o.groupId = t, o.equipNo = o.id, delete o.name, window.equipCache || (this.window.equipCache = {}), this.window.equipCache[o.id] = o, this.window.groupCache[t][o.id] = o;
1402
+ }), this.window[`group-${t}`] = i, this.notice({ type: "GetGroupEquips", data: { groupId: t } }), this.alreadyUpdate[t] = !0));
1403
+ }
1404
+ // 新增设备
1405
+ AddEquip(e) {
1406
+ const { groupId: t, equips: i } = e || {};
1407
+ this.window[`group-${t}`] || (this.window[`group-${t}`] = []), this.window.groupCache || (this.window.groupCache = {}), this.window.groupCache[t] || (this.window.groupCache[t] = {}), this.window.equipCache || (this.window.equipCache = {});
1408
+ let o = this.window[`group-${t}`].length;
1409
+ if (t && i) {
1410
+ if (i.forEach((u, a) => {
1411
+ this.window[`group-${t}`].push(
1412
+ {
1413
+ equipNo: u.id,
1414
+ groupId: t,
1415
+ id: u.id,
1416
+ title: u.name
1417
+ }
1418
+ ), this.window.equipCache[u.id] = this.window[`group-${t}`][o + a], this.window.groupCache[t][u.id] = this.window[`group-${t}`][o + a];
1419
+ }), !this.exist(t, this.window.groupList)) {
1420
+ let u = this.findParentList(t, this.window.groupList_manageMent);
1421
+ this.window.groupList.push(...u);
1422
+ }
1423
+ this.notice({ type: "AddEquip", data: e });
1424
+ }
1425
+ }
1426
+ moveEquips(e) {
1427
+ let t = [], i = !0, o = [];
1428
+ const { sourceGroup: u, targetGroupId: a } = e || {};
1429
+ a && t.push(a), u.forEach((r) => {
1430
+ if (t.push(r.groupId), (!this.window[`group-${a}`] || !this.window[`group-${a}`].length) && (this.window[`group-${a}`] = [], o.push(a)), this.window.groupCache || (this.window.groupCache = {}), this.window.groupCache[a] || (this.window.groupCache[a] = {}), r.equips.forEach((h) => {
1431
+ if (h.title = h.name, h.groupId = a, h.equipNo = h.id, this.window[`group-${r.groupId}`]) {
1432
+ let p = this.window[`group-${r.groupId}`].findIndex((c) => c.id == h.id);
1433
+ p > -1 && this.window[`group-${r.groupId}`].splice(p, 1);
1434
+ }
1435
+ window.equipCache || (this.window.equipCache = {}), this.window.equipCache[h.id] = h, this.window.groupCache[a][h.id] = h, this.window[`group-${a}`].push(h);
1436
+ }), !this.window[`group-${r.groupId}`].length) {
1437
+ let h = this.window.groupList.findIndex((p) => p.id == r.groupId);
1438
+ h > -1 && this.window.groupList.splice(h, 1), this.deleteChildGroup(r.groupId, this.window.groupList);
1439
+ }
1440
+ }), o.forEach((r) => {
1441
+ if (!this.exist(r, this.window.groupList)) {
1442
+ let h = this.findParentList(r, this.window.groupList_manageMent);
1443
+ this.window.groupList.push(...h);
1444
+ }
1445
+ }), this.notice({ type: "moveEquips", data: { updateGroups: t, buildTree: i } });
1446
+ }
1447
+ exist(e, t) {
1448
+ return t ? t.some((i) => i.id == e) : !1;
1449
+ }
1450
+ findParentList(e, t) {
1451
+ let i = [];
1452
+ if (t) {
1453
+ let o = t.findIndex((u) => u.id == e);
1454
+ o > -1 && i.push({ ...t[o] }), t[o].parentId && !this.exist(t[o].parentId, this.window.groupList) && i.push(...this.findParentList(t[o].parentId, this.window.groupList_manageMent));
1455
+ }
1456
+ return i;
1457
+ }
1458
+ // 删除设备
1459
+ DeleteEquip(e) {
1460
+ const { groupId: t, equips: i } = e || {};
1461
+ if (t && i && i instanceof Array) {
1462
+ if (this.window[`group-${t}`]) {
1463
+ for (let o = 0, u = i.length; o < u; o++) {
1464
+ let a = this.window[`group-${t}`].findIndex((r) => r.id == i[o].id);
1465
+ a > -1 && this.window[`group-${t}`].splice(a, 1), delete this.window.equipCache[i[o].id], delete this.window.groupCache[t][i[o].id];
1466
+ }
1467
+ }
1468
+ this.notice({ type: "DeleteEquip", data: e });
1469
+ }
1470
+ }
1471
+ // 编辑设备
1472
+ EditEquip(e) {
1473
+ const { equipNo: t, groupId: i, equipName: o } = e || {};
1474
+ i && t && (window[`group-${i}`] && (this.window.equipCache[t] = o), this.notice({ type: "EditEquip", data: e }));
1475
+ }
1476
+ notice(e) {
1477
+ if (this.window.hasIframe) {
1478
+ let t = document.getElementsByTagName("iframe");
1479
+ for (let i of t) { i.contentWindow.postMessage(e); }
1480
+ } else { window.postMessage(e, "*"); }
1481
+ }
1482
+ }
1483
+ const he = {
1484
+ name: "treeV2",
1485
+ components: {
1486
+ tree: ue
1487
+ },
1488
+ mixins: [m],
1489
+ data() {
1490
+ return {
1491
+ list: [],
1492
+ refId: f.generateUUID(),
1493
+ treeKey: null,
1494
+ listKey: null,
1495
+ hasBuildTree: !1
1496
+ };
1497
+ },
1498
+ props: {
1499
+ treeType: {
1500
+ type: String,
1501
+ default: ""
1502
+ }
1503
+ },
1504
+ mounted() {
1505
+ this.treeKey = `equipGroup${this.treeType}`, this.listKey = `groupList${this.treeType}`, this.window[this.treeKey] ? this.list = f.formateList(JSON.parse(JSON.stringify(this.window[this.treeKey]))) : this.window[this.listKey] && this.buildTree(), window.executeQueue || (window.executeQueues = {}), window.executeQueues[this.refId] = this.destroyTree, window.addEventListener("message", (s) => {
1506
+ s && s.data && s.data.type && this[s.data.type] && this[s.data.type]();
1507
+ });
1508
+ try {
1509
+ this.window.hasIframe || this.selfRequest();
1510
+ } catch {
1511
+ this.selfRequest();
1512
+ }
1513
+ },
1514
+ methods: {
1515
+ selfRequest() {
1516
+ new ae().Init();
1517
+ },
1518
+ GetEquipGroupTreeWidthTreeType() {
1519
+ this.treeType && this.window[this.listKey] && this.buildTree();
1520
+ },
1521
+ GetEquipGroupTree() {
1522
+ !this.treeType && this.window[this.listKey] && this.buildTree();
1523
+ },
1524
+ buildTree() {
1525
+ if (this.window[this.listKey]) {
1526
+ let s = f.listToTreeList(JSON.parse(JSON.stringify(this.window[this.listKey])));
1527
+ this.list = f.formateList(JSON.parse(JSON.stringify(s))), this.window[`equipGroup${this.treeType}`] = s, this.hasBuildTree = !0;
1528
+ }
1529
+ },
1530
+ filterMethod(s) {
1531
+ this.$refs[this.refId].filterMethod(s);
1532
+ },
1533
+ resetCheckedStatus() {
1534
+ this.$refs[this.refId].resetCheckedStatus();
1535
+ },
1536
+ getEquipSelectd() {
1537
+ return this.$refs[this.refId].getEquipSelectd();
1538
+ },
1539
+ getControlSelected() {
1540
+ return this.$refs[this.refId].getControlSelected();
1541
+ },
1542
+ destroyTree() {
1543
+ this.$refs[this.refId].destroyTree();
1544
+ }
1545
+ }
1546
+ };
1547
+ function re(s, e, t, i, o, u) {
1548
+ const a = g("tree");
1549
+ return n(), S(a, $({
1550
+ ref: o.refId,
1551
+ data: o.list
1552
+ }, { ...s.$attrs, ...s.$props }, T(s.$listeners), { buildTree: u.buildTree }), null, 16, ["data", "buildTree"]);
1553
+ }
1554
+ const j = /* @__PURE__ */ E(he, [["render", re]]);
1555
+ j.install = function(s) {
1556
+ s.component(j.name, j);
1557
+ };
1558
+ export {
1559
+ j as default
1560
+ };