<template>
  <el-dialog
    :visible.sync="dialogVisible"
    width="50%"
    style="height: 98%"
    :before-close="handleClose"
    top="5vh"
    lock-scroll
  >
    <div class="title" slot="title">
      <div class="divider"></div>
      <div class="label">{{ title }}</div>
    </div>
    <div class="dialog-content">
      <el-main style="height: 100%">
        <el-row v-if="videos.length == 1" style="height: 100%">
          <el-col :span="24" style="height: 100%" class="video-container">
            <video
              :src="videos[0]"
              style="height: auto; width: 100%"
              controls
              muted
              loop
            ></video>
          </el-col>
        </el-row>
        <el-row v-if="videos.length > 1" style="height: 100%" :gutter="16">
          <template v-for="(item, index) in videos">
            <el-col
              :span="16"
              :key="item"
              v-if="index == 0"
              style="height: 100%"
              class="video-container"
            >
              <video
                :src="videos[0]"
                style="height: auto; width: 100%"
                controls
                
                loop
              ></video>
            </el-col>
            <el-col :span="8" :key="item" v-else>
              <video
                :src="videos[index]"
                style="height: auto; width: 100%"
                 class="video-container"
                controls
                loop
              ></video>
            </el-col>
          </template>
        </el-row>
      </el-main>
      <div class="dialog-footer">
        <el-button type="primary" @click="handleClose">关闭</el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "PreviewDialog",
  components: {},
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    videos: {
      type: Array,
      default: () => [],
    },
  },
  computed: {
    dialogVisible: {
      get: function () {
        return this.visible;
      },
      set: function () {},
    },
    title() {
      return "查看视频";
    },
  },
  dicts: [],
  data() {
    return {};
  },
  async created() {
    // console.log(this.videos);
  },
  methods: {
    // 取消编辑
    cancelForm() {
      this.$emit("handleClose");
    },

    handleClose(done) {
      this.$emit("handleClose");
    },
  },
};
</script>

<style lang='scss' scoped>
.title {
  display: flex;
  margin-bottom: 16px;
  .divider {
    width: 8px;
    border-left: 4px solid #409eff;
    margin-right: 8px;
  }
  .label {
    font-weight: bold;
  }
}
.dialog-content {
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  .relate {
    flex: 1;
  }
  .dialog-footer {
    display: flex;
    justify-content: flex-end;
  }
}

.video-container {
  background-color: #000;
  display: flex;
  justify-content: center;
}
.el-dialog__body {
  padding: 0 20px 30px 20px;
}
</style>