瀏覽代碼

培训 - 考试管理 - 学习资料管理

wangggziwen 1 年之前
父節點
當前提交
b96590e8f8

+ 103 - 0
master/src/main/java/com/ruoyi/project/training/elearn/controller/TElResourceController.java

@@ -0,0 +1,103 @@
+package com.ruoyi.project.training.elearn.controller;
+
+import java.util.List;
+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.TElResource;
+import com.ruoyi.project.training.elearn.service.ITElResourceService;
+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/resource")
+public class TElResourceController extends BaseController
+{
+    @Autowired
+    private ITElResourceService tElResourceService;
+
+    /**
+     * 查询学习资料管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:resource:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TElResource tElResource)
+    {
+        startPage();
+        List<TElResource> list = tElResourceService.selectTElResourceList(tElResource);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出学习资料管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:resource:export')")
+    @Log(title = "学习资料管理", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(TElResource tElResource)
+    {
+        List<TElResource> list = tElResourceService.selectTElResourceList(tElResource);
+        ExcelUtil<TElResource> util = new ExcelUtil<TElResource>(TElResource.class);
+        return util.exportExcel(list, "resource");
+    }
+
+    /**
+     * 获取学习资料管理详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:resource:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(tElResourceService.selectTElResourceById(id));
+    }
+
+    /**
+     * 新增学习资料管理
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:resource:add')")
+    @Log(title = "学习资料管理", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TElResource tElResource)
+    {
+        return toAjax(tElResourceService.insertTElResource(tElResource));
+    }
+
+    /**
+     * 修改学习资料管理
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:resource:edit')")
+    @Log(title = "学习资料管理", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TElResource tElResource)
+    {
+        return toAjax(tElResourceService.updateTElResource(tElResource));
+    }
+
+    /**
+     * 删除学习资料管理
+     */
+    @PreAuthorize("@ss.hasPermi('elearn:resource:remove')")
+    @Log(title = "学习资料管理", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(tElResourceService.deleteTElResourceByIds(ids));
+    }
+}

+ 96 - 0
master/src/main/java/com/ruoyi/project/training/elearn/domain/TElResource.java

@@ -0,0 +1,96 @@
+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_resource
+ *
+ * @author ssy
+ * @date 2024-06-05
+ */
+public class TElResource extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键id */
+    private Long id;
+
+    /** 标题 */
+    @Excel(name = "标题")
+    private String title;
+
+    /** 备注 */
+    @Excel(name = "备注")
+    private String remarks;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    private String delFlag;
+
+    /** 部门id */
+    @Excel(name = "部门id")
+    private Long deptId;
+
+    public void setId(Long id)
+    {
+        this.id = id;
+    }
+
+    public Long getId()
+    {
+        return id;
+    }
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    public String getTitle()
+    {
+        return title;
+    }
+    public void setRemarks(String remarks)
+    {
+        this.remarks = remarks;
+    }
+
+    public String getRemarks()
+    {
+        return remarks;
+    }
+    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("title", getTitle())
+            .append("remarks", getRemarks())
+            .append("delFlag", getDelFlag())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("deptId", getDeptId())
+            .toString();
+    }
+}

+ 63 - 0
master/src/main/java/com/ruoyi/project/training/elearn/mapper/TElResourceMapper.java

@@ -0,0 +1,63 @@
+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.TElResource;
+
+/**
+ * 学习资料管理Mapper接口
+ * 
+ * @author ssy
+ * @date 2024-06-05
+ */
+public interface TElResourceMapper 
+{
+    /**
+     * 查询学习资料管理
+     * 
+     * @param id 学习资料管理ID
+     * @return 学习资料管理
+     */
+    public TElResource selectTElResourceById(Long id);
+
+    /**
+     * 查询学习资料管理列表
+     * 
+     * @param tElResource 学习资料管理
+     * @return 学习资料管理集合
+     */
+    @DataScope(deptAlias = "d")
+    public List<TElResource> selectTElResourceList(TElResource tElResource);
+
+    /**
+     * 新增学习资料管理
+     * 
+     * @param tElResource 学习资料管理
+     * @return 结果
+     */
+    public int insertTElResource(TElResource tElResource);
+
+    /**
+     * 修改学习资料管理
+     * 
+     * @param tElResource 学习资料管理
+     * @return 结果
+     */
+    public int updateTElResource(TElResource tElResource);
+
+    /**
+     * 删除学习资料管理
+     * 
+     * @param id 学习资料管理ID
+     * @return 结果
+     */
+    public int deleteTElResourceById(Long id);
+
+    /**
+     * 批量删除学习资料管理
+     * 
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteTElResourceByIds(Long[] ids);
+}

+ 61 - 0
master/src/main/java/com/ruoyi/project/training/elearn/service/ITElResourceService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.project.training.elearn.service;
+
+import java.util.List;
+import com.ruoyi.project.training.elearn.domain.TElResource;
+
+/**
+ * 学习资料管理Service接口
+ * 
+ * @author ssy
+ * @date 2024-06-05
+ */
+public interface ITElResourceService 
+{
+    /**
+     * 查询学习资料管理
+     * 
+     * @param id 学习资料管理ID
+     * @return 学习资料管理
+     */
+    public TElResource selectTElResourceById(Long id);
+
+    /**
+     * 查询学习资料管理列表
+     * 
+     * @param tElResource 学习资料管理
+     * @return 学习资料管理集合
+     */
+    public List<TElResource> selectTElResourceList(TElResource tElResource);
+
+    /**
+     * 新增学习资料管理
+     * 
+     * @param tElResource 学习资料管理
+     * @return 结果
+     */
+    public int insertTElResource(TElResource tElResource);
+
+    /**
+     * 修改学习资料管理
+     * 
+     * @param tElResource 学习资料管理
+     * @return 结果
+     */
+    public int updateTElResource(TElResource tElResource);
+
+    /**
+     * 批量删除学习资料管理
+     * 
+     * @param ids 需要删除的学习资料管理ID
+     * @return 结果
+     */
+    public int deleteTElResourceByIds(Long[] ids);
+
+    /**
+     * 删除学习资料管理信息
+     * 
+     * @param id 学习资料管理ID
+     * @return 结果
+     */
+    public int deleteTElResourceById(Long id);
+}

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

@@ -0,0 +1,96 @@
+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.TElResourceMapper;
+import com.ruoyi.project.training.elearn.domain.TElResource;
+import com.ruoyi.project.training.elearn.service.ITElResourceService;
+
+/**
+ * 学习资料管理Service业务层处理
+ *
+ * @author ssy
+ * @date 2024-06-05
+ */
+@Service
+public class TElResourceServiceImpl implements ITElResourceService
+{
+    @Autowired
+    private TElResourceMapper tElResourceMapper;
+
+    /**
+     * 查询学习资料管理
+     *
+     * @param id 学习资料管理ID
+     * @return 学习资料管理
+     */
+    @Override
+    public TElResource selectTElResourceById(Long id)
+    {
+        return tElResourceMapper.selectTElResourceById(id);
+    }
+
+    /**
+     * 查询学习资料管理列表
+     *
+     * @param tElResource 学习资料管理
+     * @return 学习资料管理
+     */
+    @Override
+    public List<TElResource> selectTElResourceList(TElResource tElResource)
+    {
+        return tElResourceMapper.selectTElResourceList(tElResource);
+    }
+
+    /**
+     * 新增学习资料管理
+     *
+     * @param tElResource 学习资料管理
+     * @return 结果
+     */
+    @Override
+    public int insertTElResource(TElResource tElResource)
+    {
+        tElResource.setCreateTime(DateUtils.getNowDate());
+        return tElResourceMapper.insertTElResource(tElResource);
+    }
+
+    /**
+     * 修改学习资料管理
+     *
+     * @param tElResource 学习资料管理
+     * @return 结果
+     */
+    @Override
+    public int updateTElResource(TElResource tElResource)
+    {
+        tElResource.setUpdateTime(DateUtils.getNowDate());
+        return tElResourceMapper.updateTElResource(tElResource);
+    }
+
+    /**
+     * 批量删除学习资料管理
+     *
+     * @param ids 需要删除的学习资料管理ID
+     * @return 结果
+     */
+    @Override
+    public int deleteTElResourceByIds(Long[] ids)
+    {
+        return tElResourceMapper.deleteTElResourceByIds(ids);
+    }
+
+    /**
+     * 删除学习资料管理信息
+     *
+     * @param id 学习资料管理ID
+     * @return 结果
+     */
+    @Override
+    public int deleteTElResourceById(Long id)
+    {
+        return tElResourceMapper.deleteTElResourceById(id);
+    }
+}

+ 101 - 0
master/src/main/resources/mybatis/training/elearn/TElResourceMapper.xml

@@ -0,0 +1,101 @@
+<?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.TElResourceMapper">
+    
+    <resultMap type="TElResource" id="TElResourceResult">
+        <result property="id"    column="id"    />
+        <result property="title"    column="title"    />
+        <result property="remarks"    column="remarks"    />
+        <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" />
+    </resultMap>
+
+    <sql id="selectTElResourceVo">
+        select d.id, d.title, d.remarks, d.del_flag, d.create_by, d.create_time, d.update_by, d.update_time, d.dept_id from t_el_resource d
+      left join sys_dept s on s.dept_id = d.dept_id
+    </sql>
+
+    <select id="selectTElResourceList" parameterType="TElResource" resultMap="TElResourceResult">
+        <include refid="selectTElResourceVo"/>
+        <where>  
+            <if test="title != null  and title != ''">
+                and title like concat(concat('%', #{title}), '%')
+            </if>
+            <if test="remarks != null  and remarks != ''"> and
+                and remarks like concat(concat('%', #{remarks}), '%')
+            </if>
+            <if test="deptId != null "> and dept_id = #{deptId}</if>
+            and d.del_flag = 0
+        </where>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+    </select>
+    
+    <select id="selectTElResourceById" parameterType="Long" resultMap="TElResourceResult">
+        <include refid="selectTElResourceVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertTElResource" parameterType="TElResource">
+        <selectKey keyProperty="id" resultType="long" order="BEFORE">
+            SELECT seq_t_el_resource.NEXTVAL as id FROM DUAL
+        </selectKey>
+        insert into t_el_resource
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="title != null">title,</if>
+            <if test="remarks != null">remarks,</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="title != null">#{title},</if>
+            <if test="remarks != null">#{remarks},</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="updateTElResource" parameterType="TElResource">
+        update t_el_resource
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="title != null">title = #{title},</if>
+            <if test="remarks != null">remarks = #{remarks},</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="deleteTElResourceById" parameterType="Long">
+        update t_el_resource set del_flag = 2 where id = #{id}
+    </update>
+
+    <update id="deleteTElResourceByIds" parameterType="String">
+        update t_el_resource set del_flag = 2 where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+    
+</mapper>

+ 53 - 0
ui/src/api/training/elearn/resource.js

@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+
+// 查询学习资料管理列表
+export function listResource(query) {
+  return request({
+    url: '/elearn/resource/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询学习资料管理详细
+export function getResource(id) {
+  return request({
+    url: '/elearn/resource/' + id,
+    method: 'get'
+  })
+}
+
+// 新增学习资料管理
+export function addResource(data) {
+  return request({
+    url: '/elearn/resource',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改学习资料管理
+export function updateResource(data) {
+  return request({
+    url: '/elearn/resource',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除学习资料管理
+export function delResource(id) {
+  return request({
+    url: '/elearn/resource/' + id,
+    method: 'delete'
+  })
+}
+
+// 导出学习资料管理
+export function exportResource(query) {
+  return request({
+    url: '/elearn/resource/export',
+    method: 'get',
+    params: query
+  })
+}

+ 545 - 0
ui/src/views/training/elearn/resource/index.vue

@@ -0,0 +1,545 @@
+<template>
+  <div class="app-container">
+    <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 label="备注" prop="remarks">
+        <el-input
+          v-model="queryParams.remarks"
+          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-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['elearn:resource:add']"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleUpdate"
+          v-hasPermi="['elearn:resource:edit']"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['elearn:resource:remove']"
+        >删除</el-button>
+      </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">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-folder"
+            @click="handleDoc(scope.row)"
+          >查看课件
+          </el-button>
+        </template>
+      </el-table-column>
+      <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
+      <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['elearn:resource:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            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 :title="title" :visible.sync="open" width="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="标题" prop="title">
+          <el-input v-model="form.title" placeholder="请输入标题" />
+        </el-form-item>
+        <el-form-item label="备注" prop="remarks">
+          <el-input v-model="form.remarks" placeholder="请输入备注" />
+        </el-form-item>
+          <el-form-item label="归属部门" prop="deptId">
+              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
+          </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+
+    <!-- 课件附件 -->
+    <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 type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>-->
+        <el-button @click="doc.open = false">{{ $t('返 回') }}</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listResource, getResource, delResource, addResource, updateResource, exportResource, importTemplate} 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";
+
+export default {
+  name: "Resource",
+  components: { Treeselect },
+  data() {
+    return {
+      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,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: false,
+      // 总条数
+      total: 0,
+      // 学习资料管理表格数据
+      resourceList: [],
+      // 弹出层标题
+      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: {
+    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;
+      listResource(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>