This commit is contained in:
limengnan 2026-01-15 17:27:26 +08:00
parent 2269796070
commit 80d707f992
4 changed files with 140 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

View File

@ -43,6 +43,7 @@ const props = defineProps({
const projectInfo:any = ref(props.projectInfo) // const projectInfo:any = ref(props.projectInfo) //
const isScenario = ref(false) // const isScenario = ref(false) //
const isDisplay = ref(true) // const isDisplay = ref(true) //
const isExpansionandcontraction = ref(false) //
// //
let graph: Graph let graph: Graph
let currentArrowStyle = 'single' // 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 // #endregion
@ -151,7 +166,7 @@ onMounted(() => {
.use( .use(
new Transform({ new Transform({
resizing: false, // resizing: false, //
rotating: true, // rotating: false, //
// scaling Transform // scaling Transform
}), }),
) )
@ -237,7 +252,7 @@ onMounted(() => {
?.appendChild(stencil.container as HTMLElement) ?.appendChild(stencil.container as HTMLElement)
// Graph // Graph
graph.on('node:added', (args) => { graph.on('node:added', (args:any) => {
console.log('节点已添加到画布', args) console.log('节点已添加到画布', args)
const { node } = args const { node } = args
@ -264,6 +279,9 @@ onMounted(() => {
graph.removeNode(node) graph.removeNode(node)
}, 100) }, 100)
} else { } else {
if(node.store && node.store.data && node.store.data.shape === 'rect'){
return
}
// //
node.size(160, 160) 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<SVGElement>, show: boolean) => { const showPorts = (ports: NodeListOf<SVGElement>, show: boolean) => {
for (let i = 0, len = ports.length; i < len; i += 1) { for (let i = 0, len = ports.length; i < len; i += 1) {
@ -846,15 +917,15 @@ function handleClose() {
</div> --> </div> -->
<div class="antvx6-header"> <div class="antvx6-header">
<div class="header-left-box"> <div class="header-left-box">
<div class="return-icon-box" @click="closeAntvx6"> <div class="return-icon-box" @click="closeAntvx6" title="返回工作台">
<img src="@/assets/x6/return.png" alt="图标" title="返回工作台" style="cursor: pointer;"> <img src="@/assets/x6/return.png" alt="图标" style="cursor: pointer;">
</div> </div>
<div class="project-name">{{ projectInfo.name }}</div> <div class="project-name">{{ projectInfo.name }}</div>
<div class="return-icon-box" @click="analysisAdd"> <div class="return-icon-box" @click="analysisAdd" title="新增模拟分析">
<img src="@/assets/x6/add.png" alt="图标" title="新增模拟分析" style="cursor: pointer;"> <img src="@/assets/x6/add.png" alt="图标" style="cursor: pointer;">
</div> </div>
<div class="return-icon-box" @click="simulationClick"> <div class="return-icon-box" @click="simulationClick" title="历史模拟分析">
<img src="@/assets/x6/history.png" alt="图标" title="历史模拟分析" style="cursor: pointer;"> <img src="@/assets/x6/history.png" alt="图标" style="cursor: pointer;">
</div> </div>
</div> </div>
<div class="header-content-box"> <div class="header-content-box">
@ -895,6 +966,20 @@ function handleClose() {
<img src="@/assets/x6/del.png" alt="图标" title="删除" style="cursor: pointer;" <img src="@/assets/x6/del.png" alt="图标" title="删除" style="cursor: pointer;"
@click="deleteNode"> @click="deleteNode">
</div> </div>
<div class="line-style-box">
<div class="expansionandcontraction-box" v-if="isExpansionandcontraction == false" @click="isExpansionandcontraction = true">
<img src="@/assets/x6/expansionandcontraction-left.png">
</div>
<div v-if="isExpansionandcontraction == true" style="display: flex;align-items: center;">
<div class="expansionandcontraction-box" @click="isExpansionandcontraction = false">
<img src="@/assets/x6/expansionandcontraction-right.png">
</div>
<div class="style-content-box">
<div class="style-content-box-title">样式</div>
</div>
</div>
</div>
</div> </div>
<Createscenario v-if="dialogVisible" :projectInfo="projectInfo" @closeCreatescenario ="closeCreatescenario"/> <Createscenario v-if="dialogVisible" :projectInfo="projectInfo" @closeCreatescenario ="closeCreatescenario"/>
<el-dialog v-model="isScenario" :close-on-click-modal="false" <el-dialog v-model="isScenario" :close-on-click-modal="false"
@ -1136,4 +1221,50 @@ function handleClose() {
text-align: center; text-align: center;
padding-top: 5px; padding-top: 5px;
} }
.line-style-box{
position: absolute;
right: 0;
height: 100%;
/* width: 100px; */
/* background-color: #d9d9d9; */
z-index: 10;
display: flex;
align-items: center;
}
.expansionandcontraction-box{
width:15px;
height: 64px;
background-color: #ffffff;
border: 1px solid #cfcfcf;
border-radius: 10px 0 0 10px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.style-content-box{
width: 300px;
height: calc(100vh - 60px);
border: 1px solid #cfcfcf;
border-top: none;
border-right: none;
background: #fff;
}
.style-content-box-title{
width: 100%;
height: 40px;
line-height: 40px;
text-align: left;
font-size: 14px;
font-family: 'Arial Negreta', 'Arial Normal', 'Arial';
font-weight: 700;
font-style: normal;
font-size: 14px;
color: #282828;
background-color: rgba(255, 255, 255, 1);
box-sizing: border-box;
border-bottom:1px solid rgba(238, 238, 238, 1);
padding-left: 15px;
}
</style> </style>

View File

@ -277,7 +277,7 @@ function closeAntvx6() {
<ScenarioModel v-if="isScenario" :projectInfo="info" ref="Scenario" /> <ScenarioModel v-if="isScenario" :projectInfo="info" ref="Scenario" />
</el-dialog> </el-dialog>
<div v-if="isShowAntvx6" style="position: fixed;top: 0px;left: 10px; width: 100vw;height: 100vh;background-color: #fff;z-index: 100;"> <div v-if="isShowAntvx6" style="position: fixed;top: 0px;left: 0px; width: 100vw;height: 100vh;background-color: #fff;z-index: 100;">
<Antvx6 ref="antvx6" v-if="isShowAntvx6" :projectInfo="info" @closeAntvx6="closeAntvx6"/> <Antvx6 ref="antvx6" v-if="isShowAntvx6" :projectInfo="info" @closeAntvx6="closeAntvx6"/>
</div> </div>
</div> </div>