<template>
  <div>
    <div class="app-container">
      <div class="mb-20">
        <table class="table-ui">
          <tr>
            <td class="tbg">学习任务名称</td>
            <td colspan="3">{{ pd.STUDY_NAME }}</td>
          </tr>
          <tr>
            <td class="tbg">培训行业类型</td>
            <td colspan="3">{{ pd.post_type_name }}</td>
          </tr>
          <tr>
            <td class="tbg">岗位培训类型</td>
            <td colspan="3">{{ pd.train_type_name }}</td>
          </tr>
          <tr>
            <td class="tbg">培训时间</td>
            <td colspan="3">{{ pd.PEIXUE_START_TIME }} - {{ pd.PEIXUE_END_TIME }}</td>
          </tr>
          <tr>
            <td class="tbg">是否签到</td>
            <td colspan="3">{{ pd.KJ_STATE=='1'?'是':'否' }}
              <div style="font-size: 12px">开启签到后，学员培训前需要进行电子手签。并会记录到《学员名册及考勤》档案中</div>
            </td>
          </tr>
          <tr>
            <td class="tbg">是否开启防挂机验证</td>
            <td colspan="3">{{ pd.KJ_STATE=='1'?'是':'否' }}
              <div style="font-size: 12px">开启放挂机验证员工学习过程会进行人脸识别，确保是员工本人在培训</div>
            </td>
          </tr>
          <tr>
            <td class="tbg">已选择课程</td>
            <td colspan="3">
              <table style="padding:0;width:auto" class="table-vi">
                <tr>
                  <th class="title">课程名称</th>
                  <th class="title">课件数</th>
                </tr>
                <tr v-for="(item,index) in scurAllList" :key="index">
                  <td class="title">{{ item.CURRICULUMNAME }}</td>
                  <td class="title">{{ item.COURSEWARECOUNT }}</td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td class="tbg">已选择人员</td>
            <td colspan="3">
              <table style="padding:0;width:auto" class="table-vi">
                <tr>
                  <th class="title">姓名</th>
                  <th class="title">手机号</th>
                  <th class="title">部门</th>
                </tr>
                <tr v-for="(item,index) in userAlllist" :key="index">
                  <td class="title">{{ item.USER_NAME }}</td>
                  <td class="title">{{ item.PHONE }}</td>
                  <td class="title">{{ item.DEPARTMENT_NAME }}</td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td class="tbg">已设置考试</td>
            <td colspan="3">
              <table style="padding:0;width:auto" class="table-vi">
                <tr>
                  <th class="title">考试名称</th>
                  <th class="title">考试时长</th>
                  <th class="title">试卷名称</th>
                </tr>
                <tr v-for="(item,index) in stageAlllist" :key="index">
                  <td class="title">{{ item.EXAMNAME }}</td>
                  <td class="title">{{ item.ANSWERSHEETTIME }}</td>
                  <td class="title">{{ item.shijuanName }}</td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </div>
    </div>

    <div class="ui-height" />
    <div class="ui-foot">
      <el-button type="primary" @click="goBack">返 回</el-button>
    </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,
      defaultProps: {
        value: 'id',
        children: 'nodes',
        label: 'name'
      },
      rules: {},
      pxList: [],
      gwList: [],
      pd: { },
      scurAllList: [],
      userAlllist: [],
      stageAlllist: []
    }
  },
  async created() {
    await this.getTreeDicByParId('pxList', '052369aa22d242118236cde52d0c67ea')
    await this.getTreeDicByParId('gwList', 'f6a7c4f5602f46e291d06b1390a3f820')
    await this.getInfo()
    await this.getuserList()
    await this.getStageexampaperList()
  },
  methods: {
    getInfo() {
      requestFN(
        '/studytask/goEdit',
        {
          STUDYTASK_ID: this.$parent.STUDYTASK_ID
        }
      ).then((data) => {
        this.listLoading = false
        this.pd = data.pd
        this.scurAllList = data.scurAllList
      }).catch((e) => {
        this.listLoading = false
      })
    },
    getuserList() {
      requestFN(
        '/stagestudentrelation/listAllByStudyTaskId',
        {
          STUDYTASK_ID: this.$parent.STUDYTASK_ID
        }
      ).then((data) => {
        this.userAlllist = data.varList
      }).catch((e) => {
        this.listLoading = false
      })
    },
    getStageexampaperList() {
      requestFN(
        '/stageexampaper/getPageDataByStudyTaskId',
        {
          STUDYTASK_ID: this.$parent.STUDYTASK_ID
        }
      ).then((data) => {
        this.stageAlllist = data.varList
      }).catch((e) => {
        this.listLoading = false
      })
    },
    goBack() {
      this.$parent.activeName = 'Course'
    },
    getTreeDicByParId(listName, parentId) {
      requestFN(
        '/dictionaries/listAllDictToParId',
        {
          parentId: parentId
        }
      ).then((data) => {
        this[listName] = JSON.parse(data.zTreeNodes)
      }).catch((e) => {
        this.listLoading = false
      })
    }
  }
}

</script>
