<template>
  <div>
    <div class="app-container">
      <div class="level-title">
        <h1>学习进度</h1>
      </div>
      <el-table
        v-loading="listLoading"
        ref="multipleTable"
        :data="varList"
        :header-cell-style="{
          'font-weight': 'bold',
          'color': '#000'
        }"
        :row-key="getRowKey"
        tooltip-effect="dark"
        border
        fit
        highlight-current-row
      >
        <el-table-column prop="COURSEWARENAME" label="资料名称" />
        <el-table-column prop="CLASSHOUR" label="总学习时长(分钟)" />
        <el-table-column prop="RESOURCETIME" label="已学习时长(分钟)" >
          <template slot-scope="{row}">
            <template v-if="row.COURSEWARETYPE =='2'">
              {{ row.RESOURCETIME?Number(row.RESOURCETIME).toFixed(2) :'0' }}
            </template>
            <template v-if="row.COURSEWARETYPE =='1'">
              {{ row.RESOURCETIME?Number(row.RESOURCETIME/60).toFixed(2) :'0' }}
            </template>
          </template>
        </el-table-column>
      </el-table>
      <div class="ui-height" />
      <div class="ui-foot">
        <el-button type="primary" @click="goBack">返 回</el-button>
      </div>
    </div>
  </div>

</template>
<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { requestFN } from '@/utils/request'
import SelectTree from '@/components/SelectTree'
import waves from '@/directive/waves' // waves directive
export default {
  components: { Pagination, SelectTree },
  directives: { waves },
  data() {
    return {
      listLoading: true,
      varList: []
    }
  },
  async created() {
    this.getInfo()
  },
  methods: {
    getRowKey(row) {
      return row.STAGESTUDENTRELATION_ID
    },
    getInfo() {
      requestFN(
        '/studytask/getAllByuserInfo',
        {
          STUDYTASK_ID: this.$parent.STUDYTASK_ID,
          STUDYTASK_USERID: this.$parent.STUDYTASK_USERID
        }
      ).then((data) => {
        this.listLoading = false
        this.varList = data.varList
      }).catch((e) => {
        this.listLoading = false
      })
    },
    goBack() {
      this.$parent.activeName = 'CouresUserInfo'
    }

  }
}

</script>
