<template>
    <!--    版本选择    -->
    <view class="mt-[20rpx] flex items-center">
        <view class="mr-[10px] text-base">版本选择</view>
        <drop-down mode="up">
            <template #default>
                <view class="drop-down-input">
                    <text>{{ 'v' + modelValue || '请选择版本' }}</text>
                    <u-icon name="arrow-down"></u-icon>
                </view>
            </template>
            <template #menu>
                <view class="w-[554rpx]">
                    <view
                        v-for="(item, key) in versionList"
                        :key="item"
                        class="py-[14rpx] px-[30rpx]"
                        @click="emit('update:modelValue', item)"
                    >
                        {{ key }}
                    </view>
                </view>
            </template>
        </drop-down>
    </view>
</template>
<script setup lang="ts">
import { watchEffect } from 'vue'
import DropDown from '@/components/drop-down/drop-down.vue'

const emit = defineEmits<{
    (event: 'update:modelValue', value: string): void
}>()
const props = withDefaults(
    defineProps<{
        modelValue?: any
        versionList?: any
    }>(),
    {
        modelValue: '',
        versionList: []
    }
)

watchEffect(() => {
    const obj = props.versionList
    emit('update:modelValue', obj['v1'] || obj[Object.keys(obj)[0]])
})
</script>

<style scoped>
.drop-down-input {
    display: flex;
    justify-content: space-between;
    color: #888888;
    width: 554rpx;
    padding: 10rpx 14rpx;
    border: 1px solid #e5e5e5;
    border-radius: 8rpx;
}
</style>
