dcim-topology2d 1.1.6 → 2.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.
- package/chart-diagram/src/echarts/index.js +88 -96
- package/chart-diagram/src/register.js +3 -3
- package/chart-diagram/src/utils/changeOptions.d.ts +4 -4
- package/chart-diagram/src/utils/changeOptions.js +172 -144
- package/chart-diagram/src/utils/conversion.d.ts +12 -12
- package/chart-diagram/src/utils/conversion.js +278 -137
- package/chart-diagram/src/utils/render.d.ts +5 -0
- package/chart-diagram/src/utils/render.js +107 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/src/activeLayer.js +0 -6
- package/core/src/canvas.js +1 -0
- package/core/src/common.d.ts +1 -2
- package/core/src/common.js +123 -540
- package/core/src/core.js +61 -46
- package/core/src/divLayer.d.ts +0 -3
- package/core/src/divLayer.js +13 -34
- package/core/src/element/common.d.ts +5 -0
- package/core/src/element/common.js +52 -0
- package/core/src/element/iframe.d.ts +3 -0
- package/core/src/element/iframe.js +12 -0
- package/core/src/element/index.d.ts +4 -0
- package/core/src/element/index.js +4 -0
- package/core/src/element/select.d.ts +11 -0
- package/core/src/element/select.js +199 -0
- package/core/src/element/tab.d.ts +1 -0
- package/core/src/element/tab.js +22 -0
- package/core/src/healps/changeData.d.ts +1 -2
- package/core/src/healps/changeData.js +16 -122
- package/core/src/middles/default.js +3 -1
- package/core/src/middles/nodes/arbitrarygraph.js +11 -9
- package/core/src/middles/nodes/formselect.d.ts +2 -0
- package/core/src/middles/nodes/formselect.js +73 -0
- package/core/src/middles/nodes/iframe.js +21 -4
- package/core/src/middles/nodes/index.d.ts +1 -0
- package/core/src/middles/nodes/index.js +1 -0
- package/core/src/models/node.d.ts +4 -0
- package/core/src/models/node.js +24 -22
- package/core/src/models/pen.js +1 -2
- package/core/src/models/rect.js +2 -2
- package/core/src/options.d.ts +1 -0
- package/core/src/preview.js +45 -31
- package/core/src/renderLayer.d.ts +10 -6
- package/core/src/renderLayer.js +36 -43
- package/core/src/store/data.d.ts +16 -17
- package/core/src/store/data.js +36 -14
- package/core/src/utils/assignment.d.ts +6 -3
- package/core/src/utils/assignment.js +84 -15
- package/core/src/utils/construction.d.ts +9 -3
- package/core/src/utils/construction.js +6 -1
- package/core/src/utils/conversion.d.ts +3 -0
- package/core/src/utils/conversion.js +67 -0
- package/core/src/utils/index.d.ts +1 -1
- package/core/src/utils/index.js +1 -1
- package/core/src/utils/math.d.ts +1 -0
- package/core/src/utils/math.js +3 -0
- package/core/src/utils/onmousevent.d.ts +3 -0
- package/core/src/utils/onmousevent.js +28 -7
- package/core/src/utils/params.d.ts +7 -0
- package/core/src/utils/params.js +125 -0
- package/package.json +1 -1
- package/static/echartsDefaultData.js +27 -107
- package/static/element.js +14 -0
- package/static/form.js +11 -0
- package/static/index.js +2 -1
- package/store/actions.js +17 -0
- package/store/clear.js +72 -0
- package/store/index.js +2 -0
- package/style/common.css +18 -0
- package/style/editor.css +13 -0
- package/style/index.css +3 -12
- package/style/select.css +143 -0
- package/core/src/utils/dom.d.ts +0 -9
- package/core/src/utils/dom.js +0 -103
- package/core/src/utils/dom.js.map +0 -1
- package/static/echartsStore.js +0 -14
package/core/src/core.js
CHANGED
@@ -18,8 +18,20 @@ import {ActiveLayer} from './activeLayer';
|
|
18
18
|
import {KeyType, KeydownType} from './options';
|
19
19
|
import {PenType, Node, Point, Line, Lock, AnchorMode, Rect} from './models';
|
20
20
|
import {drawNodeFns, drawLineFns} from './middles/index';
|
21
|
-
import {
|
22
|
-
|
21
|
+
import {
|
22
|
+
s8,
|
23
|
+
pointInRect,
|
24
|
+
formatPadding,
|
25
|
+
setTagIdData,
|
26
|
+
setKpiAddrData,
|
27
|
+
setAssetIdData,
|
28
|
+
setAreaIdData,
|
29
|
+
setVarValueData,
|
30
|
+
setThreeCategoryIdData,
|
31
|
+
initSwitchTabData
|
32
|
+
} from './utils';
|
33
|
+
import {setSelectElementPosition} from './element';
|
34
|
+
import {elementType} from '../../static';
|
23
35
|
|
24
36
|
var resizeCursors = ['nw-resize', 'ne-resize', 'se-resize', 'sw-resize'];
|
25
37
|
var dockOffset = 10;
|
@@ -195,6 +207,12 @@ var Topology = (function (_super) {
|
|
195
207
|
_this.activeLayer.move(offset.x ? offset.x : x, offset.y ? offset.y : y);
|
196
208
|
_this.needCache = true;
|
197
209
|
}
|
210
|
+
const dropdownSelect = _this.activeLayer.pens.filter((ds) => {return ds.name === elementType.select && ds.selectDropdown});
|
211
|
+
if(dropdownSelect.length) {
|
212
|
+
dropdownSelect.map((dropdown) => {
|
213
|
+
setSelectElementPosition(dropdown);
|
214
|
+
})
|
215
|
+
}
|
198
216
|
break;
|
199
217
|
case _this.moveInType.ResizeCP:
|
200
218
|
_this.store.data.dataResize = 1;
|
@@ -245,8 +263,11 @@ var Topology = (function (_super) {
|
|
245
263
|
}
|
246
264
|
}
|
247
265
|
} else {
|
266
|
+
const activeLayerPens = _this.activeLayer.pens;
|
267
|
+
const isOnlySelect = activeLayerPens.length < 2 && activeLayerPens[0].name === elementType.select && activeLayerPens[0].selectDropdown;
|
268
|
+
if(isOnlySelect) setSelectElementPosition(activeLayerPens[0]);
|
248
269
|
_this.activeLayer.resize(_this.moveIn.activeAnchorIndex, _this.mouseDown, pos);
|
249
|
-
_this.dispatch('resizePens',
|
270
|
+
_this.dispatch('resizePens', activeLayerPens);
|
250
271
|
_this.needCache = true;
|
251
272
|
}
|
252
273
|
break;
|
@@ -444,9 +465,8 @@ var Topology = (function (_super) {
|
|
444
465
|
const activeNode = _this.moveIn.activeNode;
|
445
466
|
if (!_this.checkNodeOfClickType(activeNode)) {
|
446
467
|
_this.activeLayer.setPens([activeNode]);
|
447
|
-
if
|
448
|
-
|
449
|
-
} else if (activeNode && activeNode.name == 'tablePagination') {
|
468
|
+
if(activeNode.name === elementType.select && activeNode.selectDropdown) setSelectElementPosition(activeNode, 'down');
|
469
|
+
if(activeNode.name == 'tablePagination') {
|
450
470
|
if (_this.store.options.type === 'topology') return _this.dispatch('node', activeNode);
|
451
471
|
const pnlKeys = Object.keys(activeNode.paginationData.pageNumberLocals);
|
452
472
|
const pageNumArea = pnlKeys.find((pna) => {
|
@@ -460,16 +480,8 @@ var Topology = (function (_super) {
|
|
460
480
|
if (activeNode.paginationData.pageListState) _this.spreadPageListHandle(activeNode, e);
|
461
481
|
if (activeNode.paginationData.targetPageLocal.hide) _this.targetPageInputHandle(activeNode, e);
|
462
482
|
}
|
463
|
-
}
|
483
|
+
}else {
|
464
484
|
_this.dispatch('node', activeNode);
|
465
|
-
if(!window.location.pathname.includes('workspace')) {
|
466
|
-
const staticTypeNode = activeNode.events.find((ev) => {
|
467
|
-
return parseInt(ev.action) === 8
|
468
|
-
}); // 若绑定的是echarts统计图事件
|
469
|
-
if (staticTypeNode) {
|
470
|
-
_this.switchStaticsCheckType(activeNode, staticTypeNode);
|
471
|
-
}
|
472
|
-
}
|
473
485
|
}
|
474
486
|
}
|
475
487
|
}
|
@@ -988,7 +1000,7 @@ var Topology = (function (_super) {
|
|
988
1000
|
node.scale(this.store.data.scale);
|
989
1001
|
}
|
990
1002
|
this.store.data.pens.push(node);
|
991
|
-
|
1003
|
+
initSwitchTabData(node);
|
992
1004
|
if (focus) {
|
993
1005
|
this.render();
|
994
1006
|
this.animate(true);
|
@@ -1564,7 +1576,7 @@ var Topology = (function (_super) {
|
|
1564
1576
|
this.delEmptyLines(pen.id);
|
1565
1577
|
}
|
1566
1578
|
pens.push.apply(pens, this.store.data.pens.splice(found, 1));
|
1567
|
-
this.setSwitchTabData(pen, found, 'delete');
|
1579
|
+
// this.setSwitchTabData(pen, found, 'delete');
|
1568
1580
|
--i;
|
1569
1581
|
}
|
1570
1582
|
this.animateLayer.pens.delete(pen.id);
|
@@ -1696,7 +1708,7 @@ var Topology = (function (_super) {
|
|
1696
1708
|
}
|
1697
1709
|
this.store.data.pens.push(pen);
|
1698
1710
|
this.activeLayer.add(pen);
|
1699
|
-
|
1711
|
+
initSwitchTabData(pen);
|
1700
1712
|
}
|
1701
1713
|
this.render();
|
1702
1714
|
this.animate(true);
|
@@ -1720,8 +1732,8 @@ var Topology = (function (_super) {
|
|
1720
1732
|
};
|
1721
1733
|
for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
|
1722
1734
|
var pen = _a[_i];
|
1723
|
-
pen.data = []
|
1724
|
-
this.bindInfo(item, pen, dataType, index)
|
1735
|
+
pen.data = [];
|
1736
|
+
this.bindInfo(item, pen, dataType, index);
|
1725
1737
|
this.clipboard.pens.push(pen.clone());
|
1726
1738
|
}
|
1727
1739
|
if (exite == true) {
|
@@ -1729,22 +1741,23 @@ var Topology = (function (_super) {
|
|
1729
1741
|
}
|
1730
1742
|
};
|
1731
1743
|
Topology.prototype.bindInfo = async function (item, pen, type, index) {
|
1744
|
+
const itemNode = item && item.default || item;
|
1732
1745
|
if ([0, '0'].includes(type)) {
|
1733
|
-
const setTagId = setTagIdData(
|
1746
|
+
const setTagId = setTagIdData(itemNode);
|
1734
1747
|
pen.data.push(...setTagId);
|
1735
1748
|
// 绑定悬浮文字
|
1736
|
-
pen.title =
|
1749
|
+
pen.title = itemNode.touchpname
|
1737
1750
|
//用于处理场地监控,点击一个资产类别后,隐藏掉这个类别下的所有元件
|
1738
|
-
const setThreeCategory = setThreeCategoryIdData(pen,
|
1751
|
+
const setThreeCategory = setThreeCategoryIdData(pen, itemNode);
|
1739
1752
|
pen.data.push(...setThreeCategory);
|
1740
1753
|
} else if ([1, '1'].includes(type)) {
|
1741
|
-
const setKpiAddr = setKpiAddrData(
|
1754
|
+
const setKpiAddr = setKpiAddrData(itemNode);
|
1742
1755
|
pen.data.push(...setKpiAddr);
|
1743
1756
|
} else if ([2, '2'].includes(type)) {
|
1744
|
-
const setAssetId = setAssetIdData(
|
1757
|
+
const setAssetId = setAssetIdData(itemNode);
|
1745
1758
|
pen.data.push(...setAssetId);
|
1746
1759
|
// 绑定悬浮文字
|
1747
|
-
pen.title =
|
1760
|
+
pen.title = itemNode.bak
|
1748
1761
|
if (pen.subName && pen.subName == 'temp') {
|
1749
1762
|
// 温湿度元件
|
1750
1763
|
// 通讯状态
|
@@ -1752,23 +1765,19 @@ var Topology = (function (_super) {
|
|
1752
1765
|
if (index > 0) {
|
1753
1766
|
pen.children[0].text = index + 1 + '#'
|
1754
1767
|
}
|
1755
|
-
this.bindInfo(
|
1756
|
-
//
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
}
|
1769
|
-
})
|
1770
|
-
pen.children.forEach((item) => {
|
1771
|
-
item.events = [{
|
1768
|
+
this.bindInfo(itemNode, pen.children[0], type);
|
1769
|
+
// 温度
|
1770
|
+
if(item.temperature) {
|
1771
|
+
pen.children[1].data = [];
|
1772
|
+
this.bindInfo(item.temperature, pen.children[1], 0);
|
1773
|
+
}
|
1774
|
+
// 湿度
|
1775
|
+
if(item.dampness) {
|
1776
|
+
pen.children[2].data = []
|
1777
|
+
this.bindInfo(item.dampness, pen.children[2], 0);
|
1778
|
+
}
|
1779
|
+
pen.children.forEach((itemNode) => {
|
1780
|
+
itemNode.events = [{
|
1772
1781
|
"type": 3,
|
1773
1782
|
"action": 2,
|
1774
1783
|
"value": "",
|
@@ -1777,16 +1786,19 @@ var Topology = (function (_super) {
|
|
1777
1786
|
})
|
1778
1787
|
}
|
1779
1788
|
} else if ([3, '3'].includes(type)) {
|
1780
|
-
const setAreaId = setAreaIdData(
|
1789
|
+
const setAreaId = setAreaIdData(itemNode);
|
1781
1790
|
pen.data.push(...setAreaId);
|
1791
|
+
}else if ([4, '4'].includes(type)) {
|
1792
|
+
const setVarId = setVarValueData(itemNode);
|
1793
|
+
pen.data.push(...setVarId);
|
1782
1794
|
}
|
1783
1795
|
// if([0, 2, '0', '2'].includes(type)) {
|
1784
1796
|
// //用于处理场地监控,点击一个资产类别后,隐藏掉这个类别下的所有元件
|
1785
|
-
// const setThreeCategory = setThreeCategoryIdData(pen,
|
1797
|
+
// const setThreeCategory = setThreeCategoryIdData(pen, itemNode);
|
1786
1798
|
//
|
1787
1799
|
// pen.data.push(...setThreeCategory);
|
1788
1800
|
// }
|
1789
|
-
return pen
|
1801
|
+
return pen;
|
1790
1802
|
};
|
1791
1803
|
Topology.prototype.newId = function (node, idMaps) {
|
1792
1804
|
var old = node.id;
|
@@ -1806,10 +1818,12 @@ var Topology = (function (_super) {
|
|
1806
1818
|
if (!pens) {
|
1807
1819
|
pens = this.activeLayer.pens;
|
1808
1820
|
}
|
1821
|
+
let isAnimate = false;
|
1809
1822
|
for (var _i = 0, pens_1 = pens; _i < pens_1.length; _i++) {
|
1810
1823
|
var pen = pens_1[_i];
|
1811
1824
|
if (pen instanceof Node) {
|
1812
1825
|
let isRotateBug = false
|
1826
|
+
isAnimate = pen.animateFrames && pen.animateFrames.length
|
1813
1827
|
if (pen.rotate === 0) {
|
1814
1828
|
pen.rotate = 360
|
1815
1829
|
isRotateBug = true
|
@@ -1828,6 +1842,7 @@ var Topology = (function (_super) {
|
|
1828
1842
|
this.activeLayer.calcControlPoints();
|
1829
1843
|
this.activeLayer.saveNodeRects();
|
1830
1844
|
this.render();
|
1845
|
+
if(isAnimate) this.animate(true);
|
1831
1846
|
// tslint:disable-next-line: no-unused-expression
|
1832
1847
|
cache && this.cache();
|
1833
1848
|
};
|
package/core/src/divLayer.d.ts
CHANGED
package/core/src/divLayer.js
CHANGED
@@ -22,30 +22,21 @@ var __extends = (this && this.__extends) || (function () {
|
|
22
22
|
import {Store} from 'le5le-store';
|
23
23
|
import {Node, PenType, images, defaultImages} from './models';
|
24
24
|
import {Layer} from './layer';
|
25
|
-
import { setStyleForElementIdDiv
|
25
|
+
import { setStyleForElementIdDiv } from './element';
|
26
26
|
import { commonStore } from './store';
|
27
27
|
var DivLayer = /** @class */ (function (_super) {
|
28
28
|
__extends(DivLayer, _super);
|
29
29
|
function DivLayer(TID) {
|
30
30
|
var _this = _super.call(this, TID) || this;
|
31
31
|
_this.canvas = document.createElement('div');
|
32
|
-
_this.iframes = {};
|
33
32
|
_this.elements = {};
|
34
33
|
_this.gifs = {};
|
35
34
|
_this.addDiv = function (node) {
|
36
|
-
if (node.iframe) {
|
37
|
-
Object.assign(_this.iframes, DomIframes);
|
38
|
-
if (_this.iframes[node.id] && _this.iframes[node.id].src !== node.iframe) {
|
39
|
-
_this.iframes[node.id].src = node.iframe;
|
40
|
-
}
|
41
|
-
_this.setElemPosition(node, _this.iframes[node.id] || _this.addIframe(node));
|
42
|
-
}
|
43
35
|
if (node.elementId) {
|
44
|
-
Object.assign(_this.elements, DomElements);
|
45
36
|
if (!_this.elements[node.id]) {
|
46
37
|
_this.elements[node.id] = document.getElementById(node.id);
|
47
38
|
if (_this.elements[node.id]) {
|
48
|
-
_this.
|
39
|
+
_this.addElement(node);
|
49
40
|
}
|
50
41
|
}
|
51
42
|
_this.setElemPosition(node, _this.elements[node.id]);
|
@@ -84,14 +75,12 @@ var DivLayer = /** @class */ (function (_super) {
|
|
84
75
|
_this.subcribe = Store.subscribe(_this.generateStoreKey('LT:addDiv'), _this.addDiv);
|
85
76
|
return _this;
|
86
77
|
}
|
87
|
-
DivLayer.prototype.
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
this.
|
92
|
-
commonStore[node.TID].parentElem.appendChild(iframe);
|
78
|
+
DivLayer.prototype.addElement = function (node){
|
79
|
+
if(['iframe', 'echarts'].includes(node.name)) {
|
80
|
+
this.canvas.parentNode.appendChild(this.elements[node.id]);
|
81
|
+
}else {
|
82
|
+
this.canvas.appendChild(this.elements[node.id]);
|
93
83
|
}
|
94
|
-
return iframe;
|
95
84
|
};
|
96
85
|
DivLayer.prototype.addGif = function (node) {
|
97
86
|
this.gifs[node.id] = node.img;
|
@@ -99,21 +88,18 @@ var DivLayer = /** @class */ (function (_super) {
|
|
99
88
|
return node.img;
|
100
89
|
};
|
101
90
|
DivLayer.prototype.setElemPosition = function (node, elem) {
|
102
|
-
|
91
|
+
setStyleForElementIdDiv(node, elem, commonStore[this.TID].data);
|
103
92
|
};
|
104
93
|
DivLayer.prototype.removeDiv = function (item) {
|
105
94
|
if (this.curNode && item.id === this.curNode.id) {
|
106
95
|
this.curNode = null;
|
107
96
|
}
|
108
|
-
if (item.iframe) {
|
109
|
-
const iframesNode = this.iframes[item.id] || DomIframes[item.id];
|
110
|
-
commonStore[item.TID].parentElem.removeChild(iframesNode);
|
111
|
-
this.iframes[item.id] ? this.iframes[item.id] = null : DomIframes[item.id] = null;
|
112
|
-
}
|
113
97
|
if (item.elementId) {
|
114
|
-
const elementNode = this.elements[item.id]
|
115
|
-
|
116
|
-
|
98
|
+
const elementNode = this.elements[item.id];
|
99
|
+
if(elementNode) {
|
100
|
+
this.canvas.parentElement.removeChild(elementNode);
|
101
|
+
this.elements[item.id] = null;
|
102
|
+
}
|
117
103
|
}
|
118
104
|
if (item.gif) {
|
119
105
|
this.canvas.removeChild(this.gifs[item.id]);
|
@@ -131,15 +117,8 @@ var DivLayer = /** @class */ (function (_super) {
|
|
131
117
|
};
|
132
118
|
DivLayer.prototype.clear = function () {
|
133
119
|
this.canvas.innerHTML = '';
|
134
|
-
this.iframes = {};
|
135
120
|
this.elements = {};
|
136
121
|
this.gifs = {};
|
137
|
-
for (let key in DomIframes) {
|
138
|
-
delete DomIframes[key];
|
139
|
-
}
|
140
|
-
for (let key in DomElements) {
|
141
|
-
delete DomElements[key];
|
142
|
-
}
|
143
122
|
// tslint:disable-next-line:forin
|
144
123
|
for (let key in images) {
|
145
124
|
delete images[key];
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { Node } from '../models';
|
2
|
+
import { visualization2DStore } from '../store';
|
3
|
+
export declare function setStyleForElementIdDiv(node: Node, elem: HTMLElement, data: visualization2DStore): void;
|
4
|
+
export declare function createDiv(node: Node): HTMLDivElement;
|
5
|
+
// export declare function loadJS(url: string, callback?: () => void, render?: boolean): void;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import {Lock} from '../models';
|
2
|
+
export function setStyleForElementIdDiv(node, elem, data) {
|
3
|
+
if (!elem) return;
|
4
|
+
elem.style.position = 'absolute';
|
5
|
+
elem.style.outline = 'none';
|
6
|
+
elem.style.left = node.rect.x + 'px';
|
7
|
+
elem.style.top = node.rect.y + 'px';
|
8
|
+
elem.style.width = node.rect.width + 'px';
|
9
|
+
elem.style.height = node.rect.height + 'px';
|
10
|
+
if (node.rotate || node.offsetRotate) {
|
11
|
+
elem.style.transform = "rotate(" + (node.rotate + node.offsetRotate) + "deg)";
|
12
|
+
}
|
13
|
+
if (data && data.locked > Lock.None || node.locked > Lock.None) {
|
14
|
+
elem.style.userSelect = 'initial';
|
15
|
+
elem.style.pointerEvents = 'initial';
|
16
|
+
} else {
|
17
|
+
elem.style.userSelect = 'none';
|
18
|
+
elem.style.pointerEvents = 'none';
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
// 创建div
|
23
|
+
export function createDiv(node) {
|
24
|
+
var div = document.createElement('div');
|
25
|
+
div.setAttribute('class', 'topoEchart');
|
26
|
+
div.style.position = 'absolute';
|
27
|
+
div.style.outline = 'none';
|
28
|
+
div.style.left = '-9999px';
|
29
|
+
div.style.bottom = '-9999px';
|
30
|
+
div.style.width = node.rect.width + 'px';
|
31
|
+
div.style.height = node.rect.height + 'px';
|
32
|
+
div.id = node.id;
|
33
|
+
return div;
|
34
|
+
}
|
35
|
+
|
36
|
+
// export function loadJS(url, callback, render) {
|
37
|
+
// var loaderScript = document.createElement('script');
|
38
|
+
// loaderScript.type = 'text/javascript';
|
39
|
+
// loaderScript.src = url;
|
40
|
+
// loaderScript.addEventListener('load', function () {
|
41
|
+
// if (callback) {
|
42
|
+
// callback();
|
43
|
+
// }
|
44
|
+
// // how to do
|
45
|
+
// if (render) {
|
46
|
+
// Store.set('LT:render', true);
|
47
|
+
// }
|
48
|
+
// });
|
49
|
+
// document.body.appendChild(loaderScript);
|
50
|
+
// }
|
51
|
+
|
52
|
+
//# sourceMappingURL=dom.js.map
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// 创建iframe
|
2
|
+
export function createIframeElement(node) {
|
3
|
+
const iframe = document.createElement('iframe');
|
4
|
+
// iframe.scrolling = 'no';
|
5
|
+
iframe.frameBorder = '0';
|
6
|
+
iframe.src = node.iframe;
|
7
|
+
iframe.width = node.rect.width;
|
8
|
+
iframe.height = node.rect.height;
|
9
|
+
iframe.setAttribute('id', node.id);
|
10
|
+
iframe.setAttribute('class', 'topology2dConfIfram');
|
11
|
+
return iframe;
|
12
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Node } from '../models';
|
2
|
+
|
3
|
+
export declare function createSelectElement(node: Node): HTMLDivElement;
|
4
|
+
export declare function createSelectDropdown(node: Node): HTMLDivElement;
|
5
|
+
export declare function createSelectOptions(data: [], node: Node): string;
|
6
|
+
export declare function getSelectedData(e: Event, data: any): void;
|
7
|
+
export declare function setSelectInteractiveState(selected: any, node: Node): void;
|
8
|
+
export declare function resetSelectInteractiveState(node: Node): void;
|
9
|
+
export declare function setSelectDropdownInteractiveState(node: Node, staticType: any, type: any): void;
|
10
|
+
export declare function setSelectElementPosition(node: Node, type: string): void;
|
11
|
+
export declare function setSelectElementTheme(node: Node): void;
|
@@ -0,0 +1,199 @@
|
|
1
|
+
import {
|
2
|
+
elementInteractivePoor,
|
3
|
+
selectDataPool,
|
4
|
+
echartsRealDataPool,
|
5
|
+
echartsOptionsPool
|
6
|
+
} from "../../../store";
|
7
|
+
import { setMapDataOptions } from '../../../chart-diagram';
|
8
|
+
import {previewType, selectStaticType} from '../utils';
|
9
|
+
let nodeId = '';
|
10
|
+
let downId = '';
|
11
|
+
// 创建下拉头
|
12
|
+
export function createSelectElement(node) {
|
13
|
+
const selectEle = document.createElement('div');
|
14
|
+
const inputValue = selectDataPool[node.id].data[0] && selectDataPool[node.id].data[0].name;
|
15
|
+
let attrName = 'topology-select-icon-arrow';
|
16
|
+
if(node.selectDropdown) attrName += ' reverse';
|
17
|
+
const children = `<i class="${attrName}"
|
18
|
+
style="border-width: ${node.font.fontSize/2}px;border-bottom-width: 0;">
|
19
|
+
</i><input type="text" placeholder="请选择" readonly
|
20
|
+
value="${inputValue}"
|
21
|
+
class="topology-select-input"
|
22
|
+
style="font-size: ${node.font.fontSize}px;color: ${node.font.color ? node.font.color : '#fff'}"/>`;
|
23
|
+
const themeType = node.formData.theme ? ` theme${node.formData.theme}` : '';
|
24
|
+
selectEle.setAttribute('id', node.id);
|
25
|
+
selectEle.setAttribute('class', `topology-select${themeType}`);
|
26
|
+
selectEle.innerHTML = children;
|
27
|
+
return selectEle;
|
28
|
+
}
|
29
|
+
// 创建下拉options容器
|
30
|
+
export function createSelectDropdown(node) {
|
31
|
+
const selectDropdownEle = document.createElement('div');
|
32
|
+
let liElements = '';
|
33
|
+
if(node.selectDropdown) {
|
34
|
+
liElements = createSelectOptions(selectDataPool[node.id].data, node);
|
35
|
+
selectDropdownEle.style.display = 'block';
|
36
|
+
setSelectDropdownPosition(node, selectDropdownEle);
|
37
|
+
}
|
38
|
+
const children = `<i class="popper__arrow"></i><ul class="topology-select-dropdown-list">${liElements}</ul>`;
|
39
|
+
const themeType = node.formData.theme ? ` theme${node.formData.theme}` : '';
|
40
|
+
selectDropdownEle.style.width = `${node.rect.width}px`;
|
41
|
+
selectDropdownEle.setAttribute('class', `topology-select-dropdown${themeType} documentDefine`);
|
42
|
+
selectDropdownEle.innerHTML = children;
|
43
|
+
return selectDropdownEle;
|
44
|
+
}
|
45
|
+
// 创建下拉options列表
|
46
|
+
export function createSelectOptions(data, node) {
|
47
|
+
const selectNode = selectDataPool[node.id];
|
48
|
+
const selectDropdownUl = selectNode.dom.selectDropdownUl;
|
49
|
+
if(selectDropdownUl) selectDropdownUl.innerHTML = '';
|
50
|
+
let leElement = '';
|
51
|
+
const order = selectNode.node.selected ? selectNode.node.selected.order : 0;
|
52
|
+
for (let i = 0, length = data.length; i < length; i++) {
|
53
|
+
let selected = i === order ? ' selected' : '';
|
54
|
+
leElement += `<li
|
55
|
+
class="topology-select-dropdown-item${selected}"
|
56
|
+
type="option" data-order="${i}"
|
57
|
+
style="height: ${node.rect.height}px;line-height: ${node.rect.height}px;font-size: ${node.font.fontSize}px;">
|
58
|
+
<span>${data[i].name}</span>
|
59
|
+
</li>`;
|
60
|
+
}
|
61
|
+
if(selectDropdownUl) {
|
62
|
+
selectDropdownUl.innerHTML = leElement;
|
63
|
+
}else {
|
64
|
+
return leElement;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
// 配置下拉头的交互状态:展开时三角图标向上,否则向下
|
68
|
+
export function setSelectInteractiveState(selected, node) {
|
69
|
+
const selectNode = selectDataPool[node.id];
|
70
|
+
selectNode.dom.selectIconArrow.style.display = selected ? 'none' : 'block';
|
71
|
+
//selectNode.dom['selectRemove'].style.display = selected ? 'block' : 'none';
|
72
|
+
}
|
73
|
+
// 重置下拉状态
|
74
|
+
export function resetSelectInteractiveState(node) {
|
75
|
+
if(!Object.keys(selectDataPool).length) return;
|
76
|
+
for (let data of Object.values(selectDataPool)) {
|
77
|
+
if(node && node.id !== data.node.id) {
|
78
|
+
if(data.dom.selectIconArrow) data.dom.selectIconArrow.setAttribute('class', 'topology-select-icon-arrow');
|
79
|
+
data.slideState = false;
|
80
|
+
};
|
81
|
+
}
|
82
|
+
document.querySelector('.topology-select-dropdown').style.display = 'none';
|
83
|
+
elementInteractivePoor.node = null;
|
84
|
+
}
|
85
|
+
// 配置下拉options容器的交互状态,展开和收起
|
86
|
+
export function setSelectDropdownInteractiveState(node, staticType, type) {
|
87
|
+
const selectNode = selectDataPool[node.id];
|
88
|
+
if(!selectNode.staticType) selectNode.staticType = staticType;
|
89
|
+
if(!selectNode) return;
|
90
|
+
if(downId !== node.id && type === previewType.Dcim) {
|
91
|
+
// 点击的不是同一个下拉则重置交互样式,清空数据
|
92
|
+
resetSelectInteractiveState(node);
|
93
|
+
elementInteractivePoor.options = null;
|
94
|
+
}
|
95
|
+
downId = node.id;
|
96
|
+
elementInteractivePoor.node = node;
|
97
|
+
selectElementStore(node.id);
|
98
|
+
setSelectElementPosition(node);
|
99
|
+
const { selectIconArrow, selectDropdown } = selectNode.dom;
|
100
|
+
selectNode.slideState = !selectNode.slideState || node.selectDropdown; // 下拉展开状态
|
101
|
+
let attrName = 'topology-select-icon-arrow';
|
102
|
+
if(selectNode.slideState) {
|
103
|
+
selectDropdown.style.display = 'block';
|
104
|
+
attrName += ' reverse';
|
105
|
+
}else {
|
106
|
+
selectDropdown.style.display = 'none';
|
107
|
+
attrName.replace(' reverse', '');
|
108
|
+
}
|
109
|
+
// 图标旋转
|
110
|
+
selectIconArrow.setAttribute('class', attrName);
|
111
|
+
// 添加列表数据
|
112
|
+
if(!elementInteractivePoor.options) createSelectOptions(selectNode.data, node);
|
113
|
+
}
|
114
|
+
// 配置下拉偏移位置
|
115
|
+
export function setSelectElementPosition(node, type) {
|
116
|
+
// 不同元件切换
|
117
|
+
selectElementStore(node.id);
|
118
|
+
const selectNode = selectDataPool[node.id];
|
119
|
+
if(type === 'down') {
|
120
|
+
if(nodeId === node.id) return;
|
121
|
+
elementInteractivePoor.options = null;
|
122
|
+
createSelectOptions(selectNode.data, node);
|
123
|
+
}
|
124
|
+
nodeId = node.id;
|
125
|
+
setSelectDropdownPosition(node, selectNode.dom.selectDropdown);
|
126
|
+
}
|
127
|
+
function setSelectDropdownPosition(node, selectDropdown) {
|
128
|
+
const selectEle = selectDataPool[node.id].dom.selectEle;
|
129
|
+
let left = selectEle.getBoundingClientRect().left; // 获取下拉元素距离窗体左侧位置
|
130
|
+
let top = selectEle.getBoundingClientRect().top + node.rect.height;
|
131
|
+
if(window.location.pathname.includes('workspace')) {
|
132
|
+
// topol编辑器
|
133
|
+
left = node.rect.x;
|
134
|
+
top = node.rect.y + node.rect.height;
|
135
|
+
}
|
136
|
+
selectDropdown.style.left = `${left}px`;
|
137
|
+
selectDropdown.style.top = `${top}px`;
|
138
|
+
selectDropdown.style.width = `${node.rect.width}px`;
|
139
|
+
const themeType = node.formData.theme ? ` theme${node.formData.theme}` : '';
|
140
|
+
selectDropdown.setAttribute('class', `topology-select-dropdown${themeType} documentDefine`);
|
141
|
+
}
|
142
|
+
// 获取下拉选中的数据
|
143
|
+
export function getSelectedData(e, data) {
|
144
|
+
const selectNode = selectDataPool[data.id];
|
145
|
+
if(!elementInteractivePoor.options) elementInteractivePoor.options = selectNode.dom.selectDropdownUl.querySelectorAll('.topology-select-dropdown-item');
|
146
|
+
const parentNode = e.target.parentNode;
|
147
|
+
const type = parentNode.getAttribute('type');
|
148
|
+
if(type === 'option') {
|
149
|
+
// 选中节点操作
|
150
|
+
const order = parentNode.getAttribute('data-order');
|
151
|
+
selectNode.optionOrder = order;
|
152
|
+
for(let i = 0, leng = elementInteractivePoor.options.length; i < leng; i++) {
|
153
|
+
let name = 'topology-select-dropdown-item';
|
154
|
+
if(i == order) {
|
155
|
+
name += ' selected';
|
156
|
+
}else {
|
157
|
+
name.replace(' selected', '');
|
158
|
+
}
|
159
|
+
elementInteractivePoor.options[i].setAttribute('class', name);
|
160
|
+
}
|
161
|
+
const node = selectNode.data[order];
|
162
|
+
selectNode.dom.selectEle.querySelector('.topology-select-input').value = node.name;
|
163
|
+
selectNode.slideState = false;
|
164
|
+
selectNode.dom.selectDropdown.style.display = 'none';
|
165
|
+
// 图标旋转
|
166
|
+
selectNode.dom.selectIconArrow.setAttribute('class', 'topology-select-icon-arrow');
|
167
|
+
if(selectNode.staticType === selectStaticType.static) {
|
168
|
+
// 数据统计
|
169
|
+
const optionNode = data.formData.bindBlockId && echartsOptionsPool[data.formData.bindBlockId];
|
170
|
+
if(!optionNode) return;
|
171
|
+
// 切换数据
|
172
|
+
echartsRealDataPool[optionNode.data.id] = echartsRealDataPool[node.id];
|
173
|
+
setMapDataOptions(optionNode.option, optionNode.data);
|
174
|
+
selectNode.node.selected = {
|
175
|
+
order: parseInt(order),
|
176
|
+
id: node.id
|
177
|
+
};
|
178
|
+
}else {
|
179
|
+
// 数据展示
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
// 配置下拉展示的主题风格
|
184
|
+
export function setSelectElementTheme(node) {
|
185
|
+
const themeType = node.formData.theme ? ` theme${node.formData.theme}` : '';
|
186
|
+
const { selectEle, selectDropdown } = selectDataPool[node.id].dom;
|
187
|
+
selectEle.setAttribute('class', `topology-select${themeType}`);
|
188
|
+
selectDropdown.setAttribute('class', `topology-select-dropdown${themeType} documentDefine`);
|
189
|
+
}
|
190
|
+
// 存储下拉Dom节点
|
191
|
+
function selectElementStore(id) {
|
192
|
+
const selectNode = selectDataPool[id];
|
193
|
+
if(!selectNode.dom.selectIconArrow) selectNode.dom.selectIconArrow = selectNode.dom.selectEle.querySelector('.topology-select-icon-arrow');
|
194
|
+
if(!selectNode.dom.selectDropdown) {
|
195
|
+
selectNode.dom.selectDropdown = document.querySelector('.topology-select-dropdown');
|
196
|
+
selectNode.dom.selectDropdownUl = document.querySelector('.topology-select-dropdown-list');
|
197
|
+
selectNode.dom.selectDropdownLi = document.querySelectorAll('.topology-select-dropdown-item');
|
198
|
+
}
|
199
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function setElementSwitchTabState(node: any): void;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import {
|
2
|
+
echartsDataPool,
|
3
|
+
elementInteractivePoor,
|
4
|
+
selectDataPool
|
5
|
+
} from '../../../store';
|
6
|
+
import {jsonLength} from '../utils';
|
7
|
+
// 设置tab切换显示隐藏时的 Dom元件状态
|
8
|
+
export function setElementSwitchTabState(node) {
|
9
|
+
if(typeof elementInteractivePoor.elementDataLength !== 'number') {
|
10
|
+
elementInteractivePoor.elementDataLength = jsonLength(echartsDataPool) || jsonLength(selectDataPool);
|
11
|
+
}
|
12
|
+
if(!elementInteractivePoor.elementDataLength) return;
|
13
|
+
const ele = echartsDataPool[node.id] && echartsDataPool[node.id].div ||
|
14
|
+
selectDataPool[node.id] && selectDataPool[node.id].dom.selectEle;
|
15
|
+
if(ele) ele.style.display = !node.visible ? 'none': 'block';
|
16
|
+
if(node.children && node.children.length) {
|
17
|
+
node.children.map((ch) => {
|
18
|
+
ch.visible = node.visible;
|
19
|
+
setElementSwitchTabState(ch);
|
20
|
+
})
|
21
|
+
}
|
22
|
+
}
|