Sidebar-IndustrialComponent.js
3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
(function () {
// Adds Atlassian shapes
// industrial label
Sidebar.prototype.addThingsKitIndustrialPalette = function () {
const gn = 'mxgraph.industrial';
const dt = 'industrial';
const label = mxResources.get('industry')
const width = 66;
const height = 74;
const prefix = `image;image=${window?.PROJECT_ENV.base}/webapp/images/thingskit/libs/`
const defaultStyle = ';imageAspect=0;'
this.setCurrentSearchEntryLibrary(dt);
const { COMPONENT_KEY, CATEGORY } = window.CellAttributeKeyEnum
function createUserObject(attribute) {
attribute = Object.assign({ [COMPONENT_KEY]: '', [CATEGORY]: '' }, attribute || {})
var xmlElement = mxUtils.createXmlDocument().createElement('UserObject');
Object.keys(attribute).forEach(key => {
xmlElement.setAttribute(key, attribute[key]);
})
return xmlElement
}
// 自定义属性
const cellAttribute = {
[COMPONENT_KEY]: 'Image',
[CATEGORY]: 'DEFAULT'
}
const graphPathLib = [
{ name: mxResources.get('industry1'), path: 'industrial/三级高速剪切机.svg' },
{ name: mxResources.get('industry2'), path: 'industrial/二甲氧基甲烷计量罐.svg' },
{ name: mxResources.get('industry3'), path: 'industrial/传送带.svg' },
{ name: mxResources.get('industry4'), path: 'industrial/分仓.svg' },
{ name: mxResources.get('industry5'), path: 'industrial/剪切机.svg' },
{ name: mxResources.get('industry6'), path: 'industrial/干线管道.svg' },
{ name: mxResources.get('industry7'), path: 'industrial/干酵母粉仓.svg' },
{ name: mxResources.get('industry8'), path: 'industrial/成品罐.svg' },
{ name: mxResources.get('industry9'), path: 'industrial/成熟度.svg' },
{ name: mxResources.get('industry10'), path: 'industrial/料仓.svg' },
{ name: mxResources.get('industry11'), path: 'industrial/旋液分离器.svg' },
{ name: mxResources.get('industry12'), path: 'industrial/智能控制周期.svg' },
{ name: mxResources.get('industry13'), path: 'industrial/机组.svg' },
{ name: mxResources.get('industry14'), path: 'industrial/母液槽.svg' },
{ name: mxResources.get('industry15'), path: 'industrial/母液槽2.svg' },
{ name: mxResources.get('industry16'), path: 'industrial/沥青混合料槽.svg' },
{ name: mxResources.get('industry17'), path: 'industrial/沥青膨胀罐.svg' },
{ name: mxResources.get('industry18'), path: 'industrial/泄料桶.svg' },
{ name: mxResources.get('industry19'), path: 'industrial/消烟管.svg' },
{ name: mxResources.get('industry20'), path: 'industrial/涡轮.svg' },
{ name: mxResources.get('industry21'), path: 'industrial/液态渣池.svg' },
{ name: mxResources.get('industry22'), path: 'industrial/漏斗.svg' },
{ name: mxResources.get('industry23'), path: 'industrial/烧结机.svg' },
{ name: mxResources.get('industry24'), path: 'industrial/畜粪池.svg' },
{ name: mxResources.get('industry25'), path: 'industrial/石灰粉仓.svg' },
{ name: mxResources.get('industry26'), path: 'industrial/酒槽水.svg' },
{ name: mxResources.get('industry27'), path: 'industrial/高效汽轮机.svg' },
]
const fns = graphPathLib.map(item => {
return this.addEntry(this.getTagsForStencil(gn, item.name, dt).join(' '), mxUtils.bind(this, function () {
const cell = new mxCell(createUserObject(cellAttribute), new mxGeometry(0, 0, width, height), `${prefix}${item.path}${defaultStyle}`);
cell.setVertex(true)
return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, item.name);
}));
})
this.setGalleryLib(dt, label, graphPathLib)
this.addPaletteFunctions(dt, label, false, fns);
this.setCurrentSearchEntryLibrary();
};
})();