Sidebar-IndustrialComponent.js
3.35 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 = '工业'
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: '三级高速剪切机.svg', path: 'industrial/三级高速剪切机.svg' },
{ name: '二甲氧基甲烷计量罐.svg', path: 'industrial/二甲氧基甲烷计量罐.svg' },
{ name: '传送带.svg', path: 'industrial/传送带.svg' },
{ name: '分仓.svg', path: 'industrial/分仓.svg' },
{ name: '剪切机.svg', path: 'industrial/剪切机.svg' },
{ name: '干线管道.svg', path: 'industrial/干线管道.svg' },
{ name: '干酵母粉仓.svg', path: 'industrial/干酵母粉仓.svg' },
{ name: '成品罐.svg', path: 'industrial/成品罐.svg' },
{ name: '成熟度.svg', path: 'industrial/成熟度.svg' },
{ name: '料仓.svg', path: 'industrial/料仓.svg' },
{ name: '旋液分离器.svg', path: 'industrial/旋液分离器.svg' },
{ name: '智能控制周期.svg', path: 'industrial/智能控制周期.svg' },
{ name: '机组.svg', path: 'industrial/机组.svg' },
{ name: '母液槽.svg', path: 'industrial/母液槽.svg' },
{ name: '母液槽2.svg', path: 'industrial/母液槽2.svg' },
{ name: '沥青混合料槽.svg', path: 'industrial/沥青混合料槽.svg' },
{ name: '沥青膨胀罐.svg', path: 'industrial/沥青膨胀罐.svg' },
{ name: '泄料桶.svg', path: 'industrial/泄料桶.svg' },
{ name: '消烟管.svg', path: 'industrial/消烟管.svg' },
{ name: '涡轮.svg', path: 'industrial/涡轮.svg' },
{ name: '液态渣池.svg', path: 'industrial/液态渣池.svg' },
{ name: '漏斗.svg', path: 'industrial/漏斗.svg' },
{ name: '烧结机.svg', path: 'industrial/烧结机.svg' },
{ name: '畜粪池.svg', path: 'industrial/畜粪池.svg' },
{ name: '石灰粉仓.svg', path: 'industrial/石灰粉仓.svg' },
{ name: '酒槽水.svg', path: 'industrial/酒槽水.svg' },
{ name: '高效汽轮机.svg', 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();
};
})();