| <template> | 
|   <ChooseInput :modelValue="inputValue" @click="handleOpen()" v-bind="$attrs"></ChooseInput> | 
|   <Popup v-model:visible="popupVisible" position="bottom"> | 
|     <Picker | 
|       :modelValue="[modelValue]" | 
|       :columns="options" | 
|       @cancel="popupVisible = false" | 
|       @confirm="handleConfirm" | 
|     ></Picker> | 
|   </Popup> | 
| </template> | 
|   | 
| <script setup lang="ts"> | 
| import ChooseInput from './ChooseInput.vue'; | 
| import { Popup, Picker } from '@nutui/nutui-taro'; | 
| import { convertOptions, ValueEnum } from 'senin-mini/utils'; | 
| import { computed, ref } from 'vue'; | 
|   | 
| defineOptions({ | 
|   name: 'ChooseInputWithPicker', | 
| }); | 
|   | 
| type Props = { | 
|   enumLabelKey?: string; | 
|   enumValueKey?: string; | 
|   valueEnum?: ValueEnum; | 
|   modelValue: string | number; | 
| }; | 
|   | 
| const props = withDefaults(defineProps<Props>(), { | 
|   enumLabelKey: 'name', | 
|   enumValueKey: 'id', | 
| }); | 
|   | 
| const emit = defineEmits<{ | 
|   (e: 'update:modelValue', val: string | number): void; | 
| }>(); | 
|   | 
| const options = computed(() => | 
|   convertOptions(props.valueEnum, props.enumLabelKey, props.enumValueKey) | 
| ); | 
|   | 
| const inputValue = computed( | 
|   () => options.value?.find((x) => x.value === props.modelValue)?.text ?? '' | 
| ); | 
|   | 
| const popupVisible = ref(false); | 
|   | 
| function handleConfirm({ selectedValue, selectedOptions }) { | 
|   emit('update:modelValue', selectedOptions[0].value); | 
|   popupVisible.value = false; | 
| } | 
|   | 
| function handleOpen() { | 
|   popupVisible.value = true; | 
| } | 
| </script> |