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

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,1562 @@
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
+ getColor() {
745
+ return function(s) {
746
+ let e;
747
+ switch (s) {
748
+ case 0:
749
+ e = this.colorConfig.noComm;
750
+ break;
751
+ case 1:
752
+ e = this.colorConfig.normal;
753
+ break;
754
+ case 2:
755
+ e = this.colorConfig.alarm;
756
+ break;
757
+ case 3:
758
+ e = this.colorConfig.lsSet;
759
+ break;
760
+ case 4:
761
+ e = this.colorConfig.initialize;
762
+ break;
763
+ case 5:
764
+ e = this.colorConfig.withdraw;
765
+ break;
766
+ case 6:
767
+ e = this.colorConfig.BackUp;
768
+ break;
769
+ default:
770
+ e = this.colorConfig.noComm;
771
+ break;
772
+ }
773
+ return e;
774
+ };
775
+ },
776
+ filterEquip() {
777
+ 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;
778
+ }
779
+ },
780
+ watch: {
781
+ filterEquip(s) {
782
+ s ? (this.setAlarmEqupGroup(), this.childrenResetGroupNum(!0)) : this.childrenResetGroupNum(!1);
783
+ }
784
+ },
785
+ data() {
786
+ return {
787
+ indent: 13
788
+ };
789
+ },
790
+ methods: {
791
+ clickFunction() {
792
+ this.source.expand = !this.source.expand, this.nodeClick(this.source, this.index, this.source.level, this.source.checked);
793
+ },
794
+ checkedChange(s) {
795
+ this.onChecked(this.source);
796
+ },
797
+ setAlarmEqupGroup() {
798
+ window.groupList.forEach((s) => {
799
+ window[`group-${s.id}-search`] = window["group-" + s.id].filter((e) => this.getEquipStatus(e.equipNo) === 2 || this.getEquipStatus(e.equipNo) === 0);
800
+ });
801
+ }
802
+ }
803
+ }, P = { class: "el-tree-node__content" }, H = { class: "nodeContent" }, z = {
804
+ key: 1,
805
+ class: "circle"
806
+ }, Q = { class: "label" }, X = {
807
+ key: 2,
808
+ class: "equipNumber"
809
+ }, Y = {
810
+ key: 4,
811
+ class: "el-tree-node__loading-icon el-icon-loading"
812
+ };
813
+ function Z(s, e, t, i, o, u) {
814
+ const a = g("el-checkbox"), r = g("oparate");
815
+ return u.filterEquip ? (n(), l("div", {
816
+ key: 0,
817
+ class: G(["el-tree-node", {
818
+ parent_tag: t.source.isGroup,
819
+ child_tags: !t.source.isGroup,
820
+ selectedColor: t.currentSelect === t.source.key && !t.source.isGroup
821
+ }]),
822
+ onClick: e[1] || (e[1] = (...h) => u.clickFunction && u.clickFunction(...h))
823
+ }, [
824
+ q("div", P, [
825
+ q("span", {
826
+ class: "el-tree__indent",
827
+ "aria-hidden": "true",
828
+ style: O({ width: (t.source.level - 1) * o.indent + "px" })
829
+ }, null, 4),
830
+ t.source.isGroup ? (n(), l("span", {
831
+ key: 0,
832
+ class: G([
833
+ {
834
+ "is-leaf": !t.source.isGroup,
835
+ expanded: t.source.isGroup && t.source.expand
836
+ },
837
+ "el-tree-node__expand-icon",
838
+ "iconfont icon-fangxiangL"
839
+ ])
840
+ }, null, 2)) : d("", !0),
841
+ q("div", H, [
842
+ t.showCheckbox ? (n(), S(a, {
843
+ key: 0,
844
+ modelValue: t.source.checked,
845
+ "onUpdate:modelValue": e[0] || (e[0] = (h) => t.source.checked = h),
846
+ indeterminate: t.source.indeterminate,
847
+ onChange: u.checkedChange
848
+ }, null, 8, ["modelValue", "indeterminate", "onChange"])) : d("", !0),
849
+ t.showStatus ? (n(), l("span", z, [
850
+ t.source.status != 6 ? (n(), l("span", {
851
+ key: 0,
852
+ class: "yd",
853
+ style: O({ backgroundColor: u.getColor(t.source.status) })
854
+ }, null, 4)) : (n(), l("i", {
855
+ key: 1,
856
+ style: O({ color: t.colorConfig.BackUp }),
857
+ class: "iconfont icon-gw-icon-beiji2"
858
+ }, null, 4))
859
+ ])) : d("", !0),
860
+ q("span", Q, b(t.source.title), 1),
861
+ t.source.isGroup && !t.source.isEquip || t.source.isGroup && !t.source.isEquip ? (n(), l("span", X, b(t.source.count), 1)) : d("", !0),
862
+ t.source.isGroup && t.showOperate ? (n(), S(r, {
863
+ key: 3,
864
+ source: t.source,
865
+ groupEditAndNew: t.groupEditAndNew,
866
+ deleteGroup: t.deleteGroup
867
+ }, null, 8, ["source", "groupEditAndNew", "deleteGroup"])) : d("", !0),
868
+ t.source.loading ? (n(), l("span", Y)) : d("", !0)
869
+ ])
870
+ ])
871
+ ], 2)) : d("", !0);
872
+ }
873
+ const ee = /* @__PURE__ */ E(R, [["render", Z]]), te = {
874
+ components: {
875
+ VirtualList: I
876
+ },
877
+ mixins: [m],
878
+ data() {
879
+ return {
880
+ itemComponent: ee,
881
+ //节点组件
882
+ visibleList: [],
883
+ //虚拟滚动所需要的列表
884
+ currentSelect: -1,
885
+ //当前选中的节点(不包含分组节点)
886
+ equipStatusManage: null,
887
+ //设备状态管理工具
888
+ cacheManage: null,
889
+ //内存管理工具
890
+ searchManage: null,
891
+ //搜索管理工具
892
+ equipNumManage: null,
893
+ //设备数量管理工具
894
+ requestManage: null,
895
+ //请求管理工具
896
+ checkStatusManage: null,
897
+ //请求管理工具
898
+ groupNodeObject: {},
899
+ //所有分组扁平化所保存的存储的地方
900
+ nodesMap: {},
901
+ //所有实例化对象映射
902
+ equipCheckObject: {},
903
+ //设备选中状态记录 equipCheckObject:{xxx设备号:{indeterminate: false,checked: false,groupId:xxx}}
904
+ equipStatusObject: {},
905
+ //记录设备状态,从后台推送的初始化全量状态,增量更新需要实时维护
906
+ controlObject: {},
907
+ //展开的控制项,controlObject:{xxx设备号:{groupId:xxx}}用于设置当前展开设置选中,如果依赖与equipControlObject筛选设置选中,性能差
908
+ isSearchStatus: !1,
909
+ //是否是搜索状态
910
+ equipControllObject: {},
911
+ //绑定所有的已选中的设备控制项
912
+ expandGroup: [],
913
+ //记录已展开的分组
914
+ updateJob: null
915
+ };
916
+ },
917
+ props: {
918
+ data: {
919
+ //分组列表
920
+ type: Array
921
+ },
922
+ selectEquips: {
923
+ //设备选中列表,用于回显,如权限管理
924
+ type: Array,
925
+ default: () => []
926
+ },
927
+ controllList: {
928
+ //控制项选中列表,用于回显,如权限管理
929
+ type: Array,
930
+ default: () => []
931
+ },
932
+ showSettings: {
933
+ //是否需要加载设备控制项,如权限管理
934
+ type: Boolean,
935
+ default: !1
936
+ },
937
+ showSelectNum: {
938
+ //是否在树形结构顶部展示已选设备数量,如设备管理
939
+ type: Boolean,
940
+ default() {
941
+ return !1;
942
+ }
943
+ },
944
+ showCheckbox: {
945
+ //是否展示checkbox
946
+ type: Boolean,
947
+ default: !1
948
+ },
949
+ showStatus: {
950
+ //是否展示设备状态
951
+ type: Boolean,
952
+ default: !1
953
+ },
954
+ filterEquip: {
955
+ //是否过滤
956
+ type: Boolean,
957
+ default: !1
958
+ },
959
+ showOperate: {
960
+ // 是否展示操作按钮
961
+ type: Boolean,
962
+ default: !1
963
+ },
964
+ defaultExpandAll: {
965
+ type: Boolean,
966
+ default: !1
967
+ },
968
+ currentNodeKey: [String, Number],
969
+ colorConfig: {
970
+ type: Object,
971
+ default: () => ({
972
+ noComm: "#a0a0a0",
973
+ normal: "#63e03f",
974
+ alarm: "#f22433",
975
+ lsSet: "#bebcaa",
976
+ initialize: "#289ac0",
977
+ withdraw: "#ffc0cb",
978
+ BackUp: "#f8901c"
979
+ })
980
+ },
981
+ treeType: {
982
+ type: String,
983
+ default: ""
984
+ },
985
+ buildTree: {
986
+ type: Function
987
+ },
988
+ filterData: {
989
+ type: Function
990
+ },
991
+ alias: {
992
+ type: String,
993
+ default: ""
994
+ }
995
+ },
996
+ watch: {
997
+ data(s) {
998
+ s && s.length && (f.flattern(this.data, this.groupNodeObject), this.cacheManage.addNodesMap(Object.values(this.groupNodeObject).map((e) => e)), this.init());
999
+ },
1000
+ controllList(s) {
1001
+ this.updateCheckedStatusWithControls();
1002
+ },
1003
+ selectEquips(s) {
1004
+ this.updateCheckedStatusWithEquips();
1005
+ },
1006
+ filterEquip(s) {
1007
+ this.$nextTick(() => {
1008
+ this.$refs.virtualList.scrollToIndex(0);
1009
+ });
1010
+ }
1011
+ },
1012
+ computed: {
1013
+ aliasName() {
1014
+ return this.alias ? `-${this.alias}` : "";
1015
+ }
1016
+ },
1017
+ created() {
1018
+ 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);
1019
+ },
1020
+ mounted() {
1021
+ this.updateCheckedStatusWithControls(), this.updateCheckedStatusWithEquips(), window.addEventListener("message", (s) => {
1022
+ s.data.type && this[s.data.type] && this[s.data.type](s.data.data);
1023
+ });
1024
+ },
1025
+ methods: {
1026
+ // 初始化
1027
+ init() {
1028
+ this.data[0].expand = !0, this.updateTreeList(), setTimeout(() => {
1029
+ Object.values(this.groupNodeObject).forEach((s) => {
1030
+ !s.expand && this.expandGroup.includes(s.key) && (s.expand = !0), this.filterWithAlias(s.key), this.updateGroupEquips(s.key, !0);
1031
+ }), this.equipNumManage.resetGroupNum(this.isSearchStatus), this.showStatus && !this.equipStatusManage && (this.equipStatusManage = new A(this.nodesMap, this.equipStatusObject, this.groupNodeObject, this.statusChange, this.aliasName));
1032
+ }, 500);
1033
+ },
1034
+ // 根据条件过滤
1035
+ filterWithAlias(s) {
1036
+ if (this.aliasName) {
1037
+ let e = this.window[`group-${s}`] || [];
1038
+ this.window[`group-${s}${this.aliasName}`] = this.filterData(e);
1039
+ }
1040
+ },
1041
+ // 更新当前选中
1042
+ updateCurrentSelect() {
1043
+ this.window.equipCache && this.window.equipCache[this.currentNodeKey] && (this.currentSelect = `${this.window.equipCache[this.currentNodeKey].groupId}-${this.currentNodeKey}`);
1044
+ },
1045
+ // 设备状态变化
1046
+ statusChange(s, e, t) {
1047
+ this.currentSelect == `${s}-${e}` && this.$emit("statusChange", e, t);
1048
+ },
1049
+ // 更新checkbox选中状态
1050
+ updateCheckWidthJob() {
1051
+ this.showCheckbox && (this.checkStatusManage.resetCheckedStatus(), this.updateCheckedStatusWithControls(), this.updateCheckedStatusWithEquips());
1052
+ },
1053
+ // 通过外框更新设备
1054
+ updateGroupEquips(s, e) {
1055
+ if (!this.isSearchStatus && this.groupNodeObject[s]) {
1056
+ let t = this.equipNumManage.getAllEquipsNum();
1057
+ this.$emit("getTotal", t);
1058
+ }
1059
+ this.groupNodeObject[s].expand && this.updateList(s, this.groupNodeObject[s].level, null, !1);
1060
+ },
1061
+ // 展开的时候从缓存中拿设备数据到equips中并更新视图
1062
+ updateList(s) {
1063
+ if (this.groupNodeObject[s]) {
1064
+ let e = [];
1065
+ 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();
1066
+ }
1067
+ },
1068
+ // 更新整个树形结构
1069
+ updateTreeList(s) {
1070
+ s && s.forEach((e) => {
1071
+ 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 || []);
1072
+ });
1073
+ },
1074
+ // 节点点击事件
1075
+ nodeClick(s, e, t, i) {
1076
+ 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;
1077
+ },
1078
+ groupClick(s, e, t) {
1079
+ s.expand ? this.updateList(s.key, s.level, e, t) : (this.cacheManage.recycleGroupCache(s.key), this.visibleList = [], this.updateTreeList(this.data));
1080
+ },
1081
+ async equipClick(s, e, t) {
1082
+ 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]));
1083
+ },
1084
+ onChecked(s) {
1085
+ this.checkStatusManage && this.checkStatusManage.onChecked(s, this.isSearchStatus), this.$emit("onCheck");
1086
+ },
1087
+ groupEditAndNew(s, e) {
1088
+ this.$emit("groupEditAndNew", { isGroupNew: s, node: e });
1089
+ },
1090
+ deleteGroup(s) {
1091
+ this.$emit("deleteGroup", s);
1092
+ },
1093
+ updateCheckedStatusWithControls() {
1094
+ this.controllList && this.controllList.length && this.checkStatusManage && this.checkStatusManage && this.checkStatusManage.updateCheckedStatusWithControls(this.controllList);
1095
+ },
1096
+ updateCheckedStatusWithEquips() {
1097
+ this.selectEquips && this.selectEquips.length && this.checkStatusManage && this.checkStatusManage && this.checkStatusManage.updateCheckedStatusWithEquips(this.selectEquips);
1098
+ },
1099
+ resetCheckedStatus() {
1100
+ this.checkStatusManage && this.checkStatusManage.resetCheckedStatus();
1101
+ },
1102
+
1103
+ /**
1104
+ * @description 获取选择的设备
1105
+ * @return Array
1106
+ */
1107
+ getEquipSelectd() {
1108
+ return this.checkStatusManage && this.checkStatusManage.getEquipSelectd();
1109
+ },
1110
+
1111
+ /**
1112
+ * @description 获取选择的设备控制项
1113
+ * @return Array
1114
+ */
1115
+ getControlSelected() {
1116
+ return this.checkStatusManage && this.checkStatusManage.getControlSelected();
1117
+ },
1118
+
1119
+ /**
1120
+ * @description 记录已展开的分组
1121
+ * @return 无
1122
+ */
1123
+ recordExpandGroup() {
1124
+ this.expandGroup = [], Object.values(this.groupNodeObject).forEach((s) => {
1125
+ s.expand && this.expandGroup.push(s.key);
1126
+ });
1127
+ },
1128
+
1129
+ /**
1130
+ * @description 清除已展开的分组
1131
+ * @return
1132
+ */
1133
+ removeExpandGroup() {
1134
+ this.$nextTick(() => {
1135
+ this.expandGroup = [];
1136
+ });
1137
+ },
1138
+
1139
+ /**
1140
+ * @description 搜索设备
1141
+ * 1:清除所有节点缓存
1142
+ 2: 设置搜索状态为true,搜索状态下所有操作全部不更新
1143
+ 3: 非搜索状态,需要清除搜索缓存
1144
+ * @param {searchName} 搜索名称
1145
+ * @return 无返回值
1146
+ */
1147
+ filterMethod(s) {
1148
+ this.visibleList = [], this.cacheManage.recycleAllNodeCache(), s ? (this.isSearchStatus = !0, this.searchManage.filterMethod(s)) : this.isSearchStatus = !1, this.init(), this.$nextTick(() => {
1149
+ this.$refs.virtualList.scrollToIndex(0);
1150
+ }), this.equipNumManage.resetGroupNum(this.isSearchStatus), this.showCheckbox && (this.checkStatusManage && this.checkStatusManage.reComputedCheckNum(this.isSearchStatus), this.checkStatusManage && this.checkStatusManage.updateGroupCheckStatus());
1151
+ },
1152
+ // 重新构建树
1153
+ rebuildTree() {
1154
+ this.recordExpandGroup(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus(), this.cacheManage.recycleAllNodeCache(!0), this.$nextTick(() => {
1155
+ this.buildTree(), this.removeExpandGroup();
1156
+ });
1157
+ },
1158
+ // 树形结构销毁
1159
+ destroyTree() {
1160
+ this.cacheManage.recycleAllNodeCache(!0), this.visibleList = [], this.updateTreeList(this.data);
1161
+ },
1162
+ // 通过外框事件更新树形结构数据--start
1163
+ /**
1164
+ * @description 获取分组设备
1165
+ * @param {data} {分组Id}
1166
+ * @return 无返回值
1167
+ */
1168
+ GetGroupEquips(s) {
1169
+ s.groupId && this.groupNodeObject[s.groupId] && !this.isSearchStatus && (this.updateGroupEquips(s.groupId, !0), this.updateJob && clearTimeout(this.updateJob), this.updateJob = setTimeout(() => {
1170
+ this.updateCheckWidthJob();
1171
+ }, 500));
1172
+ },
1173
+
1174
+ /**
1175
+ * @description 删除设备
1176
+ * @param {data} {groupId,equips}
1177
+ * @return 无返回值
1178
+ */
1179
+ DeleteEquip(s) {
1180
+ const { groupId: e, equips: t } = s || {};
1181
+ e && this.groupNodeObject[e] && (this.updateGroupEquips(s.groupId), this.equipNumManage.resetGroupNum(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus()), t.length && t.forEach((i) => {
1182
+ let o = this.nodesMap[`${e}-${i.id}`];
1183
+ 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];
1184
+ });
1185
+ },
1186
+
1187
+ /**
1188
+ * @description 移动设备
1189
+ * @param {data} {updateGroups} 需要更新的分组列表
1190
+ * @return 无返回值
1191
+ */
1192
+ moveEquips(s) {
1193
+ const { updateGroups: e, buildTree: t } = s || {};
1194
+ !t && e ? e.forEach((i) => {
1195
+ i && this.groupNodeObject[i] && (this.updateGroupEquips(i), this.equipNumManage.resetGroupNum(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus());
1196
+ }) : t && this.rebuildTree();
1197
+ },
1198
+
1199
+ /**
1200
+ * @description 删除分组
1201
+ * @param {data} {groupId,parentGroupId}
1202
+ * @return 无返回值
1203
+ */
1204
+ DeleteEquipGroup(s) {
1205
+ s.forEach((e) => {
1206
+ e.groupId && this.nodesMap[e.groupId] && (this.isSearchStatus || this.rebuildTree());
1207
+ });
1208
+ },
1209
+
1210
+ /**
1211
+ * @description 新增分组
1212
+ * @param {data} {groupId,parentGroupId}
1213
+ * @return 无返回值
1214
+ */
1215
+ AddEquipGroup(s) {
1216
+ const { parentGroupId: e, groupId: t } = s || {};
1217
+ t && this.nodesMap[e] && this.treeType && (this.isSearchStatus || this.rebuildTree());
1218
+ },
1219
+
1220
+ /** 编辑分组
1221
+ * @description 新增分组
1222
+ * @param {data} {groupId,parentGroupId}
1223
+ * @return 无返回值
1224
+ */
1225
+ EditEquipGroup(s) {
1226
+ const { groupId: e, groupName: t } = s;
1227
+ this.nodesMap[e] && (this.nodesMap[e].title = t);
1228
+ },
1229
+
1230
+ /**
1231
+ * @description 新增分组设备
1232
+ * @param {data} {分组Id,设备}
1233
+ * @return 无返回值
1234
+ */
1235
+ AddEquip(s) {
1236
+ const { groupId: e } = s || {};
1237
+ e && (this.isSearchStatus || this.rebuildTree());
1238
+ },
1239
+
1240
+ /**
1241
+ * @description 新增分组设备
1242
+ * @param {data} {分组Id,设备}
1243
+ * @return 无返回值
1244
+ */
1245
+ EditEquip(s) {
1246
+ const { equipNo: e, groupId: t, equipName: i } = s || {};
1247
+ this.nodesMap[`${t}-${e}`] && (this.isSearchStatus || (this.nodesMap[`${t}-${e}`].title = i));
1248
+ },
1249
+
1250
+ /**
1251
+ * @description 重置分组数量
1252
+ * @param {isSearchStatus} {是否查询状态}
1253
+ * @return 无返回值
1254
+ */
1255
+ childrenResetGroupNum(s) {
1256
+ this.equipNumManage.resetGroupNum(s);
1257
+ },
1258
+
1259
+ /**
1260
+ * @description 获取设备状态
1261
+ * @param {data} {equipNo}
1262
+ * @return arry[equipNo]
1263
+ */
1264
+ getEquipStatus(s) {
1265
+ return this.equipStatusManage.equipStatusObject[s];
1266
+ }
1267
+ // 通过外框事件更新树形结构数据--end
1268
+ }
1269
+ }, ie = {
1270
+ class: "gw-tree",
1271
+ style: { height: "100%" }
1272
+ }, se = {
1273
+ class: "tree",
1274
+ style: { height: "100%" }
1275
+ };
1276
+ function oe(s, e, t, i, o, u) {
1277
+ const a = g("virtual-list", !0);
1278
+ return n(), l("div", ie, [
1279
+ q("div", se, [
1280
+ C(a, {
1281
+ ref: "virtualList",
1282
+ class: "virtualList",
1283
+ "data-key": "key",
1284
+ "data-sources": o.visibleList,
1285
+ "data-component": o.itemComponent,
1286
+ keeps: 40,
1287
+ "extra-props": {
1288
+ currentSelect: o.currentSelect,
1289
+ nodeClick: u.nodeClick,
1290
+ showStatus: t.showStatus,
1291
+ filterEquip: t.filterEquip,
1292
+ showSettings: t.showSettings,
1293
+ showCheckbox: t.showCheckbox,
1294
+ onChecked: u.onChecked,
1295
+ showOperate: t.showOperate,
1296
+ groupEditAndNew: u.groupEditAndNew,
1297
+ deleteGroup: u.deleteGroup,
1298
+ colorConfig: t.colorConfig,
1299
+ childrenResetGroupNum: u.childrenResetGroupNum,
1300
+ getEquipStatus: u.getEquipStatus
1301
+ }
1302
+ }, null, 8, ["data-sources", "data-component", "extra-props"])
1303
+ ])
1304
+ ]);
1305
+ }
1306
+ const ue = /* @__PURE__ */ E(te, [["render", oe]]);
1307
+ class ae {
1308
+ constructor() {
1309
+ this.eGroupNotify = new y("/eGroupNotify", "", ""), this.alreadyUpdate = {}, this.notify = null, this.window = window;
1310
+ try {
1311
+ window.top.equipGroup, this.window = window.top;
1312
+ } catch {
1313
+ this.window = window;
1314
+ }
1315
+ }
1316
+ stop() {
1317
+ this.notify && this.notify.stop();
1318
+ }
1319
+ Init() {
1320
+ this.eGroupNotify.openConnect().then((e) => {
1321
+ this.notify = e;
1322
+ try {
1323
+ e.invoke("GetEquipGroupTree"), e.invoke("GetAllEquipGroupTree");
1324
+ } catch (t) {
1325
+ console.log(t);
1326
+ }
1327
+ this.subscribeTo(e, "GetEquipGroupTree"), this.subscribeTo(e, "AddEquipGroup"), this.subscribeTo(e, "EditEquipGroup"), this.subscribeTo(e, "DeleteEquipGroup");
1328
+ try {
1329
+ e.invoke("GetGroupEquips");
1330
+ } catch (t) {
1331
+ console.log(t);
1332
+ }
1333
+ 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) => {
1334
+ try {
1335
+ this.Init();
1336
+ } catch (i) {
1337
+ console.log(i);
1338
+ }
1339
+ console.log("重连", t);
1340
+ });
1341
+ }).catch((e) => {
1342
+ console.error(e);
1343
+ });
1344
+ }
1345
+ subscribeTo(e, t) {
1346
+ e.off(t), e.on(t, (i) => {
1347
+ i && i.isSuccess && (this[t] ? this[t](i.data) : this.notice({ func: t, data: i.data, key: i.groupId }));
1348
+ });
1349
+ }
1350
+ // 获取分组---无权限管理的分组列表--空设备分组不展示
1351
+ GetEquipGroupTree(e) {
1352
+ this.window.groupList || (this.window.groupList = e, this.notice({ type: "GetEquipGroupTree" }));
1353
+ }
1354
+ // 获取全量分组---设备管理使用
1355
+ GetAllEquipGroupTree(e) {
1356
+ this.window.groupList_manageMent || (this.window.groupList_manageMent = e, this.notice({ type: "GetEquipGroupTreeWidthTreeType" }));
1357
+ }
1358
+ // 新增分组
1359
+ AddEquipGroup(e) {
1360
+ const { parentGroupId: t, groupId: i, groupName: o } = e || {};
1361
+ i && (this.window.groupList_manageMent || (this.window.groupList_manageMent = []), this.window.groupList_manageMent.push({
1362
+ parentId: t,
1363
+ id: i,
1364
+ name: o,
1365
+ equipCount: 0
1366
+ }), this.notice({ type: "AddEquipGroup", data: e }));
1367
+ }
1368
+ // 编辑分组
1369
+ EditEquipGroup(e) {
1370
+ const { groupId: t, groupName: i } = e;
1371
+ this.window.groupList && window.groupList.forEach((o) => {
1372
+ o.id == t && (o.name = i);
1373
+ }), this.window.groupList_manageMent && window.groupList_manageMent.forEach((o) => {
1374
+ o.id == t && (o.name = i);
1375
+ }), this.notice({ type: "EditEquipGroup", data: e });
1376
+ }
1377
+ deleteChildGroup(e, t) {
1378
+ let i = [];
1379
+ t.forEach((o) => {
1380
+ o.parentId == e && i.push(o.id);
1381
+ }), i.forEach((o) => {
1382
+ let u = t.findIndex((a) => a.id == o);
1383
+ u > -1 && t.splice(u, 1), this.deleteChildGroup(o, t);
1384
+ });
1385
+ }
1386
+ // 删除分组
1387
+ DeleteEquipGroup(e) {
1388
+ e.forEach((t) => {
1389
+ if (this.window.groupList) {
1390
+ let i = this.window.groupList.findIndex((o) => o.id == t.groupId);
1391
+ i > -1 && this.window.groupList.splice(i, 1), this.deleteChildGroup(t.groupId, this.window.groupList);
1392
+ }
1393
+ if (this.window.groupList_manageMent) {
1394
+ let i = this.window.groupList_manageMent.findIndex((o) => o.id == t.groupId);
1395
+ i > -1 && this.window.groupList_manageMent.splice(i, 1), this.deleteChildGroup(t.groupId, this.window.groupList_manageMent);
1396
+ }
1397
+ }), this.notice({ type: "DeleteEquipGroup", data: e });
1398
+ }
1399
+ // 获取设备
1400
+ GetGroupEquips(e) {
1401
+ const { groupId: t, equips: i } = e || {};
1402
+ this.alreadyUpdate[t] || (this.window.groupCache || (this.window.groupCache = {}), this.window.groupCache[t] = {}, t && i && i instanceof Array && (i.forEach((o) => {
1403
+ 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;
1404
+ }), this.window[`group-${t}`] = i, this.notice({ type: "GetGroupEquips", data: { groupId: t } }), this.alreadyUpdate[t] = !0));
1405
+ }
1406
+ // 新增设备
1407
+ AddEquip(e) {
1408
+ const { groupId: t, equips: i } = e || {};
1409
+ 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 = {});
1410
+ let o = this.window[`group-${t}`].length;
1411
+ if (t && i) {
1412
+ if (i.forEach((u, a) => {
1413
+ this.window[`group-${t}`].push(
1414
+ {
1415
+ equipNo: u.id,
1416
+ groupId: t,
1417
+ id: u.id,
1418
+ title: u.name
1419
+ }
1420
+ ), this.window.equipCache[u.id] = this.window[`group-${t}`][o + a], this.window.groupCache[t][u.id] = this.window[`group-${t}`][o + a];
1421
+ }), !this.exist(t, this.window.groupList)) {
1422
+ let u = this.findParentList(t, this.window.groupList_manageMent);
1423
+ this.window.groupList.push(...u);
1424
+ }
1425
+ this.notice({ type: "AddEquip", data: e });
1426
+ }
1427
+ }
1428
+ moveEquips(e) {
1429
+ let t = [], i = !0, o = [];
1430
+ const { sourceGroup: u, targetGroupId: a } = e || {};
1431
+ a && t.push(a), u.forEach((r) => {
1432
+ 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) => {
1433
+ if (h.title = h.name, h.groupId = a, h.equipNo = h.id, this.window[`group-${r.groupId}`]) {
1434
+ let p = this.window[`group-${r.groupId}`].findIndex((c) => c.id == h.id);
1435
+ p > -1 && this.window[`group-${r.groupId}`].splice(p, 1);
1436
+ }
1437
+ window.equipCache || (this.window.equipCache = {}), this.window.equipCache[h.id] = h, this.window.groupCache[a][h.id] = h, this.window[`group-${a}`].push(h);
1438
+ }), !this.window[`group-${r.groupId}`].length) {
1439
+ let h = this.window.groupList.findIndex((p) => p.id == r.groupId);
1440
+ h > -1 && this.window.groupList.splice(h, 1), this.deleteChildGroup(r.groupId, this.window.groupList);
1441
+ }
1442
+ }), o.forEach((r) => {
1443
+ if (!this.exist(r, this.window.groupList)) {
1444
+ let h = this.findParentList(r, this.window.groupList_manageMent);
1445
+ this.window.groupList.push(...h);
1446
+ }
1447
+ }), this.notice({ type: "moveEquips", data: { updateGroups: t, buildTree: i } });
1448
+ }
1449
+ exist(e, t) {
1450
+ return t ? t.some((i) => i.id == e) : !1;
1451
+ }
1452
+ findParentList(e, t) {
1453
+ let i = [];
1454
+ if (t) {
1455
+ let o = t.findIndex((u) => u.id == e);
1456
+ 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));
1457
+ }
1458
+ return i;
1459
+ }
1460
+ // 删除设备
1461
+ DeleteEquip(e) {
1462
+ const { groupId: t, equips: i } = e || {};
1463
+ if (t && i && i instanceof Array) {
1464
+ if (this.window[`group-${t}`]) {
1465
+ for (let o = 0, u = i.length; o < u; o++) {
1466
+ let a = this.window[`group-${t}`].findIndex((r) => r.id == i[o].id);
1467
+ a > -1 && this.window[`group-${t}`].splice(a, 1), delete this.window.equipCache[i[o].id], delete this.window.groupCache[t][i[o].id];
1468
+ }
1469
+ }
1470
+ this.notice({ type: "DeleteEquip", data: e });
1471
+ }
1472
+ }
1473
+ // 编辑设备
1474
+ EditEquip(e) {
1475
+ const { equipNo: t, groupId: i, equipName: o } = e || {};
1476
+ i && t && (window[`group-${i}`] && (this.window.equipCache[t] = o), this.notice({ type: "EditEquip", data: e }));
1477
+ }
1478
+ notice(e) {
1479
+ if (this.window.hasIframe) {
1480
+ let t = document.getElementsByTagName("iframe");
1481
+ for (let i of t) { i.contentWindow.postMessage(e); }
1482
+ } else { window.postMessage(e, "*"); }
1483
+ }
1484
+ }
1485
+ const he = {
1486
+ name: "treeV2",
1487
+ components: {
1488
+ tree: ue
1489
+ },
1490
+ mixins: [m],
1491
+ data() {
1492
+ return {
1493
+ list: [],
1494
+ refId: f.generateUUID(),
1495
+ treeKey: null,
1496
+ listKey: null,
1497
+ hasBuildTree: !1
1498
+ };
1499
+ },
1500
+ props: {
1501
+ treeType: {
1502
+ type: String,
1503
+ default: ""
1504
+ }
1505
+ },
1506
+ mounted() {
1507
+ 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) => {
1508
+ s && s.data && s.data.type && this[s.data.type] && this[s.data.type]();
1509
+ });
1510
+ try {
1511
+ this.window.hasIframe || this.selfRequest();
1512
+ } catch {
1513
+ this.selfRequest();
1514
+ }
1515
+ },
1516
+ methods: {
1517
+ selfRequest() {
1518
+ new ae().Init();
1519
+ },
1520
+ GetEquipGroupTreeWidthTreeType() {
1521
+ this.treeType && this.window[this.listKey] && this.buildTree();
1522
+ },
1523
+ GetEquipGroupTree() {
1524
+ !this.treeType && this.window[this.listKey] && this.buildTree();
1525
+ },
1526
+ buildTree() {
1527
+ if (this.window[this.listKey]) {
1528
+ let s = f.listToTreeList(JSON.parse(JSON.stringify(this.window[this.listKey])));
1529
+ this.list = f.formateList(JSON.parse(JSON.stringify(s))), this.window[`equipGroup${this.treeType}`] = s, this.hasBuildTree = !0;
1530
+ }
1531
+ },
1532
+ filterMethod(s) {
1533
+ this.$refs[this.refId].filterMethod(s);
1534
+ },
1535
+ resetCheckedStatus() {
1536
+ this.$refs[this.refId].resetCheckedStatus();
1537
+ },
1538
+ getEquipSelectd() {
1539
+ return this.$refs[this.refId].getEquipSelectd();
1540
+ },
1541
+ getControlSelected() {
1542
+ return this.$refs[this.refId].getControlSelected();
1543
+ },
1544
+ destroyTree() {
1545
+ this.$refs[this.refId].destroyTree();
1546
+ }
1547
+ }
1548
+ };
1549
+ function re(s, e, t, i, o, u) {
1550
+ const a = g("tree");
1551
+ return n(), S(a, $({
1552
+ ref: o.refId,
1553
+ data: o.list
1554
+ }, { ...s.$attrs, ...s.$props }, T(s.$listeners), { buildTree: u.buildTree }), null, 16, ["data", "buildTree"]);
1555
+ }
1556
+ const j = /* @__PURE__ */ E(he, [["render", re]]);
1557
+ j.install = function(s) {
1558
+ s.component(j.name, j);
1559
+ };
1560
+ export {
1561
+ j as default
1562
+ };