<!--
 * @Description: 用户画像预览对话框组件
 * @Author: liusheng
 * @Date: 2024-11-28 15:38:00
-->
<template>
	<el-dialog title="画像预览" :visible.sync="dialogVisible" width="720px"
		:before-close="handleClose" :close-on-click-modal="false"	@open="handleOpenDialog">
		<div class="user-profile-panel" ref="xxx">
			<user-profile :tagSet="renderData" mode="dynamic" />
		</div>
		<div style="text-align:center; margin-top:30px">
			<el-button size="small" @click="handleClose()">关 闭</el-button>
		</div>
	</el-dialog>
</template>

<script>
import UserProfile from '../../common/UserProfile.vue';

export default {
	name: "TagSetPreviewDlg",
	props: ['dialogVisible', 'tagSet'],
	components: {
		'user-profile': UserProfile
	},

	data() {
		return {
			renderData: {}
		}
	},

	methods: {
		/*
			生成介于两个指定数字（包括这两个数字）之间的随机整数
		*/
		getRandomInt(min, max) {
			min = Math.ceil(min); 
			max = Math.floor(max);
			return Math.floor(Math.random() * (max - min + 1)) + min;
		},

		handleOpenDialog() {
			const status = ['_NORMAL_', '_LEVEL2_', '_LEVEL3_', '_LEVEL4_']
			this.renderData = JSON.parse(JSON.stringify(this.tagSet));
			for (let tag of this.renderData.tagList) {
				let num = this.getRandomInt(0, this.renderData.maxStatus - 1);
				tag.value = '|' + status[num];
			}
		},

		handleClose() {
			this.renderData.imageFile = '';
			this.renderData.tagList = [];
			this.$emit("close");
		}
	},

	mounted() {}
}
</script>

<style scope>
.user-profile-panel {
	margin: 0 auto;
	border: 0px solid red;
}
</style>