Sidebar-IndustrialComponent.js 3.35 KB

(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();
	};
})();