<template>
  <div>
    <el-table border v-loading="loading" :data="courseStudyList" >
      <el-table-column label="课程id" align="center" prop="courseId" />
      <el-table-column label="课程名称" align="center" prop="courseName"/>
      <el-table-column label="课程封面" align="center" prop="imgUrl">
        <template slot-scope="scope">
          <el-image
            v-if="scope.row.imgUrl"
            style="width: 100px; height: 100px"
            :src="scope.row.imgUrl"
            fit="contain"
            @click="openImageViewer(scope.row.imgUrl)"/>
        </template>
      </el-table-column>
      <el-table-column label="视频名称" align="center" prop="videoName" />
<!--      <el-table-column label="状态" align="center" prop="status" >-->
<!--        <template slot-scope="scope">-->
<!--          <el-tag>{{scope.row.status == 1 ? '已观看' : '未观看'}}</el-tag>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="总时长(秒)" align="center" prop="times" />
      <el-table-column label="观看进度" align="center" prop="progress" >
        <template slot-scope="scope">
          <span>{{scope.row.progress}}%</span>
        </template>
      </el-table-column>
      <el-table-column label="当前观看时间点(秒)" align="center" prop="currentTimes" />
      <el-table-column label="观看时间" align="center" prop="studyTime" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 大图预览对话框 -->
    <el-dialog
      :visible.sync="dialogVisible"
      :modal="false"
      width="1200"
      append-to-body>
      <img
        :src="this.dialogImageUrl"
        style="display: block; max-width: 100%; margin: 0 auto"
      />
    </el-dialog>
  </div>
</template>

<script>
import {
  getCourseStudyList,
} from '@/api/qw/externalContact'
export default {

  name: "courseStudyList",
  data() {
    return {
      userId:null,

      //放大图片
      dialogImageUrl:null,
      dialogVisible:false,

      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 跟进表格数据
      courseStudyList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
      },
    };
  },
  created() {

  },
  methods: {
    getData(userId){
      this.queryParams.userId=userId;
      this.queryParams.pageNum=1;
      this.getList();
    },
    getList() {
      this.loading = true;
      getCourseStudyList(this.queryParams).then(response => {

        this.courseStudyList = response.rows;
        console.log("this.courseStudyList",this.courseStudyList);
        this.total = response.total;
        this.loading = false;
      });
    },

    openImageViewer(url) {
      // 打开大图预览对话框
      this.dialogImageUrl=url
      this.dialogVisible = true;
    },
  }
};
</script>
<style lang="scss" scoped>
</style>
