This commit is contained in:
X1627315083
2023-12-22 10:57:12 +08:00
parent 22856aa281
commit a51b7f2915
5 changed files with 68 additions and 26 deletions

View File

@@ -237,7 +237,26 @@ export default defineComponent({
}
});
},
hasDuplicateId(arr) {
const set = new Set();
for (let i = 0; i < arr.length; i++) {
const id = arr[i].id;
if (set.has(id)) {
return true;
}
set.add(id);
}
return false;
},
soleId(arr,index){
let randomNum = Math.floor(100 + Math.random() * 900);
arr[index].id = this.sketchImg.id_? Number(this.sketchImg.id_+(randomNum+"")):this.current.id_
if(this.hasDuplicateId(arr)){
this.soleId(arr,index)
}else{
return arr
}
},
//提交
setPreview(){
let designItemDetail = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designItemDetail))
@@ -265,7 +284,8 @@ export default defineComponent({
data.designSingleItemDTOList[index].offset = [0,0]
data.designSingleItemDTOList[index].scale = 1
}
data.designSingleItemDTOList[index].id = this.sketchImg.id_? this.sketchImg.id_:this.current.id_
data.designSingleItemDTOList = this.soleId(data.designSingleItemDTOList,index)
this.sketchImg.id_ = data.designSingleItemDTOList[index].id
data.designSingleItemDTOList[index].path =this.sketchImg.minIOPath? this.sketchImg.minIOPath: this.current.minIOPath
data.designSingleItemDTOList[index].type =this.sketchImg.type? this.sketchImg.type: this.current.type
}else if(this.type_ == 2){