소스 검색

feat(training): 新增培训计划文档更新功能并优化表格显示

- 在 tsnew 页面添加更新文档按钮,用于重新生成培训计划相关文档
- 后端增加 regenerateWord 接口,实现培训计划文档的重新生成
- 优化培训计划表格,合并更多列以提高可读性
- 修复培训计划文档生成中的日期显示问题
jiangbiao 3 주 전
부모
커밋
e40d261ed7

+ 32 - 11
master/src/main/java/com/ruoyi/project/training/bccnew/controller/TTsNewController.java

@@ -2,6 +2,7 @@ package com.ruoyi.project.training.bccnew.controller;
 
 import com.deepoove.poi.XWPFTemplate;
 import com.deepoove.poi.data.*;
+import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -300,6 +301,20 @@ public class TTsNewController extends BaseController {
         return AjaxResult.success(appraisalFormWordPath);
     }
 
+    @PutMapping("/regenerateWord/{newId}")
+    public void regenerateWord(@PathVariable Long newId) throws IOException {
+        TTsNew tTsNew = tTsNewService.selectTTsNewById(newId);
+        // 生成word - Mentor Agreement
+        String mentorAgreementWordPath = this.genMentorAgreementWord(tTsNew);
+        // 生成word - Target Plan
+        String targetPlanWordPath = this.genTargetPlanWord(tTsNew);
+        // 更新文件地址
+        tTsNew.setMentorAgreementWordPath(mentorAgreementWordPath);
+        tTsNew.setTargetPlanWordPath(targetPlanWordPath);
+//        tTsNew.setAppraisalFormWordPath(appraisalFormWordPath);
+        tTsNewService.updateTTsNew(tTsNew);
+    }
+
     /**
      * 生成word - Mentor Agreement
      */
@@ -542,17 +557,23 @@ public class TTsNewController extends BaseController {
         SysUser apprentice = sysUserService.selectUserByStaffId(staffId);
         List<TTsApprove> tTsApproves = tsApproveService.selectTTsApproveByNewId(tTsNew.getNewId());
         if (CollectionUtils.isNotEmpty(tTsApproves)) {
-            if (tTsApproves.get(0).getApprover() != null) {
-                SysUser manager = sysUserService.selectUserById(Long.valueOf(tTsApproves.get(0).getApprover()));
-                if (StringUtils.isNotEmpty(manager.getSignUrl()))
-                    params.put("mgrSign", Pictures.ofLocal(fileName(manager.getSignUrl())).size(100, 40).create());
-                if (tTsNew.getPlanStatus() == 3) {// 模板路径
-                    String imgPath = "/static/word/training/commentImg/end2.png";
-                    params.put("mentorComments", Pictures.ofLocal(Objects.requireNonNull(getClass().getResource(imgPath)).getPath()).size(500, 80).create());
-                }
-                if (tTsNew.getPlanStatus() == 1) {// 模板路径
-                    String imgPath = "/static/word/training/commentImg/end1.png";
-                    params.put("mentorComments", Pictures.ofLocal(Objects.requireNonNull(getClass().getResource(imgPath)).getPath()).size(500, 80).create());
+            for (TTsApprove tTsApprove : tTsApproves) {
+                if(tTsApprove.getApprover()!=null) {
+                    SysUser manager = sysUserService.selectUserById(Long.valueOf(tTsApprove.getApprover()));
+                    if (StringUtils.isNotEmpty(manager.getSignUrl())) {
+                        params.put("mgrSign", Pictures.ofLocal(fileName(manager.getSignUrl())).size(100, 40).create());
+                        params.put("mgrTime", DateUtils.dateTime(tTsApprove.getApproveTime()));
+                        params.put("tutorTime", DateUtils.dateTime(tTsApprove.getApplicationTime()));
+                        params.put("traineeTime", DateUtils.dateTime(tTsApprove.getCreatedate()));
+                    }
+                    if (tTsNew.getPlanStatus() == 3) {// 模板路径
+                        String imgPath = "/static/word/training/commentImg/end2.png";
+                        params.put("mentorComments", Pictures.ofLocal(Objects.requireNonNull(getClass().getResource(imgPath)).getPath()).size(500, 80).create());
+                    }
+                    if (tTsNew.getPlanStatus() == 1) {// 模板路径
+                        String imgPath = "/static/word/training/commentImg/end1.png";
+                        params.put("mentorComments", Pictures.ofLocal(Objects.requireNonNull(getClass().getResource(imgPath)).getPath()).size(500, 80).create());
+                    }
                 }
             }
         }

BIN
master/src/main/resources/static/word/training/appraisalForm.docx


+ 7 - 0
ui/src/api/training/bccnew/tsnew.js

@@ -75,3 +75,10 @@ export function handleScore(data) {
     data: data
   })
 }
+
+export function handleRegenerate(id) {
+  return request({
+    url: '/bccnew/tsnew/regenerateWord/'+id,
+    method: 'put'
+  })
+}

+ 1 - 1
ui/src/views/training/bccnew/flPlan/index.vue

@@ -606,7 +606,7 @@ export default {
     //合并单元格
     mergeMethod({row, column, rowIndex, columnIndex}) {
       // console.log(row)
-      if ([1,2,5,6,7].includes(columnIndex)) {
+      if ([1,2,4,5,6,7].includes(columnIndex)) {
         const _row = this.setTable(this.flPlanList).merge[rowIndex];
         const _col = _row > 0 ? 1 : 0;
         return {

+ 1 - 1
ui/src/views/training/bccnew/ftPlan/index.vue

@@ -603,7 +603,7 @@ export default {
     //合并单元格
     mergeMethod({row, column, rowIndex, columnIndex}) {
       // console.log(row)
-      if ([1, 2, 5, 6, 7].includes(columnIndex)) {
+      if ([1, 2, 4, 5, 6, 7].includes(columnIndex)) {
         const _row = this.setTable(this.ftPlanList).merge[rowIndex];
         const _col = _row > 0 ? 1 : 0;
         return {

+ 1 - 1
ui/src/views/training/bccnew/ljPlan/index.vue

@@ -597,7 +597,7 @@ export default {
     //合并单元格
     mergeMethod({row, column, rowIndex, columnIndex}) {
       // console.log(row)
-      if ([1,2,5,6,7].includes(columnIndex)) {
+      if ([1,2,4,5,6,7].includes(columnIndex)) {
         const _row = this.setTable(this.ljPlanList).merge[rowIndex];
         const _col = _row > 0 ? 1 : 0;
         return {

+ 15 - 1
ui/src/views/training/bccnew/tsnew/index.vue

@@ -174,6 +174,14 @@
             v-hasPermi="['tsnew:tsnew:edit']"
           >修改
           </el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-refresh"
+            @click="handleRegen(scope.row)"
+            v-hasPermi="['tsnew:tsnew:export']"
+          >更新文档
+          </el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -414,7 +422,7 @@ import {
   delTsnew,
   exportTsnew,
   genAppraisalFormWord,
-  getTsnew,
+  getTsnew, handleRegenerate,
   importTemplate,
   listTsnew,
   updateTsnew
@@ -909,6 +917,12 @@ export default {
         this.msgSuccess(this.$t('删除成功'));
       })
     },
+    handleRegen(row){
+      handleRegenerate(row.newId).then(response => {
+        this.msgSuccess("重新生成成功");
+        this.getList();
+      });
+    }
   }
 };
 </script>

+ 1 - 1
ui/src/views/training/bccnew/ysPlan/index.vue

@@ -597,7 +597,7 @@ export default {
     //合并单元格
     mergeMethod({row, column, rowIndex, columnIndex}) {
       // console.log(row)
-      if ([1,2,5,6,7].includes(columnIndex)) {
+      if ([1,2,4,5,6,7].includes(columnIndex)) {
         const _row = this.setTable(this.ysPlanList).merge[rowIndex];
         const _col = _row > 0 ? 1 : 0;
         return {