@ganwei-web/gw-base-components-plus 1.0.29 → 1.0.31

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.
@@ -1,12 +1,12 @@
1
- import * as w from "@aspnet/signalr";
2
- class a {
3
- constructor(o, i, t) {
4
- this.url = o, this.connectionId = i, this.equipNo = t, this.signalr = null;
1
+ import * as a from "@aspnet/signalr";
2
+ class d {
3
+ constructor(e, i, t) {
4
+ this.url = e, this.connectionId = i, this.equipNo = t, this.signalr = null;
5
5
  }
6
6
  openConnect() {
7
- return this.signalr && (this.signalr.stop(), this.signalr = null), this.signalr = new w.HubConnectionBuilder().withUrl(this.url).build(), this.signalr.serverTimeoutInMilliseconds = 5e8, this.signalr.keepaliveintervalinmilliseconds = 5e8, new Promise((o) => {
7
+ return this.signalr && (this.signalr.stop(), this.signalr = null), this.signalr = new a.HubConnectionBuilder().withUrl(this.url).build(), this.signalr.serverTimeoutInMilliseconds = 5e8, this.signalr.keepaliveintervalinmilliseconds = 5e8, new Promise((e) => {
8
8
  this.signalr.start().then(() => {
9
- this.connectionId && this.send(), o(this.signalr);
9
+ this.connectionId && this.send(), e(this.signalr);
10
10
  }).catch((i) => {
11
11
  console.log(i);
12
12
  });
@@ -15,38 +15,38 @@ class a {
15
15
  async send() {
16
16
  try {
17
17
  await this.signalr.invoke(this.connectionId, this.equipNo);
18
- } catch (o) {
19
- console.log("connectHub 连接失败" + o);
18
+ } catch (e) {
19
+ console.log("connectHub 连接失败" + e);
20
20
  }
21
21
  }
22
22
  }
23
23
  class c {
24
24
  constructor() {
25
- this.eGroupNotify = new a("/eGroupNotify", "", ""), this.alreadyUpdate = {}, this.notify = null, window = window;
25
+ this.eGroupNotify = new d("/eGroupNotify", "", ""), this.alreadyUpdate = {}, this.notify = null, this.winRef = window;
26
26
  try {
27
- window.top.equipGroup, window = window.top;
27
+ window.top.equipGroup, this.winRef = window.top;
28
28
  } catch {
29
- window = window;
29
+ this.winRef = window;
30
30
  }
31
31
  }
32
32
  stop() {
33
33
  this.notify && this.notify.stop();
34
34
  }
35
35
  Init() {
36
- this.eGroupNotify.openConnect().then((o) => {
37
- this.notify = o;
36
+ this.eGroupNotify.openConnect().then((e) => {
37
+ this.notify = e;
38
38
  try {
39
- o.invoke("GetEquipGroupTree"), o.invoke("GetAllEquipGroupTree");
39
+ e.invoke("GetEquipGroupTree"), e.invoke("GetAllEquipGroupTree");
40
40
  } catch (i) {
41
41
  console.log(i);
42
42
  }
43
- this.subscribeTo(o, "GetEquipGroupTree"), this.subscribeTo(o, "AddEquipGroup"), this.subscribeTo(o, "EditEquipGroup"), this.subscribeTo(o, "DeleteEquipGroup");
43
+ this.subscribeTo(e, "GetEquipGroupTree"), this.subscribeTo(e, "AddEquipGroup"), this.subscribeTo(e, "EditEquipGroup"), this.subscribeTo(e, "DeleteEquipGroup");
44
44
  try {
45
- o.invoke("GetGroupEquips");
45
+ e.invoke("GetGroupEquips");
46
46
  } catch (i) {
47
47
  console.log(i);
48
48
  }
49
- this.subscribeTo(o, "GetGroupEquips"), this.subscribeTo(o, "AddEquip"), this.subscribeTo(o, "DeleteEquip"), this.subscribeTo(o, "EditEquip"), this.subscribeTo(o, "moveEquips"), this.subscribeTo(o, "CopyEquips"), this.subscribeTo(o, "GetAllEquipGroupTree"), o.onclose((i) => {
49
+ this.subscribeTo(e, "GetGroupEquips"), this.subscribeTo(e, "AddEquip"), this.subscribeTo(e, "DeleteEquip"), this.subscribeTo(e, "EditEquip"), this.subscribeTo(e, "moveEquips"), this.subscribeTo(e, "CopyEquips"), this.subscribeTo(e, "GetAllEquipGroupTree"), e.onclose((i) => {
50
50
  try {
51
51
  this.Init();
52
52
  } catch (t) {
@@ -54,187 +54,186 @@ class c {
54
54
  }
55
55
  console.log("重连", i);
56
56
  });
57
- }).catch((o) => {
58
- console.error(o);
57
+ }).catch((e) => {
58
+ console.error(e);
59
59
  });
60
60
  }
61
- subscribeTo(o, i) {
62
- o.off(i), o.on(i, (t) => {
61
+ subscribeTo(e, i) {
62
+ e.off(i), e.on(i, (t) => {
63
63
  t && t.isSuccess && (this[i] ? this[i](t.data) : this.notice({ func: i, data: t.data, key: t.groupId }));
64
64
  });
65
65
  }
66
66
  // 获取分组---无权限管理的分组列表--空设备分组不展示
67
- GetEquipGroupTree(o) {
68
- window.groupList || (window.groupList = o, this.notice({ type: "GetEquipGroupTree" }));
67
+ GetEquipGroupTree(e) {
68
+ this.winRef.groupList || (this.winRef.groupList = e, this.notice({ type: "GetEquipGroupTree" }));
69
69
  }
70
70
  // 获取全量分组---设备管理使用
71
- GetAllEquipGroupTree(o) {
72
- window.groupList_manageMent || (window.groupList_manageMent = o, this.notice({ type: "GetEquipGroupTreeWidthTreeType" }));
71
+ GetAllEquipGroupTree(e) {
72
+ this.winRef.groupList_manageMent || (this.winRef.groupList_manageMent = e, this.notice({ type: "GetEquipGroupTreeWidthTreeType" }));
73
73
  }
74
74
  // 新增分组
75
- AddEquipGroup(o) {
76
- const { parentGroupId: i, groupId: t, groupName: e } = o || {};
77
- t && (window.groupList_manageMent || (window.groupList_manageMent = []), window.groupList_manageMent.push({
75
+ AddEquipGroup(e) {
76
+ const { parentGroupId: i, groupId: t, groupName: s } = e || {};
77
+ t && (this.winRef.groupList_manageMent || (this.winRef.groupList_manageMent = []), this.winRef.groupList_manageMent.push({
78
78
  parentId: i,
79
79
  id: t,
80
- name: e,
80
+ name: s,
81
81
  equipCount: 0
82
- }), this.notice({ type: "AddEquipGroup", data: o }));
82
+ }), this.notice({ type: "AddEquipGroup", data: e }));
83
83
  }
84
84
  // 编辑分组
85
- EditEquipGroup(o) {
86
- const { groupId: i, groupName: t } = o;
87
- window.groupList && window.groupList.forEach((e) => {
88
- e.id == i && (e.name = t);
89
- }), window.groupList_manageMent && window.groupList_manageMent.forEach((e) => {
90
- e.id == i && (e.name = t);
91
- }), this.notice({ type: "EditEquipGroup", data: o });
92
- }
93
- deleteChildGroup(o, i) {
85
+ EditEquipGroup(e) {
86
+ const { groupId: i, groupName: t } = e;
87
+ this.winRef.groupList && this.winRef.groupList.forEach((s) => {
88
+ s.id == i && (s.name = t);
89
+ }), this.winRef.groupList_manageMent && this.winRef.groupList_manageMent.forEach((s) => {
90
+ s.id == i && (s.name = t);
91
+ }), this.notice({ type: "EditEquipGroup", data: e });
92
+ }
93
+ deleteChildGroup(e, i) {
94
94
  let t = [];
95
- i.forEach((e) => {
96
- e.parentId == o && t.push(e.id);
97
- }), t.forEach((e) => {
98
- let n = i.findIndex((s) => s.id == e);
99
- n > -1 && i.splice(n, 1), this.deleteChildGroup(e, i);
95
+ i.forEach((s) => {
96
+ s.parentId == e && t.push(s.id);
97
+ }), t.forEach((s) => {
98
+ let o = i.findIndex((n) => n.id == s);
99
+ o > -1 && i.splice(o, 1), this.deleteChildGroup(s, i);
100
100
  });
101
101
  }
102
102
  // 删除分组
103
- DeleteEquipGroup(o) {
104
- o.forEach((i) => {
105
- if (window.groupList) {
106
- let t = window.groupList.findIndex((e) => e.id == i.groupId);
107
- t > -1 && window.groupList.splice(t, 1), this.deleteChildGroup(i.groupId, window.groupList);
103
+ DeleteEquipGroup(e) {
104
+ e.forEach((i) => {
105
+ if (this.winRef.groupList) {
106
+ let t = this.winRef.groupList.findIndex((s) => s.id == i.groupId);
107
+ t > -1 && this.winRef.groupList.splice(t, 1), this.deleteChildGroup(i.groupId, this.winRef.groupList);
108
108
  }
109
- if (window.groupList_manageMent) {
110
- let t = window.groupList_manageMent.findIndex((e) => e.id == i.groupId);
111
- t > -1 && window.groupList_manageMent.splice(t, 1), this.deleteChildGroup(i.groupId, window.groupList_manageMent);
109
+ if (this.winRef.groupList_manageMent) {
110
+ let t = this.winRef.groupList_manageMent.findIndex((s) => s.id == i.groupId);
111
+ t > -1 && this.winRef.groupList_manageMent.splice(t, 1), this.deleteChildGroup(i.groupId, this.winRef.groupList_manageMent);
112
112
  }
113
- }), this.notice({ type: "DeleteEquipGroup", data: o });
113
+ }), this.notice({ type: "DeleteEquipGroup", data: e });
114
114
  }
115
115
  // 获取设备
116
- GetGroupEquips(o) {
117
- const { groupId: i, equips: t } = o || {};
118
- this.alreadyUpdate[i] || (window.groupCache || (window.groupCache = {}), window.groupCache[i] = {}, i && t && t instanceof Array && (t.forEach((e) => {
119
- e.title = e.name, e.groupId = i, e.equipNo = e.id, delete e.name, window.equipCache || (window.equipCache = {}), window.equipCache[e.id] = e, window.groupCache[i][e.id] = e;
120
- }), window[`group-${i}`] = t, this.notice({ type: "GetGroupEquips", data: { groupId: i } }), this.alreadyUpdate[i] = !0));
116
+ GetGroupEquips(e) {
117
+ const { groupId: i, equips: t } = e || {};
118
+ this.alreadyUpdate[i] || (this.winRef.groupCache || (this.winRef.groupCache = {}), this.winRef.groupCache[i] = {}, i && t && t instanceof Array && (t.forEach((s) => {
119
+ s.title = s.name, s.groupId = i, s.equipNo = s.id, delete s.name, this.winRef.equipCache || (this.winRef.equipCache = {}), this.winRef.equipCache[s.id] = s, this.winRef.groupCache[i][s.id] = s;
120
+ }), this.winRef[`group-${i}`] = t, this.notice({ type: "GetGroupEquips", data: { groupId: i } }), this.alreadyUpdate[i] = !0));
121
121
  }
122
122
  // 新增设备
123
- AddEquip(o) {
124
- const { groupId: i, equips: t } = o || {};
125
- window[`group-${i}`] || (window[`group-${i}`] = []), window.groupCache || (window.groupCache = {}), window.groupCache[i] || (window.groupCache[i] = {}), window.equipCache || (window.equipCache = {});
126
- let e = window[`group-${i}`].length;
123
+ AddEquip(e) {
124
+ const { groupId: i, equips: t } = e || {};
125
+ this.winRef[`group-${i}`] || (this.winRef[`group-${i}`] = []), this.winRef.groupCache || (this.winRef.groupCache = {}), this.winRef.groupCache[i] || (this.winRef.groupCache[i] = {}), this.winRef.equipCache || (this.winRef.equipCache = {});
126
+ let s = this.winRef[`group-${i}`].length;
127
127
  if (i && t) {
128
- if (t.forEach((n, s) => {
129
- window[`group-${i}`].push(
128
+ if (t.forEach((o, n) => {
129
+ this.winRef[`group-${i}`].push(
130
130
  {
131
- equipNo: n.id,
131
+ equipNo: o.id,
132
132
  groupId: i,
133
- id: n.id,
134
- title: n.name
133
+ id: o.id,
134
+ title: o.name
135
135
  }
136
- ), window.equipCache[n.id] = window[`group-${i}`][e + s], window.groupCache[i][n.id] = window[`group-${i}`][e + s];
137
- }), !this.exist(i, window.groupList)) {
138
- let n = this.findParentList(i, window.groupList_manageMent);
139
- window.groupList.push(...n);
136
+ ), this.winRef.equipCache[o.id] = this.winRef[`group-${i}`][s + n], this.winRef.groupCache[i][o.id] = this.winRef[`group-${i}`][s + n];
137
+ }), !this.exist(i, this.winRef.groupList)) {
138
+ let o = this.findParentList(i, this.winRef.groupList_manageMent);
139
+ this.winRef.groupList.push(...o);
140
140
  }
141
- this.notice({ type: "AddEquip", data: o });
141
+ this.notice({ type: "AddEquip", data: e });
142
142
  }
143
143
  }
144
- CopyEquips(o) {
145
- const { targetGroupId: i, equips: t } = o || {};
144
+ CopyEquips(e) {
145
+ const { targetGroupId: i, equips: t } = e || {};
146
146
  if (!i || !t || !Array.isArray(t)) {
147
- console.warn("CopyEquips: 无效的数据格式", o);
147
+ console.warn("CopyEquips: 无效的数据格式", e);
148
148
  return;
149
149
  }
150
- let e = [i], n = [];
151
- window.top[`group-${i}`] || (window.top[`group-${i}`] = [], n.push(i)), window.top.groupCache || (window.top.groupCache = {}), window.top.groupCache[i] || (window.top.groupCache[i] = {}), window.top.equipCache || (window.top.equipCache = {}), t.forEach((s) => {
152
- !s.name && window.top.equipCache && window.top.equipCache[s.id] && (s.name = window.top.equipCache[s.id].title || window.top.equipCache[s.id].name);
153
- const p = {
154
- id: s.id,
150
+ let s = [i], o = [];
151
+ this.winRef[`group-${i}`] || (this.winRef[`group-${i}`] = [], o.push(i)), this.winRef.groupCache || (this.winRef.groupCache = {}), this.winRef.groupCache[i] || (this.winRef.groupCache[i] = {}), this.winRef.equipCache || (this.winRef.equipCache = {}), t.forEach((n) => {
152
+ !n.name && this.winRef.equipCache && this.winRef.equipCache[n.id] && (n.name = this.winRef.equipCache[n.id].title || this.winRef.equipCache[n.id].name);
153
+ const h = {
154
+ id: n.id,
155
155
  // 新设备的ID(后端生成)
156
- equipNo: s.id,
156
+ equipNo: n.id,
157
157
  groupId: i,
158
158
  // 目标分组ID
159
- title: s.name || "",
159
+ title: n.name || "",
160
160
  // 设备名称
161
- name: s.name || ""
161
+ name: n.name || ""
162
162
  // 保留name属性
163
163
  };
164
- window.top.equipCache[s.id] = p, window.top.groupCache[i][s.id] = p, window.top[`group-${i}`].push(p);
165
- }), n.forEach((s) => {
166
- if (!this.exist(s, window.top.groupList)) {
167
- let p = this.findParentList(s, window.top.groupList_manageMent);
168
- window.top.groupList.push(...p);
164
+ this.winRef.equipCache[n.id] = h, this.winRef.groupCache[i][n.id] = h, this.winRef[`group-${i}`].push(h);
165
+ }), o.forEach((n) => {
166
+ if (!this.exist(n, this.winRef.groupList)) {
167
+ let h = this.findParentList(n, this.winRef.groupList_manageMent);
168
+ this.winRef.groupList.push(...h);
169
169
  }
170
170
  }), this.notice({
171
171
  type: "moveEquips",
172
172
  data: {
173
- updateGroups: e,
173
+ updateGroups: s,
174
174
  buildTree: !1,
175
175
  targetGroupId: i,
176
176
  equipCount: t.length
177
177
  }
178
178
  });
179
179
  }
180
- moveEquips(o) {
181
- let i = [], t = !0, e = [];
182
- const { sourceGroup: n, targetGroupId: s } = o || {};
183
- s && i.push(s), n.forEach((p) => {
184
- if (i.push(p.groupId), (!window[`group-${s}`] || !window[`group-${s}`].length) && (window[`group-${s}`] = [], e.push(s)), window.groupCache || (window.groupCache = {}), window.groupCache[s] || (window.groupCache[s] = {}), p.equips.forEach((d) => {
185
- if (d.title = d.name, d.groupId = s, d.equipNo = d.id, window[`group-${p.groupId}`]) {
186
- let r = window[`group-${p.groupId}`].findIndex((u) => u.id == d.id);
187
- r > -1 && window[`group-${p.groupId}`].splice(r, 1);
180
+ moveEquips(e) {
181
+ let i = [], t = !0, s = [];
182
+ const { sourceGroup: o, targetGroupId: n } = e || {};
183
+ n && i.push(n), o.forEach((h) => {
184
+ if (i.push(h.groupId), (!this.winRef[`group-${n}`] || !this.winRef[`group-${n}`].length) && (this.winRef[`group-${n}`] = [], s.push(n)), this.winRef.groupCache || (this.winRef.groupCache = {}), this.winRef.groupCache[n] || (this.winRef.groupCache[n] = {}), h.equips.forEach((r) => {
185
+ if (r.title = r.name, r.groupId = n, r.equipNo = r.id, this.winRef[`group-${h.groupId}`]) {
186
+ let p = this.winRef[`group-${h.groupId}`].findIndex((f) => f.id == r.id);
187
+ p > -1 && this.winRef[`group-${h.groupId}`].splice(p, 1);
188
188
  }
189
- window.equipCache || (window.equipCache = {}), window.equipCache[d.id] = d, window.groupCache[s][d.id] = d, window[`group-${s}`].push(d);
190
- }), !window[`group-${p.groupId}`].length) {
191
- let d = window.groupList.findIndex((r) => r.id == p.groupId);
192
- d > -1 && window.groupList.splice(d, 1), this.deleteChildGroup(p.groupId, window.groupList);
189
+ this.winRef.equipCache || (this.winRef.equipCache = {}), this.winRef.equipCache[r.id] = r, this.winRef.groupCache[n][r.id] = r, this.winRef[`group-${n}`].push(r);
190
+ }), !this.winRef[`group-${h.groupId}`].length) {
191
+ let r = this.winRef.groupList.findIndex((p) => p.id == h.groupId);
192
+ r > -1 && this.winRef.groupList.splice(r, 1), this.deleteChildGroup(h.groupId, this.winRef.groupList);
193
193
  }
194
- }), e.forEach((p) => {
195
- if (!this.exist(p, window.groupList)) {
196
- let d = this.findParentList(p, window.groupList_manageMent);
197
- window.groupList.push(...d);
194
+ }), s.forEach((h) => {
195
+ if (!this.exist(h, this.winRef.groupList)) {
196
+ let r = this.findParentList(h, this.winRef.groupList_manageMent);
197
+ this.winRef.groupList.push(...r);
198
198
  }
199
199
  }), this.notice({ type: "moveEquips", data: { updateGroups: i, buildTree: t } });
200
200
  }
201
- exist(o, i) {
202
- return i ? i.some((t) => t.id == o) : !1;
201
+ exist(e, i) {
202
+ return i ? i.some((t) => t.id == e) : !1;
203
203
  }
204
- findParentList(o, i) {
204
+ findParentList(e, i) {
205
205
  let t = [];
206
206
  if (i) {
207
- let e = i.findIndex((n) => n.id == o);
208
- e > -1 && t.push({ ...i[e] }), i[e].parentId && !this.exist(i[e].parentId, window.groupList) && t.push(...this.findParentList(i[e].parentId, window.groupList_manageMent));
207
+ let s = i.findIndex((o) => o.id == e);
208
+ s > -1 && t.push({ ...i[s] }), i[s].parentId && !this.exist(i[s].parentId, this.winRef.groupList) && t.push(...this.findParentList(i[s].parentId, this.winRef.groupList_manageMent));
209
209
  }
210
210
  return t;
211
211
  }
212
212
  // 删除设备
213
- DeleteEquip(o) {
214
- const { groupId: i, equips: t } = o || {};
213
+ DeleteEquip(e) {
214
+ const { groupId: i, equips: t } = e || {};
215
215
  if (i && t && t instanceof Array) {
216
- if (window[`group-${i}`]) {
217
- for (let e = 0, n = t.length; e < n; e++) {
218
- let s = window[`group-${i}`].findIndex((p) => p.id == t[e].id);
219
- s > -1 && window[`group-${i}`].splice(s, 1), delete window.equipCache[t[e].id], delete window.groupCache[i][t[e].id];
220
- }
221
- }
222
- this.notice({ type: "DeleteEquip", data: o });
216
+ if (this.winRef[`group-${i}`]) {
217
+ for (let s = 0, o = t.length; s < o; s++) {
218
+ let n = this.winRef[`group-${i}`].findIndex((h) => h.id == t[s].id);
219
+ n > -1 && this.winRef[`group-${i}`].splice(n, 1), delete this.winRef.equipCache[t[s].id], delete this.winRef.groupCache[i][t[s].id];
220
+ }
221
+ }
222
+ this.notice({ type: "DeleteEquip", data: e });
223
223
  }
224
224
  }
225
225
  // 编辑设备
226
- EditEquip(o) {
227
- const { equipNo: i, groupId: t, equipName: e } = o || {};
228
- t && i && (window[`group-${t}`] && (window.equipCache[i] = e), this.notice({ type: "EditEquip", data: o }));
226
+ EditEquip(e) {
227
+ const { equipNo: i, groupId: t, equipName: s } = e || {};
228
+ t && i && (this.winRef[`group-${t}`] && (this.winRef.equipCache[i] = s), this.notice({ type: "EditEquip", data: e }));
229
229
  }
230
- notice(o) {
231
- if (window.hasIframe) {
230
+ notice(e) {
231
+ if (this.winRef.hasIframe) {
232
232
  let i = document.getElementsByTagName("iframe");
233
- for (let t of i) { t.contentWindow.postMessage(o); }
234
- } else { window.postMessage(o, "*"); }
233
+ for (let t of i) { t.contentWindow.postMessage(e); }
234
+ } else { this.winRef.postMessage(e, "*"); }
235
235
  }
236
236
  }
237
237
  export {
238
238
  c as equipCache,
239
- a as Signalr
240
- };
239
+ d as Signalr};
@@ -1 +1 @@
1
- (function (r, h) { typeof exports == "object" && typeof module < "u" ? h(exports, require("@aspnet/signalr")) : typeof define == "function" && define.amd ? define(["exports", "@aspnet/signalr"], h) : (r = typeof globalThis < "u" ? globalThis : r || self, h(r.index = {}, r.SignalR)) })(this, function (r, h) { "use strict"; function c(u) { const e = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } }); if (u) { for (const i in u) { if (i !== "default") { const o = Object.getOwnPropertyDescriptor(u, i); Object.defineProperty(e, i, o.get ? o : { enumerable: !0, get: () => u[i] }) } } } return e.default = u, Object.freeze(e) } const g = c(h); class a { constructor(e, i, o) { this.url = e, this.connectionId = i, this.equipNo = o, this.signalr = null } openConnect() { return this.signalr && (this.signalr.stop(), this.signalr = null), this.signalr = new g.HubConnectionBuilder().withUrl(this.url).build(), this.signalr.serverTimeoutInMilliseconds = 5e8, this.signalr.keepaliveintervalinmilliseconds = 5e8, new Promise(e => { this.signalr.start().then(() => { this.connectionId && this.send(), e(this.signalr) }).catch(i => { console.log(i) }) }) } async send() { try { await this.signalr.invoke(this.connectionId, this.equipNo) } catch (e) { console.log("connectHub 连接失败" + e) } } } class l { constructor() { this.eGroupNotify = new a("/eGroupNotify", "", ""), this.alreadyUpdate = {}, this.notify = null, window = window; try { window.top.equipGroup, window = window.top } catch { window = window } } stop() { this.notify && this.notify.stop() } Init() { this.eGroupNotify.openConnect().then(e => { this.notify = e; try { e.invoke("GetEquipGroupTree"), e.invoke("GetAllEquipGroupTree") } catch (i) { console.log(i) } this.subscribeTo(e, "GetEquipGroupTree"), this.subscribeTo(e, "AddEquipGroup"), this.subscribeTo(e, "EditEquipGroup"), this.subscribeTo(e, "DeleteEquipGroup"); try { e.invoke("GetGroupEquips") } catch (i) { console.log(i) } this.subscribeTo(e, "GetGroupEquips"), this.subscribeTo(e, "AddEquip"), this.subscribeTo(e, "DeleteEquip"), this.subscribeTo(e, "EditEquip"), this.subscribeTo(e, "moveEquips"), this.subscribeTo(e, "CopyEquips"), this.subscribeTo(e, "GetAllEquipGroupTree"), e.onclose(i => { try { this.Init() } catch (o) { console.log(o) } console.log("重连", i) }) }).catch(e => { console.error(e) }) } subscribeTo(e, i) { e.off(i), e.on(i, o => { o && o.isSuccess && (this[i] ? this[i](o.data) : this.notice({ func: i, data: o.data, key: o.groupId })) }) } GetEquipGroupTree(e) { window.groupList || (window.groupList = e, this.notice({ type: "GetEquipGroupTree" })) } GetAllEquipGroupTree(e) { window.groupList_manageMent || (window.groupList_manageMent = e, this.notice({ type: "GetEquipGroupTreeWidthTreeType" })) } AddEquipGroup(e) { const { parentGroupId: i, groupId: o, groupName: t } = e || {}; o && (window.groupList_manageMent || (window.groupList_manageMent = []), window.groupList_manageMent.push({ parentId: i, id: o, name: t, equipCount: 0 }), this.notice({ type: "AddEquipGroup", data: e })) } EditEquipGroup(e) { const { groupId: i, groupName: o } = e; window.groupList && window.groupList.forEach(t => { t.id == i && (t.name = o) }), window.groupList_manageMent && window.groupList_manageMent.forEach(t => { t.id == i && (t.name = o) }), this.notice({ type: "EditEquipGroup", data: e }) } deleteChildGroup(e, i) { let o = []; i.forEach(t => { t.parentId == e && o.push(t.id) }), o.forEach(t => { let s = i.findIndex(n => n.id == t); s > -1 && i.splice(s, 1), this.deleteChildGroup(t, i) }) } DeleteEquipGroup(e) { e.forEach(i => { if (window.groupList) { let o = window.groupList.findIndex(t => t.id == i.groupId); o > -1 && window.groupList.splice(o, 1), this.deleteChildGroup(i.groupId, window.groupList) } if (window.groupList_manageMent) { let o = window.groupList_manageMent.findIndex(t => t.id == i.groupId); o > -1 && window.groupList_manageMent.splice(o, 1), this.deleteChildGroup(i.groupId, window.groupList_manageMent) } }), this.notice({ type: "DeleteEquipGroup", data: e }) } GetGroupEquips(e) { const { groupId: i, equips: o } = e || {}; this.alreadyUpdate[i] || (window.groupCache || (window.groupCache = {}), window.groupCache[i] = {}, i && o && o instanceof Array && (o.forEach(t => { t.title = t.name, t.groupId = i, t.equipNo = t.id, delete t.name, window.equipCache || (window.equipCache = {}), window.equipCache[t.id] = t, window.groupCache[i][t.id] = t }), window[`group-${i}`] = o, this.notice({ type: "GetGroupEquips", data: { groupId: i } }), this.alreadyUpdate[i] = !0)) } AddEquip(e) { const { groupId: i, equips: o } = e || {}; window[`group-${i}`] || (window[`group-${i}`] = []), window.groupCache || (window.groupCache = {}), window.groupCache[i] || (window.groupCache[i] = {}), window.equipCache || (window.equipCache = {}); let t = window[`group-${i}`].length; if (i && o) { if (o.forEach((s, n) => { window[`group-${i}`].push({ equipNo: s.id, groupId: i, id: s.id, title: s.name }), window.equipCache[s.id] = window[`group-${i}`][t + n], window.groupCache[i][s.id] = window[`group-${i}`][t + n] }), !this.exist(i, window.groupList)) { let s = this.findParentList(i, window.groupList_manageMent); window.groupList.push(...s) } this.notice({ type: "AddEquip", data: e }) } } CopyEquips(e) { const { targetGroupId: i, equips: o } = e || {}; if (!i || !o || !Array.isArray(o)) { console.warn("CopyEquips: 无效的数据格式", e); return } let t = [i], s = []; window.top[`group-${i}`] || (window.top[`group-${i}`] = [], s.push(i)), window.top.groupCache || (window.top.groupCache = {}), window.top.groupCache[i] || (window.top.groupCache[i] = {}), window.top.equipCache || (window.top.equipCache = {}), o.forEach(n => { !n.name && window.top.equipCache && window.top.equipCache[n.id] && (n.name = window.top.equipCache[n.id].title || window.top.equipCache[n.id].name); const d = { id: n.id, equipNo: n.id, groupId: i, title: n.name || "", name: n.name || "" }; window.top.equipCache[n.id] = d, window.top.groupCache[i][n.id] = d, window.top[`group-${i}`].push(d) }), s.forEach(n => { if (!this.exist(n, window.top.groupList)) { let d = this.findParentList(n, window.top.groupList_manageMent); window.top.groupList.push(...d) } }), this.notice({ type: "moveEquips", data: { updateGroups: t, buildTree: !1, targetGroupId: i, equipCount: o.length } }) } moveEquips(e) { let i = [], o = !0, t = []; const { sourceGroup: s, targetGroupId: n } = e || {}; n && i.push(n), s.forEach(d => { if (i.push(d.groupId), (!window[`group-${n}`] || !window[`group-${n}`].length) && (window[`group-${n}`] = [], t.push(n)), window.groupCache || (window.groupCache = {}), window.groupCache[n] || (window.groupCache[n] = {}), d.equips.forEach(p => { if (p.title = p.name, p.groupId = n, p.equipNo = p.id, window[`group-${d.groupId}`]) { let w = window[`group-${d.groupId}`].findIndex(f => f.id == p.id); w > -1 && window[`group-${d.groupId}`].splice(w, 1) } window.equipCache || (window.equipCache = {}), window.equipCache[p.id] = p, window.groupCache[n][p.id] = p, window[`group-${n}`].push(p) }), !window[`group-${d.groupId}`].length) { let p = window.groupList.findIndex(w => w.id == d.groupId); p > -1 && window.groupList.splice(p, 1), this.deleteChildGroup(d.groupId, window.groupList) } }), t.forEach(d => { if (!this.exist(d, window.groupList)) { let p = this.findParentList(d, window.groupList_manageMent); window.groupList.push(...p) } }), this.notice({ type: "moveEquips", data: { updateGroups: i, buildTree: o } }) } exist(e, i) { return i ? i.some(o => o.id == e) : !1 } findParentList(e, i) { let o = []; if (i) { let t = i.findIndex(s => s.id == e); t > -1 && o.push({ ...i[t] }), i[t].parentId && !this.exist(i[t].parentId, window.groupList) && o.push(...this.findParentList(i[t].parentId, window.groupList_manageMent)) } return o } DeleteEquip(e) { const { groupId: i, equips: o } = e || {}; if (i && o && o instanceof Array) { if (window[`group-${i}`]) { for (let t = 0, s = o.length; t < s; t++) { let n = window[`group-${i}`].findIndex(d => d.id == o[t].id); n > -1 && window[`group-${i}`].splice(n, 1), delete window.equipCache[o[t].id], delete window.groupCache[i][o[t].id] } } this.notice({ type: "DeleteEquip", data: e }) } } EditEquip(e) { const { equipNo: i, groupId: o, equipName: t } = e || {}; o && i && (window[`group-${o}`] && (window.equipCache[i] = t), this.notice({ type: "EditEquip", data: e })) } notice(e) { if (window.hasIframe) { let i = document.getElementsByTagName("iframe"); for (let o of i) { o.contentWindow.postMessage(e) } } else { window.postMessage(e, "*") } } } r.Signalr = a, r.equipCache = l, Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }) });
1
+ (function(p, f){ typeof exports == "object" && typeof module < "u" ? f(exports, require("@aspnet/signalr")) : typeof define == "function" && define.amd ? define(["exports", "@aspnet/signalr"], f) : (p = typeof globalThis < "u" ? globalThis : p || self, f(p.index = {}, p.SignalR)) })(this, function(p, f){ "use strict";function c(u){ const e = Object.create(null, {[Symbol.toStringTag]: {value: "Module"}});if(u){ for(const i in u){ if(i !== "default"){ const t = Object.getOwnPropertyDescriptor(u, i);Object.defineProperty(e, i, t.get ? t : {enumerable: !0, get: ()=>u[i]}) } } }return e.default = u, Object.freeze(e) }const g = c(f);class d{constructor(e, i, t){ this.url = e, this.connectionId = i, this.equipNo = t, this.signalr = null }openConnect(){ return this.signalr && (this.signalr.stop(), this.signalr = null), this.signalr = new g.HubConnectionBuilder().withUrl(this.url).build(), this.signalr.serverTimeoutInMilliseconds = 5e8, this.signalr.keepaliveintervalinmilliseconds = 5e8, new Promise(e=>{ this.signalr.start().then(()=>{ this.connectionId && this.send(), e(this.signalr) }).catch(i=>{ console.log(i) }) }) }async send(){ try{ await this.signalr.invoke(this.connectionId, this.equipNo) }catch(e){ console.log("connectHub 连接失败" + e) } }}class l{constructor(){ this.eGroupNotify = new d("/eGroupNotify", "", ""), this.alreadyUpdate = {}, this.notify = null, this.winRef = window;try{ window.top.equipGroup, this.winRef = window.top }catch{ this.winRef = window } }stop(){ this.notify && this.notify.stop() }Init(){ this.eGroupNotify.openConnect().then(e=>{ this.notify = e;try{ e.invoke("GetEquipGroupTree"), e.invoke("GetAllEquipGroupTree") }catch(i){ console.log(i) }this.subscribeTo(e, "GetEquipGroupTree"), this.subscribeTo(e, "AddEquipGroup"), this.subscribeTo(e, "EditEquipGroup"), this.subscribeTo(e, "DeleteEquipGroup");try{ e.invoke("GetGroupEquips") }catch(i){ console.log(i) }this.subscribeTo(e, "GetGroupEquips"), this.subscribeTo(e, "AddEquip"), this.subscribeTo(e, "DeleteEquip"), this.subscribeTo(e, "EditEquip"), this.subscribeTo(e, "moveEquips"), this.subscribeTo(e, "CopyEquips"), this.subscribeTo(e, "GetAllEquipGroupTree"), e.onclose(i=>{ try{ this.Init() }catch(t){ console.log(t) }console.log("重连", i) }) }).catch(e=>{ console.error(e) }) }subscribeTo(e, i){ e.off(i), e.on(i, t=>{ t && t.isSuccess && (this[i] ? this[i](t.data) : this.notice({func: i, data: t.data, key: t.groupId})) }) }GetEquipGroupTree(e){ this.winRef.groupList || (this.winRef.groupList = e, this.notice({type: "GetEquipGroupTree"})) }GetAllEquipGroupTree(e){ this.winRef.groupList_manageMent || (this.winRef.groupList_manageMent = e, this.notice({type: "GetEquipGroupTreeWidthTreeType"})) }AddEquipGroup(e){ const{parentGroupId: i, groupId: t, groupName: s} = e || {};t && (this.winRef.groupList_manageMent || (this.winRef.groupList_manageMent = []), this.winRef.groupList_manageMent.push({parentId: i, id: t, name: s, equipCount: 0}), this.notice({type: "AddEquipGroup", data: e})) }EditEquipGroup(e){ const{groupId: i, groupName: t} = e;this.winRef.groupList && this.winRef.groupList.forEach(s=>{ s.id == i && (s.name = t) }), this.winRef.groupList_manageMent && this.winRef.groupList_manageMent.forEach(s=>{ s.id == i && (s.name = t) }), this.notice({type: "EditEquipGroup", data: e}) }deleteChildGroup(e, i){ let t = [];i.forEach(s=>{ s.parentId == e && t.push(s.id) }), t.forEach(s=>{ let o = i.findIndex(n=>n.id == s);o > -1 && i.splice(o, 1), this.deleteChildGroup(s, i) }) }DeleteEquipGroup(e){ e.forEach(i=>{ if(this.winRef.groupList){ let t = this.winRef.groupList.findIndex(s=>s.id == i.groupId);t > -1 && this.winRef.groupList.splice(t, 1), this.deleteChildGroup(i.groupId, this.winRef.groupList) }if(this.winRef.groupList_manageMent){ let t = this.winRef.groupList_manageMent.findIndex(s=>s.id == i.groupId);t > -1 && this.winRef.groupList_manageMent.splice(t, 1), this.deleteChildGroup(i.groupId, this.winRef.groupList_manageMent) } }), this.notice({type: "DeleteEquipGroup", data: e}) }GetGroupEquips(e){ const{groupId: i, equips: t} = e || {};this.alreadyUpdate[i] || (this.winRef.groupCache || (this.winRef.groupCache = {}), this.winRef.groupCache[i] = {}, i && t && t instanceof Array && (t.forEach(s=>{ s.title = s.name, s.groupId = i, s.equipNo = s.id, delete s.name, this.winRef.equipCache || (this.winRef.equipCache = {}), this.winRef.equipCache[s.id] = s, this.winRef.groupCache[i][s.id] = s }), this.winRef[`group-${i}`] = t, this.notice({type: "GetGroupEquips", data: {groupId: i}}), this.alreadyUpdate[i] = !0)) }AddEquip(e){ const{groupId: i, equips: t} = e || {};this.winRef[`group-${i}`] || (this.winRef[`group-${i}`] = []), this.winRef.groupCache || (this.winRef.groupCache = {}), this.winRef.groupCache[i] || (this.winRef.groupCache[i] = {}), this.winRef.equipCache || (this.winRef.equipCache = {});let s = this.winRef[`group-${i}`].length;if(i && t){ if(t.forEach((o, n)=>{ this.winRef[`group-${i}`].push({equipNo: o.id, groupId: i, id: o.id, title: o.name}), this.winRef.equipCache[o.id] = this.winRef[`group-${i}`][s + n], this.winRef.groupCache[i][o.id] = this.winRef[`group-${i}`][s + n] }), !this.exist(i, this.winRef.groupList)){ let o = this.findParentList(i, this.winRef.groupList_manageMent);this.winRef.groupList.push(...o) }this.notice({type: "AddEquip", data: e}) } }CopyEquips(e){ const{targetGroupId: i, equips: t} = e || {};if(!i || !t || !Array.isArray(t)){ console.warn("CopyEquips: 无效的数据格式", e);return }let s = [i], o = [];this.winRef[`group-${i}`] || (this.winRef[`group-${i}`] = [], o.push(i)), this.winRef.groupCache || (this.winRef.groupCache = {}), this.winRef.groupCache[i] || (this.winRef.groupCache[i] = {}), this.winRef.equipCache || (this.winRef.equipCache = {}), t.forEach(n=>{ !n.name && this.winRef.equipCache && this.winRef.equipCache[n.id] && (n.name = this.winRef.equipCache[n.id].title || this.winRef.equipCache[n.id].name);const h = {id: n.id, equipNo: n.id, groupId: i, title: n.name || "", name: n.name || ""};this.winRef.equipCache[n.id] = h, this.winRef.groupCache[i][n.id] = h, this.winRef[`group-${i}`].push(h) }), o.forEach(n=>{ if(!this.exist(n, this.winRef.groupList)){ let h = this.findParentList(n, this.winRef.groupList_manageMent);this.winRef.groupList.push(...h) } }), this.notice({type: "moveEquips", data: {updateGroups: s, buildTree: !1, targetGroupId: i, equipCount: t.length}}) }moveEquips(e){ let i = [], t = !0, s = [];const{sourceGroup: o, targetGroupId: n} = e || {};n && i.push(n), o.forEach(h=>{ if(i.push(h.groupId), (!this.winRef[`group-${n}`] || !this.winRef[`group-${n}`].length) && (this.winRef[`group-${n}`] = [], s.push(n)), this.winRef.groupCache || (this.winRef.groupCache = {}), this.winRef.groupCache[n] || (this.winRef.groupCache[n] = {}), h.equips.forEach(r=>{ if(r.title = r.name, r.groupId = n, r.equipNo = r.id, this.winRef[`group-${h.groupId}`]){ let a = this.winRef[`group-${h.groupId}`].findIndex(w=>w.id == r.id);a > -1 && this.winRef[`group-${h.groupId}`].splice(a, 1) }this.winRef.equipCache || (this.winRef.equipCache = {}), this.winRef.equipCache[r.id] = r, this.winRef.groupCache[n][r.id] = r, this.winRef[`group-${n}`].push(r) }), !this.winRef[`group-${h.groupId}`].length){ let r = this.winRef.groupList.findIndex(a=>a.id == h.groupId);r > -1 && this.winRef.groupList.splice(r, 1), this.deleteChildGroup(h.groupId, this.winRef.groupList) } }), s.forEach(h=>{ if(!this.exist(h, this.winRef.groupList)){ let r = this.findParentList(h, this.winRef.groupList_manageMent);this.winRef.groupList.push(...r) } }), this.notice({type: "moveEquips", data: {updateGroups: i, buildTree: t}}) }exist(e, i){ return i ? i.some(t=>t.id == e) : !1 }findParentList(e, i){ let t = [];if(i){ let s = i.findIndex(o=>o.id == e);s > -1 && t.push({...i[s]}), i[s].parentId && !this.exist(i[s].parentId, this.winRef.groupList) && t.push(...this.findParentList(i[s].parentId, this.winRef.groupList_manageMent)) }return t }DeleteEquip(e){ const{groupId: i, equips: t} = e || {};if(i && t && t instanceof Array){ if(this.winRef[`group-${i}`]){ for(let s = 0, o = t.length;s < o;s++){ let n = this.winRef[`group-${i}`].findIndex(h=>h.id == t[s].id);n > -1 && this.winRef[`group-${i}`].splice(n, 1), delete this.winRef.equipCache[t[s].id], delete this.winRef.groupCache[i][t[s].id] } }this.notice({type: "DeleteEquip", data: e}) } }EditEquip(e){ const{equipNo: i, groupId: t, equipName: s} = e || {};t && i && (this.winRef[`group-${t}`] && (this.winRef.equipCache[i] = s), this.notice({type: "EditEquip", data: e})) }notice(e){ if(this.winRef.hasIframe){ let i = document.getElementsByTagName("iframe");for(let t of i){ t.contentWindow.postMessage(e) } }else { this.winRef.postMessage(e, "*") } }}p.Signalr = d, p.equipCache = l, Object.defineProperty(p, Symbol.toStringTag, {value: "Module"}) });