dcim-topology2d 1.1.5 → 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/calling.js +3 -0
- package/core/src/canvas.js +1 -0
- package/core/src/common.d.ts +1 -2
- package/core/src/common.js +124 -614
- package/core/src/core.js +65 -49
- package/core/src/divLayer.d.ts +0 -3
- package/core/src/divLayer.js +14 -32
- 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 +25 -22
- package/core/src/models/pen.js +7 -8
- 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 +19 -17
- package/core/src/store/data.js +38 -12
- package/core/src/utils/assignment.d.ts +6 -0
- package/core/src/utils/assignment.js +138 -0
- 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 +2 -1
- package/core/src/utils/index.js +2 -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;
|
@@ -47,7 +59,6 @@ var Topology = (function (_super) {
|
|
47
59
|
close: false, //闭合
|
48
60
|
};
|
49
61
|
_this.onMouseMove = function (e) {
|
50
|
-
_this.store.data.dataResize = 0;
|
51
62
|
if (Store.get('addingArbitraryGraph')) {
|
52
63
|
return
|
53
64
|
}
|
@@ -179,12 +190,13 @@ var Topology = (function (_super) {
|
|
179
190
|
if ((moveLeft || moveTop)) {
|
180
191
|
_this.scroll(moveLeft ? -100 : 0, moveTop ? -100 : 0);
|
181
192
|
}
|
182
|
-
//
|
193
|
+
//console.log('_this.moveIn.type----', _this.moveIn.type)
|
183
194
|
switch (_this.moveIn.type) {
|
184
195
|
case _this.moveInType.None:
|
185
196
|
_this.hoverLayer.dragRect = new Rect(_this.mouseDown.x, _this.mouseDown.y, pos.x - _this.mouseDown.x, pos.y - _this.mouseDown.y);
|
186
197
|
break;
|
187
198
|
case _this.moveInType.Nodes:
|
199
|
+
_this.store.data.dataResize = 0;
|
188
200
|
if (_this.activeLayer.locked()) {
|
189
201
|
break;
|
190
202
|
}
|
@@ -195,8 +207,15 @@ 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:
|
218
|
+
_this.store.data.dataResize = 1;
|
200
219
|
var p1 = new Point(_this.mouseDown.x, _this.mouseDown.y);
|
201
220
|
var p2 = new Point(pos.x, pos.y);
|
202
221
|
var offsetX = p2.x - p1.x;
|
@@ -244,8 +263,11 @@ var Topology = (function (_super) {
|
|
244
263
|
}
|
245
264
|
}
|
246
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]);
|
247
269
|
_this.activeLayer.resize(_this.moveIn.activeAnchorIndex, _this.mouseDown, pos);
|
248
|
-
_this.dispatch('resizePens',
|
270
|
+
_this.dispatch('resizePens', activeLayerPens);
|
249
271
|
_this.needCache = true;
|
250
272
|
}
|
251
273
|
break;
|
@@ -443,9 +465,8 @@ var Topology = (function (_super) {
|
|
443
465
|
const activeNode = _this.moveIn.activeNode;
|
444
466
|
if (!_this.checkNodeOfClickType(activeNode)) {
|
445
467
|
_this.activeLayer.setPens([activeNode]);
|
446
|
-
if
|
447
|
-
|
448
|
-
} else if (activeNode && activeNode.name == 'tablePagination') {
|
468
|
+
if(activeNode.name === elementType.select && activeNode.selectDropdown) setSelectElementPosition(activeNode, 'down');
|
469
|
+
if(activeNode.name == 'tablePagination') {
|
449
470
|
if (_this.store.options.type === 'topology') return _this.dispatch('node', activeNode);
|
450
471
|
const pnlKeys = Object.keys(activeNode.paginationData.pageNumberLocals);
|
451
472
|
const pageNumArea = pnlKeys.find((pna) => {
|
@@ -459,16 +480,8 @@ var Topology = (function (_super) {
|
|
459
480
|
if (activeNode.paginationData.pageListState) _this.spreadPageListHandle(activeNode, e);
|
460
481
|
if (activeNode.paginationData.targetPageLocal.hide) _this.targetPageInputHandle(activeNode, e);
|
461
482
|
}
|
462
|
-
}
|
483
|
+
}else {
|
463
484
|
_this.dispatch('node', activeNode);
|
464
|
-
if(!window.location.pathname.includes('workspace')) {
|
465
|
-
const staticTypeNode = activeNode.events.find((ev) => {
|
466
|
-
return parseInt(ev.action) === 8
|
467
|
-
}); // 若绑定的是echarts统计图事件
|
468
|
-
if (staticTypeNode) {
|
469
|
-
_this.switchStaticsCheckType(activeNode, staticTypeNode);
|
470
|
-
}
|
471
|
-
}
|
472
485
|
}
|
473
486
|
}
|
474
487
|
}
|
@@ -562,7 +575,7 @@ var Topology = (function (_super) {
|
|
562
575
|
_this.needCache = false;
|
563
576
|
};
|
564
577
|
_this.onkeydown = function (key) {
|
565
|
-
if (_this.store.data.locked ||
|
578
|
+
if (_this.store && _this.store.data.locked ||
|
566
579
|
key.target.tagName === 'INPUT' ||
|
567
580
|
key.target.tagName === 'TEXTAREA') {
|
568
581
|
return;
|
@@ -987,7 +1000,7 @@ var Topology = (function (_super) {
|
|
987
1000
|
node.scale(this.store.data.scale);
|
988
1001
|
}
|
989
1002
|
this.store.data.pens.push(node);
|
990
|
-
|
1003
|
+
initSwitchTabData(node);
|
991
1004
|
if (focus) {
|
992
1005
|
this.render();
|
993
1006
|
this.animate(true);
|
@@ -1563,7 +1576,7 @@ var Topology = (function (_super) {
|
|
1563
1576
|
this.delEmptyLines(pen.id);
|
1564
1577
|
}
|
1565
1578
|
pens.push.apply(pens, this.store.data.pens.splice(found, 1));
|
1566
|
-
this.setSwitchTabData(pen, found, 'delete');
|
1579
|
+
// this.setSwitchTabData(pen, found, 'delete');
|
1567
1580
|
--i;
|
1568
1581
|
}
|
1569
1582
|
this.animateLayer.pens.delete(pen.id);
|
@@ -1695,7 +1708,7 @@ var Topology = (function (_super) {
|
|
1695
1708
|
}
|
1696
1709
|
this.store.data.pens.push(pen);
|
1697
1710
|
this.activeLayer.add(pen);
|
1698
|
-
|
1711
|
+
initSwitchTabData(pen);
|
1699
1712
|
}
|
1700
1713
|
this.render();
|
1701
1714
|
this.animate(true);
|
@@ -1719,8 +1732,8 @@ var Topology = (function (_super) {
|
|
1719
1732
|
};
|
1720
1733
|
for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
|
1721
1734
|
var pen = _a[_i];
|
1722
|
-
pen.data = []
|
1723
|
-
this.bindInfo(item, pen, dataType, index)
|
1735
|
+
pen.data = [];
|
1736
|
+
this.bindInfo(item, pen, dataType, index);
|
1724
1737
|
this.clipboard.pens.push(pen.clone());
|
1725
1738
|
}
|
1726
1739
|
if (exite == true) {
|
@@ -1728,22 +1741,23 @@ var Topology = (function (_super) {
|
|
1728
1741
|
}
|
1729
1742
|
};
|
1730
1743
|
Topology.prototype.bindInfo = async function (item, pen, type, index) {
|
1744
|
+
const itemNode = item && item.default || item;
|
1731
1745
|
if ([0, '0'].includes(type)) {
|
1732
|
-
const setTagId = setTagIdData(
|
1746
|
+
const setTagId = setTagIdData(itemNode);
|
1733
1747
|
pen.data.push(...setTagId);
|
1734
1748
|
// 绑定悬浮文字
|
1735
|
-
pen.title =
|
1749
|
+
pen.title = itemNode.touchpname
|
1736
1750
|
//用于处理场地监控,点击一个资产类别后,隐藏掉这个类别下的所有元件
|
1737
|
-
const setThreeCategory = setThreeCategoryIdData(pen,
|
1751
|
+
const setThreeCategory = setThreeCategoryIdData(pen, itemNode);
|
1738
1752
|
pen.data.push(...setThreeCategory);
|
1739
1753
|
} else if ([1, '1'].includes(type)) {
|
1740
|
-
const setKpiAddr = setKpiAddrData(
|
1754
|
+
const setKpiAddr = setKpiAddrData(itemNode);
|
1741
1755
|
pen.data.push(...setKpiAddr);
|
1742
1756
|
} else if ([2, '2'].includes(type)) {
|
1743
|
-
const setAssetId = setAssetIdData(
|
1757
|
+
const setAssetId = setAssetIdData(itemNode);
|
1744
1758
|
pen.data.push(...setAssetId);
|
1745
1759
|
// 绑定悬浮文字
|
1746
|
-
pen.title =
|
1760
|
+
pen.title = itemNode.bak
|
1747
1761
|
if (pen.subName && pen.subName == 'temp') {
|
1748
1762
|
// 温湿度元件
|
1749
1763
|
// 通讯状态
|
@@ -1751,23 +1765,19 @@ var Topology = (function (_super) {
|
|
1751
1765
|
if (index > 0) {
|
1752
1766
|
pen.children[0].text = index + 1 + '#'
|
1753
1767
|
}
|
1754
|
-
this.bindInfo(
|
1755
|
-
//
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
}
|
1768
|
-
})
|
1769
|
-
pen.children.forEach((item) => {
|
1770
|
-
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 = [{
|
1771
1781
|
"type": 3,
|
1772
1782
|
"action": 2,
|
1773
1783
|
"value": "",
|
@@ -1776,16 +1786,19 @@ var Topology = (function (_super) {
|
|
1776
1786
|
})
|
1777
1787
|
}
|
1778
1788
|
} else if ([3, '3'].includes(type)) {
|
1779
|
-
const setAreaId = setAreaIdData(
|
1789
|
+
const setAreaId = setAreaIdData(itemNode);
|
1780
1790
|
pen.data.push(...setAreaId);
|
1791
|
+
}else if ([4, '4'].includes(type)) {
|
1792
|
+
const setVarId = setVarValueData(itemNode);
|
1793
|
+
pen.data.push(...setVarId);
|
1781
1794
|
}
|
1782
1795
|
// if([0, 2, '0', '2'].includes(type)) {
|
1783
1796
|
// //用于处理场地监控,点击一个资产类别后,隐藏掉这个类别下的所有元件
|
1784
|
-
// const setThreeCategory = setThreeCategoryIdData(pen,
|
1797
|
+
// const setThreeCategory = setThreeCategoryIdData(pen, itemNode);
|
1785
1798
|
//
|
1786
1799
|
// pen.data.push(...setThreeCategory);
|
1787
1800
|
// }
|
1788
|
-
return pen
|
1801
|
+
return pen;
|
1789
1802
|
};
|
1790
1803
|
Topology.prototype.newId = function (node, idMaps) {
|
1791
1804
|
var old = node.id;
|
@@ -1805,10 +1818,12 @@ var Topology = (function (_super) {
|
|
1805
1818
|
if (!pens) {
|
1806
1819
|
pens = this.activeLayer.pens;
|
1807
1820
|
}
|
1821
|
+
let isAnimate = false;
|
1808
1822
|
for (var _i = 0, pens_1 = pens; _i < pens_1.length; _i++) {
|
1809
1823
|
var pen = pens_1[_i];
|
1810
1824
|
if (pen instanceof Node) {
|
1811
1825
|
let isRotateBug = false
|
1826
|
+
isAnimate = pen.animateFrames && pen.animateFrames.length
|
1812
1827
|
if (pen.rotate === 0) {
|
1813
1828
|
pen.rotate = 360
|
1814
1829
|
isRotateBug = true
|
@@ -1827,6 +1842,7 @@ var Topology = (function (_super) {
|
|
1827
1842
|
this.activeLayer.calcControlPoints();
|
1828
1843
|
this.activeLayer.saveNodeRects();
|
1829
1844
|
this.render();
|
1845
|
+
if(isAnimate) this.animate(true);
|
1830
1846
|
// tslint:disable-next-line: no-unused-expression
|
1831
1847
|
cache && this.cache();
|
1832
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,11 +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
|
-
|
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]);
|
83
|
+
}
|
92
84
|
};
|
93
85
|
DivLayer.prototype.addGif = function (node) {
|
94
86
|
this.gifs[node.id] = node.img;
|
@@ -96,21 +88,18 @@ var DivLayer = /** @class */ (function (_super) {
|
|
96
88
|
return node.img;
|
97
89
|
};
|
98
90
|
DivLayer.prototype.setElemPosition = function (node, elem) {
|
99
|
-
|
91
|
+
setStyleForElementIdDiv(node, elem, commonStore[this.TID].data);
|
100
92
|
};
|
101
93
|
DivLayer.prototype.removeDiv = function (item) {
|
102
94
|
if (this.curNode && item.id === this.curNode.id) {
|
103
95
|
this.curNode = null;
|
104
96
|
}
|
105
|
-
if (item.iframe) {
|
106
|
-
const iframesNode = this.iframes[item.id] || DomIframes[item.id];
|
107
|
-
commonStore[item.TID].parentElem.removeChild(iframesNode);
|
108
|
-
this.iframes[item.id] ? this.iframes[item.id] = null : DomIframes[item.id] = null;
|
109
|
-
}
|
110
97
|
if (item.elementId) {
|
111
|
-
const elementNode = this.elements[item.id]
|
112
|
-
|
113
|
-
|
98
|
+
const elementNode = this.elements[item.id];
|
99
|
+
if(elementNode) {
|
100
|
+
this.canvas.parentElement.removeChild(elementNode);
|
101
|
+
this.elements[item.id] = null;
|
102
|
+
}
|
114
103
|
}
|
115
104
|
if (item.gif) {
|
116
105
|
this.canvas.removeChild(this.gifs[item.id]);
|
@@ -128,15 +117,8 @@ var DivLayer = /** @class */ (function (_super) {
|
|
128
117
|
};
|
129
118
|
DivLayer.prototype.clear = function () {
|
130
119
|
this.canvas.innerHTML = '';
|
131
|
-
this.iframes = {};
|
132
120
|
this.elements = {};
|
133
121
|
this.gifs = {};
|
134
|
-
for (let key in DomIframes) {
|
135
|
-
delete DomIframes[key];
|
136
|
-
}
|
137
|
-
for (let key in DomElements) {
|
138
|
-
delete DomElements[key];
|
139
|
-
}
|
140
122
|
// tslint:disable-next-line:forin
|
141
123
|
for (let key in images) {
|
142
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
|
+
}
|