<template>
	<text class="show-real-text" @longpress="handleLongpress">{{text}}</text>
</template>

<script>
	export default {
		props: {
			real: {
				type: String | undefined,
				required: true
			},
			type: {
				type: String | Number | undefined,
				required: true
			}
		},
		data() {
			return {
				text : this.$showReal(this.type,this.real),
				timer: null,
			}
		},
		methods: {
			async handleLongpress() {
				if(this.$store.state.user.userInfo.deptId !== '369'){
					let timeId = undefined;
					this.text = this.real;
					
					const { id: belongSystemId, systemName: belongSystemName } = this.$store.state.user.belongSystem;
					
					await uni.$u.api.saveLog({ accessType : "1", belongSystemId, belongSystemName, accessBelongSystem: belongSystemName, accessContent: this.real });
					
					timeId = setTimeout(() => {
						clearTimeout(timeId);
						this.text = this.$showReal(this.type,this.real);
					}, 10000);
					uni.setClipboardData({
						data : this.real,
						showToast : false
					});
				}
			},
		},
		mounted() {
		},
	}
</script>

<style lang="scss" scoped>
	.show-real-text {
		user-select: none;
	}
</style>
