<template>
	<a-modal
		class="selectImgList_modal generalModel"
		v-model:visible="selectImgList"
		:footer="null"
		width="50%"
		:maskClosable="false"
		:centered="true"
		:closable="false"
		:mask="selectImgListMask"
		:keyboard="false"
		:destroyOnClose="true"
		:zIndex="1050"
	>
	<div class="generalModel_btn">
		<div class="generalModel_closeIcon" @click.stop="cancelDsign()">
			<i class="fi fi-rr-cross-small"></i>
		</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" 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()">
				OK
			</div>
		</div>
		
	</div>
	<div class="mark_loading" v-show="isShowMark">
		<a-spin size="large" />
	</div>
</a-modal>
</template>

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

import { Https } from "@/tool/https";
import { getCookie,setCookie } from "@/tool/cookie";
// 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">
.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>