diff --git a/business-css/frontend/src/assets/x6/expansionandcontraction-left.png b/business-css/frontend/src/assets/x6/expansionandcontraction-left.png new file mode 100644 index 0000000..1bad476 Binary files /dev/null and b/business-css/frontend/src/assets/x6/expansionandcontraction-left.png differ diff --git a/business-css/frontend/src/assets/x6/expansionandcontraction-right.png b/business-css/frontend/src/assets/x6/expansionandcontraction-right.png new file mode 100644 index 0000000..f053759 Binary files /dev/null and b/business-css/frontend/src/assets/x6/expansionandcontraction-right.png differ diff --git a/business-css/frontend/src/components/antvx6/index.vue b/business-css/frontend/src/components/antvx6/index.vue index 217d70e..bf3e7ff 100644 --- a/business-css/frontend/src/components/antvx6/index.vue +++ b/business-css/frontend/src/components/antvx6/index.vue @@ -43,6 +43,7 @@ const props = defineProps({ const projectInfo:any = ref(props.projectInfo) // 项目信息 const isScenario = ref(false) //是否展示历史模拟场景 const isDisplay = ref(true) // 是否显示 +const isExpansionandcontraction = ref(false) // 是否显示展开收起按钮 // 为了协助代码演示 let graph: Graph let currentArrowStyle = 'single' // 默认单箭头 @@ -143,6 +144,20 @@ onMounted(() => { }, }, }, + interacting: function (cellView) { + // 获取当前节点的模型 + const cell = cellView.cell + // 判断节点是否为 'rect' 形状 + if (cell.shape === 'rect') { + // 如果是 'rect' 形状,则禁止节点移动 + return { nodeMovable: false } + } + // 其他形状的节点允许所有交互 + return true + } + // interacting: { + // nodeMovable: false, // 禁止所有节点移动 + // }, }) // #endregion @@ -151,7 +166,7 @@ onMounted(() => { .use( new Transform({ resizing: false, // 通过拖拽边缘调整节点大小 - rotating: true, // 允许旋转节点 + rotating: false, // 允许旋转节点 // scaling 不是 Transform 插件的有效配置项,已移除 }), ) @@ -237,7 +252,7 @@ onMounted(() => { ?.appendChild(stencil.container as HTMLElement) // 监听Graph中节点创建事件 - graph.on('node:added', (args) => { + graph.on('node:added', (args:any) => { console.log('节点已添加到画布', args) const { node } = args @@ -264,6 +279,9 @@ onMounted(() => { graph.removeNode(node) }, 100) } else { + if(node.store && node.store.data && node.store.data.shape === 'rect'){ + return + } // 设置固定大小 node.size(160, 160) // 去掉背景节点 @@ -349,6 +367,59 @@ onMounted(() => { } }) + + + + let startPoint:any = null // 矩形起点 + +// 监听鼠标按下事件:记录起点 +graph.on('blank:mousedown', (e) => { + startPoint = { x: e.x, y: e.y } +}) + +// 监听鼠标松开事件:绘制矩形 +graph.on('blank:mouseup', (e) => { + console.log('鼠标松开事件', e) + if (!startPoint) return + + + const endPoint = { x: e.x, y: e.y } + if(Math.abs(endPoint.x - startPoint.x) <20 && Math.abs(endPoint.y - startPoint.y) <20){ + return + } + const width = Math.abs(endPoint.x - startPoint.x) + const height = Math.abs(endPoint.y - startPoint.y) + const x = Math.min(startPoint.x, endPoint.x) + const y = Math.min(startPoint.y, endPoint.y) + + // 添加矩形节点(设置 zIndex 为 -1 确保在最底层) + graph.addNode({ + shape: 'rect', + x, + y, + width, + height, + zIndex: -1, // 关键:置于底层 + // interactive: false, // 禁用所有交互 + // selectable: false, // 明确禁止选中 + draggable: false, // 明确禁止移动 + interacting: { + nodeMovable: false, // 禁止所有节点移动 + }, + attrs: { + body: { + fill: 'transparent', + stroke: '#999', + strokeWidth: 1, + strokeDasharray: '5 5', // 设置虚线样式 + }, + }, + }) + + startPoint = null // 重置起点 +}) + + // 控制连接桩显示/隐藏 const showPorts = (ports: NodeListOf, show: boolean) => { for (let i = 0, len = ports.length; i < len; i += 1) { @@ -846,15 +917,15 @@ function handleClose() { -->
-
- 图标 +
+ 图标
{{ projectInfo.name }}
-
- 图标 +
+ 图标
-
- 图标 +
+ 图标
@@ -895,6 +966,20 @@ function handleClose() { 图标
+
+
+ +
+
+
+ +
+
+
样式
+
+
+ +
\ No newline at end of file diff --git a/business-css/frontend/src/views/business/project/index.vue b/business-css/frontend/src/views/business/project/index.vue index 248823f..95ab3a9 100644 --- a/business-css/frontend/src/views/business/project/index.vue +++ b/business-css/frontend/src/views/business/project/index.vue @@ -277,7 +277,7 @@ function closeAntvx6() { -
+