소스 검색

王子文 专项培训 - 培训计划
1) 新增功能:上传附件
2) 新增功能:查询附件列表
3) 新增功能:删除附件

wangggziwen 3 년 전
부모
커밋
e3549d23bd

+ 1 - 4
master/src/main/java/com/ruoyi/project/training/spec/controller/TStPlanController.java

@@ -1,9 +1,6 @@
 package com.ruoyi.project.training.spec.controller;
 
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import com.ruoyi.project.training.spec.domain.TStSuccessor;
 import com.ruoyi.project.training.spec.service.ITStSuccessorService;
@@ -49,7 +46,7 @@ public class TStPlanController extends BaseController
      * @param tStSuccessor 继任者清单对象
      * @return 学员列表
      */
-//    @PreAuthorize("@ss.hasPermi('spec:plan:list')")
+    @PreAuthorize("@ss.hasPermi('spec:plan:list')")
     @GetMapping("/getSuccessorListByMentorId")
     public AjaxResult getSuccessorListByMentorId(TStSuccessor tStSuccessor) {
         List<TStSuccessor> tStSuccessors = tStSuccessorService.selectTStSuccessorListByMentorId(tStSuccessor);

+ 1 - 1
master/src/main/java/com/ruoyi/project/training/spec/mapper/TStSuccessorMapper.java

@@ -13,7 +13,7 @@ import com.ruoyi.project.training.spec.domain.TStSuccessor;
 public interface TStSuccessorMapper
 {
     /**
-     * 根据导师STAFF_ID 查询继任者清单列表
+     * 根据导师ID查询学员列表
      *
      * @author 王子文
      * @date 2022年4月18日

+ 1 - 1
master/src/main/java/com/ruoyi/project/training/spec/service/ITStSuccessorService.java

@@ -12,7 +12,7 @@ import com.ruoyi.project.training.spec.domain.TStSuccessor;
 public interface ITStSuccessorService
 {
     /**
-     * 根据导师STAFF_ID 查询继任者清单列表
+     * 根据导师ID查询学员列表
      *
      * @author 王子文
      * @date 2022年4月18日

+ 1 - 1
master/src/main/java/com/ruoyi/project/training/spec/service/impl/TStSuccessorServiceImpl.java

@@ -20,7 +20,7 @@ public class TStSuccessorServiceImpl implements ITStSuccessorService
     private TStSuccessorMapper tStSuccessorMapper;
 
      /**
-     * 根据导师STAFF_ID 查询继任者清单列表
+     * 根据导师ID查询学员列表
      *
      * @author 王子文
      * @date 2022年4月18日

+ 10 - 3
master/src/main/resources/mybatis/training/spec/TStPlanMapper.xml

@@ -7,7 +7,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="TStPlan" id="TStPlanResult">
         <result property="id"    column="id"    />
         <result property="staffId"    column="staff_id"    />
-        <result property="plantName"    column="plant_name"    />
+        <!-- 王子文 2022年4月19日 10点28分 -->
+        <!-- 添加 映射属性 staffName -->
+        <result property="staffName"    column="nick_name"    />
         <result property="delFlag"    column="del_flag"    />
         <result property="createrCode"    column="creater_code"    />
         <result property="createdate"    column="createdate"    />
@@ -23,8 +25,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectTStPlanVo">
-        select d.id, d.staff_id, d.plant_name, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.start_date, d.end_date, d.class_hour, d.class_content, d.study_state ,s.dept_name from t_st_plan d
-      left join sys_dept s on s.dept_id = d.dept_id
+        <!-- select d.id, d.staff_id, d.plant_name, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.start_date, d.end_date, d.class_hour, d.class_content, d.study_state ,s.dept_name from t_st_plan d left join sys_dept s on s.dept_id = d.dept_id -->
+        <!-- 王子文 2022年4月19日 10点28分 -->
+        <!-- 添加 表连接 sys_user u -->
+        <!-- 添加 结果字段 u.nick_name -->
+        select d.id, d.staff_id, u.nick_name, d.plant_name, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.start_date, d.end_date, d.class_hour, d.class_content, d.study_state ,s.dept_name from t_st_plan d
+        left join sys_dept s on s.dept_id = d.dept_id
+        left join sys_user u on d.staff_id = u.staffid
     </sql>
 
     <select id="selectTStPlanList" parameterType="TStPlan" resultMap="TStPlanResult">

+ 1 - 1
master/src/main/resources/mybatis/training/spec/TStSuccessorMapper.xml

@@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <!--王子文 2022年4月18日-->
-    <!--根据导师STAFF_ID 查询继任者清单列表-->
+    <!--根据导师ID查询学员列表-->
     <select id="selectTStSuccessorListByMentorId" parameterType="TStSuccessor" resultMap="TStSuccessorResult">
         <include refid="selectTStSuccessorVo"/>
         <where>

+ 273 - 99
ui/src/views/training/spec/plan/index.vue

@@ -50,7 +50,7 @@
         <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
@@ -109,7 +109,7 @@
       </el-col>
 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
-
+    <!-- 表格 -->
     <el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange" :height="clientHeight" border>
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="培训员工" align="center" prop="staffName" :show-overflow-tooltip="true"/>
@@ -126,7 +126,12 @@
       </el-table-column>
       <el-table-column label="学时" align="center" prop="classHour" :show-overflow-tooltip="true"/>
       <el-table-column label="具体内容" align="center" prop="classContent" :show-overflow-tooltip="true"/>
-      <el-table-column label="学习状态" align="center" prop="studyState" :formatter="studyStateFormat" />
+      <el-table-column label="学习状态" align="center" prop="studyState" :formatter="studyStateFormat">
+        <!-- <template slot-scope="scope">
+          <span>{{scope.row.studyState}}</span>
+          <el-button icon="el-icon-view" style="color:#6e96fa" v-if="scope.row.studyState == 2" @click="handleFeedback(scope.row)"  circle></el-button>
+        </template> -->
+      </el-table-column>
       <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -143,10 +148,17 @@
             @click="handleDelete(scope.row)"
             v-hasPermi="['spec:plan:remove']"
           >删除</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-document"
+            @click="handleDoc(scope.row)"
+            v-hasPermi="['spec:plan:edit']"
+          >附件</el-button>
         </template>
       </el-table-column>
     </el-table>
-
+    <!-- 分页 -->
     <pagination
       v-show="total>0"
       :total="total"
@@ -154,12 +166,11 @@
       :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="staffId">
+        <el-form-item label="培训员工" prop="staffId" v-if="this.operation=='add'">
           <el-select v-model="form.staffId" placeholder="请选择学员">
             <el-option
               v-for="successor in successorOptions"
@@ -169,6 +180,10 @@
             ></el-option>
           </el-select>
         </el-form-item>
+        <!-- 修改对话框显示员工姓名 -->
+        <el-form-item label="培训员工" prop="staffName" v-if="this.operation=='modify'">
+          <el-input v-model="form.staffName" readonly />
+        </el-form-item>
         <el-form-item label="培训内容" prop="plantName">
           <el-input v-model="form.plantName" placeholder="请输入培训内容" />
         </el-form-item>
@@ -222,42 +237,107 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
-      <!-- 用户导入对话框 -->
-      <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
-          <el-upload
-                  ref="upload"
-                  :limit="1"
-                  accept=".xlsx, .xls"
-                  :headers="upload.headers"
-                  :action="upload.url + '?updateSupport=' + upload.updateSupport"
-                  :disabled="upload.isUploading"
-                  :on-progress="handleFileUploadProgress"
-                  :on-success="handleFileSuccess"
-                  :auto-upload="false"
-                  drag
-          >
-              <i class="el-icon-upload"></i>
-              <div class="el-upload__text">
-                  将文件拖到此处,或
-                  <em>点击上传</em>
-              </div>
-              <div class="el-upload__tip" slot="tip">
-                  <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
-                  <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
-              </div>
-              <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
-          </el-upload>
-          <div slot="footer" class="dialog-footer">
-              <el-button type="primary" @click="submitFileForm">确 定</el-button>
-              <el-button @click="upload.open = false">取 消</el-button>
-          </div>
+    <!-- 用户导入对话框 -->
+    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
+        <el-upload
+                ref="upload"
+                :limit="1"
+                accept=".xlsx, .xls"
+                :headers="upload.headers"
+                :action="upload.url + '?updateSupport=' + upload.updateSupport"
+                :disabled="upload.isUploading"
+                :on-progress="handleFileUploadProgress"
+                :on-success="handleFileSuccess"
+                :auto-upload="false"
+                drag
+        >
+            <i class="el-icon-upload"></i>
+            <div class="el-upload__text">
+                将文件拖到此处,或
+                <em>点击上传</em>
+            </div>
+            <div class="el-upload__tip" slot="tip">
+                <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
+                <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
+            </div>
+            <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
+        </el-upload>
+        <div slot="footer" class="dialog-footer">
+            <el-button type="primary" @click="submitFileForm">确 定</el-button>
+            <el-button @click="upload.open = false">取 消</el-button>
+        </div>
+    </el-dialog>
+    <!-- 报告附件对话框 -->
+    <el-dialog v-dialogDrag :title="doc.title" :visible.sync="doc.open" width="700px" append-to-body>
+      <el-upload
+        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" width="120" 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
+              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)"
+            >{{ $t('删除') }}</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-dialog 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>
     <plan-approve v-if="planApproveVisible" ref="planApprove" @refreshDataList="getList"></plan-approve>
   </div>
 </template>
 
 <script>
-import { listPlan, getPlan, delPlan, addPlan, updatePlan, exportPlan, importTemplate, getSuccessorListByMentorId} from "@/api/training/spec/plan";
+import { listPlan, getPlan, delPlan, addPlan, updatePlan, exportPlan, importTemplate, getSuccessorListByMentorId } from "@/api/training/spec/plan";
+import { allFileList, delCommonfile } from "@/api/common/commonfile";
 import { treeselect } from "@/api/system/dept";
 import { getToken } from "@/utils/auth";
 import PlanApprove from "./plan-approve"
@@ -267,7 +347,6 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 export default {
   name: "Plan",
   components: { Treeselect,PlanApprove },
-  // components: { Editor },
   data() {
     return {
       // 遮罩层
@@ -303,21 +382,46 @@ export default {
       queryObject: {
         mentorStaffId: "00427"
       },
-        // 用户导入参数
-        upload: {
-            // 是否显示弹出层(用户导入)
-            open: false,
-            // 弹出层标题(用户导入)
-            title: "",
-            // 是否禁用上传
-            isUploading: false,
-            // 是否更新已经存在的用户数据
-            updateSupport: 0,
-            // 设置上传的请求头部
-            headers: { Authorization: "Bearer " + getToken() },
-            // 上传的地址
-            url: process.env.VUE_APP_BASE_API + "/spec/plan/importData"
+      // 用户导入参数
+      upload: {
+          // 是否显示弹出层(用户导入)
+          open: false,
+          // 弹出层标题(用户导入)
+          title: "",
+          // 是否禁用上传
+          isUploading: false,
+          // 是否更新已经存在的用户数据
+          updateSupport: 0,
+          // 设置上传的请求头部
+          headers: { Authorization: "Bearer " + getToken() },
+          // 上传的地址
+          url: process.env.VUE_APP_BASE_API + "/spec/plan/importData"
+      },
+      // 报告附件参数
+      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: 'plan'
         },
+        pType: 'plan',
+        pId: null
+      },
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -333,7 +437,16 @@ export default {
       form: {},
       // 表单校验
       rules: {
-      }
+      },
+      pdf : {
+          title: '',
+          pdfUrl: '',
+          numPages: null,
+          open: false,
+          pageNum: 1,
+          pageTotalNum: 1,
+          loadedRatio: 0,
+        },
     };
   },
   watch: {
@@ -343,10 +456,10 @@ export default {
         }
    },
   created() {
-      //设置表格高度对应屏幕高度
-      this.$nextTick(() => {
-          this.clientHeight = document.body.clientHeight -250
-      })
+    //设置表格高度对应屏幕高度
+    this.$nextTick(() => {
+        this.clientHeight = document.body.clientHeight -250
+    })
     this.getList();
     this.getTreeselect();
     this.getDicts("st_study_state").then(response => {
@@ -355,6 +468,67 @@ export default {
     this.getSuccessorOptions();
   },
   methods: {
+    /** 文件下载处理 */
+    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){
+      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
+    },
+    /** 报告附件按钮操作 */
+    handleDoc(row) {
+      this.doc.id = row.id;
+      this.doc.title = row.plantName + this.$t('附件');
+      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 => {
+        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()
+    },
+    /** 删除按钮操作 */
+    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('删除成功'));
+      })
+    },
     /** 查询学员下拉列表 */
     getSuccessorOptions() {
       getSuccessorListByMentorId(this.queryObject).then(response => {
@@ -382,16 +556,16 @@ export default {
               this.deptOptions = response.data;
           });
      },
-    // 学习状态字典翻译
+    /** 学习状态字典翻译 */
     studyStateFormat(row, column) {
       return this.selectDictLabel(this.studyStateOptions, row.studyState);
     },
-    // 取消按钮
+    /** 取消按钮 */
     cancel() {
       this.open = false;
       this.reset();
     },
-    // 表单重置
+    /** 表单重置 */
     reset() {
       this.form = {
         id: null,
@@ -421,7 +595,7 @@ export default {
       this.resetForm("queryForm");
       this.handleQuery();
     },
-    // 多选框选中数据
+    /** 多选框选中数据 */
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.id)
       this.single = selection.length!==1
@@ -493,44 +667,44 @@ export default {
           this.download(response.msg);
         })
     },
-      /** 导入按钮操作 */
-      handleImport() {
-          this.upload.title = "用户导入";
-          this.upload.open = true;
-      },
-      /** 下载模板操作 */
-      importTemplate() {
-          importTemplate().then(response => {
-              this.download(response.msg);
-          });
-      },
-      // 文件上传中处理
-      handleFileUploadProgress(event, file, fileList) {
-          this.upload.isUploading = true;
-      },
-      // 文件上传成功处理
-      handleFileSuccess(response, file, fileList) {
-          this.upload.open = false;
-          this.upload.isUploading = false;
-          this.$refs.upload.clearFiles();
-          this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
-          this.getList();
-      },
-      // 提交上传文件
-      submitFileForm() {
-          this.$refs.upload.submit();
-      },
-      addAprrove (row, type) {
-        var rows = row ? [row] : this.dataListSelections.map(item => {
-          return item
-        })
-        this.planApproveVisible = true
-        console.log(rows)
-        console.log(type)
-        this.$nextTick(() => {
-          this.$refs.planApprove.init(rows, type)
-        })
-      },
+    /** 导入按钮操作 */
+    handleImport() {
+        this.upload.title = "用户导入";
+        this.upload.open = true;
+    },
+    /** 下载模板操作 */
+    importTemplate() {
+        importTemplate().then(response => {
+            this.download(response.msg);
+        });
+    },
+    /** 文件上传中处理 */
+    handleFileUploadProgress(event, file, fileList) {
+        this.upload.isUploading = true;
+    },
+    /** 文件上传成功处理 */
+    handleFileSuccess(response, file, fileList) {
+        this.upload.open = false;
+        this.upload.isUploading = false;
+        this.$refs.upload.clearFiles();
+        this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
+        this.getList();
+    },
+    /** 提交上传文件 */
+    submitFileForm() {
+        this.$refs.upload.submit();
+    },
+    addAprrove (row, type) {
+      var rows = row ? [row] : this.dataListSelections.map(item => {
+        return item
+      })
+      this.planApproveVisible = true
+      console.log(rows)
+      console.log(type)
+      this.$nextTick(() => {
+        this.$refs.planApprove.init(rows, type)
+      })
+    },
   }
 };
-</script>
+</script>