From 078f603f7686c274067028bd23032625e6eee3ce Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 12 六月 2024 14:54:48 +0800 Subject: [PATCH] 工厂登录 --- src/components/FlowChart/src/FlowChart.vue | 111 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 90 insertions(+), 21 deletions(-) diff --git a/src/components/FlowChart/src/FlowChart.vue b/src/components/FlowChart/src/FlowChart.vue index 318cc49..dde4080 100644 --- a/src/components/FlowChart/src/FlowChart.vue +++ b/src/components/FlowChart/src/FlowChart.vue @@ -6,6 +6,9 @@ @view-data="handlePreview" @save-data="handleSave" @add-data="handleAdd" + @addlf="handleAddlf" + @undo="handleUndo" + @redo="handleRedo" /> <div ref="lfElRef" class="h-full"></div> <BasicModal @register="register" title="娴佺▼鏁版嵁" width="50%"> @@ -33,6 +36,12 @@ import customEdge from './customEdge'; import { useMessage } from '/@/hooks/web/useMessage'; import { useI18n } from '/@/hooks/web/useI18n'; + import actionRect from './actionRect'; + import TestNode from './TestNode'; + import CollectNode from './CollectNode'; + import AssemblyNode from './AssemblyNode'; + import PackingNode from './PackingNode'; + import RepairNode from './RepairNode'; const { notification } = useMessage(); const { t } = useI18n(); @@ -59,7 +68,17 @@ type: Array, }, }, - setup(props) { + emits: [ + 'view-data', + 'save-data', + 'add-lf', + 'select-node', + 'click-blank', + 'init', + 'undo', + 'redo', + ], + setup(props, { emit }) { const globSetting = useGlobSetting(); const lfElRef = ref(null); const graphData = ref({}); @@ -143,6 +162,12 @@ }); const lf = unref(lfInstance)!; // lf?.setDefaultEdgeType('line'); + lf.register(actionRect); + lf.register(TestNode); + lf.register(CollectNode); + lf.register(AssemblyNode); + lf.register(PackingNode); + lf.register(RepairNode); onRender(); lf?.setPatternItems(props.patternItems || configDefaultDndPanel(lf)); } @@ -157,26 +182,41 @@ // const lFData = toLogicFlowData(props.data); lf.render(props.data); - if (globSetting.apiUrl == 'http://localhost:9528/api') { - lf.on('anchor:drop', (data) => { - const nodeData = data.nodeModel.getData(); - if (nodeData.properties.isReturn === true) { - data.nodeModel.graphModel.edges.forEach((element) => { - if (element.sourceNodeId === data.nodeModel.id) { - lf.changeEdgeType(element.id, 'custom-edge'); - } - }); - } - }); - } - lf.on('node:click,edge:click', (data) => { - console.log(data.data.text.value, data.isSelected); - notification.success({ - message: t('鐐瑰嚮浜嗚妭鐐�'), - description: `${data.data.text.value}: ${data.isSelected}`, - duration: 3, - }); + lf.on('anchor:drop', (data) => { + const nodeData = data.nodeModel.getData(); + if (nodeData.properties.isReturn === true) { + console.log(11, nodeData.properties.isReturn); + data.nodeModel.graphModel.edges.forEach((element) => { + if (element.sourceNodeId === data.nodeModel.id) { + lf.changeEdgeType(element.id, 'custom-edge'); + } + }); + } }); + lf.on('node:click,edge:click', (data) => { + if (data.isSelected) { + console.log(data.data.text.value, data.isSelected); + // notification.success({ + // message: t('鐐瑰嚮浜嗚妭鐐�'), + // description: `${data.data.text.value}: ${data.isSelected}`, + // duration: 3, + // }); + emit('select-node', data, lf); + } else { + console.log(data.data.type); + } + }); + + lf.on('blank:mousedown', (e) => { + emit('click-blank'); + }); + + lf.on('node:dnd-add', (data, e) => { + console.log('node:dnd-add', data); + emit('select-node', data, lf); + }); + + emit('init', lf); } function handlePreview() { @@ -189,11 +229,12 @@ } function handleSave() { - console.log('handleSave'); + // console.log('handleSave'); const lf = unref(lfInstance); if (!lf) { return; } + emit('save-data', lf); } function handleAdd() { @@ -206,6 +247,30 @@ lf.render({}); } + function handleAddlf() { + const lf = unref(lfInstance); + if (!lf) { + return; + } + emit('add-lf', lf); + } + + function handleUndo() { + const lf = unref(lfInstance); + if (!lf) { + return; + } + emit('undo', lf); + } + + function handleRedo() { + const lf = unref(lfInstance); + if (!lf) { + return; + } + emit('redo', lf); + } + onMounted(init); return { @@ -216,7 +281,11 @@ graphData, handleSave, handleAdd, + handleAddlf, + handleUndo, + handleRedo, }; }, }); </script> +./TestNode -- Gitblit v1.9.3