<template>
	<view class="types">
		<block v-for="(item,index) in types" :key="index">
			<block v-if="values.includes(item.dictValue)">
				<view :class="getStatusClass(item.dictValue)">
					<text class="status-text">{{item.dictLabel}}</text>
				</view>
			</block>
		</block>
	</view>
</template>

<script>
	export default {
		name: "dict-type",
		props: ['types', 'type'],
		computed: {
			values() {
				if (this.type !== null && typeof this.type !== 'undefined') {
					return Array.isArray(this.type) ? this.type : [String(this.type)];
				} else {
					return [];
				}
			},
		},
		data() {
			return {

			};
		},
		methods: {
			getStatusClass(dictValue) {
				switch (dictValue) {
					case '0':
						return 'status primary';
					case '1':
						return 'status success';
					case '6':
						return 'status success';
					case '11':
						return 'status refuse';
					case '14':
						return 'status gray';
					default:
						return 'status warn';
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.status {
		position: relative;
		padding: 5px 10px;
		border-radius: 0 8px 0 8px;
		position: absolute;
		top: 0px;
		right: 0px;

		&.primary {
			background-color: #E8F4FF;
			color: #1890FF;
			border: 1px solid #1890FF;
		}

		&.success {
			background-color: #E7FAF0;
			color: #71E2A3;
			border: 1px solid #71E2A3;
		}

		&.warn {
			background-color: #FFF8E6;
			color: #FFBA00;
			border: 1px solid #FFBA00;
		}

		&.refuse {
			background-color: #FFEDED;
			color: #FF9292;
			border: 1px solid #FFDBDB;
		}

		&.gray {
			background-color: #f4f4f5;
			border: 1px solid #e9e9eb;
			color: #909399;
		}
	}
</style>