<!--
 * @Author: zhangtq 2452618307@qq.com
 * @Date: 2024-12-10 11:12:32
 * @LastEditors: zhangtq 2452618307@qq.com
 * @LastEditTime: 2025-01-20 18:30:17
 * @FilePath: src/views/educationalTraining/statics/releaseStatics.vue
 * @Description: 这是默认设置,可以在设置》工具》File Description中进行配置
 -->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" inline v-show="showSearch">
      <el-row :gutter="10">
        <el-col :span="6">
          <el-form-item label="姓名" prop="name" class="align-right" style="display: flex; align-items: center">
            <el-input
              v-model="queryParams.name"
              placeholder="请输入姓名"
              clearable v-no-whitespace
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <!-- 查询/重置 -->
        <el-col :span="4">
          <el-button type="primary" size="small" icon="el-icon-search" @click="handleQuery">查询</el-button>
          <el-button icon="el-icon-refresh" size="small" @click="handleReset">重置</el-button>
        </el-col>
      </el-row>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出数据</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table :data="tableData" fit highlight-current-row style="width: 100%" >
      <el-table-column
        type="index"
        width="55"
        label="序号"
        align="center"
        :index="indexContinuous(queryParams.pageNum, queryParams.pageSize)"
      />
      <el-table-column
        v-for="column in tableColumns"
        :key="column.prop"
        :label="column.label"
        show-overflow-tooltip
        :prop="column.prop"
        align="center"
      >
      </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 {
  assignedStudentsList,
  getReleaseStatics,
  internalStudentList
} from '@/api/educationalTraining/studentManagement'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { deptTreeSelect } from '@/api/system/user'
import { indexContinuous } from '@/utils/bonus'

export default {
  name: 'releaseStatics',
  data() {
    return {
      showSearch: true,
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: ''
      },
      // 表格数据
      tableData: [],
      tableColumns: [
        { prop: 'name', label: '姓名' },
        { prop: 'learnNum', label: '发布学习任务数' },
        { prop: 'trainNum', label: '发布培训任务数' },
        { prop: 'examNum', label: '发布考试任务数' }
      ]
    }
  },
  created() {
    this.getList()
  },
  methods: {
    indexContinuous,
    // 查询
    handleQuery() {
      this.getList()
    },
    // 重置
    handleReset() {
      this.$refs.queryForm.resetFields()
      this.getList()
    },
    // 获取列表
    getList() {
      getReleaseStatics(this.queryParams).then(res => {
        console.log('🚀 ~ getList ~ getList:', res)
        this.total = res.total
        this.tableData = res.rows
      })
    },
    // 导出数据
    handleExport() {
      try {
        let fileName = `发布任务统计_${new Date().getTime()}.xLsx`
        let url = '/exam/studentManagement/exportReleaseStatics'

        const params = { ...this.queryParams }
        console.log('🚀 ~ 导出 ~ params:', params)
        this.derive(url, params, fileName)
      } catch (error) {
        console.log('导出数据失败', error)
      }
    },
  }
}
</script>

<style lang="scss">
.el-form-item__content {
  width: 74% !important;
}
</style>
