Browse Source

2438 115和117都是:发文管理:勾选一项导出却导出了全部

andy.wu 11 months ago
parent
commit
737c5b8e70

+ 30 - 16
ruoyi-system/src/main/java/com/ruoyi/ahrs/dispatchregistration/controller/DispatchRegistrationController.java

@@ -18,6 +18,7 @@ import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.RoleConstants;
 import com.ruoyi.common.core.page.PageDomain;
 import com.ruoyi.common.core.page.TableSupport;
+import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.common.enums.DeptEnums;
 import com.ruoyi.common.enums.FlowTypeEnums;
 import com.ruoyi.common.enums.UserEnums;
@@ -270,23 +271,36 @@ public class DispatchRegistrationController extends BaseController {
     @RequiresPermissions("ahrs:dispatchRegistration:export")
     @RequestMapping("/export")
     @ResponseBody
-    public void export(DispatchRegistration dispatchRegistration, HttpServletRequest request, HttpServletResponse response) throws Exception {
-        if (dispatchRegistration.getSendToDeptId()==null){
-            dispatchRegistration.setSendToDeptId(getDeptId());
-        }
-        //根据部门级别查询
-        SysDept sysDept = sysDeptService.selectDeptById(dispatchRegistration.getSendToDeptId());
-        dispatchRegistration.setDeptLevel(sysDept.getDeptLevel());
-        //判断是否是主管部门或者事业单位,如果是主管部门或者事业单位就不查询已作废的和没有备案时间的
-        Long roleId = ShiroUtils.getSysUser().getRoleId();
-        if(RoleConstants.ROLE_ZGBM_CZY.equals(roleId) || RoleConstants.ROLE_SYDW_CZY.equals(roleId) ||RoleConstants.ROLE_SYDW_CKY.equals(roleId) ||RoleConstants.ROLE_ZGBM_CKY.equals(roleId) ){
-            dispatchRegistration.setStatus("0");
-        }else{
-            dispatchRegistration.setDispatchRegistrationTime(new Date());
+    public void export(String ids, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        List<DispatchRegistration> dispatchRegistrationList=new ArrayList<>();
+        if (!StringUtils.isNotBlank(ids)){
+            //未勾选导出全部
+            DispatchRegistration dispatchRegistration=new DispatchRegistration();
+            if (dispatchRegistration.getSendToDeptId() == null) {
+                dispatchRegistration.setSendToDeptId(getDeptId());
+            }
+            //根据部门级别查询
+            SysDept sysDept = sysDeptService.selectDeptById(dispatchRegistration.getSendToDeptId());
+            dispatchRegistration.setDeptLevel(sysDept.getDeptLevel());
+            //判断是否是主管部门或者事业单位,如果是主管部门或者事业单位就不查询已作废的和没有备案时间的
+            Long roleId = ShiroUtils.getSysUser().getRoleId();
+            if (RoleConstants.ROLE_ZGBM_CZY.equals(roleId) || RoleConstants.ROLE_SYDW_CZY.equals(roleId) || RoleConstants.ROLE_SYDW_CKY.equals(roleId) || RoleConstants.ROLE_ZGBM_CKY.equals(roleId)) {
+                dispatchRegistration.setStatus("0");
+            } else {
+                dispatchRegistration.setDispatchRegistrationTime(new Date());
+            }
+            dispatchRegistrationList = dispatchRegistrationService.selectDispatchRegistrationList(dispatchRegistration);
+        }else {
+            //勾选的导出勾选
+            Long[] disIds = Convert.toLongArray(",", ids);
+            for (Long disId : disIds) {
+                DispatchRegistration dispatchRegistration = dispatchRegistrationService.selectDispatchRegistrationById(disId);
+                dispatchRegistrationList.add(dispatchRegistration);
+            }
+
         }
-        List<DispatchRegistration> list = dispatchRegistrationService.selectDispatchRegistrationList(dispatchRegistration);
-        list = createParentDeclatation(list);
-        dispatchRegistrationService.export(request, response, list);
+        dispatchRegistrationList = createParentDeclatation(dispatchRegistrationList);
+        dispatchRegistrationService.export(request, response, dispatchRegistrationList);
     }
 
 

+ 7 - 7
ruoyi-system/src/main/resources/templates/ahrs/dispatchregistration/registration.html

@@ -503,14 +503,14 @@
 
         // 导出发文登记表
         function downloadWord() {
+            //判断是否进行了勾选
+            var columns = $.table.selectColumns('dispatchRegistrationFormId');
+            // console.log(columns)
+            //如果进行了勾选,就导出勾选的数据,//如果未进行勾选,就导出全部
+            let params='';
+            params=columns.toString();
             $.modal.loading("下载附件中,请稍等...");
-            let params = "?letter="+$('#letter').val();
-            params += '&operator='+$('#operator').val();
-            params += '&receiptor='+$('#receiptor').val();
-            params += '&sendToDeptId='+$('input[name="sendToDeptId"]').val();
-            params += '&sendToDeptName='+$('input[name="sendToDeptName"]').val();
-            params += '&status='+$('#statusType option:selected').val();
-            window.location.href = prefix + "/export"+params;
+            window.location.href = prefix + "/export?ids="+params;
             setTimeout(function () {
                 $.modal.closeLoading();
             }, 5000);