修复detail添加印花sort值设置不对

This commit is contained in:
X1627315083
2026-02-02 13:30:43 +08:00
parent c428bfd93b
commit 4bd7740753

View File

@@ -89,8 +89,8 @@
<img crossOrigin="anonymous" :src="item?.path" :style="{transform:`rotateZ(${item.pattern?.transform?.rotateZ}deg)`}" class="designOpenrtion_imgItme" draggable="false">
</div>
</div>
<img :src="selectDetail.path" alt="" class="designOpenrtion_sketch" ref="sketchImg" @load="()=>isSketchLoad = true">
<!-- <img :src="stateOverallSingle == 'single'?(selectDetail.undividedLayer||selectDetail.path):(selectDetail.undividedLayerColor || selectDetail.path)" alt="" class="designOpenrtion_sketch" ref="sketchImg" @load="()=>isSketchLoad = true"> -->
<!-- <img :src="selectDetail.path" alt="" class="designOpenrtion_sketch" ref="sketchImg" @load="()=>isSketchLoad = true"> -->
<img :src="(selectDetail.path)" alt="" class="designOpenrtion_sketch" ref="sketchImg" @load="()=>isSketchLoad = true">
<img :src="selectDetail.sketchMask" alt="" class="designOpenrtion_sketchMask" ref="sketchMask">
<div class="designOpenrtion_btn" v-if="stateOverallSingle == 'single'" >
<ul v-for="item,index in printStyleList[type][stateOverallSingle]" :key="item" :class="{active:item?.pattern.designOpenrtionBtn?item?.pattern.designOpenrtionBtn:false}" class="designOpenrtion_Mousingle" :style="item?.pattern.style" @mousedown.stop="itemMoveMousedown(index,getMousePosition($event,false))" @touchstart.passive="itemMoveMousedown(index,getMousePosition($event,true))">
@@ -223,6 +223,7 @@ export default defineComponent({
img.onload = ()=>{
let imgScale = img.width / img.height
let zoom = 2
console.log(editPrintElementData.sketchWH)
let width = editPrintElementData.sketchWH.width / zoom
let height = width / editPrintElementData.sketchWH.height
@@ -236,26 +237,41 @@ export default defineComponent({
x = sketchW / 2
y = sketchH / 2
}
x = sketchW / 2
y = sketchH / 2
let location = [x,y]
resolve({scale,location})
}
img.src = item.url
img.src = item.url || item.path
})
}
const addPrintELement = async (data:any)=>{
if(!editPrintElementData.isSketchLoad)return
let {scale,location} = await setScaleLocation(data)
let allElementPrint = [
...(editPrintElementData.selectDetail.printObject.prints || []),
let printIndex = 0
let allElementPrint = []
if(props.type == 'print'){
allElementPrint = [
...(editPrintElementData.printStyleList.print.single || []),
...(editPrintElementData.printStyleList.print.overall || []),
...(editPrintElementData.selectDetail.trims.prints || []),
]
let printIndex = Math.max(...allElementPrint.map(item => item.priority)) + 1
}else{
allElementPrint = [
...(editPrintElementData.printStyleList.element.single || []),
...(editPrintElementData.selectDetail.printObject.prints || []),
]
}
printIndex = Math.max(...allElementPrint.map(item => Number(item.priority))) + 1
console.log(printIndex)
let item = {
angle:0,
designType:data.designType,
ifSingle:editPrintElementData.stateOverallSingle == 'single',
level2Type:data.level2Type,
location:editPrintElementData.stateOverallSingle == 'single'?location:[0,0],
location:location,
// location:editPrintElementData.stateOverallSingle == 'single'?location:[0,0],
minIOPath:data.minIOPath || data.originalUrl,
path:data.url,
priority:printIndex,
@@ -343,6 +359,7 @@ export default defineComponent({
top = item.location[1] / editPrintElementData.sketchWH.scale[1]
}else{
//overall
console.log(item)
left = item.location[0] / editPrintElementData.sketchWH.scale[0]
top = item.location[1] / editPrintElementData.sketchWH.scale[1]
item.scale = [1,1]
@@ -405,7 +422,8 @@ export default defineComponent({
}
}
}
const setPosition = ()=>{
const setPosition = async ()=>{
await new Promise<void>((resolve, reject) => {
nextTick(()=>{
let img = new Image
img.onload = ()=>{
@@ -441,15 +459,12 @@ export default defineComponent({
})
setItemPosition()
}
// if(props.type == 'print'){
// editPrintElementData.overallSingle = state
// }
resolve('')
}
// undividedLayer
//计算宽高使用editPrintElementData.selectDetail.path
// img.src = editPrintElementData.selectDetail.path
img.src = editPrintElementData.selectDetail.undividedLayer?editPrintElementData.selectDetail.undividedLayer:editPrintElementData.selectDetail.path
img.src = editPrintElementData.selectDetail.path
})
})
}
// watch(()=>editPrintElementData.selectDetail?.id,(newVal)=>{
// if(!newVal)return
@@ -860,7 +875,6 @@ export default defineComponent({
let arr:any = editPrintElementData.printStyleList[props.type][editPrintElementData.stateOverallSingle]
arr.forEach((item,index) => {item.uniqueId = `${Date.now()}_${index}`});
console.log(arr)
const sortedArray = [...arr].sort((a, b) => a.priority - b.priority);
const sortMap = {} as any;
sortedArray.forEach((item, index) => {