Преглед на файлове

问卷单条新增时自动匹配章节和目录

wangggziwen преди 8 месеца
родител
ревизия
924a3c8cc7

+ 14 - 4
rc-admin/src/main/java/com/ruoyi/web/controller/rc/TQuestionnaireController.java

@@ -2,9 +2,8 @@ package com.ruoyi.web.controller.rc;
 
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.rc.domain.DevTask;
-import com.ruoyi.rc.domain.TDeptInfo;
-import com.ruoyi.rc.domain.TProgress;
+import com.ruoyi.rc.domain.*;
+import com.ruoyi.rc.service.ITChapterService;
 import com.ruoyi.rc.service.ITProgressService;
 import com.ruoyi.system.service.ISysDeptService;
 
@@ -35,7 +34,6 @@ import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.rc.domain.TQuestionnaire;
 import com.ruoyi.rc.service.ITQuestionnaireService;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.page.TableDataInfo;
@@ -66,6 +64,9 @@ public class TQuestionnaireController extends BaseController
     @Autowired
     private ITProgressService tProgressService;
 
+    @Autowired
+    private ITChapterService tChapterService;
+
     /**
      * 流程处理
      */
@@ -238,6 +239,15 @@ public class TQuestionnaireController extends BaseController
         if (StringUtils.isNull(tQuestionnaire.getDeptId())) {
             tQuestionnaire.setDeptId(getLoginUser().getDeptId().toString());
         }
+        if (StringUtils.isNull(tQuestionnaire.getChapterId())) {
+            TChapter params = new TChapter();
+            params.setCode(tQuestionnaire.getDirectory());
+            params.setAuditId(tQuestionnaire.getAuditId());
+            TChapter chapter = tChapterService.selectTChapterByCode(params);
+            if (chapter != null) {
+                tQuestionnaire.setChapterId(chapter.getId());
+            }
+        }
         return toAjax(tQuestionnaireService.insertTQuestionnaire(tQuestionnaire));
     }
 

+ 2 - 0
rc-buisness/src/main/java/com/ruoyi/rc/mapper/TChapterMapper.java

@@ -19,6 +19,8 @@ public interface TChapterMapper
      */
     public TChapter selectTChapterById(Long id);
 
+    public TChapter selectTChapterByCode(TChapter tChapter);
+
     /**
      * 查询章节列表
      * 

+ 2 - 0
rc-buisness/src/main/java/com/ruoyi/rc/service/ITChapterService.java

@@ -19,6 +19,8 @@ public interface ITChapterService
      */
     public TChapter selectTChapterById(Long id);
 
+    public TChapter selectTChapterByCode(TChapter tChapter);
+
     /**
      * 查询章节列表
      * 

+ 6 - 0
rc-buisness/src/main/java/com/ruoyi/rc/service/impl/TChapterServiceImpl.java

@@ -31,6 +31,12 @@ public class TChapterServiceImpl implements ITChapterService
         return tChapterMapper.selectTChapterById(id);
     }
 
+    @Override
+    public TChapter selectTChapterByCode(TChapter tChapter)
+    {
+        return tChapterMapper.selectTChapterByCode(tChapter);
+    }
+
     /**
      * 查询章节列表
      * 

+ 5 - 0
rc-buisness/src/main/resources/mapper/rc/TChapterMapper.xml

@@ -32,6 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
+    <select id="selectTChapterByCode" parameterType="TChapter" resultMap="TChapterResult">
+        <include refid="selectTChapterVo"/>
+        where code = #{code} and audit_id = #{auditId}
+    </select>
+
     <insert id="insertTChapter" parameterType="TChapter" useGeneratedKeys="true" keyProperty="id">
         insert into t_chapter
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 2 - 0
ruoyi-ui/src/views/rc/questionnaire/index.vue

@@ -715,6 +715,8 @@ export default {
     /** 新增按钮操作 */
     handleAdd() {
       this.reset();
+      this.form.chapterId = this.queryParams.chapterId;
+      this.form.auditId = this.queryParams.auditId;
       this.open = true;
       this.title = "添加问卷";
     },