Przeglądaj źródła

员工权限开发

wuxw 7 lat temu
rodzic
commit
d62ee4d917

+ 39 - 0
WebService/src/main/java/com/java110/web/components/privilege/StaffPrivilegeComponent.java

@@ -0,0 +1,39 @@
+package com.java110.web.components.privilege;
+
+import com.java110.core.context.IPageData;
+import com.java110.web.smo.IPrivilegeServiceSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+@Component("staffPrivilege")
+public class StaffPrivilegeComponent {
+
+    @Autowired
+    private IPrivilegeServiceSMO privilegeServiceSMOImpl;
+    /**
+     *
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> listStaffPrivileges(IPageData pd){
+        ResponseEntity<String> responseEntity = null;
+        try{
+            responseEntity =  privilegeServiceSMOImpl.listStaffPrivileges(pd);
+        }catch (Exception e){
+            responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+        }finally {
+            return responseEntity;
+        }
+    }
+
+
+    public IPrivilegeServiceSMO getPrivilegeServiceSMOImpl() {
+        return privilegeServiceSMOImpl;
+    }
+
+    public void setPrivilegeServiceSMOImpl(IPrivilegeServiceSMO privilegeServiceSMOImpl) {
+        this.privilegeServiceSMOImpl = privilegeServiceSMOImpl;
+    }
+}

+ 7 - 0
WebService/src/main/java/com/java110/web/smo/IPrivilegeServiceSMO.java

@@ -58,4 +58,11 @@ public interface IPrivilegeServiceSMO {
      * @return
      */
     public ResponseEntity<String> deletePrivilegeFromPrivilegeGroup(IPageData pd);
+
+    /**
+     * 查询员工权限
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> listStaffPrivileges(IPageData pd);
 }

+ 38 - 0
WebService/src/main/java/com/java110/web/smo/impl/PrivilegeServiceSMOImpl.java

@@ -243,6 +243,44 @@ public class PrivilegeServiceSMOImpl extends BaseComponentSMO implements IPrivil
         return privilegeGroup;
     }
 
+    /**
+     *
+     * @param pd
+     * @return
+     */
+    @Override
+    public ResponseEntity<String> listStaffPrivileges(IPageData pd) {
+        Assert.hasLength(pd.getUserId(),"用户未登录请先登录");
+
+        JSONObject privilegeInfoObj = JSONObject.parseObject(pd.getReqData());
+        Assert.jsonObjectHaveKey(privilegeInfoObj,"staffId","请求报文中未包含员工ID 节点");
+
+        ResponseEntity<String> storeInfo = super.getStoreInfo(pd,restTemplate);
+
+        if(storeInfo.getStatusCode() != HttpStatus.OK){
+            return storeInfo;
+        }
+        // 商户返回信息
+        JSONObject storeInfoObj = JSONObject.parseObject(storeInfo.getBody());
+
+        String  storeId = storeInfoObj.getString("storeId");
+        privilegeInfoObj.put("storeId",storeId);
+
+        ResponseEntity<String> privilegeGroup = super.callCenterService(restTemplate,pd,"",
+                ServiceConstant.SERVICE_API_URL+"/api/query.user.privilege?userId="+privilegeInfoObj.getString("staffId")+"&domain="+storeInfoObj.getString("storeTypeCd") , HttpMethod.GET);
+        if(privilegeGroup.getStatusCode() != HttpStatus.OK){
+            return privilegeGroup;
+        }
+        JSONObject resultObj = JSONObject.parseObject(privilegeGroup.getBody().toString());
+
+        JSONArray privileges = resultObj.getJSONArray("privileges");
+
+        JSONObject resObj = new JSONObject();
+        resObj.put("datas",privileges);
+
+        return new ResponseEntity<String>(resObj.toJSONString(),HttpStatus.OK);
+    }
+
     public RestTemplate getRestTemplate() {
         return restTemplate;
     }

+ 56 - 0
WebService/src/main/resources/components/add-staff-privilege/addStaffPrivilege.html

@@ -0,0 +1,56 @@
+<div id = "addStaffPrivilegeModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addPrivilegeModalLabel" aria-hidden="true" >
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h3 class="modal-title" id="addPrivilegeModalLabel">添加员工权限</h3>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <div class=" row">
+                    <div class="col-lg-12">
+                        <div class="ibox ">
+                            <ul class="nav nav-tabs">
+                                <li class="nav-item">
+                                    <a class="nav-link active" href="#">Active</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link" href="#">Link</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link" href="#">Link</a>
+                                </li>
+                            </ul>
+                                <div class="table-responsive" style="margin-top:15px">
+                                    <table class="table table-striped">
+                                        <thead>
+                                        <tr>
+
+                                            <th>权限编码</th>
+                                            <th>权限名称</th>
+                                            <th>权限描述</th>
+                                            <th>创建时间</th>
+                                            <th>操作</th>
+                                        </tr>
+                                        </thead>
+                                        <tbody>
+                                            <tr >
+                                                <td>123</td>
+                                                <td>123</td>
+                                                <td>123</td>
+                                                <td>123</td>
+                                                <td>
+                                                    <button class="btn btn-primary btn-xs" >添加</button>
+                                                </td>
+                                            </tr>
+                                        </tbody>
+                                    </table>
+                                </div>
+
+                        </div>
+                    </div>
+                </div>
+        </div>
+    </div>
+</div>

+ 80 - 0
WebService/src/main/resources/components/add-staff-privilege/addStaffPrivilege.js

@@ -0,0 +1,80 @@
+(function(vc){
+
+    vc.extends({
+        data:{
+            addStaffPrivilegeInfo:{
+                _currentPgId:'',
+                name:'',
+                description:'',
+                errorInfo:'',
+                _noAddPrivilege:[]
+            }
+        },
+         _initMethod:function(){
+
+         },
+         _initEvent:function(){
+             vc.on('addStaffPrivilege','addStaffPrivilegeModel',function(_params){
+                $('#addStaffPrivilegeModel').modal('show');
+                /*vc.component.addPrivilegeInfo._currentPgId = _params.pgId;
+                //查询没有添加的权限
+                vc.component.listNoAddPrivilege();*/
+            });
+        },
+        methods:{
+            listNoAddPrivilege:function(){
+                vc.component.addPrivilegeInfo._noAddPrivilege=[];
+                var param = {
+                    params:{
+                        pgId:vc.component.addPrivilegeInfo._currentPgId
+                    }
+                }
+                vc.http.get(
+                            'addPrivilege',
+                            'listNoAddPrivilege',
+                             param,
+                             function(json,res){
+                                //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                                if(res.status == 200){
+                                    vc.component.addPrivilegeInfo._noAddPrivilege = JSON.parse(json);
+                                    return ;
+                                }
+                                vc.component.addPrivilegeInfo.errorInfo = json;
+                             },
+                             function(errInfo,error){
+                                console.log('请求失败处理');
+
+                                vc.component.addPrivilegeInfo.errorInfo = errInfo;
+                             });
+            },
+            addPrivilegeToPrivilegeGroup:function(_privilegeInfo){
+
+                vc.component.addPrivilegeInfo.errorInfo = "";
+                _privilegeInfo.pgId = vc.component.addPrivilegeInfo._currentPgId;
+                vc.http.post(
+                    'addPrivilege',
+                    'addPrivilegeToPrivilegeGroup',
+                    JSON.stringify(_privilegeInfo),
+                    {
+                        emulateJSON:true
+                     },
+                     function(json,res){
+                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                        if(res.status == 200){
+                            //关闭model
+                            vc.component.listNoAddPrivilege();
+                            vc.component.$emit('privilege_loadPrivilege',vc.component.addPrivilegeInfo._currentPgId);
+                            return ;
+                        }
+                        vc.component.addPrivilegeInfo.errorInfo = json;
+                     },
+                     function(errInfo,error){
+                        console.log('请求失败处理');
+
+                        vc.component.addPrivilegeInfo.errorInfo = errInfo;
+                     });
+            }
+        }
+    });
+
+})(window.vc);

+ 1 - 1
WebService/src/main/resources/components/privilege-staffInfo/privilegeStaffInfo.html

@@ -7,7 +7,7 @@
                     <button type="button" class="btn btn-primary btn-sm" v-on:click="openSearchStaffModel()">
                         <i class="glyphicon glyphicon-search"></i> 定位员工</button>
                     <button type="button" class="btn btn-primary btn-sm" style="margin-left:10px">
-                        <i class="glyphicon glyphicon-plus"></i> 添加权限</button>
+                        <i class="glyphicon glyphicon-plus" v-on:click="openAddStaffPrivilegeModel()"></i> 添加权限</button>
                 </div>
             </div>
             <div class="ibox-content">

+ 3 - 0
WebService/src/main/resources/components/privilege-staffInfo/privilegeStaffInfo.js

@@ -29,6 +29,9 @@
             },
             openSearchStaffModel(){
                 vc.emit('searchStaff','openSearchStaffModel',{});
+            },
+            openAddStaffPrivilegeModel:function(){
+                vc.emit('addStaffPrivilege','addStaffPrivilegeModel',{});
             }
         }
     });

+ 7 - 0
WebService/src/main/resources/components/search-staff/searchStaff.js

@@ -13,6 +13,7 @@
             vc.on('searchStaff','openSearchStaffModel',function(_param){
                 console.log("打开定位员工界面")
                 $('#searchStaffModel').modal('show');
+                vc.component._refreshSearchStaffData();
                 vc.component._loadAllStaffInfo(1,10);
             });
         },
@@ -40,10 +41,16 @@
             },
             chooseStaff:function(_staff){
                 vc.emit('privilegeStaffInfo','chooseStaff',_staff);
+                vc.emit('staffPrivilege','_loadStaffPrivileges',{
+                    staffId:_staff.userId
+                });
                 $('#searchStaffModel').modal('hide');
             },
             searchStaffs:function(){
                 vc.component._loadAllStaffInfo(1,10,vc.component.searchStaffInfo._currentStaffName);
+            },
+            _refreshSearchStaffData:function(){
+                vc.component.searchStaffInfo._currentStaffName = "";
             }
         }
 

+ 25 - 50
WebService/src/main/resources/components/staff-privilege/staffPrivilege.html

@@ -19,56 +19,31 @@
                         </tr>
                         </thead>
                         <tbody>
-                        <tr>
-                            <td>
-                                1231313
-                            </td>
-                            <td>
-                                添加员工
-                            </td>
-                            <td>
-                                添加员工
-                            </td>
-                            <td>
-                                -
-                            </td>
-                            <td>
-                                -
-                            </td>
-                            <td>
-                                <span class="label label-primary">在用</span>
-                            </td>
-                            <td class="text-right">
-                                <div class="btn-group">
-                                    <button class="btn-white btn btn-xs">删除</button>
-                                </div>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td>
-                                1231313
-                            </td>
-                            <td>
-                                物业费权限
-                            </td>
-                            <td>
-                                物业费权限
-                            </td>
-                            <td>
-                                89898797979
-                            </td>
-                            <td>
-                                缴费管理
-                            </td>
-                            <td>
-                                <span class="label label-primary">在用</span>
-                            </td>
-                            <td class="text-right">
-                                <div class="btn-group">
-                                    <button class="btn-white btn btn-xs">删除</button>
-                                </div>
-                            </td>
-                        </tr>
+                            <tr v-for="privilege in staffPrivilegeInfo.privileges">
+                                <td>
+                                    {{privilege.pId}}
+                                </td>
+                                <td>
+                                    {{privilege.name}}
+                                </td>
+                                <td>
+                                    {{privilege.description}}
+                                </td>
+                                <td>
+                                    {{privilege.pgId}}
+                                </td>
+                                <td>
+                                    {{privilege.pgName}}
+                                </td>
+                                <td>
+                                    <span class="label label-primary">在用</span>
+                                </td>
+                                <td      class="text-right">
+                                    <div class="btn-group">
+                                        <button class="btn-white btn btn-xs" v-on:click="_openDeleteStaffPrivilegeModel(privilege)">删除</button>
+                                    </div>
+                                </td>
+                            </tr>
                         </tbody>
                         <tfoot>
                         <tr>

+ 30 - 0
WebService/src/main/resources/components/staff-privilege/staffPrivilege.js

@@ -2,10 +2,40 @@
     //员工权限
     vc.extends({
         data:{
+            staffPrivilegeInfo:{
+                privileges:[]
+            }
+        },
+        _initMethod:function(){
 
+        },
+        _initEvent:function(){
+            vc.on('staffPrivilege','_loadStaffPrivileges',function(_param){
+                vc.component._loadStaffPrivileges(_param);
+            });
         },
         methods:{
+            _loadStaffPrivileges:function(_param){
+                var param = {
+                    params:{
+                        staffId:_param.staffId
+                    }
+                };
+             //发送get请求
+            vc.http.get('staffPrivilege',
+                         'listStaffPrivileges',
+                          param,
+                          function(json){
+                             var _staffPrivilegeInfo = JSON.parse(json);
+                             vc.component.staffPrivilegeInfo.privileges = _staffPrivilegeInfo.datas;
+
+                          },function(){
+                             console.log('请求失败处理');
+                          });
+            },
+            _openDeleteStaffPrivilegeModel:function(_staffPrivilege){
 
+            }
         }
     });