<template>
	<div class="selectImgListModal" ref="selectImgListModal">
	<a-modal
		class="selectImgList_modal generalModel"
		v-model:visible="selectImgList"
		:footer="null"
		width="50%"
		height="78rem"
		:get-container="() => $refs.selectImgListModal"
		:maskClosable="false"
		:centered="true"
		:closable="false"
		:mask="selectImgListMask"
		:keyboard="false"
		:destroyOnClose="true"
		:zIndex="1000"
	>
	<div class="generalModel_btn">
		<div class="generalModel_closeIcon" @click.stop="cancelDsign()">
			<svg width="100%" height="100%" viewBox="0 0 46 46" fill="none" xmlns="http://www.w3.org/2000/svg">
				<circle cx="23" cy="23" r="23" fill="white" fill-opacity="0.3"/>
				<rect x="32.5063" y="12" width="3" height="29" rx="1.5" transform="rotate(45 32.5063 12)" fill="white"/>
				<rect x="34.6274" y="32.5059" width="3" height="29" rx="1.5" transform="rotate(135 34.6274 32.5059)" fill="white"/>
			</svg>
		</div>
	</div>
	<div class="selectImgList_content">
		<div class="modal_title_text">
			<div>{{ $t('selectImgList.SelectImg') }}</div>
			<div class="modal_title_text_intro"></div>
		</div>
		<div class="selectImgList_content_bottom">
			<div class="content_bottom_item" v-for="item in imgList" @click="setItemSelect(item)">
				<img :src="item?.imgUrl || item?.url" alt="" :class="{active:item.isChecked}">
			</div>
		</div>
		<div class="selectImgList_ok">
			<div class="started_btn" @click="cancelDsign()">
				{{ $t('selectImgList.Clear') }}
			</div>
			<div class="started_btn" @click="setOk()">
				{{ $t('selectImgList.ok') }}
			</div>
		</div>
		
	</div>
	<div class="mark_loading" v-show="isShowMark">
		<a-spin size="large" />
	</div>
</a-modal>
</div>
</template>

<script lang="ts">
import { defineComponent,watch,createVNode, h, ref ,toRefs,computed,reactive,triggerRef, nextTick} from "vue";
import { message,Modal } from "ant-design-vue";
import { LoadingOutlined ,ExclamationCircleOutlined} from "@ant-design/icons-vue";

import { Https } from "@/tool/https";
// import domTurnImg from '@/tool/domTurnImg'
import { downloadIamge } from "@/tool/util";
import { useI18n } from "vue-i18n";
export default defineComponent({
emits:['setImgGetColor'],

setup(props,{emit}) {
	let selectImgList: any = ref(false);//弹窗
	let selectImgListMask:any = ref(false)//弹窗遮罩
	let selectImgListData:any = reactive({
		imgList:[],
		isShowMark:false,
	})
	const {t} = useI18n()
	let init = (data:any)=>{
		selectImgList.value = true
		selectImgListData.imgList = data
		// selectImgListData.selectStyleId = 'feng2'
	}
	let cleardata = ()=>{
		selectImgList.value = false
		selectImgListData.isShowMark = false
		// setParentData()
	}
	let cancelDsign = ()=>{
		cleardata()
	}
	let setOk= ()=>{
		let data = selectImgListData.imgList.filter((item:any)=>item.isChecked);
		if(data.length > 0){
			emit('setImgGetColor',data[0])
		}
		cleardata()
	}
	let setItemSelect = (item:any)=>{
		selectImgListData.imgList.forEach((item:any) => {
			item.isChecked = false
		});
		item.isChecked = true
	}
	return {
		selectImgList,
		selectImgListMask,
		...toRefs(selectImgListData),
		init,
		cancelDsign,
		setItemSelect,
		setOk,
	};
},
data() {
	return {
		// moodTemplateId: "", //模板id
		
	};
},
mounted() {
	
},
methods: {
},
});
</script>

<style lang="less" scoped>
.selectImgList_modal {
	&.generalModel{
		.ant-modal-body {
			// height: calc(55rem*1.2);
		}
	}
	
	.selectImgList_content{
		display: flex;
		flex-direction: column;
		height: 100%;
		.selectImgList_content_bottom{
			--border-color: #c4c4c4;
			display: flex;
			flex: 1;
			flex-wrap: wrap;
			align-content: flex-start;
			overflow-y: auto;
			.content_bottom_item{
				img{
					width: 16rem;
					height: 16rem;
					object-fit: contain;
					margin: 2rem;
					cursor: pointer;
				}
			}
			.content_bottom_item:nth-child(4n){
				margin-right: 0rem;
			}
			
			.content_bottom_item .active{
				opacity: .5;
				transform: scale(.8);
			}
		}
		.selectImgList_ok{
			width: 60%;
			text-align: center;
			margin: 0 auto;
			padding-top: 1rem;
			display: flex;
			justify-content: space-around;
			>div{
				width: 40%;
			}
		}
	}
	
}
</style>