detail缺少字段打开detail后先调用preview

This commit is contained in:
X1627315083
2025-09-26 21:53:52 +08:00
parent aba2fd0363
commit 329660bccc
6 changed files with 120 additions and 37 deletions

View File

@@ -62,6 +62,7 @@
@addSketch="()=>isEditPattern.value=false"
@revocation="revocation"
@oppositeRevocation="oppositeRevocation"
@modelOnLoad="modelOnLoad"
></model>
<div class="btn">
<div class="gallery_btn" style="margin-right: 0;" @click="submit">{{$t('DesignPrintOperation.Submit')}}</div>
@@ -154,6 +155,7 @@ export default defineComponent({
fun:null,
},
positionKey:0,
isUndividedLayerWithSinglePrint:false,
})
provide('getCanvasIfEdit',detailData.getCanvasIfEdit)
@@ -207,16 +209,24 @@ export default defineComponent({
element.designType = 'Library'
}
});
if(!item.layersObject[0].undividedLayerWithSinglePrint){
detailData.isUndividedLayerWithSinglePrint = true
}
})
detailData.singleOveral.value = rv.singleOverall
detailData.designDetailShow = true
// this.deleteShow = false
initialize()
setRevocation()
detailData.loadingShow = false
if(rv.singleOverall == "single"){
store.commit('DesignDetail/setDesignColthes',rv.clothes[0].id)
}
if(detailData.isUndividedLayerWithSinglePrint){
}else{
detailData.loadingShow = false
}
resolve(rv)
}
).catch(rv=>{
@@ -339,7 +349,7 @@ export default defineComponent({
sketchString:list[i].sketchString?list[i].sketchString:'',
trims:(newData && detailData.currentDetailType == 'element' && isCurrent && !detailData.isEditPattern.value)?{prints:newData}:list[i].trims?.prints?list[i].trims:{prints:[]},
}
if((list[i].color?.gradient || list[i].newDetail?.color?.gradient) && !detailData.isEditPattern.value){
if((detailData.isEditPattern.value && list[i].color?.gradient) || (!detailData.isEditPattern.value && (list[i].newDetail?.color?.gradient || list[i].color?.gradient))){
gradient = list[i].newDetail?.color?.gradient || list[i].color.gradient
gradient.colorImg = await setGradual(gradient,320,700)
data.gradient = gradient
@@ -351,9 +361,9 @@ export default defineComponent({
const getSubmitData = async (str:string)=>{
// return
let workspace = store.state.Workspace.probjects
if(!detailData.selectDetail.path && !detailData.selectDetail.newDetail?.sketch?.minIOPath)return
if(!detailData?.selectDetail?.path && !detailData?.selectDetail?.newDetail?.sketch?.minIOPath)return
let clothes:any
if(detailData.currentDetailType == 'models'){
if(detailData.currentDetailType == 'models' || detailData.isUndividedLayerWithSinglePrint){
clothes = await setClothes(detailData.designDetail.clothes)
}else{
clothes = await setClothes([detailData.selectDetail])
@@ -382,6 +392,7 @@ export default defineComponent({
delete detailData.designDetail.newModel
store.commit('DesignDetail/setPraeview',value)
detailData.loadingShow = false
detailData.isUndividedLayerWithSinglePrint = false
canvasReload()
// setRevocation()
}).catch(res=>{
@@ -431,6 +442,12 @@ export default defineComponent({
let data = getSubmitData('preview')
store.dispatch('DesignDetail/setSubmit',data)
}
const modelOnLoad = ()=>{
if(!detailData.isUndividedLayerWithSinglePrint)return
setTimeout(()=>{
previwe()
})
}
const detailEdit = async (str:any)=>{
if(str == 'edit'){
if(detailData.isEditPattern.value){
@@ -475,6 +492,7 @@ export default defineComponent({
oppositeRevocation,
detailEdit,
canvasReload,
modelOnLoad,
}
},

View File

@@ -9,7 +9,7 @@
<editCanvas v-if="canvasLoad" :config="canvasConfig"
@canvasInit="canvasInit"
@changeCanvas="changeCanvas"
:clothingImageUrl="selectDetail.undividedLayer || selectDetail.path"
:clothingImageUrl="selectDetail?.undividedLayerWithSinglePrint || selectDetail.undividedLayer || selectDetail.path"
showFixedLayer
:canvasJSON="canvasJSON"
:clothing-image-opts="{
@@ -141,7 +141,7 @@ export default defineComponent({
}else{
if(detailData.currentView === 'redGreenExample'){
nextTick(()=>{
setCanvas(detailData.selectDetail.undividedLayer || detailData.selectDetail.path).then(()=>{
setCanvas(detailData.selectDetail?.undividedLayerWithSinglePrint || detailData.selectDetail.undividedLayer || detailData.selectDetail.path).then(()=>{
detailData.canvasLoad = true
})
})
@@ -185,7 +185,7 @@ export default defineComponent({
})
}
const frontBackChange = (value:any)=>{
let full = detailData.frontBack.front[detailData.imgDomIndex].undividedLayer || detailData.selectDetail.path
let full = detailData.frontBack.front[detailData.imgDomIndex]?.undividedLayerWithSinglePrint || detailData.frontBack.front[detailData.imgDomIndex].undividedLayer || detailData.selectDetail.path
let size = {
...detailData.canvasConfig,
}
@@ -289,7 +289,7 @@ export default defineComponent({
});
})
}
setCanvas(detailData.selectDetail.undividedLayer || detailData.selectDetail.path).then(()=>{
setCanvas(detailData.selectDetail?.undividedLayerWithSinglePrint || detailData.selectDetail.undividedLayer || detailData.selectDetail.path).then(()=>{
detailData.canvasLoad = true
})
})

View File

@@ -70,7 +70,7 @@
</div>
</div>
<!-- <img :src="selectDetail.path" alt="" class="designOpenrtion_sketch" ref="sketchImg"> -->
<img :src="selectDetail?.undividedLayer?selectDetail.undividedLayer:selectDetail.path" alt="" class="designOpenrtion_sketch" ref="sketchImg">
<img :src="selectDetail?.undividedLayer?selectDetail.undividedLayer:selectDetail.path" alt="" class="designOpenrtion_sketch" ref="sketchImg" @load="()=>isSketchLoad = true">
<div class="designOpenrtion_btn">
<ul v-if="overallSingle" 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))">
<li class="designOpenrtion_btn_top" @mousedown.stop="itemSizeMousedown('top',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('top',getMousePosition($event,true))"></li>
@@ -148,6 +148,7 @@ export default defineComponent({
},
loadingShow:false,
printElementList:null as any,
isSketchLoad:false,
})
const collItemSize = reactive({
collValue:18,
@@ -208,6 +209,7 @@ export default defineComponent({
})
}
const addPrintELement = async (data:any)=>{
if(!editPrintElementData.isSketchLoad)return
let {scale,location} = await setScaleLocation(data)
let item = {
angle:0,
@@ -379,6 +381,7 @@ export default defineComponent({
})
watch(()=>((editPrintElementData.selectDetail?.undividedLayer || editPrintElementData.selectDetail?.id)),(newVal)=>{
if(!newVal)return
editPrintElementData.isSketchLoad = false,
editPrintElementData.printStyleList[props.type] = {
single:[],
overall:[],

View File

@@ -23,7 +23,7 @@
<i class="fi fi-rr-copy" :title="$t('DesignDetail.compareTitle')" @mousedown="mousedownDesignImg" @mouseup="mousedownDesignImg" @touchstart="mousedownDesignImg" @touchend="mousedownDesignImg"></i>
</div>
<position ref="position" @canvasReload="()=>$emit('canvasReload')" @addSketch="()=>$emit('addSketch')" :imgDesignImg=imgDesignImg></position>
<position ref="position" @modelOnLoad="()=>$emit('modelOnLoad')" @canvasReload="()=>$emit('canvasReload')" @addSketch="()=>$emit('addSketch')" :imgDesignImg=imgDesignImg></position>
</div>
</div>
@@ -42,7 +42,7 @@ export default defineComponent({
components:{
position,modelNav
},
emits:['detailEdit','canvasReload','addSketch','revocation','oppositeRevocation'],
emits:['detailEdit','canvasReload','addSketch','revocation','oppositeRevocation','modelOnLoad'],
setup(props,{emit}) {
const {t} = useI18n()
const store = useStore();

View File

@@ -49,7 +49,7 @@ export default defineComponent({
type:Boolean,
}
},
emits:['canvasReload','addSketch'],
emits:['canvasReload','addSketch','modelOnLoad'],
setup(props,{emit}) {
const {t} = useI18n()
const store = useStore();
@@ -116,6 +116,8 @@ export default defineComponent({
// detailData.frontBack.back[index].style[key] = value*sacle+'px'
}
});
console.log(111,detailData.frontBack?.body?.path)
emit('modelOnLoad')
};
img.src = detailData.frontBack?.body?.path;
})

View File

@@ -1,5 +1,6 @@
import {Module} from 'vuex'
import {RootState} from '../index'
import { forEach } from 'jszip'
interface DesignDetail{
designDetail:any,
@@ -42,7 +43,6 @@ const DesignDetail : Module<DesignDetail,RootState> = {
state.currentPrintElement = null
},
setDesignDetail(state,data){
console.log(data)
if(data.others.length > 0 && data.others[0].type == "Body"){
state.frontBack.body = data.others[0]
}
@@ -72,11 +72,13 @@ const DesignDetail : Module<DesignDetail,RootState> = {
// front[index].style.zIndex = v.priority
front[index].id = v.id
front[index].undividedLayer = v.undividedLayer
front[index].undividedLayerWithSinglePrint = v?.undividedLayerWithSinglePrint
}else{
back[index] = v.layersObject[i]
back[index].style.zIndex = v.priority
back[index].id = v.id
back[index].undividedLayer = v.undividedLayer
back[index].undividedLayerWithSinglePrint = v?.undividedLayerWithSinglePrint
// back[index].style.zIndex = backIndex==0?v.layersObject[i]:backIndex++
}
if(state.printZIndex < v.priority){
@@ -152,7 +154,6 @@ const DesignDetail : Module<DesignDetail,RootState> = {
}
},
setDesignColthes(state,data){
console.log(data)
if(!state.currentDetailType)state.currentDetailType = 'sketch'
//切换选择
// state.currentDetailType = ''
@@ -195,6 +196,7 @@ const DesignDetail : Module<DesignDetail,RootState> = {
trims:null,
type:null,
undividedLayer:null,
undividedLayerWithSinglePrint:null,
}
if(!state.currentDetailType)state.currentDetailType = 'sketch'
state.designDetail.clothes.forEach((item:any) => {
@@ -206,7 +208,6 @@ const DesignDetail : Module<DesignDetail,RootState> = {
},
async setPraeview(state,value){//preview
let data = value?.rv || value
console.log(data,'preview')
let currentType = value?.currentType
if(state.designDetail.oldModel?.url)state.frontBack.body.path = state.designDetail.oldModel.url
if(value?.rv?.currentFullBodyView)state.designDetail.currentFullBodyView = value.rv.currentFullBodyView
@@ -218,14 +219,21 @@ const DesignDetail : Module<DesignDetail,RootState> = {
}
let id_:any
if(state.currentDetailType != 'models'){
id_ = state.selectDetail.id || state.selectDetail.newDetail?.sketch?.id
if(data.clothes.length > 2){
//缺少字段临时添加
id_ = item.id || state.selectDetail.newDetail?.sketch?.id
}else{
id_ = state.selectDetail.id || state.selectDetail.newDetail?.sketch?.id
}
}else{
id_ = item.id
}
console.log(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
state.frontBack.front[0].undividedLayerWithSinglePrint = value.rv.clothes[0]?.undividedLayerWithSinglePrint
resolve('')
}
const img = new Image();
@@ -256,11 +264,13 @@ const DesignDetail : Module<DesignDetail,RootState> = {
// state.frontBack.front[index].style.zIndex = v.priority
state.frontBack.front[index].id = item.id
state.frontBack.front[index].undividedLayer = item.undividedLayer
state.frontBack.front[index].undividedLayerWithSinglePrint = item?.undividedLayerWithSinglePrint
}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
state.frontBack.back[index].undividedLayerWithSinglePrint = item?.undividedLayerWithSinglePrint
}
}
}
@@ -268,25 +278,27 @@ const DesignDetail : Module<DesignDetail,RootState> = {
resolve('')
};
})
if(state.currentDetailType != 'models'){
state.selectDetail.change = item.change
if(state.selectDetail?.newDetail?.color && currentType != 'color'){
state.selectDetail.color = state.selectDetail?.newDetail?.color
state.selectDetail.newDetail.color = null
let uploadDetail = (detailItem)=>{
detailItem.change = item.change
if(detailItem?.newDetail?.color && currentType != 'color'){
detailItem.color = detailItem?.newDetail?.color
detailItem.newDetail.color = null
}
if(item.partialDesign){
state.selectDetail.partialDesign = item.partialDesign
detailItem.partialDesign = item.partialDesign
}
state.selectDetail.designType = item.designType
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.color = {
detailItem.designType = item.designType
detailItem.layersObject = item.layersObject
detailItem.path = item.path
detailItem.minIOPath = item.minIOPath
detailItem.scale = [1,1]
detailItem.offset = [0,0]
detailItem.printObject = item.printObject
detailItem.trims = item.trims
detailItem.type = item.type
detailItem.maskMinioUrl = item.layersObject?.[0]?.maskMinioUrl
detailItem.maskUrl = item.layersObject?.[0]?.maskUrl
detailItem.color = {
...item.color,
rgba:{
r:item.color?.r,
@@ -295,12 +307,60 @@ const DesignDetail : Module<DesignDetail,RootState> = {
},
gradient:item.gradient,
}
state.selectDetail.undividedLayer = item.undividedLayer
if(state.selectDetail.newDetail?.sketch?.id && !state.selectDetail.id){
state.designDetail.clothes.push(state.selectDetail)
detailItem.undividedLayer = item.undividedLayer
detailItem.undividedLayerWithSinglePrint = item?.undividedLayerWithSinglePrint
if(detailItem.newDetail?.sketch?.id && !detailItem.id){
state.designDetail.clothes.push(detailItem)
}
state.selectDetail.id = item.id
if(currentType)if(state.selectDetail.newDetail?.[currentType] && currentType != 'color')delete state.selectDetail.newDetail[currentType]
detailItem.id = item.id
if(currentType)if(detailItem.newDetail?.[currentType] && currentType != 'color')delete detailItem.newDetail[currentType]
}
if(data.clothes.length > 2){
state.designDetail.clothes.forEach((detailItem:any) => {
if(detailItem.id == id_){
uploadDetail(detailItem)
}
});
}else{
uploadDetail(state.selectDetail)
}
if(state.currentDetailType != 'models'){
// state.selectDetail.change = item.change
// if(state.selectDetail?.newDetail?.color && currentType != '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.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.maskMinioUrl = item.layersObject?.[0]?.maskMinioUrl
// state.selectDetail.maskUrl = item.layersObject?.[0]?.maskUrl
// state.selectDetail.color = {
// ...item.color,
// rgba:{
// r:item.color?.r,
// g:item.color?.g,
// b:item.color?.b,
// },
// gradient:item.gradient,
// }
// state.selectDetail.undividedLayer = item.undividedLayer
// state.selectDetail.undividedLayerWithSinglePrint = item?.undividedLayerWithSinglePrint
// if(state.selectDetail.newDetail?.sketch?.id && !state.selectDetail.id){
// state.designDetail.clothes.push(state.selectDetail)
// }
// state.selectDetail.id = item.id
// if(currentType)if(state.selectDetail.newDetail?.[currentType] && currentType != 'color')delete state.selectDetail.newDetail[currentType]
}
}
if(value.fun)value.fun()