From c3510da29a7974c6af7ff3de1ade3db429d6f848 Mon Sep 17 00:00:00 2001
From: 李宇 <986321569@qq.com>
Date: 星期三, 18 八月 2021 14:27:59 +0800
Subject: [PATCH] 申购管理申请履历显示所有历史单据,提交时如有无效试剂耗材报错

---
 src/main/java/com/nanometer/smartlab/controller/RoleMngController.java |  106 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 94 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/nanometer/smartlab/controller/RoleMngController.java b/src/main/java/com/nanometer/smartlab/controller/RoleMngController.java
index 46cc2e2..a19fb88 100644
--- a/src/main/java/com/nanometer/smartlab/controller/RoleMngController.java
+++ b/src/main/java/com/nanometer/smartlab/controller/RoleMngController.java
@@ -14,6 +14,7 @@
 import org.springframework.stereotype.Controller;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -61,6 +62,34 @@
         RequestContext.getCurrentInstance().execute("PF('dialog').show()");
     }
 
+    public void btnPermissionClick() {
+        if (this.selectedList == null
+                || this.selectedList.size() == 0) {
+            FacesUtils.warn("请选择数据。");
+            return;
+        }
+        if (this.selectedList.size() > 1) {
+            FacesUtils.warn("只能选择一个数据进行修改。");
+            return;
+        }
+        this.baseRole = this.baseRoleService.getBaseRole(this.selectedList.get(0).getId());
+        RequestContext.getCurrentInstance().execute("PF('btnDialog').show()");
+    }
+
+    public void userPermissionClick() {
+        if (this.selectedList == null
+                || this.selectedList.size() == 0) {
+            FacesUtils.warn("请选择数据。");
+            return;
+        }
+        if (this.selectedList.size() > 1) {
+            FacesUtils.warn("只能选择一个数据进行修改。");
+            return;
+        }
+        this.baseRole = this.baseRoleService.getBaseRole(this.selectedList.get(0).getId());
+        RequestContext.getCurrentInstance().execute("PF('userDialog').show()");
+    }
+
     public void onSaveBtnClick() {
         try {
             // 新建
@@ -79,7 +108,8 @@
                     FacesUtils.warn("请选择角色权限。");
                     return;
                 }
-
+                baseRole.setUserPermission("自己");
+                baseRole.setBtnPermission("新增,修改,删除,导入");
                 this.baseRoleService.insertBaseRole(this.baseRole);
 
                 FacesUtils.info("新建成功。");
@@ -106,6 +136,57 @@
                 FacesUtils.info("修改成功。");
                 RequestContext.getCurrentInstance().execute("PF('dialog').hide()");
             }
+        } catch (Exception e) {
+            logger.error("操作失败。", e);
+            FacesUtils.warn("操作失败。");
+        }
+    }
+    /**
+    * 人员管理按钮权限修改
+    */
+    public void onSaveBtnPermission() {
+        try {
+                if (this.baseRole == null) {
+                    FacesUtils.warn("修改对象为空。");
+                    return;
+                }
+
+
+                if (this.baseRole.getBtnPermissions() == null || this.baseRole.getBtnPermissions().size() == 0) {
+                    FacesUtils.warn("请选择功能。");
+                    return;
+                }
+
+                this.baseRoleService.updateUserMngPageBtn(this.baseRole);
+
+                FacesUtils.info("修改成功。");
+                RequestContext.getCurrentInstance().execute("PF('btnDialog').hide()");
+        } catch (Exception e) {
+            logger.error("操作失败。", e);
+            FacesUtils.warn("操作失败。");
+        }
+    }
+
+    /**
+     * 人员管理人员可见权限修改
+     */
+    public void onSaveUserPermission() {
+        try {
+            if (this.baseRole == null) {
+                FacesUtils.warn("修改对象为空。");
+                return;
+            }
+
+
+            if (this.baseRole.getUserPermission() == null) {
+                FacesUtils.warn("请选择可见范围。");
+                return;
+            }
+
+            this.baseRoleService.updateUserMngPageBtn(this.baseRole);
+
+            FacesUtils.info("修改成功。");
+            RequestContext.getCurrentInstance().execute("PF('userDialog').hide()");
         } catch (Exception e) {
             logger.error("操作失败。", e);
             FacesUtils.warn("操作失败。");
@@ -141,6 +222,7 @@
                         if (count > 0) {
                             list = baseRoleService.getBaseRoleList(null, null, first, pageSize);
                         }
+                        selectedList = new ArrayList<>();
                     } catch (Exception e) {
                         logger.error(e);
                     }
@@ -149,17 +231,17 @@
 
                 @Override
                 public BaseRole getRowData(String rowKey) {
-                    Iterator<BaseRole> iterator = this.iterator();
-                    if (iterator != null) {
-                        BaseRole br = null;
-                        while (iterator.hasNext()) {
-                            br = iterator.next();
-                            if (rowKey.equals(br.getId())) {
-                                return br;
-                            }
-                        }
-                    }
-                    return null;
+//                    Iterator<BaseRole> iterator = this.iterator();
+//                    if (iterator != null) {
+//                        BaseRole br = null;
+//                        while (iterator.hasNext()) {
+//                            br = iterator.next();
+//                            if (rowKey.equals(br.getId())) {
+//                                return br;
+//                            }
+//                        }
+//                    }
+                    return baseRoleService.getBaseRole(rowKey);
                 }
             };
         }

--
Gitblit v1.9.2