<template>
	<!-- 单列选择器 -->
	<u-select v-model="is_show" mode="single-column" :value_name="value_name" :label_name="label_name" :list="list"
		@confirm="confirm" :default-value="selectDefault"></u-select>
</template>

<script>
	export default {
		props: {
			list: {
				default () {
					return []
				}
			},
			title: {
				default () {
					return ''
				}
			},
			value_name: {
				default () {
					return 'value'
				}
			},
			label_name: {
				default () {
					return 'label'
				}
			}
		},
		data() {
			return {
				is_show: false,
				selectDefault: [0],
			}
		},
		methods: {
			show() {
				this.is_show = true
				// console.log(this.list)
			},
			hide() {
				this.is_show = false
			},
			confirm(e) {
				// console.log(e)
				// 将默认下标赋值为当前选中的下标
				this.selectDefault = [this.list.findIndex(item => item.value === e[0].value)] || [0];
				this.$emit('vacChange', e)
			}
		},
	}
</script>

<style>
</style>
