|
@@ -3,6 +3,7 @@
|
|
|
<div class="furniture-rotated-container" :style="rotatedContainerStyle">
|
|
|
<div class="furniture-wrapper">
|
|
|
<furnitureIcon :icon="localItem.type" :width="localItem.width" :height="localItem.length" />
|
|
|
+ <span class="text"> {{ idx + 1 }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -17,6 +18,7 @@ defineOptions({ name: 'EditableFurniture' })
|
|
|
|
|
|
interface Props {
|
|
|
item: FurnitureItem
|
|
|
+ idx: number
|
|
|
angle: number
|
|
|
coordinates: [number, number, number, number]
|
|
|
canvasSize?: number
|
|
@@ -118,33 +120,34 @@ const pixelPosition = reactive({ left: props.item.left ?? 0, top: props.item.top
|
|
|
const boundingBox = computed(() => calculateBoundingBox())
|
|
|
|
|
|
// 容器样式 - 基于边界框
|
|
|
-const containerStyle = computed(
|
|
|
- () =>
|
|
|
- ({
|
|
|
- position: 'absolute',
|
|
|
- left: `${pixelPosition.left}px`,
|
|
|
- top: `${pixelPosition.top}px`,
|
|
|
- width: `${boundingBox.value.width}px`,
|
|
|
- height: `${boundingBox.value.height}px`,
|
|
|
- pointerEvents: props.disabled ? 'none' : 'auto',
|
|
|
- zIndex: 100,
|
|
|
- cursor: 'move',
|
|
|
- }) as CSSProperties
|
|
|
-)
|
|
|
+const containerStyle = computed(() => {
|
|
|
+ const cssObj: CSSProperties = {
|
|
|
+ position: 'absolute',
|
|
|
+ left: `${pixelPosition.left}px`,
|
|
|
+ top: `${pixelPosition.top}px`,
|
|
|
+ width: `${boundingBox.value.width}px`,
|
|
|
+ height: `${boundingBox.value.height}px`,
|
|
|
+ pointerEvents: props.disabled ? 'none' : 'auto',
|
|
|
+ zIndex: 100,
|
|
|
+ }
|
|
|
+ console.log('💆♀️💆♀️💆♀️💆♀️ AAAAA containerStyle', cssObj)
|
|
|
+ return cssObj
|
|
|
+})
|
|
|
|
|
|
// 旋转容器样式 - 调整位置使左上角对齐
|
|
|
-const rotatedContainerStyle = computed(
|
|
|
- () =>
|
|
|
- ({
|
|
|
- position: 'absolute',
|
|
|
- left: `${-boundingBox.value.left}px`,
|
|
|
- top: `${-boundingBox.value.top}px`,
|
|
|
- width: `${localItem.width}px`,
|
|
|
- height: `${localItem.length}px`,
|
|
|
- transform: `rotate(${localItem.rotate}deg)`,
|
|
|
- transformOrigin: '0 0',
|
|
|
- }) as CSSProperties
|
|
|
-)
|
|
|
+const rotatedContainerStyle = computed(() => {
|
|
|
+ const cssObj: CSSProperties = {
|
|
|
+ position: 'absolute',
|
|
|
+ left: `${-boundingBox.value.left}px`,
|
|
|
+ top: `${-boundingBox.value.top}px`,
|
|
|
+ width: `${localItem.width}px`,
|
|
|
+ height: `${localItem.length}px`,
|
|
|
+ transform: `rotate(${localItem.rotate}deg)`,
|
|
|
+ transformOrigin: '0 0',
|
|
|
+ }
|
|
|
+ console.log('💆♀️💆♀️💆♀️💆♀️ BBBBB rotatedContainerStyle', cssObj)
|
|
|
+ return cssObj
|
|
|
+})
|
|
|
|
|
|
// 监听props变化
|
|
|
watch(
|
|
@@ -219,10 +222,15 @@ const initPixelPosition = () => {
|
|
|
props.angle
|
|
|
)
|
|
|
|
|
|
+ console.log('🌸🌸🌸回显的家具数据AAAA', props.angle, props.item, itemConvert, rotatedRect)
|
|
|
+
|
|
|
// === 3️⃣ 应用最终位置 ===
|
|
|
/* 90度和270度需要特殊处理,因为旋转后家具的中心位置会改变 */
|
|
|
- pixelPosition.left = props.angle === 90 ? rotatedRect.left + length / 2 : rotatedRect.left
|
|
|
- pixelPosition.top = props.angle === 270 ? rotatedRect.top - length / 2 : rotatedRect.top
|
|
|
+ // pixelPosition.left = props.angle === 90 ? rotatedRect.left + length / 2 : rotatedRect.left
|
|
|
+ // pixelPosition.top = props.angle === 270 ? rotatedRect.top - length / 2 : rotatedRect.top
|
|
|
+
|
|
|
+ pixelPosition.left = rotatedRect.left
|
|
|
+ pixelPosition.top = rotatedRect.top
|
|
|
|
|
|
// 同步像素位置到 localItem(方便 emit)
|
|
|
// localItem.left = rotatedRect.left
|
|
@@ -326,10 +334,20 @@ const startDrag = (e: MouseEvent) => {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
+ position: relative;
|
|
|
|
|
|
:deep(*) {
|
|
|
pointer-events: none;
|
|
|
}
|
|
|
+
|
|
|
+ .text {
|
|
|
+ font-size: 14px;
|
|
|
+ color: #f41313;
|
|
|
+ position: absolute;
|
|
|
+ top: 50%;
|
|
|
+ left: 50%;
|
|
|
+ transform: translate(-50%, -50%);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|