|
|
@@ -72,6 +72,7 @@ export default {
|
|
|
color:"#fff",
|
|
|
bg_color:'#fff',
|
|
|
visible:false,
|
|
|
+ canvas_type: 'normal', // normal:普通画布 model:模特图 scene:场景图
|
|
|
multi_goods_mode: '', // 多货号模式:''(默认单货号), 'single'(一个货号多角度), 'multiple'(多个货号同角度)
|
|
|
max_goods_count: null, // 多货号模式下,最多可追加多少个货号
|
|
|
}
|
|
|
@@ -90,6 +91,25 @@ export default {
|
|
|
watch: {
|
|
|
index(newValue, oldValue) {
|
|
|
if (this.isEmpty) return
|
|
|
+ const target = this.data[newValue]
|
|
|
+ // 模特图/场景图不进入编辑,自动跳到下一个普通画布
|
|
|
+ if(target && (target.canvas_type === 'model' || target.canvas_type === 'scene')){
|
|
|
+ let nextIdx = -1
|
|
|
+ for(let i = newValue + 1; i < this.data.length; i++){
|
|
|
+ if(this.data[i].canvas_type !== 'model' && this.data[i].canvas_type !== 'scene'){
|
|
|
+ nextIdx = i; break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(nextIdx === -1){
|
|
|
+ for(let i = newValue - 1; i >= 0; i--){
|
|
|
+ if(this.data[i].canvas_type !== 'model' && this.data[i].canvas_type !== 'scene'){
|
|
|
+ nextIdx = i; break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$emit('update:index', nextIdx === -1 ? oldValue : nextIdx)
|
|
|
+ return
|
|
|
+ }
|
|
|
this.saveCanvasSnapshot(oldValue)
|
|
|
this.destroyCanvasInstance()
|
|
|
this.$nextTick(() => {
|
|
|
@@ -111,7 +131,11 @@ export default {
|
|
|
methods: {
|
|
|
loadTemplate(){
|
|
|
if(this.hasLoadedTpl) return
|
|
|
- this.data.splice(0, this.data.length, ...JSON.parse(JSON.stringify(canvas)))
|
|
|
+ const tplData = JSON.parse(JSON.stringify(canvas)).map(item => ({
|
|
|
+ canvas_type: item.canvas_type || 'normal',
|
|
|
+ ...item,
|
|
|
+ }))
|
|
|
+ this.data.splice(0, this.data.length, ...tplData)
|
|
|
this.$emit('update:index', 0)
|
|
|
this.hasLoadedTpl = true
|
|
|
},
|
|
|
@@ -169,17 +193,12 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- //画布下不存在模板OSS地址
|
|
|
- if(!this.this_canvas){
|
|
|
- this.$emit('update:index', 0)
|
|
|
- return;
|
|
|
+ // 模特图/场景图不初始化 fabric,直接跳过
|
|
|
+ const canvasType = this.this_canvas?.canvas_type || 'normal'
|
|
|
+ if (canvasType === 'model' || canvasType === 'scene') {
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if(this.this_canvas.tpl_url){
|
|
|
- return;
|
|
|
- }*/
|
|
|
this.$emit('canvasStyle:update',{
|
|
|
width: this.this_canvas.width,
|
|
|
height: this.this_canvas.height
|
|
|
@@ -232,6 +251,7 @@ export default {
|
|
|
this.canvasForm.width = FIXED_CANVAS_WIDTH
|
|
|
this.canvasForm.height = 1024
|
|
|
this.canvasForm.bg_color = '#fff'
|
|
|
+ this.canvasForm.canvas_type = 'normal'
|
|
|
this.canvasForm.multi_goods_mode = ''
|
|
|
this.canvasForm.max_goods_count = null
|
|
|
this.canvasForm.visible = true;
|
|
|
@@ -243,10 +263,21 @@ 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.canvas_type = this.this_canvas.canvas_type || 'normal'
|
|
|
this.canvasForm.multi_goods_mode = this.this_canvas.multi_goods_mode || ''
|
|
|
this.canvasForm.max_goods_count = this.this_canvas.max_goods_count || null
|
|
|
this.canvasForm.visible = true;
|
|
|
},
|
|
|
+ handleCanvasTypeChange(type){
|
|
|
+ if(this.canvasForm.type !== 'add') return
|
|
|
+ if(type === 'model'){
|
|
|
+ this.canvasForm.name = '模特图'
|
|
|
+ }else if(type === 'scene'){
|
|
|
+ this.canvasForm.name = '场景图'
|
|
|
+ }else if(!this.canvasForm.name || this.canvasForm.name === '模特图' || this.canvasForm.name === '场景图'){
|
|
|
+ this.canvasForm.name = '画布_'+new Date().getTime().toString().substr(8)+Math.round(100)
|
|
|
+ }
|
|
|
+ },
|
|
|
submitCanvasInfo() {
|
|
|
// 假设 this.canvasForm 包含最新的 width, height 和 color
|
|
|
|
|
|
@@ -259,6 +290,7 @@ export default {
|
|
|
width:FIXED_CANVAS_WIDTH,
|
|
|
height:this.canvasForm.height,
|
|
|
bg_color:this.canvasForm.bg_color,
|
|
|
+ canvas_type: this.canvasForm.canvas_type || 'normal',
|
|
|
canvas_json:'',
|
|
|
preview:'',
|
|
|
multi_goods_mode: this.canvasForm.multi_goods_mode || '',
|
|
|
@@ -331,6 +363,7 @@ export default {
|
|
|
this.data[this.index].width = FIXED_CANVAS_WIDTH
|
|
|
this.data[this.index].height = newHeight
|
|
|
this.data[this.index].bg_color = this.canvasForm.bg_color
|
|
|
+ this.data[this.index].canvas_type = this.canvasForm.canvas_type || 'normal'
|
|
|
this.data[this.index].multi_goods_mode = this.canvasForm.multi_goods_mode || ''
|
|
|
this.data[this.index].max_goods_count = this.canvasForm.multi_goods_mode ? (this.canvasForm.max_goods_count || null) : null
|
|
|
this.canvasForm.visible = false;
|
|
|
@@ -410,7 +443,7 @@ export default {
|
|
|
// 计算目标元素相对于滚动容器的位置
|
|
|
const containerRect = scrollContainer.getBoundingClientRect()
|
|
|
const targetRect = target.getBoundingClientRect()
|
|
|
-
|
|
|
+
|
|
|
// 计算需要滚动的距离(目标元素顶部 - 容器顶部 - 导航栏高度100px)
|
|
|
const scrollTop = scrollContainer.scrollTop
|
|
|
const targetPosition = scrollTop + (targetRect.top - containerRect.top) - 100
|
|
|
@@ -434,6 +467,17 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
canvasBodyStyle(item){
|
|
|
+ const canvasType = item?.canvas_type || 'normal'
|
|
|
+ // 模特图 / 场景图:保持方形显示
|
|
|
+ if(canvasType === 'model' || canvasType === 'scene'){
|
|
|
+ return {
|
|
|
+ width: `${FIXED_CANVAS_WIDTH}px`,
|
|
|
+ height: `${FIXED_CANVAS_WIDTH}px`,
|
|
|
+ lineHeight: `${FIXED_CANVAS_WIDTH}px`,
|
|
|
+ margin: '0 auto'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 普通画布
|
|
|
const height = Number(item?.height)
|
|
|
const width = Number(item?.width) || FIXED_CANVAS_WIDTH
|
|
|
const style = {
|
|
|
@@ -760,3 +804,7 @@ export default {
|
|
|
|
|
|
|
|
|
</style>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|