<!--选择组件-->

<template>
    <div class="t2">
        <!--表单提示-->
        <div v-if="item.tip" class="form-tip t3 c3 ">{{ item.tip }}</div>
        <div class="form-item clearfix">
            <label class="form-label">
                <span>{{ item.field_name }}</span>
                <span v-if="item.required" class="required-color">*</span>
            </label>
            <div @click="toggleSelectorBox" class="form-input t2" :class="{ 'is-gray': !item.value.value }">
                {{ item.value.name || item.placeholder }}
                <i class="iconfont icon-zhankaishouqijiexi"></i>
            </div>
            <!-- <div class="vtf-tip t2" @click="clearTip">{{ tipTxt }}</div> -->
        </div>
        <div v-show="isShowSelectorBox" class="form-box-content">
            <div class="form-box-top ET3">
                <span @click="toggleSelectorBox" class="form-box-top__back">
                    <i class="iconfont icon-previewleft"></i>
                    申请资料
                </span>
                {{item.placeholder}}
            </div>
            <ul class="contain-options">
                <li class="option" v-for="option in item.options" :key="option.value" @click="onSelectOption(option)">
                    <span>{{ option.name }}</span>
                    <i v-if="item.value.value === option.value" class="iconfont icon-icon-gouxuan"></i>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
import * as Utils from '../utils.js';

export default {
    props: {
        item: {
            type: Object,
            required: true
        },
        key_value: {
            type: Number,
            required: true
        },
    },
    data() {
        return {
            isShowSelectorBox: false,
        };
    },
    mounted() {
    },
    methods: {
        // 聚焦事件
        focusEvent() {
            Utils.fixedIOS12.onfocus();
        },
        toggleSelectorBox() {
            this.isShowSelectorBox = !this.isShowSelectorBox;
        },
        onSelectOption(option) {
            this.item.value = option;
            this.isShowSelectorBox = false;
        }
    }
};
</script>

<style lang="scss" scoped>
.form-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 0.88rem;
    padding: 0.24rem;
    box-sizing: border-box;
    border-radius: 0.08rem;
    border: 1px solid #dcdcdc;
    outline: none;
    &.is-gray {
        color: #C8C8C8;
    }
    i {
        color: #b2b2b2;
        font-size: 0.28rem;
    }
}
.form-box-content {
    z-index: 100;
    background-color: #fff;
    width: 100%;
    height: 100%;
    max-width: 480px;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0 auto;
    position: fixed;
    z-index: 1003;
    border-radius: 0.2rem 0.2rem 0rem 0rem;
    // max-height: 11.4rem;
    max-height: 94vh;
    overflow: auto;
    .form-box-top {
        position: relative;
        width: 100%;
        height: 1.24rem;
        line-height: 1.24rem;
        text-align: center;
        border-bottom: 0.01rem solid #f2f2f8;
        font-weight: 500;
        .form-box-top__back {
            position: absolute;
            height: 0.28rem;
            font-size: 0.28rem;
            left: 0.32rem;
            font-weight: 400;
            color: #ff8533;
            display: flex;
        }
    }
    .contain-options{
        font-size:0.28rem;
        color:#333333;
        padding: 0 0.32rem;
        padding-top: 1.24rem;
        .option {
            height: 1.04rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid #f2f2f8;
            i {
                color: #ff8533;
                font-size: 0.38rem;
            }
        }
    }
}
</style>
