<template>
  <van-popup v-model:show="showPicker" position="bottom" round>
    <van-picker :columns="columns" :title="pickerTitle" show-toolbar @confirm="onConfirm" @cancel="showPicker = false" />
  </van-popup>
</template>
<script setup>
import { onMounted, ref, computed } from 'vue'

const emit = defineEmits(['confirm'])

const props = defineProps({
  options: {
    type: Object,
    default: () => ({})
  }
})

const pickerTitle = ref("请选择损失类型")


const columns = computed(() => {
  return props.options.loss || []
})

const showPicker = ref(false)

const show = () => {
  showPicker.value = true
}

const clsoe = () => {
  showPicker.value = false
}

const onConfirm = ({ selectedValues, selectedOptions }) => {

  emit('confirm', selectedOptions[0].item)
  showPicker.value = false
}


defineExpose({
  show,
  clsoe
})
</script>
<style scoped lang="scss"></style>
