Kaynağa Gözat

培训 - 考试管理 - 在线学习

wangggziwen 1 yıl önce
ebeveyn
işleme
1db80003b2

+ 131 - 0
master/src/main/java/com/ruoyi/project/training/elearn/controller/TElLearnController.java

@@ -0,0 +1,131 @@
+package com.ruoyi.project.training.elearn.controller;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.List;
+
+import com.ruoyi.project.system.service.ISysUserService;
+import com.ruoyi.project.training.elearn.domain.TElResource;
+import com.ruoyi.project.training.elearn.service.ITElResourceService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.project.training.elearn.domain.TElLearn;
+import com.ruoyi.project.training.elearn.service.ITElLearnService;
+import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.web.page.TableDataInfo;
+
+/**
+ * 在线学习记录Controller
+ *
+ * @author ssy
+ * @date 2024-06-05
+ */
+@RestController
+@RequestMapping("/elearn/learn")
+public class TElLearnController extends BaseController
+{
+    @Autowired
+    private ITElLearnService tElLearnService;
+
+    @Autowired
+    private ISysUserService sysUserService;
+
+    @PutMapping("/updateLearnTime")
+    public AjaxResult updateLearnTime(@RequestBody TElResource resource)
+    {
+        Long userId = getUserId();
+        Long resourceId = resource.getId();
+        TElLearn tElLearn = new TElLearn();
+        tElLearn.setUserId(userId);
+        tElLearn.setResourceId(resourceId);
+        TElLearn learn = tElLearnService.selectLearnByUserIdAndResourceId(tElLearn);
+        if (learn == null) {
+            tElLearn.setLearnTime("1");
+            tElLearn.setDeptId(sysUserService.selectUserById(userId).getDeptId());
+            tElLearnService.insertTElLearn(tElLearn);
+        } else {
+            String learnTime = learn.getLearnTime();
+            learn.setLearnTime((Integer.parseInt(learnTime) + 1) + "");
+            tElLearnService.updateTElLearn(learn);
+        }
+        return AjaxResult.success();
+    }
+
+    /**
+     * 查询在线学习记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:learn:list')")
+    @GetMapping("/list")
+    public AjaxResult list(TElLearn tElLearn)
+    {
+        return AjaxResult.success(tElLearnService.selectTElLearnList(tElLearn));
+    }
+
+    /**
+     * 导出在线学习记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:learn:export')")
+    @Log(title = "在线学习记录", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(TElLearn tElLearn)
+    {
+        List<TElLearn> list = tElLearnService.selectTElLearnList(tElLearn);
+        ExcelUtil<TElLearn> util = new ExcelUtil<TElLearn>(TElLearn.class);
+        return util.exportExcel(list, "learn");
+    }
+
+    /**
+     * 获取在线学习记录详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:learn:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(tElLearnService.selectTElLearnById(id));
+    }
+
+    /**
+     * 新增在线学习记录
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:learn:add')")
+    @Log(title = "在线学习记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TElLearn tElLearn)
+    {
+        return toAjax(tElLearnService.insertTElLearn(tElLearn));
+    }
+
+    /**
+     * 修改在线学习记录
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:learn:edit')")
+    @Log(title = "在线学习记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TElLearn tElLearn)
+    {
+        return toAjax(tElLearnService.updateTElLearn(tElLearn));
+    }
+
+    /**
+     * 删除在线学习记录
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:learn:remove')")
+    @Log(title = "在线学习记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(tElLearnService.deleteTElLearnByIds(ids));
+    }
+}

+ 120 - 0
master/src/main/java/com/ruoyi/project/training/elearn/domain/TElLearn.java

@@ -0,0 +1,120 @@
+package com.ruoyi.project.training.elearn.domain;
+
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import com.ruoyi.framework.web.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 在线学习记录对象 t_el_learn
+ *
+ * @author ssy
+ * @date 2024-06-05
+ */
+public class TElLearn extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键id */
+    private Long id;
+
+    /** 学习资料id */
+    @Excel(name = "学习资料id")
+    private Long resourceId;
+
+    /** 学员id */
+    @Excel(name = "学员id")
+    private Long userId;
+
+    private String nickName;
+
+    /** 学习时长 */
+    @Excel(name = "学习时长")
+    private String learnTime;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    private String delFlag;
+
+    /** 部门id */
+    @Excel(name = "部门id")
+    private Long deptId;
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public void setId(Long id)
+    {
+        this.id = id;
+    }
+
+    public Long getId()
+    {
+        return id;
+    }
+    public void setResourceId(Long resourceId)
+    {
+        this.resourceId = resourceId;
+    }
+
+    public Long getResourceId()
+    {
+        return resourceId;
+    }
+    public void setUserId(Long userId)
+    {
+        this.userId = userId;
+    }
+
+    public Long getUserId()
+    {
+        return userId;
+    }
+    public void setLearnTime(String learnTime)
+    {
+        this.learnTime = learnTime;
+    }
+
+    public String getLearnTime()
+    {
+        return learnTime;
+    }
+    public void setDelFlag(String delFlag)
+    {
+        this.delFlag = delFlag;
+    }
+
+    public String getDelFlag()
+    {
+        return delFlag;
+    }
+    public void setDeptId(Long deptId)
+    {
+        this.deptId = deptId;
+    }
+
+    public Long getDeptId()
+    {
+        return deptId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("resourceId", getResourceId())
+            .append("userId", getUserId())
+            .append("learnTime", getLearnTime())
+            .append("delFlag", getDelFlag())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("deptId", getDeptId())
+            .toString();
+    }
+}

+ 65 - 0
master/src/main/java/com/ruoyi/project/training/elearn/mapper/TElLearnMapper.java

@@ -0,0 +1,65 @@
+package com.ruoyi.project.training.elearn.mapper;
+
+import java.util.List;
+import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
+import com.ruoyi.project.training.elearn.domain.TElLearn;
+
+/**
+ * 在线学习记录Mapper接口
+ * 
+ * @author ssy
+ * @date 2024-06-05
+ */
+public interface TElLearnMapper 
+{
+    public TElLearn selectLearnByUserIdAndResourceId(TElLearn tElLearn);
+
+    /**
+     * 查询在线学习记录
+     * 
+     * @param id 在线学习记录ID
+     * @return 在线学习记录
+     */
+    public TElLearn selectTElLearnById(Long id);
+
+    /**
+     * 查询在线学习记录列表
+     * 
+     * @param tElLearn 在线学习记录
+     * @return 在线学习记录集合
+     */
+    @DataScope(deptAlias = "d")
+    public List<TElLearn> selectTElLearnList(TElLearn tElLearn);
+
+    /**
+     * 新增在线学习记录
+     * 
+     * @param tElLearn 在线学习记录
+     * @return 结果
+     */
+    public int insertTElLearn(TElLearn tElLearn);
+
+    /**
+     * 修改在线学习记录
+     * 
+     * @param tElLearn 在线学习记录
+     * @return 结果
+     */
+    public int updateTElLearn(TElLearn tElLearn);
+
+    /**
+     * 删除在线学习记录
+     * 
+     * @param id 在线学习记录ID
+     * @return 结果
+     */
+    public int deleteTElLearnById(Long id);
+
+    /**
+     * 批量删除在线学习记录
+     * 
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteTElLearnByIds(Long[] ids);
+}

+ 62 - 0
master/src/main/java/com/ruoyi/project/training/elearn/service/ITElLearnService.java

@@ -0,0 +1,62 @@
+package com.ruoyi.project.training.elearn.service;
+
+import java.util.List;
+import com.ruoyi.project.training.elearn.domain.TElLearn;
+
+/**
+ * 在线学习记录Service接口
+ * 
+ * @author ssy
+ * @date 2024-06-05
+ */
+public interface ITElLearnService 
+{
+    /**
+     * 查询在线学习记录
+     * 
+     * @param id 在线学习记录ID
+     * @return 在线学习记录
+     */
+    public TElLearn selectTElLearnById(Long id);
+
+    /**
+     * 查询在线学习记录列表
+     * 
+     * @param tElLearn 在线学习记录
+     * @return 在线学习记录集合
+     */
+    public List<TElLearn> selectTElLearnList(TElLearn tElLearn);
+    public TElLearn selectLearnByUserIdAndResourceId(TElLearn tElLearn);
+
+    /**
+     * 新增在线学习记录
+     * 
+     * @param tElLearn 在线学习记录
+     * @return 结果
+     */
+    public int insertTElLearn(TElLearn tElLearn);
+
+    /**
+     * 修改在线学习记录
+     * 
+     * @param tElLearn 在线学习记录
+     * @return 结果
+     */
+    public int updateTElLearn(TElLearn tElLearn);
+
+    /**
+     * 批量删除在线学习记录
+     * 
+     * @param ids 需要删除的在线学习记录ID
+     * @return 结果
+     */
+    public int deleteTElLearnByIds(Long[] ids);
+
+    /**
+     * 删除在线学习记录信息
+     * 
+     * @param id 在线学习记录ID
+     * @return 结果
+     */
+    public int deleteTElLearnById(Long id);
+}

+ 101 - 0
master/src/main/java/com/ruoyi/project/training/elearn/service/impl/TElLearnServiceImpl.java

@@ -0,0 +1,101 @@
+package com.ruoyi.project.training.elearn.service.impl;
+
+import java.util.List;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.project.training.elearn.mapper.TElLearnMapper;
+import com.ruoyi.project.training.elearn.domain.TElLearn;
+import com.ruoyi.project.training.elearn.service.ITElLearnService;
+
+/**
+ * 在线学习记录Service业务层处理
+ *
+ * @author ssy
+ * @date 2024-06-05
+ */
+@Service
+public class TElLearnServiceImpl implements ITElLearnService
+{
+    @Autowired
+    private TElLearnMapper tElLearnMapper;
+
+    /**
+     * 查询在线学习记录
+     *
+     * @param id 在线学习记录ID
+     * @return 在线学习记录
+     */
+    @Override
+    public TElLearn selectTElLearnById(Long id)
+    {
+        return tElLearnMapper.selectTElLearnById(id);
+    }
+
+    /**
+     * 查询在线学习记录列表
+     *
+     * @param tElLearn 在线学习记录
+     * @return 在线学习记录
+     */
+    @Override
+    public List<TElLearn> selectTElLearnList(TElLearn tElLearn)
+    {
+        return tElLearnMapper.selectTElLearnList(tElLearn);
+    }
+
+    public TElLearn selectLearnByUserIdAndResourceId(TElLearn tElLearn)
+    {
+        return tElLearnMapper.selectLearnByUserIdAndResourceId(tElLearn);
+    }
+
+    /**
+     * 新增在线学习记录
+     *
+     * @param tElLearn 在线学习记录
+     * @return 结果
+     */
+    @Override
+    public int insertTElLearn(TElLearn tElLearn)
+    {
+        tElLearn.setCreateTime(DateUtils.getNowDate());
+        return tElLearnMapper.insertTElLearn(tElLearn);
+    }
+
+    /**
+     * 修改在线学习记录
+     *
+     * @param tElLearn 在线学习记录
+     * @return 结果
+     */
+    @Override
+    public int updateTElLearn(TElLearn tElLearn)
+    {
+        tElLearn.setUpdateTime(DateUtils.getNowDate());
+        return tElLearnMapper.updateTElLearn(tElLearn);
+    }
+
+    /**
+     * 批量删除在线学习记录
+     *
+     * @param ids 需要删除的在线学习记录ID
+     * @return 结果
+     */
+    @Override
+    public int deleteTElLearnByIds(Long[] ids)
+    {
+        return tElLearnMapper.deleteTElLearnByIds(ids);
+    }
+
+    /**
+     * 删除在线学习记录信息
+     *
+     * @param id 在线学习记录ID
+     * @return 结果
+     */
+    @Override
+    public int deleteTElLearnById(Long id)
+    {
+        return tElLearnMapper.deleteTElLearnById(id);
+    }
+}

+ 117 - 0
master/src/main/resources/mybatis/training/elearn/TElLearnMapper.xml

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.project.training.elearn.mapper.TElLearnMapper">
+    
+    <resultMap type="TElLearn" id="TElLearnResult">
+        <result property="id"    column="id"    />
+        <result property="resourceId"    column="resource_id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="learnTime"    column="learn_time"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="deptId"    column="dept_id"    />
+        <result property="deptName" column="dept_name" />
+        <result property="nickName" column="nick_name" />
+    </resultMap>
+
+    <sql id="selectTElLearnVo">
+        select d.id, d.resource_id, d.user_id, d.learn_time, d.del_flag, d.create_by, d.create_time, d.update_by, d.update_time, d.dept_id ,
+        u.nick_name
+        from t_el_learn d
+        left join sys_dept s on s.dept_id = d.dept_id
+        left join sys_user u on u.USER_ID = d.USER_ID
+    </sql>
+
+    <select id="selectTElLearnList" parameterType="TElLearn" resultMap="TElLearnResult">
+        <include refid="selectTElLearnVo"/>
+        <where>  
+            <if test="resourceId != null  and resourceId != ''"> and resource_id = #{resourceId}</if>
+            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
+            <if test="learnTime != null  and learnTime != ''"> and learn_time = #{learnTime}</if>
+            <if test="deptId != null "> and dept_id = #{deptId}</if>
+            and d.del_flag = 0
+        </where>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+    </select>
+
+    <select id="selectLearnByUserIdAndResourceId" parameterType="TElLearn" resultMap="TElLearnResult">
+        <include refid="selectTElLearnVo"/>
+        <where>
+            <if test="resourceId != null  and resourceId != ''"> and resource_id = #{resourceId}</if>
+            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
+            and d.del_flag = 0
+        </where>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+    </select>
+    
+    <select id="selectTElLearnById" parameterType="Long" resultMap="TElLearnResult">
+        <include refid="selectTElLearnVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertTElLearn" parameterType="TElLearn">
+        <selectKey keyProperty="id" resultType="long" order="BEFORE">
+            SELECT seq_t_el_learn.NEXTVAL as id FROM DUAL
+        </selectKey>
+        insert into t_el_learn
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="resourceId != null">resource_id,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="learnTime != null">learn_time,</if>
+            <if test="delFlag != null">del_flag,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="deptId != null">dept_id,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="resourceId != null">#{resourceId},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="learnTime != null">#{learnTime},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="deptId != null">#{deptId},</if>
+         </trim>
+    </insert>
+
+    <update id="updateTElLearn" parameterType="TElLearn">
+        update t_el_learn
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="resourceId != null">resource_id = #{resourceId},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="learnTime != null">learn_time = #{learnTime},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="deptId != null">dept_id = #{deptId},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <update id="deleteTElLearnById" parameterType="Long">
+        update t_el_learn set del_flag = 2 where id = #{id}
+    </update>
+
+    <update id="deleteTElLearnByIds" parameterType="String">
+        update t_el_learn set del_flag = 2 where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+    
+</mapper>

+ 61 - 0
ui/src/api/training/elearn/learn.js

@@ -0,0 +1,61 @@
+import request from '@/utils/request'
+
+export function updateLearnTime(data) {
+  return request({
+    url: '/elearn/learn/updateLearnTime',
+    method: 'put',
+    data: data
+  })
+}
+
+// 查询在线学习记录列表
+export function listLearn(query) {
+  return request({
+    url: '/elearn/learn/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询在线学习记录详细
+export function getLearn(id) {
+  return request({
+    url: '/elearn/learn/' + id,
+    method: 'get'
+  })
+}
+
+// 新增在线学习记录
+export function addLearn(data) {
+  return request({
+    url: '/elearn/learn',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改在线学习记录
+export function updateLearn(data) {
+  return request({
+    url: '/elearn/learn',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除在线学习记录
+export function delLearn(id) {
+  return request({
+    url: '/elearn/learn/' + id,
+    method: 'delete'
+  })
+}
+
+// 导出在线学习记录
+export function exportLearn(query) {
+  return request({
+    url: '/elearn/learn/export',
+    method: 'get',
+    params: query
+  })
+}

+ 550 - 0
ui/src/views/training/elearn/learn/index.vue

@@ -0,0 +1,550 @@
+<template>
+  <div class="app-container">
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="12">
+        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+          <el-form-item label="主题" prop="title">
+            <el-input
+              v-model="queryParams.title"
+              placeholder="请输入主题"
+              clearable
+              size="small"
+              @keyup.enter.native="handleQuery"
+            />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+          </el-form-item>
+        </el-form>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="resourceList" @selection-change="handleSelectionChange" :height="clientHeight" border>
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="主题" align="center" prop="title" :show-overflow-tooltip="true"/>
+      <el-table-column label="文件名" align="center" prop="fileName" :show-overflow-tooltip="true"/>
+      <el-table-column label="操作" align="center" fixed="right" width="240" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            @click="handleStudy(scope.row)"
+            icon="el-icon-video-play"
+            v-hasPermi="['elearn:resource:edit']"
+          >开始学习</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            @click="handleHistory(scope.row)"
+            icon="el-icon-document"
+            v-hasPermi="['elearn:resource:remove']"
+          >学习记录</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 课件附件 -->
+    <el-dialog  :close-on-click-modal="false" v-dialogDrag :title="doc.title" :visible.sync="doc.open" width="1000px" append-to-body >
+      <el-upload v-hasPermi="['training:trainingrecords:file']"
+                 ref="doc"
+                 :limit="50"
+                 :headers="doc.headers"
+                 :action="doc.url + '?pType=' + doc.pType + '&pId=' + doc.pId"
+                 :disabled="doc.isUploading"
+                 :on-progress="handleFileDocProgress"
+                 :on-success="handleFileDocSuccess"
+                 :auto-upload="true"
+                 drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">
+          {{ $t('将文件拖到此处,或') }}
+          <em>{{ $t('点击上传') }}</em>
+        </div>
+      </el-upload>
+      <el-table :data="doc.commonfileList" border>
+        <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
+          <template slot-scope="scope">
+            <a  class="link-type"  @click="handleDownload(scope.row)">
+              <span>{{ scope.row.fileName }}</span>
+            </a>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true" width="80" />
+        <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
+        <!--        <el-table-column :label="$t('培训日期')" align="center" prop="pDate"  width="150">-->
+        <!--          <template slot-scope="scope">-->
+        <!--            <el-date-picker-->
+        <!--              v-if="scope.row.isEdit"-->
+        <!--              v-model="scope.row.pDate"-->
+        <!--              type="date"-->
+        <!--              value-format="yyyy-MM-dd"-->
+        <!--              placeholder="日期">-->
+        <!--            </el-date-picker>-->
+        <!--            <span v-else>{{ parseTime(scope.row.pDate, '{y}-{m}-{d}') }}</span>-->
+        <!--          </template>-->
+        <!--        </el-table-column>-->
+        <el-table-column :label="$t('操作')" align="center" width="220" class-name="small-padding fixed-width">
+          <template slot-scope="scope">
+            <el-button
+              v-if="scope.row.fileName.endsWith('pdf')"
+              size="mini"
+              type="text"
+              icon="el-icon-view"
+              @click="handleSee(scope.row)"
+            >{{ $t('预览') }}</el-button>
+            <el-button v-hasPermi="['training:trainingrecords:file']"  type="text" size="small" v-if="scope.row.isEdit" @click="save(scope.row)">保存</el-button>
+            <el-button type="text" size="small" v-if="scope.row.isEdit" @click="cancelFile(scope.row, scope.$index)">取消</el-button>
+            <!--            <el-button v-hasPermi="['training:trainingrecords:file']" v-if="!scope.row.isEdit" @click="edit(scope.row)" icon="el-icon-edit" type="text" size="mini">编辑</el-button>-->
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-download"
+              @click="handleDownload(scope.row)"
+            >{{ $t('下载') }}</el-button>
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-delete"
+              @click="handleDeleteDoc(scope.row)"
+              v-hasPermi="['training:trainingrecords:file']"
+            >{{ $t('删除') }}</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-dialog  :close-on-click-modal="false" v-dialogDrag :title="pdf.title" :visible.sync="pdf.open" width="1300px" append-to-body>
+        <div style="margin-top: -60px;float: right;margin-right: 40px;">
+          <el-button size="mini" type="text" @click="openPdf">{{$t('新页面打开PDF')}}</el-button></div>
+        <div style="margin-top: -30px">
+          <iframe :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"></iframe>
+        </div>
+      </el-dialog>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="doc.open = false">{{ $t('返 回') }}</el-button>
+      </div>
+    </el-dialog>
+
+    <el-dialog  :close-on-click-modal="false"  v-loading="loadingFlash" element-loading-background="rgba(0,0,0,0.2)" v-dialogDrag :title="pdf.title"
+                :visible.sync="pdf.open" width="1300px" height="800px" :center="true" append-to-body @close="handleClose">
+      <div style="margin-top: -30px">
+        <iframe id="iFrame" class="iframe-html" :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"
+                v-if="ppt"></iframe>
+      </div>
+    </el-dialog>
+
+    <el-dialog :title="history.title" :visible.sync="history.open" width="800px" :center="true" append-to-body>
+      <el-table v-loading="historyLoading" :data="historyList" border>
+        <el-table-column label="用户" align="center" prop="nickName" :show-overflow-tooltip="true"/>
+        <el-table-column label="学习时长" align="center" prop="learnTime" :show-overflow-tooltip="true">
+          <template slot-scope="scope">
+            <span>{{ scope.row.learnTime }}</span> min
+          </template>
+        </el-table-column>
+      </el-table>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import { updateLearnTime, listLearn, getLearn, delLearn, addLearn, updateLearn, exportLearn } from "@/api/training/elearn/learn";
+  import { listFile, listResource, getResource, delResource, addResource, updateResource, exportResource } from "@/api/training/elearn/resource";
+  import { treeselect } from "@/api/system/dept";
+  import { getToken } from "@/utils/auth";
+  import Treeselect from "@riophae/vue-treeselect";
+  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+  import {addCommonfile, allFileList, delCommonfile, updateCommonfile} from "@/api/common/commonfile";
+
+  var timer = null;
+
+  export default {
+    name: "Learn",
+    components: { Treeselect },
+    data() {
+      return {
+        history: {
+          open: false,
+          title: "",
+        },
+        ppt: false,
+        pptView: false,
+        pdf: {
+          title: '',
+          pdfUrl: '',
+          numPages: null,
+          open: false,
+          pageNum: 1,
+          pageTotalNum: 1,
+          loadedRatio: 0,
+        },
+        learning: {
+          learningTimeStudied: null,
+        },
+        loadingFlash: false,
+        doc: {
+          file: "",
+          // 是否显示弹出层(报告附件)
+          open: false,
+          // 弹出层标题(报告附件)
+          title: "附件",
+          // 是否禁用上传
+          isUploading: false,
+          // 是否更新已经存在的用户数据
+          updateSupport: 0,
+          // 报告附件上传位置编号
+          ids: 0,
+          // 设置上传的请求头部
+          headers: { Authorization: "Bearer " + getToken() },
+          // 上传的地址
+          url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
+          commonfileList: null,
+          queryParams: {
+            pId: null,
+            pType: 'elearnResource'
+          },
+          pType: 'elearnResource',
+          pId: null,
+          form: {}
+        },
+        pdf : {
+          title: '',
+          pdfUrl: '',
+          numPages: null,
+          open: false,
+          pageNum: 1,
+          pageTotalNum: 1,
+          loadedRatio: 0,
+        },
+        // 遮罩层
+        loading: true,
+        historyLoading: true,
+        // 选中数组
+        ids: [],
+        // 非单个禁用
+        single: true,
+        // 非多个禁用
+        multiple: true,
+        // 显示搜索条件
+        showSearch: true,
+        // 总条数
+        total: 0,
+        // 学习资料管理表格数据
+        resourceList: [],
+        historyList: [],
+        // 弹出层标题
+        title: "",
+        // 部门树选项
+        deptOptions: undefined,
+        clientHeight:300,
+        // 是否显示弹出层
+        open: false,
+        // 用户导入参数
+        upload: {
+          // 是否显示弹出层(用户导入)
+          open: false,
+          // 弹出层标题(用户导入)
+          title: "",
+          // 是否禁用上传
+          isUploading: false,
+          // 是否更新已经存在的用户数据
+          updateSupport: 0,
+          // 设置上传的请求头部
+          headers: { Authorization: "Bearer " + getToken() },
+          // 上传的地址
+          url: process.env.VUE_APP_BASE_API + "/elearn/resource/importData"
+        },
+        // 查询参数
+        queryParams: {
+          pageNum: 1,
+          pageSize: 20,
+          title: null,
+          remarks: null,
+          deptId: null
+        },
+        // 表单参数
+        form: {},
+        // 表单校验
+        rules: {
+          id: [
+            { required: true, message: "主键id不能为空", trigger: "blur" }
+          ],
+        }
+      };
+    },
+    watch: {
+      // 根据名称筛选部门树
+      deptName(val) {
+        this.$refs.tree.filter(val);
+      }
+    },
+    created() {
+      //设置表格高度对应屏幕高度
+      this.$nextTick(() => {
+        this.clientHeight = document.body.clientHeight -250
+      })
+      this.getList();
+      this.getTreeselect();
+    },
+    methods: {
+      handleHistory(row) {
+        this.history.title = row.fileName + " 学习记录";
+        this.history.open = true;
+        listLearn({"resourceId": row.resourceId}).then(response => {
+          this.historyList = response.data;
+          this.historyLoading = false;
+        });
+      },
+      handleClose() {
+        window.clearInterval(timer);
+        this.getList();
+      },
+      handleStudy(row) {
+        //office预览
+        this.loadingFlash = true
+        this.pdf.open = true
+        this.pdf.title = row.fileName
+        this.pdf.pdfUrl = ""
+        this.ppt = true
+        //如果是PDF等直接可以打开的就不调接口,否则调用接口
+        if (row.fileName.endsWith('pdf')) {
+          this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
+          this.loadingFlash = false
+        }
+        let _this = this;
+        timer = window.setInterval(function() {
+          updateLearnTime(row).then(response => {
+            // _this.$forceUpdate();
+          });
+        }, 60000);
+      },
+      handleDoc(row) {
+        this.doc.id = row.id;
+        this.doc.title = "";
+        this.doc.open = true;
+        this.doc.queryParams.pId = row.id
+        this.doc.pId = row.id
+        this.getFileList()
+        /*this.$nextTick(() => {
+          this.$refs.doc.clearFiles()
+        })*/
+      },
+      getFileList() {
+        allFileList(this.doc.queryParams).then(response => {
+          response.forEach(element => {
+            element["isEdit"] = false
+          });
+          response.forEach(element => {
+            element["isAdd"] = false
+          });
+          this.doc.commonfileList = response;
+        });
+      },
+      //附件上传中处理
+      handleFileDocProgress(event, file, fileList) {
+        this.doc.file = file;
+        this.doc.isUploading = true;
+      },
+      //附件上传成功处理
+      handleFileDocSuccess(response, file, fileList) {
+        this.doc.isUploading = false;
+        this.$alert(response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+        this.getFileList()
+      },
+      // 文件下载处理
+      handleDownload(row) {
+        var name = row.fileName;
+        var url = row.fileUrl;
+        var suffix = url.substring(url.lastIndexOf("."), url.length);
+        const a = document.createElement('a')
+        a.setAttribute('download', name)
+        a.setAttribute('target', '_blank')
+        a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
+        a.click()
+      },
+      openPdf() {
+        window.open(this.pdf.pdfUrl);//path是文件的全路径地址
+      },
+      handleSee(row) {
+        // window.open(process.env.VUE_APP_BASE_API +'/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl);//path是文件的全路径地址
+        this.pdf.open = true
+        this.pdf.title = row.fileName
+        this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
+      },
+      // 上一页
+      prePage() {
+        let page = this.pdf.pageNum
+        page = page > 1 ? page - 1 : this.pdf.pageTotalNum
+        this.pdf.pageNum = page
+      },
+      // 下一页
+      nextPage() {
+        let page = this.pdf.pageNum
+        page = page < this.pdf.pageTotalNum ? page + 1 : 1
+        this.pdf.pageNum = page
+      },
+      // 取消
+      cancelFile(row, index) {
+        // 如果是新增的数据
+        if (row.isAdd) {
+          this.doc.commonfileList.splice(index, 1)
+        } else {
+          // 不是新增的数据  还原数据
+          for (const i in row.oldRow) {
+            row[i] = row.oldRow[i]
+          }
+          row.isEdit = false
+        }
+      },
+      edit(row) {
+        // 备份原始数据
+        row['oldRow'] = JSON.parse(JSON.stringify(row));
+        this.$nextTick(() => {
+          row.isEdit = true;
+        })
+      },
+      save(row) {
+        row.isEdit = false;
+        var that = this;
+        that.loading = true;
+        this.form = row;
+        if (row.isAdd == true) {
+          addCommonfile(this.form).then(response => {
+            this.msgSuccess(this.$t('新增成功'));
+            this.open = false;
+            this.getList();
+          });
+        } else {
+          updateCommonfile(this.form).then(response => {
+            this.msgSuccess(this.$t('修改成功'));
+            this.open = false;
+            this.getList();
+          });
+        }
+      },
+      /** 删除按钮操作 */
+      handleDeleteDoc(row) {
+        const ids = row.id || this.ids;
+        this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
+          confirmButtonText: this.$t('确定'),
+          cancelButtonText: this.$t('取消'),
+          type: "warning"
+        }).then(function () {
+          return delCommonfile(ids);
+        }).then(() => {
+          this.getFileList()
+          this.msgSuccess(this.$t('删除成功'));
+        })
+      },
+      /** 查询学习资料管理列表 */
+      getList() {
+        this.loading = true;
+        listFile(this.queryParams).then(response => {
+          this.resourceList = response.rows;
+          this.total = response.total;
+          this.loading = false;
+        });
+      },
+      /** 查询部门下拉树结构 */
+      getTreeselect() {
+        treeselect().then(response => {
+          this.deptOptions = response.data;
+        });
+      },
+      // 取消按钮
+      cancel() {
+        this.open = false;
+        this.reset();
+      },
+      // 表单重置
+      reset() {
+        this.form = {
+          id: null,
+          title: null,
+          remarks: null,
+          delFlag: null,
+          createBy: null,
+          createTime: null,
+          updateBy: null,
+          updateTime: null,
+          deptId: null
+        };
+        this.resetForm("form");
+      },
+      /** 搜索按钮操作 */
+      handleQuery() {
+        this.queryParams.pageNum = 1;
+        this.getList();
+      },
+      /** 重置按钮操作 */
+      resetQuery() {
+        this.resetForm("queryForm");
+        this.handleQuery();
+      },
+      // 多选框选中数据
+      handleSelectionChange(selection) {
+        this.ids = selection.map(item => item.id)
+        this.single = selection.length !== 1
+        this.multiple = !selection.length
+      },
+      /** 新增按钮操作 */
+      handleAdd() {
+        this.reset();
+        this.open = true;
+        this.title = "添加学习资料管理";
+      },
+      /** 修改按钮操作 */
+      handleUpdate(row) {
+        this.reset();
+        const id = row.id || this.ids
+        getResource(id).then(response => {
+          this.form = response.data;
+          this.open = true;
+          this.title = "修改学习资料管理";
+        });
+      },
+      /** 提交按钮 */
+      submitForm() {
+        this.$refs["form"].validate(valid => {
+          if (valid) {
+            if (this.form.id != null) {
+              updateResource(this.form).then(response => {
+                this.msgSuccess("修改成功");
+                this.open = false;
+                this.getList();
+              });
+            } else {
+              addResource(this.form).then(response => {
+                this.msgSuccess("新增成功");
+                this.open = false;
+                this.getList();
+              });
+            }
+          }
+        });
+      },
+      /** 删除按钮操作 */
+      handleDelete(row) {
+        const ids = row.id || this.ids;
+        this.$confirm('是否确认删除?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function () {
+          return delResource(ids);
+        }).then(() => {
+          this.getList();
+          this.msgSuccess("删除成功");
+        })
+      },
+    }
+  };
+</script>