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
@@ -1,7 +1,148 @@
1
1
  import {commonStore} from '../store';
2
2
  import {setElementSwitchTabState} from '../element';
3
3
  import {echartsStaticType} from '../utils';
4
+ import {datePickerType, datePickerTypeList} from "../../../store";
4
5
 
6
+ /**
7
+ * yyyy-MM-dd 格式转换
8
+ * @param valueType 默认值类型:1-默认当天
9
+ * @returns {string}
10
+ */
11
+ // function yyyMMddFormatting(valueType) {
12
+ // if(valueType === 1){
13
+ // // 默认当天
14
+ // return new Date().toISOString().split('T')[0];
15
+ // }
16
+ // }
17
+
18
+ /**
19
+ * yyyy-MM-dd HH:mm:ss 格式转换
20
+ * @param valueType 默认值类型:1-默认当天
21
+ * @returns {string}
22
+ */
23
+ // function yyyMMddHHmmssFormatting(valueType) {
24
+ // if(valueType === 1){
25
+ // // 默认当天
26
+ // return new Date().toISOString().replace('T', ' ').substring(0, 19);
27
+ // }
28
+ // }
29
+
30
+ /**
31
+ * yyyy 格式转换
32
+ * @param valueType 默认值类型:1-默认当天
33
+ * @returns {number}
34
+ */
35
+ // function yyyFormatting(valueType) {
36
+ // if(valueType === 1){
37
+ // // 默认当天
38
+ // return new new Date().getFullYear();
39
+ // }
40
+ // }
41
+
42
+ /**
43
+ * yyyy-MM 格式转换
44
+ * @param valueType 默认值类型:1-默认当天
45
+ * @returns {string}
46
+ */
47
+ // function yyyMMFormatting(valueType) {
48
+ // if(valueType === 1){
49
+ // // 默认当天
50
+ // return new Date().toISOString().slice(0, 7);
51
+ // }
52
+ // }
53
+
54
+ /**
55
+ * HH:mm:ss 格式转换
56
+ * @param valueType 默认值类型:1-默认当天
57
+ * @returns {string}
58
+ */
59
+ // function hhmmssddFormatting(valueType) {
60
+ // if(valueType === 1){
61
+ // // 默认当天
62
+ // Date.prototype.formatTime = function() {
63
+ // return [this.getHours(), this.getMinutes(), this.getSeconds()]
64
+ // .map(v => v.toString().padStart(2, '0')).join(':');
65
+ // };
66
+ // return new Date().formatTime();
67
+ // }
68
+ // }
69
+ export function pageZoom() {
70
+ let screenWidth = 0;
71
+ if(window.screen.width < 1920) {
72
+ // 1920 * 1080分辨率以下的适配
73
+ const zoom = window.screen.width / 1920;
74
+ screenWidth = Math.round(window.screen.width / zoom);
75
+ }else {
76
+ screenWidth = window.screen.width;
77
+ }
78
+ const order = window.screen.width > 1280 ? 12 : 8; // 差值计算
79
+ return window.innerWidth < screenWidth ? (window.innerWidth - order) / screenWidth : 1;
80
+ }
81
+
82
+ /**
83
+ * 日期转换
84
+ * @param data: {formatType: '日期格式', valueType: '默认值类型'}
85
+ * @returns {string}
86
+ */
87
+ export function datePickerValueFormatting(data) {
88
+ if(!Object.keys(datePickerType).length) {
89
+ // 获取日期类型map数据
90
+ const params = datePickerTypeList.reduce((obj, item) => {
91
+ obj[item['id']] = item.format;
92
+ return obj;
93
+ }, {});
94
+ Object.assign(datePickerType, params);
95
+ }
96
+ let now = new Date(); // data.valueType === 1 默认
97
+ const map = {
98
+ yyyy: now.getFullYear(),
99
+ MM: String(now.getMonth() + 1).padStart(2, '0'),
100
+ dd: String(now.getDate()).padStart(2, '0'),
101
+ HH: String(now.getHours()).padStart(2, '0'),
102
+ mm: String(now.getMinutes()).padStart(2, '0'),
103
+ ss: String(now.getSeconds()).padStart(2, '0')
104
+ };
105
+ const date = data.dateType ? datePickerType[data.dateType].replace(/yyyy|MM|dd|HH|mm|ss/g, match => map[match]) : '';
106
+ const dateStr = data.formatType.replace(/yyyy|MM|dd|HH|mm|ss/g, match => map[match]);
107
+ return {
108
+ date,
109
+ dateStr
110
+ };
111
+ }
112
+ // tab切换页签删除数据处理
113
+ export function getTabConnectSHConf(node) {
114
+ const switchTabType = node.tags.find((t) => {
115
+ return t.includes('switchTabType');
116
+ }); // 获取按钮组类型
117
+ const topologyChangeData = commonStore[node.TID].switchTabDataPool;
118
+ const tabAreaData = topologyChangeData[`${switchTabType}AreaData`];
119
+ const bindConfIds = node.bindStaticId.split(','); // tab元件绑定的元件id
120
+ const currentNode = [{...node}]; // 需要删除的关联元件数据
121
+ for (let i = 0; i < bindConfIds.length; i++) {
122
+ const id = bindConfIds[i];
123
+ if(tabAreaData[id]) {
124
+ currentNode.push(tabAreaData[id]);
125
+ delete tabAreaData[id];
126
+ }
127
+ }
128
+ const changeData = topologyChangeData[`${switchTabType}Data`];
129
+ delete changeData[node.id];
130
+ if(Object.keys(changeData).length) {
131
+ // 第一个页签设置选中效果
132
+ const firstNode = Object.values(changeData)[0];
133
+ firstNode.activeImgeIndex = false;
134
+ const firstNodeBindConfIds = firstNode.bindStaticId.split(','); // tab元件绑定的元件id
135
+ // 为绑定的每个元件设置可见
136
+ for (let i = 0; i < firstNodeBindConfIds.length; i++) {
137
+ const tabAreaNode = tabAreaData[firstNodeBindConfIds[i]];
138
+ if(tabAreaNode) {
139
+ tabAreaNode.visible = true;
140
+ tabAreaNode.visibleSwitch = true;
141
+ }
142
+ }
143
+ }
144
+ return currentNode;
145
+ }
5
146
  /**
6
147
  * Tab 数据统计
7
148
  * @param type 统计类型
@@ -49,6 +190,7 @@ export function tabHideShowOperation(node, areaData, isActive) {
49
190
  if(!(areaNode && pens[areaNode.order])) return;
50
191
  const tagNode = pens[areaNode.order];
51
192
  tagNode.visible = !isActive;
193
+ tagNode.visibleSwitch = tagNode.visible;
52
194
  setElementSwitchTabState(tagNode);
53
195
  }
54
196
  }
@@ -155,6 +297,15 @@ export function setVarValueData(data) {
155
297
  "value": data.name
156
298
  }];
157
299
  }
300
+ export function setBranchAddressData(data) {
301
+ return [{
302
+ "key": "branchVal",
303
+ "value": data.value
304
+ }, {
305
+ "key": "支路地址Key",
306
+ "value": data.key
307
+ }];
308
+ }
158
309
  export function setThreeCategoryIdData(pen, data) {
159
310
  let params = [];
160
311
  const hasThreeCategoryId = pen.data.find((tc) => {
@@ -1,4 +1,3 @@
1
1
  export declare function pSBC(p: any, c0: any, c1?: any, l?: any): string;
2
2
  export declare function abs(num: number, percent: number | string): number;
3
3
  export declare function ptInPolyXY(pt: any, poly: []): boolean;
4
- export declare function jsonLength(obj: {}): number;
@@ -115,7 +115,4 @@ export function ptInPolyXY(pt, poly) {
115
115
  }
116
116
  return c;
117
117
  }
118
- export function jsonLength(obj) {
119
- return Object.keys(obj).length;
120
- }
121
118
  //# sourceMappingURL=math.js.map
@@ -77,7 +77,7 @@ export function mousDownFun(type, eventNode) {
77
77
  params.eventType = downDataType.Tabswitch; // Tab切换
78
78
  }else if(action === 11) {
79
79
  params.eventType = downDataType.Formselect; // select下拉切换
80
- params.staticType = eventNode.dcimStaticForType; // 1: 数据统计;2:数据展示;3:显示隐藏
80
+ // params.staticType = eventNode.dcimStaticForType; // 1: 数据统计;2:数据展示;3:显示隐藏;4:日期类型
81
81
  }else {
82
82
  // action === 5 远程控制比较特殊,无论是否绑定远程控制事件,只要数据中有远程控制属性且值为0都会认定为远程控制
83
83
  params.eventType = downDataType.Target; // 链接跳转
@@ -1,2 +1,3 @@
1
+ // @ts-ignore
1
2
  export declare function getParams(id: string, data: []): void;
2
3
  export declare function filterParams(node: any): void;
@@ -1,7 +1,11 @@
1
1
  import {commonStore} from '../store';
2
+ import {datePickerValueFormatting} from "./conversion";
3
+ import {datePickerBindType, confBindValueType} from "./construction";
4
+ const confConfigMap = new Map();
2
5
  // 获取绑定数据的参数
3
6
  export function getParams(id, data) {
4
- data.map((item) => {
7
+ for (let i = 0, length = data.length; i < length; i++) {
8
+ const item = data[i];
5
9
  filterParams(id, item);
6
10
  if (item.children && item.children.length) {
7
11
  getParams(id, item.children);
@@ -9,7 +13,8 @@ export function getParams(id, data) {
9
13
  if (item.formData && item.formData.detailPageData && item.formData.detailPageData.pens && item.formData.detailPageData.pens.length) {
10
14
  getParams(id, item.formData.detailPageData.pens);
11
15
  }
12
- });
16
+ }
17
+ confConfigMap.clear();
13
18
  }
14
19
  // 过滤出参数
15
20
  export function filterParams(id, node) {
@@ -20,41 +25,112 @@ export function filterParams(id, node) {
20
25
  let tagEcharts = [];
21
26
  let echartData = [];
22
27
  let varVaule = [];
28
+ let branchValue = [];
23
29
  let doorIds = [];
24
30
  let isMqttEventType = false;
31
+ let dcimStaticForType = '';
25
32
  node.events.map((ev) => {
26
33
  if(ev.value && ev.value === 'entranceGuard') doorIds.push(ev.params); // 门禁参数
27
34
  if(ev.type === 3) isMqttEventType = true;
35
+ if(ev.type === 4) dcimStaticForType = ev.dcimStaticForType;
28
36
  });
29
37
  if(doorIds.length) commonStore[id].mqttParams.doorIds = [...commonStore[id].mqttParams.doorIds, ...doorIds];
30
38
  if(!isMqttEventType) return;
31
39
  if (node.data && Array.isArray(node.data) && node.data.length) {
32
- node.data.map((item) => {
40
+ for (let i = 0, length = node.data.length; i < length; i ++) {
41
+ const item = node.data[i];
42
+ let type = 0;
33
43
  if (item.key === 'tagId') {
34
44
  tagIds.push(item.value);
45
+ type = datePickerBindType.tag;
35
46
  }
36
47
  if (item.key === 'kpiAddr') {
37
48
  kpiAddrs.push(item.value);
49
+ type = datePickerBindType.kpi;
38
50
  }
39
51
  if (item.key === 'assetId') {
40
52
  assetIds.push(item.value);
53
+ type = datePickerBindType.asset;
41
54
  }
42
55
  if (item.key === 'areaId') {
43
56
  areaIds.push(item.value);
57
+ type = datePickerBindType.area;
44
58
  }
45
59
  if (item.key.includes('varValue')) {
46
60
  varVaule.push(item.value);
61
+ type = datePickerBindType.varType;
47
62
  }
48
- })
63
+ if (item.key === 'branchVal') {
64
+ branchValue.push(item.value);
65
+ type = datePickerBindType.branch;
66
+ }
67
+ if(dcimStaticForType && node.formData && type) setConfConfigMap(node.id, id, node.formData, item.value, type);
68
+ }
49
69
  }
50
70
  if (node.data && Object.prototype.toString.call(node.data) === '[object Object]' && node.data.params && node.data.params.id) {
51
71
  echartData.push(node.data.params.id);
72
+ if(dcimStaticForType && node.formData) setConfConfigMap(node.id, id, node.formData, node.data.params.id, 1);
52
73
  }
53
74
  commonStore[id].mqttParams.tagIds = [...commonStore[id].mqttParams.tagIds, ...tagIds];
54
75
  commonStore[id].mqttParams.kpiAddrs = [...commonStore[id].mqttParams.kpiAddrs, ...kpiAddrs];
55
76
  commonStore[id].mqttParams.assetIds = [...commonStore[id].mqttParams.assetIds, ...assetIds];
56
77
  commonStore[id].mqttParams.areaIds = [...commonStore[id].mqttParams.areaIds, ...areaIds];
57
78
  commonStore[id].mqttParams.varVaule = [...commonStore[id].mqttParams.varVaule, ...varVaule];
79
+ commonStore[id].mqttParams.branchValue = [...commonStore[id].mqttParams.branchValue, ...branchValue];
58
80
  commonStore[id].mqttParams.tagEcharts = [...commonStore[id].mqttParams.tagEcharts, ...tagEcharts];
59
81
  commonStore[id].mqttParams.echartData = [...commonStore[id].mqttParams.echartData, ...echartData];
82
+ }
83
+
84
+ /**
85
+ * 设置绑定日期的配置数据
86
+ * @param formData 元件关联的日期数据
87
+ * @param id 当前元件id
88
+ * @param tid
89
+ * @param realData 当前元件绑定的数据
90
+ * @param type 当前元件绑定的数据类型 1:echart 3:测点 6:指标 9:资产 12:变量类型 15:支路地址 21:区域
91
+ */
92
+ function setConfConfigMap(id, tid, formData, realData, type) {
93
+ if(!formData.dateId) return;
94
+ const dateId = formData.dateId;
95
+ let value = null;
96
+ let valueStr = '';
97
+ if(confConfigMap.has(dateId)) {
98
+
99
+ const {date, dateStr} = confConfigMap.get(dateId);
100
+
101
+ value = date;
102
+
103
+ valueStr = dateStr;
104
+
105
+ }else {
106
+
107
+ const {date, dateStr} = datePickerValueFormatting({
108
+ formatType: formData.dateFormat,
109
+ valueType: formData.valueType,
110
+ dateType: formData.dateType
111
+ });
112
+
113
+ value = date;
114
+
115
+ valueStr = dateStr;
116
+
117
+ confConfigMap.set(dateId, {date, dateStr});
118
+
119
+ }
120
+ const dataConfig = commonStore[tid].mqttParams.dataConfig;
121
+ if(!dataConfig.data){
122
+ dataConfig.data = {};
123
+ dataConfig.picker = new Map();
124
+ }
125
+ dataConfig.data[id] = {
126
+ id: realData,
127
+ date: value,
128
+ dataType: type,
129
+ valueType: confBindValueType.increment
130
+ };
131
+ dataConfig.picker.set(id, {
132
+ dateId,
133
+ date: value,
134
+ dateStr: valueStr
135
+ });
60
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcim-topology2d",
3
- "version": "2.0.8",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "main": "-",
6
6
  "scripts": {
@@ -0,0 +1,22 @@
1
+ export const datePickerTypeList = [{
2
+ id: 'date',
3
+ name: '日期选择器', // 可选择:年、月、日
4
+ format: 'yyyy-MM-dd'
5
+ },{
6
+ id: 'datetime',
7
+ name: '日期时间选择器', // 可选择:年、月、日、时、分、秒 dateType
8
+ format: 'yyyy-MM-dd HH:mm:ss'
9
+ },{
10
+ id: 'year',
11
+ name: '年选择器', // 只提供年列表选择
12
+ format: 'yyyy'
13
+ },{
14
+ id: 'month',
15
+ name: '年月选择器', // 只提供年、月选择
16
+ format: 'yyyy-MM'
17
+ },{
18
+ id: 'time',
19
+ name: '时间选择器', // 只提供时、分、秒选择
20
+ format: 'HH:mm:ss'
21
+ }];
22
+ export const datePickerType = {}
package/store/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './actions';
2
- export * from './clear';
2
+ export * from './clear';
3
+ export * from './default';
package/style/common.css CHANGED
@@ -12,7 +12,4 @@ li {
12
12
  .canvas-point,
13
13
  .canvas-point.default{
14
14
  cursor: default;
15
- }
16
- .canvas-point.pointer > div{
17
- z-index: -2;
18
15
  }
@@ -0,0 +1,44 @@
1
+ .topology-datePicker{
2
+ position: relative;
3
+ box-sizing: border-box;
4
+ }
5
+ .topology-datePicker i{
6
+ display: inline-block;
7
+ }
8
+ .topology-datePicker input{
9
+ width: 100%;
10
+ height: 100%;
11
+ line-height: 100%;
12
+ border: none;
13
+ background: transparent;
14
+ vertical-align: top;
15
+ }
16
+ .topology-datePicker input::placeholder{
17
+ font-weight: normal;
18
+ color: rgb(220, 223, 230);
19
+ }
20
+ .topology-datePicker input:active,
21
+ .topology-datePicker input:focus{
22
+ outline: none;
23
+ }
24
+ .topology-datePicker .icon-date,
25
+ .topology-datePicker .icon-arrow{
26
+ position: absolute;
27
+ top: 50%;
28
+ transform: translateY(-50%);
29
+ }
30
+ .layui-laydate-main{
31
+ width: 322px !important;
32
+ }
33
+ .layui-laydate-main table{
34
+ width: 100%;
35
+ }
36
+ .layui-laydate-header i{
37
+ font-size: 14px !important;
38
+ }
39
+ .laydate-set-ym {
40
+ font-size: 16px;
41
+ }
42
+ .layui-laydate-footer span.layui-laydate-preview{
43
+ font-size: 14px;
44
+ }
package/style/editor.css CHANGED
@@ -4,6 +4,9 @@
4
4
  /*.canvas-point{*/
5
5
  /* z-index: 6;*/
6
6
  /*}*/
7
+ .canvas-point.pointer > div{
8
+ z-index: -2;
9
+ }
7
10
  .topoEchart,
8
11
  .topology-select{
9
12
  z-index: 1;
package/style/index.css CHANGED
@@ -1,4 +1,5 @@
1
1
  @import './common.css';
2
2
  @import './select.css';
3
+ @import './datePicker.css';
3
4
 
4
5