<!--
 * @Descripttion: 字典选择器
 * @version: 1.1
 * @Author: sakuya
 * @Date: 2021年8月3日15:53:37
 * @LastEditors: sakuya
 * @LastEditTime: 2023年2月23日15:17:24
-->

<template>
	<div class="sc-select">
		<el-select v-bind="$attrs">
			<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
				<slot name="option" :data="item"></slot>
			</el-option>
		</el-select>
	</div>
</template>

<script>
	export default {
		props: {
			dic: { type: String, default: "" }
		},

		data() {
			return {
				dicParams: {
					page: 0,
					size: 999,
					dictName: this.dic
				},
				options: []
			}
		},

		created() {
			this.getRemoteData();
		},

		methods: {
			// 获取数据
			async getRemoteData() {
				const res = await this.$API.system.dictDetail.get(this.dicParams);
				this.options = res.content;
			}
		}
	}
</script>

<style scoped>
.sc-select {
  width: 100%;
}
</style>