|
@@ -2,7 +2,7 @@
|
|
<div
|
|
<div
|
|
class="editable-furniture"
|
|
class="editable-furniture"
|
|
:style="{
|
|
:style="{
|
|
- position: 'relative',
|
|
|
|
|
|
+ position: 'absolute',
|
|
left: `${centerCss.left}px`,
|
|
left: `${centerCss.left}px`,
|
|
top: `${centerCss.top}px`,
|
|
top: `${centerCss.top}px`,
|
|
zIndex: 10,
|
|
zIndex: 10,
|
|
@@ -34,11 +34,6 @@
|
|
<div class="capsule" @mousedown.prevent="startPanelDrag"></div>
|
|
<div class="capsule" @mousedown.prevent="startPanelDrag"></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <!-- <div class="panel-item">
|
|
|
|
- <label>家具名称:</label>
|
|
|
|
- <a-input v-model:value="localItem.name" size="small" />
|
|
|
|
- </div> -->
|
|
|
|
-
|
|
|
|
<div class="panel-item">
|
|
<div class="panel-item">
|
|
<label>家具尺寸:</label>
|
|
<label>家具尺寸:</label>
|
|
<a-space>
|
|
<a-space>
|
|
@@ -149,8 +144,6 @@ watch(
|
|
() => props.item,
|
|
() => props.item,
|
|
(next) => {
|
|
(next) => {
|
|
if (!next) return
|
|
if (!next) return
|
|
-
|
|
|
|
- // 显式解构预期要合并的字段
|
|
|
|
const { x, y, width, length, rotate, name, type, nanoid, left, top } = next as Partial<UIItem>
|
|
const { x, y, width, length, rotate, name, type, nanoid, left, top } = next as Partial<UIItem>
|
|
|
|
|
|
if (x !== undefined) localItem.x = x
|
|
if (x !== undefined) localItem.x = x
|
|
@@ -163,6 +156,8 @@ watch(
|
|
if (nanoid !== undefined) localItem.nanoid = nanoid
|
|
if (nanoid !== undefined) localItem.nanoid = nanoid
|
|
if (left !== undefined) localItem.left = left
|
|
if (left !== undefined) localItem.left = left
|
|
if (top !== undefined) localItem.top = top
|
|
if (top !== undefined) localItem.top = top
|
|
|
|
+
|
|
|
|
+ updateXYFromCss()
|
|
},
|
|
},
|
|
{ deep: true }
|
|
{ deep: true }
|
|
)
|
|
)
|
|
@@ -286,7 +281,6 @@ function setPanelInitialPosition() {
|
|
}
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- // 使用父组件传入的业务左上角(若有)
|
|
|
|
localItem.x = props.item.x ?? localItem.x
|
|
localItem.x = props.item.x ?? localItem.x
|
|
localItem.y = props.item.y ?? localItem.y
|
|
localItem.y = props.item.y ?? localItem.y
|
|
;({ x: localItem.x, y: localItem.y } = normXY(localItem.x!, localItem.y!))
|
|
;({ x: localItem.x, y: localItem.y } = normXY(localItem.x!, localItem.y!))
|
|
@@ -296,12 +290,26 @@ onMounted(() => {
|
|
localItem.y = 0
|
|
localItem.y = 0
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const hasLeftTopFromProps =
|
|
|
|
+ (props.item as Partial<UIItem>).left !== undefined &&
|
|
|
|
+ (props.item as Partial<UIItem>).top !== undefined
|
|
|
|
+
|
|
nextTick()
|
|
nextTick()
|
|
.then(() => new Promise<void>((r) => requestAnimationFrame(() => r())))
|
|
.then(() => new Promise<void>((r) => requestAnimationFrame(() => r())))
|
|
- .then(() => updateCssFromXY())
|
|
|
|
|
|
+ .then(() => {
|
|
|
|
+ if (!hasLeftTopFromProps || props.initialAtOrigin) {
|
|
|
|
+ updateCssFromXY()
|
|
|
|
+ } else {
|
|
|
|
+ localItem.left = (props.item as Partial<UIItem>).left!
|
|
|
|
+ localItem.top = (props.item as Partial<UIItem>).top!
|
|
|
|
+ centerCss.left = localItem.left + (localItem.width ?? 0) / 2
|
|
|
|
+ centerCss.top = localItem.top + (localItem.length ?? 0) / 2
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updateXYFromCss()
|
|
|
|
+ })
|
|
.then(() => {
|
|
.then(() => {
|
|
setPanelInitialPosition()
|
|
setPanelInitialPosition()
|
|
- // emit initial state with left/top populated
|
|
|
|
emit('update', { ...localItem })
|
|
emit('update', { ...localItem })
|
|
})
|
|
})
|
|
})
|
|
})
|