<template>
  <div class="app-container">

    <el-table v-loading="loading" :data="stageDetailsList" border>
<!--      <el-table-column label="企微客户名称" align="center" prop="externalUserName"/>-->
<!--      <el-table-column label="头像" align="center" prop="avatar">-->
<!--        <template slot-scope="scope">-->
<!--          <el-popover-->
<!--            placement="right"-->
<!--            title=""-->
<!--            trigger="hover">-->
<!--            <img slot="reference" :src="scope.row.avatar" width="100px">-->
<!--            <img :src="scope.row.avatar" style="max-width: 150px;">-->
<!--          </el-popover>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="电话" align="center" prop="mobile"/>-->
      <el-table-column label="课程名称" align="center" prop="courseName" />
      <el-table-column label="课程学习开始时间" align="center" prop="studyCreateTime" width="160px"/>
      <el-table-column label="课节顺序" align="center" prop="courseSort">
        <template slot-scope="scope">
          <div v-if="scope.row.studyId">
            第{{scope.row.courseSort}}节
          </div>
        </template>
      </el-table-column>
      <el-table-column label="课节名称" align="center" prop="videoName"/>
      <el-table-column label="课节总学时 秒" align="center" prop="times"/>
      <el-table-column label="课节观看时间点 秒" align="center" prop="currentTimes"/>
      <el-table-column label="开始学习课节时间" align="center" prop="logCreateTime" width="160px"/>
      <el-table-column label="课节进度" align="center" prop="rate">
        <template slot-scope="scope">
          <div v-if="scope.row.studyId">
            {{scope.row.rate}}%
          </div>
        </template>
      </el-table-column>

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

<script>

import {getQwCrmCourseStudyDetail } from "@/api/qw/externalContactCrm";

export default {
  name: "stageDetail",
  components: { getQwCrmCourseStudyDetail},
  props:{
    stageDetailsFrom:{},
  },
  watch:{
    stageDetailsFrom:{
      handler(newVal){
        //当表单发生变化时
        this.getList(newVal)
      },
      deep:true
    }
  },
  data() {
    return {
      // 遮罩层
      loading: false,
      // 导出遮罩层
      exportLoading: false,

      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,

      // 自动打标签的日志表格数据
      stageDetailsList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        externalUserId: null,
        studyId: null,
        userId: null,
      },
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
    };
  },
  created() {
    this.getList(this.stageDetailsFrom);
  },
  methods: {
    /** 查询自动打标签的日志列表 */
    getList(row) {
      this.queryParams.externalUserId=row.externalUserId;
      this.queryParams.studyId=row.studyId;
      this.queryParams.userId=row.userId;

      getQwCrmCourseStudyDetail(this.queryParams).then(response => {
        this.stageDetailsList=response.rows
      }).finally(()=>{
        this.loading=false;
      })
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有自动打标签的日志数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.exportLoading = true;
        return getQwCrmCourseStudyDetail(queryParams);
      }).then(response => {
        this.download(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
    }
  }
};
</script>
<style scoped>

.contentx{
  height: 100%;
  background-color: #fff;
  padding: 0px 20px 20px;
  margin:0 15px;
}
.desct{
  padding-top: 20px;
  padding-bottom: 20px;
  color: #524b4a;
  font-weight: bold;
}

.spanSize{
  font-size: 15px;
  font-weight: normal;
}
.statistics-container {
  padding: 0 20px;
}
.statistic-item {
  text-align: center;
  margin-top: 5%;
}
.statistic-item h2 {
  font-size: 15px;
  margin: 0;
  font-weight: normal;
}
.statistic-item p {
  margin: 5px 0 0;
  font-size: 15px;
  color: #666;
  font-weight: normal;
}
</style>
