<template>
  <div style="padding: 2px">
    <el-input
      class="leftInput"
      clearable
      v-model="videoName"
      placeholder="请输入视频名称"
      @clear="search"
      size="mini"/>
    <el-button size="mini" type="primary" @click="search">搜索</el-button>
    <el-tree class="leftTree" :data="data">
      <div slot-scope="{ node, data }" @dblclick="handleNodeClick(data)" style="width:100%">
        <div  style="width:100%">
          <span class="tree_span ">
           <i class=" el-icon-video-camera"/>{{data.videoName}}
          </span>
        </div>
      </div>
    </el-tree>
  </div>

</template>

<script>
import { videoInfoList } from "@/api/video/manage";
export default {
  name: "left",
  data() {
    return {
      data: [],
      videoName: "",
      params: {}
    };
  },
  created(){
    this.getVideoInfo();
  },
  methods: {
    handleNodeClick(data) {
      this.$emit('playVideo',data);
    },
    getVideoInfo(){
      videoInfoList(this.params).then(res =>{
        if(res.code == 200 && res.data){
           this.data = res.data;
        }
      })
    },
    search(){
      this.params.videoName = this.videoName;
      this.getVideoInfo();
    }
  }
}
</script>

<style scoped lang="scss">
  .leftInput{
    width: 184px;
    margin-right: 15px
  }
  .leftTree{
    margin-top: 15px;
  }

</style>
