Sidebar-FactoryFacilitiesComponent.js
4.36 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
83
84
85
86
87
88
89
90
91
92
93
(function () {
// Adds Atlassian shapes
// factoryFacilities label
Sidebar.prototype.addThingsKitfactoryFacilitiesPalette = function () {
const gn = 'mxgraph.factoryFacilities';
const dt = 'factoryFacilities';
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: 'factoryFacilities/制浆厂.svg' },
{ name: '加工工厂.svg', path: 'factoryFacilities/加工工厂.svg' },
{ name: '吊车.svg', path: 'factoryFacilities/吊车.svg' },
{ name: '提炼厂.svg', path: 'factoryFacilities/提炼厂.svg' },
{ name: '有刺铁丝网.svg', path: 'factoryFacilities/有刺铁丝网.svg' },
{ name: '梯子 1.svg', path: 'factoryFacilities/梯子 1.svg' },
{ name: '梯子 2.svg', path: 'factoryFacilities/梯子 2.svg' },
{ name: '楼层办公室.svg', path: 'factoryFacilities/楼层办公室.svg' },
{ name: '楼层夹板.svg', path: 'factoryFacilities/楼层夹板.svg' },
{ name: '楼梯 2.svg', path: 'factoryFacilities/楼梯 2.svg' },
{ name: '楼梯 3.svg', path: 'factoryFacilities/楼梯 3.svg' },
{ name: '楼梯 4.svg', path: 'factoryFacilities/楼梯 4.svg' },
{ name: '楼梯 5.svg', path: 'factoryFacilities/楼梯 5.svg' },
{ name: '楼梯.svg', path: 'factoryFacilities/楼梯.svg' },
{ name: '淡烟.svg', path: 'factoryFacilities/淡烟.svg' },
{ name: '烟囱 2.svg', path: 'factoryFacilities/烟囱 2.svg' },
{ name: '烟囱 3.svg', path: 'factoryFacilities/烟囱 3.svg' },
{ name: '烟囱.svg', path: 'factoryFacilities/烟囱.svg' },
{ name: '生产平台 1.svg', path: 'factoryFacilities/生产平台 1.svg' },
{ name: '生产平台 2.svg', path: 'factoryFacilities/生产平台 2.svg' },
{ name: '生产平台 3.svg', path: 'factoryFacilities/生产平台 3.svg' },
{ name: '生产设备.svg', path: 'factoryFacilities/生产设备.svg' },
{ name: '石油钻塔.svg', path: 'factoryFacilities/石油钻塔.svg' },
{ name: '砖烟囱.svg', path: 'factoryFacilities/砖烟囱.svg' },
{ name: '砖烟囱带架.svg', path: 'factoryFacilities/砖烟囱带架.svg' },
{ name: '紧急喷淋装置.svg', path: 'factoryFacilities/紧急喷淋装置.svg' },
{ name: '红白条烟囱.svg', path: 'factoryFacilities/红白条烟囱.svg' },
{ name: '绿色有刺铁丝网.svg', path: 'factoryFacilities/绿色有刺铁丝网.svg' },
{ name: '绿色铁丝网.svg', path: 'factoryFacilities/绿色铁丝网.svg' },
{ name: '通道梯.svg', path: 'factoryFacilities/通道梯.svg' },
{ name: '金字塔型通信塔.svg', path: 'factoryFacilities/金字塔型通信塔.svg' },
{ name: '钢格板 1.svg', path: 'factoryFacilities/钢格板 1.svg' },
{ name: '钢格板 2.svg', path: 'factoryFacilities/钢格板 2.svg' },
{ name: '钻探设备.svg', path: 'factoryFacilities/钻探设备.svg' },
{ name: '铁丝网.svg', path: 'factoryFacilities/铁丝网.svg' },
{ name: '防护筛.svg', path: 'factoryFacilities/防护筛.svg' },
{ name: '防护筛2.svg', path: 'factoryFacilities/防护筛2.svg' },
{ name: '黑色烟雾.svg', path: 'factoryFacilities/黑色烟雾.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();
};
})();