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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ (function(l, f){ typeof exports == "object" && typeof module < "u" ? module.exports = f(require("vue3-virtual-scroll-list"), require("@aspnet/signalr"), require("vue")) : typeof define == "function" && define.amd ? define(["vue3-virtual-scroll-list", "@aspnet/signalr", "vue"], f) : (l = typeof globalThis < "u" ? globalThis : l || self, l.index = f(l.VirtualList, l.SignalR, l.Vue)) })(this, function(l, f, a){ "use strict";function S(s){ const e = Object.create(null, {[Symbol.toStringTag]: {value: "Module"}});if(s){ for(const t in s){ if(t !== "default"){ const i = Object.getOwnPropertyDescriptor(s, t);Object.defineProperty(e, t, i.get ? i : {enumerable: !0, get: ()=>s[t]}) } } }return e.default = s, Object.freeze(e) }const N = S(f), H = "";class E{constructor(e, t, i){ this.groupNodeObject = e, this.nodesMap = t, this.controlObject = i }addNodesMap(e){ e && e.forEach(t=>{ this.nodesMap[t.key] = t }) }removeNodesMap(e){ e && e.forEach(t=>{ delete this.nodesMap[t.key] }) }recycleAllNodeCache(e){ for(let t in this.groupNodeObject){ this.groupNodeObject[t].expand = !1, this.groupNodeObject[t].count = 0, this.recycleGroupCache(this.groupNodeObject[t].key), e && delete this.groupNodeObject[t] } }recycleGroupCache(e){ if(this.groupNodeObject[e]){ 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;for(let t in this.groupNodeObject){ this.groupNodeObject[t].groupId == e && this.recycleGroupCache(this.groupNodeObject[t].key) } } }closeBrotherNode(e){ if(e && this.groupNodeObject[e]){ let t = this.groupNodeObject[e].groupId;for(let i in this.groupNodeObject){ this.groupNodeObject[i].groupId == t && this.groupNodeObject[i].key != e && this.groupNodeObject[i].expand && (this.groupNodeObject[i].expand = !1, this.recycleGroupCache(this.groupNodeObject[i].key)) } } }}class g{constructor(){ this.window = window;try{ window.top.equipGroup, this.window = window.top }catch{ this.window = window } }}const q = {data(){ return{window: null} }, created(){ this.window = window;try{ window.top.equipGroup, this.window = window.top }catch{ this.window = window } }};class k extends g{constructor(e, t, i, o, u, h){ super(), this.equipControllObject = i, this.groupNodeObject = e, this.nodesMap = t, this.controlObject = o, this.equipCheckObject = u, this.isSearchStatus = !1, this.searchStatusGroupObject = {}, this.aliasName = h }resetCheckedStatus(){ Object.values(this.nodesMap).forEach(e=>{ this.setCheckStatus(e.key, !1, !1), e.isGroup && !e.isEquip && (this.clearCheckedEquips(e.key), this.updateEquipSelectCount(e.key, !0)), e.halfCheckedEquips && (e.halfCheckedEquips = []) }), Object.keys(this.equipCheckObject).forEach(e=>{ this.setEquipCheckObject(e, !1, !1, this.equipCheckObject[e].groupId) }) }reComputedCheckNum(e){ this.isSearchStatus = e, this.isSearchStatus ? (Object.values(this.groupNodeObject).forEach(t=>{ this.searchStatusGroupObject[t.key] = {groupId: t.groupId, equipSelectCount: t.equipSelectCount, halfCheckedEquips: t.halfCheckedEquips, ...this.searchStatusGroupObject[t.key]} }), Object.values(this.groupNodeObject).forEach(t=>{ this.updateEquipSelectCount(t.key, !0), t.halfCheckedEquips = [] }), Object.values(this.groupNodeObject).forEach(t=>{ (this.window[`group-${t.key}-search`] || []).forEach(o=>{ this.equipCheckObject[o.equipNo] && this.equipCheckObject[o.equipNo].checked ? this.updateEquipSelectCount(t.key, !1, 1) : this.equipCheckObject[o.equipNo] && this.equipCheckObject[o.equipNo].indeterminate && t.halfCheckedEquips.push(o.equipNo) }) })) : (Object.values(this.groupNodeObject).forEach(t=>{ let i = this.searchStatusGroupObject[t.key];i && (t.equipSelectCount = i.equipSelectCount, t.halfCheckedEquips = [...i.halfCheckedEquips, ...t.halfCheckedEquips], t.halfCheckedEquips = [...new Set(t.halfCheckedEquips)]) }), this.searchStatusGroupObject = {}) }updateCheckedStatusWithEquips(e){ window.setTimeout(()=>{ for(let t = 0, i = e.length;t < i;t++){ let o = this.window.equipCache && this.window.equipCache[e[t]];o && o.groupId && (this.setEquipCheckObject(e[t], !0, !1, o.groupId), this.setCheckStatus(`${o.groupId}-${e[t]}`, !0, !1), this.updateEquipSelectCount(o.groupId, !1, 1), this.updateExpandControlCheckStatus(o.groupId, e[t])) }this.updateGroupCheckStatus() }, 200) }updateExpandControlCheckStatus(e, t){ let i = this.nodesMap[`${e}-${t}`];i && i.settings && i.settings.length && i.settings.forEach(o=>{ this.nodesMap[`${e}-${t}-${o.setNo}`] && this.setCheckStatus(`${e}-${t}-${o.setNo}`, !0, !1) }) }updateCheckedStatusWithControls(e){ window.setTimeout(()=>{ for(let t = 0, i = e.length;t < i;t++){ let o = e[t].split("."), u = o[0], h = o[1];if(this.equipControllObject[u] || (this.equipControllObject[u] = []), this.equipControllObject[u].push(Number(h)), this.window.equipCache && this.window.equipCache[u]){ let c = this.window.equipCache[u].groupId, r = `${c}-${u}-${h}`;this.nodesMap[r] && this.setCheckStatus(r, !0, !1), this.nodesMap[`${c}-${u}`] && this.setCheckStatus(`${c}-${u}`, !1, !0), this.nodesMap[`${c}`].halfCheckedEquips && this.nodesMap[`${c}`].halfCheckedEquips.push(u), this.setEquipCheckObject(u, !1, !0, c) } }this.updateGroupCheckStatus() }, 100) }updateGroupCheckStatus(){ Object.values(this.groupNodeObject).forEach(e=>{ e.count > 0 && e.count == e.equipSelectCount ? this.setCheckStatus(e.key, !0, !1) : e.count && e.equipSelectCount && e.count > e.equipSelectCount || e.halfCheckedEquips.length ? this.setGroupHalfChecked(e.key) : this.setCheckStatus(e.key, !1, !1) }) }setGroupHalfChecked(e){ this.nodesMap[e] && this.setCheckStatus(e, !1, !0), this.nodesMap[e].groupId && this.setGroupHalfChecked(this.nodesMap[e].groupId) }setControlStatus(e, t, i, o){ e && e.forEach(u=>{ this.nodesMap[`${t}-${i}-${u.setNo}`] && this.setCheckStatus(`${t}-${i}-${u.setNo}`, o, !1) }) }updateControlCheckStatus(){ Object.keys(this.controlObject).forEach(e=>{ let t = this.nodesMap[`${this.controlObject[e].groupId}-${e}`];if(t){ if(t.checked){ let i = t.settings;this.setControlStatus(i, this.controlObject[e].groupId, e, !0) }else if(!t.checked && !t.indeterminate){ let i = t.settings;this.setControlStatus(i, this.controlObject[e].groupId, e, !1) }else { this.equipControllObject[e] && this.equipControllObject[e].forEach(i=>{ let o = `${this.controlObject[e].groupId}-${e}-${i}`;this.nodesMap[o] && this.setCheckStatus(o, !0, !1) }) } } }) }getGroupChecked(){ let e = [];return Object.keys(this.groupNodeObject).forEach(t=>{ this.groupNodeObject[t].checked && e.push(t) }), e }getEquipSelectd(){ let e = [];return Object.keys(this.equipCheckObject).forEach(t=>{ this.equipCheckObject[t].checked && e.push(Number(t)) }), e }getControlSelected(){ let e = [];return Object.keys(this.equipControllObject).forEach(t=>{ e.push(...this.equipControllObject[t].map(i=>`${t}.${i}`)) }), e }onChecked(e, t){ this.isSearchStatus = t || !1, e.isGroup && !e.isEquip ? this.selectGroup(e) : e.isEquip ? this.selectEquip(e) : e.isSetting && this.selectControl(e) }setCheckStatus(e, t, i){ this.nodesMap[e] && (this.nodesMap[e].checked = t, this.nodesMap[e].isGroup && (this.nodesMap[e].indeterminate = i)) }clearCheckedEquips(e){ this.groupNodeObject[e] && (this.groupNodeObject[e].equipSelectCount = 0, this.groupNodeObject[e].halfCheckedEquips && this.groupNodeObject[e].halfCheckedEquips.forEach(t=>{ this.equipControllObject[t] && this.equipControllObject[t].forEach(i=>{ this.setCheckStatus(`${e}-${t}-${i}`, !1, !1) }) }), this.groupNodeObject[e].halfCheckedEquips = [], this.groupNodeObject[e].groupId && this.clearCheckedEquips(this.groupNodeObject[e].groupId)) }updateSearchStatusObject(e, t){ this.searchStatusGroupObject[e] && (this.searchStatusGroupObject[e].equipSelectCount = this.searchStatusGroupObject[e].equipSelectCount + t, this.searchStatusGroupObject[e].groupId && this.updateSearchStatusObject(this.searchStatusGroupObject[e].groupId, t)) }updateEquipSelectCount(e, t, i){ this.nodesMap[e] && (t ? this.nodesMap[e].equipSelectCount = 0 : this.nodesMap[e].equipSelectCount = this.nodesMap[e].equipSelectCount + i, this.nodesMap[e].groupId && this.updateEquipSelectCount(this.nodesMap[e].groupId, t, i)) }setEquipCheckObject(e, t, i, o){ this.equipCheckObject[e] || (this.equipCheckObject[e] = {}), this.equipCheckObject[e].checked = t, this.equipCheckObject[e].indeterminate = i, this.equipCheckObject[e].groupId = o }updateEquipSelect(e, t, i, o){ this.nodesMap[e] && t.length && t.forEach(u=>{ i ? (this.setEquipCheckObject(u.equipNo, !0, !1, e), this.nodesMap[`${e}-${u.equipNo}`] && this.setCheckStatus(`${e}-${u.equipNo}`, !0, !1)) : (this.setEquipCheckObject(u.equipNo, !1, !1, e), this.nodesMap[`${e}-${u.equipNo}`] && this.setCheckStatus(`${e}-${u.equipNo}`, !1, !1)), this.equipControllObject[u.equipNo] && delete this.equipControllObject[u.equipNo], this.nodesMap[e].halfCheckedEquips.includes(u.equipNo) && (this.nodesMap[e].halfCheckedEquips = this.nodesMap[e].halfCheckedEquips.filter(h=>h != u.equipNo), this.searchStatusGroupObject[e] && (this.searchStatusGroupObject[e].halfCheckedEquips = this.nodesMap[e].halfCheckedEquips)) }) }updateGroupSelect(e, t){ e.forEach(i=>{ if(this.groupNodeObject[i]){ this.groupNodeObject[i].groups && this.groupNodeObject[i].groups.length > 0 && this.updateGroupSelect(this.groupNodeObject[i].groups.map(r=>r.key), t);let o = this.window[`group-${i}${this.aliasName}`] || [];this.isSearchStatus && (o = this.window[`group-${i}-search`] || []);let u = 0, h = 0;o.forEach(r=>{ let n = this.equipCheckObject[r.equipNo];!n || !n.checked ? u++ : h-- });let c = t ? u : h;this.updateEquipSelect(i, o, t, c), console.log(i, !1, c), this.updateEquipSelectCount(i, !1, c), this.updateSearchStatusObject(i, c) } }) }clearHalfCheckedEquips(e){ e.forEach(t=>{ this.groupNodeObject[t].halfCheckedEquips && this.groupNodeObject[t].halfCheckedEquips.forEach(i=>{ this.equipControllObject[i] && this.equipControllObject[i].forEach(o=>{ this.setCheckStatus(`${t}-${i}-${o}`, !1, !1) }) }), this.groupNodeObject[t].halfCheckedEquips = [], this.groupNodeObject[t].groups && this.groupNodeObject[t].groups.length > 0 && this.clearHalfCheckedEquips(this.groupNodeObject[t].groups.map(i=>i.key)) }) }selectGroup(e){ this.clearHalfCheckedEquips([e.key]), this.updateGroupSelect([e.key], e.checked), this.updateControlCheckStatus(), this.updateGroupCheckStatus() }selectEquip(e){ if(this.nodesMap[e.groupId]){ let t = [{equipNo: e.equipNo}], i = (e.checked ? 1 : -1) * t.length;this.updateEquipSelect(e.groupId, t, e.checked, i), this.updateEquipSelectCount(e.groupId, !1, i), this.updateSearchStatusObject(e.groupId, i), this.updateControlCheckStatus(), this.updateGroupCheckStatus() } }updateEquipControl(e, t, i){ this.equipControllObject[e] || (this.equipControllObject[e] = []), i ? this.equipControllObject[e].push(t) : this.equipControllObject[e] = this.equipControllObject[e].filter(o=>o != t) }selectControl(e){ let t = this.nodesMap[`${e.groupId}-${e.equipNo}`];t && (this.updateEquipControl(e.equipNo, e.setNo, e.checked), e.checked ? t.settings && t.settings.length == this.equipControllObject[e.equipNo].length ? (delete this.equipControllObject[e.equipNo], this.updateEquipSelectCount(e.groupId, !1, 1), this.updateSearchStatusObject(e.groupId, 1), this.nodesMap[e.groupId].halfCheckedEquips = this.nodesMap[e.groupId].halfCheckedEquips.filter(i=>i != e.equipNo), this.setEquipCheckObject(e.equipNo, !0, !1, e.groupId), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !0, !1)) : t && !t.indeterminate && (this.nodesMap[`${e.groupId}`].halfCheckedEquips.push(e.equipNo), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !1, !0), this.setEquipCheckObject(e.equipNo, !1, !0, e.groupId)) : t.checked ? (this.updateEquipSelectCount(e.groupId, !1, -1), this.updateSearchStatusObject(e.groupId, -1), t.settings.length > 1 ? (this.nodesMap[e.groupId].halfCheckedEquips.push(e.equipNo), t.settings.map(o=>o.setNo).filter(o=>o != e.setNo).forEach(o=>{ this.updateEquipControl(e.equipNo, o, !0) }), this.setEquipCheckObject(e.equipNo, !1, !0, e.groupId), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !1, !0)) : (this.setEquipCheckObject(e.equipNo, !1, !1, e.groupId), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !1, !1))) : t.indeterminate && this.equipControllObject[e.equipNo] && !this.equipControllObject[e.equipNo].length && (this.nodesMap[e.groupId].halfCheckedEquips = this.nodesMap[e.groupId].halfCheckedEquips.filter(i=>i != e.equipNo), this.setEquipCheckObject(e.equipNo, !1, !1, e.groupId), this.setCheckStatus(`${e.groupId}-${e.equipNo}`, !1, !1)), this.updateGroupCheckStatus()) }}class O extends g{constructor(e, t){ super(), this.aliasName = t, this.groupNodeObject = e }resetGroupNum(e){ this.clearAllEquipNum();for(let t in this.groupNodeObject){ let i = [];e ? i = this.window[`group-${t}-search`] : i = this.window[`group-${t}${this.aliasName}`];let o = i ? i.length : 0;o && (this.groupNodeObject[t].equipCount = o, this.setGroupNum(t, o)) } }clearAllEquipNum(){ for(let e in this.groupNodeObject){ this.groupNodeObject[e].equipCount = 0, this.groupNodeObject[e].count = 0 } }setGroupNum(e, t){ this.groupNodeObject[e] && (this.groupNodeObject[e].count = Number(this.groupNodeObject[e].count) + Number(t), this.setGroupNum(this.groupNodeObject[e].groupId, t)) }getAllEquipsNum(){ let e = 0;for(let t in this.groupNodeObject){ this.window[`group-${this.groupNodeObject[t].key}${this.aliasName}`] && (e = e + this.window[`group-${this.groupNodeObject[t].key}${this.aliasName}`].length); }return e }}class b{constructor(e, t, i){ this.url = e, this.connectionId = t, this.equipNo = i, this.signalr = null }openConnect(){ return this.signalr && (this.signalr.stop(), this.signalr = null), this.signalr = new N.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(t=>{ console.log(t) }) }) }async send(){ try{ await this.signalr.invoke(this.connectionId, this.equipNo) }catch(e){ console.log("connectHub 连接失败" + e) } }}class j extends g{constructor(e, t, i, o, u){ super(), this.equipStatusObject = t, this.groupNodeObject = i, this.aleadyUpdateStatus = {}, this.isGetAllEquipStatus = !1, this.nodesMap = e, this.statusChange = o, this.openSignlr(), this.aliasName = u }openSignlr(){ this.equipStatusSignlr = new b("/equipStatusMonitor", "", ""), this.equipStatusSignlr.openConnect().then(e=>{ try{ e.invoke("GetAllEquipStatus") }catch(t){ console.log(t) }this.subscribeTo(e, "GetAllEquipStatus");try{ e.invoke("GetEquipChangeStatus") }catch(t){ console.log(t) }e.onclose(()=>{ this.openSignlr() }), this.subscribeTo(e, "GetEquipChangeStatus") }) }subscribeTo(e, t){ e.off(t), e.on(t, i=>{ i && i.isSuccess && i.data && (this[t] ? this[t](i.data) : this.notice({func: t, data: i.data, key: i.groupId})) }) }GetAllEquipStatus(e){ this.isGetAllEquipStatus = !0, this.resetGroupStatus(), Object.keys(e).forEach(t=>{ this.equipStatusObject[t] = e[t] }), Object.keys(this.groupNodeObject).forEach(t=>{ this.updateByGroup(t) }) }updateByGroup(e){ if(!this.aleadyUpdateStatus[e]){ let t = this.window[`group-${e}${this.aliasName}`] || [];t.length && (this.aleadyUpdateStatus[e] = !0, t.forEach(i=>{ this.equipStatusObject[i.equipNo] == 0 || this.equipStatusObject[i.equipNo] == 2 ? this.setGroupStatus(e, !0, 2) : this.equipStatusObject[i.equipNo] == 6 && this.setGroupStatus(e, !0, 6), this.nodesMap[`${e}-${i.equipNo}`] && (this.nodesMap[`${e}-${i.equipNo}`].status = this.equipStatusObject[i.equipNo]) })) } }updateGroupStatus(e){ this.isGetAllEquipStatus && this.updateByGroup(e) }GetEquipChangeStatus(e){ this.setStatus(e) }setGroupStatus(e, t, i){ 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) }setStatus(e){ let t = this.equipStatusObject[e.equipNo], i = this.window.equipCache && this.window.equipCache[e.equipNo] && this.window.equipCache[e.equipNo].groupId;if(e.status != 3 && i){ switch(e.status){ case 0:t != 0 && this.setGroupStatus(i, !0, 2), t == 6 && this.setGroupStatus(i, !1, 6);break;case 1:t == 6 ? this.setGroupStatus(i, !1, 6) : (t == 2 || t == 0) && this.setGroupStatus(i, !1, 2);break;case 2:t != 2 && this.setGroupStatus(i, !0, 2), t == 6 && this.setGroupStatus(i, !1, 6);break;case 6:(t == 2 || t == 0) && this.setGroupStatus(i, !1, 2), t != 6 && this.setGroupStatus(i, !0, 6);break }this.equipStatusObject[e.equipNo] = e.status;let o = `${i}-${e.equipNo}`;this.nodesMap[o] && (this.nodesMap[o].status = e.status), this.statusChange(i, e.equipNo, e.status) } }resetGroupStatus(){ for(let e in this.groupNodeObject){ this.groupNodeObject[e].alarmCounts = 0, this.groupNodeObject[e].backUpCount = 0 } }}const M = Object.assign({}, {getSetParm(s){ if(window.AxiosBuilder.axios){ return window.AxiosBuilder.axios({method: "post", url: "/IoT/api/v3/EquipList/GetFullSetParmByEquipNo", params: s, data: s, headers: {"Content-Type": "application/json;charset=UTF-8", "Accept-Language": window.sessionStorage.languageType || "zh-CN"}}) } }});class G{constructor(e, t){ this.nodesMap = e, this.equipControllObject = t }async getSetting(e, t, i, o){ let[u, h] = String(e).split("-"), c = {equipNo: h};await M.getSetParm(c).then(r=>{ if(r.data.code == 200){ let n = r && r.data && r.data.data && r.data.data.rows || [];this.nodesMap[e].settings || (this.nodesMap[e].settings = []), n && n.length > 0 && this.nodesMap[e] && (n.forEach(p=>{ p.title = p.setNm, p.key = `${u}-${h}-${p.setNo}`, p.level = Number(i) + 1, p.checked = o || this.equipControllObject[h] && this.equipControllObject[h].includes(p.setNo), p.isSetting = !0, p.equipNo = h, p.groupId = u, p.equipName = t }), this.nodesMap[e].settings = [...n]) } }) }}class d{static formateList(e, t){ let i = [];for(const o of e){ let u = {};u.count = 0, u.equipSelectCount = 0, u.controlSelectCount = 0, u.equipCount = o.equipCount || 0, u.title = o.name, u.key = o.id, u.isGroup = !0, u.children = [], u.status = 1, u.level = t || 1, u.expand = !t, u.equips = [], u.groupId = o.parentId, u.groups = [], u.alarmCounts = 0, u.backUpCounts = 0, u.indeterminate = !1, u.checked = !1, u.visible = !0, u.nodeEquipSelectCount = 0, u.checkedEquips = [], u.halfCheckedEquips = [], u.selectControlCount = 0, o.children && o.children.length > 0 && (u.groups = [...this.formateList(o.children, t ? t + 1 : 2)]), i.push(u) }return i }static deepClone(e, t, i, o, u, h){ let c = [];if(e){ for(let r = 0, n = e.length;r < n;r++){ c.push({isGroup: i, key: `${o}-${e[r].id}`, status: h[e[r].id] || 0, title: e[r].title, level: t, expand: !1, isEquip: !0, loading: !1, indeterminate: u[e[r].equipNo] && u[e[r].equipNo].indeterminate || !1, checked: u[e[r].equipNo] && u[e[r].equipNo].checked || !1, groupId: o, equipNo: e[r].id, visible: !0, settings: []}); } }return c }static copyOrigin(e){ let t = [];return e.forEach(i=>{ t.push({...i}) }), t }static getPosition(e, t){ let i = 0;for(let o = 0, u = t.length;o < u;o++){ if(t[o].key == e){ i = o - 30;break } }return i }static flattern(e, t){ e.forEach(i=>{ i.isGroup && (t[`${i.key}`] = null, t[`${i.key}`] = i), i.groups && i.groups.length && this.flattern(i.groups, t) }) }static generateUUID(){ let e = new Date().getTime();return window.performance && typeof window.performance.now == "function" && (e += performance.now()), "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(i){ let o = (e + Math.random() * 16) % 16 | 0;return e = Math.floor(e / 16), (i === "x" ? o : o & 3 | 8).toString(16) }) }static listToTreeList(e){ const t = e, i = [], o = {};return t.forEach(u=>{ o[u.id] = u }), t.forEach(u=>{ const h = o[u.parentId];h ? (h.children || (h.children = [])).push(u) : i.push(u) }), i }}class m extends g{constructor(e, t, i){ super(), this.showSettings = t, this.groupNodeObject = e, this.aliasName = i }filterMethod(e){ for(let t in this.groupNodeObject){ e && this.updateBySearch(t, e) } }updateBySearch(e, t){ let i = this.window[`group-${this.groupNodeObject[e].key}${this.aliasName}`];i && (i = i.filter(o=>o.title.includes(t)), this.window[`group-${this.groupNodeObject[e].key}-search`] = d.copyOrigin(i)) }}const C = (s, e)=>{ const t = s.__vccOpts || s;for(const[i, o]of e){ t[i] = o; }return t }, y = {props: {source: {type: Object}, groupEditAndNew: {type: Function}, deleteGroup: {type: Function}}}, x = {class: "operates"};function I(s, e, t, i, o, u){ const h = a.resolveComponent("el-button"), c = a.resolveComponent("el-button-group"), r = a.resolveComponent("el-popover");return a.openBlock(), a.createElementBlock("div", x, [a.createVNode(r, {placement: "bottom", trigger: "hover"}, {reference: a.withCtx(()=>e[3] || (e[3] = [a.createElementVNode("i", {class: "el-icon-more"}, null, -1)])), default: a.withCtx(()=>[a.createVNode(c, {class: "new-button-group setModule"}, {default: a.withCtx(()=>[a.createVNode(h, {type: "text", size: "small", class: "elBtn", icon: " iconfont icon-tubiao20_bianji", onClick: e[0] || (e[0] = a.withModifiers(n=>t.groupEditAndNew(!1, t.source), ["stop"]))}, {default: a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.$t("equipInfo.poverTips.rename")), 1)]), _: 1}), a.createVNode(h, {type: "text", size: "small", class: "elBtn", icon: " iconfont icon-gw-icon-tianjia1", onClick: e[1] || (e[1] = n=>t.groupEditAndNew(!0, t.source))}, {default: a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.$t("equipInfo.poverTips.newChildGroup")), 1)]), _: 1}), t.source.level != 1 ? (a.openBlock(), a.createBlock(h, {key: 0, type: "danger", size: "small", onClick: e[2] || (e[2] = a.withModifiers(n=>t.deleteGroup(t.source), ["stop"])), icon: " iconfont icon-tubiao20_shanchu"}, {default: a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.$t("publics.button.deletes")), 1)]), _: 1})) : a.createCommentVNode("", !0)]), _: 1})]), _: 1})]) }const $ = {name: "ElTreeVirtualNode", componentName: "ElTreeVirtualNode", props: {searchName: {type: String, default: ""}, expanding: {type: Boolean, default: !1}, aleadyLoadAll: {type: Boolean, default: !1}, groupLoading: {type: Boolean, default: !1}, source: {type: Object}, showCheckbox: {type: Boolean, default: !1}, showStatus: {type: Boolean, default: !1}, filterEquip: {type: Boolean, default: !1}, showOperate: {type: Boolean, default: !1}, currentSelect: {type: [Number, String], default: -1}, nodeClick: {type: Function}, onChecked: {type: Function}, groupEditAndNew: {type: Function}, deleteGroup: {type: Function}, childrenResetGroupNum: {type: Function}, getEquipStatus: {type: Function}, colorConfig: {type: Object}, index: {type: Number, default: -1}}, components: {oparate: C(y, [["render", I]])}, computed: {getColor(){ return function(s){ let e;switch(s){ case 0:e = this.colorConfig.noComm;break;case 1:e = this.colorConfig.normal;break;case 2:e = this.colorConfig.alarm;break;case 3:e = this.colorConfig.lsSet;break;case 4:e = this.colorConfig.initialize;break;case 5:e = this.colorConfig.withdraw;break;case 6:e = this.colorConfig.BackUp;break;default:e = this.colorConfig.noComm;break }return e } }, filterEquip(){ return this.filterEquip ? this.source.isGroup && this.source.count !== 0 && this.source.status === 2 || !this.source.isGroup && (this.source.status === 2 || this.source.status === 0) : !0 }}, watch: {filterEquip(s){ s ? (this.setAlarmEqupGroup(), this.childrenResetGroupNum(!0)) : this.childrenResetGroupNum(!1) }}, data(){ return{indent: 13} }, methods: {clickFunction(){ this.source.expand = !this.source.expand, this.nodeClick(this.source, this.index, this.source.level, this.source.checked) }, checkedChange(s){ this.onChecked(this.source) }, setAlarmEqupGroup(){ window.groupList.forEach(s=>{ window[`group-${s.id}-search`] = window["group-" + s.id].filter(e=>this.getEquipStatus(e.equipNo) === 2 || this.getEquipStatus(e.equipNo) === 0) }) }}}, T = {class: "el-tree-node__content"}, _ = {class: "nodeContent"}, L = {key: 1, class: "circle"}, B = {class: "label"}, A = {key: 2, class: "equipNumber"}, V = {key: 4, class: "el-tree-node__loading-icon el-icon-loading"};function U(s, e, t, i, o, u){ const h = a.resolveComponent("el-checkbox"), c = a.resolveComponent("oparate");return u.filterEquip ? (a.openBlock(), a.createElementBlock("div", {key: 0, class: a.normalizeClass(["el-tree-node", {parent_tag: t.source.isGroup, child_tags: !t.source.isGroup, selectedColor: t.currentSelect === t.source.key && !t.source.isGroup}]), onClick: e[1] || (e[1] = (...r)=>u.clickFunction && u.clickFunction(...r))}, [a.createElementVNode("div", T, [a.createElementVNode("span", {class: "el-tree__indent", "aria-hidden": "true", style: a.normalizeStyle({width: (t.source.level - 1) * o.indent + "px"})}, null, 4), t.source.isGroup ? (a.openBlock(), a.createElementBlock("span", {key: 0, class: a.normalizeClass([{"is-leaf": !t.source.isGroup, expanded: t.source.isGroup && t.source.expand}, "el-tree-node__expand-icon", "iconfont icon-fangxiangL"])}, null, 2)) : a.createCommentVNode("", !0), a.createElementVNode("div", _, [t.showCheckbox ? (a.openBlock(), a.createBlock(h, {key: 0, modelValue: t.source.checked, "onUpdate:modelValue": e[0] || (e[0] = r=>t.source.checked = r), indeterminate: t.source.indeterminate, onChange: u.checkedChange}, null, 8, ["modelValue", "indeterminate", "onChange"])) : a.createCommentVNode("", !0), t.showStatus ? (a.openBlock(), a.createElementBlock("span", L, [t.source.status != 6 ? (a.openBlock(), a.createElementBlock("span", {key: 0, class: "yd", style: a.normalizeStyle({backgroundColor: u.getColor(t.source.status)})}, null, 4)) : (a.openBlock(), a.createElementBlock("i", {key: 1, style: a.normalizeStyle({color: t.colorConfig.BackUp}), class: "iconfont icon-gw-icon-beiji2"}, null, 4))])) : a.createCommentVNode("", !0), a.createElementVNode("span", B, a.toDisplayString(t.source.title), 1), t.source.isGroup && !t.source.isEquip || t.source.isGroup && !t.source.isEquip ? (a.openBlock(), a.createElementBlock("span", A, a.toDisplayString(t.source.count), 1)) : a.createCommentVNode("", !0), t.source.isGroup && t.showOperate ? (a.openBlock(), a.createBlock(c, {key: 3, source: t.source, groupEditAndNew: t.groupEditAndNew, deleteGroup: t.deleteGroup}, null, 8, ["source", "groupEditAndNew", "deleteGroup"])) : a.createCommentVNode("", !0), t.source.loading ? (a.openBlock(), a.createElementBlock("span", V)) : a.createCommentVNode("", !0)])])], 2)) : a.createCommentVNode("", !0) }const D = C($, [["render", U]]), W = {components: {VirtualList: l}, mixins: [q], data(){ return{itemComponent: D, visibleList: [], currentSelect: -1, equipStatusManage: null, cacheManage: null, searchManage: null, equipNumManage: null, requestManage: null, checkStatusManage: null, groupNodeObject: {}, nodesMap: {}, equipCheckObject: {}, equipStatusObject: {}, controlObject: {}, isSearchStatus: !1, equipControllObject: {}, expandGroup: [], updateJob: null} }, props: {data: {type: Array}, selectEquips: {type: Array, default: ()=>[]}, controllList: {type: Array, default: ()=>[]}, showSettings: {type: Boolean, default: !1}, showSelectNum: {type: Boolean, default(){ return!1 }}, showCheckbox: {type: Boolean, default: !1}, showStatus: {type: Boolean, default: !1}, filterEquip: {type: Boolean, default: !1}, showOperate: {type: Boolean, default: !1}, defaultExpandAll: {type: Boolean, default: !1}, currentNodeKey: [String, Number], colorConfig: {type: Object, default: ()=>({noComm: "#a0a0a0", normal: "#63e03f", alarm: "#f22433", lsSet: "#bebcaa", initialize: "#289ac0", withdraw: "#ffc0cb", BackUp: "#f8901c"})}, treeType: {type: String, default: ""}, buildTree: {type: Function}, filterData: {type: Function}, alias: {type: String, default: ""}}, watch: {data(s){ s && s.length && (d.flattern(this.data, this.groupNodeObject), this.cacheManage.addNodesMap(Object.values(this.groupNodeObject).map(e=>e)), this.init()) }, controllList(s){ this.updateCheckedStatusWithControls() }, selectEquips(s){ this.updateCheckedStatusWithEquips() }, filterEquip(s){ this.$nextTick(()=>{ this.$refs.virtualList.scrollToIndex(0) }) }}, computed: {aliasName(){ return this.alias ? `-${this.alias}` : "" }}, created(){ this.showCheckbox && (this.checkStatusManage = new k(this.groupNodeObject, this.nodesMap, this.equipControllObject, this.controlObject, this.equipCheckObject, this.aliasName)), this.cacheManage = new E(this.groupNodeObject, this.nodesMap, this.controlObject, this.equipCheckObject), this.searchManage = new m(this.groupNodeObject, this.showSettings, this.aliasName), this.equipNumManage = new O(this.groupNodeObject, this.aliasName), this.requestManage = new G(this.nodesMap, this.equipControllObject) }, mounted(){ this.updateCheckedStatusWithControls(), this.updateCheckedStatusWithEquips(), window.addEventListener("message", s=>{ s.data.type && this[s.data.type] && this[s.data.type](s.data.data) }) }, methods: {init(){ this.data[0].expand = !0, this.updateTreeList(), setTimeout(()=>{ Object.values(this.groupNodeObject).forEach(s=>{ !s.expand && this.expandGroup.includes(s.key) && (s.expand = !0), this.filterWithAlias(s.key), this.updateGroupEquips(s.key, !0) }), this.equipNumManage.resetGroupNum(this.isSearchStatus), this.showStatus && !this.equipStatusManage && (this.equipStatusManage = new j(this.nodesMap, this.equipStatusObject, this.groupNodeObject, this.statusChange, this.aliasName)) }, 500) }, filterWithAlias(s){ if(this.aliasName){ let e = this.window[`group-${s}`] || [];this.window[`group-${s}${this.aliasName}`] = this.filterData(e) } }, updateCurrentSelect(){ this.window.equipCache && this.window.equipCache[this.currentNodeKey] && (this.currentSelect = `${this.window.equipCache[this.currentNodeKey].groupId}-${this.currentNodeKey}`) }, statusChange(s, e, t){ this.currentSelect == `${s}-${e}` && this.$emit("statusChange", e, t) }, updateCheckWidthJob(){ this.showCheckbox && (this.checkStatusManage.resetCheckedStatus(), this.updateCheckedStatusWithControls(), this.updateCheckedStatusWithEquips()) }, updateGroupEquips(s, e){ if(!this.isSearchStatus && this.groupNodeObject[s]){ let t = this.equipNumManage.getAllEquipsNum();this.$emit("getTotal", t) }this.groupNodeObject[s].expand && this.updateList(s, this.groupNodeObject[s].level, null, !1) }, updateList(s){ if(this.groupNodeObject[s]){ let e = [];this.isSearchStatus ? (e = this.window[`group-${s}-search`], this.groupNodeObject[s].equips = [...d.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 = [...d.deepClone(e, Number(this.groupNodeObject[s].level) + 1, this.showSettings, s, this.equipCheckObject, this.equipStatusObject)]), this.cacheManage.addNodesMap(this.groupNodeObject[s].equips), this.cacheManage.closeBrotherNode(s), this.visibleList = [], this.updateTreeList(this.data), this.showStatus && this.equipStatusManage && this.equipStatusManage.updateGroupStatus(s), this.updateCurrentSelect() } }, updateTreeList(s){ s && s.forEach(e=>{ 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 || []) }) }, nodeClick(s, e, t, i){ 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 }, groupClick(s, e, t){ s.expand ? this.updateList(s.key, s.level, e, t) : (this.cacheManage.recycleGroupCache(s.key), this.visibleList = [], this.updateTreeList(this.data)) }, async equipClick(s, e, t){ this.showSettings && (s.expand ? (s.loading = !0, await this.requestManage.getSetting(s.key, s.title, s.level, t), this.controlObject[s.equipNo] = {groupId: s.groupId}, s.loading = !1, this.visibleList.splice(e + 1, 0, ...this.nodesMap[s.key].settings), this.cacheManage.addNodesMap(this.nodesMap[s.key].settings)) : (this.visibleList.splice(e + 1, this.nodesMap[s.key].settings.length), this.cacheManage.removeNodesMap(this.nodesMap[s.key].settings), this.nodesMap[s.key].settings = [], delete this.controlObject[s.equipNo])) }, onChecked(s){ this.checkStatusManage && this.checkStatusManage.onChecked(s, this.isSearchStatus), this.$emit("onCheck") }, groupEditAndNew(s, e){ this.$emit("groupEditAndNew", {isGroupNew: s, node: e}) }, deleteGroup(s){ this.$emit("deleteGroup", s) }, updateCheckedStatusWithControls(){ this.controllList && this.controllList.length && this.checkStatusManage && this.checkStatusManage && this.checkStatusManage.updateCheckedStatusWithControls(this.controllList) }, updateCheckedStatusWithEquips(){ this.selectEquips && this.selectEquips.length && this.checkStatusManage && this.checkStatusManage && this.checkStatusManage.updateCheckedStatusWithEquips(this.selectEquips) }, resetCheckedStatus(){ this.checkStatusManage && this.checkStatusManage.resetCheckedStatus() }, getEquipSelectd(){ return this.checkStatusManage && this.checkStatusManage.getEquipSelectd() }, getControlSelected(){ return this.checkStatusManage && this.checkStatusManage.getControlSelected() }, recordExpandGroup(){ this.expandGroup = [], Object.values(this.groupNodeObject).forEach(s=>{ s.expand && this.expandGroup.push(s.key) }) }, removeExpandGroup(){ this.$nextTick(()=>{ this.expandGroup = [] }) }, filterMethod(s){ this.visibleList = [], this.cacheManage.recycleAllNodeCache(), s ? (this.isSearchStatus = !0, this.searchManage.filterMethod(s)) : this.isSearchStatus = !1, this.init(), this.$nextTick(()=>{ this.$refs.virtualList.scrollToIndex(0) }), this.equipNumManage.resetGroupNum(this.isSearchStatus), this.showCheckbox && (this.checkStatusManage && this.checkStatusManage.reComputedCheckNum(this.isSearchStatus), this.checkStatusManage && this.checkStatusManage.updateGroupCheckStatus()) }, rebuildTree(){ this.recordExpandGroup(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus(), this.cacheManage.recycleAllNodeCache(!0), this.$nextTick(()=>{ this.buildTree(), this.removeExpandGroup() }) }, destroyTree(){ this.cacheManage.recycleAllNodeCache(!0), this.visibleList = [], this.updateTreeList(this.data) }, GetGroupEquips(s){ s.groupId && this.groupNodeObject[s.groupId] && !this.isSearchStatus && (this.updateGroupEquips(s.groupId, !0), this.updateJob && clearTimeout(this.updateJob), this.updateJob = setTimeout(()=>{ this.updateCheckWidthJob() }, 500)) }, DeleteEquip(s){ const{groupId: e, equips: t} = s || {};e && this.groupNodeObject[e] && (this.updateGroupEquips(s.groupId), this.equipNumManage.resetGroupNum(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus()), t.length && t.forEach(i=>{ let o = this.nodesMap[`${e}-${i.id}`];o && (this.currentSelect.toString().includes(i.id) && this.$emit("currentDelete"), this.showStatus && (o.status == 2 || o.status == 0 ? this.equipStatusManage.setGroupStatus(e, !1, 2) : o.status == 6 && this.equipStatusManage.setGroupStatus(e, !1, 6)), delete this.nodesMap[`${e}-${i.id}`], delete this.equipCheckObject[i.id]), delete this.equipStatusObject[i.id] }) }, moveEquips(s){ const{updateGroups: e, buildTree: t} = s || {};!t && e ? e.forEach(i=>{ i && this.groupNodeObject[i] && (this.updateGroupEquips(i), this.equipNumManage.resetGroupNum(), this.checkStatusManage && this.checkStatusManage.resetCheckedStatus()) }) : t && this.rebuildTree() }, DeleteEquipGroup(s){ s.forEach(e=>{ e.groupId && this.nodesMap[e.groupId] && (this.isSearchStatus || this.rebuildTree()) }) }, AddEquipGroup(s){ const{parentGroupId: e, groupId: t} = s || {};t && this.nodesMap[e] && this.treeType && (this.isSearchStatus || this.rebuildTree()) }, EditEquipGroup(s){ const{groupId: e, groupName: t} = s;this.nodesMap[e] && (this.nodesMap[e].title = t) }, AddEquip(s){ const{groupId: e} = s || {};e && (this.isSearchStatus || this.rebuildTree()) }, EditEquip(s){ const{equipNo: e, groupId: t, equipName: i} = s || {};this.nodesMap[`${t}-${e}`] && (this.isSearchStatus || (this.nodesMap[`${t}-${e}`].title = i)) }, childrenResetGroupNum(s){ this.equipNumManage.resetGroupNum(s) }, getEquipStatus(s){ return this.equipStatusManage.equipStatusObject[s] }}}, K = {class: "gw-tree", style: {height: "100%"}}, F = {class: "tree", style: {height: "100%"}};function v(s, e, t, i, o, u){ const h = a.resolveComponent("virtual-list", !0);return a.openBlock(), a.createElementBlock("div", K, [a.createElementVNode("div", F, [a.createVNode(h, {ref: "virtualList", class: "virtualList", "data-key": "key", "data-sources": o.visibleList, "data-component": o.itemComponent, keeps: 40, "extra-props": {currentSelect: o.currentSelect, nodeClick: u.nodeClick, showStatus: t.showStatus, filterEquip: t.filterEquip, showSettings: t.showSettings, showCheckbox: t.showCheckbox, onChecked: u.onChecked, showOperate: t.showOperate, groupEditAndNew: u.groupEditAndNew, deleteGroup: u.deleteGroup, colorConfig: t.colorConfig, childrenResetGroupNum: u.childrenResetGroupNum, getEquipStatus: u.getEquipStatus}}, null, 8, ["data-sources", "data-component", "extra-props"])])]) }const R = C(W, [["render", v]]);class z{constructor(){ this.eGroupNotify = new b("/eGroupNotify", "", ""), this.alreadyUpdate = {}, this.notify = null, this.window = window;try{ window.top.equipGroup, this.window = window.top }catch{ this.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(t){ console.log(t) }this.subscribeTo(e, "GetEquipGroupTree"), this.subscribeTo(e, "AddEquipGroup"), this.subscribeTo(e, "EditEquipGroup"), this.subscribeTo(e, "DeleteEquipGroup");try{ e.invoke("GetGroupEquips") }catch(t){ console.log(t) }this.subscribeTo(e, "GetGroupEquips"), this.subscribeTo(e, "AddEquip"), this.subscribeTo(e, "DeleteEquip"), this.subscribeTo(e, "EditEquip"), this.subscribeTo(e, "moveEquips"), this.subscribeTo(e, "GetAllEquipGroupTree"), e.onclose(t=>{ try{ this.Init() }catch(i){ console.log(i) }console.log("重连", t) }) }).catch(e=>{ console.error(e) }) }subscribeTo(e, t){ e.off(t), e.on(t, i=>{ i && i.isSuccess && (this[t] ? this[t](i.data) : this.notice({func: t, data: i.data, key: i.groupId})) }) }GetEquipGroupTree(e){ this.window.groupList || (this.window.groupList = e, this.notice({type: "GetEquipGroupTree"})) }GetAllEquipGroupTree(e){ this.window.groupList_manageMent || (this.window.groupList_manageMent = e, this.notice({type: "GetEquipGroupTreeWidthTreeType"})) }AddEquipGroup(e){ const{parentGroupId: t, groupId: i, groupName: o} = e || {};i && (this.window.groupList_manageMent || (this.window.groupList_manageMent = []), this.window.groupList_manageMent.push({parentId: t, id: i, name: o, equipCount: 0}), this.notice({type: "AddEquipGroup", data: e})) }EditEquipGroup(e){ const{groupId: t, groupName: i} = e;this.window.groupList && window.groupList.forEach(o=>{ o.id == t && (o.name = i) }), this.window.groupList_manageMent && window.groupList_manageMent.forEach(o=>{ o.id == t && (o.name = i) }), this.notice({type: "EditEquipGroup", data: e}) }deleteChildGroup(e, t){ let i = [];t.forEach(o=>{ o.parentId == e && i.push(o.id) }), i.forEach(o=>{ let u = t.findIndex(h=>h.id == o);u > -1 && t.splice(u, 1), this.deleteChildGroup(o, t) }) }DeleteEquipGroup(e){ e.forEach(t=>{ if(this.window.groupList){ let i = this.window.groupList.findIndex(o=>o.id == t.groupId);i > -1 && this.window.groupList.splice(i, 1), this.deleteChildGroup(t.groupId, this.window.groupList) }if(this.window.groupList_manageMent){ let i = this.window.groupList_manageMent.findIndex(o=>o.id == t.groupId);i > -1 && this.window.groupList_manageMent.splice(i, 1), this.deleteChildGroup(t.groupId, this.window.groupList_manageMent) } }), this.notice({type: "DeleteEquipGroup", data: e}) }GetGroupEquips(e){ const{groupId: t, equips: i} = e || {};this.alreadyUpdate[t] || (this.window.groupCache || (this.window.groupCache = {}), this.window.groupCache[t] = {}, t && i && i instanceof Array && (i.forEach(o=>{ o.title = o.name, o.groupId = t, o.equipNo = o.id, delete o.name, window.equipCache || (this.window.equipCache = {}), this.window.equipCache[o.id] = o, this.window.groupCache[t][o.id] = o }), this.window[`group-${t}`] = i, this.notice({type: "GetGroupEquips", data: {groupId: t}}), this.alreadyUpdate[t] = !0)) }AddEquip(e){ const{groupId: t, equips: i} = e || {};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 = {});let o = this.window[`group-${t}`].length;if(t && i){ if(i.forEach((u, h)=>{ this.window[`group-${t}`].push({equipNo: u.id, groupId: t, id: u.id, title: u.name}), this.window.equipCache[u.id] = this.window[`group-${t}`][o + h], this.window.groupCache[t][u.id] = this.window[`group-${t}`][o + h] }), !this.exist(t, this.window.groupList)){ let u = this.findParentList(t, this.window.groupList_manageMent);this.window.groupList.push(...u) }this.notice({type: "AddEquip", data: e}) } }moveEquips(e){ let t = [], i = !0, o = [];const{sourceGroup: u, targetGroupId: h} = e || {};h && t.push(h), u.forEach(c=>{ if(t.push(c.groupId), (!this.window[`group-${h}`] || !this.window[`group-${h}`].length) && (this.window[`group-${h}`] = [], o.push(h)), this.window.groupCache || (this.window.groupCache = {}), this.window.groupCache[h] || (this.window.groupCache[h] = {}), c.equips.forEach(r=>{ if(r.title = r.name, r.groupId = h, r.equipNo = r.id, this.window[`group-${c.groupId}`]){ let n = this.window[`group-${c.groupId}`].findIndex(p=>p.id == r.id);n > -1 && this.window[`group-${c.groupId}`].splice(n, 1) }window.equipCache || (this.window.equipCache = {}), this.window.equipCache[r.id] = r, this.window.groupCache[h][r.id] = r, this.window[`group-${h}`].push(r) }), !this.window[`group-${c.groupId}`].length){ let r = this.window.groupList.findIndex(n=>n.id == c.groupId);r > -1 && this.window.groupList.splice(r, 1), this.deleteChildGroup(c.groupId, this.window.groupList) } }), o.forEach(c=>{ if(!this.exist(c, this.window.groupList)){ let r = this.findParentList(c, this.window.groupList_manageMent);this.window.groupList.push(...r) } }), this.notice({type: "moveEquips", data: {updateGroups: t, buildTree: i}}) }exist(e, t){ return t ? t.some(i=>i.id == e) : !1 }findParentList(e, t){ let i = [];if(t){ let o = t.findIndex(u=>u.id == e);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)) }return i }DeleteEquip(e){ const{groupId: t, equips: i} = e || {};if(t && i && i instanceof Array){ if(this.window[`group-${t}`]){ for(let o = 0, u = i.length;o < u;o++){ let h = this.window[`group-${t}`].findIndex(c=>c.id == i[o].id);h > -1 && this.window[`group-${t}`].splice(h, 1), delete this.window.equipCache[i[o].id], delete this.window.groupCache[t][i[o].id] } }this.notice({type: "DeleteEquip", data: e}) } }EditEquip(e){ const{equipNo: t, groupId: i, equipName: o} = e || {};i && t && (window[`group-${i}`] && (this.window.equipCache[t] = o), this.notice({type: "EditEquip", data: e})) }notice(e){ if(this.window.hasIframe){ let t = document.getElementsByTagName("iframe");for(let i of t){ i.contentWindow.postMessage(e) } }else { window.postMessage(e, "*") } }}const J = {name: "treeV2", components: {tree: R}, mixins: [q], data(){ return{list: [], refId: d.generateUUID(), treeKey: null, listKey: null, hasBuildTree: !1} }, props: {treeType: {type: String, default: ""}}, mounted(){ this.treeKey = `equipGroup${this.treeType}`, this.listKey = `groupList${this.treeType}`, this.window[this.treeKey] ? this.list = d.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=>{ s && s.data && s.data.type && this[s.data.type] && this[s.data.type]() });try{ this.window.hasIframe || this.selfRequest() }catch{ this.selfRequest() } }, methods: {selfRequest(){ new z().Init() }, GetEquipGroupTreeWidthTreeType(){ this.treeType && this.window[this.listKey] && this.buildTree() }, GetEquipGroupTree(){ !this.treeType && this.window[this.listKey] && this.buildTree() }, buildTree(){ if(this.window[this.listKey]){ let s = d.listToTreeList(JSON.parse(JSON.stringify(this.window[this.listKey])));this.list = d.formateList(JSON.parse(JSON.stringify(s))), this.window[`equipGroup${this.treeType}`] = s, this.hasBuildTree = !0 } }, filterMethod(s){ this.$refs[this.refId].filterMethod(s) }, resetCheckedStatus(){ this.$refs[this.refId].resetCheckedStatus() }, getEquipSelectd(){ return this.$refs[this.refId].getEquipSelectd() }, getControlSelected(){ return this.$refs[this.refId].getControlSelected() }, destroyTree(){ this.$refs[this.refId].destroyTree() }}};function P(s, e, t, i, o, u){ const h = a.resolveComponent("tree");return a.openBlock(), a.createBlock(h, a.mergeProps({ref: o.refId, data: o.list}, {...s.$attrs, ...s.$props}, a.toHandlers(s.$listeners), {buildTree: u.buildTree}), null, 16, ["data", "buildTree"]) }const w = C(J, [["render", P]]);return w.install = function(s){ s.component(w.name, w) }, w });
@@ -0,0 +1 @@
1
+ @charset "UTF-8";.gw-tree{height:100%;font-size:14px;color:var(--tree-node-color)}.gw-tree .el-icon-more{transform:rotate(90deg)}.gw-tree .el-tree__indent{flex-shrink:0}.gw-tree .nodeContent{display:flex;justify-content:flex-start;align-items:center;width:calc(100% - 30px)}.gw-tree .nodeContent .label{line-height:30px;flex:1;word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gw-tree .el-tree-node__expand-icon{padding:0!important}.gw-tree .hover-add-width{width:calc(100% + 8px)!important}.gw-tree .hover-add-width .el-tree-node{width:calc(100% - 12px)!important;position:relative}.gw-tree .notAllow{cursor:not-allowed!important}.gw-tree .el-tree-node{height:36px;position:relative}.gw-tree .el-tree-node .block{width:100%;height:100%;position:absolute;top:0;left:0;z-index:10;cursor:not-allowed}.gw-tree .virtualList{height:100%;overflow-y:auto;overflow-x:hidden}.gw-tree .el-loading-mask{visibility:visible!important}.gw-tree .el-tree__empty-block .el-tree__empty-text{color:var(--frame-main-color-1);display:flex;justify-content:center;align-items:center;font-size:18px}.gw-tree .selectNum{height:36px;line-height:36px;padding-left:20px;color:var(--tree-node-color);font-size:14px}.gw-tree .el-checkbox{margin-right:10px!important}.gw-tree .circle{width:14px;height:14px;display:flex;justify-content:center;align-items:center;margin-right:5px}.gw-tree .circle .yd{width:10px;height:10px;border-radius:50%;display:inline-block}.gw-tree .circle .iconfont{font-size:14px}.gw-tree .el-tree-node__content:hover{background-color:unset!important}.gw-tree>div .el-tree-node:hover{background-color:var(--tree-node-background_hover);border-top-right-radius:3px;border-bottom-right-radius:3px}.gw-tree>div .el-tree-node:hover>.el-tree-node__content>.nodeContent .el-tree-node__label{color:var(--tree-node-color__select)}.gw-tree .el-tree-node.selectedColor{border-left:4px solid var(--tree-node-border__select);background-color:var(--tree-node-background_select)}.gw-tree .el-tree-node.selectedColor .nodeContent .el-tree-node__label{color:#3875ff}.gw-tree .el-tree-node{-webkit-user-select:none;user-select:none}.gw-tree .el-tree-node__content{width:100%;height:100%!important;display:flex}.gw-tree .el-tree-node__content .nodeContent{flex:1;height:100%;display:flex;align-items:center;border-radius:3px}.gw-tree .el-tree-node__content .nodeContent .equipNumber{margin:0 12px}.gw-tree .el-tree-node__content .nodeContent .icon-gw-icon-yijian{width:16px;height:16px;margin-right:18px;opacity:0}.gw-tree .el-tree-node__content .nodeContent .icon-gw-icon-yijian path{fill:var(--tree-node-color)}.gw-tree .el-tree-node__content .nodeContent:hover .icon-gw-icon-yijian{opacity:1}.gw-tree .el-tree-node__content .nodeContent .el-tree-node__label{flex:1}.gw-tree .el-tree-node__content .nodeContent .expanded,.gw-tree .el-tree-node__content .nodeContent .el-tree-node__expand-icon{color:var(--tree-node-color)}.gw-tree .el-tree-node:focus>.el-tree-node__content{background-color:unset!important}.gw-tree .el-tree-node__expand-icon{margin:10px}.gw-tree .child_tags{position:relative;width:auto;height:36px;display:flex;flex-direction:row;justify-content:flex-start;align-items:center;line-height:30px;white-space:nowrap;text-overflow:ellipsis;color:var(--tre-node-color);cursor:pointer;border-left:4px solid transparent}.gw-tree .child_tags .nodeContent{padding-left:18px;background-size:.5px 12px;background-repeat:repeat-y;background-position:left}[data-theme=light] .gw-tree .child_tags .nodeContent{background-image:linear-gradient(to bottom,#979797 50%,#979797 50%,transparent 50%)}[data-theme=dark] .gw-tree .child_tags .nodeContent{background-image:linear-gradient(to bottom,#494D57 50%,#494D57 50%,transparent 50%)}.gw-tree .child_tags>label{margin-left:10px}.gw-tree .child_tags .icondian{font-size:.8rem;color:#8c8c8c;pointer-events:none}.gw-tree .child_tags a{font-size:14px;height:40px;line-height:40px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:72%}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ganwei-web/gw-base-components-plus",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "components",
5
5
  "main": "./dist/index.es.js",
6
6
  "scripts": {