<template>
  <div>
	<a-modal
            class="designElements_modal"
            v-model:visible="designElements"
            :footer="null"
            width="78%"
            :maskClosable="false"
            :centered="true"
            :closable="false"
			:keyboard="false"
            :mask="true"
        >
            <div class="designElements_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="designElements_open">
					<!--  -->
					<div class="print_right">
						<div class="print_right show_print_right ">
							<div @click="random" class="button_second">{{ $t('DesignPrintOperation.Random') }}</div>
							<div class="designElements_nav">
								<div class="designElements_single" v-for="item,index in designElementsList" :key="item">
									<img :src="item.path" @click="setpitch(item,index)">
								</div>
								<div class="designElements_single" v-for="item,index in designSelectElementsList" :key="item">
									<img :src="item.path" @click="setpitch(item,index)">
								</div>
							</div>
							<div class="subitOkPreviewBtn" @click.stop="setPreview">{{ $t('DesignPrintOperation.preview') }}</div>
							<div class="subitOkPreviewBtn  _1"  @click.stop="setOK">OK</div>
						</div>
					</div>
				</div>
				<div class="designElements_centent" id="designElementsCentent">
					<div class="designElements_imgMask">
						<div class="designElements_print">
							<div 
								v-for="item,index in exhibitionElementsList" 
								:key="item"
								:style="[printStyleList?.[index]?.style]" 
								@mousedown.stop="itemMoveMousedown(index,getMousePosition($event,false))" @touchstart.passive="itemMoveMousedown(index,getMousePosition($event,true))"
								class="modal_imgItem" 
								ref="content" >
								<img crossOrigin="anonymous" :src="item?.path" :style="{transform:`rotateZ(${printStyleList[index]?.transform?.rotateZ}deg)`}" class="designElements_imgItme" draggable="false"> 
							</div>
						</div>
						<img :src="current?.undividedLayer?current.undividedLayer:current.path" alt="" class="designElements_sketch">
						<!-- <img :src="current?.path" alt="" class="designElements_sketch"> -->
						<div class="designElements_btn">
							<ul v-for="item,index in printStyleList" :key="item" :class="{active:item?.designElementsBtn?item?.designElementsBtn:false}" class="designElements_Mousingle" :style="item.style" @mousedown.stop="itemMoveMousedown(index,getMousePosition($event,false))" @touchstart.passive="itemMoveMousedown(index,getMousePosition($event,true))">
								<li class="designElements_btn_top" @mousedown.stop="itemSizeMousedown('top',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('top',getMousePosition($event,true))"></li>
								<li class="designElements_btn_bottom" @mousedown.stop="itemSizeMousedown('bottom',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('bottom',getMousePosition($event,true))"></li>
								<li class="designElements_btn_left" @mousedown.stop="itemSizeMousedown('left',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('left',getMousePosition($event,true))"></li>
								<li class="designElements_btn_right" @mousedown.stop="itemSizeMousedown('right',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('right',getMousePosition($event,true))"></li>
								<li class="designElements_rotote" v-rotote.stop="[index,item.transform]"></li>
								<li class="designElements_delete" @click="deletePrint">
									<img src="../../assets/images/homePage/cuowu.svg" alt="">
								</li>
							</ul>
							<div></div>
						</div>
					</div>
				</div>
				<div class="designElements_right">
					<div class="designElements_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";
import { getMousePosition } from "@/tool/mdEvent";
export default defineComponent({
	
    setup(prop) {
        let designElements = ref(false);
		let designSelectElementsList = ref([])//新增的元素
		let designElementsList = ref([])//已经存在的元素
		let exhibitionElementsList = ref([])//展示的元素
		let setOkData = ref([])
		let current = inject('current')//父组件传过来的数据
		let driver__ = inject('driver__')
        let setRevocation = inject('setRevocation')//父组件传过来的数据
		let printZIndex = ref(2)//印花优先级
        let printStyleList = ref([]);
		let currentPrintStyleList = {
			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,
			},
			designElementsBtn: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 {
            designElements,
			designSelectElementsList,
			designElementsList,
			exhibitionElementsList,
			setOkData,
			current,
			driver__,
			printZIndex,
            printStyleList,
			currentPrintStyleList,
			direction,//判断点击的是li那个边
			imgDom,
			imgDomIndex,
			print,
			sketch,
			loadingShow,
			setRevocation,
			t,
			currentFullBodyView,
			designItemDetailTS,
			body,
			getMousePosition,
        };
    },
    data() {
        return {
            store: useStore(),
        };
    },

	directives:{
		//操作旋转
		rotote:{
			mounted(el,value){
				let mousedown = function(event){
					let e = getMousePosition(event,false)
					mouseDownOperation(e)
				}

				let touchstart = function(event){
					let e = getMousePosition(event,true)
					mouseDownOperation(e)
				}
				let mouseDownOperation  = (e) => {
				let elParent = document.getElementsByClassName('designElements_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])
					mouse = true;
					var info = el.getBoundingClientRect();
					let eX = info.x + info.width / 2;
					let eY = info.y + info.height / 2;
					let mouseMove = function(event){
						let e = getMousePosition(event,false)
						mouseMoveOperation(e)
					}
					let touchmove = function(event){
						let e = getMousePosition(event,true)
						mouseMoveOperation(e)
					}
					let mouseMoveOperation = (e) => {
						if (mouse) {
							let X = eX 
							let Y = eY
							let x = e.clientX - X
							let y = Y - e.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('mousemove', mousemove);
					// 添加鼠标松开事件监听器
					let mouseup = () => {
						value.instance.printStyleList[value.instance.imgDomIndex].transform.rotateZ = angle
						mouse = false;
						document.removeEventListener('mousemove',mouseMove)
						document.removeEventListener('touchmove',touchmove)
						document.removeEventListener('mouseup',mouseup) 
						document.removeEventListener('touchend',mouseup) 
					}
					// document.addEventListener('mouseup', mouseup);
					document.addEventListener('mousemove', mouseMove);
					document.addEventListener('touchmove', touchmove);
					document.addEventListener('mouseup', mouseup);
					document.addEventListener('touchend', mouseup);
				};
				el.addEventListener('mousedown',mousedown)
				el.addEventListener('touchstart',touchstart)
			}

			},
	},
    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
			}
			this.designElements = true
			this.clearModal()
			if(this.current.trims.prints)this.exhibitionElementsList = JSON.parse(JSON.stringify(this.current.trims.prints))
			if(this.$parent.exhibitionList.elements)this.designSelectElementsList = JSON.parse(JSON.stringify(this.$parent.exhibitionList.elements))
			if(this.$parent.elementsList)this.designElementsList = JSON.parse(JSON.stringify(this.$parent.elementsList))
			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'
				skecth.remove()
			}
			if(this.exhibitionElementsList.length > 0){
				this.exhibitionElementsList.forEach((item,index)=>{
					this.setTemplate(item,index)
				})
			}else{
			}
		},
		random(){
			if(this.printStyleList.length == 0)return
			this.printStyleList.forEach((v,index)=>{
				this.refetchTemplate(index)
			})
		},
		setPrintWH(url){
			let print = new Image
			return new Promise((resolve, reject) => {
				print.onload=()=>{
					this.print.width = print.width+'px'
					this.print.height = print.height+'px'
					resolve()
					print.remove()
				}
				print.src = url
			})
		},
		async setpitch(item,index){
			await this.setPrintWH(item.path)
			this.printStyleList.forEach((v)=>{
				v.designElementsBtn = false
			})
			this.currentPrintStyleList.url = item.url
			this.printStyleList.push(JSON.parse(JSON.stringify(this.currentPrintStyleList)))
			let currentIndex = this.printStyleList.length-1
			this.exhibitionElementsList.push({
				angle:0,
				designType:item.designType,
				minIOPath:item.minIOPath,
				path:item.path,
				priority:1,
				scale:1,
				location:[0,0]
			})
			this.refetchTemplate(currentIndex)
		
			
		},
		//设置移动
		itemMoveMousedown(index,event){
			if (event.target.tagName === 'IMG' || event.target.nodeName === 'IMG')return
			this.imgDomIndex = index
			this.printStyleList.forEach((v)=>{
				v.designElementsBtn = false
			})
			this.imgDom = document.getElementsByClassName('designElements_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].designElementsBtn = true
			this.printStyleList[index].style.zIndex = this.printZIndex++
			this.printStyleList[index].transform = {
				scale:scale,
				rotateZ:rotateZ?rotateZ:0,
			}
			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.offsetX-left
			this.printStyleList[index].centers.top = imgDomWH.y+event.offsetY-top
			// document.addEventListener("mouseup", this.mouseup);
			// document.addEventListener("mousemove", this.moveMousemove);
			document.addEventListener('mousemove', this.mouseMove);
			document.addEventListener('touchmove', this.touchmove);
			document.addEventListener('mouseup', this.mouseup);
			document.addEventListener('touchend', this.mouseup);
		},
		//设置尺寸
		itemSizeMousedown(direction,event){
			this.direction = direction
			this.imgDom = document.getElementsByClassName('designElements_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].designElementsBtn = true
			this.printStyleList[this.imgDomIndex].transform = {
				scale:scale,
				rotateZ:rotateZ,
			}
			let imgDomWH = this.imgDom.getBoundingClientRect()
			let li = document.getElementsByClassName('designElements_modal')[0].getElementsByClassName("designElements_btn_top")[0].offsetWidth/2
			if(this.direction == 'right' || this.direction == 'bottom'){
				this.printStyleList[this.imgDomIndex].centers.left = imgDomWH.x+event.offsetX-li
				this.printStyleList[this.imgDomIndex].centers.top = imgDomWH.y+event.offsetY-li
			}else{
				this.printStyleList[this.imgDomIndex].centers.left = imgDomWH.x+event.offsetX+imgDomWH.width-li
				this.printStyleList[this.imgDomIndex].centers.top = imgDomWH.y+event.offsetY+imgDomWH.height-li
			}
			
			// document.addEventListener("mouseup", this.sizeMouseup);
			// document.addEventListener("mousemove", this.sizeMousemove);
			document.addEventListener('mousemove', this.sizeMouseMove);
			document.addEventListener('touchmove', this.sizeTouchmove);
			document.addEventListener('mouseup', this.sizeMouseup);
			document.addEventListener('touchend', this.sizeMouseup);
		},
		mouseMove(event){
			let e = getMousePosition(event,false)
			this.mouseMoveOperation(e)
		},
		touchmove(event){
			let e = getMousePosition(event,true)
			this.mouseMoveOperation(e)
		},
		//鼠标移动
		mouseMoveOperation(e) {
			let imgDomWH = this.imgDom.getBoundingClientRect()
			let parentNode = document.getElementsByClassName('designElements_modal')[0].getElementsByClassName("designElements_imgMask")[0]
			parentNode = parentNode.getBoundingClientRect()
			let x = (e.clientX - this.printStyleList[this.imgDomIndex].centers.left)+'px'
			let y = ( e.clientY - this.printStyleList[this.imgDomIndex].centers.top)+'px'
			this.printStyleList[this.imgDomIndex].style.left = x
			this.printStyleList[this.imgDomIndex].style.top = y
			
		
		},
		sizeMouseMove(event){
			let e = getMousePosition(event,false)
			this.sizeMouseMoveOperation(e)
		},
		sizeTouchmove(event){
			let e = getMousePosition(event,true)
			this.sizeMouseMoveOperation(e)
		},
		sizeMouseMoveOperation(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.clientX - this.printStyleList[this.imgDomIndex].centers.left)
				h = (e.clientX - this.printStyleList[this.imgDomIndex].centers.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'
				w = (e.clientX - this.printStyleList[this.imgDomIndex].centers.left)*num
				h = (this.printStyleList[this.imgDomIndex].centers.top - e.clientY)
				
				height = h+'px'
				width = h*num+'px'
			}else if(this.direction == 'bottom'){
				h = (e.clientY - this.printStyleList[this.imgDomIndex].centers.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 = parentNode.offsetWidth -imgDomWH.width - this.imgDom.offsetLeft+'px'
				w = (this.printStyleList[this.imgDomIndex].centers.left - e.clientX)
				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("mouseup", this.sizeMouseup);
			// document.removeEventListener("mousemove", this.sizeMousemove);
			document.removeEventListener('mousemove',this.sizeMouseMove)
			document.removeEventListener('touchmove',this.sizeTouchmove)
			document.removeEventListener('mouseup',this.sizeMouseup) 
			document.removeEventListener('touchend',this.sizeMouseup) 
		},
		mouseup(e) {

			// document.removeEventListener("mouseup", this.mouseup);
			// document.removeEventListener("mousemove", this.moveMousemove);
			document.removeEventListener('mousemove',this.mouseMove)
			document.removeEventListener('touchmove',this.touchmove)
			document.removeEventListener('mouseup',this.mouseup) 
			document.removeEventListener('touchend',this.mouseup) 
		},
		deletePrint(){
			this.exhibitionElementsList.splice(this.imgDomIndex,1)
			this.printStyleList.splice(this.imgDomIndex,1)
		},
		
        //随机重置图片顺序
        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("designElements_modal")[0]?.getElementsByClassName('designElements_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 
			let y = sketch?.height-this.print.height.replace(/px/g,'')*scale
			this.printStyleList[index].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++
			}
			this.printStyleList[index].transform = {
				rotateZ:this.printStyleList[index].transform.rotateZ?this.printStyleList[index].transform.rotateZ:0
			}
        },
		//设置图片
       async setTemplate(item,index) {
			await this.setPrintWH(item.path)
			this.designSelectElementsList
			let sketch = document.getElementsByClassName("designElements_modal")[0]?.getElementsByClassName('designElements_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,
				},
				designElementsBtn:false
			}
        },
		computeZindex(resolve,prints){
			prints.sort((a, b) => {
				var a_num = a.priority;
				var b_num = b.priority;
				return a_num - b_num;
			});
			let num = 1
			prints.forEach((v)=>{
				v.priority = num++
			})
			resolve(prints)
			// return this.computeSize(arr)//计算单件衣服初始大小到目前大小的缩放比
		},
		computeSize(){
			// let num = this.sketch/
			return new Promise(async (resolve, reject) => {
				let arr = JSON.parse(JSON.stringify(this.printStyleList))
				let sketch = document.getElementsByClassName("designElements_sketch")[0]
				let sketchNum = this.sketch.width.replace(/rem/g,'')*10/sketch.offsetWidth
				let prints = []
				let scale
				let location
				for (let index = 0; index < arr.length; index++) {
					await this.setPrintWH(this.exhibitionElementsList[index].path)
					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 : arr[index].transform.rotateZ,
						location : location,
						priority:arr[index].style.zIndex,
						scale: scale,
						designType:this.exhibitionElementsList[index].designType,
						path:this.exhibitionElementsList[index].path,
						minIOPath:this.exhibitionElementsList[index].minIOPath,
					}
					prints.push(obj)
				}
				this.computeZindex(resolve,prints)
			})
		},
		async setPreview(){
			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
				}
			})
			// let data = {
            //     ...designItemDetail,
            //     priority:priority,
            //     timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,
            // }
			await this.computeSize().then((rv)=>{
				this.setOkData = rv
			})
			let data = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designPreviewData))
			data.designSingleItemDTOList[index].trims.prints = this.setOkData
			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.designElements = false
					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
				}
			})
			if(this.designItemDetailTS.rv){
				designItemDetail.currentFullBodyView = this.designItemDetailTS.rv.currentFullBodyView
				designItemDetail.clothes[index].layersObject = this.designItemDetailTS.rv.clothes[index].layersObject
				designItemDetail.clothes[index].printObject = this.designItemDetailTS.rv.clothes[index].printObject
				designItemDetail.clothes[index].trims.prints = this.setOkData
				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.designItemDetailTS = {}
			}
			this.$parent.elementsList = JSON.parse(JSON.stringify(this.designElementsList))

			this.designElements = false
			if(this.driver__.driver){
				driverObj__.moveNext();
			}
		},
		clearModal(){
			this.designElements = true//modal页面关闭
			this.printZIndex = 2//点击图片z-index
			this.imgDomIndex = 0//点击图片下标
			this.designSelectElementsList = []
			this.printStyleList = []
			this.designElementsList = []
			this.exhibitionElementsList = []
		},
		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.designElements=false
                }
            });
		},
    },
});
</script>

<style lang="less">
.designElements_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;
	}

    .designElements_content {
        // background: #f2f3fb;
        // padding-bottom: 2.9rem*1.2);
		display: flex;
		flex-direction: column;
		height: 100%;
        .designElements_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;
            }
        }

		.designElements_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);
			.designElements_entirety_img{
				height: 100%;
				img{
					max-width: 100%;
					max-height: 100%;
					object-fit: contain;
					position: relative;
					top: 50%;
					left: 50%;
					transform: translate(-50%,-50%);
				}
			}
		}
		.designElements_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);
				.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);
				}
				.designElements_nav{
					display: flex;
					margin-top: calc(2rem*1.2);
					flex-wrap: wrap;
					width: 100%;
					height: calc(22rem*1.2);
					overflow-x: hidden;
					justify-content: space-evenly;
					align-content: flex-start;
					&.designElements_nav::-webkit-scrollbar {
						display: none;
					}
					.active{
						img{
							border: 2px solid;
							border-radius: 2px;
							box-sizing: border-box;
						}
					}
					.designElements_single{
						width: 40%;
						margin-bottom: calc(2rem*1.2);
					}
					img{
						width: 100%;
						cursor: pointer;
					}
				}
				&.show_print_right{
					border: none;
					padding: 0;
					height: 100%;
				}
			}
		}
		.designElements_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;
			}
			.designElements_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);
				}
				.designElements_sketch_mask{
					z-index: 3;
					position: absolute;
					inset: 0;
					width: 100%;
				}
				>div{
					position: absolute;
					width: 100%;
					height: 100%;
					top: 0;
				}
			}
			.designElements_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;
					}
				}
			}
			.designElements_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;
				
					&.designElements_Mouoverall{
						opacity: 1;
						border: none;
						width: calc(1.4rem*1.2);
						height: calc(1.4rem*1.2);
						i{
							display: flex;
							color: #14bcff;
						}

					}
					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;
						}
					}
					.designElements_btn_top,.designElements_btn_bottom{
						left: 50%;
						transform: translate(-50%,-50%) ;
						cursor: n-resize;
					}
					.designElements_btn_top{
						top: 0;
					}
					.designElements_btn_bottom{
						top: 100%;
					}
					.designElements_btn_left,.designElements_btn_right{
						top: 50%;
						transform: translate(-50%,-50%) ;
						cursor: e-resize;
					}
					.designElements_btn_left{
						left: 0;
					}
					.designElements_btn_right{
						left: 100%;
					}
					.designElements_rotote{
						top: 50%;
						left: 50%;
						transform: translate(-50%,-50%);
						width: 0;
						height: 0;
					}
					.designElements_delete{
						position: absolute;
						top: 0;
						right: 0;
						width: 2.5rem;
						background: none;
						transform: translate(100%, -100%);
						height: 2.5rem;
						img{
							width: 100%;
							height: 100%;
						}
					}
					.designElements_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%);
					}
					.designElements_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>