dcim-topology2d 1.1.6 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chart-diagram/index.d.ts +1 -1
- package/chart-diagram/index.js +1 -1
- package/chart-diagram/src/echarts/index.js +88 -96
- package/chart-diagram/src/register.js +3 -3
- package/chart-diagram/src/utils/changeOptions.d.ts +7 -4
- package/chart-diagram/src/utils/changeOptions.js +228 -144
- package/chart-diagram/src/utils/conversion.d.ts +12 -12
- package/chart-diagram/src/utils/conversion.js +263 -137
- package/chart-diagram/src/utils/render.d.ts +6 -0
- package/chart-diagram/src/utils/render.js +124 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/src/activeLayer.js +0 -6
- package/core/src/canvas.js +1 -0
- package/core/src/common.d.ts +1 -2
- package/core/src/common.js +197 -541
- package/core/src/core.js +116 -60
- package/core/src/divLayer.d.ts +0 -3
- package/core/src/divLayer.js +13 -34
- package/core/src/element/common.d.ts +5 -0
- package/core/src/element/common.js +52 -0
- package/core/src/element/iframe.d.ts +3 -0
- package/core/src/element/iframe.js +12 -0
- package/core/src/element/index.d.ts +4 -0
- package/core/src/element/index.js +4 -0
- package/core/src/element/select.d.ts +11 -0
- package/core/src/element/select.js +234 -0
- package/core/src/element/tab.d.ts +1 -0
- package/core/src/element/tab.js +19 -0
- package/core/src/healps/changeData.d.ts +1 -2
- package/core/src/healps/changeData.js +33 -125
- package/core/src/middles/default.js +3 -1
- package/core/src/middles/nodes/arbitrarygraph.js +11 -9
- package/core/src/middles/nodes/formselect.d.ts +2 -0
- package/core/src/middles/nodes/formselect.js +87 -0
- package/core/src/middles/nodes/iframe.js +21 -4
- package/core/src/middles/nodes/index.d.ts +1 -0
- package/core/src/middles/nodes/index.js +1 -0
- package/core/src/models/node.d.ts +4 -0
- package/core/src/models/node.js +24 -22
- package/core/src/models/pen.js +3 -52
- package/core/src/models/rect.js +2 -2
- package/core/src/options.d.ts +2 -0
- package/core/src/options.js +2 -1
- package/core/src/preview.js +51 -32
- package/core/src/renderLayer.d.ts +10 -6
- package/core/src/renderLayer.js +36 -43
- package/core/src/store/data.d.ts +71 -21
- package/core/src/store/data.js +93 -17
- package/core/src/utils/assignment.d.ts +6 -3
- package/core/src/utils/assignment.js +120 -21
- package/core/src/utils/construction.d.ts +10 -3
- package/core/src/utils/construction.js +7 -1
- package/core/src/utils/conversion.d.ts +3 -0
- package/core/src/utils/conversion.js +62 -1
- package/core/src/utils/index.d.ts +1 -1
- package/core/src/utils/index.js +1 -1
- package/core/src/utils/math.d.ts +1 -0
- package/core/src/utils/math.js +3 -0
- package/core/src/utils/onmousevent.d.ts +3 -0
- package/core/src/utils/onmousevent.js +27 -7
- package/core/src/utils/params.d.ts +2 -0
- package/core/src/utils/params.js +57 -0
- package/myShape-diagram/index.js +196 -0
- package/package.json +1 -1
- package/static/echartsDefaultData.js +27 -107
- package/static/element.js +14 -0
- package/static/form.js +11 -0
- package/static/index.js +2 -1
- package/store/actions.js +1 -0
- package/store/clear.js +10 -0
- package/store/index.js +2 -0
- package/style/common.css +18 -0
- package/style/editor.css +13 -0
- package/style/index.css +3 -12
- package/style/select.css +143 -0
- package/core/src/poll.js +0 -37
- package/core/src/utils/dom.d.ts +0 -9
- package/core/src/utils/dom.js +0 -103
- package/core/src/utils/dom.js.map +0 -1
- package/myShape-diagram/myShape.js +0 -196
- package/static/echartsStore.js +0 -14
- /package/myShape-diagram/{myShape.ts → index.ts} +0 -0
@@ -0,0 +1,234 @@
|
|
1
|
+
import {Store} from 'le5le-store';
|
2
|
+
import {commonStore} from "../store";
|
3
|
+
import { setMapDataOptions } from '../../../chart-diagram';
|
4
|
+
import {previewType, selectStaticType} from '../utils';
|
5
|
+
import {setElementSwitchTabState} from './tab';
|
6
|
+
let nodeId = '';
|
7
|
+
let downId = '';
|
8
|
+
// 创建下拉头
|
9
|
+
export function createSelectElement(node) {
|
10
|
+
const selectEle = document.createElement('div');
|
11
|
+
const order = node.formData.selected && node.formData.selected.order || 0;
|
12
|
+
const inputValue = commonStore[node.TID].selectDataPool[node.id].data[order] && commonStore[node.TID].selectDataPool[node.id].data[order].name;
|
13
|
+
let attrName = 'topology-select-icon-arrow';
|
14
|
+
if(node.selectDropdown) attrName += ' reverse';
|
15
|
+
const children = `<i class="${attrName}"
|
16
|
+
style="border-width: ${node.font.fontSize/2}px;border-bottom-width: 0;">
|
17
|
+
</i><input type="text" placeholder="请选择" readonly
|
18
|
+
value="${inputValue}"
|
19
|
+
class="topology-select-input"
|
20
|
+
style="font-size: ${node.font.fontSize}px;color: ${node.font.color ? node.font.color : '#fff'}"/>`;
|
21
|
+
const themeType = node.formData.theme ? ` theme${node.formData.theme}` : '';
|
22
|
+
selectEle.setAttribute('id', node.id);
|
23
|
+
selectEle.setAttribute('class', `topology-select${themeType}`);
|
24
|
+
selectEle.innerHTML = children;
|
25
|
+
return selectEle;
|
26
|
+
}
|
27
|
+
// 创建下拉options容器
|
28
|
+
export function createSelectDropdown(node) {
|
29
|
+
const selectDropdownEle = document.createElement('div');
|
30
|
+
let liElements = '';
|
31
|
+
if(node.selectDropdown) {
|
32
|
+
liElements = createSelectOptions(commonStore[node.TID].selectDataPool[node.id].data, node);
|
33
|
+
selectDropdownEle.style.display = 'block';
|
34
|
+
setSelectDropdownPosition(node, selectDropdownEle);
|
35
|
+
}
|
36
|
+
const children = `<i class="popper__arrow"></i><ul class="topology-select-dropdown-list">${liElements}</ul>`;
|
37
|
+
const themeType = node.formData.theme ? ` theme${node.formData.theme}` : '';
|
38
|
+
selectDropdownEle.style.width = `${node.rect.width}px`;
|
39
|
+
selectDropdownEle.setAttribute('class', `topology-select-dropdown${themeType} documentDefine`);
|
40
|
+
selectDropdownEle.innerHTML = children;
|
41
|
+
return selectDropdownEle;
|
42
|
+
}
|
43
|
+
// 创建下拉options列表
|
44
|
+
export function createSelectOptions(data, node) {
|
45
|
+
const selectNode = commonStore[node.TID].selectDataPool[node.id];
|
46
|
+
const selectDropdownUl = selectNode.dom.selectDropdownUl;
|
47
|
+
if(selectDropdownUl) selectDropdownUl.innerHTML = '';
|
48
|
+
let leElement = '';
|
49
|
+
const order = selectNode.node.selected ? selectNode.node.selected.order : 0;
|
50
|
+
for (let i = 0, length = data.length; i < length; i++) {
|
51
|
+
let selected = i === order ? ' selected' : '';
|
52
|
+
leElement += `<li
|
53
|
+
class="topology-select-dropdown-item${selected}"
|
54
|
+
type="option" data-order="${i}"
|
55
|
+
style="height: ${node.rect.height}px;line-height: ${node.rect.height}px;font-size: ${node.font.fontSize}px;">
|
56
|
+
<span>${data[i].name}</span>
|
57
|
+
</li>`;
|
58
|
+
}
|
59
|
+
if(selectDropdownUl) {
|
60
|
+
selectDropdownUl.innerHTML = leElement;
|
61
|
+
}else {
|
62
|
+
return leElement;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
// 配置下拉头的交互状态:展开时三角图标向上,否则向下
|
66
|
+
export function setSelectInteractiveState(selected, node) {
|
67
|
+
const selectNode = commonStore[node.TID].selectDataPool[node.id];
|
68
|
+
selectNode.dom.selectIconArrow.style.display = selected ? 'none' : 'block';
|
69
|
+
//selectNode.dom['selectRemove'].style.display = selected ? 'block' : 'none';
|
70
|
+
}
|
71
|
+
// 重置下拉状态
|
72
|
+
export function resetSelectInteractiveState(node) {
|
73
|
+
const currentStore = commonStore[node.TID];
|
74
|
+
if(!Object.keys(currentStore.selectDataPool).length) return;
|
75
|
+
for (let data of Object.values(currentStore.selectDataPool)) {
|
76
|
+
if(node && node.id !== data.node.id) {
|
77
|
+
if(data.dom.selectIconArrow) data.dom.selectIconArrow.setAttribute('class', 'topology-select-icon-arrow');
|
78
|
+
data.slideState = false;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
document.querySelector('.topology-select-dropdown').style.display = 'none';
|
82
|
+
currentStore.elementInteractivePoor.node = null;
|
83
|
+
}
|
84
|
+
|
85
|
+
/**
|
86
|
+
* 配置下拉options容器的交互状态,展开和收起
|
87
|
+
* @param node 下拉元件节点数据
|
88
|
+
* @param staticType 下拉功能类型:1: 数据统计;2:数据展示;3:显示隐藏
|
89
|
+
* @param type 功能作用区域类型:Dcim,Topology,Logo
|
90
|
+
*/
|
91
|
+
export function setSelectDropdownInteractiveState(node, staticType, type) {
|
92
|
+
const currentStore = commonStore[node.TID];
|
93
|
+
const selectNode = currentStore.selectDataPool[node.id];
|
94
|
+
if(!selectNode.staticType) selectNode.staticType = staticType;
|
95
|
+
if(!selectNode) return;
|
96
|
+
if(downId !== node.id && type === previewType.Dcim) {
|
97
|
+
// 点击的不是同一个下拉则重置交互样式,清空数据
|
98
|
+
resetSelectInteractiveState(node);
|
99
|
+
currentStore.elementInteractivePoor.options = null;
|
100
|
+
}
|
101
|
+
downId = node.id;
|
102
|
+
currentStore.elementInteractivePoor.node = node;
|
103
|
+
selectElementStore(node.id, node.TID);
|
104
|
+
setSelectElementPosition(node);
|
105
|
+
const { selectIconArrow, selectDropdown } = selectNode.dom;
|
106
|
+
selectNode.slideState = !selectNode.slideState || node.selectDropdown; // 下拉展开状态
|
107
|
+
let attrName = 'topology-select-icon-arrow';
|
108
|
+
if(selectNode.slideState) {
|
109
|
+
selectDropdown.style.display = 'block';
|
110
|
+
attrName += ' reverse';
|
111
|
+
}else {
|
112
|
+
selectDropdown.style.display = 'none';
|
113
|
+
attrName.replace(' reverse', '');
|
114
|
+
}
|
115
|
+
// 图标旋转
|
116
|
+
selectIconArrow.setAttribute('class', attrName);
|
117
|
+
// 添加列表数据
|
118
|
+
if(!currentStore.elementInteractivePoor.options) createSelectOptions(selectNode.data, node);
|
119
|
+
}
|
120
|
+
// 配置下拉偏移位置
|
121
|
+
export function setSelectElementPosition(node, type) {
|
122
|
+
// 不同元件切换
|
123
|
+
selectElementStore(node.id, node.TID);
|
124
|
+
const selectNode = commonStore[node.TID].selectDataPool[node.id];
|
125
|
+
if(type === 'down') {
|
126
|
+
if(nodeId === node.id) return;
|
127
|
+
commonStore[node.TID].elementInteractivePoor.options = null;
|
128
|
+
createSelectOptions(selectNode.data, node);
|
129
|
+
}
|
130
|
+
nodeId = node.id;
|
131
|
+
setSelectDropdownPosition(node, selectNode.dom.selectDropdown);
|
132
|
+
}
|
133
|
+
function setSelectDropdownPosition(node, selectDropdown) {
|
134
|
+
const selectEle = commonStore[node.TID].selectDataPool[node.id].dom.selectEle;
|
135
|
+
let left = selectEle.getBoundingClientRect().left; // 获取下拉元素距离窗体左侧位置
|
136
|
+
let top = selectEle.getBoundingClientRect().top + node.rect.height;
|
137
|
+
if(window.location.pathname.includes('workspace')) {
|
138
|
+
// topol编辑器
|
139
|
+
left = node.rect.x;
|
140
|
+
top = node.rect.y + node.rect.height;
|
141
|
+
}
|
142
|
+
selectDropdown.style.left = `${left}px`;
|
143
|
+
selectDropdown.style.top = `${top}px`;
|
144
|
+
selectDropdown.style.width = `${node.rect.width}px`;
|
145
|
+
const themeType = node.formData.theme ? ` theme${node.formData.theme}` : '';
|
146
|
+
selectDropdown.setAttribute('class', `topology-select-dropdown${themeType} documentDefine`);
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* 获取下拉选中的数据
|
151
|
+
* @param e 节点选中事件
|
152
|
+
* @param data 下拉元件节点数据
|
153
|
+
* @param editData 编辑显下拉的数据
|
154
|
+
*/
|
155
|
+
export function getSelectedData(e, data, editData) {
|
156
|
+
const currentStore = commonStore[data.TID];
|
157
|
+
const selectNode = currentStore.selectDataPool[data.id];
|
158
|
+
if(!currentStore.elementInteractivePoor.options && data.selectDropdown) currentStore.elementInteractivePoor.options = selectNode.dom.selectDropdownUl.querySelectorAll('.topology-select-dropdown-item');
|
159
|
+
let order = 0;
|
160
|
+
let staticType = selectNode.staticType;
|
161
|
+
if(!editData) {
|
162
|
+
const parentNode = e.target.parentNode;
|
163
|
+
const type = parentNode.getAttribute('type');
|
164
|
+
if(type !== 'option') return;
|
165
|
+
selectNode.slideState = false;
|
166
|
+
selectNode.dom.selectDropdown.style.display = 'none';
|
167
|
+
// 图标旋转
|
168
|
+
selectNode.dom.selectIconArrow.setAttribute('class', 'topology-select-icon-arrow');
|
169
|
+
// 选中节点操作
|
170
|
+
order = parentNode.getAttribute('data-order');
|
171
|
+
}else {
|
172
|
+
order = editData.order;
|
173
|
+
staticType = editData.staticType;
|
174
|
+
}
|
175
|
+
if(data.selectDropdown) {
|
176
|
+
for(let i = 0, leng = currentStore.elementInteractivePoor.options.length; i < leng; i++) {
|
177
|
+
let name = 'topology-select-dropdown-item';
|
178
|
+
if(i == order) {
|
179
|
+
name += ' selected';
|
180
|
+
}else {
|
181
|
+
name.replace(' selected', '');
|
182
|
+
}
|
183
|
+
currentStore.elementInteractivePoor.options[i].setAttribute('class', name);
|
184
|
+
}
|
185
|
+
}
|
186
|
+
selectNode.optionOrder = order;
|
187
|
+
const node = selectNode.data[order];
|
188
|
+
selectNode.dom.selectEle.querySelector('.topology-select-input').value = node.name;
|
189
|
+
selectNode.node.selected = {
|
190
|
+
order: parseInt(order),
|
191
|
+
id: node.id
|
192
|
+
};
|
193
|
+
if(staticType === selectStaticType.static) {
|
194
|
+
// 数据统计
|
195
|
+
const optionNode = data.formData.bindBlockId && currentStore.echartsOptionsPool[data.formData.bindBlockId];
|
196
|
+
if(!optionNode) return;
|
197
|
+
// 切换数据
|
198
|
+
currentStore.echartsRealDataPool[optionNode.data.id] = currentStore.echartsRealDataPool[node.id];
|
199
|
+
setMapDataOptions(optionNode.option, optionNode.data);
|
200
|
+
}
|
201
|
+
if(staticType === selectStaticType.dataShow) {
|
202
|
+
// 数据展示
|
203
|
+
}
|
204
|
+
if(staticType === selectStaticType.visible) {
|
205
|
+
// 显示隐藏
|
206
|
+
const optionsVisibleData = currentStore.selectTabDataPool[data.id];
|
207
|
+
if(!optionsVisibleData || !optionsVisibleData.size) return;
|
208
|
+
for(const [key, value] of optionsVisibleData){
|
209
|
+
const eque = node.id === value.tag;
|
210
|
+
currentStore.data.pens[value.order].visible = eque;
|
211
|
+
currentStore.data.pens[value.order].visibleSwitch = eque;
|
212
|
+
value.visible = eque;
|
213
|
+
setElementSwitchTabState(value);
|
214
|
+
}
|
215
|
+
Store.set(`${data.TID}-LT:render`, true);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
// 配置下拉展示的主题风格
|
219
|
+
export function setSelectElementTheme(node) {
|
220
|
+
const themeType = node.formData.theme ? ` theme${node.formData.theme}` : '';
|
221
|
+
const { selectEle, selectDropdown } = commonStore[node.TID].selectDataPool[node.id].dom;
|
222
|
+
selectEle.setAttribute('class', `topology-select${themeType}`);
|
223
|
+
selectDropdown.setAttribute('class', `topology-select-dropdown${themeType} documentDefine`);
|
224
|
+
}
|
225
|
+
// 存储下拉Dom节点
|
226
|
+
function selectElementStore(id, TID) {
|
227
|
+
const selectNode = commonStore[TID].selectDataPool[id];
|
228
|
+
if(!selectNode.dom.selectIconArrow) selectNode.dom.selectIconArrow = selectNode.dom.selectEle.querySelector('.topology-select-icon-arrow');
|
229
|
+
if(!selectNode.dom.selectDropdown) {
|
230
|
+
selectNode.dom.selectDropdown = document.querySelector('.topology-select-dropdown');
|
231
|
+
selectNode.dom.selectDropdownUl = document.querySelector('.topology-select-dropdown-list');
|
232
|
+
selectNode.dom.selectDropdownLi = document.querySelectorAll('.topology-select-dropdown-item');
|
233
|
+
}
|
234
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function setElementSwitchTabState(node: any): void;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import {jsonLength} from '../utils';
|
2
|
+
import {commonStore} from "../store";
|
3
|
+
// 设置tab切换显示隐藏时的 Dom元件状态
|
4
|
+
export function setElementSwitchTabState(node) {
|
5
|
+
if(node.name !== 'echarts' && (!node.children || !node.children.length)) return;
|
6
|
+
if(typeof commonStore[node.TID].elementInteractivePoor.elementDataLength !== 'number') {
|
7
|
+
commonStore[node.TID].elementInteractivePoor.elementDataLength = jsonLength(commonStore[node.TID].echartsDataPool) || jsonLength(commonStore[node.TID].selectDataPool);
|
8
|
+
}
|
9
|
+
if(!commonStore[node.TID].elementInteractivePoor.elementDataLength) return;
|
10
|
+
const ele = commonStore[node.TID].echartsDataPool[node.id] && commonStore[node.TID].echartsDataPool[node.id].div ||
|
11
|
+
commonStore[node.TID].selectDataPool[node.id] && commonStore[node.TID].selectDataPool[node.id].dom.selectEle;
|
12
|
+
if(ele) ele.style.display = !node.visible ? 'none': 'block';
|
13
|
+
if(node.children && node.children.length) {
|
14
|
+
node.children.map((ch) => {
|
15
|
+
ch.visible = node.visible;
|
16
|
+
setElementSwitchTabState(ch);
|
17
|
+
})
|
18
|
+
}
|
19
|
+
}
|
@@ -4,5 +4,4 @@ export declare function setConfItemNode(item: any[], syncData: Node): Node;
|
|
4
4
|
export declare function setNodeEvents(item: any[], pen: Pen): void;
|
5
5
|
export declare function setControlData(pen: Pen, syncData: Node): void;
|
6
6
|
export declare function getControlNode(item: any, data: any): Node;
|
7
|
-
export declare function getDetailData(data: Node): void;
|
8
|
-
export declare function setStatisticalData(pen: Pen, dataType: any, staticForType: string, chartData: any): Node;
|
7
|
+
export declare function getDetailData(data: Node): void;
|
@@ -1,13 +1,23 @@
|
|
1
1
|
//let DETAILDATA = null;
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import {commonStore} from '../store';
|
3
|
+
import { getEchartsRealData } from '../utils/conversion';
|
4
4
|
export function setConfItemNode(pen, syn_synata) {
|
5
|
-
|
6
|
-
|
5
|
+
const entranceGuard = pen.events.find((ev) => {
|
6
|
+
return ev.value === 'entranceGuard';
|
7
|
+
});
|
8
|
+
if(entranceGuard) {
|
9
|
+
// 绑定门禁的元件实时数据
|
10
|
+
const nullUndefinedRegex = /^(?:null|undefined|\s*)$/;
|
11
|
+
const doorData = syn_synata.doorData && syn_synata.doorData[entranceGuard.params];
|
12
|
+
const doorState = doorData && !nullUndefinedRegex.test(doorData.state) && parseInt(doorData.state);
|
13
|
+
pen.text = doorState === 1 ? '开门' : '关门'; // 1-开门,其他值为关门
|
14
|
+
}
|
15
|
+
if (!pen.data) return;
|
16
|
+
if(commonStore[pen.TID]) commonStore[pen.TID].data.dataResize = 1;
|
17
|
+
let isAlarm = false; // 判断元件绑定的数据中是否有告警发生,用于九所项目服务器自身监控功能
|
7
18
|
if(pen.data instanceof Array) {
|
8
|
-
let _syn =
|
9
|
-
let isResetVal = false
|
10
|
-
let isResetFontColor = false
|
19
|
+
let _syn = null;
|
20
|
+
let isResetVal = false;
|
11
21
|
const {areaData, assetData, kpiData, tagData, asset} = syn_synata
|
12
22
|
pen.data.map((d) => {
|
13
23
|
const key = d.key;
|
@@ -15,7 +25,7 @@ export function setConfItemNode(pen, syn_synata) {
|
|
15
25
|
const assetItem = assetData[value];
|
16
26
|
const areaItem = areaData[value];
|
17
27
|
const kpiItem = kpiData[value];
|
18
|
-
if(key === 'tagId') value = d.tagId ? d.tagId : d.value
|
28
|
+
if(key === 'tagId') value = d.tagId ? d.tagId : d.value;
|
19
29
|
const tagItem = tagData[value];
|
20
30
|
//console.log('key===========', d)
|
21
31
|
if (key === 'assetKey' && d.value === 'assetName' && asset) {
|
@@ -28,7 +38,7 @@ export function setConfItemNode(pen, syn_synata) {
|
|
28
38
|
}else if (key === 'tagId' && tagItem) {
|
29
39
|
_syn = tagItem;
|
30
40
|
if(_syn.kpiName !== '通讯状态' || pen.name !== 'circle'){
|
31
|
-
isResetVal = true
|
41
|
+
isResetVal = true;
|
32
42
|
}
|
33
43
|
const isControl = parseInt(tagItem.isControlDis); // 是否可控,0可控,1不可控
|
34
44
|
//d.isControlDis = isControlDis
|
@@ -50,6 +60,7 @@ export function setConfItemNode(pen, syn_synata) {
|
|
50
60
|
}
|
51
61
|
}
|
52
62
|
})
|
63
|
+
if(!_syn) return;
|
53
64
|
// const type = parseInt(_syn.type) // 是否是开关量
|
54
65
|
// 显示的值
|
55
66
|
if (isResetVal) pen.text = `${_syn.value}${_syn.unit}`;
|
@@ -61,9 +72,11 @@ export function setConfItemNode(pen, syn_synata) {
|
|
61
72
|
switch (state) {
|
62
73
|
case 0: // 正常告警
|
63
74
|
color = '#FF0000';
|
75
|
+
isAlarm = true;
|
64
76
|
break;
|
65
77
|
case 1: // 离线告警, 通讯开关告警
|
66
78
|
color = '#6d6d6d';
|
79
|
+
isAlarm = true;
|
67
80
|
break;
|
68
81
|
case 2: // 未告警
|
69
82
|
case 3: // 无告警
|
@@ -93,127 +106,22 @@ export function setConfItemNode(pen, syn_synata) {
|
|
93
106
|
if (name === 'electricFan') setFanData(pen, _syn)
|
94
107
|
}else {
|
95
108
|
if (pen.elementRendered) pen.elementRendered = false;
|
96
|
-
if(pen.data.echarts) {
|
97
|
-
const {
|
109
|
+
if (pen.data.echarts) {
|
110
|
+
const {echartDataValue} = syn_synata;
|
98
111
|
const seriesData = echartDataValue;
|
99
|
-
const
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
/**
|
108
|
-
* 设置图表数据
|
109
|
-
* @param pen 拓扑节点
|
110
|
-
* @param dataType 数据类型:‘def’-默认,不传默认为-实时
|
111
|
-
* @param staticForType 统计类型:日,周,月,年
|
112
|
-
* @param chartData // 图表实时数据
|
113
|
-
* @returns {*}
|
114
|
-
*/
|
115
|
-
export function setStatisticalData(pen, dataType, staticForType, chartData) {
|
116
|
-
const node = JSON.parse(JSON.stringify(pen));
|
117
|
-
const echartsOption = node.data.echarts.option;
|
118
|
-
const optionDisplayMode = echartsOption.displayMode;
|
119
|
-
let displayMode = 0;
|
120
|
-
if(typeof optionDisplayMode === 'string') {
|
121
|
-
|
122
|
-
const displayType = optionDisplayMode.split('_')[0];
|
123
|
-
|
124
|
-
displayMode = parseInt(displayType);
|
125
|
-
|
126
|
-
}else {
|
127
|
-
displayMode = parseInt(optionDisplayMode);
|
128
|
-
}
|
129
|
-
const defaultData = echartsDefaultDataMap[`displayMode_${optionDisplayMode}`];
|
130
|
-
const staticTypeData = chartData && chartData[`${staticForType}_Data`];
|
131
|
-
const chartRealData = staticForType ? staticTypeData || defaultData : chartData || defaultData;
|
132
|
-
if (displayMode === 1 || displayMode === 2){ // 折线图,柱状图
|
133
|
-
//const xData = [], seriesData = [];
|
134
|
-
dataType = staticForType && staticTypeData || chartData && chartData.seriesData.length ? '' : 'def';
|
135
|
-
const seriesNodes = echartsOption.series;
|
136
|
-
const isBaseLineBar = ['line', 'bar'].includes(node.appearance.type);
|
137
|
-
// 双轴曲线
|
138
|
-
if(seriesNodes.length > 1 || node.data.params && node.data.params.curveNum > 1){
|
139
|
-
const legendData = [];
|
140
|
-
let legendChange = false;
|
141
|
-
echartsOption.xAxis[0].data = chartRealData.XData;
|
142
|
-
let order = 0;
|
143
|
-
//循环给每条统计数据赋值
|
144
|
-
seriesNodes.map((item, index) => {
|
145
|
-
let seriesItem = null;
|
146
|
-
// 执行类型为恢复默认
|
147
|
-
if(dataType === 'def') {
|
148
|
-
let defaultSeriesItem = defaultData.seriesData[order];
|
149
|
-
if(!defaultSeriesItem) defaultSeriesItem = defaultData.seriesData[0]; // 默认数据只有一个时,只取第一个
|
150
|
-
seriesItem = JSON.parse(JSON.stringify(defaultSeriesItem));
|
151
|
-
if(['line', 'bar'].includes(item.type)) order++; // 此判断为过滤series中的图表柱子或折线节点样式
|
152
|
-
if(!isBaseLineBar) return item.data = seriesItem.data; // 曲线或柱状图模板一般会走这个逻辑
|
153
|
-
if(!index) {
|
154
|
-
seriesItem.name = '标注1';
|
155
|
-
item.data = seriesItem.data;
|
156
|
-
}else {
|
157
|
-
// 自动生成series数据计算
|
158
|
-
for(let i = 0, sdl = seriesItem.data.length; i < sdl; i++){
|
159
|
-
displayMode === 1 ? seriesItem.data[i] -= 400 : seriesItem.data[i] += 100;
|
160
|
-
}
|
161
|
-
seriesItem.name = `标注${index + 1}`;
|
162
|
-
item.data = seriesItem.data;
|
163
|
-
}
|
164
|
-
}else {
|
165
|
-
// 执行类型为实时数据
|
166
|
-
seriesItem = chartRealData.seriesData[index];
|
167
|
-
if(!seriesItem) return item.data = [];
|
168
|
-
item.data = seriesItem.data;
|
169
|
-
}
|
170
|
-
// 获取角标数据
|
171
|
-
if(seriesItem.name) {
|
172
|
-
item.name = seriesItem.name;
|
173
|
-
legendData.push(seriesItem.name);
|
174
|
-
legendChange = true;
|
175
|
-
}
|
176
|
-
});
|
177
|
-
if(echartsOption.legend && legendChange) echartsOption.legend.data = legendData; // 为角标数据赋值
|
178
|
-
}else {
|
179
|
-
// 单曲线或柱状的执行逻辑
|
180
|
-
echartsOption.xAxis[0].data = chartRealData.XData;
|
181
|
-
const { name, data } = chartRealData.seriesData[0];
|
182
|
-
if(name) seriesNodes[0].name = name;
|
183
|
-
seriesNodes[0].data = data;
|
184
|
-
}
|
185
|
-
}
|
186
|
-
if(displayMode === 4) { // top排行榜
|
187
|
-
echartsOption.yAxis[0].data = chartRealData.XData;
|
188
|
-
const { data } = chartRealData.seriesData[0];
|
189
|
-
echartsOption.yAxis[1].data = data;
|
190
|
-
for (let i = 0; i < echartsOption.series.length; i++) {
|
191
|
-
const node = echartsOption.series[i];
|
192
|
-
node.symbolBoundingData = chartRealData.total;
|
193
|
-
node.data = data;
|
112
|
+
const realData = pen.data.params && seriesData && Object.keys(seriesData).length && seriesData[pen.data.params.id];
|
113
|
+
if (Array.isArray(realData)) {
|
114
|
+
getEchartsRealData(pen, realData);
|
115
|
+
} else {
|
116
|
+
commonStore[pen.TID].echartsRealDataPool[pen.id] = realData;
|
117
|
+
}
|
194
118
|
}
|
195
119
|
}
|
196
|
-
|
197
|
-
|
198
|
-
const pieData = staticForType ? chartData || defaultData : chartData && chartData.data || defaultData.seriesData;
|
199
|
-
const seriesData = [];
|
200
|
-
pieData.map((chd, index) => {
|
201
|
-
seriesData.push({
|
202
|
-
itemStyle: { color: colors[index] },
|
203
|
-
name: chd.name,
|
204
|
-
value: chd.value
|
205
|
-
})
|
206
|
-
})
|
207
|
-
echartsOption.series[0].data = seriesData;
|
120
|
+
return {
|
121
|
+
monitorAlarm: isAlarm
|
208
122
|
}
|
209
|
-
if(displayMode === 6){ // 仪表盘
|
210
|
-
// 仪表盘分两种,分别有不同的取值方式,下面两行先注释掉
|
211
|
-
// node.appearance.title.text = chartData.name;
|
212
|
-
// node.data.echarts.option.title.text = chartData.name;
|
213
|
-
echartsOption.series[0].data[0].value = chartData && chartData.value || defaultData.value;
|
214
|
-
}
|
215
|
-
return echartsOption;
|
216
123
|
}
|
124
|
+
|
217
125
|
export function setNodeEvents(item, pen) {
|
218
126
|
|
219
127
|
}
|
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
twowayArrow, twowayArrowIconRect, twowayArrowTextRect,
|
6
6
|
rectangle, rectangleIconRect, rectangleTextRect,
|
7
7
|
diamond, diamondIconRect, diamondTextRect,
|
8
|
-
text, file, formtable, tablePagination, iframePrimeval,
|
8
|
+
text, file, formtable, tablePagination, iframePrimeval,formSelect,
|
9
9
|
line as nodeLine, lineAnchors, lineIconRect, lineTextRect,
|
10
10
|
circle, circleIconRect, circleTextRect, circleAnchors,
|
11
11
|
triangle, triangleIconRect, triangleTextRect, triangleAnchors,
|
@@ -62,6 +62,8 @@ export var drawArrowFns = {};
|
|
62
62
|
function init() {
|
63
63
|
console.log('Init middles.');
|
64
64
|
// ********Default nodes.*******
|
65
|
+
// select
|
66
|
+
drawNodeFns.select = formSelect;
|
65
67
|
// iframe
|
66
68
|
drawNodeFns.iframe = iframePrimeval;
|
67
69
|
// tablePagination
|
@@ -1,17 +1,19 @@
|
|
1
1
|
export function arbitraryGraph(ctx, node) {
|
2
2
|
|
3
|
-
|
3
|
+
ctx.beginPath();
|
4
4
|
|
5
|
-
|
5
|
+
ctx.lineWidth = 1;
|
6
6
|
|
7
|
-
|
7
|
+
ctx.moveTo(node.rect.circles[0].x, node.rect.circles[0].y);
|
8
8
|
|
9
|
-
|
10
|
-
}
|
9
|
+
for(let i=1,len=node.rect.circles.length; i<len; i++) {
|
11
10
|
|
12
|
-
|
11
|
+
ctx.lineTo(node.rect.circles[i].x, node.rect.circles[i].y);
|
12
|
+
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
ctx.closePath();
|
15
|
+
|
16
|
+
(node.fillStyle || node.bkType) && ctx.fill();
|
17
|
+
|
18
|
+
ctx.stroke();
|
17
19
|
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import {rectangle} from './rectangle';
|
2
|
+
import {
|
3
|
+
createSelectElement,
|
4
|
+
createSelectDropdown} from '../../element';
|
5
|
+
import {
|
6
|
+
setEventListener,
|
7
|
+
s8} from '../../utils';
|
8
|
+
import {selectDefaultData} from '../../../../static';
|
9
|
+
import {commonStore} from "../../store";
|
10
|
+
|
11
|
+
export function formSelect(ctx, node) {
|
12
|
+
// 绘制一个底图,类似于占位符。
|
13
|
+
rectangle(ctx, node);
|
14
|
+
if (!commonStore[node.TID].selectDataPool[node.id]) {
|
15
|
+
const currentStore = commonStore[node.TID];
|
16
|
+
node.elementId = s8();
|
17
|
+
node.dash = 4;
|
18
|
+
currentStore.selectDataPool[node.id] = {
|
19
|
+
slideState: node.selectDropdown,
|
20
|
+
node: {
|
21
|
+
id: node.id,
|
22
|
+
color: node.font.color,
|
23
|
+
fontSize: node.font.fontSize,
|
24
|
+
selected: node.formData.selected || null
|
25
|
+
},
|
26
|
+
dom: {}
|
27
|
+
};
|
28
|
+
const bindBlockId = node.formData && node.formData.bindBlockId;
|
29
|
+
let selectRealData = bindBlockId && currentStore.selectRealDataPool[bindBlockId];
|
30
|
+
if(bindBlockId && selectRealData) {
|
31
|
+
// select与echarts互相关联
|
32
|
+
currentStore.selectDataPool[node.id].data = selectRealData;
|
33
|
+
const echartsData = currentStore.echartsDataPool[bindBlockId];
|
34
|
+
if(echartsData){
|
35
|
+
echartsData.bindId = node.id;
|
36
|
+
}else {
|
37
|
+
currentStore.echartsDataPool[bindBlockId] = {
|
38
|
+
bindId: node.id
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}else {
|
42
|
+
if(node.formData.ids) {
|
43
|
+
const optionIds = node.formData.ids.split(',');
|
44
|
+
const optionNames = node.formData.names.split(',');
|
45
|
+
const optionsData = [];
|
46
|
+
for (let i = 0; i < optionIds.length; i++) {
|
47
|
+
optionsData.push({
|
48
|
+
id: optionIds[i],
|
49
|
+
name: optionNames[i]
|
50
|
+
});
|
51
|
+
}
|
52
|
+
currentStore.selectDataPool[node.id].data = optionsData;
|
53
|
+
}else {
|
54
|
+
currentStore.selectDataPool[node.id].data = JSON.parse(JSON.stringify(selectDefaultData));
|
55
|
+
}
|
56
|
+
}
|
57
|
+
const select = createSelectElement(node);
|
58
|
+
currentStore.selectDataPool[node.id].dom.selectEle = select;
|
59
|
+
document.body.appendChild(select);
|
60
|
+
let selectDropdownEle = document.querySelector('.topology-select-dropdown');
|
61
|
+
if(!selectDropdownEle) {
|
62
|
+
selectDropdownEle = createSelectDropdown(node);
|
63
|
+
const parentEle = window.location.pathname.includes('workspace') ? document.getElementById('topology-canvas') : document.body;
|
64
|
+
parentEle.appendChild(selectDropdownEle);
|
65
|
+
// 鼠标按下
|
66
|
+
selectDropdownEle.addEventListener('mousedown', (e) => {
|
67
|
+
setEventListener(e, node.TID);
|
68
|
+
});
|
69
|
+
}
|
70
|
+
// 添加当前节点到div层
|
71
|
+
node.addToDiv();
|
72
|
+
}else {
|
73
|
+
const selectNode = commonStore[node.TID].selectDataPool[node.id];
|
74
|
+
if(selectNode.node.color === node.font.color && selectNode.node.fontSize === node.font.fontSize) return;
|
75
|
+
const selectDom = selectNode.dom;
|
76
|
+
if(!selectDom.selectInput) selectDom.selectInput = selectDom.selectEle.querySelector('.topology-select-input');
|
77
|
+
selectDom.selectInput.style.color = node.font.color;
|
78
|
+
selectDom.selectInput.style.fontSize = `${node.font.fontSize}px`;
|
79
|
+
if(node.selectDropdown) {
|
80
|
+
const liEle = selectDom.selectDropdownUl.querySelectorAll('.topology-select-dropdown-item');
|
81
|
+
liEle.forEach(function(element) {
|
82
|
+
element.style.color = node.font.color;
|
83
|
+
element.style.fontSize = `${node.font.fontSize}px`;
|
84
|
+
});
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
@@ -1,12 +1,29 @@
|
|
1
|
-
import {rectangle} from '
|
1
|
+
import {rectangle} from './rectangle';
|
2
|
+
import {s8} from "../../utils";
|
3
|
+
import {createIframeElement} from "../../element";
|
4
|
+
import {commonStore} from "../../store";
|
2
5
|
|
3
6
|
export function iframePrimeval(ctx, node) {
|
4
7
|
//console.log('iframePrimeval############', node)
|
5
8
|
// 绘制一个底图,类似于占位符。
|
6
9
|
rectangle(ctx, node);
|
7
|
-
if (!node.
|
10
|
+
if (!commonStore[node.TID].iframeDataPool[node.id]) {
|
11
|
+
node.elementId = s8();
|
12
|
+
commonStore[node.TID].iframeDataPool[node.id] = {
|
13
|
+
node: {
|
14
|
+
id: node.id,
|
15
|
+
src: node.iframe
|
16
|
+
}
|
17
|
+
};
|
18
|
+
const iframe = createIframeElement(node);
|
19
|
+
commonStore[node.TID].iframeDataPool[node.id].iframe = iframe;
|
20
|
+
const parentEle = window.location.pathname.includes('workspace') ? document.getElementById('topology-canvas') : document.body;
|
21
|
+
parentEle.appendChild(iframe);
|
8
22
|
// 添加当前节点到div层
|
9
|
-
node.addToDiv(
|
10
|
-
|
23
|
+
node.addToDiv();
|
24
|
+
}else {
|
25
|
+
const iframeNode = commonStore[node.TID].iframeDataPool[node.id];
|
26
|
+
if(iframeNode.node.src === node.iframe) return;
|
27
|
+
iframeNode.iframe.src = node.iframe;
|
11
28
|
}
|
12
29
|
}
|