布局修改 部分bug修复

This commit is contained in:
X1627315083
2025-08-22 10:27:48 +08:00
parent 141821a843
commit 594bf5ce0a
275 changed files with 5675 additions and 13049 deletions

View File

@@ -2,35 +2,298 @@ import {Module} from 'vuex'
import {RootState} from '../index'
interface DesignDetail{
designItemDetail:any,
designDetail:any,
designPreviewData:any,
frontBack:any,
selectDetail:any,
printZIndex:any,
//值都有 sketchcolor,print,element
currentDetailType:any,
currentPrintElement:any,
}
const DesignDetailModule : Module<DesignDetail,RootState> = {
const DesignDetail : Module<DesignDetail,RootState> = {
namespaced: true,
state:{
designItemDetail:{},
designPreviewData:{}
designDetail:null,
designPreviewData:{},
frontBack:{
front:[],
back:[],
body:{},
},
selectDetail:null,
printZIndex:-1,
currentDetailType:'',
currentPrintElement:null,
},
mutations:{
setDesignItemDetail(state,files){
state.designItemDetail = files
setDesignDetail(state,data){
if(data.others.length > 0 && data.others[0].type == "Body"){
state.frontBack.body = data.others[0]
}
let front:any = []
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],
left:v.layersObject[i].position?.[1],
width:v.layersObject[i].imageSize?.[0],
height:v.layersObject[i].imageSize?.[1],
}
v.layersObject[i].centers={
left:0,
top:0,
}
v.layersObject[i].designOpenrtionBtn = false
if(v.layersObject[i].imageCategory.indexOf("back") == -1){
front[index] = v.layersObject[i]
// front[index].style.zIndex = v.priority
front[index].id = v.id
front[index].undividedLayer = v.undividedLayer
}else{
back[index] = v.layersObject[i]
back[index].style.zIndex = v.priority
back[index].id = v.id
back[index].undividedLayer = v.undividedLayer
// back[index].style.zIndex = backIndex==0?v.layersObject[i]:backIndex++
}
if(state.printZIndex < v.priority){
state.printZIndex = v.priority
}
}
})
state.frontBack.front = front
state.frontBack.back = back
state.designDetail = data
},
setDesignItemColthes(state,data){
state.designItemDetail.clothes[data.index] = data.clothes
},
setDesignItemOthers(state,data){
state.designItemDetail.others[data.index] = data.others
},
setDesignPreviewData(state,files){
state.designPreviewData = files
updataDetailItem(state,data){
state.designDetail.clothes.forEach((item:any) => {
if(item.id == state.selectDetail.id){
for (const key in data) {
item[key] = data[key]
}
}
});
},
clearDesignDetail(state){
state.designDetail = null
state.designPreviewData = {}
state.frontBack = {
front:[],
back:[],
body:{},
}
state.selectDetail = null
state.currentDetailType = ''
state.printZIndex = -1
},
addDesign(state,data){
},
setNewDetail(state,value){
// state.designDetail.clothes.forEach((item:any) => {
// if(item.id == state.selectDetail.id){
// }
// });
let {data} = value
let str = value.str || state.currentDetailType
if(!state.selectDetail)return
if(!state.selectDetail.newDetail){
state.selectDetail.newDetail = {}
}
if(str == 'sketch'){
state.selectDetail.newDetail[str] = data
}else if(str == 'color'){
state.selectDetail.newDetail[str] = data
}else if(str == 'print'){
state.selectDetail.newDetail[str] = data
}else if(str == 'element'){
state.selectDetail.newDetail[str] = data
}else if(str == 'models'){
// if(!state.designDetail.newModel)state.designDetail.newModel={}
state.designDetail.newModel = JSON.parse(JSON.stringify(data))
}else{
if(!state.selectDetail.newDetail[str])state.selectDetail.newDetail[str] = []
const foundObjects = state.selectDetail.newDetail[str].filter((item:any) => item.id === data.id);
if(foundObjects.length == 0){
state.selectDetail.newDetail[str].push(data)
}
}
},
setCurrentPrintElement(state,data){//临时存放印花和元素点击用来监听在衣服上添加元素
state.currentPrintElement = data?.resData || data
},
setCurrentDetailType(state,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'
//切换选择
// 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,index:any)=>{
v.designOpenrtionBtn = false
if(v.id == data){
v.designOpenrtionBtn = true
}
})
}
});
},
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,value){//preview
let data = value.rv
let currentType = value.currentType
if(state.designDetail.oldModel?.url)state.frontBack.body.path = state.designDetail.oldModel.url
state.designDetail.currentFullBodyView = value.rv.currentFullBodyView
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_:any
if(state.currentDetailType != 'models'){
id_ = state.selectDetail.id || state.selectDetail.newDetail?.sketch?.id
}else{
id_ = item.id
}
let el:any = document.querySelector('.molepositon .perview_img')
await new Promise((resolve, reject) => {
if(!state.frontBack?.body?.path){
state.frontBack.front[0].undividedLayer = value.rv.clothes[0].undividedLayer
resolve('')
}
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('')
};
})
if(state.currentDetailType != 'models'){
state.selectDetail.change = item.change
if(state.selectDetail?.newDetail?.color){
state.selectDetail.color = state.selectDetail?.newDetail?.color
state.selectDetail.newDetail.color = null
}
if(item.partialDesign){
state.selectDetail.partialDesign = item.partialDesign
}
state.selectDetail.designType = item.designType
state.selectDetail.gradient = item.gradient
state.selectDetail.layersObject = item.layersObject
state.selectDetail.path = item.path
state.selectDetail.minIOPath = item.minIOPath
state.selectDetail.scale = [1,1]
state.selectDetail.offset = [0,0]
state.selectDetail.printObject = item.printObject
state.selectDetail.trims = item.trims
state.selectDetail.type = item.type
state.selectDetail.undividedLayer = item.undividedLayer
if(state.selectDetail.newDetail?.sketch?.id && !state.selectDetail.id){
state.designDetail.clothes.push(state.selectDetail)
}
state.selectDetail.id = item.id
if(state.selectDetail.newDetail?.[currentType])delete state.selectDetail.newDetail[currentType]
}
}
},
// setDesignItemOthers(state,data){
// state.designItemDetail.others[data.index] = data.others
// state.designDetail.others[data.index] = data.others
// },
},
actions:{
async setSubmit({ commit },str) {
// setTimeout(() => {
// const message = 'Hello from Vuex';
// commit('setMessage', message); // 更新状态
// resolve(message); // 返回数据
// }, 1000);
},
}
}
export default DesignDetailModule
export default DesignDetail

View File

@@ -1,298 +0,0 @@
import {Module} from 'vuex'
import {RootState} from '../index'
interface DesignDetailCopy{
designDetail:any,
designPreviewData:any,
frontBack:any,
selectDetail:any,
printZIndex:any,
//值都有 sketchcolor,print,element
currentDetailType:any,
currentPrintElement:any,
}
const DesignDetailCopy : Module<DesignDetailCopy,RootState> = {
namespaced: true,
state:{
designDetail:null,
designPreviewData:{},
frontBack:{
front:[],
back:[],
body:{},
},
selectDetail:null,
printZIndex:-1,
currentDetailType:'',
currentPrintElement:null,
},
mutations:{
setDesignDetail(state,data){
if(data.others.length > 0 && data.others[0].type == "Body"){
state.frontBack.body = data.others[0]
}
let front:any = []
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],
left:v.layersObject[i].position?.[1],
width:v.layersObject[i].imageSize?.[0],
height:v.layersObject[i].imageSize?.[1],
}
v.layersObject[i].centers={
left:0,
top:0,
}
v.layersObject[i].designOpenrtionBtn = false
if(v.layersObject[i].imageCategory.indexOf("back") == -1){
front[index] = v.layersObject[i]
// front[index].style.zIndex = v.priority
front[index].id = v.id
front[index].undividedLayer = v.undividedLayer
}else{
back[index] = v.layersObject[i]
back[index].style.zIndex = v.priority
back[index].id = v.id
back[index].undividedLayer = v.undividedLayer
// back[index].style.zIndex = backIndex==0?v.layersObject[i]:backIndex++
}
if(state.printZIndex < v.priority){
state.printZIndex = v.priority
}
}
})
state.frontBack.front = front
state.frontBack.back = back
state.designDetail = data
},
updataDetailItem(state,data){
state.designDetail.clothes.forEach((item:any) => {
if(item.id == state.selectDetail.id){
for (const key in data) {
item[key] = data[key]
}
}
});
},
clearDesignDetail(state){
state.designDetail = null
state.designPreviewData = {}
state.frontBack = {
front:[],
back:[],
body:{},
}
state.selectDetail = null
state.currentDetailType = ''
state.printZIndex = -1
},
addDesign(state,data){
},
setNewDetail(state,value){
// state.designDetail.clothes.forEach((item:any) => {
// if(item.id == state.selectDetail.id){
// }
// });
let {data} = value
let str = value.str || state.currentDetailType
if(!state.selectDetail)return
if(!state.selectDetail.newDetail){
state.selectDetail.newDetail = {}
}
if(str == 'sketch'){
state.selectDetail.newDetail[str] = data
}else if(str == 'color'){
state.selectDetail.newDetail[str] = data
}else if(str == 'print'){
state.selectDetail.newDetail[str] = data
}else if(str == 'element'){
state.selectDetail.newDetail[str] = data
}else if(str == 'models'){
// if(!state.designDetail.newModel)state.designDetail.newModel={}
state.designDetail.newModel = JSON.parse(JSON.stringify(data))
}else{
if(!state.selectDetail.newDetail[str])state.selectDetail.newDetail[str] = []
const foundObjects = state.selectDetail.newDetail[str].filter((item:any) => item.id === data.id);
if(foundObjects.length == 0){
state.selectDetail.newDetail[str].push(data)
}
}
},
setCurrentPrintElement(state,data){//临时存放印花和元素点击用来监听在衣服上添加元素
state.currentPrintElement = data?.resData || data
},
setCurrentDetailType(state,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'
//切换选择
// 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,index:any)=>{
v.designOpenrtionBtn = false
if(v.id == data){
v.designOpenrtionBtn = true
}
})
}
});
},
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,value){//preview
let data = value.rv
let currentType = value.currentType
if(state.designDetail.oldModel?.url)state.frontBack.body.path = state.designDetail.oldModel.url
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_:any
if(state.currentDetailType != 'models'){
id_ = state.selectDetail.id || state.selectDetail.newDetail?.sketch?.id
}else{
id_ = item.id
}
let el:any = document.querySelector('.molepositon .perview_img')
await new Promise((resolve, reject) => {
if(!state.frontBack?.body?.path){
state.frontBack.front[0].undividedLayer = value.rv.clothes[0].undividedLayer
resolve('')
}
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('')
};
})
if(state.currentDetailType != 'models'){
state.selectDetail.change = item.change
if(state.selectDetail?.newDetail?.color){
state.selectDetail.color = state.selectDetail?.newDetail?.color
state.selectDetail.newDetail.color = null
}
if(item.partialDesign){
state.selectDetail.partialDesign = item.partialDesign
}
state.selectDetail.designType = item.designType
state.selectDetail.gradient = item.gradient
state.selectDetail.layersObject = item.layersObject
state.selectDetail.path = item.path
state.selectDetail.minIOPath = item.minIOPath
state.selectDetail.scale = [1,1]
state.selectDetail.offset = [0,0]
state.selectDetail.printObject = item.printObject
state.selectDetail.trims = item.trims
state.selectDetail.type = item.type
state.selectDetail.undividedLayer = item.undividedLayer
if(state.selectDetail.newDetail?.sketch?.id && !state.selectDetail.id){
state.designDetail.clothes.push(state.selectDetail)
}
state.selectDetail.id = item.id
if(state.selectDetail.newDetail?.[currentType])delete state.selectDetail.newDetail[currentType]
}
}
},
// setDesignItemOthers(state,data){
// state.designDetail.others[data.index] = data.others
// },
},
actions:{
async setSubmit({ commit },str) {
// setTimeout(() => {
// const message = 'Hello from Vuex';
// commit('setMessage', message); // 更新状态
// resolve(message); // 返回数据
// }, 1000);
},
}
}
export default DesignDetailCopy

View File

@@ -1,7 +1,7 @@
import { createStore } from 'vuex'
import UploadFilesModule from './uploadFile/uploadFile'
import DesignDetailModule from './Detail/designDetail'
import DesignDetailCopy from './Detail/designDetailCopy'
import DesignDetail from './Detail/designDetail'
import HomeStoreModule from './homeStore/homeStore'
import UserHabit from './userHabit/userHabit'
import Workspace from './workspace/workspace'
@@ -23,7 +23,7 @@ export default createStore<RootState>({
modules: {
UploadFilesModule,
DesignDetailModule,
DesignDetailCopy,
DesignDetail,
HomeStoreModule,
UserHabit,
Workspace,

View File

@@ -218,7 +218,6 @@ const userHabit : Module<UserHabit,RootState> = {
},
setUserDetail(state,data){
// if(!data.email && !state.userDetail.email)state.isBindEmail = true
// state.userDetail = data
state.userDetail.email = data.email?data.email:'-------------'