<template>
  <div :style="{height:height+'px'}" class="realVideo">
    <el-table style="width: 200px" stripe ref="table" size="medium"
              :height="tableHeight" v-loading="tableLoading" :data="dataList">
      <el-table-column  label="设备名称" prop="name" align="center"/>
      <el-table-column label="实时视频" align="center">
        <template slot-scope="scoped">
          <el-button v-if="scoped.row.liveUrl" @click="play(scoped.row)" type="primary" size="mini"
                     icon="el-icon-video-play">
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div>
    <iframe allowfullscreen="true" allowtransparency="true" v-if="liveUrl" width="100%" height="100%" :src="liveUrl" frameborder="0"/>
<!--      <dVideo style="width: 100%" v-if="liveUrl" :liveUrl="liveUrl"></dVideo>-->
    </div>
  </div>
</template>

<script>
  import inspectApi from '@/api/business/inspect'
  import dVideo from '@/components/dVideo'
  export default {
    name: "realVideo",
    data() {
      return {
        height: document.body.clientHeight - 150,
        tableHeight: document.body.clientHeight - 170,
        tableLoading: false,
        dataList: [],
        liveUrl:''
      }
    },
    mounted(){
      this.getList()
    },
    components:{dVideo},
    methods:{
      getList(){
        inspectApi.getLiveList().then(res => {
          this.dataList=res.data
        }).catch(e => {
          this.dataList=[]
        })
      },
      play(row){
        this.liveUrl=''
        this.$nextTick(function () {
          this.liveUrl = row.liveUrl
        })
      }
    }
  }
</script>

<style lang="less">
  .realVideo {
    background-color: #fff;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .12), 0 0 6px 0 rgba(0, 0, 0, .04);
    padding: 15px;
    display: flex;
    >div:first-child{
      flex: inherit;
    }
    >div:last-child{
      flex: 1;
    }
  }
</style>
