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.
Files changed (76) hide show
  1. package/chart-diagram/src/echarts/index.js +88 -96
  2. package/chart-diagram/src/register.js +3 -3
  3. package/chart-diagram/src/utils/changeOptions.d.ts +4 -4
  4. package/chart-diagram/src/utils/changeOptions.js +172 -144
  5. package/chart-diagram/src/utils/conversion.d.ts +12 -12
  6. package/chart-diagram/src/utils/conversion.js +278 -137
  7. package/chart-diagram/src/utils/render.d.ts +5 -0
  8. package/chart-diagram/src/utils/render.js +107 -0
  9. package/core/index.d.ts +1 -0
  10. package/core/index.js +1 -0
  11. package/core/src/activeLayer.js +0 -6
  12. package/core/src/canvas.js +1 -0
  13. package/core/src/common.d.ts +1 -2
  14. package/core/src/common.js +123 -540
  15. package/core/src/core.js +61 -46
  16. package/core/src/divLayer.d.ts +0 -3
  17. package/core/src/divLayer.js +13 -34
  18. package/core/src/element/common.d.ts +5 -0
  19. package/core/src/element/common.js +52 -0
  20. package/core/src/element/iframe.d.ts +3 -0
  21. package/core/src/element/iframe.js +12 -0
  22. package/core/src/element/index.d.ts +4 -0
  23. package/core/src/element/index.js +4 -0
  24. package/core/src/element/select.d.ts +11 -0
  25. package/core/src/element/select.js +199 -0
  26. package/core/src/element/tab.d.ts +1 -0
  27. package/core/src/element/tab.js +22 -0
  28. package/core/src/healps/changeData.d.ts +1 -2
  29. package/core/src/healps/changeData.js +16 -122
  30. package/core/src/middles/default.js +3 -1
  31. package/core/src/middles/nodes/arbitrarygraph.js +11 -9
  32. package/core/src/middles/nodes/formselect.d.ts +2 -0
  33. package/core/src/middles/nodes/formselect.js +73 -0
  34. package/core/src/middles/nodes/iframe.js +21 -4
  35. package/core/src/middles/nodes/index.d.ts +1 -0
  36. package/core/src/middles/nodes/index.js +1 -0
  37. package/core/src/models/node.d.ts +4 -0
  38. package/core/src/models/node.js +24 -22
  39. package/core/src/models/pen.js +1 -2
  40. package/core/src/models/rect.js +2 -2
  41. package/core/src/options.d.ts +1 -0
  42. package/core/src/preview.js +45 -31
  43. package/core/src/renderLayer.d.ts +10 -6
  44. package/core/src/renderLayer.js +36 -43
  45. package/core/src/store/data.d.ts +16 -17
  46. package/core/src/store/data.js +36 -14
  47. package/core/src/utils/assignment.d.ts +6 -3
  48. package/core/src/utils/assignment.js +84 -15
  49. package/core/src/utils/construction.d.ts +9 -3
  50. package/core/src/utils/construction.js +6 -1
  51. package/core/src/utils/conversion.d.ts +3 -0
  52. package/core/src/utils/conversion.js +67 -0
  53. package/core/src/utils/index.d.ts +1 -1
  54. package/core/src/utils/index.js +1 -1
  55. package/core/src/utils/math.d.ts +1 -0
  56. package/core/src/utils/math.js +3 -0
  57. package/core/src/utils/onmousevent.d.ts +3 -0
  58. package/core/src/utils/onmousevent.js +28 -7
  59. package/core/src/utils/params.d.ts +7 -0
  60. package/core/src/utils/params.js +125 -0
  61. package/package.json +1 -1
  62. package/static/echartsDefaultData.js +27 -107
  63. package/static/element.js +14 -0
  64. package/static/form.js +11 -0
  65. package/static/index.js +2 -1
  66. package/store/actions.js +17 -0
  67. package/store/clear.js +72 -0
  68. package/store/index.js +2 -0
  69. package/style/common.css +18 -0
  70. package/style/editor.css +13 -0
  71. package/style/index.css +3 -12
  72. package/style/select.css +143 -0
  73. package/core/src/utils/dom.d.ts +0 -9
  74. package/core/src/utils/dom.js +0 -103
  75. package/core/src/utils/dom.js.map +0 -1
  76. package/static/echartsStore.js +0 -14
@@ -14,7 +14,18 @@ var __extends = (this && this.__extends) || (function () {
14
14
  import {KeyType} from './options';
15
15
  import {Point} from './models';
16
16
  import { Common } from './common'
17
- import {downDataType, formatPadding, mousMoveFun, mousDownFun, omouseEventPrototDoWindowFn} from './utils';
17
+ import {
18
+ downDataType,
19
+ previewType,
20
+ formatPadding,
21
+ mousMoveFun,
22
+ mousDownFun,
23
+ omouseEventPrototDoWindowFn
24
+ } from './utils';
25
+ import {
26
+ resetSelectInteractiveState,
27
+ setSelectDropdownInteractiveState
28
+ } from './element';
18
29
 
19
30
  var Preview = (function (_super) {
20
31
  __extends(Preview, _super);
@@ -74,7 +85,8 @@ var Preview = (function (_super) {
74
85
  if (_this.inputObj) {
75
86
  _this.setNodeText();
76
87
  }
77
- const {eventType, value} = mousDownFun(_this.store.options.type, _this.moveIn.eventNode);
88
+ resetSelectInteractiveState(_this.moveIn.hoverNode);
89
+ const {eventType, value, staticType} = mousDownFun(_this.store.options.type, _this.moveIn.eventNode);
78
90
  if (_this.moveIn.type == _this.moveInType.Nodes) {
79
91
  _this.setAttributeForCanvasPoint('pointer');
80
92
  switch (eventType) {
@@ -91,10 +103,14 @@ var Preview = (function (_super) {
91
103
  if (visibleRange == '1') {
92
104
  _this.openCount++
93
105
  }
106
+ this.render();
94
107
  break;
95
108
  case downDataType.Tabswitch:
96
109
  _this.switchStaticsCheckType(_this.moveIn.hoverNode, _this.moveIn.eventNode);
97
110
  break;
111
+ case downDataType.Formselect:
112
+ setSelectDropdownInteractiveState(_this.moveIn.hoverNode, staticType, previewType.Dcim);
113
+ break;
98
114
  }
99
115
  }
100
116
  };
@@ -114,7 +130,7 @@ var Preview = (function (_super) {
114
130
  _this.divLayer.canvas.onmousedown = this.onmousedown;
115
131
  _this.divLayer.canvas.onmouseup = this.onmouseup;
116
132
  _this.divLayer.canvas.onwheel = function (event) {
117
- if (_this.store.options.disableScale) {
133
+ if (_this.store.options.disableScale || _this.store.options.type === 'dialog') {
118
134
  return;
119
135
  }
120
136
  switch (_this.store.options.scaleKey) {
@@ -162,6 +178,14 @@ var Preview = (function (_super) {
162
178
  _this.divLayer.canvas.focus();
163
179
  return false;
164
180
  };
181
+ window.onresize = function () {
182
+ const isFullScreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullscreenElement;
183
+ if(!isFullScreen && _this.isFullScreen){
184
+ _this.moveIn.hoverNode.text = '全屏';
185
+ _this.fitViewPreview(_this.isFullScreen);
186
+ _this.isFullScreen = false;
187
+ }
188
+ };
165
189
  return _this;
166
190
  }
167
191
  Preview.prototype.setAttributeForCanvasPoint = function (type){
@@ -175,43 +199,30 @@ var Preview = (function (_super) {
175
199
  };
176
200
  // open - redraw by the data
177
201
  Preview.prototype.open = function (topoJSon, type) {
178
- this.conversionData(topoJSon, type);
202
+ this.conversionData(topoJSon);
179
203
  this.setBKImageRect();
180
204
  this.fitView();
181
205
  this.render(true);
182
206
  this.animate(true);
183
207
  };
184
208
  Preview.prototype.setBKImageRect = function () {
185
- if (this.store.data.bkImageRect) {
186
- this.store.data.bkImageRect.x = this.store.data.bkImageRect.x ? Number(this.store.data.bkImageRect.x) : 0;
187
- this.store.data.bkImageRect.y = this.store.data.bkImageRect.y ? Number(this.store.data.bkImageRect.y) : 0;
188
- this.store.data.bkImageRect.width = this.store.data.bkImageRect.width ? Number(this.store.data.bkImageRect.width) : this.canvas.width;
189
- this.store.data.bkImageRect.height = this.store.data.bkImageRect.height ? Number(this.store.data.bkImageRect.height) : this.canvas.height;
190
- this.store.data.bkImageRect.center = {
191
- x: this.store.data.bkImageRect.x + this.store.data.bkImageRect.width / 2,
192
- y: this.store.data.bkImageRect.y + this.store.data.bkImageRect.height / 2
209
+ if (this.store.data.bkImageRect) {
210
+ this.store.data.bkImageRect.x = this.store.data.bkImageRect.x ? Number(this.store.data.bkImageRect.x) : 0;
211
+ this.store.data.bkImageRect.y = this.store.data.bkImageRect.y ? Number(this.store.data.bkImageRect.y) : 0;
212
+ this.store.data.bkImageRect.width = this.store.data.bkImageRect.width ? Number(this.store.data.bkImageRect.width) : this.canvas.width;
213
+ this.store.data.bkImageRect.height = this.store.data.bkImageRect.height ? Number(this.store.data.bkImageRect.height) : this.canvas.height;
214
+ this.store.data.bkImageRect.center = {
215
+ x: this.store.data.bkImageRect.x + this.store.data.bkImageRect.width / 2,
216
+ y: this.store.data.bkImageRect.y + this.store.data.bkImageRect.height / 2
217
+ }
193
218
  }
194
- }
195
219
  };
196
220
  Preview.prototype.scale = function (scale, center, w, h) {
197
221
  if (this.store.data.scale * scale < this.store.options.minScale ||
198
222
  this.store.data.scale * scale > this.store.options.maxScale) {
199
223
  return;
200
224
  }
201
- const scaleX = w ? w : scale;
202
- const scaleY = h ? h : scale;
203
225
  this.store.data.scale *= scale;
204
- if(this.isFullScreen) {
205
- this.store.ratioCord.ratio *= scale;
206
- this.store.ratioCord.scaleX *= scaleX;
207
- this.store.ratioCord.scaleY *= scaleY;
208
- }else {
209
- this.store.ratioCord = {
210
- ratio: 1,
211
- scaleX: 1,
212
- scaleY: 1
213
- }
214
- }
215
226
  !center && (center = this.getRect().center);
216
227
  for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
217
228
  var item = _a[_i];
@@ -239,6 +250,11 @@ var Preview = (function (_super) {
239
250
  var padding = formatPadding(viewPadding || this.store.options.viewPadding);
240
251
  // 4. 获取图形尺寸
241
252
  var rect = this.getRect();
253
+ if(!rect.width) {
254
+ const bkImageRect = this.store.data.bkImageRect;
255
+ rect.width = bkImageRect && bkImageRect.width ? bkImageRect.width : width;
256
+ rect.height = bkImageRect && bkImageRect.height ? bkImageRect.height : height;
257
+ }
242
258
  // 6. 计算缩放比
243
259
  var w = (width - padding[1] - padding[3]) / rect.width;
244
260
  var h = (height - padding[0] - padding[2]) / rect.height;
@@ -246,11 +262,8 @@ var Preview = (function (_super) {
246
262
  if (w > h) {
247
263
  ratio = h;
248
264
  }
249
- if(typeof restore === 'boolean' && restore) {
250
- ratio = 1 / this.store.ratioCord.ratio;
251
- w = 1 / this.store.ratioCord.scaleX;
252
- h = 1 / this.store.ratioCord.scaleY;
253
- }
265
+ // 保持缩放后的还原度
266
+ if(typeof restore === 'boolean' && restore) ratio = w;
254
267
  this.scale(ratio, undefined, w, h);
255
268
  this.canvas.scale(ratio, undefined, w, h);
256
269
  // 7. X抽滚动条隐藏
@@ -261,6 +274,7 @@ var Preview = (function (_super) {
261
274
  this.onMouseMove = null;
262
275
  this.onmousedown = null;
263
276
  this.onmouseup = null;
277
+ window.onresize = null;
264
278
  };
265
279
  return Preview;
266
280
  }(Common));
@@ -5,12 +5,6 @@ export declare class RenderLayer extends Canvas {
5
5
  offscreen: any;
6
6
  bkImg: HTMLImageElement;
7
7
  bkImgRect: {
8
- x: number;
9
- y: number;
10
- width: number;
11
- height: number;
12
- };
13
- bgRect: {
14
8
  center: {
15
9
  x: number;
16
10
  y: number;
@@ -20,6 +14,16 @@ export declare class RenderLayer extends Canvas {
20
14
  width: number;
21
15
  height: number;
22
16
  };
17
+ bgRect: {
18
+ // center: {
19
+ // x: number;
20
+ // y: number;
21
+ // },
22
+ x: number;
23
+ y: number;
24
+ // width: number;
25
+ // height: number;
26
+ };
23
27
  constructor(TID: String);
24
28
  loadBkImg(cb?: any): void;
25
29
  clearBkImg(): void;
@@ -24,6 +24,9 @@ var RenderLayer = /** @class */ (function (_super) {
24
24
  _this.initImage = false;
25
25
  _this.coverType = 'container';
26
26
  _this.bgRect = null;
27
+ _this.scaleX = 1;
28
+ _this.scaleY = 1;
29
+ _this.ratio = 1;
27
30
  _this.render = function () {
28
31
  if(!commonStore || !commonStore[TID]) return;
29
32
  if (commonStore[TID].data.bkImage && !_this.initImage) {
@@ -50,41 +53,34 @@ var RenderLayer = /** @class */ (function (_super) {
50
53
  return _this;
51
54
  }
52
55
  RenderLayer.prototype.scale = function (scale, center, w, h){
53
- const TID = this.TID;
54
- if(!commonStore || !commonStore[TID]) return;
55
- const bkImage = commonStore[TID].data.bkImage;
56
- const bkImageRect = commonStore[TID].data.bkImageRect;
57
- if(!bkImage) return;
56
+ if(!this.bkImgRect) {
57
+ this.scaleX = w ? w : scale;
58
+ this.scaleY = h ? h : scale;
59
+ this.ratio = scale;
60
+ return;
61
+ }
58
62
  if(!center) {
59
- center = bkImageRect ? bkImageRect.center : this.bgRect.center;
63
+ center = this.bkImgRect.center;
60
64
  }
61
65
  if (!w) {
62
66
  w = scale;
63
- if(bkImageRect) {
64
- bkImageRect.x = center.x - (center.x - bkImageRect.x) * w;
65
- }else {
66
- this.bgRect.x = center.x - (center.x - this.bgRect.x) * w;
67
- }
67
+ this.bkImgRect.x = center.x - (center.x - this.bkImgRect.x) * scale;
68
+ }else {
69
+ this.bkImgRect.x = this.bgRect.x;
68
70
  }
69
71
  if (!h) {
70
72
  h = scale;
71
- if(bkImageRect){
72
- bkImageRect.y = center.y - (center.y - bkImageRect.y) * h;
73
- }else {
74
- this.bgRect.y = center.y - (center.y - this.bgRect.y) * h;
75
- }
76
- }
77
- if(bkImageRect) {
78
- bkImageRect.width *= w;
79
- bkImageRect.height *= h;
80
- this.bkImgRect = bkImageRect;
73
+ this.bkImgRect.y = center.y - (center.y - this.bkImgRect.y) * scale;
81
74
  }else {
82
- if(this.initImage) {
83
- this.bgRect.width *= w;
84
- this.bgRect.height *= h;
85
- }
86
- this.bkImgRect = this.bgRect;
75
+ this.bkImgRect.y = this.bgRect.y;
87
76
  }
77
+ this.bkImgRect.width *= w;
78
+ this.bkImgRect.height *= h;
79
+ this.calcCenter();
80
+ };
81
+ RenderLayer.prototype.calcCenter = function () {
82
+ this.bkImgRect.center.x = this.bkImgRect.x + this.bkImgRect.width / 2;
83
+ this.bkImgRect.center.y = this.bkImgRect.y + this.bkImgRect.height / 2;
88
84
  };
89
85
  RenderLayer.prototype.loadBkImg = function (cb, pixi) {
90
86
  var _this = this;
@@ -98,6 +94,7 @@ var RenderLayer = /** @class */ (function (_super) {
98
94
  this.bkImg.onload = function () {
99
95
  if(pixi && !_this.bkImgRect) {
100
96
  _this.bkImgRectResize({width: _this.canvas.width, height: _this.canvas.height});
97
+ _this.scale(_this.ratio, undefined, _this.scaleX, _this.scaleY);
101
98
  }else {
102
99
  //_this.bkImgRect = _this.coverRect(_this.canvas.width, _this.canvas.height, _this.bkImg.width, _this.bkImg.height);
103
100
  }
@@ -105,10 +102,6 @@ var RenderLayer = /** @class */ (function (_super) {
105
102
  cb();
106
103
  }
107
104
  _this.initImage = true;
108
- _this.bgRect.center.x = _this.width / 2;
109
- _this.bgRect.center.y = _this.height / 2;
110
- _this.bgRect.width = _this.width;
111
- _this.bgRect.height = _this.height;
112
105
  };
113
106
  };
114
107
  RenderLayer.prototype.clearBkImg = function () {
@@ -116,14 +109,8 @@ var RenderLayer = /** @class */ (function (_super) {
116
109
  this.bkImg = null;
117
110
  this.initImage = false;
118
111
  this.bgRect = {
119
- center: {
120
- x: this.width / 2,
121
- y: this.height / 2
122
- },
123
112
  x: 0,
124
- y: 0,
125
- width: this.width,
126
- height: this.height
113
+ y: 0
127
114
  }
128
115
  };
129
116
  RenderLayer.prototype.coverRect = function (canvasWidth, canvasHeight, imgWidth, imgHeight) {
@@ -157,13 +144,19 @@ var RenderLayer = /** @class */ (function (_super) {
157
144
  let bkWidth = bkImageRect.width ? Number(bkImageRect.width) : width;
158
145
  let bkHeight = bkImageRect.height ? Number(bkImageRect.height) : height;
159
146
  this.bkImgRect = {
160
- x: x,
161
- y: y,
162
- width: bkImageRect.width ? bkImageRect.width : width,
163
- height: bkImageRect.height ? bkImageRect.height : height
147
+ center: {
148
+ x: x + bkWidth / 2,
149
+ y: y + bkHeight / 2
150
+ },
151
+ x,
152
+ y,
153
+ width: bkWidth,
154
+ height: bkHeight
155
+ };
156
+ this.bgRect = {
157
+ x,
158
+ y
164
159
  };
165
- }else {
166
- this.bkImgRect = this.bgRect;
167
160
  }
168
161
  };
169
162
 
@@ -40,17 +40,26 @@ export interface visualization2DStore {
40
40
  emitter: Emitter;
41
41
  dpiRatio?: number;
42
42
  lastScale?: number; //记录上次模版的scale
43
- ratioCord: {
44
- ratio?: number;
45
- scaleX?: number;
46
- scaleY?: number;
47
- },
48
43
  parentElem: HTMLElement
49
44
  }
50
45
  export interface mqttData {
51
- data: null
46
+ data: null,
47
+ initData: {},
48
+ params: {
49
+ tagIds?: [],
50
+ kpiAddrs?: [],
51
+ tagEcharts?: [],
52
+ assetIds?: [],
53
+ areaIds?: [],
54
+ varVaule?: [],
55
+ echartData?: [],
56
+ echartAssemblyData?: [],
57
+ routingkey?: string,
58
+ pathRewrite?: string
59
+ }
52
60
  }
53
61
  export const syncMqttData: mqttData;
62
+ export declare function clearMqttParams(): void;
54
63
  // @ts-ignore
55
64
  export const createStore = () => {
56
65
  return {
@@ -74,11 +83,6 @@ export const createStore = () => {
74
83
  cacheDatas: [],
75
84
  dpiRatio: 1,
76
85
  lastScale: 1,
77
- ratioCord: {
78
- ratio: 1,
79
- scaleX: 1,
80
- scaleY: 1
81
- },
82
86
  parentElem: null
83
87
  } as visualization2DStore;
84
88
  };
@@ -93,7 +97,7 @@ export const useStore = (id = 'default'): visualization2DStore => {
93
97
  };
94
98
 
95
99
  // @ts-ignore
96
- export const clearStore = (store: visualization2DStore) => {
100
+ export const clearStore = (store: visualization2DStore, del: string) => {
97
101
  store.data = {
98
102
  bkColor: '',
99
103
  bkImage: '',
@@ -121,9 +125,4 @@ export const clearStore = (store: visualization2DStore) => {
121
125
  store.cacheDatas = [];
122
126
  store.dpiRatio = 1;
123
127
  store.lastScale = 1;
124
- store.ratioCord = {
125
- ratio: 1,
126
- scaleX: 1,
127
- scaleY: 1
128
- }
129
128
  };
@@ -14,8 +14,34 @@ import { Lock } from '../models';
14
14
  import {DefalutOptions} from '../options';
15
15
  import {s8} from '../utils';
16
16
  import { commonStore } from './common'
17
+ import { clearDataPool, removeAllElement } from '../../../store';
17
18
  export const syncMqttData = {
18
- data: null
19
+ data: null, // 实时值
20
+ initData: {}, // 初始值
21
+ params: {
22
+ tagIds: [],
23
+ kpiAddrs: [],
24
+ tagEcharts: [],
25
+ assetIds: [],
26
+ areaIds: [],
27
+ varVaule: [],
28
+ echartData: [],
29
+ echartAssemblyData: [],
30
+ routingkey: '',
31
+ pathRewrite: ''
32
+ }
33
+ }
34
+ export const clearMqttParams = function () {
35
+ syncMqttData.params.tagIds = [];
36
+ syncMqttData.params.kpiAddrs = [];
37
+ syncMqttData.params.tagEcharts = [];
38
+ syncMqttData.params.assetIds = [];
39
+ syncMqttData.params.areaIds = [];
40
+ syncMqttData.params.varVaule = [];
41
+ syncMqttData.params.echartData = [];//统计图表组件类型ID
42
+ syncMqttData.params.echartAssemblyData = [];//统计图表组件类型ID
43
+ syncMqttData.params.routingkey = '';
44
+ syncMqttData.params.pathRewrite = '';
19
45
  }
20
46
  export var createStore = function () {
21
47
  return {
@@ -40,11 +66,6 @@ export var createStore = function () {
40
66
  cacheDatas: [],
41
67
  dpiRatio: 1,
42
68
  lastScale: 1,
43
- ratioCord: {
44
- ratio: 1,
45
- scaleX: 1,
46
- scaleY: 1
47
- },
48
69
  parentElem: null
49
70
  };
50
71
  };
@@ -72,15 +93,16 @@ export var clearStore = function (store, del) {
72
93
  },
73
94
  dataConstruct: {}
74
95
  };
75
- store.pens = {};
96
+ store.pens = {}; // 先保留,后期优化提取变量用
76
97
  store.cacheDatas = [];
77
98
  store.dpiRatio = 1;
78
99
  store.lastScale = 1;
79
- store.ratioCord = {
80
- ratio: 1,
81
- scaleX: 1,
82
- scaleY: 1
83
- };
84
- syncMqttData.data = null;
85
- if(del) delete commonStore[store.id];
100
+ clearDataPool();
101
+ if(del) {
102
+ syncMqttData.data = null;
103
+ syncMqttData.initData = {};
104
+ clearMqttParams();
105
+ delete commonStore[store.id];
106
+ removeAllElement();
107
+ }
86
108
  };
@@ -1,3 +1,6 @@
1
- export declare function setInitNodeDataValidat(node: any): void;
2
- export declare function setDefaultColorValidat(node: any, TID: string): void;
3
- export declare function setDefaultNodeValidat(node: any, retData: any): any;
1
+ import {Node} from '../models';
2
+
3
+ export declare function setInitNodeDataValidat(node: any, TID: string, type: string, order: number): void;
4
+ export declare function initDefaultValidat(node: any, retData: any): void;
5
+ export declare function setDefaultNodeValidat(node: any, retData: any): any;
6
+ export declare function initSwitchTabData(node: Node): void;
@@ -2,34 +2,82 @@
2
2
  import {syncMqttData} from '../store';
3
3
  import { setConfItemNode } from '../healps';
4
4
  import { EventAction } from '../models';
5
- export function setInitNodeDataValidat(node, TID) {
5
+ import {switchTabDataPool} from "../../../store";
6
+
7
+ /**
8
+ * 在节点注册前初始化node数据
9
+ * @param node 节点数据
10
+ * @param TID 数据键
11
+ * @param type topology类型
12
+ * @param order 节点序列
13
+ */
14
+ export function setInitNodeDataValidat(node, TID, type, order) {
15
+
6
16
  const syncData = syncMqttData.data;
17
+
18
+ node.TID = TID;
19
+
20
+ if(typeof order === "number") node.order = order;
21
+ if(type !== 'topology') node.selectDropdown = false;
22
+
23
+ initDefaultValidat(node, syncData);
24
+
25
+ setDefaultNodeValidat(node, syncData);
26
+
7
27
  if (node.children && node.children.length) {
28
+
8
29
  node.children.map((_item) => {
9
- node.TID = TID;
10
- setDefaultColorValidat(node);
11
- setDefaultNodeValidat(node, syncData);
30
+
31
+ setInitNodeDataValidat(_item, TID, type);
32
+
12
33
  })
13
- }else {
14
- node.TID = TID;
15
- setDefaultColorValidat(node);
16
- setDefaultNodeValidat(node, syncData);
34
+
17
35
  }
18
36
  }
19
- export function setDefaultColorValidat(node) {
37
+ // 初始化默认节点值
38
+ export function initDefaultValidat(node, retData) {
20
39
  node.defaultFillStyle = node.fillStyle;
21
40
  node.defaultFontColor = node.font.color;
22
41
  if (node.name === 'line') {
23
- node.defaultStrokeStyle = node.font.color;
42
+ node.defaultStrokeStyle = node.strokeStyle;
43
+ }
44
+ // 变量类型数据展示,不需要实时更新
45
+ if(Array.isArray(node.data) && retData && retData.varData) {
46
+ let typeName = '';
47
+ let imgs = '';
48
+ const varData = retData.varData;
49
+ node.data.map((vd) => {
50
+ if(vd.key.includes('varValue') && varData[vd.value]){
51
+ const varNode = varData[vd.value];
52
+ const showType = varNode.showType ? parseInt(varNode.showType) : 1;
53
+ if(showType === 1 && varNode.value) typeName += typeName ? `,${varNode.value}` : varNode.value;
54
+ if(showType === 2 && varNode.value) console.log('显示图标>>>');
55
+ if(showType === 3 && varNode.value) imgs = `/dcim-api${varNode.value}`; //imgs += imgs ? `,${varData.value}` : varData.value;
56
+ }
57
+ });
58
+ if(typeName) node.text = typeName;
59
+ if(imgs) {
60
+ node.text = '';
61
+ node.image = imgs;
62
+ node.paddingBottom = 0;
63
+ node.paddingBottomNum = 0;
64
+ node.paddingLeft = 0;
65
+ node.paddingLeftNum = 0;
66
+ node.paddingRight = 0;
67
+ node.paddingRightNum = 0;
68
+ node.paddingTop = 0;
69
+ node.paddingTopNum = 0;
70
+ }
24
71
  }
25
72
  }
73
+ // 初始化mqtt实时值
26
74
  export function setDefaultNodeValidat(node, retData) {
27
75
  //const item = JSON.parse(JSON.stringify(node));
28
76
  if (!node.data || !retData) return;
29
77
  //const node = detailData.length > 0 ? detailData : syncData
30
78
  const functionData = node.events.filter((ev) => {
31
79
  return ev.action === EventAction.Function
32
- })
80
+ });
33
81
  const dataValue = functionData[0]
34
82
  if (functionData.length > 0 && dataValue.value && retData) {
35
83
  node.data.map((d) => {
@@ -49,10 +97,12 @@ export function setDefaultNodeValidat(node, retData) {
49
97
  })
50
98
  // console.log('定制函数=====')
51
99
  try {
52
- const func = new Function('pen', 'params', dataValue.value)
53
- func(node, JSON.stringify(retData))
100
+ const func = new Function('pen', 'params', dataValue.value);
101
+ func(node, JSON.stringify(retData));
54
102
  }catch (e) {
55
- console.log(`自定义函数 ${node.id} 出错>>>`, e);
103
+ console.log(`自定义函数出错>>>`,);
104
+ console.log(`目标元件:${node.id}>>>`,);
105
+ console.log(`目标元件方位:X->${node.rect.x},Y->${node.rect.y}>>>`,);
56
106
  }
57
107
  } else {
58
108
  // console.log('默认函数')
@@ -66,4 +116,23 @@ export function setDefaultNodeValidat(node, retData) {
66
116
  }
67
117
  }
68
118
  //return node;
69
- }
119
+ }
120
+ // 初始化tab节点数据
121
+ export function initSwitchTabData(node) {
122
+ if (node.tags && node.tags.length > 0) {
123
+ const tagTypeData = node.tags.find((t) => {
124
+ return t === 'statisticType' || t.includes('switchTabType');
125
+ });
126
+ if (tagTypeData) {
127
+ let topologyChangeData = switchTabDataPool;
128
+ let keyName = node.bindStaticId ? `${tagTypeData}Data` : `${tagTypeData}AreaData`;
129
+ if (!topologyChangeData[keyName]) topologyChangeData[keyName] = {};
130
+ topologyChangeData[keyName][node.id] = node;
131
+ }else {
132
+ const isTabs = node.events && node.events.find((ev) => ev.action === 8);
133
+ if(isTabs) {
134
+ console.log('>>>未能找到绑定的标签数据,请检查绑定的Tabs标签是否包含switchTabType前缀>>>')
135
+ }
136
+ }
137
+ }
138
+ }
@@ -12,20 +12,18 @@ export interface MoveDataType {
12
12
  HoverAnchors?: string | number;
13
13
  Rotate?: string | number;
14
14
  }
15
- export const moveDataType: MoveDataType;
16
15
  export interface DownDataType {
17
16
  Window?: string | number;
18
17
  Target?: string | number;
19
18
  Showhide?: string | number;
20
19
  Tabswitch?: string | number;
20
+ Formselect?: string | number;
21
21
  }
22
- export const downDataType: DownDataType;
23
22
  export interface PreviewType {
24
23
  Dcim?: string;
25
24
  Topology?: string;
26
25
  Logo?: string;
27
26
  }
28
- export const previewType: PreviewType;
29
27
  export interface AnimateType {
30
28
  LeftFlow?: string;
31
29
  RightFlow?: string;
@@ -38,4 +36,12 @@ export interface AnimateType {
38
36
  Show?: string;
39
37
  Rotate?: string;
40
38
  }
39
+ export interface SelectStaticType {
40
+ static?:number;
41
+ show?:number;
42
+ }
43
+ export const moveDataType: MoveDataType;
44
+ export const downDataType: DownDataType;
45
+ export const previewType: PreviewType;
41
46
  export const animateType: AnimateType;
47
+ export const selectStaticType: SelectStaticType;
@@ -15,7 +15,8 @@ export const downDataType = {
15
15
  Window: 'window',
16
16
  Target: 'target',
17
17
  Showhide: 'showhide',
18
- Tabswitch: 'Tabswitch'
18
+ Tabswitch: 'Tabswitch',
19
+ Formselect: 'Formselect'
19
20
  };
20
21
  export const previewType = {
21
22
  Dcim: 'dcim',
@@ -33,4 +34,8 @@ export const animateType = {
33
34
  Error: 'error',
34
35
  Show: 'show',
35
36
  Rotate: 'rotate'
37
+ };
38
+ export const selectStaticType = {
39
+ static: 1,
40
+ show: 2
36
41
  };
@@ -1,7 +1,10 @@
1
1
  import {Node} from "../models";
2
2
 
3
+ export declare function getEchartsRealData(node: {}, data: []): void;
4
+ export declare function setInitConfData(data: object): void;
3
5
  export declare function setTagIdData(data: any): [];
4
6
  export declare function setKpiAddrData(data: any): [];
5
7
  export declare function setAssetIdData(data: any): [];
6
8
  export declare function setAreaIdData(data: any): [];
9
+ export declare function setVarValueData(data: any): [];
7
10
  export declare function setThreeCategoryIdData(pen: Node, data: any): [];