dcim-topology2d 2.0.8 → 2.2.0

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 (63) hide show
  1. package/chart-diagram/src/echarts/index.js +6 -3
  2. package/chart-diagram/src/utils/changeOptions.d.ts +1 -0
  3. package/chart-diagram/src/utils/changeOptions.js +41 -35
  4. package/chart-diagram/src/utils/conversion.d.ts +1 -1
  5. package/chart-diagram/src/utils/conversion.js +143 -15
  6. package/chart-diagram/src/utils/formatter.d.ts +1 -1
  7. package/chart-diagram/src/utils/formatter.js +51 -15
  8. package/chart-diagram/src/utils/index.d.ts +1 -0
  9. package/chart-diagram/src/utils/index.js +1 -0
  10. package/chart-diagram/src/utils/render.js +43 -52
  11. package/chart-diagram/src/utils/surfaceParametricConversion.d.ts +3 -0
  12. package/chart-diagram/src/utils/surfaceParametricConversion.js +252 -0
  13. package/core/src/common.js +24 -15
  14. package/core/src/core.d.ts +2 -0
  15. package/core/src/core.js +75 -23
  16. package/core/src/element/common.d.ts +2 -1
  17. package/core/src/element/common.js +27 -18
  18. package/core/src/element/datePicker.d.ts +3 -0
  19. package/core/src/element/datePicker.js +44 -0
  20. package/core/src/element/index.d.ts +2 -1
  21. package/core/src/element/index.js +3 -1
  22. package/core/src/element/select.d.ts +1 -1
  23. package/core/src/element/select.js +15 -5
  24. package/core/src/element/tab.js +6 -9
  25. package/core/src/element/time.d.ts +3 -0
  26. package/core/src/element/time.js +44 -0
  27. package/core/src/healps/changeData.js +61 -41
  28. package/core/src/middles/default.js +53 -43
  29. package/core/src/middles/nodes/formDatePicker.d.ts +2 -0
  30. package/core/src/middles/nodes/formDatePicker.js +107 -0
  31. package/core/src/middles/nodes/formselect.js +20 -4
  32. package/core/src/middles/nodes/index.d.ts +4 -1
  33. package/core/src/middles/nodes/index.js +4 -0
  34. package/core/src/middles/nodes/switchs.d.ts +2 -0
  35. package/core/src/middles/nodes/switchs.js +46 -0
  36. package/core/src/middles/nodes/time.d.ts +2 -0
  37. package/core/src/middles/nodes/time.js +98 -0
  38. package/core/src/models/line.js +7 -7
  39. package/core/src/models/node.js +88 -74
  40. package/core/src/models/pen.js +11 -11
  41. package/core/src/offscreen.js +19 -19
  42. package/core/src/preview.d.ts +1 -0
  43. package/core/src/preview.js +44 -11
  44. package/core/src/store/data.d.ts +7 -0
  45. package/core/src/store/data.js +15 -2
  46. package/core/src/utils/assignment.d.ts +2 -1
  47. package/core/src/utils/assignment.js +55 -12
  48. package/core/src/utils/construction.d.ts +24 -0
  49. package/core/src/utils/construction.js +22 -1
  50. package/core/src/utils/conversion.d.ts +4 -0
  51. package/core/src/utils/conversion.js +151 -0
  52. package/core/src/utils/math.d.ts +0 -1
  53. package/core/src/utils/math.js +0 -3
  54. package/core/src/utils/onmousevent.js +1 -1
  55. package/core/src/utils/params.d.ts +1 -0
  56. package/core/src/utils/params.js +80 -4
  57. package/package.json +1 -1
  58. package/store/default.js +22 -0
  59. package/store/index.js +2 -1
  60. package/style/common.css +0 -3
  61. package/style/datePicker.css +44 -0
  62. package/style/editor.css +3 -0
  63. package/style/index.css +1 -0
@@ -0,0 +1,44 @@
1
+ import {commonStore} from "../store";
2
+ // 创建datePicker依赖DOM
3
+ export function createDatePickerElement(node) {
4
+ const pickerBarEle = document.createElement('div');
5
+ pickerBarEle.setAttribute('id', node.id);
6
+ pickerBarEle.setAttribute('class', 'topology-datePicker');
7
+ pickerBarEle.innerHTML = `<svg class="icon-date" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14.000000" height="14.000000" fill="none" customFrame="#000000">
8
+ \t<path id="icon-日历" d="M13.4167 1.16667L10.5 1.16667L10.5 0L9.33333 0L9.33333 1.16667L4.66667 1.16667L4.66667 0L3.5 0L3.5 1.16667L0.583333 1.16667C0.2625 1.16667 0 1.42917 0 1.75L0 13.4167C0 13.7375 0.2625 14 0.583333 14L13.4167 14C13.7375 14 14 13.7375 14 13.4167L14 1.75C14 1.42917 13.7375 1.16667 13.4167 1.16667ZM12.8333 12.8333L1.16667 12.8333L1.16667 4.66667L12.8333 4.66667L12.8333 12.8333ZM4.66667 7L2.33333 7L2.33333 5.83333L4.66667 5.83333L4.66667 7ZM8.16667 7L5.83333 7L5.83333 5.83333L8.16667 5.83333L8.16667 7ZM11.6667 7L9.33333 7L9.33333 5.83333L11.6667 5.83333L11.6667 7ZM4.66667 9.33333L2.33333 9.33333L2.33333 8.16667L4.66667 8.16667L4.66667 9.33333ZM8.16667 9.33333L5.83333 9.33333L5.83333 8.16667L8.16667 8.16667L8.16667 9.33333ZM11.6667 9.33333L9.33333 9.33333L9.33333 8.16667L11.6667 8.16667L11.6667 9.33333ZM4.66667 11.6667L2.33333 11.6667L2.33333 10.5L4.66667 10.5L4.66667 11.6667ZM8.16667 11.6667L5.83333 11.6667L5.83333 10.5L8.16667 10.5L8.16667 11.6667Z" fill="rgb(64,244,255)" fill-rule="nonzero" />
9
+ </svg>
10
+ <svg class="icon-arrow" viewBox="0 0 10 6" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10.000000" height="6.000000" fill="none" customFrame="#000000">
11
+ <path id="箭头" d="M5 0C5.14734 0 5.28865 0.0632141 5.39284 0.175736L9.83728 4.97574C10.0542 5.21005 10.0542 5.58995 9.83728 5.82426C9.62032 6.05858 9.26857 6.05858 9.05161 5.82426L5 1.44853L0.948393 5.82426C0.731435 6.05858 0.379676 6.05858 0.162718 5.82426C-0.0542395 5.58995 -0.0542395 5.21005 0.162718 4.97574L4.60716 0.175736C4.71135 0.0632141 4.85266 0 5 0Z" fill="rgb(23,206,230)" fill-rule="evenodd" transform="matrix(1,0,0,-1,0,6)" />
12
+ </svg>
13
+ <input id='picker${node.id}' class="dataPickerInput" type="text" name='dataPicker${node.id}' value='${node.pickerOptions.value}' placeholder="请选择" readonly />`;
14
+
15
+ return pickerBarEle;
16
+ }
17
+
18
+ // datePicker样式配置
19
+ export function setDataPickerElementStyle(node) {
20
+ const {pickerDataPool, data} = commonStore[node.TID];
21
+ const pickerDom = pickerDataPool[node.id].dom;
22
+ const padding = `${node.paddingTop}px ${node.paddingRight}px ${node.paddingBottom}px ${node.paddingLeft}px`;
23
+ const containerStyle = pickerDom.container.getAttribute('style');
24
+ pickerDom.container.style.cssText =`${containerStyle}padding: ${padding}`;
25
+
26
+ if (!pickerDom.iconDate) pickerDom.iconDate = pickerDom.container.querySelector('.icon-date');
27
+ if (!pickerDom.iconArrow) pickerDom.iconArrow = pickerDom.container.querySelector('.icon-arrow');
28
+ if (!pickerDom.input) pickerDom.input = pickerDom.container.querySelector('.dataPickerInput');
29
+
30
+ const round = `${node.font.fontSize + data.scale * 2}px`;
31
+ const parts = node.strokeStyle.match(/([\d.]+)/g);
32
+ const fillColor = parts ? `rgba(${parts[0]},${parts[1]},${parts[2]},1)` : node.strokeStyle;
33
+
34
+ pickerDom.iconDate.style.cssText = `width: ${round};height: ${round};left: ${node.font.fontSize}px`;
35
+ pickerDom.iconDate.querySelector('path').style.fill = fillColor;
36
+
37
+ const width = node.font.fontSize - data.scale * 2;
38
+ const height = node.font.fontSize - data.scale * 6;
39
+
40
+ pickerDom.iconArrow.style.cssText = `width: ${width}px;height: ${height}px;right: ${width}px`;
41
+ pickerDom.iconArrow.querySelector('path').style.fill = fillColor;
42
+
43
+ pickerDom.input.style.cssText = `font-size: ${node.font.fontSize}px;color: ${node.font.color}`;
44
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './common';
2
2
  export * from './iframe';
3
3
  export * from './select';
4
- export * from './tab';
4
+ export * from './tab';
5
+ export * from './datePicker';
@@ -1,4 +1,6 @@
1
1
  export * from './common';
2
2
  export * from './iframe';
3
3
  export * from './select';
4
- export * from './tab';
4
+ export * from './tab';
5
+ export * from './time';
6
+ export * from './datePicker';
@@ -6,6 +6,6 @@ export declare function createSelectOptions(data: [], node: Node): string;
6
6
  export declare function getSelectedData(e: Event, data: any, editData: any): void;
7
7
  export declare function setSelectInteractiveState(selected: any, node: Node): void;
8
8
  export declare function resetSelectInteractiveState(node: Node): void;
9
- export declare function setSelectDropdownInteractiveState(node: any, staticType: any, type: any): void;
9
+ export declare function setSelectDropdownInteractiveState(node: any, type: any): void;
10
10
  export declare function setSelectElementPosition(node: Node, type: string): void;
11
11
  export declare function setSelectElementTheme(node: Node): void;
@@ -86,13 +86,11 @@ export function resetSelectInteractiveState(node) {
86
86
  /**
87
87
  * 配置下拉options容器的交互状态,展开和收起
88
88
  * @param node 下拉元件节点数据
89
- * @param staticType 下拉功能类型:1: 数据统计;2:数据展示;3:显示隐藏
90
89
  * @param type 功能作用区域类型:Dcim,Topology,Logo
91
90
  */
92
- export function setSelectDropdownInteractiveState(node, staticType, type) {
91
+ export function setSelectDropdownInteractiveState(node, type) {
93
92
  const currentStore = commonStore[node.TID];
94
93
  const selectNode = currentStore.selectDataPool[node.id];
95
- if(!selectNode.staticType) selectNode.staticType = staticType;
96
94
  if(!selectNode) return;
97
95
  if(downId !== node.id && type === previewType.Dcim) {
98
96
  // 点击的不是同一个下拉则重置交互样式,清空数据
@@ -206,14 +204,26 @@ export function getSelectedData(e, data, editData) {
206
204
  }
207
205
  if(staticType === selectStaticType.visible) {
208
206
  // 显示隐藏
207
+ const optionNode = data.formData.bindBlockId && currentStore.echartsOptionsPool[data.formData.bindBlockId];
208
+ if(optionNode) {
209
+ // 有绑定图表则切换图表数据
210
+ const selecteRealData = currentStore.selectRealDataPool[optionNode.data.id];
211
+
212
+ selectNode.node.selected.id = selecteRealData && selecteRealData[order] && selecteRealData[order].id;
213
+
214
+ currentStore.echartsRealDataPool[optionNode.data.id] = currentStore.echartsRealDataPool[node.id];
215
+
216
+ setMapDataOptions(optionNode.option, optionNode.data);
217
+ }
209
218
  const optionsVisibleData = currentStore.selectTabDataPool[data.id];
210
219
  if(!optionsVisibleData || !optionsVisibleData.size) return;
211
220
  for(const [key, value] of optionsVisibleData){
212
- const eque = node.id === value.tag;
221
+ const optionId = node.optionId || node.id;
222
+ const eque = optionId === value.tag;
213
223
  currentStore.data.pens[value.order].visible = eque;
214
224
  currentStore.data.pens[value.order].visibleSwitch = eque;
215
225
  value.visible = eque;
216
- setElementSwitchTabState(value);
226
+ setElementSwitchTabState(currentStore.data.pens[value.order]);
217
227
  }
218
228
  Store.set(`${data.TID}-LT:render`, true);
219
229
  }
@@ -1,23 +1,20 @@
1
- import {jsonLength} from '../utils';
2
1
  import {commonStore} from "../store";
3
2
  // 设置tab切换显示隐藏时的 Dom元件状态
4
3
  export function setElementSwitchTabState(node) {
5
4
  if(node.children && node.children.length) {
6
5
  node.children.map((ch) => {
7
6
  ch.visible = node.visible;
7
+ ch.visibleSwitch = node.visible;
8
8
  setElementSwitchTabState(ch);
9
9
  })
10
10
  }
11
- if(!(node.name === 'echarts' || node.name === 'select')) return;
12
- if(typeof commonStore[node.TID].elementInteractivePoor.elementDataLength !== 'number') {
13
- commonStore[node.TID].elementInteractivePoor.elementDataLength = jsonLength(commonStore[node.TID].echartsDataPool) || jsonLength(commonStore[node.TID].selectDataPool);
14
- }
15
- if(!commonStore[node.TID].elementInteractivePoor.elementDataLength) return;
16
- const ele = commonStore[node.TID].echartsDataPool[node.id] && commonStore[node.TID].echartsDataPool[node.id].div ||
17
- commonStore[node.TID].selectDataPool[node.id] && commonStore[node.TID].selectDataPool[node.id].dom.selectEle;
11
+ if(node.attribute !== 'dom') return;
12
+ const currentStore = commonStore[node.TID];
13
+ if(!currentStore.elementInteractivePoor.dom) return;
14
+ const ele = currentStore.elementInteractivePoor.dom[node.id];
18
15
  if(ele) {
19
16
  ele.style.display = !node.visible ? 'none': 'block';
20
17
  }else {
21
- commonStore[node.TID].data.dataResize = 1;
18
+ currentStore.data.dataResize = 1;
22
19
  }
23
20
  }
@@ -0,0 +1,3 @@
1
+ import { Node } from '../models';
2
+
3
+ export declare function createTimeElement(node: Node): HTMLTimeElement;
@@ -0,0 +1,44 @@
1
+ // 创建时间组件
2
+ export function createTimeElement(node) {
3
+ const timeBox = document.createElement('div');
4
+ // timeBox.scrolling = 'no';
5
+ timeBox.width = node.rect.width;
6
+ timeBox.height = node.rect.height;
7
+ let children =
8
+ `<div class="timeWrapper" style="display: flex;flex-direction: initial; justify-content: center; font-size: ${node.font.fontSize}px;width:100%;height:100%; line-height:${timeBox.height}px; color:${node.font.color}; font-family:${node.font.fontFamily}">`+
9
+ `<div class="timeList" style="position: relative;display: flex; flex-direction: column;flex:4;height: 100%;overflow: hidden;text-align: center;">
10
+ <div class="timeBox" style="position: relative;width: 100%;height: 100%;overflow: hidden;">
11
+ <div class="timeTextUp h" style="position: relative;clip-path: polygon(0 0,100% 0,100% 49%,0 49%); background-color: rgba(255,255,255,0.1);border-radius: 20px;height: 100%;">${node.h}</div>
12
+ <div class="timeTextDown h" style="position: absolute;clip-path: polygon(0 51%,100% 51%,100% 100%,0 100%);left: 0;top: 0;width: 100%;height: 100%; background-color: rgba(255,255,255,0.1);border-radius: 20px;">${node.h}</div>
13
+ </div>
14
+ </div>`+
15
+ `<div class="split" style="flex:1; position: relative;line-height:${timeBox.height}px">:</div>`+
16
+ `<div class="timeList" style="position: relative;display: flex; flex-direction: column;flex:4;height: 100%;overflow: hidden;text-align: center;">
17
+ <div class="timeBox" style="position: relative;width: 100%;height: 100%;overflow: hidden;">
18
+ <div class="timeTextUp m" style="position: relative;clip-path: polygon(0 0,100% 0,100% 49%,0 49%); background-color: rgba(255,255,255,0.1);border-radius: 20px; height: 100%;">${node.m}</div>
19
+ <div class="timeTextDown m" style="position: absolute;clip-path: polygon(0 51%,100% 51%,100% 100%,0 100%);left: 0;top: 0;width: 100%;height: 100%; background-color: rgba(255,255,255,0.1);border-radius: 20px;">${node.m}</div>
20
+ </div>
21
+ </div>`+
22
+ `<div class="split" style="flex:1; position: relative;line-height:${timeBox.height}px">:</div>`+
23
+ `<div class="timeList" style="position: relative;display: flex; flex-direction: column;flex:4;height: 100%;overflow: hidden;text-align: center;">
24
+ <div class="timeBox" style="position: relative;width: 100%;height: 100%;overflow: hidden;">
25
+ <div class="timeTextUp s" style="position: relative;clip-path: polygon(0 0,100% 0,100% 49%,0 49%); background-color: rgba(255,255,255,0.1);border-radius: 20px; height: 100%;">${node.s}</div>
26
+ <div class="timeTextDown s" style="position: absolute;clip-path: polygon(0 51%,100% 51%,100% 100%,0 100%);left: 0;top: 0;width: 100%;height: 100%; background-color: rgba(255,255,255,0.1);border-radius: 20px;">${node.s}</div>
27
+ </div>
28
+ </div>`+
29
+ `</div>`
30
+ timeBox.setAttribute('id', node.id);
31
+ timeBox.setAttribute('class', 'topology2dConfTime');
32
+ timeBox.innerHTML = children;
33
+ return timeBox;
34
+ }
35
+ export function updateTimeStyle(node, time) {
36
+ time.querySelector('.timeWrapper').style.lineHeight = node.rect.height+'px';
37
+ time.querySelector('.timeWrapper').style.fontSize = node.font.fontSize+'px';
38
+ time.querySelector('.timeWrapper').style.fontFamily = node.font.fontFamily;
39
+ time.querySelector('.timeWrapper').style.color = node.font.color;
40
+ time.querySelectorAll('.split').forEach(element => {
41
+ element.style.lineHeight = node.rect.height+'px';
42
+ });
43
+
44
+ }
@@ -1,11 +1,11 @@
1
1
  //let DETAILDATA = null;
2
- import {commonStore} from '../store';
2
+ import { commonStore } from '../store';
3
3
  import { getEchartsRealData } from '../utils/conversion';
4
4
  export function setConfItemNode(pen, syn_synata) {
5
5
  const entranceGuard = pen.events.find((ev) => {
6
6
  return ev.value === 'entranceGuard';
7
7
  });
8
- if(entranceGuard) {
8
+ if (entranceGuard) {
9
9
  // 绑定门禁的元件实时数据
10
10
  const nullUndefinedRegex = /^(?:null|undefined|\s*)$/;
11
11
  const doorData = syn_synata.doorData && syn_synata.doorData[entranceGuard.params];
@@ -13,59 +13,64 @@ export function setConfItemNode(pen, syn_synata) {
13
13
  pen.text = doorState === 1 ? '开门' : '关门'; // 1-开门,其他值为关门
14
14
  }
15
15
  if (!pen.data) return;
16
- if(commonStore[pen.TID]) commonStore[pen.TID].data.dataResize = 1;
16
+ if (commonStore[pen.TID]) commonStore[pen.TID].data.dataResize = 1;
17
17
  let isAlarm = false; // 判断元件绑定的数据中是否有告警发生,用于九所项目服务器自身监控功能
18
- if(pen.data instanceof Array) {
18
+ if (pen.data instanceof Array) {
19
19
  let _syn = null;
20
20
  let isResetVal = false;
21
- const {areaData, assetData, kpiData, tagData, asset} = syn_synata
21
+ const { areaData, assetData, componentData, kpiData, tagData, asset } = syn_synata;
22
+ const comData = componentData && componentData[pen.id];
22
23
  pen.data.map((d) => {
23
24
  const key = d.key;
24
25
  let value = d.value;
25
- const assetItem = assetData[value];
26
- const areaItem = areaData[value];
27
- const kpiItem = kpiData[value];
28
- if(key === 'tagId') value = d.tagId ? d.tagId : d.value;
29
- const tagItem = tagData[value];
26
+ if (key === 'tagId') value = d.tagId ? d.tagId : d.value;
30
27
  //console.log('key===========', d)
31
28
  if (key === 'assetKey' && d.value === 'assetName' && asset) {
29
+
32
30
  pen.text = asset.assetName;
33
- }else if (key === 'assetId' && assetItem) {
34
- _syn = assetItem;
31
+
32
+ } else if (key === 'assetId') {
33
+
34
+ _syn = comData || assetData[value];
35
+
35
36
  // if(value === '264'){console.log('_syn',_syn,pen.name,parseInt(_syn.state))}
36
- }else if (key === 'areaId' && areaItem) {
37
- _syn = areaItem;
38
- }else if (key === 'tagId' && tagItem) {
39
- _syn = tagItem;
40
- if(_syn.kpiName !== '通讯状态' || pen.name !== 'circle'){
37
+ } else if (key === 'areaId') {
38
+
39
+ _syn = comData || areaData[value];
40
+
41
+ } else if (key === 'tagId' && (comData || tagData[value])) {
42
+
43
+ _syn = comData || tagData[value];
44
+
45
+ if (_syn.kpiName !== '通讯状态' || pen.name !== 'circle') {
41
46
  isResetVal = true;
42
47
  }
43
- const isControl = parseInt(tagItem.isControlDis); // 是否可控,0可控,1不可控
48
+ const isControl = parseInt(_syn.isControlDis); // 是否可控,0可控,1不可控
44
49
  //d.isControlDis = isControlDis
45
- if(!isControl) {
50
+ if (!isControl) {
46
51
  d.tagVal = value
47
- d.controlParams = tagItem
52
+ d.controlParams = _syn
48
53
  //Object.assign(d, tagItem)
49
54
  }
50
- }else if (key === 'kpiAddr' && kpiItem) {
51
- _syn = kpiItem;
55
+ } else if (key === 'kpiAddr' && (comData || kpiData[value])) {
56
+ _syn = comData || kpiData[value];
52
57
  isResetVal = true
53
- const isControl = parseInt(kpiItem.isControlDis); // 是否可控,0可控,1不可控
58
+ const isControl = parseInt(_syn.isControlDis); // 是否可控,0可控,1不可控
54
59
  //d.isControlDis = isControlDis
55
- if(!isControl) {
60
+ if (!isControl) {
56
61
  d.tagVal = value
57
- d.controlParams = kpiItem
62
+ d.controlParams = _syn
58
63
  // delete kpiItem[value]
59
64
  // Object.assign(d, kpiItem)
60
65
  }
61
66
  }
62
67
  })
63
- if(!_syn) return;
68
+ if (!_syn) return;
64
69
  // const type = parseInt(_syn.type) // 是否是开关量
65
70
  // 显示的值
66
71
  if (isResetVal) pen.text = `${_syn.value}${_syn.unit}`;
67
72
  const state = parseInt(_syn.state)
68
- if(!state && state !== 0) return
73
+ if (!state && state !== 0) return
69
74
  const name = pen.name
70
75
  // 显示的颜色
71
76
  let color = ''
@@ -83,9 +88,9 @@ export function setConfItemNode(pen, syn_synata) {
83
88
  let defaulColor = ''
84
89
  if (name === 'text') {
85
90
  defaulColor = 'defaultFontColor'
86
- }else if(name === 'line') {
91
+ } else if (name === 'line') {
87
92
  defaulColor = 'defaultStrokeStyle'
88
- }else {
93
+ } else {
89
94
  defaulColor = 'defaultFillStyle'
90
95
  }
91
96
  color = pen[defaulColor]
@@ -97,17 +102,24 @@ export function setConfItemNode(pen, syn_synata) {
97
102
  // 显示的属性
98
103
  if (name === 'text') {
99
104
  pen.font.color = color
100
- }else if(name === 'line') {
105
+ } else if (name === 'line') {
101
106
  pen.strokeStyle = color
102
107
  pen.text = ''
103
- }else {
108
+ } else if (name === 'switchs') {
109
+ //获取值说明中的开值 默认为第一个值为开
110
+ let openValue = getOpenValue(_syn.valExplain)
111
+ pen.isOpen = _syn.v == openValue;
112
+ pen.fillStyle = pen.isOpen ? pen.visitStrokeStyle : pen.strokeStyle;
113
+ pen.text = '';
114
+ }
115
+ else {
104
116
  pen.fillStyle = color
105
117
  }
106
118
  if (name === 'electricFan') setFanData(pen, _syn)
107
- }else {
119
+ } else {
108
120
  if (pen.elementRendered) pen.elementRendered = false;
109
121
  if (pen.data.echarts) {
110
- const {echartDataValue} = syn_synata;
122
+ const { echartDataValue } = syn_synata;
111
123
  const seriesData = echartDataValue;
112
124
  const realData = pen.data.params && seriesData && Object.keys(seriesData).length && seriesData[pen.data.params.id];
113
125
  if (Array.isArray(realData) && pen.data.params && pen.data.params.displayMode !== 7) {
@@ -137,24 +149,24 @@ export function setFanData(pen, syncData) {
137
149
  let runState = false
138
150
  let percentage = 1
139
151
  const value = parseInt(syncData.v)
140
- if(pen.fanValType == '1'){
141
- if(value > pen.fanMinVal && value <= pen.fanMaxVal) {
152
+ if (pen.fanValType == '1') {
153
+ if (value > pen.fanMinVal && value <= pen.fanMaxVal) {
142
154
  runState = true
143
- percentage = value/(pen.fanMaxVal-pen.fanMinVal)
155
+ percentage = value / (pen.fanMaxVal - pen.fanMinVal)
144
156
  }
145
- }else if(pen.fanValType == '2'){
146
- if(pen.fanNorVal === value) runState = true
157
+ } else if (pen.fanValType == '2') {
158
+ if (pen.fanNorVal === value) runState = true
147
159
  }
148
- if(runState){
160
+ if (runState) {
149
161
  addAnimateByRevolve(pen, percentage)
150
162
  pen.animatePlay = true
151
- }else{
163
+ } else {
152
164
  pen.animatePlay = false
153
165
  }
154
166
  }
155
167
 
156
168
  export function addAnimateByRevolve(pen, percentage) {
157
- let time = 200/pen.fanSpeed/percentage
169
+ let time = 200 / pen.fanSpeed / percentage
158
170
  const state = JSON.parse(JSON.stringify(pen))
159
171
  delete state.TID
160
172
  delete state.animateFrames
@@ -169,3 +181,11 @@ export function addAnimateByRevolve(pen, percentage) {
169
181
  pen.animateDuration = time;
170
182
 
171
183
  }
184
+
185
+ export function getOpenValue(explain) {
186
+ let value = 1
187
+ if (!explain) return value
188
+ value = explain.split(',')[0].split('=')[0];
189
+ return value
190
+
191
+ }
@@ -1,51 +1,51 @@
1
1
  import {
2
- arrowAnchors,
3
- leftArrow, leftArrowIconRect, leftArrowTextRect,
4
- rightArrow, rightArrowIconRect, rightArrowTextRect,
5
- twowayArrow, twowayArrowIconRect, twowayArrowTextRect,
6
- rectangle, rectangleIconRect, rectangleTextRect,
7
- diamond, diamondIconRect, diamondTextRect,
8
- text, file, formtable, tablePagination, iframePrimeval,formSelect,
9
- line as nodeLine, lineAnchors, lineIconRect, lineTextRect,
10
- circle, circleIconRect, circleTextRect, circleAnchors,
11
- triangle, triangleIconRect, triangleTextRect, triangleAnchors,
12
- pentagon, pentagonIconRect, pentagonTextRect, pentagonAnchors,
13
- hexagon, hexagonAnchors, hexagonIconRect, hexagonTextRect,
14
- pentagram, pentagramAnchors, pentagramIconRect, pentagramTextRect,
15
- cloud, cloudAnchors, cloudIconRect, cloudTextRect,
16
- message, messageIconRect, messageTextRect, messageAnchors,
17
- imageIconRect, imageTextRect,
18
- cube, cubeAnchors, cubeIconRect, cubeTextRect,
19
- people, peopleIconRect, peopleTextRect,
20
- arbitraryGraph, arbitraryGraphAnchors,
2
+ arrowAnchors,
3
+ leftArrow, leftArrowIconRect, leftArrowTextRect,
4
+ rightArrow, rightArrowIconRect, rightArrowTextRect,
5
+ twowayArrow, twowayArrowIconRect, twowayArrowTextRect,
6
+ rectangle, rectangleIconRect, rectangleTextRect,
7
+ diamond, diamondIconRect, diamondTextRect,
8
+ text, file, formtable, tablePagination, iframePrimeval, formSelect, fromDatePicker,
9
+ line as nodeLine, lineAnchors, lineIconRect, lineTextRect,
10
+ circle, circleIconRect, circleTextRect, circleAnchors,
11
+ triangle, triangleIconRect, triangleTextRect, triangleAnchors,
12
+ pentagon, pentagonIconRect, pentagonTextRect, pentagonAnchors,
13
+ hexagon, hexagonAnchors, hexagonIconRect, hexagonTextRect,
14
+ pentagram, pentagramAnchors, pentagramIconRect, pentagramTextRect,
15
+ cloud, cloudAnchors, cloudIconRect, cloudTextRect,
16
+ message, messageIconRect, messageTextRect, messageAnchors,
17
+ imageIconRect, imageTextRect,
18
+ cube, cubeAnchors, cubeIconRect, cubeTextRect,
19
+ people, peopleIconRect, peopleTextRect,
20
+ arbitraryGraph, arbitraryGraphAnchors, time, switchs
21
21
  } from './nodes';
22
22
  import {
23
- line,
24
- lineControlPoints,
25
- calcLineControlPoints,
26
- polyline,
27
- polylineControlPoints,
28
- pointInPolyline,
29
- calcPolylineControlPoints,
30
- dockPolylineControlPoint,
31
- curve,
32
- curveControlPoints,
33
- pointInCurve,
34
- calcCurveControlPoints,
35
- mind,
36
- calcMindControlPoints,
37
- mindControlPoints,
38
- pointInMind
23
+ line,
24
+ lineControlPoints,
25
+ calcLineControlPoints,
26
+ polyline,
27
+ polylineControlPoints,
28
+ pointInPolyline,
29
+ calcPolylineControlPoints,
30
+ dockPolylineControlPoint,
31
+ curve,
32
+ curveControlPoints,
33
+ pointInCurve,
34
+ calcCurveControlPoints,
35
+ mind,
36
+ calcMindControlPoints,
37
+ mindControlPoints,
38
+ pointInMind
39
39
  } from './lines';
40
40
  import {
41
- triangleSolid,
42
- triangle as arrowTriangle,
43
- diamondSolid,
44
- diamond as arrowDiamond,
45
- circleSolid, circle as arrowCircle,
46
- lineUp,
47
- lineDown,
48
- line as arrowLine
41
+ triangleSolid,
42
+ triangle as arrowTriangle,
43
+ diamondSolid,
44
+ diamond as arrowDiamond,
45
+ circleSolid, circle as arrowCircle,
46
+ lineUp,
47
+ lineDown,
48
+ line as arrowLine
49
49
  } from './arrows';
50
50
  // Functions of drawing a node.
51
51
  export var drawNodeFns = {};
@@ -62,6 +62,8 @@ export var drawArrowFns = {};
62
62
  function init() {
63
63
  console.log('Init middles.');
64
64
  // ********Default nodes.*******
65
+ // datePicker
66
+ drawNodeFns.datePicker = fromDatePicker;
65
67
  // select
66
68
  drawNodeFns.select = formSelect;
67
69
  // iframe
@@ -199,6 +201,14 @@ function init() {
199
201
  drawArrowFns.lineUp = lineUp;
200
202
  drawArrowFns.lineDown = lineDown;
201
203
  // ********end********
204
+ // 当前时间
205
+ drawNodeFns.time = time;
206
+ iconRectFns.time = rectangleIconRect;
207
+ textRectFns.time = rectangleTextRect;
208
+ // 开关
209
+ drawNodeFns.switchs = switchs;
210
+ iconRectFns.switchs = rectangleIconRect;
211
+ textRectFns.switchs = rectangleTextRect;
202
212
  }
203
213
  init();
204
214
  // registerNode: Register a custom node.
@@ -0,0 +1,2 @@
1
+ import { Node } from '../../models';
2
+ export declare function fromDatePicker(ctx: CanvasRenderingContext2D, node: Node): void;
@@ -0,0 +1,107 @@
1
+ import {Store} from "le5le-store";
2
+ import {rectangle} from './rectangle';
3
+ import { createDatePickerElement, loadJS, setDataPickerElementStyle } from '../../element';
4
+ import { s8, datePickerValueFormatting } from '../../utils';
5
+ import {commonStore} from "../../store";
6
+ import {datePickerType} from "../../../../store";
7
+
8
+ export async function fromDatePicker(ctx, node) {
9
+ // 绘制一个底图,类似于占位符。
10
+ rectangle(ctx, node);
11
+
12
+ if (!window.datePickerRegister) {
13
+ //未注册datePicker插件
14
+ const datePickerRegisterData = await loadJS(`${window.location.origin}/libary/laydate/laydate.js`).catch((e) => {
15
+ console.error('datePicker插件加载失败>>>', e);
16
+ });
17
+ if(!datePickerRegisterData) return;
18
+ }
19
+
20
+ const currentStore = commonStore[node.TID];
21
+
22
+ if (!currentStore.pickerDataPool[node.id]) {
23
+ // 未创建该元件
24
+ node.elementId = s8();
25
+
26
+ if(currentStore.mqttParams.dataConfig.picker){
27
+ // 日期元件关联绑定的元件数据
28
+ const pickerConfig = currentStore.mqttParams.dataConfig.picker;
29
+ for (let [key, config] of pickerConfig.entries()){
30
+ if(config.dateId === node.id) {
31
+ node.formData.realIds = node.formData.realIds ? `${node.formData.realIds},${key}` : key;
32
+ node.formData.selected = config.dateStr;
33
+ }
34
+ }
35
+ }
36
+
37
+ const format = node.pickerOptions.format;
38
+ const valueType = node.formData.valueType;
39
+ const dateType = node.pickerOptions.type;
40
+ node.pickerOptions.value = node.formData.selected || datePickerValueFormatting({
41
+ formatType: format,
42
+ valueType
43
+ }).dateStr;
44
+ const datePicker = createDatePickerElement(node);
45
+ currentStore.pickerDataPool[node.id] = {
46
+ format,
47
+ valueType,
48
+ dateType,
49
+ dom: {
50
+ container: datePicker
51
+ }
52
+ };
53
+
54
+ document.body.appendChild(datePicker);
55
+ // 添加当前节点到div层
56
+ node.addToDiv();
57
+ setDataPickerElementStyle(node);
58
+ if(window.location.pathname.includes('workspace') && currentStore.options.type === 'topology') return;
59
+ const pickerOptions = Object.keys(node.pickerOptions).reduce((a,k) => (node.pickerOptions[k] && (a[k]=node.pickerOptions[k]), a), {}); // 过滤空数据
60
+ if((pickerOptions.min || pickerOptions.max) && (pickerOptions.type !== 'year' || pickerOptions.type !== 'month')){
61
+ // 字符转换
62
+ if(pickerOptions.min && isValidInteger(pickerOptions.min)) pickerOptions.min = Number(pickerOptions.min);
63
+ if(pickerOptions.max && isValidInteger(pickerOptions.max)) pickerOptions.max = Number(pickerOptions.max);
64
+ }
65
+ let layDatePicker = null;
66
+ pickerOptions.elem = `#picker${node.id}`;
67
+ pickerOptions.done = function (val, date) {
68
+ const { year, month, hours, minutes, seconds } = date;
69
+ const map = {
70
+ yyyy: year,
71
+ MM: String(month).padStart(2, '0'),
72
+ dd: String(date.date).padStart(2, '0'),
73
+ HH: String(hours).padStart(2, '0'),
74
+ mm: String(minutes).padStart(2, '0'),
75
+ ss: String(seconds).padStart(2, '0')
76
+ };
77
+ node.formData.selected = val;
78
+ date.valueStr = val;
79
+ date.value = datePickerType[layDatePicker.config.type].replace(/yyyy|MM|dd|HH|mm|ss/g, match => map[match]);
80
+ Store.set(`${node.TID}-EVENT:change`, {node, date});
81
+ }
82
+ setTimeout(() => {
83
+
84
+ layDatePicker = laydate.render(pickerOptions);
85
+
86
+ }, 100)
87
+ }else {
88
+ if(node.formData.resetStyle) {
89
+ // 重置样式
90
+ setDataPickerElementStyle(node);
91
+ node.formData.resetStyle = false;
92
+ }
93
+ if(node.formData.render) {
94
+ // 重置数据
95
+ node.formData.render = false;
96
+ const params = {
97
+ format: node.pickerOptions.format,
98
+ valueType: node.formData.valueType,
99
+ dateType: node.pickerOptions.type
100
+ };
101
+ Object.assign(currentStore.pickerDataPool[node.id], params);
102
+ }
103
+ }
104
+ }
105
+ function isValidInteger(str) {
106
+ return /^-?\d+$/.test(str) && str !== '-' && !str.startsWith('+');
107
+ }