<style lang="scss">
 @import '../style/style.scss';
    .sub{
        .el-input{
            width: 300px !important;
        }
    }
</style>

<template>  
    <el-cascader-multi v-model="value2" :data="data" @change="valChange" value="value2"> </el-cascader-multi>
</template>   
<script>
export default {
    data(){
        return{
            data:[],
            checkList:[[1,32,38]],
            value1:[],
            props2:{
                label:'name',
                checkStrictly:true,
                value:'id'
            },
            // value2:[[1,32,38]],
            props1:{
                label:'name',
                checkStrictly:true,
                value:'name'
            }
        }
    },
    props: {
        subvalue:'',
        subject_id:'',
        value2:{
                    type:Array,
                    default:[]
                }
    },
    methods:{
        getData(type){
            this.$api.getSubList().then(res=>{
                let data=res.data.data;
                if(this.subject_id){
                    for(let i=0;i<data.length;i++){
                        if(data[i].id == this.subject_id){
                            this.data=data[i].children
                        }
                    }
                }else{
                    this.data=res.data.data
                }
                // this.value2 = [[1,32,38]]              
          })
        },
        handleChange(value) {
            var id='',that=this;
            if(value.length>=3&&isNaN(value[0])){
                var item1=this.data.filter(item=>item.name==value[0]),
                    item2=item1[0].children.filter(item=>item.name==value[1]),
                    item3=item2[0].children.filter(item=>item.name==value[2])
                    id=item3[0].id;
            }
            setTimeout(function(){
                let values=document.querySelector('.el-input__inner').value;
                let items=values.split(' / ');
                console.log(values)
                that.$emit('subChange',items,id,value)
            },100)
            
            
        }
    },
    created(){
        this.getData()
        console.log(this.value2)
    }
}
</script>