
import tabData from '../data/tab';

import globalEvent from "$utils/tool/globalEvent";

export default <LibMixins>{

    data(){
        return {
            tabData,
            vValue:false,
            vDraw:false
        }
    },

    watch:{
        value:{
            handler(){
                return this.setValue(this.value);
            },
            immediate:true
        }
    },

    methods:{

        setValue(value){
            if (this.vValue !== value) {
                this.vValue = value;

                if (value) {
                    globalEvent.on('search-modal',()=> this.setValue(false));

                    if (!this.vDraw) {
                        this.vDraw = true;
                    }

                } else {
                    globalEvent.off('search-modal');
                }

                if (this.value !== value) {
                    return this.$emit('update:value',value);
                }
            }

        }

    },

    beforeUnmount(){
        return globalEvent.off('search-modal');
    }

}