1139 lines
36 KiB
Vue
1139 lines
36 KiB
Vue
<template>
|
|
<div>
|
|
<a-modal
|
|
class="designOpenrtion_modal Guide_1_24"
|
|
v-model:visible="designOpenrtion"
|
|
:class="[driver__.driver?'hideEvents':'']"
|
|
:footer="null"
|
|
width="78%"
|
|
:maskClosable="false"
|
|
:centered="true"
|
|
:closable="false"
|
|
:keyboard="false"
|
|
:mask="true"
|
|
>
|
|
<div class="designOpenrtion_content">
|
|
<div class="design_title_text">
|
|
<div>{{ $t('DesignPrintOperation.Placement') }}</div>
|
|
</div>
|
|
<div class="design_closeIcon" @click.stop="closeModal()">
|
|
<i class="fi fi-rr-cross-small"></i>
|
|
</div>
|
|
<div class="designOpenrtion_open">
|
|
<!-- -->
|
|
<div class="print_right">
|
|
<div class="habit_Overal_Single">
|
|
<div
|
|
class="habit_Overal_Single_text"
|
|
:class="{ active: !overallSingle }"
|
|
>
|
|
{{ $t('DesignPrintOperation.Overall') }}
|
|
</div>
|
|
<a-switch v-model:checked="overallSingle" @change="setOveralSingle"/>
|
|
<div
|
|
class="habit_Overal_Single_text"
|
|
:class="{ active: overallSingle }"
|
|
>
|
|
{{ $t('DesignPrintOperation.Single') }}
|
|
</div>
|
|
</div>
|
|
<div class="print_right show_print_right Guide_1_25" :class="[driver__?.driver?'showEvents':'']">
|
|
<div v-show="!overallSingle" class="habit_System_Designer">
|
|
<div class="habit_System_Designer_text">Scale</div>
|
|
<a-slider id="system_silder"
|
|
v-model:value="systemDesignerPercentage"
|
|
@afterChange="systemDesigner"
|
|
:tip-formatter="formatter"
|
|
>
|
|
</a-slider>
|
|
</div>
|
|
<div v-show="overallSingle" @click="random" class="button_second">{{ $t('DesignPrintOperation.Random') }}</div>
|
|
<div v-show="overallSingle" class="print_input">
|
|
<input class="search_input" :placeholder="$t('DesignPrintOperation.inputContent')" type="Number" v-model="printAmount" @input="setprintAmount">
|
|
<i class="fi fi-rr-trash" @click="deletePrint"></i>
|
|
</div>
|
|
<div class="designOpenrtion_nav">
|
|
<div class="designOpenrtion_single" v-show="overallSingle" v-for="item,index in designOpenrtionList" :key="item" :class="{active:printStyleList[index]?.designOpenrtionBtn?printStyleList[index]?.designOpenrtionBtn:false}">
|
|
<img :src="item.path" @click="setpitch(item,index)">
|
|
</div>
|
|
<div class="designOpenrtion_overall" v-show="!overallSingle">
|
|
<img :src="designOpenrtionList[0].path">
|
|
</div>
|
|
</div>
|
|
<div class="subitOkPreviewBtn" @click.stop="setPreview">{{ $t('DesignPrintOperation.preview') }}</div>
|
|
<div class="subitOkPreviewBtn Guide_1_25_1" :class="[driver__.driver?'hideEvents':'']" @click.stop="setOK">OK</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="designOpenrtion_centent" id="designOpenrtionCentent">
|
|
<!-- <div class="designOpenrtion_imgMask" :style="sketch"> -->
|
|
<div class="designOpenrtion_imgMask">
|
|
<div class="designOpenrtion_print" v-show="overallSingle">
|
|
<div
|
|
v-for="item,index in designOpenrtionList"
|
|
:key="item"
|
|
:style="[printStyleList?.[index]?.style]"
|
|
@touchstart.stop="itemMoveMousedown(index,$event)"
|
|
class="modal_imgItem"
|
|
@click="setpitch(item,index)" ref="content" >
|
|
<img crossOrigin="anonymous" :src="item?.path" :style="{transform:`rotateZ(${printStyleList[index]?.transform?.rotateZ}deg)`}" class="designOpenrtion_imgItme" draggable="false">
|
|
</div>
|
|
</div>
|
|
<!-- <img v-if="overallSingle" :src="current?.layersObject?.[1]?.maskUrl" alt="" class="designOpenrtion_sketch"> -->
|
|
<img :src="current?.path" alt="" class="designOpenrtion_sketch">
|
|
<img v-show="overallSingle" :src="current?.layersObject?.[1]?.maskUrl" alt="" class="designOpenrtion_sketch_mask">
|
|
<div class="designOpenrtion_btn">
|
|
<ul v-if="overallSingle" v-for="item,index in printStyleList" :key="item" :class="{active:item?.designOpenrtionBtn?item?.designOpenrtionBtn:false}" class="designOpenrtion_Mousingle" :style="item.style" @touchstart.stop="itemMoveMousedown(index,$event)">
|
|
<li class="designOpenrtion_btn_top" @touchstart.stop="itemSizeMousedown('top',$event)"></li>
|
|
<li class="designOpenrtion_btn_bottom" @touchstart.stop="itemSizeMousedown('bottom',$event)"></li>
|
|
<li class="designOpenrtion_btn_left" @touchstart.stop="itemSizeMousedown('left',$event)"></li>
|
|
<li class="designOpenrtion_btn_right" @touchstart.stop="itemSizeMousedown('right',$event)"></li>
|
|
<li class="designOpenrtion_rotote" v-rotote.stop="[index,item.transform]"></li>
|
|
</ul>
|
|
<div v-show="!overallSingle"></div>
|
|
<ul v-if="!overallSingle" v-for="item,index in printStyleList" :key="item" :class="{active:item?.designOpenrtionBtn?item?.designOpenrtionBtn:false}" class="designOpenrtion_Mouoverall" :style="'left:'+item.style.left+';top:'+item.style.top" @touchstart.stop="itemMoveMousedown(index,$event)">
|
|
<i class="fi fi-rr-arrows animtion1"></i>
|
|
<i class="fi fi-rr-arrows animtion2"></i>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="designOpenrtion_right">
|
|
<div class="designOpenrtion_entirety_img">
|
|
<img :src="currentFullBodyView" alt="">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="mark_loading" v-show="loadingShow">
|
|
<a-spin size="large" />
|
|
</div>
|
|
</a-modal>
|
|
</div>
|
|
</template>
|
|
|
|
<script >
|
|
import { defineComponent, h,createVNode, ref ,computed, inject,nextTick} from "vue";
|
|
// import { LoadingOutlined } from "@ant-design/icons-vue";
|
|
import { useStore } from "vuex";
|
|
import { openGuide,driverObj__ } from "@/tool/guide";
|
|
import { Https } from "@/tool/https";
|
|
import { Modal,message } from 'ant-design-vue';
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
|
import { useI18n } from "vue-i18n";
|
|
export default defineComponent({
|
|
|
|
setup(prop) {
|
|
let designOpenrtion = ref(false);
|
|
let designOpenrtionList = ref([])
|
|
let driver__ = inject('driver__')
|
|
let current = inject('current')//父组件传过来的数据
|
|
let setRevocation = inject('setRevocation')//父组件传过来的数据
|
|
let overallSingle = ref(false)
|
|
let systemDesignerPercentage = ref(0)
|
|
let printAmount = ref(1)//印花数量
|
|
let printZIndex = ref(2)//印花优先级
|
|
let printStyleList = ref([{
|
|
centers:{
|
|
left:0,
|
|
top:0,
|
|
},
|
|
style:{
|
|
left:0+"px",
|
|
top:0+"px",
|
|
right:"auto",
|
|
bottom:"auto",
|
|
width:'auto',
|
|
height:'auto',
|
|
zIndex:1,
|
|
},
|
|
transform:{
|
|
scale:1,
|
|
rotateZ:0,
|
|
},
|
|
designOpenrtionBtn:false
|
|
}]);
|
|
|
|
let direction = ref('')
|
|
let imgDom = ref()
|
|
let imgDomIndex = ref(0)
|
|
let print = ref({
|
|
width:'',
|
|
height:''
|
|
})
|
|
let sketch = ref({
|
|
width:'',
|
|
height:''
|
|
})
|
|
let loadingShow = ref(false)
|
|
let currentFullBodyView = ref('')
|
|
let designItemDetailTS = ref({})
|
|
let body = ref(false)
|
|
let {t} = useI18n()
|
|
return {
|
|
designOpenrtion,
|
|
designOpenrtionList,
|
|
overallSingle,
|
|
systemDesignerPercentage,
|
|
current,
|
|
printAmount,
|
|
printZIndex,
|
|
printStyleList,
|
|
direction,//判断点击的是li那个边
|
|
imgDom,
|
|
imgDomIndex,
|
|
print,
|
|
sketch,
|
|
loadingShow,
|
|
setRevocation,
|
|
t,
|
|
driver__,
|
|
currentFullBodyView,
|
|
designItemDetailTS,
|
|
body,
|
|
};
|
|
},
|
|
data() {
|
|
return {
|
|
store: useStore(),
|
|
};
|
|
},
|
|
|
|
directives:{
|
|
//操作旋转
|
|
rotote:{
|
|
mounted(el,value){
|
|
|
|
el.addEventListener('touchstart', (e) => {
|
|
let elParent = document.getElementsByClassName('designOpenrtion_modal')[0].getElementsByClassName('modal_imgItem')[value.instance.imgDomIndex]
|
|
let mouse = true;
|
|
let angle = 0
|
|
let num = 1
|
|
let x = 0
|
|
let y = 0
|
|
num = value.instance.printStyleList[value.instance.imgDomIndex].transform.scale
|
|
angle = value.instance.printStyleList[value.instance.imgDomIndex].transform.rotateZ
|
|
// 添加鼠标按下事件监听器
|
|
el.style.transform = "translate(-50%, -50%)rotateZ("+ angle + "deg)"
|
|
// let scale = Number(elParent.firstElementChild.style.transform?.split('scale(')[1]?.split(')')[0])
|
|
// let rotateZ = Number(elParent.firstElementChild.style.transform?.split('rotateZ(')[1]?.split('deg')[0])
|
|
e.stopPropagation()
|
|
mouse = true;
|
|
var info = el.getBoundingClientRect();
|
|
let eX = info.x + info.width / 2;
|
|
let eY = info.y + info.height / 2;
|
|
let touchmove = (e) => {
|
|
if (mouse) {
|
|
let X = eX
|
|
let Y = eY
|
|
let x = e.targetTouches[0].clientX - X
|
|
let y = Y - e.targetTouches[0].clientY
|
|
angle = Math.atan2(x,y)*(180 / Math.PI)
|
|
elParent.firstElementChild.style.transform = "rotateZ("+ angle + "deg)"
|
|
el.style.transform = "translate(-50%, -50%)rotateZ("+ angle + "deg)"
|
|
}
|
|
}
|
|
document.addEventListener('touchmove', touchmove);
|
|
// 添加鼠标松开事件监听器
|
|
let touchend = () => {
|
|
value.instance.printStyleList[value.instance.imgDomIndex].transform.rotateZ = angle
|
|
mouse = false;
|
|
document.removeEventListener('touchend',touchend)
|
|
document.removeEventListener('touchmove',touchmove)
|
|
}
|
|
document.addEventListener('touchend', touchend);
|
|
});
|
|
}
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
init(){
|
|
let designItemDetail = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designItemDetail))
|
|
this.currentFullBodyView = designItemDetail.currentFullBodyView? designItemDetail.currentFullBodyView:designItemDetail.designItemUrl
|
|
if(designItemDetail.others.length == 0){
|
|
this.body = true
|
|
}
|
|
let DesignPrintOperationParent = this.$parent
|
|
this.designOpenrtion = true
|
|
this.clearModal()
|
|
this.designOpenrtionList = []
|
|
this.designOpenrtionList.push(...this.current.printObject.prints)
|
|
this.overallSingle = DesignPrintOperationParent.overallSingle
|
|
this.systemDesignerPercentage = DesignPrintOperationParent.systemDesignerPercentage
|
|
let skecth = new Image
|
|
skecth.src = this.current.path
|
|
skecth.onload=()=>{
|
|
this.sketch.width = skecth.width/10+'rem'
|
|
this.sketch.height = skecth.height/10+'rem'
|
|
}
|
|
// this.sketch = {
|
|
// width:this.current.layersObject[1].imageSize[0]/10+'rem',
|
|
// height:this.current.layersObject[1].imageSize[1]/10+'rem'
|
|
// }
|
|
let print = new Image
|
|
print.src = this.current.printObject.prints[0].path
|
|
print.onload=()=>{
|
|
this.print.width = print.width+'px'
|
|
this.print.height = print.height+'px'
|
|
this.printStyleList[0].style.width = print.width+'px'
|
|
this.printStyleList[0].style.height = print.height+'px'
|
|
this.printStyleList[0].designOpenrtionBtn = false
|
|
nextTick().then(()=>{
|
|
if(this.designOpenrtionList[0].scale){
|
|
this.designOpenrtionList.forEach((item,index)=>{
|
|
this.setTemplate(item,index)
|
|
this.printAmount = this.printStyleList.length
|
|
if (!this.overallSingle) {
|
|
this.printAmount = 1
|
|
this.setprintAmount()
|
|
}
|
|
if(this.current.printObject.ifSingle != this.overallSingle){
|
|
this.refetchTemplate(0)
|
|
}
|
|
|
|
})
|
|
}else{
|
|
this.refetchTemplate(0)
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
systemDesigner(num) {
|
|
let DesignPrintOperationParent = this.$parent
|
|
DesignPrintOperationParent.systemDesignerPercentage = num
|
|
},
|
|
formatter(value) {
|
|
return `${value*3}%`;
|
|
},
|
|
|
|
setOveralSingle(){
|
|
let DesignPrintOperationParent = this.$parent
|
|
DesignPrintOperationParent.overallSingle = this.overallSingle
|
|
if (!this.overallSingle) {
|
|
this.printAmount = 1
|
|
this.setprintAmount()
|
|
}else{
|
|
this.random()
|
|
}
|
|
},
|
|
setpitch(item,index){
|
|
this.printStyleList.forEach((v)=>{
|
|
v.designOpenrtionBtn = false
|
|
})
|
|
this.imgDomIndex = index
|
|
this.printStyleList[index].designOpenrtionBtn = true
|
|
this.printStyleList[index].style.zIndex = this.printZIndex++
|
|
},
|
|
//设置移动
|
|
itemMoveMousedown(index,event){
|
|
this.imgDomIndex = index
|
|
this.printStyleList.forEach((v)=>{
|
|
v.designOpenrtionBtn = false
|
|
})
|
|
if(!this.overallSingle){
|
|
this.imgDom = document.getElementsByClassName('designOpenrtion_modal')[0].getElementsByClassName("designOpenrtion_Mouoverall")[0]
|
|
}else{
|
|
this.imgDom = document.getElementsByClassName('designOpenrtion_modal')[0].getElementsByClassName("modal_imgItem")[this.imgDomIndex]
|
|
}
|
|
let scale = Number(this.imgDom.children[0].style.transform?.split('scale(')[1]?.split(')')[0])
|
|
let rotateZ = Number(this.imgDom.children[0].style.transform?.split('rotateZ(')[1]?.split('deg')[0])
|
|
this.printStyleList[index].designOpenrtionBtn = true
|
|
this.printStyleList[index].style.zIndex = this.printZIndex++
|
|
this.printStyleList[index].transform = {
|
|
scale:scale,
|
|
rotateZ:rotateZ,
|
|
}
|
|
let imgDomWH = this.imgDom.getBoundingClientRect()
|
|
let left = Number(this.printStyleList[index].style.left.replace(/px/g,''))
|
|
let top = Number(this.printStyleList[index].style.top.replace(/px/g,''))
|
|
this.printStyleList[index].centers.left = imgDomWH.x+event.changedTouches[0].pageX - this.imgDom.getBoundingClientRect().left-left
|
|
this.printStyleList[index].centers.top = imgDomWH.y+event.changedTouches[0].pageY - this.imgDom.getBoundingClientRect().top-top
|
|
document.addEventListener("touchend", this.touchend);
|
|
document.addEventListener("touchmove", this.moveMousemove);
|
|
},
|
|
//设置尺寸
|
|
itemSizeMousedown(direction,event){
|
|
this.direction = direction
|
|
this.imgDom = document.getElementsByClassName('designOpenrtion_modal')[0].getElementsByClassName("modal_imgItem")[this.imgDomIndex]
|
|
let scale = Number(this.imgDom.firstChild.style.transform?.split('scale(')[1]?.split(')')[0])
|
|
let rotateZ = Number(this.imgDom.firstChild.style.transform?.split('rotateZ(')[1]?.split('deg')[0])
|
|
this.printStyleList[this.imgDomIndex].designOpenrtionBtn = true
|
|
this.printStyleList[this.imgDomIndex].transform = {
|
|
scale:scale,
|
|
rotateZ:rotateZ,
|
|
}
|
|
let imgDomWH = this.imgDom.getBoundingClientRect()
|
|
let li = document.getElementsByClassName('designOpenrtion_modal')[0].getElementsByClassName("designOpenrtion_btn_top")[0].offsetWidth/2
|
|
if(this.direction == 'right' || this.direction == 'bottom'){
|
|
this.printStyleList[this.imgDomIndex].centers.left = imgDomWH.x+event.changedTouches[0].pageX - this.imgDom.getBoundingClientRect().left-li
|
|
this.printStyleList[this.imgDomIndex].centers.top = imgDomWH.y+event.changedTouches[0].pageY - this.imgDom.getBoundingClientRect().top-li
|
|
}else{
|
|
this.printStyleList[this.imgDomIndex].centers.left = imgDomWH.x+event.changedTouches[0].pageX - this.imgDom.getBoundingClientRect().left+imgDomWH.width-li
|
|
this.printStyleList[this.imgDomIndex].centers.top = imgDomWH.y+event.changedTouches[0].pageY - this.imgDom.getBoundingClientRect().top+imgDomWH.height-li
|
|
this.printStyleList[this.imgDomIndex].centers.right = this.imgDom.parentNode.offsetWidth -imgDomWH.width - this.imgDom.offsetLeft
|
|
this.printStyleList[this.imgDomIndex].centers.bottom = this.imgDom.parentNode.offsetHeight -imgDomWH.height - this.imgDom.offsetTop
|
|
}
|
|
|
|
document.addEventListener("touchend", this.sizeMouseup);
|
|
document.addEventListener("touchmove", this.sizeMousemove);
|
|
},
|
|
//鼠标移动
|
|
moveMousemove(e) {
|
|
let imgDomWH = this.imgDom.getBoundingClientRect()
|
|
let parentNode = document.getElementsByClassName('designOpenrtion_modal')[0].getElementsByClassName("designOpenrtion_imgMask")[0]
|
|
parentNode = parentNode.getBoundingClientRect()
|
|
let x = ( e.changedTouches[0].pageX - this.printStyleList[this.imgDomIndex].centers.left)+'px'
|
|
let y = ( e.changedTouches[0].pageY - this.printStyleList[this.imgDomIndex].centers.top)+'px'
|
|
this.printStyleList[this.imgDomIndex].style.left = x
|
|
this.printStyleList[this.imgDomIndex].style.top = y
|
|
if(!this.overallSingle){
|
|
if(x.replace(/px/g,'') >= parentNode.width - imgDomWH.width){
|
|
this.printStyleList[this.imgDomIndex].style.left = parentNode.width - imgDomWH.width+'px'
|
|
}
|
|
if(x.replace(/px/g,'') <= 0){
|
|
this.printStyleList[this.imgDomIndex].style.left = 0+'px'
|
|
}
|
|
if(y.replace(/px/g,'') >= parentNode.height - imgDomWH.height){
|
|
this.printStyleList[this.imgDomIndex].style.top = parentNode.height - imgDomWH.height+'px'
|
|
}
|
|
if(y.replace(/px/g,'') <= 0){
|
|
this.printStyleList[this.imgDomIndex].style.top = 0+'px'
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
sizeMousemove(e) {
|
|
let imgDomWH = this.imgDom.getBoundingClientRect()
|
|
let parentNode =this.imgDom.parentNode
|
|
let width = imgDomWH.width
|
|
let height = imgDomWH.height
|
|
let num = width/height
|
|
let num1 = height/width
|
|
let w,h
|
|
//判断移动四个边
|
|
if(this.direction == 'right'){
|
|
w = ( e.changedTouches[0].pageX -imgDomWH.left)
|
|
h = ( e.changedTouches[0].pageX - imgDomWH.left)*num
|
|
width = w+'px'
|
|
height = w*num1+'px'
|
|
}else if(this.direction == 'top'){
|
|
this.printStyleList[this.imgDomIndex].style.top = 'auto'
|
|
// this.printStyleList[this.imgDomIndex].style.left = 'auto'
|
|
// this.printStyleList[this.imgDomIndex].style.bottom = parentNode.offsetHeight -imgDomWH.height - this.imgDom.offsetTop+'px'
|
|
this.printStyleList[this.imgDomIndex].style.bottom = this.printStyleList[this.imgDomIndex].centers.bottom+'px'
|
|
w = ( e.changedTouches[0].pageX - this.printStyleList[this.imgDomIndex].centers.left)*num
|
|
h = (this.printStyleList[this.imgDomIndex].centers.top - e.changedTouches[0].pageY)
|
|
|
|
height = h+'px'
|
|
width = h*num+'px'
|
|
}else if(this.direction == 'bottom'){
|
|
h = ( e.changedTouches[0].pageY - imgDomWH.top)
|
|
height = h+'px'
|
|
width = h*num+'px'
|
|
}else if(this.direction == 'left'){
|
|
this.printStyleList[this.imgDomIndex].style.left = 'auto'
|
|
this.printStyleList[this.imgDomIndex].style.right = this.printStyleList[this.imgDomIndex].centers.right+'px'
|
|
w = (this.printStyleList[this.imgDomIndex].centers.left - e.changedTouches[0].pageX)
|
|
width = w+'px'
|
|
height = w*num1+'px'
|
|
}
|
|
//判断尺寸是否到边
|
|
this.printStyleList[this.imgDomIndex].style.width = width
|
|
this.printStyleList[this.imgDomIndex].style.height = height
|
|
},
|
|
//鼠标抬起
|
|
sizeMouseup(e){
|
|
this.printStyleList[this.imgDomIndex].style={
|
|
right:'auto',
|
|
left:this.imgDom.offsetLeft+'px',
|
|
bottom:'auto',
|
|
top:this.imgDom.offsetTop+'px',
|
|
height:this.imgDom.offsetHeight+'px',
|
|
width:this.imgDom.offsetWidth+'px',
|
|
zIndex:this.printZIndex
|
|
}
|
|
document.removeEventListener("touchend", this.sizeMouseup);
|
|
document.removeEventListener("touchmove", this.sizeMousemove);
|
|
},
|
|
touchend(e) {
|
|
|
|
document.removeEventListener("touchend", this.touchend);
|
|
document.removeEventListener("touchmove", this.moveMousemove);
|
|
},
|
|
|
|
|
|
setprintAmount(){
|
|
if(this.printAmount < 1){
|
|
this.printAmount = 1
|
|
return
|
|
}
|
|
if(this.printAmount > 20){
|
|
this.printAmount = 20
|
|
return
|
|
}
|
|
let printTiemNum
|
|
if(this.printAmount>this.printStyleList.length){
|
|
let num = this.printAmount - this.printStyleList.length
|
|
for (let index = 0; index < num; index++) {
|
|
this.printStyleList.push(JSON.parse(JSON.stringify(this.printStyleList[this.printStyleList.length-1])))
|
|
this.printStyleList[this.printStyleList.length-1].transform.rotateZ = 0
|
|
this.refetchTemplate(this.printStyleList.length-1)
|
|
this.designOpenrtionList.push(this.current.printObject.prints[this.current.printObject.prints.length-1])
|
|
}
|
|
}else{
|
|
let num = this.printStyleList.length - this.printAmount
|
|
this.designOpenrtionList.splice(this.printStyleList.length-num,num)
|
|
this.printStyleList.splice(this.printStyleList.length-num,num)
|
|
}
|
|
this.printStyleList.forEach((v)=>{
|
|
v.designOpenrtionBtn = false
|
|
})
|
|
this.printStyleList[this.printStyleList.length-1].designOpenrtionBtn = true
|
|
this.imgDomIndex = this.printStyleList.length-1
|
|
},
|
|
deletePrint(){
|
|
if(this.designOpenrtionList.length <= 1){
|
|
return
|
|
}
|
|
this.designOpenrtionList.splice(this.imgDomIndex,1)
|
|
this.printStyleList.splice(this.imgDomIndex,1)
|
|
this.printAmount = this.designOpenrtionList.length
|
|
},
|
|
random(){
|
|
this.designOpenrtionList.forEach((v,index)=>{
|
|
this.refetchTemplate(index)
|
|
})
|
|
},
|
|
//随机重置图片顺序
|
|
refetchTemplate(index) {
|
|
// let scale = (Math.trunc(Math.random()*15)+1)*.1
|
|
let rotateZ1 = Math.trunc(Math.random()*360)+1
|
|
let rotateZ2 = Math.trunc(Math.random()*360)+1
|
|
let sketch = document.getElementsByClassName("designOpenrtion_modal")[0]?.getElementsByClassName('designOpenrtion_sketch')[0]
|
|
let width
|
|
let scale
|
|
if(sketch.width<sketch.height){
|
|
width = Math.trunc(Math.random()*(sketch?.width-sketch?.width/2))+sketch?.width/4
|
|
scale = width / this.print.width.replace(/px/g,'')
|
|
}else{
|
|
width = Math.trunc(Math.random()*(sketch?.height-sketch?.height/2))+sketch?.height/4
|
|
scale = width / this.print.height.replace(/px/g,'')
|
|
}
|
|
// let x = sketch.width-Number(this.print.width.replace(/px/g,''))
|
|
// let y = sketch.height-Number(this.print.height.replace(/px/g,''))
|
|
let x = sketch?.width - this.print.width.replace(/px/g,'')*scale
|
|
if(!this.overallSingle){
|
|
x = sketch?.width - this.print.width.replace(/px/g,'')*scale/2
|
|
}
|
|
let y = sketch?.height-this.print.height.replace(/px/g,'')*scale
|
|
this.printStyleList[index]={
|
|
centers:{
|
|
left:0,
|
|
top:0,
|
|
},
|
|
style:{
|
|
left:Math.trunc(Math.random()*x)+1+"px",
|
|
top:Math.trunc(Math.random()*y)+1+"px",
|
|
right:"auto",
|
|
bottom:"auto",
|
|
width:this.print.width.replace(/px/g,'')*scale+'px',
|
|
height:this.print.height.replace(/px/g,'')*scale+'px',
|
|
zIndex:this.printZIndex++
|
|
},
|
|
transform:{
|
|
// scale:scale<.2?.2:scale,//0.2-3
|
|
// rotateZ:rotateZ1-rotateZ2,
|
|
rotateZ:this.printStyleList[index].transform.rotateZ!=0?this.printStyleList[index].transform.rotateZ:0
|
|
},
|
|
designOpenrtionBtn:false
|
|
}
|
|
},
|
|
//设置图片
|
|
setTemplate(item,index) {
|
|
this.designOpenrtionList
|
|
let sketch = document.getElementsByClassName("designOpenrtion_modal")[0]?.getElementsByClassName('designOpenrtion_sketch')[0]
|
|
let sketchNum = this.sketch.width.replace(/rem/g,'')*10/sketch.offsetWidth
|
|
let scale
|
|
scale = (this.print.width.replace(/px/g,'')*sketchNum/this.print.width.replace(/px/g,''))
|
|
let zIndex = 1
|
|
let left = item.location[0]/sketchNum+'px'
|
|
let top = item.location[1]/sketchNum+'px'
|
|
if(sketch.offsetWidth < item.location[0]/sketchNum){
|
|
left = sketch.offsetWidth +'px'
|
|
}
|
|
if(sketch.offsetHeight < item.location[1]/sketchNum){
|
|
top = sketch.offsetHeight +'px'
|
|
}
|
|
this.printStyleList[index]={
|
|
centers:{
|
|
left:0,
|
|
top:0,
|
|
},
|
|
style:{
|
|
left:left,
|
|
top:top,
|
|
right:"auto",
|
|
bottom:"auto",
|
|
width:this.print.width.replace(/px/g,'')/sketchNum*item.scale+'px',
|
|
height:this.print.height.replace(/px/g,'')/sketchNum*item.scale+'px',
|
|
zIndex:zIndex++
|
|
},
|
|
transform:{
|
|
// scale:scale<.2?.2:scale,//0.2-3
|
|
rotateZ:item.angle,
|
|
},
|
|
designOpenrtionBtn:false
|
|
}
|
|
},
|
|
computeZindex(){
|
|
let arr = JSON.parse(JSON.stringify(this.printStyleList))
|
|
arr.sort((a, b) => {
|
|
var a_num = a["style"].zIndex;
|
|
var b_num = b["style"].zIndex;
|
|
return a_num - b_num;
|
|
});
|
|
let num = 1
|
|
arr.forEach((v)=>{
|
|
v.style.zIndex = num++
|
|
})
|
|
return this.computeSize(arr)//计算单件衣服初始大小到目前大小的缩放比
|
|
},
|
|
computeSize(arr){
|
|
// let num = this.sketch/
|
|
let sketch = document.getElementsByClassName("designOpenrtion_sketch")[0]
|
|
let sketchNum = this.sketch.width.replace(/rem/g,'')*10/sketch.offsetWidth
|
|
let prints = []
|
|
let scale
|
|
let location
|
|
arr.forEach((v,index)=>{
|
|
if(!this.overallSingle){
|
|
scale = this.systemDesignerPercentage*3/100
|
|
// location = [arr[index].style.left.replace(/px/g,'')*sketchNum+this.print.width.replace(/px/g,'')/2-7,arr[index].style.top.replace(/px/g,'')*sketchNum+this.print.height.replace(/px/g,'')/2-7]
|
|
location = [arr[index].style.left.replace(/px/g,'')*sketchNum,arr[index].style.top.replace(/px/g,'')*sketchNum]
|
|
}else{
|
|
scale = (arr[index].style.width.replace(/px/g,'')*sketchNum/this.print.width.replace(/px/g,''))
|
|
location = [arr[index].style.left.replace(/px/g,'')*sketchNum,arr[index].style.top.replace(/px/g,'')*sketchNum]
|
|
}
|
|
let obj = {
|
|
angle : !this.overallSingle ? 0:arr[index].transform.rotateZ,
|
|
location : location,
|
|
priority:arr[index].style.zIndex,
|
|
scale: scale,
|
|
path:this.designOpenrtionList[index].path,
|
|
minIOPath:this.designOpenrtionList[index].minIOPath,
|
|
}
|
|
prints.push(obj)
|
|
})
|
|
return prints
|
|
},
|
|
setPreview(){
|
|
let designItemDetail = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designItemDetail))
|
|
let index
|
|
let scale = this.printStyleList[0].style.width.replace(/px/g,'')/this.print.width.replace(/px/g,'')
|
|
designItemDetail.clothes.forEach((v,ind)=>{
|
|
if(v.id == this.current.id){
|
|
index = ind
|
|
}
|
|
})
|
|
let priority = designItemDetail.clothes.map((v)=>{
|
|
return v.type
|
|
})
|
|
// let data = {
|
|
// ...designItemDetail,
|
|
// priority:priority,
|
|
// timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
// }
|
|
let data = this.store.state.DesignDetailModule.designPreviewData
|
|
data.designSingleItemDTOList[index].printObject={
|
|
ifSingle:this.overallSingle,
|
|
prints:this.computeZindex(),
|
|
}
|
|
data.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
this.loadingShow = true
|
|
Https.axiosPost(Https.httpUrls.designSingle, data).then(
|
|
(rv) => {
|
|
// designItemDetail.clothes[index].printObject.path = rv.clothes[0].printObject.path
|
|
this.currentFullBodyView = rv.currentFullBodyView
|
|
this.designItemDetailTS.rv = rv
|
|
this.designItemDetailTS.data = data
|
|
this.loadingShow = false
|
|
// this.closeModal()
|
|
if(this.driver__?.driver){
|
|
nextTick().then(()=>{
|
|
driverObj__.moveNext();
|
|
})
|
|
}
|
|
}
|
|
).catch(res=>{
|
|
this.loadingShow = false
|
|
});
|
|
},
|
|
setOK(){
|
|
let designItemDetail = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designItemDetail))
|
|
let index
|
|
designItemDetail.clothes.forEach((v,ind)=>{
|
|
if(v.id == this.current.id){
|
|
index = ind
|
|
}
|
|
})
|
|
designItemDetail.currentFullBodyView = this.designItemDetailTS.rv.currentFullBodyView
|
|
designItemDetail.clothes[index].printObject.ifSingle = this.overallSingle
|
|
designItemDetail.clothes[index].layersObject = this.designItemDetailTS.rv.clothes[index].layersObject
|
|
designItemDetail.clothes[index].printObject.prints = this.computeZindex()
|
|
designItemDetail.ifSubmit = true
|
|
designItemDetail.clothes.forEach((item,i)=>{
|
|
let a
|
|
if(item.layersObject[0].imageCategory.indexOf("back") == -1){
|
|
a = item.layersObject[0]
|
|
item.layersObject[0] = item.layersObject[1]
|
|
item.layersObject[1] = a
|
|
}
|
|
item.layersObject[0].id = this.store.state.DesignDetailModule.designItemDetail.clothes[i].layersObject[0].id
|
|
item.layersObject[1].id = this.store.state.DesignDetailModule.designItemDetail.clothes[i].layersObject[1].id
|
|
})
|
|
this.store.commit("setDesignItemDetail", designItemDetail);
|
|
this.store.commit("setDesignPreviewData", this.designItemDetailTS.data);
|
|
this.setRevocation(designItemDetail,this.designItemDetailTS.data)
|
|
this.designOpenrtion = false
|
|
if(this.driver__.driver){
|
|
driverObj__.moveNext();
|
|
}
|
|
},
|
|
clearModal(){
|
|
this.printAmount = 1//显示数量
|
|
this.designOpenrtion = true//modal页面关闭
|
|
this.printZIndex = 2//点击图片z-index
|
|
this.imgDomIndex = 0//点击图片下标
|
|
this.designOpenrtionList = []
|
|
this.printStyleList.splice(1,this.printStyleList.length-1)
|
|
this.printStyleList[0] = {
|
|
centers:{
|
|
left:0,
|
|
top:0,
|
|
},
|
|
style:{
|
|
left:0+"px",
|
|
top:0+"px",
|
|
right:"auto",
|
|
bottom:"auto",
|
|
width:'auto',
|
|
height:'auto',
|
|
zIndex:1,
|
|
},
|
|
transform:{
|
|
scale:1,
|
|
rotateZ:0,
|
|
},
|
|
designOpenrtionBtn:false
|
|
}
|
|
},
|
|
closeModal(){
|
|
let designItemDetail = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designItemDetail))
|
|
let _this = this
|
|
Modal.confirm({
|
|
title: this.t('DesignPrintOperation.jsContent1'),
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
okText: 'Yes',
|
|
cancelText: 'No',
|
|
mask:false,
|
|
centered:true,
|
|
onOk() {
|
|
_this.designOpenrtion=false
|
|
}
|
|
});
|
|
},
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style lang="less">
|
|
.designOpenrtion_modal {
|
|
// max-width: 1440px;
|
|
.mark_loading{
|
|
position: absolute;
|
|
}
|
|
.ant-modal-body{
|
|
padding: calc(4rem*1.2) calc(5rem*1.2) calc(0rem*1.2)!important;
|
|
// height: calc(65vh - 6.4rem*1.2));
|
|
height: calc(65rem*1.2);
|
|
display: flex;
|
|
overflow-y: hidden;
|
|
flex-direction: column;
|
|
}
|
|
.ant-modal-content{
|
|
border-radius: calc(1rem*1.2);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.designOpenrtion_content {
|
|
// background: #f2f3fb;
|
|
// padding-bottom: 2.9rem*1.2);
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
.designOpenrtion_header {
|
|
position: relative;
|
|
height: calc(6.6rem*1.2);
|
|
width: 100%;
|
|
background: #F7F7F7;
|
|
|
|
.placement_modal_title{
|
|
position: absolute;
|
|
height: 100%;
|
|
line-height: calc(6.6rem*1.2);
|
|
left: calc(3.7rem*1.2);
|
|
top: 0;
|
|
font-size: calc(1.8rem*1.2);
|
|
color: #030303;
|
|
}
|
|
}
|
|
|
|
.designOpenrtion_right{
|
|
height: calc(50rem*1.2);
|
|
position: absolute;
|
|
right: calc(2rem*1.2);
|
|
left: auto;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
max-height: calc(50rem*1.2);
|
|
max-width: calc(30rem*1.2);
|
|
.designOpenrtion_entirety_img{
|
|
height: 100%;
|
|
img{
|
|
max-width: 100%;
|
|
max-height: 100%;
|
|
object-fit: contain;
|
|
position: relative;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%,-50%);
|
|
}
|
|
}
|
|
}
|
|
.designOpenrtion_open{
|
|
position: absolute;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
.print_right{
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
border: 2px solid;
|
|
padding: calc(2rem*1.2) 0;
|
|
width: calc(16rem*1.2);
|
|
border-radius: calc(1rem*1.2);
|
|
height: calc(40rem*1.2);
|
|
.habit_Overal_Single {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
// margin: 2rem*1.2) 0;
|
|
transform: scale(.8);
|
|
|
|
// margin: 3rem*1.2) 0;
|
|
.habit_Overal_Single_text {
|
|
font-weight: 600;
|
|
color: rgba(0, 0, 0, 0.5);
|
|
&.active {
|
|
color: rgba(0, 0, 0, 0.7);
|
|
// font-weight: 900;
|
|
transform: scale(1.2);
|
|
}
|
|
}
|
|
.ant-switch {
|
|
margin: 0 calc(1rem*1.2);
|
|
background-color: #efefef;
|
|
}
|
|
.ant-switch-checked {
|
|
background-color: #000;
|
|
}
|
|
}
|
|
.habit_System_Designer {
|
|
transform: scale(.8);
|
|
width: 100%;
|
|
margin-top: calc(1.5rem*1.2);
|
|
.ant-slider-track,
|
|
.ant-slider-rail {
|
|
height: calc(.6rem*1.2);
|
|
background-color: #e1e1e1;
|
|
border-radius: calc(0.5rem*1.2);
|
|
}
|
|
.ant-slider .ant-slider-handle:not(.ant-tooltip-open),
|
|
.ant-slider-handle {
|
|
background-color: #2d2e76 !important;
|
|
border: none !important;
|
|
}
|
|
.ant-slider-handle:hover{
|
|
box-shadow: 0 0 0 5px rgba(45, 46, 118, 0.2);
|
|
}
|
|
.habit_System_Designer_text{
|
|
font-size: calc(1.6rem*1.2);
|
|
color: rgba(0, 0, 0, 0.7);
|
|
font-weight: 600;
|
|
}
|
|
}
|
|
.button_second{
|
|
margin: calc(1rem*1.2) 0;
|
|
width: calc(10rem*1.2);
|
|
text-align: center;
|
|
position: initial;
|
|
transform: none;
|
|
height: calc(3rem*1.2);
|
|
line-height: calc(3rem*1.2);
|
|
}
|
|
.print_input{
|
|
margin-top: calc(1rem*1.2);
|
|
width: calc(9.85rem*1.2);
|
|
display: flex;
|
|
.search_input{
|
|
width: calc(6.85rem*1.2);
|
|
margin-right: calc(1rem*1.2);
|
|
padding: 0 calc(1.5rem*1.2);
|
|
border: 2px solid #000;
|
|
font-size: calc(1.2rem*1.2);
|
|
font-weight: 400;
|
|
height: calc(3rem*1.2);
|
|
border-radius: calc(1.5rem*1.2);
|
|
&::placeholder {
|
|
color: #C2C2C2;
|
|
}
|
|
}
|
|
i{
|
|
width: calc(2rem*1.2);
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
}
|
|
.designOpenrtion_nav{
|
|
display: flex;
|
|
margin-top: calc(2rem*1.2);
|
|
flex-wrap: wrap;
|
|
width: 100%;
|
|
height: calc(12rem*1.2);
|
|
overflow-x: hidden;
|
|
justify-content: space-evenly;
|
|
&.designOpenrtion_nav::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
.active{
|
|
img{
|
|
border: 2px solid;
|
|
border-radius: 2px;
|
|
box-sizing: border-box;
|
|
}
|
|
}
|
|
.designOpenrtion_single{
|
|
width: 40%;
|
|
margin-bottom: calc(2rem*1.2);
|
|
}
|
|
img{
|
|
width: 100%;
|
|
cursor: pointer;
|
|
}
|
|
.designOpenrtion_overall{
|
|
width: 80%;
|
|
}
|
|
}
|
|
&.show_print_right{
|
|
border: none;
|
|
padding: 0;
|
|
height: auto;
|
|
}
|
|
}
|
|
}
|
|
.designOpenrtion_centent{
|
|
margin: 0 auto;
|
|
overflow: hidden;
|
|
justify-content: space-between;
|
|
position: relative;
|
|
user-select:none;
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%,-50%);
|
|
display: flex;
|
|
&.active{
|
|
flex-direction: row;
|
|
}
|
|
.designOpenrtion_imgMask{
|
|
width: auto;
|
|
height: auto;
|
|
position: relative;
|
|
>img{
|
|
z-index: 2;
|
|
position: relative;
|
|
// max-width: 100%;
|
|
// max-height: 100%;
|
|
// width: 100%;
|
|
// height: 50rem*1.2);
|
|
max-height: calc(50rem*1.2);
|
|
min-height: calc(30rem*1.2);
|
|
width: auto;
|
|
max-width: calc(60rem*1.2);
|
|
}
|
|
.designOpenrtion_sketch_mask{
|
|
z-index: 3;
|
|
position: absolute;
|
|
inset: 0;
|
|
width: 100%;
|
|
}
|
|
>div{
|
|
position: absolute;
|
|
width: 100%;
|
|
height: 100%;
|
|
top: 0;
|
|
}
|
|
}
|
|
.designOpenrtion_print{
|
|
z-index: 3;
|
|
.modal_imgItem{
|
|
position: absolute;
|
|
overflow: hidden;
|
|
top: 0;
|
|
img{
|
|
width: 100%;
|
|
height: 100%;
|
|
float: left;
|
|
user-select:none;
|
|
-webkit-user-drag: none;
|
|
}
|
|
}
|
|
}
|
|
.designOpenrtion_btn{
|
|
z-index: 3;
|
|
>div{
|
|
width: 100%;
|
|
height: 100%;
|
|
border: 2px solid rgb(20, 188, 255);
|
|
position: absolute;
|
|
}
|
|
ul{
|
|
list-style: none;
|
|
// width: 100%;
|
|
// height: 100%;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
box-sizing: border-box;
|
|
border: 2px solid rgb(20, 188, 255);
|
|
padding: 0;
|
|
-webkit-user-drag: none;
|
|
user-select:none;
|
|
opacity: 0;
|
|
margin: 0;
|
|
|
|
&.designOpenrtion_Mouoverall{
|
|
opacity: 1;
|
|
border: none;
|
|
width: calc(1.4rem*1.2);
|
|
height: calc(1.4rem*1.2);
|
|
i{
|
|
display: flex;
|
|
color: #14bcff;
|
|
}
|
|
.animtion1{
|
|
animation: anim 4s 2s linear infinite;
|
|
// animation-delay: .5;
|
|
}
|
|
.animtion2{
|
|
animation: anim 4s linear infinite;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
}
|
|
@keyframes anim{
|
|
0% {
|
|
opacity: 1;
|
|
transform: scale(1);
|
|
}
|
|
100% {
|
|
opacity: 0;
|
|
transform: scale(3);
|
|
}
|
|
}
|
|
|
|
}
|
|
li{
|
|
cursor: pointer;
|
|
// border-radius: 50%;
|
|
width: calc(1rem*1.2);
|
|
height: calc(1rem*1.2);
|
|
background-color: rgb(20, 188, 255);
|
|
position: absolute;
|
|
pointer-events: none;
|
|
}
|
|
&.active{
|
|
opacity: 1;
|
|
li{
|
|
pointer-events: auto;
|
|
}
|
|
}
|
|
.designOpenrtion_btn_top,.designOpenrtion_btn_bottom{
|
|
left: 50%;
|
|
transform: translate(-50%,-50%) ;
|
|
cursor: n-resize;
|
|
}
|
|
.designOpenrtion_btn_top{
|
|
top: 0;
|
|
}
|
|
.designOpenrtion_btn_bottom{
|
|
top: 100%;
|
|
}
|
|
.designOpenrtion_btn_left,.designOpenrtion_btn_right{
|
|
top: 50%;
|
|
transform: translate(-50%,-50%) ;
|
|
cursor: e-resize;
|
|
}
|
|
.designOpenrtion_btn_left{
|
|
left: 0;
|
|
}
|
|
.designOpenrtion_btn_right{
|
|
left: 100%;
|
|
}
|
|
.designOpenrtion_rotote{
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%,-50%);
|
|
width: 0;
|
|
height: 0;
|
|
}
|
|
.designOpenrtion_rotote::after{
|
|
position: absolute;
|
|
content: "";
|
|
background-color: #14bcff;
|
|
width: calc(.2rem*1.2);
|
|
height: calc(3rem*1.2);
|
|
left: 50%;
|
|
bottom: 0;
|
|
transform: translateX(-50%);
|
|
}
|
|
.designOpenrtion_rotote::before{
|
|
position: absolute;
|
|
content: "";
|
|
background-color: #14bcff;
|
|
top: calc(50% - 3rem*1.2);
|
|
left: 50%;
|
|
transform: translate(-50%,-50%) ;
|
|
width: calc(1.5rem*1.2);
|
|
height: calc(1.5rem*1.2);
|
|
border-radius: 50%;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
.subitOkPreviewBtn{
|
|
z-index: 2;
|
|
margin: calc(1rem*1.2) 0;
|
|
width: calc(10rem*1.2);
|
|
text-align: center;
|
|
position: initial;
|
|
transform: none;
|
|
}
|
|
}
|
|
}
|
|
</style> |