<template>
    <div class="van-cell van-field" :class="{'van-cell--required':!!option.required}">
        <div class="van-cell__title van-field__label"><span>{{option.label}}</span></div>
        <!-- <select class="card_type"  v-model="model">
                <option v-for="(sValue) in option.columns" :selected="(option.value)==sValue.key" :key="sValue.key" :value="sValue.key">{{sValue.value}}</option>
            </select> -->
            <div @click="alertMenu" class="w100 text-left">{{model||msg}}</div>
            <van-action-sheet v-model="show">
                <van-datetime-picker
                :type="option.type"
                :title="option.label"
                :value="option.value"
                @change="change"
                @cancel="cancel"
                @confirm="confirm"
                :min-date="option.minDate"
                :max-date="option.maxDate"
                :formatter="option.formatter"
                />
             </van-action-sheet>
    </div>
</template>

<script>
export default {
    name:"myfieldDate",
    model:{
        prop:"give",
        event:'change_time'
    },
    props:{
        give:String|Number,
        option:Object
    },
    data(){
        return{
            msg: '请选择',
            show: false,
            timeValue:'',
            selectDate:''
        }
    },
    created(){
        this.model = this.option.value;
        this.$emit('change_time', this.model=="请选择"?"":this.model);
    },
    computed:{
        model:{
            get() {
                return this.give;
            },
            set(val) {
                this.$emit('change_time', val=="请选择"?"":val);
            }
        }
    },
    methods:{
        alertMenu(){
            this.show = true;
        },
        confirm(e){
            this.timeValue=EdateFormat(e,"yyyy-MM-dd")
            this.show= false;
            this.selectDate = e;
            this.model = this.timeValue||'请选择';
        },
        cancel(e){
            this.show= false;
        },
        change(o){
            // console.log(o.getValues())
            // this.timeValue = o.getValues().join('-').replace(/[^\u0000-\u00FF]/g,"")
        }
    },
}

</script>
<style scoped>
</style>