dcim-topology2d 1.0.3 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/chart-diagram/src/echarts/index.js +3 -6
  2. package/core/index.d.ts +1 -0
  3. package/core/index.js +1 -0
  4. package/core/src/activeLayer.d.ts +2 -10
  5. package/core/src/activeLayer.js +42 -41
  6. package/core/src/animateLayer.d.ts +3 -7
  7. package/core/src/animateLayer.js +10 -12
  8. package/core/src/calling.d.ts +1 -4
  9. package/core/src/calling.js +38 -41
  10. package/core/src/canvas.d.ts +1 -6
  11. package/core/src/canvas.js +17 -18
  12. package/core/src/common.d.ts +5 -5
  13. package/core/src/common.js +147 -110
  14. package/core/src/core.d.ts +3 -4
  15. package/core/src/core.js +222 -251
  16. package/core/src/divLayer.d.ts +2 -7
  17. package/core/src/divLayer.js +25 -25
  18. package/core/src/healps/changeData.d.ts +1 -1
  19. package/core/src/healps/changeData.js +31 -11
  20. package/core/src/hoverLayer.d.ts +2 -9
  21. package/core/src/hoverLayer.js +31 -34
  22. package/core/src/models/index.d.ts +0 -1
  23. package/core/src/models/index.js +0 -1
  24. package/core/src/offscreen.d.ts +1 -4
  25. package/core/src/offscreen.js +10 -8
  26. package/core/src/options.js +1 -0
  27. package/core/src/preview.d.ts +1 -13
  28. package/core/src/preview.js +26 -27
  29. package/core/src/renderLayer.d.ts +1 -3
  30. package/core/src/renderLayer.js +26 -31
  31. package/core/src/store/common.d.ts +9 -0
  32. package/core/src/store/common.js +5 -0
  33. package/core/src/store/data.d.ts +126 -0
  34. package/core/src/store/data.js +80 -0
  35. package/core/src/store/index.d.ts +2 -0
  36. package/core/src/store/index.js +2 -0
  37. package/core/src/utils/conversion.d.ts +7 -0
  38. package/core/src/utils/conversion.js +54 -0
  39. package/core/src/utils/dom.d.ts +4 -3
  40. package/core/src/utils/dom.js +2 -0
  41. package/package.json +1 -1
  42. package/core/src/models/data.d.ts +0 -26
  43. package/core/src/models/data.js +0 -77
  44. package/core/src/models/data.js.map +0 -1
  45. package/core/src/mqtt.d.ts +0 -14
  46. package/core/src/mqtt.js +0 -82
  47. package/core/src/mqtt.js.map +0 -1
  48. package/core/src/socket.d.ts +0 -10
  49. package/core/src/socket.js +0 -51
  50. package/core/src/socket.js.map +0 -1
package/core/src/core.js CHANGED
@@ -16,9 +16,9 @@ import { Common } from './common'
16
16
  import {HoverLayer} from './hoverLayer';
17
17
  import {ActiveLayer} from './activeLayer';
18
18
  import {KeyType, KeydownType} from './options';
19
- import {PenType, Node, Point, Line, TopologyData, Lock, AnchorMode, Rect} from './models';
19
+ import {PenType, Node, Point, Line, Lock, AnchorMode, Rect} from './models';
20
20
  import {drawNodeFns, drawLineFns} from './middles/index';
21
- import { s8, pointInRect, formatPadding, previewType} from './utils';
21
+ import { s8, pointInRect, formatPadding, setTagIdData, setKpiAddrData, setAssetIdData, setAreaIdData, setThreeCategoryIdData} from './utils';
22
22
  import axios from 'axios'
23
23
 
24
24
  var resizeCursors = ['nw-resize', 'ne-resize', 'se-resize', 'sw-resize'];
@@ -27,8 +27,8 @@ var Topology = (function (_super) {
27
27
  __extends(Topology, _super);
28
28
  function Topology(parent, options) {
29
29
  var _this = _super.call(this, parent, options) || this;
30
- _this.hoverLayer = new HoverLayer(this.options, _this.id);
31
- _this.activeLayer = new ActiveLayer(this.options, _this.id);
30
+ _this.hoverLayer = new HoverLayer(_this.id);
31
+ _this.activeLayer = new ActiveLayer(_this.id);
32
32
  _this.offscreen.getRoutineLayer();
33
33
  _this.activeLayer.topology = this;
34
34
  _this.gridElem = document.createElement('div');
@@ -50,7 +50,7 @@ var Topology = (function (_super) {
50
50
  if (Store.get('addingArbitraryGraph')) {
51
51
  return
52
52
  }
53
- if (_this.scheduledAnimationFrame || _this.data.locked === Lock.NoEvent) {
53
+ if (_this.scheduledAnimationFrame || _this.store.data.locked === Lock.NoEvent) {
54
54
  return;
55
55
  }
56
56
  // https://caniuse.com/#feat=mdn-api_mouseevent_buttons
@@ -61,7 +61,7 @@ var Topology = (function (_super) {
61
61
  }
62
62
  if (_this.mouseDown) {
63
63
  var b = false;
64
- switch (_this.options.translateKey) {
64
+ switch (_this.store.options.translateKey) {
65
65
  case KeyType.None:
66
66
  b = true;
67
67
  break;
@@ -96,7 +96,7 @@ var Topology = (function (_super) {
96
96
  return false;
97
97
  }
98
98
  }
99
- if (_this.data.locked && _this.mouseDown) {
99
+ if (_this.store.data.locked && _this.mouseDown) {
100
100
  return;
101
101
  }
102
102
  _this.scheduledAnimationFrame = true;
@@ -150,18 +150,18 @@ var Topology = (function (_super) {
150
150
  return;
151
151
  }
152
152
  // Move out parent element.
153
- var moveOutX = pos.x + 50 > _this.parentElem.clientWidth + _this.parentElem.scrollLeft;
154
- var moveOutY = pos.y + 50 > _this.parentElem.clientHeight + _this.parentElem.scrollTop;
155
- if (!_this.options.disableMoveOutParent && (moveOutX || moveOutY)) {
153
+ var moveOutX = pos.x + 50 > _this.store.parentElem.clientWidth + _this.store.parentElem.scrollLeft;
154
+ var moveOutY = pos.y + 50 > _this.store.parentElem.clientHeight + _this.store.parentElem.scrollTop;
155
+ if (!_this.store.options.disableMoveOutParent && (moveOutX || moveOutY)) {
156
156
  _this.dispatch('moveOutParent', pos);
157
- if (_this.options.autoExpandDistance > 0) {
157
+ if (_this.store.options.autoExpandDistance > 0) {
158
158
  var resize = false;
159
159
  if (pos.x + 50 > _this.divLayer.canvas.clientWidth) {
160
- _this.canvas.width += _this.options.autoExpandDistance;
160
+ _this.canvas.width += _this.store.options.autoExpandDistance;
161
161
  resize = true;
162
162
  }
163
163
  if (pos.y + 50 > _this.divLayer.canvas.clientHeight) {
164
- _this.canvas.height += _this.options.autoExpandDistance;
164
+ _this.canvas.height += _this.store.options.autoExpandDistance;
165
165
  resize = true;
166
166
  }
167
167
  if (resize) {
@@ -170,11 +170,11 @@ var Topology = (function (_super) {
170
170
  height: _this.canvas.height,
171
171
  });
172
172
  }
173
- _this.scroll(moveOutX ? _this.options.autoExpandDistance / 2 : 0, moveOutY ? _this.options.autoExpandDistance / 2 : 0);
173
+ _this.scroll(moveOutX ? _this.store.options.autoExpandDistance / 2 : 0, moveOutY ? _this.store.options.autoExpandDistance / 2 : 0);
174
174
  }
175
175
  }
176
- var moveLeft = pos.x - 100 < _this.parentElem.scrollLeft;
177
- var moveTop = pos.y - 100 < _this.parentElem.scrollTop;
176
+ var moveLeft = pos.x - 100 < _this.store.parentElem.scrollLeft;
177
+ var moveTop = pos.y - 100 < _this.store.parentElem.scrollTop;
178
178
  if ((moveLeft || moveTop)) {
179
179
  _this.scroll(moveLeft ? -100 : 0, moveTop ? -100 : 0);
180
180
  }
@@ -285,7 +285,7 @@ var Topology = (function (_super) {
285
285
 
286
286
  } else {
287
287
 
288
- var arrow = _this.data.toArrowType;
288
+ var arrow = _this.store.data.toArrowType;
289
289
  if (_this.moveIn.hoverLine) {
290
290
  arrow = _this.moveIn.hoverLine.toArrow;
291
291
  }
@@ -375,7 +375,7 @@ var Topology = (function (_super) {
375
375
  break;
376
376
  case _this.moveInType.LineMove:
377
377
  _this.hoverLayer.initLine = new Line(_this.moveIn.hoverLine);
378
- if (_this.data.locked || _this.moveIn.hoverLine.locked) {
378
+ if (_this.store.data.locked || _this.moveIn.hoverLine.locked) {
379
379
  _this.moveIn.hoverLine.click();
380
380
  }
381
381
  // tslint:disable-next-line:no-switch-case-fall-through
@@ -393,12 +393,12 @@ var Topology = (function (_super) {
393
393
 
394
394
  } else {
395
395
  _this.hoverLayer.line = _this.addLine({
396
- name: _this.data.lineName,
396
+ name: _this.store.data.lineName,
397
397
  from: new Point(_this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].x, _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].y, _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].direction, _this.moveIn.hoverAnchorIndex, _this.moveIn.hoverNode.id),
398
- fromArrow: _this.data.fromArrowType,
398
+ fromArrow: _this.store.data.fromArrowType,
399
399
  to: new Point(_this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].x, _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex].y),
400
- toArrow: _this.data.toArrowType,
401
- strokeStyle: _this.options.color,
400
+ toArrow: _this.store.data.toArrowType,
401
+ strokeStyle: _this.store.options.color,
402
402
  });
403
403
  _this.dispatch('anchor', {
404
404
  anchor: _this.moveIn.hoverNode.rotatedAnchors[_this.moveIn.hoverAnchorIndex],
@@ -444,7 +444,7 @@ var Topology = (function (_super) {
444
444
  if (activeNode && activeNode.name == 'arbitraryGraph') {
445
445
  _this.dispatch('node', activeNode);
446
446
  } else if (activeNode && activeNode.name == 'tablePagination') {
447
- if (_this.options.type === 'topology') return _this.dispatch('node', activeNode);
447
+ if (_this.store.options.type === 'topology') return _this.dispatch('node', activeNode);
448
448
  const pnlKeys = Object.keys(activeNode.paginationData.pageNumberLocals);
449
449
  const pageNumArea = pnlKeys.find((pna) => {
450
450
  return e.offsetX - 32 < pna && e.offsetX - parseInt(pna) > 0
@@ -470,7 +470,7 @@ var Topology = (function (_super) {
470
470
  }
471
471
  }
472
472
  }
473
- if (_this.data.locked || _this.moveIn.activeNode.locked) {
473
+ if (_this.store.data.locked || _this.moveIn.activeNode.locked) {
474
474
  _this.moveIn.activeNode.click();
475
475
  }
476
476
  break;
@@ -511,10 +511,10 @@ var Topology = (function (_super) {
511
511
  if (_this.hoverLayer.line) {
512
512
  var willAddLine = void 0;
513
513
  if (_this.hoverLayer.line.to.id) {
514
- if (!_this.options.disableRepeatLine) {
514
+ if (!_this.store.options.disableRepeatLine) {
515
515
  willAddLine = true;
516
516
  } else {
517
- var lines = _this.data.pens.filter(function (pen) {
517
+ var lines = _this.store.data.pens.filter(function (pen) {
518
518
  return pen.type === PenType.Line &&
519
519
  pen.from.isSameAs(_this.hoverLayer.line.from) &&
520
520
  pen.to.isSameAs(_this.hoverLayer.line.to);
@@ -522,13 +522,13 @@ var Topology = (function (_super) {
522
522
  willAddLine = lines.length <= 1;
523
523
  }
524
524
  } else {
525
- willAddLine = !_this.options.disableEmptyLine;
525
+ willAddLine = !_this.store.options.disableEmptyLine;
526
526
  }
527
527
  if (willAddLine) {
528
528
  _this.activeLayer.pens = [_this.hoverLayer.line];
529
529
  _this.dispatch('addLine', _this.hoverLayer.line);
530
530
  } else {
531
- _this.data.pens.pop();
531
+ _this.store.data.pens.pop();
532
532
  _this.activeLayer.clear();
533
533
  }
534
534
  }
@@ -547,7 +547,7 @@ var Topology = (function (_super) {
547
547
  (!_this.hoverLayer.line.from.id || !_this.hoverLayer.line.to.id)) {
548
548
  _this.needCache = true;
549
549
  _this.activeLayer.clear();
550
- _this.data.pens.splice(_this.findIndex(_this.hoverLayer.line), 1);
550
+ _this.store.data.pens.splice(_this.findIndex(_this.hoverLayer.line), 1);
551
551
  }
552
552
  break;
553
553
  }
@@ -560,7 +560,7 @@ var Topology = (function (_super) {
560
560
  _this.needCache = false;
561
561
  };
562
562
  _this.onkeydown = function (key) {
563
- if (_this.data.locked ||
563
+ if (_this.store.data.locked ||
564
564
  key.target.tagName === 'INPUT' ||
565
565
  key.target.tagName === 'TEXTAREA') {
566
566
  return;
@@ -571,7 +571,7 @@ var Topology = (function (_super) {
571
571
  switch (key.key) {
572
572
  case 'a':
573
573
  case 'A':
574
- _this.activeLayer.setPens(_this.data.pens);
574
+ _this.activeLayer.setPens(_this.store.data.pens);
575
575
  _this.dispatch('multi', _this.activeLayer.pens);
576
576
  done = true;
577
577
  break;
@@ -709,7 +709,7 @@ var Topology = (function (_super) {
709
709
  }
710
710
  };
711
711
  _this.subcribeAnimateMoved = Store.subscribe(this.generateStoreKey('LT:rectChanged'), function (e) {
712
- _this.activeLayer.updateLines(_this.data.pens);
712
+ _this.activeLayer.updateLines(_this.store.data.pens);
713
713
  });
714
714
  _this.subcribeMediaEnd = Store.subscribe(this.generateStoreKey('mediaEnd'), function (node) {
715
715
  if (node.nextPlay) {
@@ -722,7 +722,7 @@ var Topology = (function (_super) {
722
722
  if (window.location.pathname.includes('workspace')) {
723
723
  return
724
724
  }
725
- _this.hidePenByTag(_this.data.pens, e);
725
+ _this.hidePenByTag(_this.store.data.pens, e);
726
726
  const obj = e ? JSON.parse(e) : {}
727
727
  const visibleRange = obj.visibleRange
728
728
  if (visibleRange == '1') {
@@ -733,10 +733,10 @@ var Topology = (function (_super) {
733
733
  _this.divLayer.canvas.onmousedown = this.onmousedown;
734
734
  _this.divLayer.canvas.onmouseup = this.onmouseup;
735
735
  _this.divLayer.canvas.onwheel = function (event) {
736
- if (_this.options.disableScale) {
736
+ if (_this.store.options.disableScale) {
737
737
  return;
738
738
  }
739
- switch (_this.options.scaleKey) {
739
+ switch (_this.store.options.scaleKey) {
740
740
  case KeyType.None:
741
741
  break;
742
742
  case KeyType.Ctrl:
@@ -771,17 +771,17 @@ var Topology = (function (_super) {
771
771
  } else {
772
772
  if (event.layerX && event.layerY) {
773
773
  _this.scale(0.9, {x: event.layerX, y: event.layerY});
774
- _this.canvas.scale(0.9, {x: event.layerX, y: event.layerY});
774
+ _this.canvas.scale(0.9, {x: event.layerX, y: event.layerY});
775
775
  } else {
776
776
  _this.scale(0.9);
777
- _this.canvas.scale(0.9);
777
+ _this.canvas.scale(0.9);
778
778
  }
779
779
  }
780
780
  _this.divLayer.canvas.focus();
781
781
  return false;
782
782
  };
783
783
  _this.cache();
784
- switch (_this.options.keydown) {
784
+ switch (_this.store.options.keydown) {
785
785
  case KeydownType.Document:
786
786
  document.onkeydown = _this.onkeydown;
787
787
  break;
@@ -795,6 +795,7 @@ var Topology = (function (_super) {
795
795
  clearTimeout(timer);
796
796
  }
797
797
  timer = setTimeout(function () {
798
+ _this.resize();
798
799
  _this.overflow();
799
800
  _this.render();
800
801
  }, 100);
@@ -803,26 +804,26 @@ var Topology = (function (_super) {
803
804
  return _this;
804
805
  }
805
806
  // Render or redraw
806
- Topology.prototype.render = function (noFocus, type) {
807
- try{
808
- if (noFocus === void 0) {
809
- noFocus = false;
810
- }
811
- if (noFocus) {
812
- this.activeLayer.pens = [];
813
- this.hoverLayer.node = null;
814
- this.hoverLayer.line = null;
815
- }
816
- if (this.rendering) {
817
- return this;
818
- }
819
- this.rendering = true;
820
- this.offscreen.render();
821
- this.canvas.render();
822
- this.rendering = false;
823
- }catch (e){
824
- console.log('render-error-------------')
825
- }
807
+ Topology.prototype.render = function (noFocus) {
808
+ try{
809
+ if (noFocus === void 0) {
810
+ noFocus = false;
811
+ }
812
+ if (noFocus) {
813
+ this.activeLayer.pens = [];
814
+ this.hoverLayer.node = null;
815
+ this.hoverLayer.line = null;
816
+ }
817
+ if (this.rendering) {
818
+ return this;
819
+ }
820
+ this.rendering = true;
821
+ this.offscreen.render();
822
+ this.canvas.render();
823
+ this.rendering = false;
824
+ }catch (e){
825
+ //console.log('render-error-------------', e)
826
+ }
826
827
  };
827
828
  Topology.prototype.resize = function (size) {
828
829
  this.canvasResize(size);
@@ -852,12 +853,12 @@ var Topology = (function (_super) {
852
853
  }
853
854
  if (json.name === 'lineAlone') {
854
855
  _this.addLine({
855
- name: _this.data.lineName,
856
+ name: _this.store.data.lineName,
856
857
  from: new Point(json.rect.x, json.rect.y),
857
- fromArrow: _this.data.fromArrowType,
858
+ fromArrow: _this.store.data.fromArrowType,
858
859
  to: new Point(json.rect.x + json.rect.width, json.rect.y + json.rect.height),
859
- toArrow: _this.data.toArrowType,
860
- strokeStyle: _this.options.color,
860
+ toArrow: _this.store.data.toArrowType,
861
+ strokeStyle: _this.store.options.color,
861
862
  }, true);
862
863
  }
863
864
 
@@ -866,7 +867,7 @@ var Topology = (function (_super) {
866
867
  // console.log('创建自定义组件 ', json);
867
868
 
868
869
  console.log('store 中的 自定义 ', Store.get('defineNode'));
869
- if (_this.data.locked) return
870
+ if (_this.store.data.locked) return
870
871
  // let defineNode = Store.get('defineNode');
871
872
  // let nodesList = Store.get('defineNode').pens;
872
873
  let defineNode = JSON.parse(localStorage.getItem("defineNode_"))
@@ -888,7 +889,7 @@ var Topology = (function (_super) {
888
889
 
889
890
  // console.log('push之前的node', node);
890
891
 
891
- _this.data.pens.push(node);
892
+ _this.store.data.pens.push(node);
892
893
 
893
894
  renderNodesList.push(node);
894
895
  }
@@ -911,7 +912,7 @@ var Topology = (function (_super) {
911
912
  _this.dispatch('LT:addDiv', node);
912
913
  }
913
914
  if (node.name === 'formTable') {
914
- _this.data.dataConstruct[node.id] = {
915
+ _this.store.data.dataConstruct[node.id] = {
915
916
  id: node.id,
916
917
  name: 'table'
917
918
  }
@@ -924,26 +925,26 @@ var Topology = (function (_super) {
924
925
  if (focus === void 0) {
925
926
  focus = false;
926
927
  }
927
- if (this.data.locked || !drawNodeFns[node.name]) {
928
+ if (this.store.data.locked || !drawNodeFns[node.name]) {
928
929
  return null;
929
930
  }
930
931
  // if it's not a Node
931
932
  if (!node.init) {
932
933
  node = new Node(node);
933
934
  }
934
- if (!node.strokeStyle && this.options.color) {
935
- node.strokeStyle = this.options.color;
935
+ if (!node.strokeStyle && this.store.options.color) {
936
+ node.strokeStyle = this.store.options.color;
936
937
  }
937
938
  for (var key in node.font) {
938
939
  if (!node.font[key]) {
939
- node.font[key] = this.options.font[key];
940
+ node.font[key] = this.store.options.font[key];
940
941
  }
941
942
  }
942
- if (this.data.scale !== 1) {
943
- node.scale(this.data.scale);
943
+ if (this.store.data.scale !== 1) {
944
+ node.scale(this.store.data.scale);
944
945
  }
945
- this.data.pens.push(node);
946
- this.setSwitchTabData(node, this.data.pens.length-1);
946
+ this.store.data.pens.push(node);
947
+ this.setSwitchTabData(node, this.store.data.pens.length-1);
947
948
  if (focus) {
948
949
  this.activeLayer.setPens([node]);
949
950
  this.render();
@@ -957,14 +958,14 @@ var Topology = (function (_super) {
957
958
  if (focus === void 0) {
958
959
  focus = false;
959
960
  }
960
- if (this.data.locked) {
961
+ if (this.store.data.locked) {
961
962
  return null;
962
963
  }
963
964
  if (!line.clone) {
964
965
  line = new Line(line);
965
966
  line.calcControlPoints(true);
966
967
  }
967
- this.data.pens.push(line);
968
+ this.store.data.pens.push(line);
968
969
  if (focus) {
969
970
  this.activeLayer.setPens([line]);
970
971
  this.render();
@@ -977,10 +978,10 @@ var Topology = (function (_super) {
977
978
  // open - redraw by the data
978
979
  Topology.prototype.open = function (topoJSon) {
979
980
  this.conversionData(topoJSon);
980
- Store.set(this.generateStoreKey('LT:scale'), this.data.scale);
981
- this.dispatch('scale', this.data.scale);
982
- this.parentElem.scrollLeft = 0;
983
- this.parentElem.scrollTop = 0;
981
+ Store.set(this.generateStoreKey('LT:scale'), this.store.data.scale);
982
+ this.dispatch('scale', this.store.data.scale);
983
+ this.store.parentElem.scrollLeft = 0;
984
+ this.store.parentElem.scrollTop = 0;
984
985
  this.caches.list = [];
985
986
  this.divLayer.clear();
986
987
  this.cache();
@@ -990,22 +991,22 @@ var Topology = (function (_super) {
990
991
  this.showGrid();
991
992
  };
992
993
  Topology.prototype.overflow = function () {
993
- try {
994
- var rect = this.getRect();
995
- let _a = this.canvas;
996
- if(!_a.width) return;
997
- let width = _a.width, height = _a.height;
998
- if (width < rect.width) {
999
- width = rect.width;
1000
- }
1001
- if (height < rect.height) {
1002
- height = rect.height;
1003
- }
1004
- this.resize({width: width, height: height});
1005
- return rect;
1006
- }catch (e){
1007
- console.log('init-error-----------')
1008
- }
994
+ try {
995
+ var rect = this.getRect();
996
+ let _a = this.canvas;
997
+ if(!_a.width) return;
998
+ let width = _a.width, height = _a.height;
999
+ if (width < rect.width) {
1000
+ width = rect.width;
1001
+ }
1002
+ if (height < rect.height) {
1003
+ height = rect.height;
1004
+ }
1005
+ this.resize({width: width + 20, height: height + 20});
1006
+ return rect;
1007
+ }catch (e){
1008
+ //console.log('init-error-----------',e)
1009
+ }
1009
1010
  };
1010
1011
  Topology.prototype.getMoveIn = function (pt) {
1011
1012
  this.lastHoverNode = this.moveIn.hoverNode;
@@ -1015,13 +1016,13 @@ var Topology = (function (_super) {
1015
1016
  this.moveIn.lineControlPoint = null;
1016
1017
  this.moveIn.hoverLine = null;
1017
1018
  this.hoverLayer.hoverAnchorIndex = -1;
1018
- if (!this.data.locked &&
1019
+ if (!this.store.data.locked &&
1019
1020
  !(this.activeLayer.pens.length === 1 && this.activeLayer.pens[0].type) &&
1020
1021
  !this.activeLayer.locked() &&
1021
1022
  this.activeLayer.rotateCPs[0] &&
1022
1023
  this.activeLayer.rotateCPs[0].hit(pt, 15)) {
1023
1024
  this.moveIn.type = this.moveInType.Rotate;
1024
- var cursor = this.options.rotateCursor;
1025
+ var cursor = this.store.options.rotateCursor;
1025
1026
  this.divLayer.canvas.style.cursor = cursor.includes('/')
1026
1027
  ? "url(\"" + cursor + "\"), auto"
1027
1028
  : cursor;
@@ -1031,9 +1032,9 @@ var Topology = (function (_super) {
1031
1032
  pointInRect(pt, this.activeLayer.sizeCPs)) {
1032
1033
  this.moveIn.type = this.moveInType.Nodes;
1033
1034
  }
1034
- if (!this.data.locked &&
1035
+ if (!this.store.data.locked &&
1035
1036
  !this.activeLayer.locked() &&
1036
- !this.options.hideSizeCP) {
1037
+ !this.store.options.hideSizeCP) {
1037
1038
  if (this.activeLayer.pens.length > 1 ||
1038
1039
  (!this.activeLayer.pens[0].type && !this.activeLayer.pens[0].hideSizeCP)) {
1039
1040
  for (var i = 0; i < this.activeLayer.sizeCPs.length; ++i) {
@@ -1047,7 +1048,7 @@ var Topology = (function (_super) {
1047
1048
  }
1048
1049
  }
1049
1050
  // In active pen.
1050
- if (!this.data.locked) {
1051
+ if (!this.store.data.locked) {
1051
1052
  for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
1052
1053
  var item = _a[_i];
1053
1054
  if (item instanceof Line && !item.locked) {
@@ -1068,13 +1069,13 @@ var Topology = (function (_super) {
1068
1069
  }
1069
1070
  }
1070
1071
  this.divLayer.canvas.style.cursor = 'default';
1071
- var len = this.data.pens.length;
1072
+ var len = this.store.data.pens.length;
1072
1073
  for (var i = len - 1; i > -1; --i) {
1073
- if (this.data.pens[i].type === PenType.Node &&
1074
- this.inNode(pt, this.data.pens[i])) {
1074
+ if (this.store.data.pens[i].type === PenType.Node &&
1075
+ this.inNode(pt, this.store.data.pens[i])) {
1075
1076
  return;
1076
- } else if (this.data.pens[i].type === PenType.Line &&
1077
- this.inLine(pt, this.data.pens[i])) {
1077
+ } else if (this.store.data.pens[i].type === PenType.Line &&
1078
+ this.inLine(pt, this.store.data.pens[i])) {
1078
1079
  // 需要优先判断十分在节点锚点上
1079
1080
  // return;
1080
1081
  }
@@ -1107,7 +1108,7 @@ var Topology = (function (_super) {
1107
1108
  if (inChild === void 0) {
1108
1109
  inChild = false;
1109
1110
  }
1110
- if (this.data.locked === Lock.NoEvent ||
1111
+ if (this.store.data.locked === Lock.NoEvent ||
1111
1112
  (!node.visible && !window.location.pathname.includes('workspace')) ||
1112
1113
  node.locked === Lock.NoEvent) {
1113
1114
  return null;
@@ -1128,21 +1129,22 @@ var Topology = (function (_super) {
1128
1129
  }
1129
1130
  return child;
1130
1131
  }
1132
+ if(!(node instanceof Node)) node = new Node(node);
1131
1133
  if (node.hit(pt)) {
1132
1134
  this.moveIn.hoverNode = node;
1133
1135
  this.moveIn.type = this.moveInType.Nodes;
1134
1136
  // 非绘画页面下禁止不包含点击、双击事件的节点选中鼠标样式
1135
1137
  if (!this.checkNodeOfClickType(node)) {
1136
- if (!this.data.locked && !node.locked) {
1138
+ if (!this.store.data.locked && !node.locked) {
1137
1139
  this.divLayer.canvas.style.cursor = 'move';
1138
1140
  } else {
1139
- this.divLayer.canvas.style.cursor = this.options.hoverCursor;
1141
+ this.divLayer.canvas.style.cursor = this.store.options.hoverCursor;
1140
1142
  }
1141
1143
  }
1142
1144
  // Too small
1143
- if (!this.data.locked &&
1145
+ if (!this.store.data.locked &&
1144
1146
  !node.locked &&
1145
- !(this.options.hideAnchor ||
1147
+ !(this.store.options.hideAnchor ||
1146
1148
  node.hideAnchor ||
1147
1149
  node.rect.width < 20 ||
1148
1150
  node.rect.height < 20)) {
@@ -1165,9 +1167,9 @@ var Topology = (function (_super) {
1165
1167
  }
1166
1168
  return node;
1167
1169
  }
1168
- if (this.options.hideAnchor ||
1170
+ if (this.store.options.hideAnchor ||
1169
1171
  node.hideAnchor ||
1170
- this.data.locked ||
1172
+ this.store.data.locked ||
1171
1173
  node.locked) {
1172
1174
  return null;
1173
1175
  }
@@ -1199,8 +1201,8 @@ var Topology = (function (_super) {
1199
1201
  if (line.from.hit(point, 5)) {
1200
1202
  this.moveIn.type = this.moveInType.LineFrom;
1201
1203
  this.moveIn.hoverLine = line;
1202
- if (this.data.locked || line.locked) {
1203
- this.divLayer.canvas.style.cursor = this.options.hoverCursor;
1204
+ if (this.store.data.locked || line.locked) {
1205
+ this.divLayer.canvas.style.cursor = this.store.options.hoverCursor;
1204
1206
  } else {
1205
1207
  this.divLayer.canvas.style.cursor = 'move';
1206
1208
  }
@@ -1209,8 +1211,8 @@ var Topology = (function (_super) {
1209
1211
  if (line.to.hit(point, 5)) {
1210
1212
  this.moveIn.type = this.moveInType.LineTo;
1211
1213
  this.moveIn.hoverLine = line;
1212
- if (this.data.locked || line.locked) {
1213
- this.divLayer.canvas.style.cursor = this.options.hoverCursor;
1214
+ if (this.store.data.locked || line.locked) {
1215
+ this.divLayer.canvas.style.cursor = this.store.options.hoverCursor;
1214
1216
  } else {
1215
1217
  this.divLayer.canvas.style.cursor = 'move';
1216
1218
  }
@@ -1219,7 +1221,7 @@ var Topology = (function (_super) {
1219
1221
  if (line.pointIn(point)) {
1220
1222
  this.moveIn.type = this.moveInType.LineMove;
1221
1223
  this.moveIn.hoverLine = line;
1222
- this.divLayer.canvas.style.cursor = this.options.hoverCursor;
1224
+ this.divLayer.canvas.style.cursor = this.store.options.hoverCursor;
1223
1225
  if (line.from.id || line.to.id) {
1224
1226
  this.moveIn.type = this.moveInType.Line;
1225
1227
  }
@@ -1229,7 +1231,7 @@ var Topology = (function (_super) {
1229
1231
  };
1230
1232
  Topology.prototype.getLineDock = function (point) {
1231
1233
  this.hoverLayer.dockAnchor = null;
1232
- for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
1234
+ for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
1233
1235
  var item = _a[_i];
1234
1236
  if (item instanceof Node) {
1235
1237
  if (item.rect.hit(point, 10)) {
@@ -1296,7 +1298,7 @@ var Topology = (function (_super) {
1296
1298
  rect.ey = rect.y + rect.height;
1297
1299
  }
1298
1300
  this.activeLayer.pens = [];
1299
- for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
1301
+ for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
1300
1302
  var item = _a[_i];
1301
1303
  if (item.locked === Lock.NoEvent) {
1302
1304
  continue;
@@ -1343,7 +1345,7 @@ var Topology = (function (_super) {
1343
1345
  x: 0,
1344
1346
  y: 0,
1345
1347
  };
1346
- if (noDock || this.options.disableDockLine) {
1348
+ if (noDock || this.store.options.disableDockLine) {
1347
1349
  return offset;
1348
1350
  }
1349
1351
  var x = 0;
@@ -1352,7 +1354,7 @@ var Topology = (function (_super) {
1352
1354
  var disY = dockOffset;
1353
1355
  for (var _i = 0, _a = this.activeLayer.dockWatchers; _i < _a.length; _i++) {
1354
1356
  var activePt = _a[_i];
1355
- for (var _b = 0, _c = this.data.pens; _b < _c.length; _b++) {
1357
+ for (var _b = 0, _c = this.store.data.pens; _b < _c.length; _b++) {
1356
1358
  var item = _c[_b];
1357
1359
  if (!(item instanceof Node) ||
1358
1360
  this.activeLayer.has(item) ||
@@ -1385,9 +1387,9 @@ var Topology = (function (_super) {
1385
1387
  if (this.caches.index < this.caches.list.length - 1) {
1386
1388
  this.caches.list.splice(this.caches.index + 1, this.caches.list.length - this.caches.index - 1);
1387
1389
  }
1388
- var data = new TopologyData(this.data);
1390
+ var data = JSON.parse(JSON.stringify(this.store.data));
1389
1391
  this.caches.list.push(data);
1390
- if (this.caches.list.length > this.options.cacheLen) {
1392
+ if (this.caches.list.length > this.store.options.cacheLen) {
1391
1393
  this.caches.list.shift();
1392
1394
  }
1393
1395
  this.caches.index = this.caches.list.length - 1;
@@ -1420,31 +1422,31 @@ var Topology = (function (_super) {
1420
1422
  if (noRedo === void 0) {
1421
1423
  noRedo = false;
1422
1424
  }
1423
- if (this.data.locked || this.caches.index < 1) {
1425
+ if (this.store.data.locked || this.caches.index < 1) {
1424
1426
  return;
1425
1427
  }
1426
1428
  this.divLayer.clear();
1427
- var data = new TopologyData(this.caches.list[--this.caches.index]);
1428
- this.data.pens.splice(0, this.data.pens.length);
1429
- this.data.pens.push.apply(this.data.pens, data.pens);
1429
+ var data = JSON.parse(JSON.stringify(this.caches.list[--this.caches.index]));
1430
+ this.store.data.pens.splice(0, this.store.data.pens.length);
1431
+ this.store.data.pens.push.apply(this.store.data.pens, data.pens);
1430
1432
  this.render(true);
1431
1433
  this.divLayer.render();
1432
1434
  if (noRedo) {
1433
1435
  this.caches.list.splice(this.caches.index + 1, this.caches.list.length - this.caches.index - 1);
1434
1436
  }
1435
- this.dispatch('undo', this.data);
1437
+ this.dispatch('undo', this.store.data);
1436
1438
  };
1437
1439
  Topology.prototype.redo = function () {
1438
- if (this.data.locked || this.caches.index > this.caches.list.length - 2) {
1440
+ if (this.store.data.locked || this.caches.index > this.caches.list.length - 2) {
1439
1441
  return;
1440
1442
  }
1441
1443
  this.divLayer.clear();
1442
- var data = new TopologyData(this.caches.list[++this.caches.index]);
1443
- this.data.pens.splice(0, this.data.pens.length);
1444
- this.data.pens.push.apply(this.data.pens, data.pens);
1444
+ var data = JSON.parse(JSON.stringify(this.caches.list[++this.caches.index]));
1445
+ this.store.data.pens.splice(0, this.store.data.pens.length);
1446
+ this.store.data.pens.push.apply(this.store.data.pens, data.pens);
1445
1447
  this.render(true);
1446
1448
  this.divLayer.render();
1447
- this.dispatch('redo', this.data);
1449
+ this.dispatch('redo', this.store.data);
1448
1450
  };
1449
1451
  Topology.prototype.toImage = function (type, quality, callback, padding, thumbnail) {
1450
1452
  if (thumbnail === void 0) {
@@ -1508,13 +1510,13 @@ var Topology = (function (_super) {
1508
1510
  }
1509
1511
  var found = this.findIndex(pen);
1510
1512
  if (found > -1) {
1511
- if (this.data.pens[found].type === PenType.Node) {
1512
- this.divLayer.removeDiv(this.data.pens[found]);
1513
+ if (this.store.data.pens[found].type === PenType.Node) {
1514
+ this.divLayer.removeDiv(this.store.data.pens[found]);
1513
1515
  }
1514
- if (this.options.disableEmptyLine) {
1516
+ if (this.store.options.disableEmptyLine) {
1515
1517
  this.delEmptyLines(pen.id);
1516
1518
  }
1517
- pens.push.apply(pens, this.data.pens.splice(found, 1));
1519
+ pens.push.apply(pens, this.store.data.pens.splice(found, 1));
1518
1520
  this.setSwitchTabData(pen, found, 'delete');
1519
1521
  --i;
1520
1522
  }
@@ -1528,16 +1530,16 @@ var Topology = (function (_super) {
1528
1530
  this.dispatch('delete', pens);
1529
1531
  };
1530
1532
  Topology.prototype.delEmptyLines = function (deleteedId) {
1531
- for (var i = 0; i < this.data.pens.length; i++) {
1532
- if (this.data.pens[i].type !== PenType.Line) {
1533
+ for (var i = 0; i < this.store.data.pens.length; i++) {
1534
+ if (this.store.data.pens[i].type !== PenType.Line) {
1533
1535
  continue;
1534
1536
  }
1535
- var line = this.data.pens[i];
1537
+ var line = this.store.data.pens[i];
1536
1538
  if (!line.from.id ||
1537
1539
  !line.to.id ||
1538
1540
  line.from.id === deleteedId ||
1539
1541
  line.to.id === deleteedId) {
1540
- this.data.pens.splice(i, 1);
1542
+ this.store.data.pens.splice(i, 1);
1541
1543
  this.animateLayer.pens.delete(line.id);
1542
1544
  --i;
1543
1545
  }
@@ -1546,8 +1548,8 @@ var Topology = (function (_super) {
1546
1548
  Topology.prototype.removeNode = function (node) {
1547
1549
  var i = this.findIndex(node);
1548
1550
  if (i > -1) {
1549
- this.divLayer.removeDiv(this.data.pens[i]);
1550
- var nodes = this.data.pens.splice(i, 1);
1551
+ this.divLayer.removeDiv(this.store.data.pens[i]);
1552
+ var nodes = this.store.data.pens.splice(i, 1);
1551
1553
  this.dispatch('delete', nodes);
1552
1554
  }
1553
1555
  this.render(true);
@@ -1556,28 +1558,28 @@ var Topology = (function (_super) {
1556
1558
  Topology.prototype.removeLine = function (line) {
1557
1559
  var i = this.findIndex(line);
1558
1560
  if (i > -1) {
1559
- var lines = this.data.pens.splice(i, 1);
1561
+ var lines = this.store.data.pens.splice(i, 1);
1560
1562
  this.dispatch('delete', lines);
1561
1563
  }
1562
1564
  this.render(true);
1563
1565
  this.cache();
1564
1566
  };
1565
1567
  Topology.prototype.cut = function () {
1566
- if (this.data.locked) {
1568
+ if (this.store.data.locked) {
1567
1569
  return;
1568
1570
  }
1569
- this.clipboard = new TopologyData({
1571
+ this.clipboard = {
1570
1572
  pens: [],
1571
- });
1573
+ };
1572
1574
  for (var i = 0; i < this.activeLayer.pens.length; i++) {
1573
1575
  var pen = this.activeLayer.pens[i];
1574
1576
  this.clipboard.pens.push(pen.clone());
1575
1577
  var found = this.findIndex(pen);
1576
1578
  if (found > -1) {
1577
1579
  if (pen.type === PenType.Node) {
1578
- this.divLayer.removeDiv(this.data.pens[found]);
1580
+ this.divLayer.removeDiv(this.store.data.pens[found]);
1579
1581
  }
1580
- this.data.pens.splice(found, 1);
1582
+ this.store.data.pens.splice(found, 1);
1581
1583
  --i;
1582
1584
  }
1583
1585
  }
@@ -1594,9 +1596,9 @@ var Topology = (function (_super) {
1594
1596
  return item.animatePlay;
1595
1597
  });
1596
1598
  if(isAnimate) return false;
1597
- this.clipboard = new TopologyData({
1599
+ this.clipboard = {
1598
1600
  pens: [],
1599
- });
1601
+ };
1600
1602
  for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
1601
1603
  var pen = _a[_i];
1602
1604
  this.clipboard.pens.push(pen.clone());
@@ -1604,7 +1606,7 @@ var Topology = (function (_super) {
1604
1606
  return true;
1605
1607
  };
1606
1608
  Topology.prototype.paste = function () {
1607
- if (!this.clipboard || this.data.locked) {
1609
+ if (!this.clipboard || this.store.data.locked) {
1608
1610
  return;
1609
1611
  }
1610
1612
  this.hoverLayer.node = null;
@@ -1645,9 +1647,9 @@ var Topology = (function (_super) {
1645
1647
  }
1646
1648
  pen.controlPoints = controlPoints;
1647
1649
  }
1648
- this.data.pens.push(pen);
1650
+ this.store.data.pens.push(pen);
1649
1651
  this.activeLayer.add(pen);
1650
- this.setSwitchTabData(pen, this.data.pens.length-1);
1652
+ this.setSwitchTabData(pen, this.store.data.pens.length-1);
1651
1653
  }
1652
1654
  this.render();
1653
1655
  this.animate(true);
@@ -1666,9 +1668,9 @@ var Topology = (function (_super) {
1666
1668
  }
1667
1669
  };
1668
1670
  Topology.prototype.bind = function (item, exite, dataType, index) {
1669
- this.clipboard = new TopologyData({
1671
+ this.clipboard = {
1670
1672
  pens: [],
1671
- });
1673
+ };
1672
1674
  for (var _i = 0, _a = this.activeLayer.pens; _i < _a.length; _i++) {
1673
1675
  var pen = _a[_i];
1674
1676
  pen.data = []
@@ -1680,46 +1682,20 @@ var Topology = (function (_super) {
1680
1682
  }
1681
1683
  };
1682
1684
  Topology.prototype.bindInfo = async function (item, pen, type, index) {
1683
- if (type == 0) {
1684
- pen.data.push({
1685
- "key": "tagId",
1686
- "value": item.tagId,
1687
- "isControlDis": item.isControlDis,
1688
- "type": item.tagType,
1689
- "tagVal": item.value,
1690
- "valExplain": item.valExplain,
1691
- "tagId": item.tagId
1692
- }, {
1693
- "key": "测点名称",
1694
- "value": item.tagName
1695
- })
1696
- let obj = {
1697
- "key": "threeCategoryId",
1698
- "value": item.threeCategoryId
1699
- }
1685
+ if ([0, '0'].includes(type)) {
1686
+ const setTagId = setTagIdData(item);
1687
+ pen.data.push(...setTagId);
1700
1688
  // 绑定悬浮文字
1701
1689
  pen.title = item.touchpname
1702
- if (!JSON.stringify(pen.data).includes(JSON.stringify(obj))) {
1703
- pen.data.push(obj)
1704
- }
1705
- } else if (type == 1) {
1706
- pen.data.push({
1707
- "key": "kpiAddr",
1708
- "value": item.kpiId + '_' + item.kpiAddr,
1709
- "isControlDis": item.isControlDis,
1710
- "type": item.tagType
1711
- }, {
1712
- "key": "指标名称",
1713
- "value": item.kpiName
1714
- })
1715
- } else if (type == 2) {
1716
- pen.data.push({
1717
- "key": "assetId",
1718
- "value": item.id
1719
- }, {
1720
- "key": "资产名称",
1721
- "value": item.name
1722
- })
1690
+ //用于处理场地监控,点击一个资产类别后,隐藏掉这个类别下的所有元件
1691
+ const setThreeCategory = setThreeCategoryIdData(pen, item);
1692
+ pen.data.push(...setThreeCategory);
1693
+ } else if ([1, '1'].includes(type)) {
1694
+ const setKpiAddr = setKpiAddrData(item);
1695
+ pen.data.push(...setKpiAddr);
1696
+ } else if ([2, '2'].includes(type)) {
1697
+ const setAssetId = setAssetIdData(item);
1698
+ pen.data.push(...setAssetId);
1723
1699
  // 绑定悬浮文字
1724
1700
  pen.title = item.bak
1725
1701
  if (pen.subName && pen.subName == 'temp') {
@@ -1753,22 +1729,16 @@ var Topology = (function (_super) {
1753
1729
  }]
1754
1730
  })
1755
1731
  }
1756
- } else if (type == 3) {
1757
- pen.data.push({
1758
- "key": "areaId",
1759
- "value": item.id
1760
- }, {
1761
- "key": "区域名称",
1762
- "value": item.name
1763
- })
1764
- }
1765
- // let str = JSON.stringify(pen.events)
1766
- // pen.events.forEach((_item) => {
1767
- // if(_item.action==0 && _item.dcimDetailPage && _item.dcimDetailPage != '' && item.devId){
1768
- // str = str.replace(new RegExp(_item.dcimAssetValue,'g'), item.devId)
1769
- // }
1770
- // });
1771
- // pen.events = JSON.parse(str)
1732
+ } else if ([3, '3'].includes(type)) {
1733
+ const setAreaId = setAreaIdData(item);
1734
+ pen.data.push(...setAreaId);
1735
+ }
1736
+ // if([0, 2, '0', '2'].includes(type)) {
1737
+ // //用于处理场地监控,点击一个资产类别后,隐藏掉这个类别下的所有元件
1738
+ // const setThreeCategory = setThreeCategoryIdData(pen, item);
1739
+ //
1740
+ // pen.data.push(...setThreeCategory);
1741
+ // }
1772
1742
  return pen
1773
1743
  };
1774
1744
  Topology.prototype.newId = function (node, idMaps) {
@@ -1815,15 +1785,15 @@ var Topology = (function (_super) {
1815
1785
  cache && this.cache();
1816
1786
  };
1817
1787
  Topology.prototype.lock = function (lock) {
1818
- this.data.locked = lock;
1819
- for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
1788
+ this.store.data.locked = lock;
1789
+ for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
1820
1790
  var item = _a[_i];
1821
1791
  item.addToDiv && item.addToDiv();
1822
1792
  }
1823
- this.dispatch('locked', this.data.locked);
1793
+ this.dispatch('locked', this.store.data.locked);
1824
1794
  };
1825
1795
  Topology.prototype.lockPens = function (pens, lock) {
1826
- for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
1796
+ for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
1827
1797
  var item = _a[_i];
1828
1798
  for (var _b = 0, pens_2 = pens; _b < pens_2.length; _b++) {
1829
1799
  var pen = pens_2[_b];
@@ -1841,30 +1811,30 @@ var Topology = (function (_super) {
1841
1811
  };
1842
1812
  Topology.prototype.up = function (pen) {
1843
1813
  var i = this.findIndex(pen);
1844
- if (i > -1 && i !== this.data.pens.length - 1) {
1845
- this.data.pens.splice(i + 2, 0, this.data.pens[i]);
1846
- this.data.pens.splice(i, 1);
1814
+ if (i > -1 && i !== this.store.data.pens.length - 1) {
1815
+ this.store.data.pens.splice(i + 2, 0, this.store.data.pens[i]);
1816
+ this.store.data.pens.splice(i, 1);
1847
1817
  }
1848
1818
  };
1849
1819
  Topology.prototype.top = function (pen) {
1850
1820
  var i = this.findIndex(pen);
1851
1821
  if (i > -1) {
1852
- this.data.pens.push(this.data.pens[i]);
1853
- this.data.pens.splice(i, 1);
1822
+ this.store.data.pens.push(this.store.data.pens[i]);
1823
+ this.store.data.pens.splice(i, 1);
1854
1824
  }
1855
1825
  };
1856
1826
  Topology.prototype.down = function (pen) {
1857
1827
  var i = this.findIndex(pen);
1858
1828
  if (i > -1 && i !== 0) {
1859
- this.data.pens.splice(i - 1, 0, this.data.pens[i]);
1860
- this.data.pens.splice(i + 1, 1);
1829
+ this.store.data.pens.splice(i - 1, 0, this.store.data.pens[i]);
1830
+ this.store.data.pens.splice(i + 1, 1);
1861
1831
  }
1862
1832
  };
1863
1833
  Topology.prototype.bottom = function (pen) {
1864
1834
  var i = this.findIndex(pen);
1865
1835
  if (i > -1) {
1866
- this.data.pens.unshift(this.data.pens[i]);
1867
- this.data.pens.splice(i + 1, 1);
1836
+ this.store.data.pens.unshift(this.store.data.pens[i]);
1837
+ this.store.data.pens.splice(i + 1, 1);
1868
1838
  }
1869
1839
  };
1870
1840
  Topology.prototype.combine = function (pens, stand, temp) {
@@ -1880,7 +1850,7 @@ var Topology = (function (_super) {
1880
1850
  var item = pens_3[_i];
1881
1851
  var i = this.findIndex(item);
1882
1852
  if (i > -1) {
1883
- this.data.pens.splice(i, 1);
1853
+ this.store.data.pens.splice(i, 1);
1884
1854
  }
1885
1855
  }
1886
1856
  var node = new Node({
@@ -1905,7 +1875,7 @@ var Topology = (function (_super) {
1905
1875
  item.calcRectInParent(node);
1906
1876
  node.children.push(item);
1907
1877
  }
1908
- this.data.pens.push(node);
1878
+ this.store.data.pens.push(node);
1909
1879
  this.activeLayer.setPens([node]);
1910
1880
  this.dispatch('node', node);
1911
1881
  this.cache();
@@ -1923,11 +1893,11 @@ var Topology = (function (_super) {
1923
1893
  item.parentId = undefined;
1924
1894
  item.rectInParent = undefined;
1925
1895
  item.locked = Lock.None;
1926
- this.data.pens.push(item);
1896
+ this.store.data.pens.push(item);
1927
1897
  }
1928
1898
  var i = this.findIndex(nodeChildren);
1929
1899
  if (i > -1 && nodeChildren.name === 'combine') {
1930
- this.data.pens.splice(i, 1);
1900
+ this.store.data.pens.splice(i, 1);
1931
1901
  } else {
1932
1902
  nodeChildren.children = null;
1933
1903
  }
@@ -1938,7 +1908,7 @@ var Topology = (function (_super) {
1938
1908
  Topology.prototype.find = function (idOrTag, pens) {
1939
1909
  var _this = this;
1940
1910
  if (!pens) {
1941
- pens = this.data.pens;
1911
+ pens = this.store.data.pens;
1942
1912
  }
1943
1913
  var result = [];
1944
1914
  pens.forEach(function (item) {
@@ -1955,28 +1925,28 @@ var Topology = (function (_super) {
1955
1925
  return result;
1956
1926
  };
1957
1927
  Topology.prototype.findIndex = function (pen) {
1958
- for (var i = 0; i < this.data.pens.length; ++i) {
1959
- if (pen.id === this.data.pens[i].id) {
1928
+ for (var i = 0; i < this.store.data.pens.length; ++i) {
1929
+ if (pen.id === this.store.data.pens[i].id) {
1960
1930
  return i;
1961
1931
  }
1962
1932
  }
1963
1933
  return -1;
1964
1934
  };
1965
1935
  Topology.prototype.anchor = function (anchor) {
1966
- this.options.hideAnchor = anchor
1936
+ this.store.options.hideAnchor = anchor
1967
1937
  this.dispatch('hideAnchor', anchor);
1968
1938
  };
1969
1939
  // scale for scaled canvas:
1970
1940
  // > 1, expand
1971
1941
  // < 1, reduce
1972
1942
  Topology.prototype.scale = function (scale, center, w, h) {
1973
- if (this.data.scale * scale < this.options.minScale ||
1974
- this.data.scale * scale > this.options.maxScale) {
1943
+ if (this.store.data.scale * scale < this.store.options.minScale ||
1944
+ this.store.data.scale * scale > this.store.options.maxScale) {
1975
1945
  return;
1976
1946
  }
1977
- this.data.scale *= scale;
1947
+ this.store.data.scale *= scale;
1978
1948
  !center && (center = this.getRect().center);
1979
- for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
1949
+ for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
1980
1950
  var item = _a[_i];
1981
1951
  item.scale(scale, center, w, h);
1982
1952
  }
@@ -1985,18 +1955,18 @@ var Topology = (function (_super) {
1985
1955
  pen.scale(scale, center);
1986
1956
  }
1987
1957
  });
1988
- Store.set(this.generateStoreKey('LT:scale'), this.data.scale);
1958
+ Store.set(this.generateStoreKey('LT:scale'), this.store.data.scale);
1989
1959
  this.render();
1990
1960
  this.cache();
1991
- this.dispatch('scale', this.data.scale);
1961
+ this.dispatch('scale', this.store.data.scale);
1992
1962
  };
1993
1963
  // scale for origin canvas:
1994
1964
  Topology.prototype.scaleTo = function (scale) {
1995
- this.scale(scale / this.data.scale);
1996
- this.data.scale = scale;
1965
+ this.scale(scale / this.store.data.scale);
1966
+ this.store.data.scale = scale;
1997
1967
  };
1998
1968
  Topology.prototype.round = function () {
1999
- for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
1969
+ for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
2000
1970
  var item = _a[_i];
2001
1971
  if (item instanceof Node) {
2002
1972
  item.round();
@@ -2007,7 +1977,7 @@ var Topology = (function (_super) {
2007
1977
  if (!this.hasView())
2008
1978
  return;
2009
1979
  // 1. 重置画布尺寸为容器尺寸
2010
- var parentElem = this.canvas.parentElem;
1980
+ var parentElem = this.store.parentElem;
2011
1981
  var width = parentElem.offsetWidth, height = parentElem.offsetHeight;
2012
1982
  this.resize({
2013
1983
  width: width,
@@ -2016,7 +1986,7 @@ var Topology = (function (_super) {
2016
1986
  // 2. 图形居中
2017
1987
  this.centerView(viewPadding);
2018
1988
  // 3. 获取设置的留白值
2019
- var padding = formatPadding(viewPadding || this.options.viewPadding);
1989
+ var padding = formatPadding(viewPadding || this.store.options.viewPadding);
2020
1990
  // 4. 获取图形尺寸
2021
1991
  var rect = this.getRect();
2022
1992
  // 6. 计算缩放比
@@ -2029,7 +1999,7 @@ var Topology = (function (_super) {
2029
1999
  this.scale(ratio);
2030
2000
  };
2031
2001
  Topology.prototype.showTipText = function (data, pos) {
2032
- if (this.data.locked && data.title) {
2002
+ if (this.store.data.locked && data.title) {
2033
2003
  this.divLayer.canvas.title = data.title;
2034
2004
  this.tip = data.id;
2035
2005
  }
@@ -2040,15 +2010,15 @@ var Topology = (function (_super) {
2040
2010
  return;
2041
2011
  }
2042
2012
  this.scrolling = true;
2043
- this.parentElem.scrollLeft += x;
2044
- this.parentElem.scrollTop += y;
2013
+ this.store.parentElem.scrollLeft += x;
2014
+ this.store.parentElem.scrollTop += y;
2045
2015
  setTimeout(function () {
2046
2016
  _this.scrolling = false;
2047
2017
  }, 700);
2048
2018
  };
2049
2019
  Topology.prototype.toComponent = function (pens) {
2050
2020
  if (!pens) {
2051
- pens = this.data.pens;
2021
+ pens = this.store.data.pens;
2052
2022
  }
2053
2023
  var rect = this.getRect(pens);
2054
2024
  var node = new Node({
@@ -2089,7 +2059,7 @@ var Topology = (function (_super) {
2089
2059
  attr = 'text';
2090
2060
  }
2091
2061
  var pen;
2092
- this.data.pens.forEach(function (item) {
2062
+ this.store.data.pens.forEach(function (item) {
2093
2063
  if (item.id === idOrTag || item.tags.indexOf(idOrTag) > -1) {
2094
2064
  pen = item;
2095
2065
  }
@@ -2101,7 +2071,7 @@ var Topology = (function (_super) {
2101
2071
  attr = 'text';
2102
2072
  }
2103
2073
  var pen;
2104
- this.data.pens.forEach(function (item) {
2074
+ this.store.data.pens.forEach(function (item) {
2105
2075
  if (item.id === idOrTag || item.tags.indexOf(idOrTag) > -1) {
2106
2076
  pen = item;
2107
2077
  }
@@ -2114,11 +2084,12 @@ var Topology = (function (_super) {
2114
2084
  this.gridElem.style.left = '0';
2115
2085
  this.gridElem.style.top = '0';
2116
2086
  this.gridElem.innerHTML = "<svg class=\"svg-grid\" width=\"100%\" height=\"100%\" style=\"position:absolute;left:0;right:0;top:0;bottom:0\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <defs>\n <pattern id=\"grid\" width=\"10\" height=\"10\" patternUnits=\"userSpaceOnUse\">\n <path d=\"M 10 0 L 0 0 0 10\" fill=\"none\" stroke=\"#f3f3f3\" stroke-width=\"1\" />\n </pattern>\n </defs>\n <rect width=\"100%\" height=\"100%\" fill=\"url(#grid)\" />\n </svg>";
2117
- this.parentElem.appendChild(this.gridElem);
2087
+ this.store.parentElem.appendChild(this.gridElem);
2118
2088
  };
2119
2089
  Topology.prototype.showGrid = function (show) {
2090
+ if(!this.store || !this.store.data) return;
2120
2091
  if (show === undefined) {
2121
- show = this.data.grid;
2092
+ show = this.store.data.grid;
2122
2093
  }
2123
2094
  this.gridElem.style.width = this.canvas.width + 'px';
2124
2095
  this.gridElem.style.height = this.canvas.height + 'px';
@@ -2209,7 +2180,7 @@ var Topology = (function (_super) {
2209
2180
  canvas.style.height = 500 + 'px';
2210
2181
  canvas.style.zIndex = 1;
2211
2182
  canvas.setAttribute('id', 'arbitraryCanvas');
2212
- this.parentElem.appendChild(canvas)
2183
+ this.store.parentElem.appendChild(canvas)
2213
2184
  };
2214
2185
  Topology.prototype.createArbitraryGraph = function () {
2215
2186