|
@@ -104,9 +104,9 @@ export default defineComponent({
|
|
|
item.left = !item.left
|
|
|
if (item.left) {
|
|
|
// 为true时添加定位
|
|
|
- const obj: any = useRect(e.target)
|
|
|
- obj.index = item.index
|
|
|
- state.selectItem[0] = obj
|
|
|
+ state.selectItem[0] = {
|
|
|
+ index: item.index
|
|
|
+ }
|
|
|
} else {
|
|
|
state.selectItem[0] = null
|
|
|
}
|
|
@@ -170,9 +170,9 @@ export default defineComponent({
|
|
|
|
|
|
if (item.right) {
|
|
|
// 为true时添加定位
|
|
|
- const obj: any = useRect(e.target)
|
|
|
- obj.index = item.index
|
|
|
- state.selectItem[1] = obj
|
|
|
+ state.selectItem[1] = {
|
|
|
+ index: item.index
|
|
|
+ }
|
|
|
} else {
|
|
|
state.selectItem[1] = null
|
|
|
}
|
|
@@ -218,14 +218,23 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description 计算连线坐标位置及左右关联编号
|
|
|
+ * @description 计算连线坐标位置及左右关联编号,每次计算坐标的时候都取元素最新位置定位
|
|
|
* @returns 连线的坐标
|
|
|
*/
|
|
|
const calcPoint = () => {
|
|
|
const canvasPostion = useRect(canvasRef.value)
|
|
|
- const firstPostion = state.selectItem[0]
|
|
|
- const secondPostion = state.selectItem[1]
|
|
|
-
|
|
|
+ const leftSectionItem = state.selectItem[0]
|
|
|
+ const firstPostion: any = useRect(
|
|
|
+ document.getElementById(leftSectionItem.index + '-left') as any
|
|
|
+ )
|
|
|
+ firstPostion.index = leftSectionItem.index
|
|
|
+ // console.log('🚀 ~ calcPoint ~ leftObj', leftObj)
|
|
|
+ const rightSectionItem = state.selectItem[1]
|
|
|
+ const secondPostion: any = useRect(
|
|
|
+ document.getElementById(rightSectionItem.index + '-right') as any
|
|
|
+ )
|
|
|
+ secondPostion.index = rightSectionItem.index
|
|
|
+ console.log(state.selectItem, firstPostion, secondPostion)
|
|
|
const startPoint = {
|
|
|
x: firstPostion.width,
|
|
|
y: firstPostion.top + firstPostion.height / 2 - canvasPostion.top
|