|
|
@@ -62,6 +62,7 @@ export default {
|
|
|
color:"#fff",
|
|
|
bg_color:'#fff',
|
|
|
visible:false,
|
|
|
+ multi_goods_mode: '', // 多货号模式:''(默认单货号), 'single'(一个货号多角度), 'multiple'(多个货号同角度)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -128,6 +129,50 @@ export default {
|
|
|
this.$emit('update:index', 0)
|
|
|
this.hasLoadedTpl = true
|
|
|
},
|
|
|
+ // 加载模板后的初始化处理
|
|
|
+ setTpl(){
|
|
|
+ if(!this.fcanvas) return
|
|
|
+ try {
|
|
|
+ // 确保所有对象都是可选的,并且控件可见
|
|
|
+ this.fcanvas.getObjects().forEach(obj => {
|
|
|
+ // 确保对象可选中和可交互
|
|
|
+ obj.set({
|
|
|
+ selectable: true,
|
|
|
+ evented: true
|
|
|
+ })
|
|
|
+ // 根据对象类型设置控件可见性(与原有逻辑保持一致)
|
|
|
+ if(obj.type === 'image' || obj.type === 'textbox' || obj.type === 'group'){
|
|
|
+ obj.setControlsVisibility({
|
|
|
+ 'mtr': false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 特殊对象处理(参考原有逻辑)
|
|
|
+ if(obj.name === 'scene'){
|
|
|
+ obj.set({
|
|
|
+ selectable: false,
|
|
|
+ delable: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(obj.name === 'subject'){
|
|
|
+ obj.set({
|
|
|
+ delable: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 确保画布尺寸正确
|
|
|
+ if(this.this_canvas){
|
|
|
+ this.fcanvas.setWidth(this.this_canvas.width)
|
|
|
+ this.fcanvas.setHeight(this.this_canvas.height)
|
|
|
+ }
|
|
|
+ // 更新图层列表
|
|
|
+ this.getLayers()
|
|
|
+ // 恢复选中状态
|
|
|
+ this.undoAfterSelectLayers()
|
|
|
+ this.fcanvas.renderAll()
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('[marketingEdit] setTpl failed', e)
|
|
|
+ }
|
|
|
+ },
|
|
|
// 初始化
|
|
|
async init() {
|
|
|
|
|
|
@@ -182,6 +227,10 @@ export default {
|
|
|
? this.this_canvas.canvas_json
|
|
|
: JSON.stringify(this.this_canvas.canvas_json)
|
|
|
this.fcanvas.loadFromJSON(jsonData, () => {
|
|
|
+ // 如果是加载模板,调用专门的初始化函数
|
|
|
+ if(this.hasLoadedTpl){
|
|
|
+ this.setTpl()
|
|
|
+ }
|
|
|
this.fcanvas.renderAll()
|
|
|
hydrateCanvas()
|
|
|
})
|
|
|
@@ -197,6 +246,7 @@ export default {
|
|
|
this.canvasForm.width = FIXED_CANVAS_WIDTH
|
|
|
this.canvasForm.height = 1024
|
|
|
this.canvasForm.bg_color = '#fff'
|
|
|
+ this.canvasForm.multi_goods_mode = ''
|
|
|
this.canvasForm.visible = true;
|
|
|
},
|
|
|
handleAdjustCanvas() {
|
|
|
@@ -206,6 +256,7 @@ export default {
|
|
|
this.canvasForm.width = FIXED_CANVAS_WIDTH
|
|
|
this.canvasForm.height = this.this_canvas.height
|
|
|
this.canvasForm.bg_color = this.this_canvas.bg_color
|
|
|
+ this.canvasForm.multi_goods_mode = this.this_canvas.multi_goods_mode || ''
|
|
|
this.canvasForm.visible = true;
|
|
|
},
|
|
|
submitCanvasInfo() {
|
|
|
@@ -221,7 +272,8 @@ export default {
|
|
|
height:this.canvasForm.height,
|
|
|
bg_color:this.canvasForm.bg_color,
|
|
|
canvas_json:'',
|
|
|
- preview:''
|
|
|
+ preview:'',
|
|
|
+ multi_goods_mode: this.canvasForm.multi_goods_mode || ''
|
|
|
})
|
|
|
const nextIndex = this.data.length - 1
|
|
|
this.$emit('update:index',nextIndex)
|
|
|
@@ -257,6 +309,7 @@ export default {
|
|
|
this.data[this.index].width = FIXED_CANVAS_WIDTH
|
|
|
this.data[this.index].height = this.canvasForm.height
|
|
|
this.data[this.index].bg_color = this.canvasForm.bg_color
|
|
|
+ this.data[this.index].multi_goods_mode = this.canvasForm.multi_goods_mode || ''
|
|
|
this.canvasForm.visible = false;
|
|
|
}
|
|
|
|
|
|
@@ -308,7 +361,8 @@ export default {
|
|
|
bg_color: item.bg_color,
|
|
|
name: item.name || '',
|
|
|
tpl_url: item.tpl_url || '',
|
|
|
- image_path: item.image_path || ''
|
|
|
+ image_path: item.image_path || '',
|
|
|
+ multi_goods_mode: item.multi_goods_mode || ''
|
|
|
}
|
|
|
}))
|
|
|
this.$emit('save', payload)
|