<script setup>
import {edbUnitOpts} from '../util/config'

const unitOpts=edbUnitOpts.map(item=>{return{text:item,value:item}})

const props=defineProps({
    show:{
        type:Boolean,
        default:false
    },
})

const emits=defineEmits(['update:show','select'])

function handleClose(){
    emits('update:show',false)
}
function onConfirmSelectUnit(e){
    const value=e.selectedValues[0]
    emits('select',value)
    handleClose()
}

</script>

<template>
    <van-popup 
        :show="props.show" 
        round 
        position="bottom"
    >
        <van-picker
            title="选择单位"
            :columns="unitOpts"
            @cancel="handleClose"
            @confirm="onConfirmSelectUnit"
        />
    </van-popup>
</template>