<template>
    <div class="ht-base-transfer-tree-demo">
        <ht-base-transfer-tree v-bind="formData" @arrowChange="arrowChange"></ht-base-transfer-tree>
    </div>
</template>

<script>
  export default {
    name: 'HtBaseTransferTreeDemo',
    data(){
        return{
            formData:{
                transferTitle:['',''],
                leftNode: [
                    {
                        title: 'parent 1',
                        expand: true,
                        totalNum:7,
                        children: [
                            {
                                title: 'parent 1-1',
                                expand: true,
                                children: [
                                    {
                                        title: 'leaf 1-1-1'
                                    },
                                    {
                                        title: 'leaf 1-1-2'
                                    }
                                ]
                            },
                            {
                                title: 'parent 1-2',
                                expand: true,
                                children: [
                                    {
                                        title: 'leaf 1-2-1'
                                    },
                                    {
                                        title: 'leaf 1-2-2'
                                    }
                                ]
                            }
                        ]
                    }
                ],
                rightNode:[]
            },
        }
    },
      methods:{
          arrowChange(selectLeftNode){
              let arr=[];
              if(selectLeftNode.length>0){
                  //取值
                  selectLeftNode.forEach(item=>{
                        let rightObject={};
                        rightObject.checked=item.checked;
                        rightObject.title=item.title;
                        rightObject.nodeKey=item.nodeKey;
                        arr.push(rightObject);
                  })
                      if(this.formData.rightNode.length>0){
                          arr.forEach(k=>{
                              this.formData.rightNode.forEach(j=>{
                                  if(k.title!=j.title){
                                      this.formData.rightNode=arr;
                                   }
                              })
                          })
                      }else{
                          this.formData.rightNode=arr;
                      }
              }
          }
      }
  }
</script>
<style>
    .ht-base-transfer-tree-demo {

    }
</style>
<!--<template>-->

<!--</template>-->
<!--<script>-->

<!--</script>-->
<!--<style>-->

<!--</style>-->


