detail更新
This commit is contained in:
@@ -34,6 +34,8 @@ const DesignDetailCopy : Module<DesignDetailCopy,RootState> = {
|
||||
let back:any = []
|
||||
// let printZIndex =
|
||||
data.clothes.forEach((v:any,index:any)=>{
|
||||
// if(!v?.partialDesignDTO){
|
||||
// }
|
||||
for (let i = v.layersObject.length-1; i >= 0; i--) {
|
||||
v.layersObject[i].style = {
|
||||
top:v.layersObject[i].position?.[0],
|
||||
@@ -67,6 +69,17 @@ const DesignDetailCopy : Module<DesignDetailCopy,RootState> = {
|
||||
state.frontBack.back = back
|
||||
state.designDetail = data
|
||||
},
|
||||
updataDetailItem(state,data){
|
||||
state.designDetail.clothes.forEach((item:any) => {
|
||||
if(item.id == state.selectDetail.id){
|
||||
console.log(data);
|
||||
|
||||
for (const key in data) {
|
||||
item[key] = data[key]
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
clearDesignDetail(state){
|
||||
state.designDetail = null
|
||||
state.designPreviewData = {}
|
||||
@@ -103,20 +116,21 @@ const DesignDetailCopy : Module<DesignDetailCopy,RootState> = {
|
||||
}
|
||||
},
|
||||
setCurrentDetailType(state,data){
|
||||
if(state.selectDetail && state.selectDetail.id)state.currentDetailType = data
|
||||
if(state.selectDetail && state.selectDetail.id){
|
||||
state.currentDetailType = data
|
||||
}else if(state.selectDetail && data == 'sketch'){
|
||||
state.currentDetailType = data
|
||||
}
|
||||
},
|
||||
setDesignColthes(state,data){
|
||||
if(!state.currentDetailType)state.currentDetailType = 'sketch'
|
||||
if(state.selectDetail && state.selectDetail.id == data){
|
||||
return
|
||||
}
|
||||
//切换选择
|
||||
// state.currentDetailType = ''
|
||||
// state.designDetail.clothes[data.index] = data.clothes
|
||||
state.designDetail.clothes.forEach((item:any) => {
|
||||
if(item.id == data){
|
||||
state.selectDetail = item
|
||||
state.frontBack.front.forEach((v:any)=>{
|
||||
state.frontBack.front.forEach((v:any,index:any)=>{
|
||||
v.designOpenrtionBtn = false
|
||||
if(v.id == data){
|
||||
v.designOpenrtionBtn = true
|
||||
@@ -125,10 +139,91 @@ const DesignDetailCopy : Module<DesignDetailCopy,RootState> = {
|
||||
}
|
||||
});
|
||||
},
|
||||
setPraeview(state,data){//preview
|
||||
data.clothes.forEach((item:any) => {
|
||||
if(!item.id)return
|
||||
let id_ = state.selectDetail.id
|
||||
addDesignColthes(state){
|
||||
let data = {
|
||||
changed:null,
|
||||
color:{rgba:{
|
||||
r:255,
|
||||
g:255,
|
||||
b:255,
|
||||
}},
|
||||
designType:null,
|
||||
gradient:null,
|
||||
id:null,
|
||||
partialDesign:{
|
||||
layers:[],
|
||||
partialDesignPath:'',
|
||||
partialDesignMinioPath:'',
|
||||
partialDesignBase64:''
|
||||
},
|
||||
layersObject:null,
|
||||
newDetail:{},
|
||||
level1Type:'Sketchboard',
|
||||
minIOPath:null,
|
||||
path:null,
|
||||
printObject:null,
|
||||
trims:null,
|
||||
type:null,
|
||||
undividedLayer:null,
|
||||
}
|
||||
if(!state.currentDetailType)state.currentDetailType = 'sketch'
|
||||
state.designDetail.clothes.forEach((item:any) => {
|
||||
state.frontBack.front.forEach((v:any,index:any)=>{
|
||||
v.designOpenrtionBtn = false
|
||||
})
|
||||
});
|
||||
state.selectDetail = data
|
||||
},
|
||||
async setPraeview(state,data){//preview
|
||||
for (let j = 0; j < data.clothes.length; j++) {
|
||||
const item = data.clothes[j];
|
||||
if(!item.id)continue
|
||||
if(item.id == state.selectDetail.id || state.selectDetail.newDetail?.sketch?.id == item.id){
|
||||
|
||||
}
|
||||
let id_ = state.selectDetail.id || state.selectDetail.newDetail?.sketch?.id
|
||||
let el:any = document.querySelector('.molepositon .perview_img')
|
||||
await new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.src = state.frontBack.body.path;
|
||||
img.onload = () => {
|
||||
let scale:any = el.parentNode.offsetWidth / img.width;
|
||||
if(state.selectDetail.newDetail?.sketch?.id && !state.selectDetail.id){
|
||||
state.frontBack.front.push({id:state.selectDetail.newDetail?.sketch?.id})
|
||||
state.frontBack.back.push({id:state.selectDetail.newDetail?.sketch?.id})
|
||||
}
|
||||
state.frontBack.front.forEach((v:any,index:any)=>{
|
||||
if(v.id == id_){
|
||||
for (let i = item.layersObject.length-1; i >= 0; i--) {
|
||||
item.layersObject[i].style = {
|
||||
top:item.layersObject[i].position?.[0] * scale + 'px',
|
||||
left:item.layersObject[i].position?.[1] * scale + 'px',
|
||||
width:item.layersObject[i].imageSize?.[0] * scale + 'px',
|
||||
height:item.layersObject[i].imageSize?.[1] * scale + 'px',
|
||||
zIndex:v?.style?.zIndex?v.style.zIndex:state.frontBack.front.length
|
||||
}
|
||||
item.layersObject[i].centers={
|
||||
left:0,
|
||||
top:0,
|
||||
}
|
||||
item.layersObject[i].designOpenrtionBtn = false
|
||||
if(item.layersObject[i].imageCategory.indexOf("back") == -1){
|
||||
state.frontBack.front[index] = item.layersObject[i]
|
||||
// state.frontBack.front[index].style.zIndex = v.priority
|
||||
state.frontBack.front[index].id = item.id
|
||||
state.frontBack.front[index].undividedLayer = item.undividedLayer
|
||||
}else{
|
||||
state.frontBack.back[index] = item.layersObject[i]
|
||||
// state.frontBack.back[index].style.zIndex = v.priority
|
||||
state.frontBack.back[index].id = item.id
|
||||
state.frontBack.back[index].undividedLayer = item.undividedLayer
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
resolve('')
|
||||
};
|
||||
})
|
||||
state.selectDetail.change = item.change
|
||||
if(state.selectDetail?.newDetail?.color){
|
||||
state.selectDetail.color = state.selectDetail?.newDetail?.color
|
||||
@@ -136,9 +231,7 @@ const DesignDetailCopy : Module<DesignDetailCopy,RootState> = {
|
||||
}
|
||||
state.selectDetail.designType = item.designType
|
||||
state.selectDetail.gradient = item.gradient
|
||||
state.selectDetail.id = item.id
|
||||
state.selectDetail.layersObject = item.layersObject
|
||||
state.selectDetail.newDetail[state.currentDetailType] = null
|
||||
state.selectDetail.path = item.path
|
||||
state.selectDetail.minIOPath = item.minIOPath
|
||||
state.selectDetail.scale = [1,1]
|
||||
@@ -146,54 +239,20 @@ const DesignDetailCopy : Module<DesignDetailCopy,RootState> = {
|
||||
state.selectDetail.printObject = item.printObject
|
||||
state.selectDetail.type = item.type
|
||||
state.selectDetail.undividedLayer = item.undividedLayer
|
||||
// if(state.currentDetailType == 'sketch'){//如果是sketch更新front和back
|
||||
let el:any = document.querySelector('.molepositon .perview_img')
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
let scale:any = el.parentNode.offsetWidth / img.width
|
||||
state.frontBack.front.forEach((v:any,index:any)=>{
|
||||
if(v.id == id_){
|
||||
for (let i = item.layersObject.length-1; i >= 0; i--) {
|
||||
item.layersObject[i].style = {
|
||||
top:item.layersObject[i].position?.[0] * scale + 'px',
|
||||
left:item.layersObject[i].position?.[1] * scale + 'px',
|
||||
width:item.layersObject[i].imageSize?.[0] * scale + 'px',
|
||||
height:item.layersObject[i].imageSize?.[1] * scale + 'px',
|
||||
zIndex:v.style.zIndex
|
||||
}
|
||||
item.layersObject[i].centers={
|
||||
left:0,
|
||||
top:0,
|
||||
}
|
||||
item.layersObject[i].designOpenrtionBtn = false
|
||||
if(item.layersObject[i].imageCategory.indexOf("back") == -1){
|
||||
state.frontBack.front[index] = item.layersObject[i]
|
||||
// state.frontBack.front[index].style.zIndex = v.priority
|
||||
state.frontBack.front[index].id = item.id
|
||||
state.frontBack.front[index].undividedLayer = item.undividedLayer
|
||||
}else{
|
||||
state.frontBack.back[index] = item.layersObject[i]
|
||||
// state.frontBack.back[index].style.zIndex = v.priority
|
||||
state.frontBack.back[index].id = item.id
|
||||
state.frontBack.back[index].undividedLayer = item.undividedLayer
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
img.src = state.frontBack.body.path;
|
||||
|
||||
// }
|
||||
})
|
||||
|
||||
if(state.selectDetail.newDetail?.sketch?.id && !state.selectDetail.id){
|
||||
state.designDetail.clothes.push(state.selectDetail)
|
||||
}
|
||||
state.selectDetail.id = item.id
|
||||
if(state.selectDetail.newDetail?.[state.currentDetailType])state.selectDetail.newDetail[state.currentDetailType] = null
|
||||
}
|
||||
},
|
||||
|
||||
// setDesignItemOthers(state,data){
|
||||
// state.designDetail.others[data.index] = data.others
|
||||
// },
|
||||
},
|
||||
actions:{
|
||||
async setSubmit({ commit },str) {
|
||||
console.log(str);
|
||||
|
||||
// setTimeout(() => {
|
||||
// const message = 'Hello from Vuex';
|
||||
|
||||
Reference in New Issue
Block a user