projects/mes-test #133
@@ -109,7 +109,7 @@
 | 
			
		||||
<script>
 | 
			
		||||
import { getAccessToken } from '@/utils/auth';
 | 
			
		||||
import tupleImg from '@/assets/images/tuple.png';
 | 
			
		||||
import cache from '@/views/extend/processFlow/cache';
 | 
			
		||||
import cache from '@/utils/cache';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 找到最长的label
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import basicPageMixin from '@/mixins/lb/basicPageMixin';
 | 
			
		||||
// import cache from './cache';
 | 
			
		||||
// import cache from '@/utils/cache';
 | 
			
		||||
 | 
			
		||||
const ProcessItem = {
 | 
			
		||||
	name: 'ProcessItem',
 | 
			
		||||
 
 | 
			
		||||
@@ -12,180 +12,337 @@
 | 
			
		||||
		<div
 | 
			
		||||
			class="btns"
 | 
			
		||||
			style="text-align: right; position: absolute; top: 20px; right: 20px">
 | 
			
		||||
			<el-button
 | 
			
		||||
				type="warning"
 | 
			
		||||
				@click="undo"
 | 
			
		||||
				plain
 | 
			
		||||
				v-if="allowUndo"
 | 
			
		||||
				:disabled="!allowUndo"
 | 
			
		||||
				icon="el-icon-back">
 | 
			
		||||
				撤销
 | 
			
		||||
			</el-button>
 | 
			
		||||
			<el-button
 | 
			
		||||
				type="warning"
 | 
			
		||||
				@click="redo"
 | 
			
		||||
				plain
 | 
			
		||||
				v-if="allowRedo"
 | 
			
		||||
				:disabled="!allowRedo">
 | 
			
		||||
				下一步
 | 
			
		||||
				<i class="el-icon-right el-icon--right"></i>
 | 
			
		||||
			</el-button>
 | 
			
		||||
			<el-button
 | 
			
		||||
				type="primary"
 | 
			
		||||
				plain
 | 
			
		||||
				class="btn-create"
 | 
			
		||||
				icon="el-icon-plus"
 | 
			
		||||
				@click="createDet">
 | 
			
		||||
				@click="handleAdd">
 | 
			
		||||
				新建工序
 | 
			
		||||
			</el-button>
 | 
			
		||||
			<el-button class="btn-serialize" @click="graphToJson">序列化</el-button>
 | 
			
		||||
			<el-button class="btn-antiserialize" @click="jsonToGraph">
 | 
			
		||||
				反序列化
 | 
			
		||||
			</el-button>
 | 
			
		||||
			<el-button class="btn-edit" @click="handleEdit">编辑</el-button>
 | 
			
		||||
			<el-button type="error" class="btn-delete" @click="handleDelete">
 | 
			
		||||
				删除
 | 
			
		||||
			</el-button>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class="process-graph__panel" ref="panel"></div>
 | 
			
		||||
 | 
			
		||||
		<!-- 对话框(添加 / 修改) -->
 | 
			
		||||
		<base-dialog
 | 
			
		||||
			:dialogTitle="title"
 | 
			
		||||
			:dialogVisible="open"
 | 
			
		||||
			width="35%"
 | 
			
		||||
			@close="cancel"
 | 
			
		||||
			@cancel="cancel"
 | 
			
		||||
			@confirm="submitForm">
 | 
			
		||||
			<DialogForm v-if="open" ref="form" v-model="form" :rows="rows" />
 | 
			
		||||
		</base-dialog>
 | 
			
		||||
	</section>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { Graph } from '@antv/x6';
 | 
			
		||||
import ProcessNode from './ProcessNode';
 | 
			
		||||
import DialogForm from '@/components/DialogForm';
 | 
			
		||||
 | 
			
		||||
Graph.registerNode('process-node', ProcessNode);
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
	name: 'ProcessGraph',
 | 
			
		||||
	components: {},
 | 
			
		||||
	components: { DialogForm },
 | 
			
		||||
	props: {},
 | 
			
		||||
	inject: ['getFlowId'],
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			allowRedo: false,
 | 
			
		||||
			allowUndo: false,
 | 
			
		||||
			graph: null,
 | 
			
		||||
			searchBarFormConfig: [{ label: '工序列表' }],
 | 
			
		||||
			title: '',
 | 
			
		||||
			open: false,
 | 
			
		||||
			form: {
 | 
			
		||||
				name: '', // 工序名称
 | 
			
		||||
				sectionId: '', // 工段id
 | 
			
		||||
				remark: '', // 描述
 | 
			
		||||
			},
 | 
			
		||||
			rows: [
 | 
			
		||||
				[
 | 
			
		||||
					{
 | 
			
		||||
						input: true,
 | 
			
		||||
						label: '工序名称',
 | 
			
		||||
						prop: 'name',
 | 
			
		||||
						rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
 | 
			
		||||
					},
 | 
			
		||||
				],
 | 
			
		||||
				[
 | 
			
		||||
					{
 | 
			
		||||
						select: true,
 | 
			
		||||
						label: '工段',
 | 
			
		||||
						prop: 'sectionId',
 | 
			
		||||
						url: '/base/core-workshop-section/listAll',
 | 
			
		||||
						rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
 | 
			
		||||
						bind: {
 | 
			
		||||
							filterable: true,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				],
 | 
			
		||||
				[
 | 
			
		||||
					{
 | 
			
		||||
						textarea: true,
 | 
			
		||||
						label: '工序说明',
 | 
			
		||||
						prop: 'remark',
 | 
			
		||||
					},
 | 
			
		||||
				],
 | 
			
		||||
			],
 | 
			
		||||
			updateUrl: '/extend/process-flow-det/update',
 | 
			
		||||
			addUrl: '/extend/process-flow-det/create',
 | 
			
		||||
			// pageUrl: '/extend/process-flow-det/get',
 | 
			
		||||
			infoUrl: '/extend/process-flow-det/get',
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
	watch: {
 | 
			
		||||
		'form.sectionId': {
 | 
			
		||||
			handler(id) {
 | 
			
		||||
				// const { form } = this;
 | 
			
		||||
				// const { sectionId } = form;
 | 
			
		||||
				// if (sectionId) {
 | 
			
		||||
				// 	const { label } = this.$refs['form'].getSelectItem(
 | 
			
		||||
				// 		'sectionId',
 | 
			
		||||
				// 		sectionId
 | 
			
		||||
				// 	);
 | 
			
		||||
				// 	form.workshopName = label;
 | 
			
		||||
				// }
 | 
			
		||||
			},
 | 
			
		||||
			immediate: false,
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	mounted() {
 | 
			
		||||
		const graph = new Graph({
 | 
			
		||||
			container: this.$refs.panel,
 | 
			
		||||
			grid: {
 | 
			
		||||
				size: 10,
 | 
			
		||||
				visible: false,
 | 
			
		||||
				type: 'dot',
 | 
			
		||||
				args: {
 | 
			
		||||
					color: '#f005',
 | 
			
		||||
					thickness: 1,
 | 
			
		||||
				},
 | 
			
		||||
				visible: true,
 | 
			
		||||
			},
 | 
			
		||||
			history: true,
 | 
			
		||||
			selecting: {
 | 
			
		||||
				enabled: true,
 | 
			
		||||
				rubberband: true,
 | 
			
		||||
				movable: true,
 | 
			
		||||
				showNodeSelectionBox: true,
 | 
			
		||||
				className: 'process-selected',
 | 
			
		||||
			},
 | 
			
		||||
			snapline: true,
 | 
			
		||||
			scroller: {
 | 
			
		||||
				enabled: true,
 | 
			
		||||
			},
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		graph.on('node:click', ({ node }) => {
 | 
			
		||||
			const { processId } = node.attrs;
 | 
			
		||||
			console.log('node:click', processId.text);
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		// const pn1 = graph.addNode({
 | 
			
		||||
		// 	shape: 'process-node',
 | 
			
		||||
		// 	x: 30,
 | 
			
		||||
		// 	y: 30,
 | 
			
		||||
		// 	processName: '工序00A',
 | 
			
		||||
		// 	workshopName: '工段1',
 | 
			
		||||
		// 	processDesc: 'test test test',
 | 
			
		||||
		// 	processId: '1',
 | 
			
		||||
		// 	tools: [{ name: 'button-remove' }],
 | 
			
		||||
		// });
 | 
			
		||||
		// const pn2 = graph.addNode({
 | 
			
		||||
		// 	shape: 'process-node',
 | 
			
		||||
		// 	x: 240,
 | 
			
		||||
		// 	y: 30,
 | 
			
		||||
		// 	processName: '工序00B',
 | 
			
		||||
		// 	workshopName: '工段1',
 | 
			
		||||
		// 	processDesc: 'test test test',
 | 
			
		||||
		// 	processId: '1',
 | 
			
		||||
		// });
 | 
			
		||||
 | 
			
		||||
		// const pn3 = graph.addNode({
 | 
			
		||||
		// 	shape: 'process-node',
 | 
			
		||||
		// 	x: 360,
 | 
			
		||||
		// 	y: 30,
 | 
			
		||||
		// 	processName: '工序00C',
 | 
			
		||||
		// 	workshopName: '工段1',
 | 
			
		||||
		// 	processDesc: 'test test test',
 | 
			
		||||
		// 	processId: '1',
 | 
			
		||||
		// });
 | 
			
		||||
 | 
			
		||||
		// const pn4 = graph.addNode({
 | 
			
		||||
		// 	shape: 'process-node',
 | 
			
		||||
		// 	x: 360,
 | 
			
		||||
		// 	y: 120,
 | 
			
		||||
		// 	processName: '工序00D',
 | 
			
		||||
		// 	workshopName: '工段1',
 | 
			
		||||
		// 	processDesc: 'test test test',
 | 
			
		||||
		// 	processId: '1',
 | 
			
		||||
		// });
 | 
			
		||||
 | 
			
		||||
		// const pn5 = graph.addNode({
 | 
			
		||||
		// 	shape: 'process-node',
 | 
			
		||||
		// 	x: 500,
 | 
			
		||||
		// 	y: 30,
 | 
			
		||||
		// 	processName: '工序00E',
 | 
			
		||||
		// 	workshopName: '工段1',
 | 
			
		||||
		// 	processDesc: 'test test test',
 | 
			
		||||
		// 	processId: '1',
 | 
			
		||||
		// });
 | 
			
		||||
 | 
			
		||||
		// graph.addEdge({
 | 
			
		||||
		// 	source: pn1,
 | 
			
		||||
		// 	target: pn2,
 | 
			
		||||
		// 	router: {
 | 
			
		||||
		// 		name: 'er',
 | 
			
		||||
		// 	},
 | 
			
		||||
		// 	attrs: {
 | 
			
		||||
		// 		line: {
 | 
			
		||||
		// 			stroke: '#0b58ff',
 | 
			
		||||
		// 			strokeWidth: 1,
 | 
			
		||||
		// 			targetMarker: {
 | 
			
		||||
		// 				// name: 'classic',
 | 
			
		||||
		// 				// name: 'async',
 | 
			
		||||
		// 				size: 0,
 | 
			
		||||
		// 			},
 | 
			
		||||
		// 		},
 | 
			
		||||
		// 	},
 | 
			
		||||
		// });
 | 
			
		||||
		// graph.addEdge({
 | 
			
		||||
		// 	source: pn2,
 | 
			
		||||
		// 	target: pn3,
 | 
			
		||||
		// 	router: {
 | 
			
		||||
		// 		name: 'er',
 | 
			
		||||
		// 	},
 | 
			
		||||
		// 	attrs: {
 | 
			
		||||
		// 		line: {
 | 
			
		||||
		// 			stroke: '#0b58ff',
 | 
			
		||||
		// 			strokeWidth: 1,
 | 
			
		||||
		// 			targetMarker: {
 | 
			
		||||
		// 				// name: 'classic',
 | 
			
		||||
		// 				// name: 'async',
 | 
			
		||||
		// 				size: 0,
 | 
			
		||||
		// 			},
 | 
			
		||||
		// 		},
 | 
			
		||||
		// 	},
 | 
			
		||||
		// });
 | 
			
		||||
		// graph.addEdge({
 | 
			
		||||
		// 	source: pn2,
 | 
			
		||||
		// 	target: pn4,
 | 
			
		||||
		// 	router: {
 | 
			
		||||
		// 		name: 'er',
 | 
			
		||||
		// 	},
 | 
			
		||||
		// 	attrs: {
 | 
			
		||||
		// 		line: {
 | 
			
		||||
		// 			stroke: '#0b58ff',
 | 
			
		||||
		// 			strokeWidth: 1,
 | 
			
		||||
		// 			targetMarker: {
 | 
			
		||||
		// 				// name: 'classic',
 | 
			
		||||
		// 				// name: 'async',
 | 
			
		||||
		// 				size: 0,
 | 
			
		||||
		// 			},
 | 
			
		||||
		// 		},
 | 
			
		||||
		// 	},
 | 
			
		||||
		// });
 | 
			
		||||
		// graph.addEdge({
 | 
			
		||||
		// 	source: pn3,
 | 
			
		||||
		// 	target: pn5,
 | 
			
		||||
		// 	router: {
 | 
			
		||||
		// 		name: 'er',
 | 
			
		||||
		// 	},
 | 
			
		||||
		// 	attrs: {
 | 
			
		||||
		// 		line: {
 | 
			
		||||
		// 			stroke: '#0b58ff',
 | 
			
		||||
		// 			strokeWidth: 1,
 | 
			
		||||
		// 			targetMarker: {
 | 
			
		||||
		// 				// name: 'classic',
 | 
			
		||||
		// 				// name: 'async',
 | 
			
		||||
		// 				size: 0,
 | 
			
		||||
		// 			},
 | 
			
		||||
		// 		},
 | 
			
		||||
		// 	},
 | 
			
		||||
		// });
 | 
			
		||||
		// graph.addEdge({
 | 
			
		||||
		// 	source: pn4,
 | 
			
		||||
		// 	target: pn5,
 | 
			
		||||
		// 	router: {
 | 
			
		||||
		// 		name: 'er',
 | 
			
		||||
		// 	},
 | 
			
		||||
		// 	attrs: {
 | 
			
		||||
		// 		line: {
 | 
			
		||||
		// 			stroke: '#0b58ff',
 | 
			
		||||
		// 			strokeWidth: 1,
 | 
			
		||||
		// 			targetMarker: {
 | 
			
		||||
		// 				// name: 'classic',
 | 
			
		||||
		// 				// name: 'async',
 | 
			
		||||
		// 				size: 0,
 | 
			
		||||
		// 			},
 | 
			
		||||
		// 		},
 | 
			
		||||
		// 	},
 | 
			
		||||
		// });
 | 
			
		||||
 | 
			
		||||
		const pn1 = graph.addNode({
 | 
			
		||||
			shape: 'process-node',
 | 
			
		||||
			x: 30,
 | 
			
		||||
			y: 30,
 | 
			
		||||
			processName: '工序00A',
 | 
			
		||||
			workshopName: '工段1',
 | 
			
		||||
            processDesc: 'test test test',
 | 
			
		||||
			processId: '1',
 | 
			
		||||
		});
 | 
			
		||||
		const pn2 = graph.addNode({
 | 
			
		||||
			shape: 'process-node',
 | 
			
		||||
			x: 240,
 | 
			
		||||
			y: 30,
 | 
			
		||||
			processName: '工序00B',
 | 
			
		||||
			workshopName: '工段1',
 | 
			
		||||
            processDesc: 'test test test',
 | 
			
		||||
			processId: '1',
 | 
			
		||||
			x: 0,
 | 
			
		||||
			y: 0,
 | 
			
		||||
			detName: '测试工序', // 工序名称
 | 
			
		||||
			sectionName: 'default', // 工段
 | 
			
		||||
			detDesc: 'loremakdfkd...', // 工序说明
 | 
			
		||||
			processId: 'p-1', // 工艺ID
 | 
			
		||||
			detId: 'det-id-1', // 工序ID
 | 
			
		||||
			tools: [{ name: 'button-remove' }],
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		const pn3 = graph.addNode({
 | 
			
		||||
			shape: 'process-node',
 | 
			
		||||
			x: 360,
 | 
			
		||||
			y: 30,
 | 
			
		||||
			processName: '工序00C',
 | 
			
		||||
			workshopName: '工段1',
 | 
			
		||||
            processDesc: 'test test test',
 | 
			
		||||
			processId: '1',
 | 
			
		||||
		});
 | 
			
		||||
		// const htmlNode = graph.addNode({
 | 
			
		||||
		// 	x: 0,
 | 
			
		||||
		// 	y: 0,
 | 
			
		||||
		// 	width: 200,
 | 
			
		||||
		// 	height: 100,
 | 
			
		||||
		// 	shape: 'html',
 | 
			
		||||
		// 	html() {
 | 
			
		||||
		// 		const ctn = document.createElement('div');
 | 
			
		||||
		// 		ctn.style.width = '100%';
 | 
			
		||||
		// 		ctn.style.height = '100%';
 | 
			
		||||
		// 		ctn.style.border = '1px solid #ccc';
 | 
			
		||||
		// 		ctn.style.background = '#fff';
 | 
			
		||||
		// 		ctn.innerText = 'hello';
 | 
			
		||||
 | 
			
		||||
		const pn4 = graph.addNode({
 | 
			
		||||
			shape: 'process-node',
 | 
			
		||||
			x: 360,
 | 
			
		||||
			y: 120,
 | 
			
		||||
			processName: '工序00D',
 | 
			
		||||
			workshopName: '工段1',
 | 
			
		||||
            processDesc: 'test test test',
 | 
			
		||||
			processId: '1',
 | 
			
		||||
		});
 | 
			
		||||
		// 		return ctn;
 | 
			
		||||
		// 	},
 | 
			
		||||
		// });
 | 
			
		||||
 | 
			
		||||
		const pn5 = graph.addNode({
 | 
			
		||||
			shape: 'process-node',
 | 
			
		||||
			x: 500,
 | 
			
		||||
			y: 30,
 | 
			
		||||
			processName: '工序00E',
 | 
			
		||||
			workshopName: '工段1',
 | 
			
		||||
            processDesc: 'test test test',
 | 
			
		||||
			processId: '1',
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		graph.addEdge({
 | 
			
		||||
			source: pn1,
 | 
			
		||||
			target: pn2,
 | 
			
		||||
			attrs: {
 | 
			
		||||
				line: {
 | 
			
		||||
					stroke: '#0b58ff',
 | 
			
		||||
					strokeWidth: 1,
 | 
			
		||||
					targetMarker: {
 | 
			
		||||
						// name: 'classic',
 | 
			
		||||
						// name: 'async',
 | 
			
		||||
						size: 0,
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		});
 | 
			
		||||
		graph.addEdge({
 | 
			
		||||
			source: pn2,
 | 
			
		||||
			target: pn3,
 | 
			
		||||
			attrs: {
 | 
			
		||||
				line: {
 | 
			
		||||
					stroke: '#0b58ff',
 | 
			
		||||
					strokeWidth: 1,
 | 
			
		||||
					targetMarker: {
 | 
			
		||||
						// name: 'classic',
 | 
			
		||||
						// name: 'async',
 | 
			
		||||
						size: 0,
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		});
 | 
			
		||||
		graph.addEdge({
 | 
			
		||||
			source: pn2,
 | 
			
		||||
			target: pn4,
 | 
			
		||||
			attrs: {
 | 
			
		||||
				line: {
 | 
			
		||||
					stroke: '#0b58ff',
 | 
			
		||||
					strokeWidth: 1,
 | 
			
		||||
					targetMarker: {
 | 
			
		||||
						// name: 'classic',
 | 
			
		||||
						// name: 'async',
 | 
			
		||||
						size: 0,
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		});
 | 
			
		||||
		graph.addEdge({
 | 
			
		||||
			source: pn3,
 | 
			
		||||
			target: pn5,
 | 
			
		||||
			attrs: {
 | 
			
		||||
				line: {
 | 
			
		||||
					stroke: '#0b58ff',
 | 
			
		||||
					strokeWidth: 1,
 | 
			
		||||
					targetMarker: {
 | 
			
		||||
						// name: 'classic',
 | 
			
		||||
						// name: 'async',
 | 
			
		||||
						size: 0,
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		});
 | 
			
		||||
		graph.addEdge({
 | 
			
		||||
			source: pn4,
 | 
			
		||||
			target: pn5,
 | 
			
		||||
			attrs: {
 | 
			
		||||
				line: {
 | 
			
		||||
					stroke: '#0b58ff',
 | 
			
		||||
					strokeWidth: 1,
 | 
			
		||||
					targetMarker: {
 | 
			
		||||
						// name: 'classic',
 | 
			
		||||
						// name: 'async',
 | 
			
		||||
						size: 0,
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		graph.on('cell:selected', ({ cell, options }) => {
 | 
			
		||||
			console.log('cell:selected', cell, options);
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		this.graph = graph;
 | 
			
		||||
 | 
			
		||||
		// console.log('selected:', this.graph.selection.widget.container)
 | 
			
		||||
	},
 | 
			
		||||
	computed: {},
 | 
			
		||||
	methods: {
 | 
			
		||||
@@ -196,6 +353,109 @@ export default {
 | 
			
		||||
				console.log(JSON.stringify(this.graph.toJSON(), null, 2));
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		reset() {
 | 
			
		||||
			this.form = {
 | 
			
		||||
				name: '', // 工序名称
 | 
			
		||||
				sectionId: '', // 工段id
 | 
			
		||||
				remark: '', // 描述
 | 
			
		||||
			};
 | 
			
		||||
			this.resetForm('form');
 | 
			
		||||
		},
 | 
			
		||||
		/** 取消按钮 */
 | 
			
		||||
		cancel() {
 | 
			
		||||
			this.open = false;
 | 
			
		||||
			this.reset();
 | 
			
		||||
		},
 | 
			
		||||
		handleAdd() {
 | 
			
		||||
			this.reset();
 | 
			
		||||
			this.open = true;
 | 
			
		||||
			this.title = '添加工序';
 | 
			
		||||
		},
 | 
			
		||||
		handleEdit() {
 | 
			
		||||
			this.open = true;
 | 
			
		||||
			this.title = '编辑工序';
 | 
			
		||||
		},
 | 
			
		||||
		handleDelete(id) {},
 | 
			
		||||
		/** 提交按钮 */
 | 
			
		||||
		submitForm() {
 | 
			
		||||
			this.$refs['form'].validate((valid) => {
 | 
			
		||||
				if (!valid) {
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
				// 修改的提交
 | 
			
		||||
				if (this.form.id != null) {
 | 
			
		||||
					this.updateProcess();
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
				this.createProcess().then((id) => {
 | 
			
		||||
					if (!id) return;
 | 
			
		||||
					this.graph.addNode(
 | 
			
		||||
						this.createProcessNode({
 | 
			
		||||
							flowId: this.flowId,
 | 
			
		||||
							...this.form,
 | 
			
		||||
							id,
 | 
			
		||||
						})
 | 
			
		||||
					);
 | 
			
		||||
				});
 | 
			
		||||
			});
 | 
			
		||||
		},
 | 
			
		||||
		createProcessNode({ flowId, name, id, remark, sectionId }) {
 | 
			
		||||
			return {
 | 
			
		||||
				shape: 'process-node',
 | 
			
		||||
				x: 0,
 | 
			
		||||
				y: 0,
 | 
			
		||||
				detName: name, // 工序名称
 | 
			
		||||
				sectionName: 'default', // 工段
 | 
			
		||||
				detDesc: remark, // 工序说明
 | 
			
		||||
				processId: flowId, // 工艺ID
 | 
			
		||||
				detId: id, // 工序ID
 | 
			
		||||
				tools: [{ name: 'button-remove' }],
 | 
			
		||||
			};
 | 
			
		||||
		},
 | 
			
		||||
		updateProcess() {
 | 
			
		||||
			return updateEquipmentType(this.form).then((response) => {
 | 
			
		||||
				this.$modal.msgSuccess('修改成功');
 | 
			
		||||
				this.open = false;
 | 
			
		||||
				// this.getList();
 | 
			
		||||
			});
 | 
			
		||||
		},
 | 
			
		||||
		createProcess() {
 | 
			
		||||
			const flowId = this.$route.params.id;
 | 
			
		||||
			// const t = this.getFlowId(); // it also works
 | 
			
		||||
			if (!flowId) {
 | 
			
		||||
				this.$modal.msgError('工艺ID不能为空');
 | 
			
		||||
				return Promise.reject(null);
 | 
			
		||||
			}
 | 
			
		||||
			// 添加的提交
 | 
			
		||||
			return this.post({ flowId: this.flowId, ...this.form }).then(
 | 
			
		||||
				({ code, data }) => {
 | 
			
		||||
					this.$modal.msgSuccess('新增成功');
 | 
			
		||||
					this.open = false;
 | 
			
		||||
					// this.getList();
 | 
			
		||||
					return data;
 | 
			
		||||
				}
 | 
			
		||||
			);
 | 
			
		||||
		},
 | 
			
		||||
		put(payload) {
 | 
			
		||||
			return this.http(this.updateUrl, 'put', payload);
 | 
			
		||||
		},
 | 
			
		||||
		post(payload) {
 | 
			
		||||
			return this.http(this.addUrl, 'post', payload);
 | 
			
		||||
		},
 | 
			
		||||
		recv(payload) {
 | 
			
		||||
			return this.http(this.pageUrl, 'get', payload);
 | 
			
		||||
		},
 | 
			
		||||
		info(payload) {
 | 
			
		||||
			return this.http(this.infoUrl, 'get', payload);
 | 
			
		||||
		},
 | 
			
		||||
		http(url, method, payload) {
 | 
			
		||||
			return this.$axios({
 | 
			
		||||
				url,
 | 
			
		||||
				method,
 | 
			
		||||
				params: method === 'get' ? payload : null,
 | 
			
		||||
				data: method !== 'get' ? payload : null,
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
@@ -212,3 +472,9 @@ export default {
 | 
			
		||||
	height: 300px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
 | 
			
		||||
<style>
 | 
			
		||||
.x6-widget-selection-selected {
 | 
			
		||||
	border: 1px solid red;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
 
 | 
			
		||||
@@ -11,13 +11,14 @@ ProcessNode.config({
 | 
			
		||||
    markup: [
 | 
			
		||||
        {
 | 
			
		||||
            tagName: 'rect',
 | 
			
		||||
            selector: 'container',
 | 
			
		||||
            attrs: {
 | 
			
		||||
                x: 0,
 | 
			
		||||
                y: 0,
 | 
			
		||||
                width: 200,
 | 
			
		||||
                height: 100,
 | 
			
		||||
                fill: 'transparent',
 | 
			
		||||
                stroke: '#0b58ff'
 | 
			
		||||
                stroke: '#ccc'
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
@@ -42,7 +43,7 @@ ProcessNode.config({
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            tagName: 'text',
 | 
			
		||||
            selector: 'processName',
 | 
			
		||||
            selector: 'detName',
 | 
			
		||||
            attrs: {
 | 
			
		||||
                x: 20,
 | 
			
		||||
                y: 30,
 | 
			
		||||
@@ -52,7 +53,7 @@ ProcessNode.config({
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            tagName: 'text',
 | 
			
		||||
            selector: 'workshopName',
 | 
			
		||||
            selector: 'sectionName',
 | 
			
		||||
            attrs: {
 | 
			
		||||
                x: 115,
 | 
			
		||||
                y: 30,
 | 
			
		||||
@@ -62,74 +63,27 @@ ProcessNode.config({
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            tagName: 'text',
 | 
			
		||||
            selector: 'processDesc',
 | 
			
		||||
            selector: 'detDesc',
 | 
			
		||||
            // textContent: '工序00A',
 | 
			
		||||
            attrs: {
 | 
			
		||||
                x: 26,
 | 
			
		||||
                y: 80,
 | 
			
		||||
                fill: '#777',
 | 
			
		||||
                fontSize: 14
 | 
			
		||||
                fontSize: 14,
 | 
			
		||||
                fill: '#1a90fc',
 | 
			
		||||
                // lengthAdjust: 'spacingAndGlyphs',
 | 
			
		||||
                // textLength: 180
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        // {
 | 
			
		||||
        //     tagName: 'text',
 | 
			
		||||
        //     textContent: '工序名称',
 | 
			
		||||
        //     attrs: {
 | 
			
		||||
        //         x: 20,
 | 
			
		||||
        //         y: 30,
 | 
			
		||||
        //     },
 | 
			
		||||
        // },
 | 
			
		||||
        // {
 | 
			
		||||
        //     tagName: 'text',
 | 
			
		||||
        //     textContent: '工段名称',
 | 
			
		||||
        //     attrs: {
 | 
			
		||||
        //         x: 115,
 | 
			
		||||
        //         y: 30,
 | 
			
		||||
        //     },
 | 
			
		||||
        // },
 | 
			
		||||
        // {
 | 
			
		||||
        //     tagName: 'text',
 | 
			
		||||
        //     selector: 'processName',
 | 
			
		||||
        //     // textContent: '工序00A',
 | 
			
		||||
        //     attrs: {
 | 
			
		||||
        //         x: 26,
 | 
			
		||||
        //         y: 80,
 | 
			
		||||
        //         fill: '#777',
 | 
			
		||||
        //         fontSize: 14
 | 
			
		||||
        //     },
 | 
			
		||||
        // },
 | 
			
		||||
        // {
 | 
			
		||||
        //     tagName: 'text',
 | 
			
		||||
        //     selector: 'workshopName',
 | 
			
		||||
        //     // textContent: '工段1',
 | 
			
		||||
        //     attrs: {
 | 
			
		||||
        //         x: 128,
 | 
			
		||||
        //         y: 80,
 | 
			
		||||
        //         fill: '#777',
 | 
			
		||||
        //         fontSize: 14
 | 
			
		||||
        //     },
 | 
			
		||||
        // },
 | 
			
		||||
    ],
 | 
			
		||||
    //
 | 
			
		||||
    propHooks(metadata) {
 | 
			
		||||
        const { processName, workshopName, processDesc, processId, ...others } = metadata;
 | 
			
		||||
        const { detId, detName, detDesc, sectionName, processId, ...others } = metadata;
 | 
			
		||||
        // debugger;
 | 
			
		||||
        if (processName) {
 | 
			
		||||
            console.log("processName", processName)
 | 
			
		||||
            ObjectExt.setByPath(others, 'attrs/processName/text', processName);
 | 
			
		||||
        }
 | 
			
		||||
        if (workshopName) {
 | 
			
		||||
            console.log("workshopName", workshopName)
 | 
			
		||||
            ObjectExt.setByPath(others, 'attrs/workshopName/text', workshopName);
 | 
			
		||||
        }
 | 
			
		||||
        if (processDesc) {
 | 
			
		||||
            console.log("processDesc", processDesc)
 | 
			
		||||
            ObjectExt.setByPath(others, 'attrs/processDesc/text', processDesc);
 | 
			
		||||
        }
 | 
			
		||||
        if (processId) {
 | 
			
		||||
            console.log("processId", processId)
 | 
			
		||||
            ObjectExt.setByPath(others, 'processId', processId);
 | 
			
		||||
        }
 | 
			
		||||
        if (detName) ObjectExt.setByPath(others, 'attrs/detName/text', detName);
 | 
			
		||||
        if (detDesc) ObjectExt.setByPath(others, 'attrs/detDesc/text', detDesc);
 | 
			
		||||
        if (sectionName) ObjectExt.setByPath(others, 'attrs/sectionName/text', sectionName);
 | 
			
		||||
        if (detId) ObjectExt.setByPath(others, 'attrs/detId', detId);
 | 
			
		||||
        if (processId) ObjectExt.setByPath(others, 'attrs/processId', processId);
 | 
			
		||||
        return others;
 | 
			
		||||
    }
 | 
			
		||||
})
 | 
			
		||||
@@ -23,10 +23,21 @@ export default {
 | 
			
		||||
	components: { ProcessInfo, ProcessDetail, ProcessBomList },
 | 
			
		||||
	props: {},
 | 
			
		||||
	data() {
 | 
			
		||||
		return {};
 | 
			
		||||
		return {
 | 
			
		||||
			flowId: null,
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
	provide() {
 | 
			
		||||
		const that = this;
 | 
			
		||||
		return {
 | 
			
		||||
			getFlowId() {
 | 
			
		||||
				return that.flowId;
 | 
			
		||||
			},
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
	activated() {
 | 
			
		||||
		console.log('activated...', this.$route.params);
 | 
			
		||||
		this.flowId = this.$route.params.id;
 | 
			
		||||
	},
 | 
			
		||||
	computed: {},
 | 
			
		||||
	methods: {},
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user