Files
aida_front/src/component/Detail/model/modelPosition.vue

850 lines
41 KiB
Vue
Raw Normal View History

2025-01-24 13:41:13 +08:00
<template>
2025-02-25 15:32:55 +08:00
<div class="molepositon" :class="{active:!imgDesignImg}">
2025-04-09 14:09:19 +08:00
<div class="designOpenrtion_imgMask" v-if="frontBack?.body?.path" :style="frontBack?.body?.style">
<div class="designOpenrtion_print" v-for="item,index in frontBack.back" :style="frontBack.front[index].style">
2025-01-24 13:41:13 +08:00
<img :style="item.imageUrl?'':'display:none;'" :src="item.imageUrl" alt="">
</div>
<img class="perview_img" @load="setPrintSize()" ref="detailBody" :key="designDetail.designItemId" :src="frontBack?.body?.path" :style="'width:'+ frontBack?.body?.layersObject?.[0].imageSize?.[0] +';height:' + frontBack?.body?.layersObject?.[0].imageSize?.[0] +';'">
<!-- <div class="detail_modal_item_front" ref="target" v-for="item,index in frontBack.front" @mousedown.stop="itemMoveMousedown(index,getMousePosition($event,false))" @touchstart.passive="itemMoveMousedown(index,getMousePosition($event,true))" @click="setpitch(item,index)" :style="item.style">
<img :src="item.imageUrl" alt="">
</div> -->
2026-02-02 10:31:37 +08:00
<div class="detail_modal_item_front" :ref="el => { setElementRef(el, index) }" v-for="item,index in frontBack.front" :class="{'active':item.id == selectDetail?.id}" :style="{...item.style,transform:`rotate(${getTransformValues(item.style.transform)?.rotate}deg) scaleX(1) scaleY(1)`}">
<img :src="item.imageUrl" alt="" :style="{transform:`scaleX(${getTransformValues(item.style.transform).scaleX}) scaleY(${getTransformValues(item.style.transform).scaleY})`}">
2025-01-24 13:41:13 +08:00
</div>
<div ref="moveableContainer" class="moveableContainer"></div>
2025-01-24 13:41:13 +08:00
</div>
2025-09-03 16:36:06 +08:00
<div class="designOpenrtion_imgMask" v-if="!frontBack?.body?.path">
<div class="designOpenrtion_print">
<img v-if="frontBack.back?.[0].imageUrl" :src="frontBack.back?.[0].imageUrl" style="object-fit: cover;" alt="">
</div>
<div class="detail_modal_item_front" style="position: relative;">
<img :src="frontBack.front?.[0].imageUrl || selectDetail?.path" style="object-fit: cover;" alt="">
</div>
2025-09-08 14:50:59 +08:00
<!-- <img @load="setSelectSketch()" :src="designDetail?.currentFullBodyView || selectDetail?.undividedLayer" style="object-fit: cover;" alt=""> -->
2025-02-17 09:34:28 +08:00
</div>
2025-01-24 13:41:13 +08:00
</div>
2025-09-08 14:50:59 +08:00
<div class="molepositon imgDesignImg" :class="{active:imgDesignImg}">
<div class="designOpenrtion_imgMask" style="width: 100%;height: 100%;">
2025-02-25 15:32:55 +08:00
<div class="detail_modal_item_front">
<img
style="object-fit: cover;"
2026-01-23 16:06:47 +08:00
:style="observerWH.width > 0?{width:observerWH.width+'px',height:observerWH.height+'px'}:{width:'100%',height:'auto','object-fit': 'contain'}"
:src="designDetail.designItemUrl" alt="">
2025-02-25 15:32:55 +08:00
</div>
</div>
</div>
2025-01-24 13:41:13 +08:00
</template>
<script lang="ts">
import { defineComponent,computed,inject,watch,nextTick,createVNode,toRefs, reactive, onUnmounted} from 'vue'
2025-01-24 13:41:13 +08:00
// import setDesignItem from '@/component/Detail/setDesignItem2.vue'
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { Https } from "@/tool/https";
import { useStore } from "vuex";
import { useI18n } from 'vue-i18n'
import { getMousePosition } from "@/tool/mdEvent";
import { KeyValueDB } from "@/tool/indexedDB";
import Vue3Moveable from 'vue3-moveable';
import Moveable from 'moveable';
import { parse } from 'vue/compiler-sfc';
import { scale } from 'echarts/types/src/scale/helper.js';
2025-01-24 13:41:13 +08:00
export default defineComponent({
components:{
},
2025-02-25 15:32:55 +08:00
props:{
imgDesignImg:{
default:false,
type:Boolean,
}
},
2026-01-15 17:14:11 +08:00
emits:['addSketch'],
2025-01-24 13:41:13 +08:00
setup(props,{emit}) {
2025-03-03 14:52:05 +08:00
const {t} = useI18n()
2025-01-24 13:41:13 +08:00
const store = useStore();
const detailData = reactive({
2025-08-22 10:27:48 +08:00
frontBack:computed(()=>store.state.DesignDetail.frontBack),
designDetail:computed(()=>store.state.DesignDetail.designDetail),
2025-09-08 14:50:59 +08:00
selectDetail:computed(()=>store.state.DesignDetail.selectDetail),
2025-04-01 15:25:15 +08:00
isEditPattern:inject('isEditPattern') as any,
2025-06-03 14:57:18 +08:00
singleOveral:inject('singleOveral') as any,
detailBody:null as any,
observer:null as any,
observerWH:{
width:0,
height:0,
},
2025-02-17 09:34:28 +08:00
})
const selectItem = reactive({
2025-08-22 10:27:48 +08:00
selectDetail:computed(()=>store.state.DesignDetail.selectDetail),
2025-02-17 09:34:28 +08:00
imgDomIndex:-1,
2025-08-22 10:27:48 +08:00
printZIndex:store.state.DesignDetail.printZIndex,
2025-02-17 09:34:28 +08:00
imgDom:null as any,
direction:'',
})
2025-06-03 14:57:18 +08:00
watch(()=>detailData.frontBack?.body?.path,(newVal)=>{
2025-09-03 16:36:06 +08:00
setPrintSize()
})
const setPrintSize = ()=>{
nextTick(()=>{
let sacle = 0
const img = new Image();
let dom = document.querySelector('.molepositon .perview_img') as any
if(!detailData.frontBack?.body?.path || !dom)return
img.onload = () => {
//监听模特图片宽度设置整体图片宽度
if (detailData.observer) {
detailData.observer.disconnect()
}
detailData.observerWH.width = dom.width
detailData.observerWH.height = dom.height
detailData.observer = new ResizeObserver((entries) => {
if(entries[0].contentRect.width == 0)return
detailData.observerWH.width = Math.floor(entries[0].contentRect.width)
detailData.observerWH.height = Math.floor(entries[0].contentRect.height)
})
detailData.observer.observe(dom)
if(detailData.designDetail.clothes.length == 0){
store.commit('DesignDetail/addDesignColthes')
emit('addSketch')
return
}
2025-09-08 14:50:59 +08:00
if(!detailData.selectDetail?.id){
let item = detailData.designDetail.clothes.reduce((max, current) => {
return current.priority > max.priority ? current : max;
});
store.commit('DesignDetail/setDesignColthes',item.id)
2025-09-08 14:50:59 +08:00
}
2025-09-03 16:36:06 +08:00
// resolve(img)
sacle = dom.parentNode.offsetWidth / img.width
detailData.frontBack.front.forEach((item:any,index:number) => {
for (const key in item.style) {
if(key == 'zIndex')return
let value = item.style[key]
if(typeof value !== 'number'){
value = value.replace('px','')
item.style[key] = value
}else{
item.style[key] = value*sacle+'px'
}
// item.style[key] = value*sacle+'px'
2025-06-03 14:57:18 +08:00
}
2025-09-03 16:36:06 +08:00
for (const key in detailData.frontBack.back[index].style) {
if(key == 'zIndex')return
if(key == 'transform')return
2025-09-03 16:36:06 +08:00
let value = detailData.frontBack.back[index].style[key]
if(typeof value !== 'number'){
value = value.replace('px','')
detailData.frontBack.back[index].style[key] = value
}else{
detailData.frontBack.back[index].style[key] = value*sacle+'px'
}
// detailData.frontBack.back[index].style[key] = value*sacle+'px'
2025-06-03 14:57:18 +08:00
}
2025-09-03 16:36:06 +08:00
});
2025-09-29 14:13:24 +08:00
setTimeout(() => {
initMoveableForSelected()
},500);
2025-09-03 16:36:06 +08:00
};
img.src = detailData.frontBack?.body?.path;
})
}
2025-01-24 13:41:13 +08:00
const getDetailListDom = reactive({
libraryList:null as any,
moveableContainer:null as any,//控件层
2025-01-24 13:41:13 +08:00
})
const elementRefs = ref([]) as any;
const moveableInstance = ref(null) as any;
const setElementRef = (el, index) => {
elementRefs.value[index] = el;
};
const updateRect = ()=>{
setTimeout(() => {
if(moveableInstance.value)moveableInstance.value.updateRect()
}, 200);
}
2026-02-02 10:31:37 +08:00
function getTransformValues(transformStr) {
let scaleX = 1;
let scaleY = 1;
let rotate = 0;
if (!transformStr || transformStr === 'none') {
return { scaleX, scaleY, rotate };
}
const scaleXMatch = transformStr.match(/scaleX\(([-\d.]+)\)/);
if (scaleXMatch) {
scaleX = parseFloat(scaleXMatch[1]);
}
const scaleYMatch = transformStr.match(/scaleY\(([-\d.]+)\)/);
if (scaleYMatch) {
scaleY = parseFloat(scaleYMatch[1]);
}
const rotateMatch = transformStr.match(/rotate\(([-\d.]+)(deg|rad)?\)/);
if (rotateMatch) {
rotate = parseFloat(rotateMatch[1]);
if (rotateMatch[2] === 'rad') {
rotate = rotate * (180 / Math.PI);
}
}
return { scaleX, scaleY, rotate };
}
const initMoveableForSelected = () => {
// 销毁旧的实例
if(selectItem.imgDomIndex == -1)return
if (moveableInstance.value) {
moveableInstance.value.destroy();
2025-02-17 09:34:28 +08:00
}
2025-01-24 13:41:13 +08:00
const selectedEl = elementRefs.value[selectItem.imgDomIndex];
if (!selectedEl) return;
if(!selectedEl.style.left)return
moveableInstance.value = new Moveable(getDetailListDom.moveableContainer, {
target: selectedEl,
draggable: true,
scalable: true,
rotatable: true,
keepRatio: false, // 等比缩放
snappable: true,
snapThreshold: 5,
edge: false,
});
2026-02-02 10:31:37 +08:00
const createCustomButtons = () => {
const flipX = document.createElement('div');
const flipY = document.createElement('div');
flipX.className = 'custom-btn';
flipX.innerHTML = `
<svg class="btn flip-x" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<mask id="mask0_2641_12523" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="-1" width="24" height="25">
<rect y="-0.00044632" width="23.3511" height="23.3511" fill="url(#pattern0_2641_12523)"/>
</mask>
<g mask="url(#mask0_2641_12523)">
<rect x="2.92188" y="2.91752" width="17.5133" height="17.5133" fill="#0090FF"/>
</g>
<defs>
<pattern id="pattern0_2641_12523" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0_2641_12523" transform="scale(0.005)"/>
</pattern>
<image id="image0_2641_12523" width="200" height="200" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAPOklEQVR4AeydeWwmZR3H2y4ab0Tl9ARta9YDERWjxAMFRMB4gSiXCyoCQkBZVgQCch8riAgoAi6Xwm5iPBKMKNHERNGEaFDTbUuCJqAhGOOBiX+4Wz4/2ul2u+87z9zzHN/N79dnZp77+5vPzDztvvOOjeifFJACQxUQIEOlUYYUGBkRIDoLpECOAgIkRxxlSQEBonNACuQo0CIgOb0qSwoEooAACSRQGmY/CgiQfnRXr4EoIEACCZSG2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5EZA2Ol5O6THAMUAhITmXhfs2ArKQOxQjI3kTQHquKvGFdcCDWMGPhfhoL968Oy0/heGyA7EXQ7M6xO6nLBIdLIfJZuJ9OcjXei/XdaUyA2NvN7c7xygKiCo4CImVFeNz6PNtfwZOzWACxN5vbneNVBSIoOAqItLwIkJzBmmTt8uOx78cAiH3lmMExUSBYgqOASMOKsCZZzZrkimH5MR73DZBHc0ReOSDvtRyzx6pJUpcJDpdCBfJZk6wBkssLFK1a5MGqFduo5xsgv8mZ5GHkLf1imuzvHK/muMsEh0uhEvlAYt+FaC+oK1GrWFHgs7dDFitcr1Sh2r4B8jvHqH9OvvnPSA2mQXcVsrYywbGVHM3ssCY5i5YuwRs11jmzjTZYszHfAPljgfnYXcQ+R16g6IjgKKJSxTJAcjYn9
</defs>
</svg>
`;
flipY.className = 'custom-btn';
flipY.innerHTML = `
<svg class="btn flip-y" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<mask id="mask0_2641_12520" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="-1" y="-1" width="25" height="25">
<rect width="23.3511" height="23.3511" transform="matrix(0 -1 -1 0 23.3511 23.3511)" fill="url(#pattern0_2641_12520)"/>
</mask>
<g mask="url(#mask0_2641_12520)">
<rect width="17.5133" height="17.5133" transform="matrix(0 -1 -1 0 20.4292 20.4331)" fill="#0090FF"/>
</g>
<defs>
<pattern id="pattern0_2641_12520" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0_2641_12520" transform="scale(0.005)"/>
</pattern>
<image id="image0_2641_12520" width="200" height="200" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAPOklEQVR4AeydeWwmZR3H2y4ab0Tl9ARta9YDERWjxAMFRMB4gSiXCyoCQkBZVgQCch8riAgoAi6Xwm5iPBKMKNHERNGEaFDTbUuCJqAhGOOBiX+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rqQuSwqOTAwW7ieycL8h21c6r0AKgLyVqRocLyZ1WZJwZKKwcD+J7evxchZx6dgB2YfY2WPVS0hdljQcmTg8bp3M9tdxGQrEDMhbmJ/dOV5K6jLBsUQhIDmF3Wvx5C1WQN5EZA2Ol5O6THAMUAhITmXhfs2ArKQOxQjI3kTQHquKvGFdcCDWMGPhfhoL968Oy0/heGyA7EXQ7M6xO6nLBIdLIfJZuJ9OcjXei/XdaUyA2NvN7c7xygKiCo4CImVFeNz6PNtfwZOzWACxN5vbneNVBSIoOAqItLwIkJzBmmTt8uOx78cAiH3lmMExUSBYgqOASMOKsCZZzZrkimH5MR73DZBHc0ReOSDvtRyzx6pJUpcJDpdCBfJZk6wBkssLFK1a5MGqFduo5xsgv8mZ5GHkLf1imuzvHK/muMsEh0uhEvlAYt+FaC+oK1GrWFHgs7dDFitcr1Sh2r4B8jvHqH9OvvnPSA2mQXcVsrYywbGVHM3ssCY5i5YuwRs11jmzjTZYszHfAPljgfnYXcQ+R16g6IjgKKJSxTJAcjYn9
</defs>
</svg>
`;
let moveableControlBox = getDetailListDom.moveableContainer.querySelector('.moveable-control-box')
// 添加到 Moveable 容器或目标元素
moveableControlBox.appendChild(flipX);
moveableControlBox.appendChild(flipY);
// 绑定事件
moveableControlBox.addEventListener('click', (e:any) => {
e.stopPropagation();
const btn = e.target.closest('.btn');
if (!btn) return;
handleCustomButtonClick(btn.className?.animVal);
});
};
const handleCustomButtonClick = (btnClass:any) => {
const frontStyle = detailData.frontBack.front[selectItem.imgDomIndex];
let transform = getTransformValues(frontStyle.style.transform)
switch (btnClass) {
case 'btn flip-x':
transform.scaleX = transform.scaleX == -1?1:-1
frontStyle.style.transform = `rotate(${transform.rotate}deg) scaleX(${transform.scaleX}) scaleY(${transform.scaleY})`;
break;
case 'btn flip-y':
transform.scaleY = transform.scaleY == -1?1:-1
frontStyle.style.transform = `rotate(${transform.rotate}deg) scaleX(${transform.scaleX}) scaleY(${transform.scaleY})`;
break;
}
};
const updateTransform = () => {
let leftClass = '.moveable-control-box .moveable-w'
let bottomClass = '.moveable-control-box .moveable-s'
const frontStyle = detailData.frontBack.front[selectItem.imgDomIndex];
let transform = getTransformValues(frontStyle.style.transform)
// leftClass = transform.scaleX == -1?'.moveable-control-box .moveable-e':leftClass
// bottomClass = transform.scaleY == -1?'.moveable-control-box .moveable-n':bottomClass
let customFlipX = getDetailListDom.moveableContainer.querySelector('.moveable-control-box .flip-x')
let customFlipY = getDetailListDom.moveableContainer.querySelector('.moveable-control-box .flip-y')
let leftBorder = getDetailListDom.moveableContainer.querySelector(leftClass)
let bottomBorder = getDetailListDom.moveableContainer.querySelector(bottomClass)
customFlipX.parentNode.style.transform = leftBorder.style.transform
customFlipY.parentNode.style.transform = bottomBorder.style.transform
}
createCustomButtons()
updateTransform()
let startPosition = {//记录初始位置
left: 0,
top: 0,
2025-02-17 09:34:28 +08:00
}
2026-01-29 17:16:31 +08:00
let startSize = {//记录初始缩放比例
width: 0,
height: 0,
}
moveableInstance.value.on('scaleStart', ({ target, direction }) => {
const frontStyle = detailData.frontBack.front[selectItem.imgDomIndex];
2026-02-02 10:31:37 +08:00
// let scaleX = frontStyle.style.transform.match(/scaleX\(([-\d.]+)\)/);
// let scaleY = frontStyle.style.transform.match(/scaleY\(([-\d.]+)\)/);
let scaleX = ['1','1']
let scaleY = ['1','1']
frontStyle.mirror = { x: scaleX[1] == '-1' ? true : false, y: scaleY[1] == '-1' ? true : false };
2026-01-29 17:16:31 +08:00
startSize.width = Number(parseInt(target.style.width))
startSize.height = Number(parseInt(target.style.height))
startPosition.left = Number(parseInt(target.style.left))
startPosition.top = Number(parseInt(target.style.top))
});
moveableInstance.value.on('rotateStart', ({ target, direction }) => {
const frontStyle = detailData.frontBack.front[selectItem.imgDomIndex];
2026-02-02 10:31:37 +08:00
// let scaleX = frontStyle.style.transform.match(/scaleX\(([-\d.]+)\)/);
// let scaleY = frontStyle.style.transform.match(/scaleY\(([-\d.]+)\)/);
let scaleX = ['1','1']
let scaleY = ['1','1']
frontStyle.mirror = { x: scaleX[1] == '-1' ? true : false, y: scaleY[1] == '-1' ? true : false };
});
moveableInstance.value.on('dragStart', ({ target, clientX, clientY }) => {
startPosition = {
left:parseFloat(selectedEl.style.left.replace('px','')) || 0,
top:parseFloat(selectedEl.style.top.replace('px','')) || 0,
}
});
2026-01-29 14:10:55 +08:00
// 拖拽
moveableInstance.value.on('drag', ({ target, beforeTranslate }) => {
let x = startPosition.left + beforeTranslate[0]
let y = startPosition.top + beforeTranslate[1]
detailData.frontBack.front[selectItem.imgDomIndex].style.left = x + 'px'
detailData.frontBack.front[selectItem.imgDomIndex].style.top = y + 'px'
});
const updateElementTransform = (element, rotateDeg = null) => {
const currentTransform = element.style?.transform || '';
const currentRotates = (currentTransform.match(/rotate[XYZ]?\([^)]+\)/g) || []);
2026-02-02 10:31:37 +08:00
const scaleXMatch = currentTransform.match(/scaleX\(([^)]+)\)/);
const scaleYMatch = currentTransform.match(/scaleY\(([^)]+)\)/);
// 移除所有需要单独处理的变换
let otherTransforms = currentTransform
2026-01-28 17:11:28 +08:00
.replace(/rotate[XYZ]?\([^)]+\)/g, '')
2026-02-02 10:31:37 +08:00
.replace(/scaleX\([^)]+\)/g, '')
.replace(/scaleY\([^)]+\)/g, '')
.replace(/\s+/g, ' ')
.trim();
2026-01-28 17:11:28 +08:00
const transforms = [];
2026-02-02 10:31:37 +08:00
// 处理旋转
if (rotateDeg !== null) {
transforms.push(`rotate(${rotateDeg}deg)`);
} else if (currentRotates.length > 0) {
transforms.push(...currentRotates);
}
2026-02-02 10:31:37 +08:00
// 处理scaleX
if (element.mirror && element.mirror.x) {
transforms.push('scaleX(-1)');
} else if (scaleXMatch) {
// 保留原有的scaleX
transforms.push(`scaleX(${scaleXMatch[1]})`);
}
// 处理scaleY
if (element.mirror && element.mirror.y) {
transforms.push('scaleY(-1)');
} else if (scaleYMatch) {
// 保留原有的scaleY
transforms.push(`scaleY(${scaleYMatch[1]})`);
}
// 添加其他变换
if (otherTransforms) {
transforms.push(otherTransforms);
}
2026-01-28 17:11:28 +08:00
element.style.transform = transforms.join(' ').trim();
};
2026-01-29 17:16:31 +08:00
moveableInstance.value.on('scale', (e) => {
var { target, delta, direction, dist} = e
// console.log('scaleStart', e);
const frontStyle = detailData.frontBack.front[selectItem.imgDomIndex];
2026-01-28 16:11:55 +08:00
2026-01-28 17:11:28 +08:00
// 清除可能存在的重复镜像变换
2026-02-02 10:31:37 +08:00
// updateElementTransform(frontStyle);
2026-01-28 17:11:28 +08:00
2026-01-29 17:16:31 +08:00
let width = startSize.width
let height = startSize.height
let left = startPosition.left;
let top = startPosition.top;
let rotation = 0;
2026-01-28 17:11:28 +08:00
const originalRatio = width / height;
if (frontStyle.style.transform) {
2026-01-28 17:11:28 +08:00
const match = frontStyle.style.transform.match(/rotate\(([-\d.]+)deg\)/);
if (match) rotation = parseFloat(match[1]);
}
const isDiagonal = Math.abs(direction[0]) === 1 && Math.abs(direction[1]) === 1;
2026-01-28 16:11:55 +08:00
2026-01-29 17:16:31 +08:00
const processAxis = (axis, val, distVal, dir, pos, keepRatio = false, otherAxisResult = null) => {
const mirrorKey = axis === 'width' ? 'x' : 'y';
const isWidth = axis === 'width';
2026-01-28 16:11:55 +08:00
2026-01-29 17:16:31 +08:00
let newVal = val * distVal;
2026-02-02 10:31:37 +08:00
2026-01-29 17:16:31 +08:00
if(newVal < 10) newVal = 10;
2026-01-28 17:11:28 +08:00
// 位置调整
const shouldMove = (!frontStyle.mirror[mirrorKey] && dir === -1) || (frontStyle.mirror[mirrorKey] && dir === 1);
// 保持宽高比
const adjustPos = shouldMove ? pos - (newVal - val) : pos;
return { newVal, adjustPos };
};
2026-01-28 17:11:28 +08:00
// 处理缩放
if (isDiagonal) {
2026-01-29 17:16:31 +08:00
const scale = (dist[0] < 0 && dist[1] < 0) ? -Math.sqrt(dist[0] * dist[1]) : Math.sqrt(dist[0] * dist[1]);
const widthResult = processAxis('width', width, scale, direction[0], left);
const heightResult = processAxis('height', height, scale, direction[1], top);
frontStyle.style.width = widthResult.newVal + 'px';
frontStyle.style.height = heightResult.newVal + 'px';
frontStyle.style.left = widthResult.adjustPos + 'px';
frontStyle.style.top = heightResult.adjustPos + 'px';
2026-01-28 17:11:28 +08:00
} else {
2026-01-29 17:16:31 +08:00
const widthResult = processAxis('width', width, dist[0], direction[0], left);
const heightResult = processAxis('height', height, dist[1], direction[1], top);
2026-01-28 16:11:55 +08:00
frontStyle.style.left = widthResult.adjustPos + 'px';
frontStyle.style.top = heightResult.adjustPos + 'px';
frontStyle.style.width = widthResult.newVal + 'px';
frontStyle.style.height = heightResult.newVal + 'px';
2026-01-28 17:11:28 +08:00
}
// 更新变换,确保正确的顺序
updateElementTransform(frontStyle);
2026-02-02 10:31:37 +08:00
//更新自定义按钮
updateTransform()
});
moveableInstance.value.on('rotate', ({ target, beforeRotate }) => {
let frontStyle = detailData.frontBack.front[selectItem.imgDomIndex];
2026-02-02 10:31:37 +08:00
// 获取当前旋转角度
2026-01-28 16:11:55 +08:00
const currentTransform = frontStyle.style?.transform || '';
const rotateMatch = currentTransform.match(/rotate\(([-\d.]+)deg\)/);
let currentAngle = 0;
if (rotateMatch && rotateMatch[1]) {
const parsed = parseFloat(rotateMatch[1]);
if (!isNaN(parsed)) {
currentAngle = parsed;
}
}
2026-02-02 10:31:37 +08:00
// 计算新角度
2026-01-28 16:11:55 +08:00
const newBeforeRotate = parseFloat(beforeRotate) || 0;
if (!window._lastRotateData) {
window._lastRotateData = {
beforeRotate: newBeforeRotate,
angle: currentAngle
};
}
2026-01-28 16:11:55 +08:00
const delta = newBeforeRotate - window._lastRotateData.beforeRotate;
2026-02-02 10:31:37 +08:00
let newAngle = window._lastRotateData.angle + delta;
// 规范化角度到 0-360 范围
2026-01-28 16:11:55 +08:00
newAngle = ((newAngle % 360) + 360) % 360;
2026-02-02 10:31:37 +08:00
2026-01-28 16:11:55 +08:00
window._lastRotateData.beforeRotate = newBeforeRotate;
window._lastRotateData.angle = newAngle;
2026-02-02 10:31:37 +08:00
// 更新元素变换
2026-01-28 16:11:55 +08:00
updateElementTransform(frontStyle, newAngle);
2026-02-02 10:31:37 +08:00
// 更新自定义按钮
updateTransform();
2026-01-28 16:11:55 +08:00
});
2026-01-28 17:11:28 +08:00
// 可选在rotateStart时重置
moveableInstance.value.on('rotateStart', () => {
window._lastRotateData = null;
});
// 调整大小
moveableInstance.value.on('resize', ({ target, width, height }) => {
// console.log(width, height)
// detailData.frontBack.front[selectItem.imgDomIndex].style.width = width
// detailData.frontBack.front[selectItem.imgDomIndex].style.height = height
});
moveableInstance.value.on('dragEnd', ({ target, clientX, clientY }) => {
startPosition = {
left:0,
top:0,
}
upDataDetail()
});
moveableInstance.value.on('scaleEnd', () => {
upDataDetail()
});
moveableInstance.value.on('rotateEnd', () => {
upDataDetail()
});
};
2026-01-28 17:11:28 +08:00
// watch(()=>selectItem.selectDetail,(newValue,oldValue)=>{
// if(!newValue && newValue?.id == oldValue?.id)return
// },{immediate: true,})
watch(()=>selectItem.selectDetail?.id,(newValue,oldValue)=>{
if(newValue){
selectItem.imgDomIndex = detailData.frontBack.front.findIndex((item:any)=>item.id == newValue)
setTimeout(()=>{
initMoveableForSelected()
},100)
}
},{immediate: true,})
2026-01-29 14:10:55 +08:00
watch(()=>detailData.frontBack.front.length,(newValue,oldValue)=>{
if(selectItem.selectDetail?.id)selectItem.imgDomIndex = detailData.frontBack.front.findIndex((item:any)=>item.id == selectItem.selectDetail?.id)
setTimeout(()=>{
initMoveableForSelected()
},100)
})
const setRevocation = async ()=>{
2025-10-23 10:18:15 +08:00
let frontBack = JSON.parse(JSON.stringify(detailData.frontBack))
let revocation:any = JSON.parse((await KeyValueDB.get("revocation") as any) || '[]')
2025-10-23 10:18:15 +08:00
revocation.push({designData:null,position:frontBack})
KeyValueDB.set('revocation', JSON.stringify(revocation));
2025-01-24 13:41:13 +08:00
}
const upDataDetail = async ()=>{
//同步到selectDetail数据中
// getDetailListData.designDetail
2026-01-15 17:14:11 +08:00
let {scale,offset,priority,transpose,rotate,position,imageSize} = await getSubmitData(selectItem.selectDetail)
selectItem.selectDetail.layersObject[0].scale = scale
selectItem.selectDetail.layersObject[1].scale = scale
selectItem.selectDetail.layersObject[0].offset = offset
selectItem.selectDetail.layersObject[1].offset = offset
selectItem.selectDetail.layersObject[0].priority = priority
selectItem.selectDetail.layersObject[1].priority = priority
selectItem.selectDetail.layersObject[0].rotate = rotate
selectItem.selectDetail.layersObject[1].rotate = rotate
selectItem.selectDetail.layersObject[0].transpose = transpose
selectItem.selectDetail.layersObject[1].transpose = transpose
selectItem.selectDetail.layersObject[0].position = position
selectItem.selectDetail.layersObject[1].position = position
selectItem.selectDetail.layersObject[0].imageSize = imageSize
selectItem.selectDetail.layersObject[1].imageSize = imageSize
setRevocation()
2025-01-24 13:41:13 +08:00
}
2025-02-17 09:34:28 +08:00
const sort = (arr:any)=>{
arr.sort((a:any, b:any) => {
var a_num = a.style.zIndex;
var b_num = b.style.zIndex;
return a_num - b_num;
});
return arr
}
2026-01-15 17:14:11 +08:00
const getSubmitData = async (value:any)=>{
2025-02-17 09:34:28 +08:00
let parentNode = document.getElementsByClassName('molepositon')[0].getElementsByClassName("designOpenrtion_imgMask")[0].getBoundingClientRect()
2026-01-15 17:14:11 +08:00
if(!detailData.frontBack?.body?.layersObject?.[0]?.imageSize){
2025-07-19 14:04:48 +08:00
return{
scale:value.layersObject[0].scale,
offset:value.layersObject[0].offset,
priority:value.layersObject[0].priority,
}
}
2025-02-17 09:34:28 +08:00
let ratio = detailData.frontBack.body.layersObject[0].imageSize[0]/parentNode.width
let scale = 0
let dom:any = document.querySelector('.molepositon .perview_img')
const img = new Image();
img.src = detailData.frontBack?.body?.path;
await new Promise<void>((resolve, reject) => {
img.onload = () => {
scale = dom.parentNode.offsetWidth / img.width
resolve()
};
})
2025-05-08 14:09:12 +08:00
// let arr:any = sort(detailData.frontBack.front)
let arr:any = sort(JSON.parse(JSON.stringify(detailData.frontBack.front)))
2025-02-17 09:34:28 +08:00
let num = 10
arr.forEach((item:any)=>{
item.priority = num++
})
let data:any = {
2025-02-25 15:32:55 +08:00
scale:null,
offset:null,
priority:'',
2025-02-17 09:34:28 +08:00
maskUrl:'',
maskMinioUrl:'',
position:null,
imageSize:null,
2025-02-17 09:34:28 +08:00
}
2025-02-25 15:32:55 +08:00
let state = false
2025-02-17 09:34:28 +08:00
for (let index = 0; index < arr.length; index++) {
if(value.id == arr[index].id){
2025-02-25 15:32:55 +08:00
state = true
2025-02-17 09:34:28 +08:00
let y = ((arr[index]?.style?.top.replace(/px/g,'')*ratio).toFixed(0) as any - arr[index]?.position[0])
let x = ((arr[index]?.style?.left.replace(/px/g,'')*ratio).toFixed(0) as any - arr[index]?.position[1])
let positionX = Number((arr[index]?.style?.left.replace(/px/g,'')/scale)).toFixed(2)
let positionY = Number((arr[index]?.style?.top.replace(/px/g,'')/scale)).toFixed(2)
let imageSizeW = Number((arr[index]?.style?.width.replace(/px/g,'')/scale)).toFixed(2)
let imageSizeH = Number((arr[index]?.style?.height.replace(/px/g,'')/scale)).toFixed(2)
2025-02-17 09:34:28 +08:00
let scaleWidth = arr[index]?.imageSize?Number(((arr[index]?.style?.width.replace(/px/g,'')*ratio)/(arr[index]?.imageSize[0]/arr[index].scale[0])).toFixed(2)):1
let scaleHeight = arr[index]?.imageSize?Number(((arr[index]?.style?.height.replace(/px/g,'')*ratio)/(arr[index]?.imageSize[1]/arr[index].scale[1])).toFixed(2)):1
// let widthScale = (arr[index].style.width.replace(/px/g,'')/arr[index].style.height.replace(/px/g,'')).toFixed(2)
let transformStr = arr[index]?.style?.transform
let scaleX = transformStr.match(/scaleX\(([-\d.]+)\)/)
let scaleY = transformStr.match(/scaleY\(([-\d.]+)\)/)
let rotate = transformStr.match(/rotate\(([-\d.]+)deg\)/);
data.transpose = [parseFloat(scaleX?.[1] || 1),parseFloat(scaleY?.[1] || 1)]
data.rotate = parseFloat(rotate?.[1] || 0)
2025-02-17 09:34:28 +08:00
data.scale = [scaleWidth,scaleHeight]
let top = y == 0 ? value.layersObject[0].offset[1]:y+value.layersObject[0].offset[1]
let left = x == 0 ? value.layersObject[0].offset[0]:x+value.layersObject[0].offset[0]
2025-02-25 15:32:55 +08:00
data.offset = [left?left:0,top?top:0]
data.position = [positionY,positionX]
data.imageSize = [imageSizeW,imageSizeH]
2025-02-25 15:32:55 +08:00
// data.offset = [left?left:0,top?top:0]
2025-02-17 09:34:28 +08:00
data.maskUrl = arr[index].maskUrl
data.maskMinioUrl = arr[index].maskMinioUrl
// data.priority = arr[index].style.zIndex
data.priority = arr[index].priority
arr[index].similarity = true
// item.offset = [(arr[index]?.style?.left.replace(/px/g,'')*ratio).toFixed(0),(i?.style?.top.replace(/px/g,'')*ratio).toFixed(0)]
break
}
}
2025-02-25 15:32:55 +08:00
if(!state){
data.scale = [1,1]
data.offset = [0,0]
data.priority = 10+arr.length
}
2025-02-17 09:34:28 +08:00
return data
2025-01-24 13:41:13 +08:00
}
const deleteNav = ()=>{
2025-02-17 09:34:28 +08:00
}
2025-03-03 14:52:05 +08:00
const updataPosition = ()=>{
let url = detailData.frontBack?.body?.path
let sacle = 0
const img = new Image();
img.onload = () => {
let dom:any = document.querySelector('.molepositon .perview_img')
// resolve(img)
sacle = dom.parentNode.offsetWidth / img.width
detailData.frontBack.front.forEach((item:any,index:number) => {
for (const key in item.style) {
if(key == 'zIndex')return
if(key == 'transform')return
2025-03-03 14:52:05 +08:00
item.style[key] = item.style[key]*sacle+'px'
}
for (const key in detailData.frontBack.back[index].style) {
if(key == 'zIndex')return
if(key == 'transform')return
2025-03-03 14:52:05 +08:00
detailData.frontBack.back[index].style[key] = detailData.frontBack.back[index].style[key]*sacle+'px'
}
});
};
img.src = url;
}
onUnmounted(()=>{
if (detailData.observer) {
detailData.observer.disconnect()
}
if (moveableInstance.value) {
moveableInstance.value.destroy();
}
})
2025-01-24 13:41:13 +08:00
return{
...toRefs(detailData),
2025-04-09 14:09:19 +08:00
...toRefs(selectItem),
2025-01-24 13:41:13 +08:00
...toRefs(getDetailListDom),
setElementRef,
2025-09-03 16:36:06 +08:00
setPrintSize,
2025-01-24 13:41:13 +08:00
deleteNav,
2025-02-17 09:34:28 +08:00
getSubmitData,
getMousePosition,
2025-03-03 14:52:05 +08:00
updataPosition,
updateRect,
2026-01-28 17:11:28 +08:00
initMoveableForSelected,
2026-02-02 10:31:37 +08:00
getTransformValues,
2025-01-24 13:41:13 +08:00
}
},
2025-02-17 09:34:28 +08:00
directives:{
detailBody:{
mounted (el,data:any) {
let sacle = 0
const img = new Image();
img.onload = () => {
// resolve(img)
sacle = el.parentNode.offsetWidth / img.width
data.instance.frontBack.front.forEach((item:any,index:number) => {
for (const key in item.style) {
if(key == 'zIndex')return
item.style[key] = item.style[key]*sacle+'px'
}
for (const key in data.instance.frontBack.back[index].style) {
if(key == 'zIndex')return
data.instance.frontBack.back[index].style[key] = data.instance.frontBack.back[index].style[key]*sacle+'px'
}
});
};
img.src = data.value;
2025-06-03 14:57:18 +08:00
},
updated (el,data:any) {
let sacle = 0
const img = new Image();
img.onload = () => {
// resolve(img)
sacle = el.parentNode.offsetWidth / img.width
data.instance.frontBack.front.forEach((item:any,index:number) => {
for (const key in item.style) {
if(key == 'zIndex')return
item.style[key] = item.style[key].replace(/px/g,'')*sacle+'px'
}
for (const key in data.instance.frontBack.back[index].style) {
if(key == 'zIndex')return
data.instance.frontBack.back[index].style[key] = data.instance.frontBack.back[index].style[key].replace(/px/g,'')*sacle+'px'
}
});
};
img.src = data.value;
2025-02-17 09:34:28 +08:00
}
}
},
2025-01-24 13:41:13 +08:00
provide() {
return {
}
},
})
</script>
<style lang="less" scoped>
.molepositon{
2025-06-11 15:08:17 +08:00
// width: 30rem;
// width: calc(66 * .470rem);
width: calc(66 * .457rem);
2025-04-23 09:39:24 +08:00
height: 66rem;
2025-01-24 13:41:13 +08:00
display: flex;
flex-direction: column;
2025-02-17 09:34:28 +08:00
// margin: auto 0;
2025-04-23 09:39:24 +08:00
// padding-top: 3rem;
2025-02-25 15:32:55 +08:00
position: relative;
display: none;
&.active{
2025-09-08 14:50:59 +08:00
display: flex;
2025-02-25 15:32:55 +08:00
z-index: 2;
2025-09-08 14:50:59 +08:00
align-items: center;
justify-content: center;
}
&.imgDesignImg{
> .designOpenrtion_imgMask{
.detail_modal_item_front{
display: flex;
align-items: center;
justify-content: center;
img{
2025-09-16 11:39:45 +08:00
// height: auto;
2025-09-08 14:50:59 +08:00
}
}
}
2025-02-25 15:32:55 +08:00
}
.moveableContainer{
:deep(.moveable-origin){
opacity: 0;
}
:deep(.moveable-control){
2026-01-28 17:11:28 +08:00
width: 1.4rem;
height: 1.4rem;
margin-top: -.7rem;
margin-left: -.7rem;
border-radius: 0;
2026-01-28 17:11:28 +08:00
background-color: #44aaff;
border: 2px solid #44aaff;
&.moveable-ne,&.moveable-se,&.moveable-sw,&.moveable-nw{
border: 2px solid #44aaff;
background-color: #ffff;
}
}
2026-02-02 10:31:37 +08:00
:deep(.custom-btn){
width: 2.8rem;
height: 2.8rem;
margin: .5rem;
border-radius: 50%;
position: absolute;
left: 0;
top: 0;
will-change: transform;
margin-left: -1.4rem;
margin-top: -1.4rem;
> svg{
cursor: pointer;
}
.flip-y{
transform: translateY(100%);
}
.flip-x{
transform: translateX(-100%);
}
}
:deep(.moveable-rotation-control){
border-radius: 50%;
}
}
2025-01-24 13:41:13 +08:00
> .designOpenrtion_imgMask{
width: auto;
height: auto;
position: relative;
2025-09-08 14:50:59 +08:00
// height: 100%;
2025-05-08 15:20:22 +08:00
display: flex;
align-items: center;
justify-content: center;
2025-01-24 13:41:13 +08:00
>img{
z-index: 2;
position: relative;
2025-04-09 14:09:19 +08:00
width: 100%;
2025-04-23 09:39:24 +08:00
height: auto;
// height: 100%;
// object-fit: contain;
2025-01-24 13:41:13 +08:00
}
>div{
position: absolute;
top: 0;
}
2025-02-17 09:34:28 +08:00
.detail_modal_item_front,.designOpenrtion_print{
z-index: 2;
2025-03-03 14:52:05 +08:00
height: 100%;
2025-04-30 14:01:52 +08:00
width: 100%;
pointer-events: none;
&.active{
pointer-events: auto;
}
2025-02-17 09:34:28 +08:00
img{
2025-04-30 14:01:52 +08:00
width: 100%;
2025-09-08 14:50:59 +08:00
// height: ;
2025-05-08 15:20:22 +08:00
height: 100%;
2025-02-17 09:34:28 +08:00
float: left;
user-select:none;
-webkit-user-drag: none;
}
.modal_imgItem{
position: absolute;
overflow: hidden;
top: 0;
}
}
.designOpenrtion_print{
z-index: 1 !important;
}
2025-01-24 13:41:13 +08:00
}
}
</style>