@ganwei-web/gw-base-components-plus 1.0.51 → 1.0.53
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,2521 @@
|
|
|
1
|
+
import "./style.css";
|
|
2
|
+
import { defineComponent as ae, ref as z, createVNode as C, watch as P, onBeforeMount as Ie, onActivated as xe, onMounted as Ce, onUnmounted as be, computed as Te, onUpdated as $e, resolveComponent as I, openBlock as m, createElementBlock as N, withCtx as $, createElementVNode as E, withModifiers as oe, createTextVNode as te, toDisplayString as R, createBlock as K, createCommentVNode as j, normalizeClass as pe, normalizeStyle as ie, mergeProps as _e, toHandlers as Le } from "vue";
|
|
3
|
+
import { io as Ae } from "socket.io-client";
|
|
4
|
+
import "@aspnet/signalr";
|
|
5
|
+
function fe(s, e) {
|
|
6
|
+
var t = Object.keys(s);
|
|
7
|
+
if (Object.getOwnPropertySymbols) {
|
|
8
|
+
var i = Object.getOwnPropertySymbols(s);
|
|
9
|
+
e && (i = i.filter(function(o) {
|
|
10
|
+
return Object.getOwnPropertyDescriptor(s, o).enumerable;
|
|
11
|
+
})), t.push.apply(t, i);
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
14
|
+
}
|
|
15
|
+
function U(s) {
|
|
16
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
17
|
+
var t = arguments[e] != null ? arguments[e] : {};
|
|
18
|
+
e % 2 ? fe(Object(t), !0).forEach(function(i) {
|
|
19
|
+
Be(s, i, t[i]);
|
|
20
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(t)) : fe(Object(t)).forEach(function(i) {
|
|
21
|
+
Object.defineProperty(s, i, Object.getOwnPropertyDescriptor(t, i));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return s;
|
|
25
|
+
}
|
|
26
|
+
function ze(s, e) {
|
|
27
|
+
if (!(s instanceof e))
|
|
28
|
+
throw new TypeError("Cannot call a class as a function");
|
|
29
|
+
}
|
|
30
|
+
function ge(s, e) {
|
|
31
|
+
for (var t = 0; t < e.length; t++) {
|
|
32
|
+
var i = e[t];
|
|
33
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(s, i.key, i);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function Re(s, e, t) {
|
|
37
|
+
return e && ge(s.prototype, e), t && ge(s, t), s;
|
|
38
|
+
}
|
|
39
|
+
function Be(s, e, t) {
|
|
40
|
+
return e in s ? Object.defineProperty(s, e, {
|
|
41
|
+
value: t,
|
|
42
|
+
enumerable: !0,
|
|
43
|
+
configurable: !0,
|
|
44
|
+
writable: !0
|
|
45
|
+
}) : s[e] = t, s;
|
|
46
|
+
}
|
|
47
|
+
function De(s) {
|
|
48
|
+
return Fe(s) || Pe(s) || Ue(s) || Ke();
|
|
49
|
+
}
|
|
50
|
+
function Fe(s) {
|
|
51
|
+
if (Array.isArray(s))
|
|
52
|
+
return ne(s);
|
|
53
|
+
}
|
|
54
|
+
function Pe(s) {
|
|
55
|
+
if (typeof Symbol < "u" && s[Symbol.iterator] != null || s["@@iterator"] != null)
|
|
56
|
+
return Array.from(s);
|
|
57
|
+
}
|
|
58
|
+
function Ue(s, e) {
|
|
59
|
+
if (s) {
|
|
60
|
+
if (typeof s == "string")
|
|
61
|
+
return ne(s, e);
|
|
62
|
+
var t = Object.prototype.toString.call(s).slice(8, -1);
|
|
63
|
+
if (t === "Object" && s.constructor && (t = s.constructor.name), t === "Map" || t === "Set")
|
|
64
|
+
return Array.from(s);
|
|
65
|
+
if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))
|
|
66
|
+
return ne(s, e);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function ne(s, e) {
|
|
70
|
+
(e == null || e > s.length) && (e = s.length);
|
|
71
|
+
for (var t = 0, i = new Array(e); t < e; t++)
|
|
72
|
+
i[t] = s[t];
|
|
73
|
+
return i;
|
|
74
|
+
}
|
|
75
|
+
function Ke() {
|
|
76
|
+
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
77
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
78
|
+
}
|
|
79
|
+
var _ = {
|
|
80
|
+
FRONT: "FRONT",
|
|
81
|
+
// scroll up or left
|
|
82
|
+
BEHIND: "BEHIND"
|
|
83
|
+
// scroll down or right
|
|
84
|
+
}, G = {
|
|
85
|
+
INIT: "INIT",
|
|
86
|
+
FIXED: "FIXED",
|
|
87
|
+
DYNAMIC: "DYNAMIC"
|
|
88
|
+
}, Se = 2, He = /* @__PURE__ */ function() {
|
|
89
|
+
function s(e, t) {
|
|
90
|
+
ze(this, s), this.init(e, t);
|
|
91
|
+
}
|
|
92
|
+
return Re(s, [{
|
|
93
|
+
key: "init",
|
|
94
|
+
value: function(t, i) {
|
|
95
|
+
this.param = t, this.callUpdate = i, this.sizes = /* @__PURE__ */ new Map(), this.firstRangeTotalSize = 0, this.firstRangeAverageSize = 0, this.lastCalcIndex = 0, this.fixedSizeValue = 0, this.calcType = G.INIT, this.offset = 0, this.direction = "", this.range = /* @__PURE__ */ Object.create(null), t && this.checkRange(0, t.keeps - 1);
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "destroy",
|
|
99
|
+
value: function() {
|
|
100
|
+
this.init(null, null);
|
|
101
|
+
}
|
|
102
|
+
// return current render range
|
|
103
|
+
}, {
|
|
104
|
+
key: "getRange",
|
|
105
|
+
value: function() {
|
|
106
|
+
var t = /* @__PURE__ */ Object.create(null);
|
|
107
|
+
return t.start = this.range.start, t.end = this.range.end, t.padFront = this.range.padFront, t.padBehind = this.range.padBehind, t;
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "isBehind",
|
|
111
|
+
value: function() {
|
|
112
|
+
return this.direction === _.BEHIND;
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "isFront",
|
|
116
|
+
value: function() {
|
|
117
|
+
return this.direction === _.FRONT;
|
|
118
|
+
}
|
|
119
|
+
// return start index offset
|
|
120
|
+
}, {
|
|
121
|
+
key: "getOffset",
|
|
122
|
+
value: function(t) {
|
|
123
|
+
return (t < 1 ? 0 : this.getIndexOffset(t)) + this.param.slotHeaderSize;
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "updateParam",
|
|
127
|
+
value: function(t, i) {
|
|
128
|
+
var o = this;
|
|
129
|
+
this.param && t in this.param && (t === "uniqueIds" && this.sizes.forEach(function(n, a) {
|
|
130
|
+
i.includes(a) || o.sizes.delete(a);
|
|
131
|
+
}), this.param[t] = i);
|
|
132
|
+
}
|
|
133
|
+
// save each size map by id
|
|
134
|
+
}, {
|
|
135
|
+
key: "saveSize",
|
|
136
|
+
value: function(t, i) {
|
|
137
|
+
this.sizes.set(t, i), this.calcType === G.INIT ? (this.fixedSizeValue = i, this.calcType = G.FIXED) : this.calcType === G.FIXED && this.fixedSizeValue !== i && (this.calcType = G.DYNAMIC, delete this.fixedSizeValue), this.calcType !== G.FIXED && typeof this.firstRangeTotalSize < "u" && (this.sizes.size < Math.min(this.param.keeps, this.param.uniqueIds.length) ? (this.firstRangeTotalSize = De(this.sizes.values()).reduce(function(o, n) {
|
|
138
|
+
return o + n;
|
|
139
|
+
}, 0), this.firstRangeAverageSize = Math.round(this.firstRangeTotalSize / this.sizes.size)) : delete this.firstRangeTotalSize);
|
|
140
|
+
}
|
|
141
|
+
// in some special situation (e.g. length change) we need to update in a row
|
|
142
|
+
// try goiong to render next range by a leading buffer according to current direction
|
|
143
|
+
}, {
|
|
144
|
+
key: "handleDataSourcesChange",
|
|
145
|
+
value: function() {
|
|
146
|
+
var t = this.range.start;
|
|
147
|
+
this.isFront() ? t = t - Se : this.isBehind() && (t = t + Se), t = Math.max(t, 0), this.updateRange(this.range.start, this.getEndByStart(t));
|
|
148
|
+
}
|
|
149
|
+
// when slot size change, we also need force update
|
|
150
|
+
}, {
|
|
151
|
+
key: "handleSlotSizeChange",
|
|
152
|
+
value: function() {
|
|
153
|
+
this.handleDataSourcesChange();
|
|
154
|
+
}
|
|
155
|
+
// calculating range on scroll
|
|
156
|
+
}, {
|
|
157
|
+
key: "handleScroll",
|
|
158
|
+
value: function(t) {
|
|
159
|
+
this.direction = t < this.offset ? _.FRONT : _.BEHIND, this.offset = t, this.param && (this.direction === _.FRONT ? this.handleFront() : this.direction === _.BEHIND && this.handleBehind());
|
|
160
|
+
}
|
|
161
|
+
// ----------- public method end -----------
|
|
162
|
+
}, {
|
|
163
|
+
key: "handleFront",
|
|
164
|
+
value: function() {
|
|
165
|
+
var t = this.getScrollOvers();
|
|
166
|
+
if (!(t > this.range.start)) {
|
|
167
|
+
var i = Math.max(t - this.param.buffer, 0);
|
|
168
|
+
this.checkRange(i, this.getEndByStart(i));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "handleBehind",
|
|
173
|
+
value: function() {
|
|
174
|
+
var t = this.getScrollOvers();
|
|
175
|
+
t < this.range.start + this.param.buffer || this.checkRange(t, this.getEndByStart(t));
|
|
176
|
+
}
|
|
177
|
+
// return the pass overs according to current scroll offset
|
|
178
|
+
}, {
|
|
179
|
+
key: "getScrollOvers",
|
|
180
|
+
value: function() {
|
|
181
|
+
var t = this.offset - this.param.slotHeaderSize;
|
|
182
|
+
if (t <= 0)
|
|
183
|
+
return 0;
|
|
184
|
+
if (this.isFixedType())
|
|
185
|
+
return Math.floor(t / this.fixedSizeValue);
|
|
186
|
+
for (var i = 0, o = 0, n = 0, a = this.param.uniqueIds.length; i <= a; ) {
|
|
187
|
+
if (o = i + Math.floor((a - i) / 2), n = this.getIndexOffset(o), n === t)
|
|
188
|
+
return o;
|
|
189
|
+
n < t ? i = o + 1 : n > t && (a = o - 1);
|
|
190
|
+
}
|
|
191
|
+
return i > 0 ? --i : 0;
|
|
192
|
+
}
|
|
193
|
+
// return a scroll offset from given index, can efficiency be improved more here?
|
|
194
|
+
// although the call frequency is very high, its only a superposition of numbers
|
|
195
|
+
}, {
|
|
196
|
+
key: "getIndexOffset",
|
|
197
|
+
value: function(t) {
|
|
198
|
+
if (!t)
|
|
199
|
+
return 0;
|
|
200
|
+
for (var i = 0, o = 0, n = 0; n < t; n++)
|
|
201
|
+
o = this.sizes.get(this.param.uniqueIds[n]), i = i + (typeof o == "number" ? o : this.getEstimateSize());
|
|
202
|
+
return this.lastCalcIndex = Math.max(this.lastCalcIndex, t - 1), this.lastCalcIndex = Math.min(this.lastCalcIndex, this.getLastIndex()), i;
|
|
203
|
+
}
|
|
204
|
+
// is fixed size type
|
|
205
|
+
}, {
|
|
206
|
+
key: "isFixedType",
|
|
207
|
+
value: function() {
|
|
208
|
+
return this.calcType === G.FIXED;
|
|
209
|
+
}
|
|
210
|
+
// return the real last index
|
|
211
|
+
}, {
|
|
212
|
+
key: "getLastIndex",
|
|
213
|
+
value: function() {
|
|
214
|
+
return this.param.uniqueIds.length - 1;
|
|
215
|
+
}
|
|
216
|
+
// in some conditions range is broke, we need correct it
|
|
217
|
+
// and then decide whether need update to next range
|
|
218
|
+
}, {
|
|
219
|
+
key: "checkRange",
|
|
220
|
+
value: function(t, i) {
|
|
221
|
+
var o = this.param.keeps, n = this.param.uniqueIds.length;
|
|
222
|
+
n <= o ? (t = 0, i = this.getLastIndex()) : i - t < o - 1 && (t = i - o + 1), this.range.start !== t && this.updateRange(t, i);
|
|
223
|
+
}
|
|
224
|
+
// setting to a new range and rerender
|
|
225
|
+
}, {
|
|
226
|
+
key: "updateRange",
|
|
227
|
+
value: function(t, i) {
|
|
228
|
+
this.range.start = t, this.range.end = i, this.range.padFront = this.getPadFront(), this.range.padBehind = this.getPadBehind(), this.callUpdate(this.getRange());
|
|
229
|
+
}
|
|
230
|
+
// return end base on start
|
|
231
|
+
}, {
|
|
232
|
+
key: "getEndByStart",
|
|
233
|
+
value: function(t) {
|
|
234
|
+
var i = t + this.param.keeps - 1, o = Math.min(i, this.getLastIndex());
|
|
235
|
+
return o;
|
|
236
|
+
}
|
|
237
|
+
// return total front offset
|
|
238
|
+
}, {
|
|
239
|
+
key: "getPadFront",
|
|
240
|
+
value: function() {
|
|
241
|
+
return this.isFixedType() ? this.fixedSizeValue * this.range.start : this.getIndexOffset(this.range.start);
|
|
242
|
+
}
|
|
243
|
+
// return total behind offset
|
|
244
|
+
}, {
|
|
245
|
+
key: "getPadBehind",
|
|
246
|
+
value: function() {
|
|
247
|
+
var t = this.range.end, i = this.getLastIndex();
|
|
248
|
+
return this.isFixedType() ? (i - t) * this.fixedSizeValue : this.lastCalcIndex === i ? this.getIndexOffset(i) - this.getIndexOffset(t) : (i - t) * this.getEstimateSize();
|
|
249
|
+
}
|
|
250
|
+
// get the item estimate size
|
|
251
|
+
}, {
|
|
252
|
+
key: "getEstimateSize",
|
|
253
|
+
value: function() {
|
|
254
|
+
return this.isFixedType() ? this.fixedSizeValue : this.firstRangeAverageSize || this.param.estimateSize;
|
|
255
|
+
}
|
|
256
|
+
}]), s;
|
|
257
|
+
}(), Ve = {
|
|
258
|
+
dataKey: {
|
|
259
|
+
type: [String, Function],
|
|
260
|
+
required: !0
|
|
261
|
+
},
|
|
262
|
+
dataSources: {
|
|
263
|
+
type: Array,
|
|
264
|
+
required: !0,
|
|
265
|
+
default: function() {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
dataComponent: {
|
|
270
|
+
type: [Object, Function],
|
|
271
|
+
required: !0
|
|
272
|
+
},
|
|
273
|
+
keeps: {
|
|
274
|
+
type: Number,
|
|
275
|
+
default: 30
|
|
276
|
+
},
|
|
277
|
+
extraProps: {
|
|
278
|
+
type: Object
|
|
279
|
+
},
|
|
280
|
+
estimateSize: {
|
|
281
|
+
type: Number,
|
|
282
|
+
default: 50
|
|
283
|
+
},
|
|
284
|
+
direction: {
|
|
285
|
+
type: String,
|
|
286
|
+
default: "vertical"
|
|
287
|
+
// the other value is horizontal
|
|
288
|
+
},
|
|
289
|
+
start: {
|
|
290
|
+
type: Number,
|
|
291
|
+
default: 0
|
|
292
|
+
},
|
|
293
|
+
offset: {
|
|
294
|
+
type: Number,
|
|
295
|
+
default: 0
|
|
296
|
+
},
|
|
297
|
+
topThreshold: {
|
|
298
|
+
type: Number,
|
|
299
|
+
default: 0
|
|
300
|
+
},
|
|
301
|
+
bottomThreshold: {
|
|
302
|
+
type: Number,
|
|
303
|
+
default: 0
|
|
304
|
+
},
|
|
305
|
+
pageMode: {
|
|
306
|
+
type: Boolean,
|
|
307
|
+
default: !1
|
|
308
|
+
},
|
|
309
|
+
rootTag: {
|
|
310
|
+
type: String,
|
|
311
|
+
default: "div"
|
|
312
|
+
},
|
|
313
|
+
wrapTag: {
|
|
314
|
+
type: String,
|
|
315
|
+
default: "div"
|
|
316
|
+
},
|
|
317
|
+
wrapClass: {
|
|
318
|
+
type: String,
|
|
319
|
+
default: "wrap"
|
|
320
|
+
},
|
|
321
|
+
wrapStyle: {
|
|
322
|
+
type: Object
|
|
323
|
+
},
|
|
324
|
+
itemTag: {
|
|
325
|
+
type: String,
|
|
326
|
+
default: "div"
|
|
327
|
+
},
|
|
328
|
+
itemClass: {
|
|
329
|
+
type: String,
|
|
330
|
+
default: ""
|
|
331
|
+
},
|
|
332
|
+
itemClassAdd: {
|
|
333
|
+
type: Function
|
|
334
|
+
},
|
|
335
|
+
itemStyle: {
|
|
336
|
+
type: Object
|
|
337
|
+
},
|
|
338
|
+
headerTag: {
|
|
339
|
+
type: String,
|
|
340
|
+
default: "div"
|
|
341
|
+
},
|
|
342
|
+
headerClass: {
|
|
343
|
+
type: String,
|
|
344
|
+
default: ""
|
|
345
|
+
},
|
|
346
|
+
headerStyle: {
|
|
347
|
+
type: Object
|
|
348
|
+
},
|
|
349
|
+
footerTag: {
|
|
350
|
+
type: String,
|
|
351
|
+
default: "div"
|
|
352
|
+
},
|
|
353
|
+
footerClass: {
|
|
354
|
+
type: String,
|
|
355
|
+
default: ""
|
|
356
|
+
},
|
|
357
|
+
footerStyle: {
|
|
358
|
+
type: Object
|
|
359
|
+
},
|
|
360
|
+
itemScopedSlots: {
|
|
361
|
+
type: Object
|
|
362
|
+
}
|
|
363
|
+
}, We = {
|
|
364
|
+
index: {
|
|
365
|
+
type: Number
|
|
366
|
+
},
|
|
367
|
+
event: {
|
|
368
|
+
type: String
|
|
369
|
+
},
|
|
370
|
+
tag: {
|
|
371
|
+
type: String
|
|
372
|
+
},
|
|
373
|
+
horizontal: {
|
|
374
|
+
type: Boolean
|
|
375
|
+
},
|
|
376
|
+
source: {
|
|
377
|
+
type: Object
|
|
378
|
+
},
|
|
379
|
+
component: {
|
|
380
|
+
type: [Object, Function]
|
|
381
|
+
},
|
|
382
|
+
uniqueKey: {
|
|
383
|
+
type: [String, Number]
|
|
384
|
+
},
|
|
385
|
+
extraProps: {
|
|
386
|
+
type: Object
|
|
387
|
+
},
|
|
388
|
+
scopedSlots: {
|
|
389
|
+
type: Object
|
|
390
|
+
}
|
|
391
|
+
}, Je = {
|
|
392
|
+
event: {
|
|
393
|
+
type: String
|
|
394
|
+
},
|
|
395
|
+
uniqueKey: {
|
|
396
|
+
type: String
|
|
397
|
+
},
|
|
398
|
+
tag: {
|
|
399
|
+
type: String
|
|
400
|
+
},
|
|
401
|
+
horizontal: {
|
|
402
|
+
type: Boolean
|
|
403
|
+
}
|
|
404
|
+
}, me = function(e, t, i) {
|
|
405
|
+
var o = null, n = Te(function() {
|
|
406
|
+
return e.horizontal ? "offsetWidth" : "offsetHeight";
|
|
407
|
+
}), a = function() {
|
|
408
|
+
return t.value ? t.value[n.value] : 0;
|
|
409
|
+
}, r = function() {
|
|
410
|
+
var h = e.event, c = e.uniqueKey, d = e.hasInitial;
|
|
411
|
+
i(h, c, a(), d);
|
|
412
|
+
};
|
|
413
|
+
Ce(function() {
|
|
414
|
+
typeof ResizeObserver < "u" && (o = new ResizeObserver(function() {
|
|
415
|
+
r();
|
|
416
|
+
}), t.value && o.observe(t.value));
|
|
417
|
+
}), $e(function() {
|
|
418
|
+
r();
|
|
419
|
+
}), be(function() {
|
|
420
|
+
o && (o.disconnect(), o = null);
|
|
421
|
+
});
|
|
422
|
+
}, Xe = ae({
|
|
423
|
+
name: "VirtualListItem",
|
|
424
|
+
props: We,
|
|
425
|
+
emits: ["itemResize"],
|
|
426
|
+
setup: function(e, t) {
|
|
427
|
+
var i = t.emit, o = z(null);
|
|
428
|
+
return me(e, o, i), function() {
|
|
429
|
+
var n = e.tag, a = e.component, r = e.extraProps, u = r === void 0 ? {} : r, h = e.index, c = e.source, d = e.scopedSlots, S = d === void 0 ? {} : d, g = e.uniqueKey, q = U(U({}, u), {}, {
|
|
430
|
+
source: c,
|
|
431
|
+
index: h
|
|
432
|
+
});
|
|
433
|
+
return C(n, {
|
|
434
|
+
key: g,
|
|
435
|
+
ref: o
|
|
436
|
+
}, {
|
|
437
|
+
default: function() {
|
|
438
|
+
return [C(a, U(U({}, q), {}, {
|
|
439
|
+
scopedSlots: S
|
|
440
|
+
}), null)];
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
}), we = ae({
|
|
446
|
+
name: "VirtualListSlot",
|
|
447
|
+
props: Je,
|
|
448
|
+
emits: ["slotResize"],
|
|
449
|
+
setup: function(e, t) {
|
|
450
|
+
var i = t.slots, o = t.emit, n = z(null);
|
|
451
|
+
return me(e, n, o), function() {
|
|
452
|
+
var a, r = e.tag, u = e.uniqueKey;
|
|
453
|
+
return C(r, {
|
|
454
|
+
ref: n,
|
|
455
|
+
key: u
|
|
456
|
+
}, {
|
|
457
|
+
default: function() {
|
|
458
|
+
return [(a = i.default) === null || a === void 0 ? void 0 : a.call(i)];
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}), B;
|
|
464
|
+
(function(s) {
|
|
465
|
+
s.ITEM = "itemResize", s.SLOT = "slotResize";
|
|
466
|
+
})(B || (B = {}));
|
|
467
|
+
var L;
|
|
468
|
+
(function(s) {
|
|
469
|
+
s.HEADER = "thead", s.FOOTER = "tfoot";
|
|
470
|
+
})(L || (L = {}));
|
|
471
|
+
var Ye = ae({
|
|
472
|
+
name: "VirtualList",
|
|
473
|
+
props: Ve,
|
|
474
|
+
setup: function(e, t) {
|
|
475
|
+
var i = t.emit, o = t.slots, n = t.expose, a = e.direction === "horizontal", r = a ? "scrollLeft" : "scrollTop", u = z(null), h = z(), c = z(null), d;
|
|
476
|
+
P(function() {
|
|
477
|
+
return e.dataSources.length;
|
|
478
|
+
}, function() {
|
|
479
|
+
d.updateParam("uniqueIds", re()), d.handleDataSourcesChange();
|
|
480
|
+
}), P(function() {
|
|
481
|
+
return e.keeps;
|
|
482
|
+
}, function(p) {
|
|
483
|
+
d.updateParam("keeps", p), d.handleSlotSizeChange();
|
|
484
|
+
}), P(function() {
|
|
485
|
+
return e.start;
|
|
486
|
+
}, function(p) {
|
|
487
|
+
J(p);
|
|
488
|
+
}), P(function() {
|
|
489
|
+
return e.offset;
|
|
490
|
+
}, function(p) {
|
|
491
|
+
return x(p);
|
|
492
|
+
});
|
|
493
|
+
var S = function(l) {
|
|
494
|
+
return d.sizes.get(l);
|
|
495
|
+
}, g = function() {
|
|
496
|
+
return e.pageMode ? document.documentElement[r] || document.body[r] : h.value ? Math.ceil(h.value[r]) : 0;
|
|
497
|
+
}, q = function() {
|
|
498
|
+
var l = a ? "clientWidth" : "clientHeight";
|
|
499
|
+
return e.pageMode ? document.documentElement[l] || document.body[l] : h.value ? Math.ceil(h.value[l]) : 0;
|
|
500
|
+
}, v = function() {
|
|
501
|
+
var l = a ? "scrollWidth" : "scrollHeight";
|
|
502
|
+
return e.pageMode ? document.documentElement[l] || document.body[l] : h.value ? Math.ceil(h.value[l]) : 0;
|
|
503
|
+
}, Ne = function(l, f, w, b) {
|
|
504
|
+
i("scroll", b, d.getRange()), d.isFront() && e.dataSources.length && l - e.topThreshold <= 0 ? i("totop") : d.isBehind() && l + f + e.bottomThreshold >= w && i("tobottom");
|
|
505
|
+
}, W = function(l) {
|
|
506
|
+
var f = g(), w = q(), b = v();
|
|
507
|
+
f < 0 || f + w > b + 1 || !b || (d.handleScroll(f), Ne(f, w, b, l));
|
|
508
|
+
}, re = function() {
|
|
509
|
+
var l = e.dataKey, f = e.dataSources, w = f === void 0 ? [] : f;
|
|
510
|
+
return w.map(function(b) {
|
|
511
|
+
return typeof l == "function" ? l(b) : b[l];
|
|
512
|
+
});
|
|
513
|
+
}, Ee = function(l) {
|
|
514
|
+
u.value = l;
|
|
515
|
+
}, Oe = function() {
|
|
516
|
+
d = new He({
|
|
517
|
+
slotHeaderSize: 0,
|
|
518
|
+
slotFooterSize: 0,
|
|
519
|
+
keeps: e.keeps,
|
|
520
|
+
estimateSize: e.estimateSize,
|
|
521
|
+
buffer: Math.round(e.keeps / 3),
|
|
522
|
+
// recommend for a third of keeps
|
|
523
|
+
uniqueIds: re()
|
|
524
|
+
}, Ee), u.value = d.getRange();
|
|
525
|
+
}, J = function(l) {
|
|
526
|
+
if (l >= e.dataSources.length - 1)
|
|
527
|
+
he();
|
|
528
|
+
else {
|
|
529
|
+
var f = d.getOffset(l);
|
|
530
|
+
x(f);
|
|
531
|
+
}
|
|
532
|
+
}, x = function(l) {
|
|
533
|
+
e.pageMode ? (document.body[r] = l, document.documentElement[r] = l) : h.value && (h.value[r] = l);
|
|
534
|
+
}, ve = function() {
|
|
535
|
+
for (var l = [], f = u.value, w = f.start, b = f.end, X = e.dataSources, T = e.dataKey, Y = e.itemClass, Q = e.itemTag, Z = e.itemStyle, ee = e.extraProps, D = e.dataComponent, F = e.itemScopedSlots, k = w; k <= b; k++) {
|
|
536
|
+
var M = X[k];
|
|
537
|
+
if (M) {
|
|
538
|
+
var A = typeof T == "function" ? T(M) : M[T];
|
|
539
|
+
typeof A == "string" || typeof A == "number" ? l.push(C(Xe, {
|
|
540
|
+
index: k,
|
|
541
|
+
tag: Q,
|
|
542
|
+
event: B.ITEM,
|
|
543
|
+
horizontal: a,
|
|
544
|
+
uniqueKey: A,
|
|
545
|
+
source: M,
|
|
546
|
+
extraProps: ee,
|
|
547
|
+
component: D,
|
|
548
|
+
scopedSlots: F,
|
|
549
|
+
style: Z,
|
|
550
|
+
class: "".concat(Y).concat(e.itemClassAdd ? " " + e.itemClassAdd(k) : ""),
|
|
551
|
+
onItemResize: Me
|
|
552
|
+
}, null)) : console.warn("Cannot get the data-key '".concat(T, "' from data-sources."));
|
|
553
|
+
} else
|
|
554
|
+
console.warn("Cannot get the index '".concat(k, "' from data-sources."));
|
|
555
|
+
}
|
|
556
|
+
return l;
|
|
557
|
+
}, Me = function(l, f) {
|
|
558
|
+
d.saveSize(l, f), i("resized", l, f);
|
|
559
|
+
}, ue = function(l, f, w) {
|
|
560
|
+
l === L.HEADER ? d.updateParam("slotHeaderSize", f) : l === L.FOOTER && d.updateParam("slotFooterSize", f), w && d.handleSlotSizeChange();
|
|
561
|
+
}, he = function p() {
|
|
562
|
+
if (c.value) {
|
|
563
|
+
var l = c.value[a ? "offsetLeft" : "offsetTop"];
|
|
564
|
+
x(l), setTimeout(function() {
|
|
565
|
+
g() + q() < v() && p();
|
|
566
|
+
}, 3);
|
|
567
|
+
}
|
|
568
|
+
}, Ge = function() {
|
|
569
|
+
if (h.value) {
|
|
570
|
+
var l = h.value.getBoundingClientRect(), f = h.value.ownerDocument.defaultView, w = a ? l.left + f.pageXOffset : l.top + f.pageYOffset;
|
|
571
|
+
d.updateParam("slotHeaderSize", w);
|
|
572
|
+
}
|
|
573
|
+
}, je = function() {
|
|
574
|
+
return d.sizes.size;
|
|
575
|
+
};
|
|
576
|
+
return Ie(function() {
|
|
577
|
+
Oe();
|
|
578
|
+
}), xe(function() {
|
|
579
|
+
x(d.offset);
|
|
580
|
+
}), Ce(function() {
|
|
581
|
+
e.start ? J(e.start) : e.offset && x(e.offset), e.pageMode && (Ge(), document.addEventListener("scroll", W, {
|
|
582
|
+
passive: !1
|
|
583
|
+
}));
|
|
584
|
+
}), be(function() {
|
|
585
|
+
d.destroy(), e.pageMode && document.removeEventListener("scroll", W);
|
|
586
|
+
}), n({
|
|
587
|
+
scrollToBottom: he,
|
|
588
|
+
getSizes: je,
|
|
589
|
+
getSize: S,
|
|
590
|
+
getOffset: g,
|
|
591
|
+
getScrollSize: v,
|
|
592
|
+
getClientSize: q,
|
|
593
|
+
scrollToOffset: x,
|
|
594
|
+
scrollToIndex: J
|
|
595
|
+
}), function() {
|
|
596
|
+
var p = e.pageMode, l = e.rootTag, f = e.wrapTag, w = e.wrapClass, b = e.wrapStyle, X = e.headerTag, T = e.headerClass, Y = e.headerStyle, Q = e.footerTag, Z = e.footerClass, ee = e.footerStyle, D = u.value, F = D.padFront, k = D.padBehind, M = {
|
|
597
|
+
padding: a ? "0px ".concat(k, "px 0px ").concat(F, "px") : "".concat(F, "px 0px ").concat(k, "px")
|
|
598
|
+
}, A = b ? Object.assign({}, b, M) : M, ce = o.header, le = o.footer;
|
|
599
|
+
return C(l, {
|
|
600
|
+
ref: h,
|
|
601
|
+
onScroll: !p && W
|
|
602
|
+
}, {
|
|
603
|
+
default: function() {
|
|
604
|
+
return [ce && C(we, {
|
|
605
|
+
class: T,
|
|
606
|
+
style: Y,
|
|
607
|
+
tag: X,
|
|
608
|
+
event: B.SLOT,
|
|
609
|
+
uniqueKey: L.HEADER,
|
|
610
|
+
onSlotResize: ue
|
|
611
|
+
}, {
|
|
612
|
+
default: function() {
|
|
613
|
+
return [ce()];
|
|
614
|
+
}
|
|
615
|
+
}), C(f, {
|
|
616
|
+
class: w,
|
|
617
|
+
style: A
|
|
618
|
+
}, {
|
|
619
|
+
default: function() {
|
|
620
|
+
return [ve()];
|
|
621
|
+
}
|
|
622
|
+
}), le && C(we, {
|
|
623
|
+
class: Z,
|
|
624
|
+
style: ee,
|
|
625
|
+
tag: Q,
|
|
626
|
+
event: B.SLOT,
|
|
627
|
+
uniqueKey: L.FOOTER,
|
|
628
|
+
onSlotResize: ue
|
|
629
|
+
}, {
|
|
630
|
+
default: function() {
|
|
631
|
+
return [le()];
|
|
632
|
+
}
|
|
633
|
+
}), C("div", {
|
|
634
|
+
ref: c,
|
|
635
|
+
style: {
|
|
636
|
+
width: a ? "0px" : "100%",
|
|
637
|
+
height: a ? "100%" : "0px"
|
|
638
|
+
}
|
|
639
|
+
}, null)];
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
class Qe {
|
|
646
|
+
// 分组节点扁平化对象、设备扁平化对象、window缓存设备扁平化对象
|
|
647
|
+
constructor(e, t, i) {
|
|
648
|
+
this.groupNodeObject = e, this.nodesMap = t, this.controlObject = i;
|
|
649
|
+
}
|
|
650
|
+
// 增加映射
|
|
651
|
+
addNodesMap(e) {
|
|
652
|
+
e && e.forEach((t) => {
|
|
653
|
+
this.nodesMap[t.key] = t;
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
// 移除映射
|
|
657
|
+
removeNodesMap(e) {
|
|
658
|
+
e && e.forEach((t) => {
|
|
659
|
+
delete this.nodesMap[t.key];
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
// 回收所有分组节点缓存
|
|
663
|
+
recycleAllNodeCache(e) {
|
|
664
|
+
for (let t in this.groupNodeObject)
|
|
665
|
+
this.groupNodeObject[t].expand = !1, this.groupNodeObject[t].count = 0, this.recycleGroupCache(this.groupNodeObject[t].key), e && delete this.groupNodeObject[t];
|
|
666
|
+
}
|
|
667
|
+
// 回收分组节点内存
|
|
668
|
+
recycleGroupCache(e) {
|
|
669
|
+
if (this.groupNodeObject[e]) {
|
|
670
|
+
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;
|
|
671
|
+
for (let t in this.groupNodeObject)
|
|
672
|
+
this.groupNodeObject[t].groupId == e && this.recycleGroupCache(this.groupNodeObject[t].key);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
// 关闭兄弟分组节点及回收内存
|
|
676
|
+
closeBrotherNode(e) {
|
|
677
|
+
if (e && this.groupNodeObject[e]) {
|
|
678
|
+
let t = this.groupNodeObject[e].groupId;
|
|
679
|
+
for (let i in this.groupNodeObject)
|
|
680
|
+
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));
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
class H {
|
|
685
|
+
constructor() {
|
|
686
|
+
this.window = window;
|
|
687
|
+
try {
|
|
688
|
+
window.top.equipGroup, this.window = window.top;
|
|
689
|
+
} catch {
|
|
690
|
+
this.window = window;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
const ye = {
|
|
695
|
+
data() {
|
|
696
|
+
return {
|
|
697
|
+
window: null
|
|
698
|
+
};
|
|
699
|
+
},
|
|
700
|
+
created() {
|
|
701
|
+
this.window = window;
|
|
702
|
+
try {
|
|
703
|
+
window.top.equipGroup, this.window = window.top;
|
|
704
|
+
} catch {
|
|
705
|
+
this.window = window;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
class Ze extends H {
|
|
710
|
+
constructor(e, t, i, o, n, a) {
|
|
711
|
+
super(), this.equipControllObject = i, this.groupNodeObject = e, this.nodesMap = t, this.controlObject = o, this.equipCheckObject = n, this.isSearchStatus = !1, this.searchStatusGroupObject = {}, this.aliasName = a;
|
|
712
|
+
}
|
|
713
|
+
resetCheckedStatus() {
|
|
714
|
+
Object.values(this.nodesMap).forEach((e) => {
|
|
715
|
+
this.setCheckStatus(e.key, !1, !1);
|
|
716
|
+
}), Object.keys(this.equipCheckObject).forEach((e) => delete this.equipCheckObject[e]), this.updateGroupCheckStatus();
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* 搜索状态下,更新分组选中状态
|
|
720
|
+
* 新方案:直接调用 updateGroupCheckStatus 重新计算
|
|
721
|
+
*/
|
|
722
|
+
reComputedCheckNum(e) {
|
|
723
|
+
this.isSearchStatus = e, this.updateGroupCheckStatus();
|
|
724
|
+
}
|
|
725
|
+
// 根据传过来的设备选中数据、回显选中状态
|
|
726
|
+
/**
|
|
727
|
+
* 支持两种数据格式:
|
|
728
|
+
* 格式1:纯 equipNo 数组,如 [1, 2, 3],选中该设备在所有分组下的实例
|
|
729
|
+
* 格式2:{ groupId: [equipNo1, equipNo2] } 对象,如 { 2: [1, 2], 3: [5] },只选中指定分组下的设备
|
|
730
|
+
*
|
|
731
|
+
* 注意:此方法只负责将选中状态写入 equipCheckObject,不调用 updateGroupCheckStatus。
|
|
732
|
+
* 分组状态的更新由调用方在合适的时机(数据就绪后)统一调用。
|
|
733
|
+
*/
|
|
734
|
+
updateCheckedStatusWithEquips(e) {
|
|
735
|
+
Object.keys(this.equipCheckObject).forEach((i) => {
|
|
736
|
+
i.split("-").length === 2 && delete this.equipCheckObject[i];
|
|
737
|
+
});
|
|
738
|
+
let t = [];
|
|
739
|
+
Array.isArray(e) ? t = e.map((i) => ({ equipNo: i, groupId: null })) : e !== null && typeof e == "object" && Object.keys(e).forEach((i) => {
|
|
740
|
+
Array.isArray(e[i]) && e[i].forEach((o) => {
|
|
741
|
+
t.push({ equipNo: o, groupId: Number(i) });
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
for (let i = 0, o = t.length; i < o; i++) {
|
|
745
|
+
const { equipNo: n, groupId: a } = t[i];
|
|
746
|
+
if (a != null) {
|
|
747
|
+
const r = `${a}-${n}`;
|
|
748
|
+
this.setEquipCheckObject(r, !0, !1, a), this.setCheckStatus(r, !0, !1), this.updateExpandControlCheckStatus(a, n);
|
|
749
|
+
} else {
|
|
750
|
+
const r = this.window.equipCache && this.window.equipCache[n];
|
|
751
|
+
r && (r.groupIds || (r.groupId ? [r.groupId] : [])).forEach((h) => {
|
|
752
|
+
const c = `${h}-${n}`;
|
|
753
|
+
this.setEquipCheckObject(c, !0, !1, h), this.setCheckStatus(c, !0, !1), this.updateExpandControlCheckStatus(h, n);
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
// 更新展开的设备控制项选中状态
|
|
759
|
+
updateExpandControlCheckStatus(e, t) {
|
|
760
|
+
let i = this.nodesMap[`${e}-${t}`];
|
|
761
|
+
i && i.settings && i.settings.length && i.settings.forEach((o) => {
|
|
762
|
+
this.nodesMap[`${e}-${t}-${o.setNo}`] && this.setCheckStatus(`${e}-${t}-${o.setNo}`, !0, !1);
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
// 根据传过来的设备控制项,回显设备分组选中状态
|
|
766
|
+
/**
|
|
767
|
+
* 注意:此方法只负责将控制项状态写入 equipControllObject/equipCheckObject,不调用 updateGroupCheckStatus。
|
|
768
|
+
* 分组状态的更新由调用方在合适的时机(数据就绪后)统一调用。
|
|
769
|
+
*/
|
|
770
|
+
updateCheckedStatusWithControls(e) {
|
|
771
|
+
for (let t = 0, i = e.length; t < i; t++) {
|
|
772
|
+
let o = e[t], n, a, r;
|
|
773
|
+
if (o !== null && typeof o == "object" && !Array.isArray(o))
|
|
774
|
+
n = o.equipNo, a = o.setNo, r = o.groupId;
|
|
775
|
+
else {
|
|
776
|
+
let h = o.split(".");
|
|
777
|
+
n = h[0], a = h[1], r = null;
|
|
778
|
+
}
|
|
779
|
+
this.equipControllObject[n] || (this.equipControllObject[n] = []), this.equipControllObject[n].push(Number(a));
|
|
780
|
+
const u = this.window.equipCache && this.window.equipCache[n];
|
|
781
|
+
u && (r != null ? [r] : u.groupIds || (u.groupId ? [u.groupId] : [])).forEach((c) => {
|
|
782
|
+
const d = `${c}-${n}`, S = `${c}-${n}-${a}`;
|
|
783
|
+
this.nodesMap[S] && this.setCheckStatus(S, !0, !1), this.nodesMap[d] && this.setCheckStatus(d, !1, !0), this.setEquipCheckObject(d, !1, !0, c);
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
// 更新分组选中状态------------------------------------------------------------------------------------
|
|
788
|
+
/**
|
|
789
|
+
* 新方案:基于 equipCheckObject 实时计算分组状态,而不是依赖中间状态
|
|
790
|
+
* 优点:状态判断准确,不会累积误差
|
|
791
|
+
*/
|
|
792
|
+
updateGroupCheckStatus() {
|
|
793
|
+
this.getSortedGroupsByLevel().forEach((t) => {
|
|
794
|
+
const i = this.computeGroupStatus(t.key);
|
|
795
|
+
this.setCheckStatus(t.key, i.checked, i.indeterminate), t.equipSelectCount = i.selectCount;
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
// 按层级排序分组(从深到浅,确保子分组先处理)
|
|
799
|
+
getSortedGroupsByLevel() {
|
|
800
|
+
return Object.values(this.groupNodeObject).sort((e, t) => t.level - e.level);
|
|
801
|
+
}
|
|
802
|
+
// 计算单个分组的选中状态
|
|
803
|
+
/**
|
|
804
|
+
* @returns {Object} { checked, indeterminate, selectCount }
|
|
805
|
+
*/
|
|
806
|
+
computeGroupStatus(e) {
|
|
807
|
+
const t = this.groupNodeObject[e];
|
|
808
|
+
if (!t)
|
|
809
|
+
return { checked: !1, indeterminate: !1, selectCount: 0 };
|
|
810
|
+
let i = this.isSearchStatus ? this.window[`group-${e}-search`] || [] : this.window[`group-${e}${this.aliasName}`] || [];
|
|
811
|
+
!this.isSearchStatus && i.length === 0 && this.aliasName && (i = this.window[`group-${e}`] || []);
|
|
812
|
+
let o = 0, n = i.length || t.equipCount || 0;
|
|
813
|
+
if (i.length > 0)
|
|
814
|
+
i.forEach((S) => {
|
|
815
|
+
const g = S.equipNo || S.id, q = `${e}-${g}`;
|
|
816
|
+
this.equipCheckObject[q] && this.equipCheckObject[q].checked && o++;
|
|
817
|
+
});
|
|
818
|
+
else {
|
|
819
|
+
const S = `${e}-`;
|
|
820
|
+
Object.keys(this.equipCheckObject).forEach((g) => {
|
|
821
|
+
g.startsWith(S) && g.split("-").length === 2 && this.equipCheckObject[g].checked && o++;
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
let a = 0, r = 0, u = !1, h = !1;
|
|
825
|
+
t.groups && t.groups.length > 0 && t.groups.forEach((S) => {
|
|
826
|
+
const g = this.nodesMap[S.key], q = this.groupNodeObject[S.key];
|
|
827
|
+
if (g) {
|
|
828
|
+
const v = g.count || (q ? q.equipCount : 0) || 0;
|
|
829
|
+
r += v, g.checked ? (a += v, u = !0) : g.indeterminate ? (h = !0, u = !0) : h = !0;
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
const c = o + a;
|
|
833
|
+
let d = t.count || 0;
|
|
834
|
+
return d === 0 && (d = n + r), c === 0 && !u ? { checked: !1, indeterminate: !1, selectCount: 0 } : d === 0 ? c > 0 ? { checked: !1, indeterminate: !0, selectCount: c } : { checked: !1, indeterminate: !1, selectCount: 0 } : c === 0 ? u ? { checked: !1, indeterminate: !0, selectCount: c } : { checked: !1, indeterminate: !1, selectCount: 0 } : c === d && !h ? { checked: !0, indeterminate: !1, selectCount: c } : { checked: !1, indeterminate: !0, selectCount: c };
|
|
835
|
+
}
|
|
836
|
+
// 设置设备控制项状态
|
|
837
|
+
setControlStatus(e, t, i, o) {
|
|
838
|
+
e && e.forEach((n) => {
|
|
839
|
+
this.nodesMap[`${t}-${i}-${n.setNo}`] && this.setCheckStatus(`${t}-${i}-${n.setNo}`, o, !1);
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
// 更新设备控制项选中状态
|
|
843
|
+
/**
|
|
844
|
+
* 改造点:controlObject 键格式统一为 ${groupId}-${equipNo}
|
|
845
|
+
* */
|
|
846
|
+
updateControlCheckStatus() {
|
|
847
|
+
Object.keys(this.controlObject).forEach((e) => {
|
|
848
|
+
const [t, i] = e.split("-");
|
|
849
|
+
let o = this.nodesMap[e];
|
|
850
|
+
if (o)
|
|
851
|
+
if (o.checked) {
|
|
852
|
+
let n = o.settings;
|
|
853
|
+
this.setControlStatus(n, t, i, !0);
|
|
854
|
+
} else if (!o.checked && !o.indeterminate) {
|
|
855
|
+
let n = o.settings;
|
|
856
|
+
this.setControlStatus(n, t, i, !1);
|
|
857
|
+
} else
|
|
858
|
+
this.equipControllObject[i] && this.equipControllObject[i].forEach((n) => {
|
|
859
|
+
let a = `${t}-${i}-${n}`;
|
|
860
|
+
this.nodesMap[a] && this.setCheckStatus(a, !0, !1);
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
// 获取选中的分组
|
|
865
|
+
getGroupChecked() {
|
|
866
|
+
let e = [];
|
|
867
|
+
return Object.keys(this.groupNodeObject).forEach((t) => {
|
|
868
|
+
this.groupNodeObject[t].checked && e.push(t);
|
|
869
|
+
}), e;
|
|
870
|
+
}
|
|
871
|
+
// 获取选中设备
|
|
872
|
+
getEquipSelectd() {
|
|
873
|
+
let e = [], t = /* @__PURE__ */ new Set();
|
|
874
|
+
return Object.keys(this.equipCheckObject).forEach((i) => {
|
|
875
|
+
if (this.equipCheckObject[i].checked)
|
|
876
|
+
try {
|
|
877
|
+
t.add(Number(i.split("-")[1]));
|
|
878
|
+
} catch (o) {
|
|
879
|
+
console.log(o);
|
|
880
|
+
}
|
|
881
|
+
}), e = Array.from(t), e;
|
|
882
|
+
}
|
|
883
|
+
// 获取选中设备(携带分组)
|
|
884
|
+
getEquipGroupSelectd() {
|
|
885
|
+
let e = Object.keys(this.equipCheckObject);
|
|
886
|
+
return e.length > 0 && (e = this.returnArray(e)), e;
|
|
887
|
+
}
|
|
888
|
+
returnArray(e) {
|
|
889
|
+
const t = [];
|
|
890
|
+
return e.forEach((i) => {
|
|
891
|
+
const o = i.split("-");
|
|
892
|
+
if (o.length >= 2) {
|
|
893
|
+
const n = parseInt(o[0]), a = parseInt(o[1]);
|
|
894
|
+
!isNaN(n) && !isNaN(a) && t.push({ groupId: n, equipNo: a });
|
|
895
|
+
}
|
|
896
|
+
}), t;
|
|
897
|
+
}
|
|
898
|
+
// 解析设备数组为分组格式
|
|
899
|
+
parseEquipArrayToGroupFormat(e) {
|
|
900
|
+
const t = {};
|
|
901
|
+
return e.forEach((i) => {
|
|
902
|
+
const [o, n] = i.split("-"), a = parseInt(o);
|
|
903
|
+
isNaN(a) || (t[a] || (t[a] = []), t[a].push(parseInt(n)));
|
|
904
|
+
}), t;
|
|
905
|
+
}
|
|
906
|
+
// 获取选中的设备控制项
|
|
907
|
+
getControlSelected() {
|
|
908
|
+
let e = [];
|
|
909
|
+
return Object.keys(this.equipControllObject).forEach((t) => {
|
|
910
|
+
e.push(...this.equipControllObject[t].map((i) => `${t}.${i}`));
|
|
911
|
+
}), e;
|
|
912
|
+
}
|
|
913
|
+
// 点击选中
|
|
914
|
+
/**
|
|
915
|
+
* 1:如果是分组选择,触发分组选中事件
|
|
916
|
+
* 2:如果是设备选择,触发设备选中事件
|
|
917
|
+
* 3:如果是设备控制项选择,触发设备控制项选中事件
|
|
918
|
+
* */
|
|
919
|
+
onChecked(e, t) {
|
|
920
|
+
this.isSearchStatus = t || !1, e.isGroup && !e.isEquip ? this.selectGroup(e) : e.isEquip ? this.selectEquip(e) : e.isSetting && this.selectControl(e);
|
|
921
|
+
}
|
|
922
|
+
// 从全局映射中,设置节点选中状态
|
|
923
|
+
setCheckStatus(e, t, i, o) {
|
|
924
|
+
this.nodesMap[e] && (this.nodesMap[e].checked = t, this.nodesMap[e].isGroup && (this.nodesMap[e].indeterminate = i));
|
|
925
|
+
}
|
|
926
|
+
// 保存全局设备选中状态
|
|
927
|
+
setEquipCheckObject(e, t, i, o) {
|
|
928
|
+
this.equipCheckObject[e] || (this.equipCheckObject[e] = {}), this.equipCheckObject[e].checked = t, this.equipCheckObject[e].indeterminate = i, this.equipCheckObject[e].groupId = o, !t && !i && delete this.equipCheckObject[e];
|
|
929
|
+
}
|
|
930
|
+
// 触发分组选择
|
|
931
|
+
selectGroup(e) {
|
|
932
|
+
this.updateAllEquipStatus(e.key, e.checked), this.updateControlCheckStatus(), this.updateGroupCheckStatus();
|
|
933
|
+
}
|
|
934
|
+
// 更新分组下所有设备的选中状态
|
|
935
|
+
updateAllEquipStatus(e, t) {
|
|
936
|
+
const i = this.groupNodeObject[e];
|
|
937
|
+
if (!i)
|
|
938
|
+
return;
|
|
939
|
+
let o = this.isSearchStatus ? this.window[`group-${e}-search`] || [] : this.window[`group-${e}${this.aliasName}`] || [];
|
|
940
|
+
!this.isSearchStatus && o.length === 0 && this.aliasName && (o = this.window[`group-${e}`] || []), o.forEach((n) => {
|
|
941
|
+
const a = n.equipNo || n.id, r = `${e}-${a}`;
|
|
942
|
+
this.setEquipCheckObject(r, t, !1, e), this.nodesMap[r] && this.setCheckStatus(r, t, !1);
|
|
943
|
+
}), i.groups && i.groups.length > 0 && i.groups.forEach((n) => {
|
|
944
|
+
this.updateAllEquipStatus(n.key, t);
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
// 触发设备选择
|
|
948
|
+
/**
|
|
949
|
+
* 新方案:简化逻辑,只更新设备状态,分组状态由 updateGroupCheckStatus 统一计算
|
|
950
|
+
*/
|
|
951
|
+
selectEquip(e) {
|
|
952
|
+
const t = `${e.groupId}-${e.equipNo}`;
|
|
953
|
+
this.setEquipCheckObject(t, e.checked, !1, e.groupId), this.nodesMap[t] && this.setCheckStatus(t, e.checked, !1), this.updateControlCheckStatus(), this.updateGroupCheckStatus();
|
|
954
|
+
}
|
|
955
|
+
// 更新设备控制项存储
|
|
956
|
+
updateEquipControl(e, t, i) {
|
|
957
|
+
this.equipControllObject[e] || (this.equipControllObject[e] = []), i ? this.equipControllObject[e].push(t) : this.equipControllObject[e] = this.equipControllObject[e].filter((o) => o != t);
|
|
958
|
+
}
|
|
959
|
+
// 触发控制项选择
|
|
960
|
+
/**
|
|
961
|
+
* 新方案:简化逻辑,只更新控制项和设备状态,分组状态由 updateGroupCheckStatus 统一计算
|
|
962
|
+
*/
|
|
963
|
+
selectControl(e) {
|
|
964
|
+
const t = `${e.groupId}-${e.equipNo}`, i = `${e.groupId}-${e.equipNo}-${e.setNo}`, o = this.nodesMap[t];
|
|
965
|
+
if (!o)
|
|
966
|
+
return;
|
|
967
|
+
this.updateEquipControl(e.equipNo, e.setNo, e.checked), this.setCheckStatus(i, e.checked, !1);
|
|
968
|
+
const n = o.settings || [], a = this.equipControllObject[e.equipNo] || [], r = n.length, u = a.length;
|
|
969
|
+
e.checked ? u === r ? (delete this.equipControllObject[e.equipNo], this.setEquipCheckObject(t, !0, !1, e.groupId), this.setCheckStatus(t, !0, !1)) : (this.setEquipCheckObject(t, !1, !0, e.groupId), this.setCheckStatus(t, !1, !0)) : u === 0 ? (this.setEquipCheckObject(t, !1, !1, e.groupId), this.setCheckStatus(t, !1, !1)) : (this.setEquipCheckObject(t, !1, !0, e.groupId), this.setCheckStatus(t, !1, !0)), this.updateGroupCheckStatus();
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
class et extends H {
|
|
973
|
+
// 分组节点扁平化对象、设备扁平化对象、window缓存设备扁平化对象
|
|
974
|
+
constructor(e, t) {
|
|
975
|
+
super(), this.aliasName = t, this.groupNodeObject = e;
|
|
976
|
+
}
|
|
977
|
+
// 重新计算分组设备数量
|
|
978
|
+
resetGroupNum(e, t, i) {
|
|
979
|
+
this.clearAllEquipNum();
|
|
980
|
+
const o = Object.keys(this.groupNodeObject).sort((n, a) => (this.groupNodeObject[a].level || 0) - (this.groupNodeObject[n].level || 0));
|
|
981
|
+
for (let n of o) {
|
|
982
|
+
let a = [];
|
|
983
|
+
e ? a = this.window[`group-${n}-search`] : a = this.window[`group-${n}${this.aliasName}`], t && a && a.length && (a = a.filter((u) => i[u.equipNo] === 2));
|
|
984
|
+
let r = a ? a.length : 0;
|
|
985
|
+
this.groupNodeObject[n].equipCount = r, this.setGroupNum(n, r);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
clearAllEquipNum() {
|
|
989
|
+
for (let e in this.groupNodeObject)
|
|
990
|
+
this.groupNodeObject[e].equipCount = 0, this.groupNodeObject[e].count = 0;
|
|
991
|
+
}
|
|
992
|
+
// 设置分组设备数量
|
|
993
|
+
setGroupNum(e, t) {
|
|
994
|
+
this.groupNodeObject[e] && (this.groupNodeObject[e].count = Number(this.groupNodeObject[e].count) + Number(t), this.setGroupNum(this.groupNodeObject[e].groupId, t));
|
|
995
|
+
}
|
|
996
|
+
// 获取设备总数
|
|
997
|
+
getAllEquipsNum() {
|
|
998
|
+
let e = 0;
|
|
999
|
+
for (let t in this.groupNodeObject)
|
|
1000
|
+
this.window[`group-${this.groupNodeObject[t].key}${this.aliasName}`] && (e = e + this.window[`group-${this.groupNodeObject[t].key}${this.aliasName}`].length);
|
|
1001
|
+
return e;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
function qe() {
|
|
1005
|
+
return `${location.protocol === "https:" ? "https" : "http"}://${location.hostname}:9600`;
|
|
1006
|
+
}
|
|
1007
|
+
const y = {
|
|
1008
|
+
/** 已连接 */
|
|
1009
|
+
Connected: "Connected",
|
|
1010
|
+
/** 连接中 */
|
|
1011
|
+
Connecting: "Connecting",
|
|
1012
|
+
/** 已断开 */
|
|
1013
|
+
Disconnected: "Disconnected",
|
|
1014
|
+
/** 重连中 */
|
|
1015
|
+
Reconnecting: "Reconnecting"
|
|
1016
|
+
};
|
|
1017
|
+
class ke {
|
|
1018
|
+
constructor(e) {
|
|
1019
|
+
this.socket = null, this.config = {
|
|
1020
|
+
url: e.url,
|
|
1021
|
+
hub: e.hub,
|
|
1022
|
+
userName: e.userName || "",
|
|
1023
|
+
autoReconnect: e.autoReconnect !== !1,
|
|
1024
|
+
reconnectDelay: e.reconnectDelay || 3e3,
|
|
1025
|
+
maxReconnectAttempts: e.maxReconnectAttempts || 5,
|
|
1026
|
+
timeout: e.timeout || 5e5,
|
|
1027
|
+
autoConnect: e.autoConnect !== !1,
|
|
1028
|
+
transports: e.transports || ["websocket"],
|
|
1029
|
+
withCredentials: e.withCredentials !== !1
|
|
1030
|
+
}, this.reconnectAttempts = 0, this.isReconnecting = !1, this.messageHandlers = /* @__PURE__ */ new Map(), this.state = y.Disconnected, this.stateChangeCallbacks = [], this.pendingListeners = [], this.config.autoConnect && this.connect();
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* 获取连接状态
|
|
1034
|
+
*/
|
|
1035
|
+
getState() {
|
|
1036
|
+
return this.state;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* 监听连接状态变化
|
|
1040
|
+
* @returns 取消监听函数
|
|
1041
|
+
*/
|
|
1042
|
+
onStateChange(e) {
|
|
1043
|
+
return this.stateChangeCallbacks.push(e), () => {
|
|
1044
|
+
const t = this.stateChangeCallbacks.indexOf(e);
|
|
1045
|
+
t > -1 && this.stateChangeCallbacks.splice(t, 1);
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
setState(e) {
|
|
1049
|
+
this.state = e, this.stateChangeCallbacks.forEach((t) => t(e));
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* 内部创建 io 连接的公共配置
|
|
1053
|
+
*/
|
|
1054
|
+
createSocket() {
|
|
1055
|
+
return Ae(this.config.url, {
|
|
1056
|
+
transports: this.config.transports,
|
|
1057
|
+
autoConnect: !1,
|
|
1058
|
+
reconnection: !1,
|
|
1059
|
+
// 由本管理器自行控制重连
|
|
1060
|
+
timeout: this.config.timeout,
|
|
1061
|
+
forceNew: !0,
|
|
1062
|
+
query: {
|
|
1063
|
+
hub: this.config.hub,
|
|
1064
|
+
userName: this.config.userName
|
|
1065
|
+
},
|
|
1066
|
+
withCredentials: this.config.withCredentials
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* 建立连接
|
|
1071
|
+
* @returns Socket 实例
|
|
1072
|
+
*/
|
|
1073
|
+
async connect() {
|
|
1074
|
+
this.socket && (this.socket.disconnect(), this.socket = null), this.setState(y.Connecting);
|
|
1075
|
+
try {
|
|
1076
|
+
this.socket = this.createSocket();
|
|
1077
|
+
const e = this.socket;
|
|
1078
|
+
return this.pendingListeners.forEach(({ event: t, callback: i }) => {
|
|
1079
|
+
e.on(t, i);
|
|
1080
|
+
}), this.pendingListeners = [], new Promise((t, i) => {
|
|
1081
|
+
const o = () => {
|
|
1082
|
+
r(), this.reconnectAttempts = 0, this.setState(y.Connected), console.log(`Socket.IO [${this.config.hub}] 连接成功`), t(e);
|
|
1083
|
+
}, n = (u) => {
|
|
1084
|
+
r(), console.error(`Socket.IO [${this.config.hub}] 连接失败:`, u.message), this.setState(y.Disconnected), i(new Error(`Socket.IO 连接失败: ${u.message}`));
|
|
1085
|
+
}, a = (u) => {
|
|
1086
|
+
r(), console.log(`Socket.IO [${this.config.hub}] 连接断开:`, u), this.setState(y.Disconnected), this.config.autoReconnect && u !== "io client disconnect" && this.handleReconnect();
|
|
1087
|
+
}, r = () => {
|
|
1088
|
+
e.off("connect", o), e.off("connect_error", n), e.off("disconnect", a);
|
|
1089
|
+
};
|
|
1090
|
+
e.on("connect", o), e.on("connect_error", n), e.on("disconnect", a), e.connect();
|
|
1091
|
+
});
|
|
1092
|
+
} catch (e) {
|
|
1093
|
+
throw console.error(`Socket.IO [${this.config.hub}] 连接异常:`, e), this.setState(y.Disconnected), e;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* 处理自动重连
|
|
1098
|
+
*/
|
|
1099
|
+
async handleReconnect() {
|
|
1100
|
+
if (!this.isReconnecting) {
|
|
1101
|
+
for (this.isReconnecting = !0, this.setState(y.Reconnecting); this.reconnectAttempts < this.config.maxReconnectAttempts; ) {
|
|
1102
|
+
this.reconnectAttempts++, console.log(
|
|
1103
|
+
`Socket.IO [${this.config.hub}] 尝试重连 (${this.reconnectAttempts}/${this.config.maxReconnectAttempts})...`
|
|
1104
|
+
);
|
|
1105
|
+
try {
|
|
1106
|
+
await this.sleep(this.config.reconnectDelay), this.socket && (this.socket.disconnect(), this.socket = null), this.socket = this.createSocket();
|
|
1107
|
+
const e = this.socket;
|
|
1108
|
+
this.resubscribeMessages(e), await new Promise((t, i) => {
|
|
1109
|
+
const o = () => {
|
|
1110
|
+
r(), this.reconnectAttempts = 0, this.isReconnecting = !1, this.setState(y.Connected), console.log(`Socket.IO [${this.config.hub}] 重连成功`), t();
|
|
1111
|
+
}, n = (u) => {
|
|
1112
|
+
r(), i(u);
|
|
1113
|
+
}, a = (u) => {
|
|
1114
|
+
r(), console.log(`Socket.IO [${this.config.hub}] 重连后连接断开:`, u), this.setState(y.Disconnected), i(new Error(`重连后断开: ${u}`));
|
|
1115
|
+
}, r = () => {
|
|
1116
|
+
e.off("connect", o), e.off("connect_error", n), e.off("disconnect", a);
|
|
1117
|
+
};
|
|
1118
|
+
e.on("connect", o), e.on("connect_error", n), e.on("disconnect", a), e.connect();
|
|
1119
|
+
}), this.socket.on("disconnect", (t) => {
|
|
1120
|
+
console.log(`Socket.IO [${this.config.hub}] 连接断开:`, t), this.setState(y.Disconnected), this.config.autoReconnect && t !== "io client disconnect" && this.handleReconnect();
|
|
1121
|
+
});
|
|
1122
|
+
return;
|
|
1123
|
+
} catch (e) {
|
|
1124
|
+
console.error(`Socket.IO [${this.config.hub}] 重连失败:`, e.message || e);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
console.error(`Socket.IO [${this.config.hub}] 重连次数已达上限,停止重连`), this.isReconnecting = !1, this.setState(y.Disconnected);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* 重新订阅所有消息(重连后调用)
|
|
1132
|
+
*/
|
|
1133
|
+
resubscribeMessages(e) {
|
|
1134
|
+
this.messageHandlers.forEach((t, i) => {
|
|
1135
|
+
t.forEach((o) => {
|
|
1136
|
+
e.on(i, o);
|
|
1137
|
+
});
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* 监听服务端推送事件
|
|
1142
|
+
* 支持在 connect() 之前预注册,连接成功后自动应用。
|
|
1143
|
+
* @returns 取消监听函数
|
|
1144
|
+
*/
|
|
1145
|
+
on(e, t) {
|
|
1146
|
+
this.messageHandlers.has(e) || this.messageHandlers.set(e, /* @__PURE__ */ new Set());
|
|
1147
|
+
const i = this.messageHandlers.get(e);
|
|
1148
|
+
return i && i.add(t), this.socket ? this.socket.on(e, t) : this.pendingListeners.push({ event: e, callback: t }), () => {
|
|
1149
|
+
this.off(e, t);
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* 取消监听
|
|
1154
|
+
* 不传 callback 则取消该事件的所有监听。
|
|
1155
|
+
*/
|
|
1156
|
+
off(e, t) {
|
|
1157
|
+
if (t) {
|
|
1158
|
+
const i = this.messageHandlers.get(e);
|
|
1159
|
+
i && (i.delete(t), i.size === 0 && this.messageHandlers.delete(e)), this.socket && this.socket.off(e, t);
|
|
1160
|
+
} else
|
|
1161
|
+
this.messageHandlers.delete(e), this.socket && this.socket.off(e);
|
|
1162
|
+
this.pendingListeners = this.pendingListeners.filter(
|
|
1163
|
+
(i) => !(i.event === e && (!t || i.callback === t))
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* 发送自定义事件
|
|
1168
|
+
*/
|
|
1169
|
+
emit(e, t) {
|
|
1170
|
+
if (!this.socket) {
|
|
1171
|
+
console.error(`Socket.IO [${this.config.hub}] 未初始化,请先调用 connect()`);
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
this.socket.emit(e, t);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* 调用服务端方法
|
|
1178
|
+
*
|
|
1179
|
+
* Socket.IO 中调用服务端方法的统一格式:
|
|
1180
|
+
* emit('invoke', { method: 'MethodName', data: {} })
|
|
1181
|
+
*
|
|
1182
|
+
* 此方法是对 emit('invoke', ...) 的封装。
|
|
1183
|
+
*/
|
|
1184
|
+
invoke(e, t) {
|
|
1185
|
+
this.emit("invoke", { method: e, data: t });
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* 断开连接(不销毁实例,可重新 connect)
|
|
1189
|
+
*/
|
|
1190
|
+
async disconnect() {
|
|
1191
|
+
this.socket && (this.socket.disconnect(), this.socket = null), this.isReconnecting = !1, this.reconnectAttempts = 0, this.setState(y.Disconnected);
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* 获取原始 Socket 实例
|
|
1195
|
+
*/
|
|
1196
|
+
getSocket() {
|
|
1197
|
+
return this.socket;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* 清空所有消息订阅
|
|
1201
|
+
*/
|
|
1202
|
+
clearAllHandlers() {
|
|
1203
|
+
this.messageHandlers.forEach((e, t) => {
|
|
1204
|
+
this.socket && this.socket.off(t);
|
|
1205
|
+
}), this.messageHandlers.clear(), this.pendingListeners = [];
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* 销毁实例,彻底清理连接和所有事件
|
|
1209
|
+
*/
|
|
1210
|
+
async destroy() {
|
|
1211
|
+
this.stateChangeCallbacks = [], this.clearAllHandlers(), await this.disconnect();
|
|
1212
|
+
}
|
|
1213
|
+
sleep(e) {
|
|
1214
|
+
return new Promise((t) => setTimeout(t, e));
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
class tt extends H {
|
|
1218
|
+
constructor(e, t, i, o, n) {
|
|
1219
|
+
super(), this.equipStatusObject = t, this.groupNodeObject = i, this.aleadyUpdateStatus = {}, this.isGetAllEquipStatus = !1, this.nodesMap = e, this.statusChange = o, this.aliasName = n, this.openSignlr();
|
|
1220
|
+
}
|
|
1221
|
+
openSignlr() {
|
|
1222
|
+
this.equipStatusSignlr = new ke({
|
|
1223
|
+
url: qe(),
|
|
1224
|
+
hub: "equipStatusMonitor",
|
|
1225
|
+
userName: sessionStorage.userName,
|
|
1226
|
+
autoConnect: !1
|
|
1227
|
+
}), this.equipStatusSignlr.connect().then(() => {
|
|
1228
|
+
{
|
|
1229
|
+
this.equipStatusSignlr.on("connect", () => {
|
|
1230
|
+
try {
|
|
1231
|
+
this.equipStatusSignlr.invoke("GetAllEquipStatus", {}), this.equipStatusSignlr.invoke("GetEquipChangeStatus", {});
|
|
1232
|
+
} catch (e) {
|
|
1233
|
+
console.log(e);
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
try {
|
|
1237
|
+
this.equipStatusSignlr.invoke("GetAllEquipStatus", {}), this.equipStatusSignlr.invoke("GetEquipChangeStatus", {});
|
|
1238
|
+
} catch (e) {
|
|
1239
|
+
console.log(e);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
this.subscribeTo(this.equipStatusSignlr, "GetAllEquipStatus"), this.subscribeTo(this.equipStatusSignlr, "GetEquipChangeStatus");
|
|
1243
|
+
}).catch((e) => {
|
|
1244
|
+
console.error(e);
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
// ★ subscribeTo 根据 backendType 区分解包逻辑
|
|
1248
|
+
subscribeTo(e, t) {
|
|
1249
|
+
e.off(t), e.on(t, (i) => {
|
|
1250
|
+
{
|
|
1251
|
+
const o = i == null ? void 0 : i.data;
|
|
1252
|
+
o && o.isSuccess && o.data && (this[t] ? this[t](o.data) : this.notice({ func: t, data: o.data, key: o.groupId }));
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
GetAllEquipStatus(e) {
|
|
1257
|
+
this.isGetAllEquipStatus = !0, this.resetGroupStatus(), this.aleadyUpdateStatus = {}, Object.keys(e).forEach((t) => {
|
|
1258
|
+
this.equipStatusObject[t] = e[t];
|
|
1259
|
+
}), Object.keys(this.groupNodeObject).forEach((t) => {
|
|
1260
|
+
this.updateByGroup(t);
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
updateByGroup(e) {
|
|
1264
|
+
if (!this.aleadyUpdateStatus[e]) {
|
|
1265
|
+
let t = this.window[`group-${e}${this.aliasName}`] || [];
|
|
1266
|
+
if (t.length) {
|
|
1267
|
+
this.aleadyUpdateStatus[e] = !0;
|
|
1268
|
+
let i = !1, o = !0;
|
|
1269
|
+
t.forEach((n) => {
|
|
1270
|
+
const a = this.equipStatusObject[n.equipNo];
|
|
1271
|
+
a === 1 ? (i = !0, o = !1) : a !== 0 && (o = !1);
|
|
1272
|
+
}), o && this.setOfflineStatus(e), t.forEach((n) => {
|
|
1273
|
+
this.equipStatusObject[n.equipNo] == 2 ? this.setGroupStatus(e, !0, 2) : this.equipStatusObject[n.equipNo] == 6 && this.setGroupStatus(e, !0, 6), this.nodesMap[`${e}-${n.equipNo}`] && (this.nodesMap[`${e}-${n.equipNo}`].status = this.equipStatusObject[n.equipNo]);
|
|
1274
|
+
}), this.nodesMap[e].alarmCounts === 0 && this.nodesMap[e].backUpCounts === 0 && i && (this.nodesMap[e].status = 1, this.nodesMap[e].groupId && this.setNormalStatus(this.nodesMap[e].groupId));
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
updateGroupStatus(e) {
|
|
1279
|
+
this.isGetAllEquipStatus && this.updateByGroup(e);
|
|
1280
|
+
}
|
|
1281
|
+
GetEquipChangeStatus(e) {
|
|
1282
|
+
this.setStatus(e);
|
|
1283
|
+
}
|
|
1284
|
+
// 设置分组状态 key:扁平化数据中节点索引;type:类型(增加,减少);status:状态(报警2、双机热备6)
|
|
1285
|
+
setGroupStatus(e, t, i) {
|
|
1286
|
+
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);
|
|
1287
|
+
}
|
|
1288
|
+
// 设置分组离线状态并向上冒泡(不覆盖正常、报警、双机热备状态)
|
|
1289
|
+
setOfflineStatus(e) {
|
|
1290
|
+
this.nodesMap[e].status !== 2 && this.nodesMap[e].status !== 6 && this.nodesMap[e].status !== 1 && (this.nodesMap[e].status = 0, this.nodesMap[e].groupId && this.setOfflineStatus(this.nodesMap[e].groupId));
|
|
1291
|
+
}
|
|
1292
|
+
// 设置分组正常状态并向上冒泡(不覆盖报警和双机热备状态)
|
|
1293
|
+
setNormalStatus(e) {
|
|
1294
|
+
this.nodesMap[e].status !== 2 && this.nodesMap[e].status !== 6 && (this.nodesMap[e].status = 1, this.nodesMap[e].groupId && this.setNormalStatus(this.nodesMap[e].groupId));
|
|
1295
|
+
}
|
|
1296
|
+
// 获取设备所属的所有分组ID
|
|
1297
|
+
// 优先从 groupCache 反查(按分组隔离存储,数据准确),兜底从 equipCache 获取
|
|
1298
|
+
getEquipGroupIds(e) {
|
|
1299
|
+
const t = [];
|
|
1300
|
+
if (this.window.groupCache && Object.keys(this.window.groupCache).forEach((i) => {
|
|
1301
|
+
this.window.groupCache[i] && this.window.groupCache[i][e] && t.push(Number(i));
|
|
1302
|
+
}), t.length === 0) {
|
|
1303
|
+
const i = this.window.equipCache && this.window.equipCache[e];
|
|
1304
|
+
if (i) {
|
|
1305
|
+
if (i.groupIds && i.groupIds.length > 0)
|
|
1306
|
+
return i.groupIds;
|
|
1307
|
+
i.groupId && t.push(i.groupId);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
return t;
|
|
1311
|
+
}
|
|
1312
|
+
setStatus(e) {
|
|
1313
|
+
let t = this.equipStatusObject[e.equipNo];
|
|
1314
|
+
const i = this.getEquipGroupIds(e.equipNo);
|
|
1315
|
+
e.status != 3 && i.length > 0 && (i.forEach((o) => {
|
|
1316
|
+
switch (e.status) {
|
|
1317
|
+
case 0:
|
|
1318
|
+
t == 6 && this.setGroupStatus(o, !1, 6);
|
|
1319
|
+
break;
|
|
1320
|
+
case 1:
|
|
1321
|
+
t == 6 ? this.setGroupStatus(o, !1, 6) : t == 2 && this.setGroupStatus(o, !1, 2);
|
|
1322
|
+
break;
|
|
1323
|
+
case 2:
|
|
1324
|
+
t != 2 && this.setGroupStatus(o, !0, 2), t == 6 && this.setGroupStatus(o, !1, 6);
|
|
1325
|
+
break;
|
|
1326
|
+
case 6:
|
|
1327
|
+
t == 2 && this.setGroupStatus(o, !1, 2), t != 6 && this.setGroupStatus(o, !0, 6);
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
let n = `${o}-${e.equipNo}`;
|
|
1331
|
+
this.nodesMap[n] && (this.nodesMap[n].status = e.status);
|
|
1332
|
+
}), this.equipStatusObject[e.equipNo] = e.status, this.statusChange(i[0], e.equipNo, e.status));
|
|
1333
|
+
}
|
|
1334
|
+
// 重置分组状态
|
|
1335
|
+
resetGroupStatus() {
|
|
1336
|
+
for (let e in this.groupNodeObject)
|
|
1337
|
+
this.groupNodeObject[e].alarmCounts = 0, this.groupNodeObject[e].backUpCount = 0;
|
|
1338
|
+
}
|
|
1339
|
+
// ★ 断开连接:统一用 destroy()
|
|
1340
|
+
disconnect() {
|
|
1341
|
+
this.equipStatusSignlr && (this.equipStatusSignlr.destroy(), this.equipStatusSignlr = null);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
const it = {
|
|
1345
|
+
getSetParm(s) {
|
|
1346
|
+
if (window.AxiosBuilder.axios)
|
|
1347
|
+
return window.AxiosBuilder.axios({
|
|
1348
|
+
method: "post",
|
|
1349
|
+
url: "/IoT/api/v3/EquipList/GetFullSetParmByEquipNo",
|
|
1350
|
+
params: s,
|
|
1351
|
+
data: s,
|
|
1352
|
+
headers: {
|
|
1353
|
+
"Content-Type": "application/json;charset=UTF-8",
|
|
1354
|
+
"Accept-Language": window.sessionStorage.languageType || "zh-CN"
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
}, st = Object.assign(
|
|
1359
|
+
{},
|
|
1360
|
+
it
|
|
1361
|
+
);
|
|
1362
|
+
class ot {
|
|
1363
|
+
constructor(e, t) {
|
|
1364
|
+
this.nodesMap = e, this.equipControllObject = t;
|
|
1365
|
+
}
|
|
1366
|
+
// 获取设备控制项
|
|
1367
|
+
async getSetting(e, t, i, o) {
|
|
1368
|
+
let [n, a] = String(e).split("-"), r = {
|
|
1369
|
+
equipNo: a
|
|
1370
|
+
};
|
|
1371
|
+
await st.getSetParm(r).then((u) => {
|
|
1372
|
+
if (u.data.code == 200) {
|
|
1373
|
+
let h = u && u.data && u.data.data && u.data.data.rows || [];
|
|
1374
|
+
this.nodesMap[e].settings || (this.nodesMap[e].settings = []), h && h.length > 0 && this.nodesMap[e] && (h.forEach((c) => {
|
|
1375
|
+
c.title = c.setNm, c.key = `${n}-${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 = n, c.setNo = c.setNo, c.equipName = t;
|
|
1376
|
+
}), this.nodesMap[e].settings = [...h]);
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
class O {
|
|
1382
|
+
static formateList(e, t) {
|
|
1383
|
+
let i = [];
|
|
1384
|
+
for (const o of e) {
|
|
1385
|
+
let n = {};
|
|
1386
|
+
n.count = 0, n.equipSelectCount = 0, n.controlSelectCount = 0, n.equipCount = o.equipCount || 0, n.title = o.name, n.key = o.id, n.isGroup = !0, n.children = [], n.status = 1, n.level = t || 1, n.expand = !t, n.equips = [], n.groupId = o.parentId, n.groups = [], n.alarmCounts = 0, n.backUpCounts = 0, n.indeterminate = !1, n.checked = !1, n.visible = !0, n.nodeEquipSelectCount = 0, n.checkedEquips = [], n.halfCheckedEquips = [], n.selectControlCount = 0, o.children && o.children.length > 0 && (n.groups = [
|
|
1387
|
+
...this.formateList(o.children, t ? t + 1 : 2)
|
|
1388
|
+
]), i.push(n);
|
|
1389
|
+
}
|
|
1390
|
+
return i;
|
|
1391
|
+
}
|
|
1392
|
+
static deepClone(e, t, i, o, n, a) {
|
|
1393
|
+
let r = [];
|
|
1394
|
+
if (e)
|
|
1395
|
+
for (let u = 0, h = e.length; u < h; u++) {
|
|
1396
|
+
const c = e[u].id || e[u].equipNo, d = `${o}-${c}`;
|
|
1397
|
+
r.push(
|
|
1398
|
+
{
|
|
1399
|
+
isGroup: i,
|
|
1400
|
+
key: d,
|
|
1401
|
+
status: a[c] || 0,
|
|
1402
|
+
title: e[u].title,
|
|
1403
|
+
level: t,
|
|
1404
|
+
expand: !1,
|
|
1405
|
+
isEquip: !0,
|
|
1406
|
+
loading: !1,
|
|
1407
|
+
indeterminate: n[d] && n[d].indeterminate || !1,
|
|
1408
|
+
checked: n[d] && n[d].checked || !1,
|
|
1409
|
+
groupId: o,
|
|
1410
|
+
equipNo: c,
|
|
1411
|
+
visible: !0,
|
|
1412
|
+
settings: []
|
|
1413
|
+
}
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
return r;
|
|
1417
|
+
}
|
|
1418
|
+
static copyOrigin(e) {
|
|
1419
|
+
let t = [];
|
|
1420
|
+
return e.forEach((i) => {
|
|
1421
|
+
t.push({ ...i });
|
|
1422
|
+
}), t;
|
|
1423
|
+
}
|
|
1424
|
+
// 获取分组位置
|
|
1425
|
+
static getPosition(e, t) {
|
|
1426
|
+
let i = 0;
|
|
1427
|
+
for (let o = 0, n = t.length; o < n; o++)
|
|
1428
|
+
if (t[o].key == e) {
|
|
1429
|
+
i = o - 30;
|
|
1430
|
+
break;
|
|
1431
|
+
}
|
|
1432
|
+
return i;
|
|
1433
|
+
}
|
|
1434
|
+
// 扁平化
|
|
1435
|
+
static flattern(e, t) {
|
|
1436
|
+
e.forEach((i) => {
|
|
1437
|
+
if (i.isGroup) {
|
|
1438
|
+
const o = t[`${i.key}`];
|
|
1439
|
+
t[`${i.key}`] = i, o && (i.alarmCounts = o.alarmCounts, i.backUpCounts = o.backUpCounts, i.status = o.status);
|
|
1440
|
+
}
|
|
1441
|
+
i.groups && i.groups.length && this.flattern(i.groups, t);
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* @description 生成唯一Id
|
|
1446
|
+
* @param {} 不用传参
|
|
1447
|
+
* @return {string}
|
|
1448
|
+
*/
|
|
1449
|
+
static generateUUID() {
|
|
1450
|
+
let e = (/* @__PURE__ */ new Date()).getTime();
|
|
1451
|
+
return window.performance && typeof window.performance.now == "function" && (e += performance.now()), "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(i) {
|
|
1452
|
+
let o = (e + Math.random() * 16) % 16 | 0;
|
|
1453
|
+
return e = Math.floor(e / 16), (i === "x" ? o : o & 3 | 8).toString(16);
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* @description 将普通列表转换为树结构的列表
|
|
1458
|
+
* @param {list} 可构建树形结构的普通列表
|
|
1459
|
+
* @return {string}
|
|
1460
|
+
*/
|
|
1461
|
+
static listToTreeList(e) {
|
|
1462
|
+
const t = e, i = [], o = {};
|
|
1463
|
+
return t.forEach((n) => {
|
|
1464
|
+
o[n.id] = n;
|
|
1465
|
+
}), t.forEach((n) => {
|
|
1466
|
+
const a = o[n.parentId];
|
|
1467
|
+
a ? (a.children || (a.children = [])).push(n) : i.push(n);
|
|
1468
|
+
}), i;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
class nt extends H {
|
|
1472
|
+
// 分组节点扁平化对象、设备扁平化对象、window缓存设备扁平化对象
|
|
1473
|
+
constructor(e, t, i) {
|
|
1474
|
+
super(), this.showSettings = t, this.groupNodeObject = e, this.aliasName = i;
|
|
1475
|
+
}
|
|
1476
|
+
// 触发搜索
|
|
1477
|
+
filterMethod(e) {
|
|
1478
|
+
for (let t in this.groupNodeObject)
|
|
1479
|
+
e && this.updateBySearch(t, e);
|
|
1480
|
+
}
|
|
1481
|
+
// 搜索状态将搜索的结果存放缓存中
|
|
1482
|
+
updateBySearch(e, t) {
|
|
1483
|
+
let i = this.window[`group-${this.groupNodeObject[e].key}${this.aliasName}`];
|
|
1484
|
+
i && (i = i.filter((o) => o.title.includes(t)), this.window[`group-${this.groupNodeObject[e].key}-search`] = O.copyOrigin(i));
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
const V = (s, e) => {
|
|
1488
|
+
const t = s.__vccOpts || s;
|
|
1489
|
+
for (const [i, o] of e)
|
|
1490
|
+
t[i] = o;
|
|
1491
|
+
return t;
|
|
1492
|
+
}, at = {
|
|
1493
|
+
props: {
|
|
1494
|
+
source: {
|
|
1495
|
+
type: Object,
|
|
1496
|
+
default: () => {
|
|
1497
|
+
}
|
|
1498
|
+
},
|
|
1499
|
+
groupEditAndNew: {
|
|
1500
|
+
type: Function,
|
|
1501
|
+
default: () => {
|
|
1502
|
+
}
|
|
1503
|
+
},
|
|
1504
|
+
deleteGroup: {
|
|
1505
|
+
type: Function,
|
|
1506
|
+
default: () => {
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
}, rt = { class: "operates" };
|
|
1511
|
+
function ut(s, e, t, i, o, n) {
|
|
1512
|
+
const a = I("el-button"), r = I("el-button-group"), u = I("el-popover");
|
|
1513
|
+
return m(), N("div", rt, [
|
|
1514
|
+
C(u, {
|
|
1515
|
+
placement: "bottom",
|
|
1516
|
+
trigger: "hover"
|
|
1517
|
+
}, {
|
|
1518
|
+
reference: $(() => e[6] || (e[6] = [
|
|
1519
|
+
E("i", { class: "iconfont icon-_gengduo" }, null, -1)
|
|
1520
|
+
])),
|
|
1521
|
+
default: $(() => [
|
|
1522
|
+
C(r, { class: "new-button-group setModule" }, {
|
|
1523
|
+
default: $(() => [
|
|
1524
|
+
C(a, {
|
|
1525
|
+
type: "text",
|
|
1526
|
+
size: "small",
|
|
1527
|
+
class: "elBtn",
|
|
1528
|
+
onClick: e[0] || (e[0] = oe((h) => t.groupEditAndNew(!1, t.source), ["stop"]))
|
|
1529
|
+
}, {
|
|
1530
|
+
default: $(() => [
|
|
1531
|
+
e[3] || (e[3] = E("i", { class: "iconfont icon-tubiao20_bianji" }, null, -1)),
|
|
1532
|
+
te(" " + R(s.$t("equipInfo.poverTips.rename")), 1)
|
|
1533
|
+
]),
|
|
1534
|
+
_: 1,
|
|
1535
|
+
__: [3]
|
|
1536
|
+
}),
|
|
1537
|
+
C(a, {
|
|
1538
|
+
type: "text",
|
|
1539
|
+
size: "small",
|
|
1540
|
+
class: "elBtn",
|
|
1541
|
+
onClick: e[1] || (e[1] = (h) => t.groupEditAndNew(!0, t.source))
|
|
1542
|
+
}, {
|
|
1543
|
+
default: $(() => [
|
|
1544
|
+
e[4] || (e[4] = E("i", { class: "iconfont icon-tubiao20_tianjiashebei" }, null, -1)),
|
|
1545
|
+
te(" " + R(s.$t("equipInfo.poverTips.newChildGroup")), 1)
|
|
1546
|
+
]),
|
|
1547
|
+
_: 1,
|
|
1548
|
+
__: [4]
|
|
1549
|
+
}),
|
|
1550
|
+
t.source.level != 1 ? (m(), K(a, {
|
|
1551
|
+
key: 0,
|
|
1552
|
+
type: "text",
|
|
1553
|
+
size: "small",
|
|
1554
|
+
class: "delete-btn",
|
|
1555
|
+
onClick: e[2] || (e[2] = oe((h) => t.deleteGroup(t.source), ["stop"]))
|
|
1556
|
+
}, {
|
|
1557
|
+
default: $(() => [
|
|
1558
|
+
e[5] || (e[5] = E("i", { class: "iconfont icon-tubiao20_shanchu" }, null, -1)),
|
|
1559
|
+
te(" " + R(s.$t("publics.button.deletes")), 1)
|
|
1560
|
+
]),
|
|
1561
|
+
_: 1,
|
|
1562
|
+
__: [5]
|
|
1563
|
+
})) : j("", !0)
|
|
1564
|
+
]),
|
|
1565
|
+
_: 1
|
|
1566
|
+
})
|
|
1567
|
+
]),
|
|
1568
|
+
_: 1
|
|
1569
|
+
})
|
|
1570
|
+
]);
|
|
1571
|
+
}
|
|
1572
|
+
const ht = /* @__PURE__ */ V(at, [["render", ut]]), ct = {
|
|
1573
|
+
name: "ElTreeVirtualNode",
|
|
1574
|
+
componentName: "ElTreeVirtualNode",
|
|
1575
|
+
props: {
|
|
1576
|
+
searchName: {
|
|
1577
|
+
type: String,
|
|
1578
|
+
default: ""
|
|
1579
|
+
},
|
|
1580
|
+
expanding: {
|
|
1581
|
+
type: Boolean,
|
|
1582
|
+
default: !1
|
|
1583
|
+
},
|
|
1584
|
+
aleadyLoadAll: {
|
|
1585
|
+
type: Boolean,
|
|
1586
|
+
default: !1
|
|
1587
|
+
},
|
|
1588
|
+
groupLoading: {
|
|
1589
|
+
type: Boolean,
|
|
1590
|
+
default: !1
|
|
1591
|
+
},
|
|
1592
|
+
source: {
|
|
1593
|
+
type: Object,
|
|
1594
|
+
default() {
|
|
1595
|
+
return {};
|
|
1596
|
+
}
|
|
1597
|
+
},
|
|
1598
|
+
showCheckbox: {
|
|
1599
|
+
type: Boolean,
|
|
1600
|
+
default: !1
|
|
1601
|
+
},
|
|
1602
|
+
showStatus: {
|
|
1603
|
+
type: Boolean,
|
|
1604
|
+
default: !1
|
|
1605
|
+
},
|
|
1606
|
+
showOperate: {
|
|
1607
|
+
type: Boolean,
|
|
1608
|
+
default: !1
|
|
1609
|
+
},
|
|
1610
|
+
currentSelect: {
|
|
1611
|
+
type: [Number, String],
|
|
1612
|
+
default: -1
|
|
1613
|
+
},
|
|
1614
|
+
nodeClick: {
|
|
1615
|
+
type: Function
|
|
1616
|
+
},
|
|
1617
|
+
onChecked: {
|
|
1618
|
+
type: Function
|
|
1619
|
+
},
|
|
1620
|
+
groupEditAndNew: {
|
|
1621
|
+
type: Function
|
|
1622
|
+
},
|
|
1623
|
+
deleteGroup: {
|
|
1624
|
+
type: Function
|
|
1625
|
+
},
|
|
1626
|
+
childrenResetGroupNum: {
|
|
1627
|
+
type: Function
|
|
1628
|
+
},
|
|
1629
|
+
getEquipStatus: {
|
|
1630
|
+
type: Function
|
|
1631
|
+
},
|
|
1632
|
+
colorConfig: {
|
|
1633
|
+
type: Object,
|
|
1634
|
+
default: () => {
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
index: {
|
|
1638
|
+
type: Number,
|
|
1639
|
+
default: -1
|
|
1640
|
+
}
|
|
1641
|
+
},
|
|
1642
|
+
components: {
|
|
1643
|
+
oparate: ht
|
|
1644
|
+
},
|
|
1645
|
+
computed: {
|
|
1646
|
+
getColor() {
|
|
1647
|
+
return function(s) {
|
|
1648
|
+
this.colorConfig || (this.colorConfig = {
|
|
1649
|
+
noComm: "#a0a0a0",
|
|
1650
|
+
normal: "#63e03f",
|
|
1651
|
+
alarm: "#f22433",
|
|
1652
|
+
lsSet: "#bebcaa",
|
|
1653
|
+
initialize: "#289ac0",
|
|
1654
|
+
withdraw: "#ffc0cb",
|
|
1655
|
+
BackUp: "#f8901c"
|
|
1656
|
+
});
|
|
1657
|
+
let e;
|
|
1658
|
+
switch (s) {
|
|
1659
|
+
case 0:
|
|
1660
|
+
e = this.colorConfig.noComm;
|
|
1661
|
+
break;
|
|
1662
|
+
case 1:
|
|
1663
|
+
e = this.colorConfig.normal;
|
|
1664
|
+
break;
|
|
1665
|
+
case 2:
|
|
1666
|
+
e = this.colorConfig.alarm;
|
|
1667
|
+
break;
|
|
1668
|
+
case 3:
|
|
1669
|
+
e = this.colorConfig.lsSet;
|
|
1670
|
+
break;
|
|
1671
|
+
case 4:
|
|
1672
|
+
e = this.colorConfig.initialize;
|
|
1673
|
+
break;
|
|
1674
|
+
case 5:
|
|
1675
|
+
e = this.colorConfig.withdraw;
|
|
1676
|
+
break;
|
|
1677
|
+
case 6:
|
|
1678
|
+
e = this.colorConfig.BackUp;
|
|
1679
|
+
break;
|
|
1680
|
+
default:
|
|
1681
|
+
e = this.colorConfig.noComm;
|
|
1682
|
+
break;
|
|
1683
|
+
}
|
|
1684
|
+
return e;
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
},
|
|
1688
|
+
data() {
|
|
1689
|
+
return {
|
|
1690
|
+
indent: 13
|
|
1691
|
+
};
|
|
1692
|
+
},
|
|
1693
|
+
methods: {
|
|
1694
|
+
clickFunction() {
|
|
1695
|
+
this.source.expand = !this.source.expand, this.nodeClick(this.source, this.index, this.source.level, this.source.checked);
|
|
1696
|
+
},
|
|
1697
|
+
checkedChange(s) {
|
|
1698
|
+
this.onChecked(this.source);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
}, lt = { class: "el-tree-node__content" }, dt = { class: "nodeContent" }, pt = {
|
|
1702
|
+
key: 1,
|
|
1703
|
+
class: "circle"
|
|
1704
|
+
}, ft = { class: "label" }, gt = {
|
|
1705
|
+
key: 2,
|
|
1706
|
+
class: "equipNumber"
|
|
1707
|
+
}, St = {
|
|
1708
|
+
key: 4,
|
|
1709
|
+
class: "el-tree-node__loading-icon el-icon-loading"
|
|
1710
|
+
};
|
|
1711
|
+
function wt(s, e, t, i, o, n) {
|
|
1712
|
+
const a = I("el-checkbox"), r = I("oparate");
|
|
1713
|
+
return m(), N("div", {
|
|
1714
|
+
class: pe(["el-tree-node", {
|
|
1715
|
+
parent_tag: t.source.isGroup,
|
|
1716
|
+
child_tags: !t.source.isGroup,
|
|
1717
|
+
selectedColor: t.currentSelect === t.source.key && !t.source.isGroup
|
|
1718
|
+
}]),
|
|
1719
|
+
onClick: e[2] || (e[2] = (...u) => n.clickFunction && n.clickFunction(...u))
|
|
1720
|
+
}, [
|
|
1721
|
+
E("div", lt, [
|
|
1722
|
+
E("span", {
|
|
1723
|
+
class: "el-tree__indent",
|
|
1724
|
+
"aria-hidden": "true",
|
|
1725
|
+
style: ie({ width: (t.source.level - 1) * o.indent + "px" })
|
|
1726
|
+
}, null, 4),
|
|
1727
|
+
t.source.isGroup ? (m(), N("span", {
|
|
1728
|
+
key: 0,
|
|
1729
|
+
class: pe([
|
|
1730
|
+
{
|
|
1731
|
+
"is-leaf": !t.source.isGroup,
|
|
1732
|
+
expanded: t.source.isGroup && t.source.expand
|
|
1733
|
+
},
|
|
1734
|
+
"el-tree-node__expand-icon",
|
|
1735
|
+
"iconfont icon-fangxiangL"
|
|
1736
|
+
])
|
|
1737
|
+
}, null, 2)) : j("", !0),
|
|
1738
|
+
E("div", dt, [
|
|
1739
|
+
t.showCheckbox ? (m(), K(a, {
|
|
1740
|
+
key: 0,
|
|
1741
|
+
onClick: e[0] || (e[0] = oe(() => {
|
|
1742
|
+
}, ["stop"])),
|
|
1743
|
+
modelValue: t.source.checked,
|
|
1744
|
+
"onUpdate:modelValue": e[1] || (e[1] = (u) => t.source.checked = u),
|
|
1745
|
+
indeterminate: t.source.indeterminate,
|
|
1746
|
+
onChange: n.checkedChange
|
|
1747
|
+
}, null, 8, ["modelValue", "indeterminate", "onChange"])) : j("", !0),
|
|
1748
|
+
t.showStatus ? (m(), N("span", pt, [
|
|
1749
|
+
t.source.status != 6 ? (m(), N("span", {
|
|
1750
|
+
key: 0,
|
|
1751
|
+
class: "yd",
|
|
1752
|
+
style: ie({ backgroundColor: n.getColor(t.source.status) })
|
|
1753
|
+
}, null, 4)) : (m(), N("i", {
|
|
1754
|
+
key: 1,
|
|
1755
|
+
style: ie({ color: t.colorConfig.BackUp }),
|
|
1756
|
+
class: "iconfont icon-gw-icon-beiji2"
|
|
1757
|
+
}, null, 4))
|
|
1758
|
+
])) : j("", !0),
|
|
1759
|
+
E("span", ft, R(t.source.title), 1),
|
|
1760
|
+
t.source.isGroup && !t.source.isEquip || t.source.isGroup && !t.source.isEquip ? (m(), N("span", gt, R(t.source.count), 1)) : j("", !0),
|
|
1761
|
+
t.source.isGroup && t.showOperate ? (m(), K(r, {
|
|
1762
|
+
key: 3,
|
|
1763
|
+
source: t.source,
|
|
1764
|
+
groupEditAndNew: t.groupEditAndNew,
|
|
1765
|
+
deleteGroup: t.deleteGroup
|
|
1766
|
+
}, null, 8, ["source", "groupEditAndNew", "deleteGroup"])) : j("", !0),
|
|
1767
|
+
t.source.loading ? (m(), N("span", St)) : j("", !0)
|
|
1768
|
+
])
|
|
1769
|
+
])
|
|
1770
|
+
], 2);
|
|
1771
|
+
}
|
|
1772
|
+
const Ct = /* @__PURE__ */ V(ct, [["render", wt]]), bt = {
|
|
1773
|
+
components: {
|
|
1774
|
+
VirtualList: Ye
|
|
1775
|
+
},
|
|
1776
|
+
mixins: [ye],
|
|
1777
|
+
data() {
|
|
1778
|
+
return {
|
|
1779
|
+
itemComponent: Ct,
|
|
1780
|
+
//节点组件
|
|
1781
|
+
visibleList: [],
|
|
1782
|
+
//虚拟滚动所需要的列表
|
|
1783
|
+
currentSelect: -1,
|
|
1784
|
+
//当前选中的节点(不包含分组节点)
|
|
1785
|
+
equipStatusManage: null,
|
|
1786
|
+
//设备状态管理工具
|
|
1787
|
+
cacheManage: null,
|
|
1788
|
+
//内存管理工具
|
|
1789
|
+
searchManage: null,
|
|
1790
|
+
//搜索管理工具
|
|
1791
|
+
equipNumManage: null,
|
|
1792
|
+
//设备数量管理工具
|
|
1793
|
+
requestManage: null,
|
|
1794
|
+
//请求管理工具
|
|
1795
|
+
checkStatusManage: null,
|
|
1796
|
+
//请求管理工具
|
|
1797
|
+
groupNodeObject: {},
|
|
1798
|
+
//所有分组扁平化所保存的存储的地方
|
|
1799
|
+
nodesMap: {},
|
|
1800
|
+
//所有实例化对象映射
|
|
1801
|
+
equipCheckObject: {},
|
|
1802
|
+
//设备选中状态记录 equipCheckObject:{xxx设备号:{indeterminate: false,checked: false,groupId:xxx}}
|
|
1803
|
+
equipStatusObject: {},
|
|
1804
|
+
//记录设备状态,从后台推送的初始化全量状态,增量更新需要实时维护
|
|
1805
|
+
controlObject: {},
|
|
1806
|
+
//展开的控制项,controlObject:{xxx设备号:{groupId:xxx}}用于设置当前展开设置选中,如果依赖与equipControlObject筛选设置选中,性能差
|
|
1807
|
+
isSearchStatus: !1,
|
|
1808
|
+
//是否是搜索状态
|
|
1809
|
+
equipControllObject: {},
|
|
1810
|
+
//绑定所有的已选中的设备控制项
|
|
1811
|
+
expandGroup: [],
|
|
1812
|
+
//记录已展开的分组
|
|
1813
|
+
updateJob: null,
|
|
1814
|
+
filterEquipList: []
|
|
1815
|
+
//过滤条件下新增的设备列表,由于设备开始状态都是0,因而需要单独维护
|
|
1816
|
+
};
|
|
1817
|
+
},
|
|
1818
|
+
props: {
|
|
1819
|
+
data: {
|
|
1820
|
+
//分组列表
|
|
1821
|
+
type: Array
|
|
1822
|
+
},
|
|
1823
|
+
selectEquips: {
|
|
1824
|
+
//设备选中列表,用于回显,如权限管理。支持数组格式 [equipNo] 或对象格式 { groupId: [equipNo] }
|
|
1825
|
+
type: [Array, Object],
|
|
1826
|
+
default: () => []
|
|
1827
|
+
},
|
|
1828
|
+
controllList: {
|
|
1829
|
+
//控制项选中列表,用于回显,如权限管理
|
|
1830
|
+
type: Array,
|
|
1831
|
+
default: () => []
|
|
1832
|
+
},
|
|
1833
|
+
showSettings: {
|
|
1834
|
+
//是否需要加载设备控制项,如权限管理
|
|
1835
|
+
type: Boolean,
|
|
1836
|
+
default: !1
|
|
1837
|
+
},
|
|
1838
|
+
showSelectNum: {
|
|
1839
|
+
//是否在树形结构顶部展示已选设备数量,如设备管理
|
|
1840
|
+
type: Boolean,
|
|
1841
|
+
default() {
|
|
1842
|
+
return !1;
|
|
1843
|
+
}
|
|
1844
|
+
},
|
|
1845
|
+
showCheckbox: {
|
|
1846
|
+
//是否展示checkbox
|
|
1847
|
+
type: Boolean,
|
|
1848
|
+
default: !1
|
|
1849
|
+
},
|
|
1850
|
+
showStatus: {
|
|
1851
|
+
//是否展示设备状态
|
|
1852
|
+
type: Boolean,
|
|
1853
|
+
default: !1
|
|
1854
|
+
},
|
|
1855
|
+
filterEquip: {
|
|
1856
|
+
//是否过滤
|
|
1857
|
+
type: Boolean,
|
|
1858
|
+
default: !1
|
|
1859
|
+
},
|
|
1860
|
+
showOperate: {
|
|
1861
|
+
// 是否展示操作按钮
|
|
1862
|
+
type: Boolean,
|
|
1863
|
+
default: !1
|
|
1864
|
+
},
|
|
1865
|
+
defaultExpandAll: {
|
|
1866
|
+
type: Boolean,
|
|
1867
|
+
default: !1
|
|
1868
|
+
},
|
|
1869
|
+
currentNodeKey: [String, Number],
|
|
1870
|
+
colorConfig: {
|
|
1871
|
+
type: Object,
|
|
1872
|
+
default: () => ({
|
|
1873
|
+
noComm: "#a0a0a0",
|
|
1874
|
+
normal: "#63e03f",
|
|
1875
|
+
alarm: "#f22433",
|
|
1876
|
+
lsSet: "#bebcaa",
|
|
1877
|
+
initialize: "#289ac0",
|
|
1878
|
+
withdraw: "#ffc0cb",
|
|
1879
|
+
BackUp: "#f8901c"
|
|
1880
|
+
})
|
|
1881
|
+
},
|
|
1882
|
+
treeType: {
|
|
1883
|
+
type: String,
|
|
1884
|
+
default: ""
|
|
1885
|
+
},
|
|
1886
|
+
buildTree: {
|
|
1887
|
+
type: Function,
|
|
1888
|
+
default: () => {
|
|
1889
|
+
}
|
|
1890
|
+
},
|
|
1891
|
+
filterData: {
|
|
1892
|
+
type: Function,
|
|
1893
|
+
default: () => {
|
|
1894
|
+
}
|
|
1895
|
+
},
|
|
1896
|
+
alias: {
|
|
1897
|
+
type: String,
|
|
1898
|
+
default: ""
|
|
1899
|
+
}
|
|
1900
|
+
},
|
|
1901
|
+
watch: {
|
|
1902
|
+
data(s) {
|
|
1903
|
+
s && s.length && (O.flattern(this.data, this.groupNodeObject), this.cacheManage.addNodesMap(Object.values(this.groupNodeObject).map((e) => e)), this.init());
|
|
1904
|
+
},
|
|
1905
|
+
controllList(s) {
|
|
1906
|
+
this.updateCheckedStatusWithControls();
|
|
1907
|
+
},
|
|
1908
|
+
selectEquips(s) {
|
|
1909
|
+
this.updateCheckedStatusWithEquips(), this.$nextTick(() => {
|
|
1910
|
+
this.checkStatusManage && this.checkStatusManage.updateGroupCheckStatus();
|
|
1911
|
+
});
|
|
1912
|
+
},
|
|
1913
|
+
filterEquip(s) {
|
|
1914
|
+
this.$nextTick(() => {
|
|
1915
|
+
this.visibleList = [], this.$refs.virtualList.scrollToIndex(0), this.updateTreeList(this.data), this.equipNumManage.resetGroupNum(this.isSearchStatus, s, this.equipStatusObject);
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
},
|
|
1919
|
+
computed: {
|
|
1920
|
+
aliasName() {
|
|
1921
|
+
return this.alias ? `-${this.alias}` : "";
|
|
1922
|
+
}
|
|
1923
|
+
},
|
|
1924
|
+
created() {
|
|
1925
|
+
this.showCheckbox && (this.checkStatusManage = new Ze(this.groupNodeObject, this.nodesMap, this.equipControllObject, this.controlObject, this.equipCheckObject, this.aliasName)), this.cacheManage = new Qe(this.groupNodeObject, this.nodesMap, this.controlObject, this.equipCheckObject), this.searchManage = new nt(this.groupNodeObject, this.showSettings, this.aliasName), this.equipNumManage = new et(this.groupNodeObject, this.aliasName), this.requestManage = new ot(this.nodesMap, this.equipControllObject);
|
|
1926
|
+
},
|
|
1927
|
+
mounted() {
|
|
1928
|
+
this.updateCheckedStatusWithControls(), this.updateCheckedStatusWithEquips(), window.addEventListener("message", (s) => {
|
|
1929
|
+
s.data.type && this[s.data.type] && this[s.data.type](s.data.data);
|
|
1930
|
+
});
|
|
1931
|
+
},
|
|
1932
|
+
methods: {
|
|
1933
|
+
// 初始化
|
|
1934
|
+
init() {
|
|
1935
|
+
this.data[0].expand = !0, this.updateTreeList(), setTimeout(() => {
|
|
1936
|
+
Object.values(this.groupNodeObject).forEach((s, e) => {
|
|
1937
|
+
!s.expand && this.expandGroup.includes(s.key) && (s.expand = !0), this.filterWithAlias(s.key), this.updateGroupEquips(s.key, !0);
|
|
1938
|
+
}), this.showCheckbox && this.checkStatusManage && this.checkStatusManage.updateGroupCheckStatus(), this.showStatus && !this.equipStatusManage && (this.equipStatusManage = new tt(this.nodesMap, this.equipStatusObject, this.groupNodeObject, this.statusChange, this.aliasName));
|
|
1939
|
+
}, 500);
|
|
1940
|
+
},
|
|
1941
|
+
// 根据条件过滤
|
|
1942
|
+
filterWithAlias(s) {
|
|
1943
|
+
if (this.aliasName) {
|
|
1944
|
+
let e = this.window[`group-${s}`] || [];
|
|
1945
|
+
this.window[`group-${s}${this.aliasName}`] = this.filterData(e);
|
|
1946
|
+
}
|
|
1947
|
+
},
|
|
1948
|
+
// 更新当前选中
|
|
1949
|
+
updateCurrentSelect() {
|
|
1950
|
+
this.window.equipCache && this.window.equipCache[this.currentNodeKey] && (this.currentSelect = `${this.window.equipCache[this.currentNodeKey].groupId}-${this.currentNodeKey}`);
|
|
1951
|
+
},
|
|
1952
|
+
// 设备状态变化
|
|
1953
|
+
statusChange(s, e, t) {
|
|
1954
|
+
this.currentSelect == `${s}-${e}` && this.$emit("statusChange", e, t);
|
|
1955
|
+
},
|
|
1956
|
+
// 更新checkbox选中状态
|
|
1957
|
+
updateCheckWidthJob() {
|
|
1958
|
+
this.showCheckbox && (this.checkStatusManage.resetCheckedStatus(), this.updateCheckedStatusWithControls(), this.updateCheckedStatusWithEquips(), this.checkStatusManage && this.checkStatusManage.updateGroupCheckStatus());
|
|
1959
|
+
},
|
|
1960
|
+
// 通过外框更新设备
|
|
1961
|
+
updateGroupEquips(s, e) {
|
|
1962
|
+
if (!this.isSearchStatus && this.groupNodeObject[s]) {
|
|
1963
|
+
let t = this.equipNumManage.getAllEquipsNum();
|
|
1964
|
+
this.$emit("getTotal", t);
|
|
1965
|
+
}
|
|
1966
|
+
this.equipNumManage.resetGroupNum(this.isSearchStatus, this.filterEquip, this.equipStatusObject), this.groupNodeObject[s].expand && this.updateList(s, this.groupNodeObject[s].level, null, !1);
|
|
1967
|
+
},
|
|
1968
|
+
// 展开的时候从缓存中拿设备数据到equips中并更新视图
|
|
1969
|
+
updateList(s) {
|
|
1970
|
+
if (this.groupNodeObject[s]) {
|
|
1971
|
+
let e = [];
|
|
1972
|
+
this.isSearchStatus ? (e = this.window[`group-${s}-search`], this.groupNodeObject[s].equips = [...O.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 = [...O.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.showCheckbox && this.checkStatusManage && e && e.length && this.checkStatusManage.updateGroupCheckStatus(), this.showStatus && this.equipStatusManage && this.equipStatusManage.updateGroupStatus(s), this.updateCurrentSelect();
|
|
1973
|
+
}
|
|
1974
|
+
},
|
|
1975
|
+
// 更新整个树形结构
|
|
1976
|
+
updateTreeList(s) {
|
|
1977
|
+
s && s.length > 0 && s.forEach((e) => {
|
|
1978
|
+
this.filterEquip && e.status === 2 ? this.filterEquipList.includes(e.equipNo) || this.visibleList.push(e) : this.filterEquip || 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 || []);
|
|
1979
|
+
});
|
|
1980
|
+
},
|
|
1981
|
+
// 节点点击事件
|
|
1982
|
+
nodeClick(s, e, t, i) {
|
|
1983
|
+
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;
|
|
1984
|
+
},
|
|
1985
|
+
groupClick(s, e, t) {
|
|
1986
|
+
s.expand ? this.updateList(s.key, s.level, e, t) : (this.cacheManage.recycleGroupCache(s.key), this.visibleList = [], this.updateTreeList(this.data));
|
|
1987
|
+
},
|
|
1988
|
+
async equipClick(s, e, t) {
|
|
1989
|
+
this.showSettings && (s.expand ? (s.loading = !0, await this.requestManage.getSetting(s.key, s.title, s.level, t), this.controlObject[`${s.groupId}-${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.groupId}-${s.equipNo}`]));
|
|
1990
|
+
},
|
|
1991
|
+
onChecked(s) {
|
|
1992
|
+
this.checkStatusManage && this.checkStatusManage.onChecked(s, this.isSearchStatus), this.$emit("onCheck");
|
|
1993
|
+
},
|
|
1994
|
+
groupEditAndNew(s, e) {
|
|
1995
|
+
this.$emit("groupEditAndNew", { isGroupNew: s, node: e });
|
|
1996
|
+
},
|
|
1997
|
+
deleteGroup(s) {
|
|
1998
|
+
this.$emit("deleteGroup", s);
|
|
1999
|
+
},
|
|
2000
|
+
updateCheckedStatusWithControls() {
|
|
2001
|
+
this.controllList && this.controllList.length && this.checkStatusManage && this.checkStatusManage && this.checkStatusManage.updateCheckedStatusWithControls(this.controllList);
|
|
2002
|
+
},
|
|
2003
|
+
updateCheckedStatusWithEquips() {
|
|
2004
|
+
if (!this.checkStatusManage || !this.selectEquips)
|
|
2005
|
+
return;
|
|
2006
|
+
(Array.isArray(this.selectEquips) ? this.selectEquips.length > 0 : Object.keys(this.selectEquips).length > 0) && (this.checkStatusManage.updateCheckedStatusWithEquips(this.selectEquips), this.checkStatusManage.updateGroupCheckStatus());
|
|
2007
|
+
},
|
|
2008
|
+
resetCheckedStatus() {
|
|
2009
|
+
this.checkStatusManage && this.checkStatusManage.resetCheckedStatus();
|
|
2010
|
+
},
|
|
2011
|
+
/**
|
|
2012
|
+
* @description 获取选择的设备
|
|
2013
|
+
* @return Array
|
|
2014
|
+
*/
|
|
2015
|
+
getEquipSelectd() {
|
|
2016
|
+
return this.checkStatusManage && this.checkStatusManage.getEquipSelectd();
|
|
2017
|
+
},
|
|
2018
|
+
/**
|
|
2019
|
+
* @description 获取选择的设备(携带分组)
|
|
2020
|
+
* @return Array
|
|
2021
|
+
*/
|
|
2022
|
+
getEquipGroupSelectd() {
|
|
2023
|
+
return this.checkStatusManage && this.checkStatusManage.getEquipGroupSelectd();
|
|
2024
|
+
},
|
|
2025
|
+
/**
|
|
2026
|
+
* @description 获取选择的设备控制项
|
|
2027
|
+
* @return Array
|
|
2028
|
+
*/
|
|
2029
|
+
getControlSelected() {
|
|
2030
|
+
return this.checkStatusManage && this.checkStatusManage.getControlSelected();
|
|
2031
|
+
},
|
|
2032
|
+
/**
|
|
2033
|
+
* @description 记录已展开的分组
|
|
2034
|
+
* @return 无
|
|
2035
|
+
*/
|
|
2036
|
+
recordExpandGroup() {
|
|
2037
|
+
this.expandGroup = [], Object.values(this.groupNodeObject).forEach((s) => {
|
|
2038
|
+
s.expand && this.expandGroup.push(s.key);
|
|
2039
|
+
});
|
|
2040
|
+
},
|
|
2041
|
+
/**
|
|
2042
|
+
* @description 清除已展开的分组
|
|
2043
|
+
* @return
|
|
2044
|
+
*/
|
|
2045
|
+
removeExpandGroup() {
|
|
2046
|
+
this.$nextTick(() => {
|
|
2047
|
+
this.expandGroup = [];
|
|
2048
|
+
});
|
|
2049
|
+
},
|
|
2050
|
+
/**
|
|
2051
|
+
* @description 搜索设备
|
|
2052
|
+
* 1:清除所有节点缓存
|
|
2053
|
+
2: 设置搜索状态为true,搜索状态下所有操作全部不更新
|
|
2054
|
+
3: 非搜索状态,需要清除搜索缓存
|
|
2055
|
+
* @param {searchName} 搜索名称
|
|
2056
|
+
* @return 无返回值
|
|
2057
|
+
*/
|
|
2058
|
+
filterMethod(s) {
|
|
2059
|
+
this.visibleList = [], this.cacheManage.recycleAllNodeCache(), s ? (this.isSearchStatus = !0, this.searchManage.filterMethod(s)) : this.isSearchStatus = !1, this.init(), this.$nextTick(() => {
|
|
2060
|
+
this.$refs.virtualList.scrollToIndex(0);
|
|
2061
|
+
}), this.equipNumManage.resetGroupNum(this.isSearchStatus, this.filterEquip, this.equipStatusObject), this.showCheckbox && (this.checkStatusManage && this.checkStatusManage.reComputedCheckNum(this.isSearchStatus), this.checkStatusManage && this.checkStatusManage.updateGroupCheckStatus());
|
|
2062
|
+
},
|
|
2063
|
+
// 重新构建树
|
|
2064
|
+
rebuildTree() {
|
|
2065
|
+
this.recordExpandGroup(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus(), this.cacheManage.recycleAllNodeCache(!0), this.$nextTick(() => {
|
|
2066
|
+
this.buildTree(), this.removeExpandGroup();
|
|
2067
|
+
});
|
|
2068
|
+
},
|
|
2069
|
+
// 树形结构销毁
|
|
2070
|
+
destroyTree() {
|
|
2071
|
+
this.cacheManage.recycleAllNodeCache(!0), this.visibleList = [], this.updateTreeList(this.data);
|
|
2072
|
+
},
|
|
2073
|
+
// 通过外框事件更新树形结构数据--start
|
|
2074
|
+
/**
|
|
2075
|
+
* @description 获取分组设备
|
|
2076
|
+
* @param {data} {分组Id}
|
|
2077
|
+
* @return 无返回值
|
|
2078
|
+
*/
|
|
2079
|
+
GetGroupEquips(s) {
|
|
2080
|
+
s.groupId && this.groupNodeObject[s.groupId] && !this.isSearchStatus && (this.updateGroupEquips(s.groupId, !0), this.updateJob && clearTimeout(this.updateJob), this.updateJob = setTimeout(() => {
|
|
2081
|
+
this.equipNumManage.resetGroupNum(this.isSearchStatus, this.filterEquip, this.equipStatusObject), this.updateCheckWidthJob();
|
|
2082
|
+
}, 500));
|
|
2083
|
+
},
|
|
2084
|
+
/**
|
|
2085
|
+
* @description 删除设备
|
|
2086
|
+
* @param {data} {groupId,equips}
|
|
2087
|
+
* @return 无返回值
|
|
2088
|
+
*/
|
|
2089
|
+
DeleteEquip(s) {
|
|
2090
|
+
const { groupId: e, equips: t } = s || {};
|
|
2091
|
+
e && this.groupNodeObject[e] && (this.updateGroupEquips(s.groupId), this.equipNumManage.resetGroupNum(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus()), t.length && t.forEach((i) => {
|
|
2092
|
+
let o = this.nodesMap[`${e}-${i.id}`];
|
|
2093
|
+
o && (this.currentSelect.toString().includes(i.id) && this.$emit("currentDelete"), this.showStatus && (o.status == 2 ? 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];
|
|
2094
|
+
});
|
|
2095
|
+
},
|
|
2096
|
+
/**
|
|
2097
|
+
* @description 移动设备
|
|
2098
|
+
* @param {data} {updateGroups} 需要更新的分组列表
|
|
2099
|
+
* @return 无返回值
|
|
2100
|
+
*/
|
|
2101
|
+
MoveEquips(s) {
|
|
2102
|
+
const { updateGroups: e, buildTree: t } = s || {};
|
|
2103
|
+
!t && e ? e.forEach((i) => {
|
|
2104
|
+
i && this.groupNodeObject[i] && (this.updateGroupEquips(i), this.equipNumManage.resetGroupNum(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus());
|
|
2105
|
+
}) : t && this.rebuildTree();
|
|
2106
|
+
},
|
|
2107
|
+
/**
|
|
2108
|
+
* @description 删除分组
|
|
2109
|
+
* @param {data} {groupId,parentGroupId}
|
|
2110
|
+
* @return 无返回值
|
|
2111
|
+
*/
|
|
2112
|
+
DeleteEquipGroup(s) {
|
|
2113
|
+
s.forEach((e) => {
|
|
2114
|
+
e.groupId && this.nodesMap[e.groupId] && (this.isSearchStatus || this.rebuildTree());
|
|
2115
|
+
});
|
|
2116
|
+
},
|
|
2117
|
+
/**
|
|
2118
|
+
* @description 新增分组
|
|
2119
|
+
* @param {data} {groupId,parentGroupId}
|
|
2120
|
+
* @return 无返回值
|
|
2121
|
+
*/
|
|
2122
|
+
AddEquipGroup(s) {
|
|
2123
|
+
const { parentGroupId: e, groupId: t } = s || {};
|
|
2124
|
+
t && this.nodesMap[e] && this.treeType && (this.isSearchStatus || this.rebuildTree());
|
|
2125
|
+
},
|
|
2126
|
+
/** 编辑分组
|
|
2127
|
+
* @description 新增分组
|
|
2128
|
+
* @param {data} {groupId,parentGroupId}
|
|
2129
|
+
* @return 无返回值
|
|
2130
|
+
*/
|
|
2131
|
+
EditEquipGroup(s) {
|
|
2132
|
+
const { groupId: e, groupName: t } = s;
|
|
2133
|
+
this.nodesMap[e] && (this.nodesMap[e].title = t);
|
|
2134
|
+
},
|
|
2135
|
+
/**
|
|
2136
|
+
* @description 新增分组设备
|
|
2137
|
+
* @param {data} {分组Id,设备}
|
|
2138
|
+
* @return 无返回值
|
|
2139
|
+
*/
|
|
2140
|
+
AddEquip(s) {
|
|
2141
|
+
const { groupId: e } = s || {};
|
|
2142
|
+
this.filterEquip && (this.filterEquipList = s == null ? void 0 : s.equips.map((t) => t.id)), e && this.groupNodeObject[e] && !this.isSearchStatus ? (this.updateGroupEquips(e, !0), this.updateJob && clearTimeout(this.updateJob), this.updateJob = setTimeout(() => {
|
|
2143
|
+
this.updateCheckWidthJob();
|
|
2144
|
+
}, 500)) : e && !this.isSearchStatus && this.rebuildTree();
|
|
2145
|
+
},
|
|
2146
|
+
/**
|
|
2147
|
+
* @description 新增分组设备
|
|
2148
|
+
* @param {data} {分组Id,设备}
|
|
2149
|
+
* @return 无返回值
|
|
2150
|
+
*/
|
|
2151
|
+
EditEquip(s) {
|
|
2152
|
+
const { equipNo: e, groupId: t, equipName: i } = s || {};
|
|
2153
|
+
this.nodesMap[`${t}-${e}`] && (this.isSearchStatus || (this.nodesMap[`${t}-${e}`].title = i));
|
|
2154
|
+
},
|
|
2155
|
+
/**
|
|
2156
|
+
* @description 重置分组数量
|
|
2157
|
+
* @param {isSearchStatus} {是否查询状态}
|
|
2158
|
+
* @return 无返回值
|
|
2159
|
+
*/
|
|
2160
|
+
childrenResetGroupNum(s) {
|
|
2161
|
+
this.equipNumManage.resetGroupNum(s, this.filterEquip, this.equipStatusObject);
|
|
2162
|
+
},
|
|
2163
|
+
/**
|
|
2164
|
+
* @description 获取设备状态
|
|
2165
|
+
* @param {data} {equipNo}
|
|
2166
|
+
* @return arry[equipNo]
|
|
2167
|
+
*/
|
|
2168
|
+
getEquipStatus(s) {
|
|
2169
|
+
return this.equipStatusManage.equipStatusObject[s];
|
|
2170
|
+
}
|
|
2171
|
+
// 通过外框事件更新树形结构数据--end
|
|
2172
|
+
}
|
|
2173
|
+
}, mt = {
|
|
2174
|
+
class: "gw-tree",
|
|
2175
|
+
style: { height: "100%" }
|
|
2176
|
+
}, yt = {
|
|
2177
|
+
class: "tree",
|
|
2178
|
+
style: { height: "100%" }
|
|
2179
|
+
};
|
|
2180
|
+
function qt(s, e, t, i, o, n) {
|
|
2181
|
+
const a = I("virtual-list", !0);
|
|
2182
|
+
return m(), N("div", mt, [
|
|
2183
|
+
E("div", yt, [
|
|
2184
|
+
C(a, {
|
|
2185
|
+
ref: "virtualList",
|
|
2186
|
+
class: "virtualList",
|
|
2187
|
+
"data-key": "key",
|
|
2188
|
+
"data-sources": o.visibleList,
|
|
2189
|
+
"data-component": o.itemComponent,
|
|
2190
|
+
keeps: 40,
|
|
2191
|
+
"extra-props": {
|
|
2192
|
+
currentSelect: o.currentSelect,
|
|
2193
|
+
nodeClick: n.nodeClick,
|
|
2194
|
+
showStatus: t.showStatus,
|
|
2195
|
+
filterEquip: t.filterEquip,
|
|
2196
|
+
showSettings: t.showSettings,
|
|
2197
|
+
showCheckbox: t.showCheckbox,
|
|
2198
|
+
onChecked: n.onChecked,
|
|
2199
|
+
showOperate: t.showOperate,
|
|
2200
|
+
groupEditAndNew: n.groupEditAndNew,
|
|
2201
|
+
deleteGroup: n.deleteGroup,
|
|
2202
|
+
colorConfig: t.colorConfig,
|
|
2203
|
+
childrenResetGroupNum: n.childrenResetGroupNum,
|
|
2204
|
+
getEquipStatus: n.getEquipStatus
|
|
2205
|
+
}
|
|
2206
|
+
}, null, 8, ["data-sources", "data-component", "extra-props"])
|
|
2207
|
+
])
|
|
2208
|
+
]);
|
|
2209
|
+
}
|
|
2210
|
+
const kt = /* @__PURE__ */ V(bt, [["render", qt]]);
|
|
2211
|
+
class Nt {
|
|
2212
|
+
constructor() {
|
|
2213
|
+
this.alreadyUpdate = {}, this.notify = null, this.window = window;
|
|
2214
|
+
try {
|
|
2215
|
+
window.top.equipGroup, this.window = window.top;
|
|
2216
|
+
} catch {
|
|
2217
|
+
this.window = window;
|
|
2218
|
+
}
|
|
2219
|
+
this.eGroupNotify = new ke({
|
|
2220
|
+
url: qe(),
|
|
2221
|
+
hub: "eGroupNotify",
|
|
2222
|
+
userName: sessionStorage.userName,
|
|
2223
|
+
autoConnect: !1
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
stop() {
|
|
2227
|
+
this.notify && this.notify.disconnect(), this.eGroupNotify && this.eGroupNotify.destroy();
|
|
2228
|
+
}
|
|
2229
|
+
Init() {
|
|
2230
|
+
this._initSocketIO();
|
|
2231
|
+
}
|
|
2232
|
+
// ★ java 版:SocketIOManager 连接流程
|
|
2233
|
+
_initSocketIO() {
|
|
2234
|
+
this.eGroupNotify.connect().then((e) => {
|
|
2235
|
+
this.notify = e;
|
|
2236
|
+
try {
|
|
2237
|
+
this.eGroupNotify.invoke("GetEquipGroupTree", {}), this.eGroupNotify.invoke("GetAllEquipGroupTree", {}), this.eGroupNotify.invoke("GetGroupEquips", {});
|
|
2238
|
+
} catch (t) {
|
|
2239
|
+
console.log(t);
|
|
2240
|
+
}
|
|
2241
|
+
this.subscribeTo(this.eGroupNotify, "GetEquipGroupTree"), this.subscribeTo(this.eGroupNotify, "AddEquipGroup"), this.subscribeTo(this.eGroupNotify, "EditEquipGroup"), this.subscribeTo(this.eGroupNotify, "DeleteEquipGroup"), this.subscribeTo(this.eGroupNotify, "GetGroupEquips"), this.subscribeTo(this.eGroupNotify, "AddEquip"), this.subscribeTo(this.eGroupNotify, "DeleteEquip"), this.subscribeTo(this.eGroupNotify, "EditEquip"), this.subscribeTo(this.eGroupNotify, "MoveEquips"), this.subscribeTo(this.eGroupNotify, "CopyEquips"), this.subscribeTo(this.eGroupNotify, "GetAllEquipGroupTree");
|
|
2242
|
+
}).catch((e) => {
|
|
2243
|
+
console.error(e);
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
// ★ net 版:SignalRManager 连接流程
|
|
2247
|
+
_initSignalR() {
|
|
2248
|
+
this.eGroupNotify.connect().then((e) => {
|
|
2249
|
+
try {
|
|
2250
|
+
e.invoke("GetEquipGroupTree"), e.invoke("GetAllEquipGroupTree"), e.invoke("GetGroupEquips");
|
|
2251
|
+
} catch (t) {
|
|
2252
|
+
console.log(t);
|
|
2253
|
+
}
|
|
2254
|
+
this.subscribeTo(this.eGroupNotify, "GetEquipGroupTree"), this.subscribeTo(this.eGroupNotify, "AddEquipGroup"), this.subscribeTo(this.eGroupNotify, "EditEquipGroup"), this.subscribeTo(this.eGroupNotify, "DeleteEquipGroup"), this.subscribeTo(this.eGroupNotify, "GetGroupEquips"), this.subscribeTo(this.eGroupNotify, "AddEquip"), this.subscribeTo(this.eGroupNotify, "DeleteEquip"), this.subscribeTo(this.eGroupNotify, "EditEquip"), this.subscribeTo(this.eGroupNotify, "MoveEquips"), this.subscribeTo(this.eGroupNotify, "CopyEquips"), this.subscribeTo(this.eGroupNotify, "GetAllEquipGroupTree");
|
|
2255
|
+
}).catch((e) => {
|
|
2256
|
+
console.error(e);
|
|
2257
|
+
});
|
|
2258
|
+
}
|
|
2259
|
+
// ★ subscribeTo 根据 backendType 区分解包逻辑
|
|
2260
|
+
subscribeTo(e, t) {
|
|
2261
|
+
e.off(t), e.on(t, (i) => {
|
|
2262
|
+
{
|
|
2263
|
+
const o = i == null ? void 0 : i.data;
|
|
2264
|
+
o && o.isSuccess && (this[t] ? this[t](o.data) : this.notice({ func: t, data: o.data, key: o.groupId }));
|
|
2265
|
+
}
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
// 获取分组---无权限管理的分组列表--空设备分组不展示
|
|
2269
|
+
GetEquipGroupTree(e) {
|
|
2270
|
+
this.window.groupList || (this.window.groupList = e, this.notice({ type: "GetEquipGroupTree" }));
|
|
2271
|
+
}
|
|
2272
|
+
// 获取全量分组---设备管理使用
|
|
2273
|
+
GetAllEquipGroupTree(e) {
|
|
2274
|
+
this.window.groupList_manageMent || (this.window.groupList_manageMent = e, this.notice({ type: "GetEquipGroupTreeWidthTreeType" }));
|
|
2275
|
+
}
|
|
2276
|
+
// 新增分组
|
|
2277
|
+
AddEquipGroup(e) {
|
|
2278
|
+
const { parentGroupId: t, groupId: i, groupName: o } = e || {};
|
|
2279
|
+
i && (this.window.groupList_manageMent || (this.window.groupList_manageMent = []), this.window.groupList_manageMent.push({
|
|
2280
|
+
parentId: t,
|
|
2281
|
+
id: i,
|
|
2282
|
+
name: o,
|
|
2283
|
+
equipCount: 0
|
|
2284
|
+
}), this.notice({ type: "AddEquipGroup", data: e }));
|
|
2285
|
+
}
|
|
2286
|
+
// 编辑分组
|
|
2287
|
+
EditEquipGroup(e) {
|
|
2288
|
+
const { groupId: t, groupName: i } = e;
|
|
2289
|
+
this.window.groupList && window.groupList.forEach((o) => {
|
|
2290
|
+
o.id == t && (o.name = i);
|
|
2291
|
+
}), this.window.groupList_manageMent && window.groupList_manageMent.forEach((o) => {
|
|
2292
|
+
o.id == t && (o.name = i);
|
|
2293
|
+
}), this.notice({ type: "EditEquipGroup", data: e });
|
|
2294
|
+
}
|
|
2295
|
+
deleteChildGroup(e, t) {
|
|
2296
|
+
let i = [];
|
|
2297
|
+
t.forEach((o) => {
|
|
2298
|
+
o.parentId == e && i.push(o.id);
|
|
2299
|
+
}), i.forEach((o) => {
|
|
2300
|
+
let n = t.findIndex((a) => a.id == o);
|
|
2301
|
+
n > -1 && t.splice(n, 1), this.deleteChildGroup(o, t);
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
// 删除分组
|
|
2305
|
+
DeleteEquipGroup(e) {
|
|
2306
|
+
e.forEach((t) => {
|
|
2307
|
+
if (this.window.groupList) {
|
|
2308
|
+
let i = this.window.groupList.findIndex((o) => o.id == t.groupId);
|
|
2309
|
+
i > -1 && this.window.groupList.splice(i, 1), this.deleteChildGroup(t.groupId, this.window.groupList);
|
|
2310
|
+
}
|
|
2311
|
+
if (this.window.groupList_manageMent) {
|
|
2312
|
+
let i = this.window.groupList_manageMent.findIndex((o) => o.id == t.groupId);
|
|
2313
|
+
i > -1 && this.window.groupList_manageMent.splice(i, 1), this.deleteChildGroup(t.groupId, this.window.groupList_manageMent);
|
|
2314
|
+
}
|
|
2315
|
+
}), this.notice({ type: "DeleteEquipGroup", data: e });
|
|
2316
|
+
}
|
|
2317
|
+
// 获取设备
|
|
2318
|
+
GetGroupEquips(e) {
|
|
2319
|
+
const { groupId: t, equips: i } = e || {};
|
|
2320
|
+
this.alreadyUpdate[t] || (this.window.groupCache || (this.window.groupCache = {}), this.window.groupCache[t] = {}, t && i && i instanceof Array && (i.forEach((o) => {
|
|
2321
|
+
o.title = o.name, o.groupId = t, o.equipNo = o.id, this.window.equipCache || (this.window.equipCache = {}), this.window.equipCache[o.id] = o, this.window.groupCache[t][o.id] = o;
|
|
2322
|
+
}), this.window[`group-${t}`] = i, this.notice({ type: "GetGroupEquips", data: { groupId: t } }), this.alreadyUpdate[t] = !0));
|
|
2323
|
+
}
|
|
2324
|
+
// 新增设备
|
|
2325
|
+
AddEquip(e) {
|
|
2326
|
+
const { groupId: t, equips: i } = e || {};
|
|
2327
|
+
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 = {});
|
|
2328
|
+
let o = this.window[`group-${t}`].length;
|
|
2329
|
+
if (t && i) {
|
|
2330
|
+
if (i.forEach((n, a) => {
|
|
2331
|
+
this.window[`group-${t}`].push(
|
|
2332
|
+
{
|
|
2333
|
+
equipNo: n.id,
|
|
2334
|
+
groupId: t,
|
|
2335
|
+
id: n.id,
|
|
2336
|
+
title: n.name
|
|
2337
|
+
}
|
|
2338
|
+
), this.window.equipCache[n.id] = this.window[`group-${t}`][o + a], this.window.groupCache[t][n.id] = this.window[`group-${t}`][o + a];
|
|
2339
|
+
}), !this.exist(t, this.window.groupList)) {
|
|
2340
|
+
let n = this.findParentList(t, this.window.groupList_manageMent);
|
|
2341
|
+
this.window.groupList.push(...n);
|
|
2342
|
+
}
|
|
2343
|
+
this.notice({ type: "AddEquip", data: e });
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
MoveEquips(e) {
|
|
2347
|
+
let t = [], i = !0, o = [];
|
|
2348
|
+
const { sourceGroup: n, targetGroupId: a } = e || {};
|
|
2349
|
+
a && t.push(a), n.forEach((r) => {
|
|
2350
|
+
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((u) => {
|
|
2351
|
+
if (!u.name && this.window.equipCache && this.window.equipCache[u.id] && (u.name = this.window.equipCache[u.id].title || this.window.equipCache[u.id].name), u.title = u.name || "", u.groupId = a, u.equipNo = u.id, this.window[`group-${r.groupId}`]) {
|
|
2352
|
+
let h = this.window[`group-${r.groupId}`].findIndex((c) => c.id == u.id);
|
|
2353
|
+
h > -1 && this.window[`group-${r.groupId}`].splice(h, 1);
|
|
2354
|
+
}
|
|
2355
|
+
this.window.equipCache || (this.window.equipCache = {}), this.window.equipCache[u.id] = u, this.window.groupCache[a][u.id] = u, this.window[`group-${a}`].push(u);
|
|
2356
|
+
}), !this.window[`group-${r.groupId}`].length) {
|
|
2357
|
+
let u = this.window.groupList.findIndex((h) => h.id == r.groupId);
|
|
2358
|
+
u > -1 && this.window.groupList.splice(u, 1), this.deleteChildGroup(r.groupId, this.window.groupList);
|
|
2359
|
+
}
|
|
2360
|
+
}), o.forEach((r) => {
|
|
2361
|
+
if (!this.exist(r, this.window.groupList)) {
|
|
2362
|
+
let u = this.findParentList(r, this.window.groupList_manageMent);
|
|
2363
|
+
this.window.groupList.push(...u);
|
|
2364
|
+
}
|
|
2365
|
+
}), this.notice({ type: "MoveEquips", data: { updateGroups: t, buildTree: i } });
|
|
2366
|
+
}
|
|
2367
|
+
// 复制设备(纯复制,不删除源设备)
|
|
2368
|
+
CopyEquips(e) {
|
|
2369
|
+
const { targetGroupId: t, equips: i } = e || {};
|
|
2370
|
+
if (!t || !i || !Array.isArray(i)) {
|
|
2371
|
+
console.warn("CopyEquips: 无效的数据格式", e);
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
let o = [t], n = [];
|
|
2375
|
+
this.window[`group-${t}`] || (this.window[`group-${t}`] = [], n.push(t)), this.window.groupCache || (this.window.groupCache = {}), this.window.groupCache[t] || (this.window.groupCache[t] = {}), this.window.equipCache || (this.window.equipCache = {}), i.forEach((a) => {
|
|
2376
|
+
!a.name && this.window.equipCache && this.window.equipCache[a.id] && (a.name = this.window.equipCache[a.id].title || this.window.equipCache[a.id].name);
|
|
2377
|
+
const r = {
|
|
2378
|
+
id: a.id,
|
|
2379
|
+
equipNo: a.id,
|
|
2380
|
+
groupId: t,
|
|
2381
|
+
title: a.name || "",
|
|
2382
|
+
name: a.name || ""
|
|
2383
|
+
};
|
|
2384
|
+
this.window.equipCache[a.id] = r, this.window.groupCache[t][a.id] = r, this.window[`group-${t}`].push(r);
|
|
2385
|
+
}), n.forEach((a) => {
|
|
2386
|
+
if (!this.exist(a, this.window.groupList)) {
|
|
2387
|
+
let r = this.findParentList(a, this.window.groupList_manageMent);
|
|
2388
|
+
this.window.groupList.push(...r);
|
|
2389
|
+
}
|
|
2390
|
+
}), this.notice({
|
|
2391
|
+
type: "MoveEquips",
|
|
2392
|
+
data: {
|
|
2393
|
+
updateGroups: o,
|
|
2394
|
+
buildTree: !1,
|
|
2395
|
+
targetGroupId: t,
|
|
2396
|
+
equipCount: i.length
|
|
2397
|
+
}
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2400
|
+
exist(e, t) {
|
|
2401
|
+
return t ? t.some((i) => i.id == e) : !1;
|
|
2402
|
+
}
|
|
2403
|
+
findParentList(e, t) {
|
|
2404
|
+
let i = [];
|
|
2405
|
+
if (t) {
|
|
2406
|
+
let o = t.findIndex((n) => n.id == e);
|
|
2407
|
+
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));
|
|
2408
|
+
}
|
|
2409
|
+
return i;
|
|
2410
|
+
}
|
|
2411
|
+
// 删除设备
|
|
2412
|
+
DeleteEquip(e) {
|
|
2413
|
+
const { groupId: t, equips: i } = e || {};
|
|
2414
|
+
if (t && i && i instanceof Array) {
|
|
2415
|
+
if (this.window[`group-${t}`])
|
|
2416
|
+
for (let o = 0, n = i.length; o < n; o++) {
|
|
2417
|
+
let a = this.window[`group-${t}`].findIndex((r) => r.id == i[o].id);
|
|
2418
|
+
a > -1 && this.window[`group-${t}`].splice(a, 1), delete this.window.equipCache[i[o].id], delete this.window.groupCache[t][i[o].id];
|
|
2419
|
+
}
|
|
2420
|
+
this.notice({ type: "DeleteEquip", data: e });
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
// 编辑设备
|
|
2424
|
+
EditEquip(e) {
|
|
2425
|
+
const { equipNo: t, groupId: i, equipName: o } = e || {};
|
|
2426
|
+
i && t && (window[`group-${i}`] && (this.window.equipCache[t] = o), this.notice({ type: "EditEquip", data: e }));
|
|
2427
|
+
}
|
|
2428
|
+
notice(e) {
|
|
2429
|
+
if (this.window.hasIframe) {
|
|
2430
|
+
let t = document.getElementsByTagName("iframe");
|
|
2431
|
+
for (let i of t)
|
|
2432
|
+
i.contentWindow.postMessage(e);
|
|
2433
|
+
} else
|
|
2434
|
+
window.postMessage(e, "*");
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
const Et = {
|
|
2438
|
+
name: "treeV2",
|
|
2439
|
+
components: {
|
|
2440
|
+
tree: kt
|
|
2441
|
+
},
|
|
2442
|
+
mixins: [ye],
|
|
2443
|
+
data() {
|
|
2444
|
+
return {
|
|
2445
|
+
list: [],
|
|
2446
|
+
refId: O.generateUUID(),
|
|
2447
|
+
treeKey: null,
|
|
2448
|
+
listKey: null,
|
|
2449
|
+
hasBuildTree: !1
|
|
2450
|
+
};
|
|
2451
|
+
},
|
|
2452
|
+
props: {
|
|
2453
|
+
treeType: {
|
|
2454
|
+
type: String,
|
|
2455
|
+
default: ""
|
|
2456
|
+
}
|
|
2457
|
+
},
|
|
2458
|
+
mounted() {
|
|
2459
|
+
this.treeKey = `equipGroup${this.treeType}`, this.listKey = `groupList${this.treeType}`, this.window[this.treeKey] ? this.list = O.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) => {
|
|
2460
|
+
s && s.data && s.data.type && this[s.data.type] && this[s.data.type](s.data.data);
|
|
2461
|
+
});
|
|
2462
|
+
try {
|
|
2463
|
+
this.window.hasIframe || this.selfRequest();
|
|
2464
|
+
} catch {
|
|
2465
|
+
this.selfRequest();
|
|
2466
|
+
}
|
|
2467
|
+
},
|
|
2468
|
+
methods: {
|
|
2469
|
+
selfRequest() {
|
|
2470
|
+
new Nt().Init();
|
|
2471
|
+
},
|
|
2472
|
+
GetEquipGroupTreeWidthTreeType() {
|
|
2473
|
+
this.treeType && this.window[this.listKey] && this.buildTree();
|
|
2474
|
+
},
|
|
2475
|
+
GetEquipGroupTree() {
|
|
2476
|
+
!this.treeType && this.window[this.listKey] && this.buildTree();
|
|
2477
|
+
},
|
|
2478
|
+
AddEquip(s) {
|
|
2479
|
+
const { groupId: e } = s || {};
|
|
2480
|
+
this.window[this.listKey] && (!e || !this.$refs[this.refId] || !this.$refs[this.refId].groupNodeObject[e]) && this.buildTree();
|
|
2481
|
+
},
|
|
2482
|
+
buildTree() {
|
|
2483
|
+
if (this.window[this.listKey]) {
|
|
2484
|
+
let s = O.listToTreeList(JSON.parse(JSON.stringify(this.window[this.listKey])));
|
|
2485
|
+
this.list = O.formateList(JSON.parse(JSON.stringify(s))), this.window[`equipGroup${this.treeType}`] = s, this.hasBuildTree = !0;
|
|
2486
|
+
}
|
|
2487
|
+
},
|
|
2488
|
+
filterMethod(s) {
|
|
2489
|
+
this.$refs[this.refId].filterMethod(s);
|
|
2490
|
+
},
|
|
2491
|
+
resetCheckedStatus() {
|
|
2492
|
+
this.$refs[this.refId].resetCheckedStatus();
|
|
2493
|
+
},
|
|
2494
|
+
getEquipSelectd() {
|
|
2495
|
+
return this.$refs[this.refId].getEquipSelectd();
|
|
2496
|
+
},
|
|
2497
|
+
getEquipGroupSelectd() {
|
|
2498
|
+
return this.$refs[this.refId].getEquipGroupSelectd();
|
|
2499
|
+
},
|
|
2500
|
+
getControlSelected() {
|
|
2501
|
+
return this.$refs[this.refId].getControlSelected();
|
|
2502
|
+
},
|
|
2503
|
+
destroyTree() {
|
|
2504
|
+
this.$refs[this.refId].destroyTree();
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
function Ot(s, e, t, i, o, n) {
|
|
2509
|
+
const a = I("tree");
|
|
2510
|
+
return m(), K(a, _e({
|
|
2511
|
+
ref: o.refId,
|
|
2512
|
+
data: o.list
|
|
2513
|
+
}, { ...s.$attrs, ...s.$props }, Le(s.$listeners), { buildTree: n.buildTree }), null, 16, ["data", "buildTree"]);
|
|
2514
|
+
}
|
|
2515
|
+
const se = /* @__PURE__ */ V(Et, [["render", Ot]]);
|
|
2516
|
+
se.install = function(s) {
|
|
2517
|
+
s.component(se.name, se);
|
|
2518
|
+
};
|
|
2519
|
+
export {
|
|
2520
|
+
se as default
|
|
2521
|
+
};
|