Ver Fonte

Merge branch 'master' of http://git_xt.git.topm.win:8080/wenhongquan/VisualInspection

minitiger há 9 anos atrás
pai
commit
db77863496

+ 127 - 45
VisualInspection/js/role/role.js

@@ -1,45 +1,127 @@
-  var cols = [{
-      width: 'auto',
-      text: '序号',
-      type: 'number',
-      flex: true,
-      colClass: 'text-center'
-  }, {
-      width: 'auto',
-      text: '角色名称',
-      type: 'string',
-      flex: true,
-      colClass: 'text-center'
-  }, {
-      width: 'auto',
-      text: '组织机构',
-      type: 'string',
-      flex: true,
-      sort: 'down',
-      colClass: 'text-center'
-  }, {
-      width: 'auto',
-      text: '用户数',
-      type: 'number',
-      flex: true,
-      colClass: 'text-center'
-  }, {
-      width: 'auto',
-      text: '操作',
-      type: 'string',
-      flex: true,
-      colClass: 'text-center'
-  }];
-  $(document).ready(function() {
-
-      $("#main_content_title").html("角色管理")
-
-      $('.datatable').datatable({
-          checkable: false,
-          sortable: false,
-          data: {
-              cols: cols,
-              rows: [{ checked: false, data: [1, '2016-01-18 11:05:15', '名称示例1', 22, '<button class="btn btn-primary" name="user_edit" id=' + 1 + '><i class="icon icon-edit"></i>修改</button>  <button class="btn btn-primary" name="user_delete" id=' + 1 + ' ><i class="icon icon-remove-circle"></i>删除</button>'] }]
-          }
-      });
-  });
+var cols = [{
+    width: 'auto',
+    text: '序号',
+    type: 'number',
+    flex: true,
+    colClass: 'text-center'
+}, {
+    width: 'auto',
+    text: '角色名称',
+    type: 'string',
+    flex: true,
+    colClass: 'text-center'
+}, {
+    width: 'auto',
+    text: '用户数',
+    type: 'number',
+    flex: true,
+    colClass: 'text-center'
+}, {
+    width: 'auto',
+    text: '操作',
+    type: 'string',
+    flex: true,
+    colClass: 'text-center'
+}];
+var pageNo = null;
+$(document).ready(function () {
+
+    $("#main_content_title").html("角色管理")
+
+    $('.datatable').datatable({
+        checkable: false,
+        sortable: false,
+        data: {
+            cols: cols,
+            rows: []
+        }
+    });
+
+    var pagesize = 15;
+    if (pageNo == null || pageNo == "") {
+        getrole(pagesize, 1);
+    } else {
+        getrole(pagesize, pageNo);
+    }
+
+
+});
+
+
+function getrole(size, page) {
+    RoleGetALL(page, size, function (data) {
+
+console.log(data)
+        totalPage = data.pages;
+        totalRecords = data.total;
+        setpage(data.currentPage);
+        var rowdata = [];
+        if (data.list.length > 0) {
+            for (var i = 0; i < data.list.length; i++) {
+                var role = data.list[i];
+                var userdata = {};
+                userdata["checked"] = false;
+                userdata["data"] = [i + 1, role.des, role.usercount, '<button class="btn btn-primary" name="user_edit" id=' + role.id + '><i class="icon icon-edit"></i>修改</button>  <button class="btn btn-primary" name="user_delete" id=' + role.id + ' ><i class="icon icon-remove-circle"></i>删除</button>'];
+                rowdata.push(userdata);
+            }
+        }
+
+        // 使用data参数更新数据:
+        $('.datatable').datatable('load', {
+            cols: cols,
+            rows: rowdata
+        });
+    }, function (error) {
+
+    });
+}
+
+var totalPage = 20;
+var totalRecords = 390;
+function setpage(currentpage) {
+    if (!pageNo) {
+        pageNo = currentpage;
+    }
+
+    //生成分页
+    //有些参数是可选的,比如lang,若不传有默认值
+    kkpager.generPageHtml({
+        pno: pageNo,
+        //总页码
+        total: totalPage,
+        //总数据条数
+        totalRecords: totalRecords,
+        mode: 'click',//默认值是link,可选link或者click
+        click: function (n) {
+            // do something
+            getrole(pagesize, n);
+
+            //手动选中按钮
+            this.selectPage(n);
+            return false;
+        }
+        /*
+         ,lang				: {
+         firstPageText			: '首页',
+         firstPageTipText		: '首页',
+         lastPageText			: '尾页',
+         lastPageTipText			: '尾页',
+         prePageText				: '上一页',
+         prePageTipText			: '上一页',
+         nextPageText			: '下一页',
+         nextPageTipText			: '下一页',
+         totalPageBeforeText		: '共',
+         totalPageAfterText		: '页',
+         currPageBeforeText		: '当前第',
+         currPageAfterText		: '页',
+         totalInfoSplitStr		: '/',
+         totalRecordsBeforeText	: '共',
+         totalRecordsAfterText	: '条数据',
+         gopageBeforeText		: ' 转到',
+         gopageButtonOkText		: '确定',
+         gopageAfterText			: '页',
+         buttonTipBeforeText		: '第',
+         buttonTipAfterText		: '页'
+         }*/
+    });
+}

+ 11 - 4
VisualInspection/js/teamClass/charge_team_schedule.js

@@ -191,7 +191,7 @@
 
         $("#save_user_class").click(function(){
             var dutyList = [];
-            var work_date = $("#save_user_class").data("work_date");
+            var work_date = $("#save_user_class").data("work_date")+"00:00:00";
 
             for(var j=1;j<4;j++){
                 var cache = $(".tr-"+j).data("cache");
@@ -199,7 +199,14 @@
                 if(cache) {
                     for(var i=0;i<lans+1;i++){
                         if($(".tr-"+j+" td select").eq(i).val()!='' ){
-                            var obj = { "work_date":work_date,"dept_id":cache.dept_id,"user_id": $(".tr-"+j+" td select").eq(i).val() , "class_type":j,"team_id":cache.team_id,"start_time":work_date, "end_time":work_date,"lane":$(".tr-"+j+" td select").eq(i).parent().attr('tag') };
+
+
+                        
+
+                            var start_time = $("#save_user_class").data("work_date")+ classCode[j].start_time+":00" ;
+                            var end_time =  $("#save_user_class").data("work_date")+classCode[j].end_time+":00";
+
+                            var obj = { "work_date":work_date,"dept_id":cache.dept_id,"user_id": $(".tr-"+j+" td select").eq(i).val() , "class_type":j,"team_id":cache.team_id,"start_time":start_time, "end_time":end_time,"lane":$(".tr-"+j+" td select").eq(i).parent().attr('tag') };
                             dutyList.push(obj);
                         }
                     }
@@ -236,7 +243,7 @@
                 $('#add_fee_station').modal();
                 $(".modal-title").html("收费站排班表-"+event.event.start.format("yyyy-MM-dd"));
 
-                $("#save_user_class").data("work_date",event.event.start.format("yyyy-MM-dd 00:00:00"));
+                $("#save_user_class").data("work_date",event.event.start.format("yyyy-MM-dd "));
 
                  var data = {
                     "dept_id": user_dept_id ,
@@ -329,7 +336,7 @@
                         }
                     }else{
                          var cache = $(".tr-1").data("cache");
-                         var work_date = $("#save_user_class").data("work_date");
+                         var work_date = $("#save_user_class").data("work_date")+"00:00:00";
                          var param = {
                             'dept_id':user_dept_id,
                             'work_date':work_date

+ 4 - 0
VisualInspection/js/util/const.js

@@ -20,6 +20,10 @@ var DEPT_ADD = "dept/addDept"
 var DEPT_EDIT = "dept/updateDept/"
 var DEPT_DELETE = "/dept/deleteDept/"
 
+//角色
+var ROLE_GET_ALL = "/role/get/all/"
+var ROLE_GET_ALL_DATA = "/role/get/alldata/"
+
 
 
 //File

+ 16 - 0
VisualInspection/js/util/service.js

@@ -246,4 +246,20 @@ function uploadFile(file, name, successfunc, errorfunc) {
             errorfunc("网络错误");
         }
     });
+}
+
+
+
+function RoleGetALL(page,size, success, fail) {
+    var url = base_server_url + ROLE_GET_ALL_DATA+"/"+page+"/"+size;
+    ajaxGet(url, "", function(response) {
+        var data = response;
+        if (data.result_code == 0) {
+            success(data.result_data)
+        } else {
+            fail(data.result_desc);
+        }
+    }, function(error) {
+        fail("网络错误");
+    });
 }

+ 4 - 2
VisualInspection/view/role/role.html

@@ -20,9 +20,11 @@
 
         </div>
     </div>
-    <div class="row" style="padding-top:20px">
+    <div class="row" style="padding-top:10px">
         <div class="datatable" style="border: 1px solid #ddd" data-checkable="true" data-sortable="true"></div>
-
     </div>
+     <div class="row" style="padding-top:8px">
+         <div id='kkpager'></div>
+     </div>
 
 </div>

+ 21 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/RoleController.java

@@ -14,6 +14,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.xintong.system.err.BusinessException;
 import com.xintong.visualinspection.bean.Role;
+import com.xintong.visualinspection.pojo.RoleData;
 import com.xintong.visualinspection.service.RoleService;
 
 /**
@@ -98,6 +99,26 @@ public class RoleController extends BaseController {
 		}
 	}
 
+	
+	/**
+	 * 获取所有角色
+	 * 
+	 * @param page
+	 * @param size
+	 * @return
+	 */
+	@RequestMapping(value = "/get/alldata/{page}/{size}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
+	public String getAllRoleData(@PathVariable Integer page, @PathVariable Integer size) {
+		try {
+			PageHelper.startPage(page, size);
+			List<RoleData> roles = roleService.getRoleDatas(new Role());
+
+			return returnResult(0, "获取成功", new PageInfo(roles));
+		} catch (Exception e) {
+			throw new BusinessException(20001);
+		}
+	}
+
 	@RequestMapping(value = "/roleBindPermission/{roleId}/{permissions}", method = RequestMethod.PUT, produces = "application/json;charset=UTF-8")
 	public String roleBindPermission(@PathVariable Integer roleId, @PathVariable String permissions) {
 		String[] permissionids = permissions.split(",");

+ 3 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/dao/master/RoleDao.java

@@ -6,6 +6,7 @@ import java.util.Map;
 import org.apache.ibatis.annotations.Mapper;
 
 import com.xintong.visualinspection.bean.Role;
+import com.xintong.visualinspection.pojo.RoleData;
 
 /**
  * 文件名:UserInfoDao
@@ -28,4 +29,6 @@ public interface RoleDao  {
     public List<Role> getRoleByUser(Integer userId);
     public List<Role> getRoleByPosition(Integer positionId);
     
+    public List<RoleData> getRolesCount(Role role);
+    
 }

+ 15 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/RoleMapper.xml

@@ -7,6 +7,13 @@
         <result column="des" property="des" jdbcType="VARCHAR" />
     </resultMap>
     
+     <resultMap id="BaseRoleDaataMap" type="com.xintong.visualinspection.pojo.RoleData" >
+        <id column="id" property="id" jdbcType="INTEGER" />
+        <result column="name" property="name" jdbcType="VARCHAR" />
+        <result column="des" property="des" jdbcType="VARCHAR" />
+        <result column="count" property="usercount" jdbcType="INTEGER" />
+    </resultMap>
+    
     
      <select id="getRole" parameterType="com.xintong.visualinspection.bean.Role" resultMap="BaseResultMap">
         SELECT 
@@ -17,6 +24,14 @@
          <if test="name != null">and name = #{name}</if>
     </select>
     
+    <select id="getRolesCount" parameterType="com.xintong.visualinspection.bean.Role" resultMap="BaseRoleDaataMap">
+        select s.*,p.count from sys_role s LEFT JOIN  (select sys_role_id,count(sys_role_id) as count from sys_role_user  GROUP BY sys_role_id) p on p.sys_role_id = s.id 
+         where 1=1
+         <if test="id != null and id != 0">and s.id = #{id}</if>
+         <if test="name != null">and s.name = #{name}</if>
+    </select>
+    
+    
 
     <insert id="insert" parameterType="com.xintong.visualinspection.bean.Role" >
         INSERT INTO

+ 11 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/pojo/RoleData.java

@@ -0,0 +1,11 @@
+package com.xintong.visualinspection.pojo;
+
+import com.xintong.visualinspection.bean.Role;
+
+import lombok.Data;
+
+@Data
+public class RoleData extends Role {
+
+	private int usercount;
+}

+ 2 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/RoleService.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.xintong.visualinspection.bean.Role;
+import com.xintong.visualinspection.pojo.RoleData;
 
 /**
  * 文件名:UserService 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
@@ -30,4 +31,5 @@ public interface RoleService {
 	public List<Role> getRoleByUser(Integer userId);
 
 	public List<Role> getRoleByPosition(Integer positionId);
+	public List<RoleData> getRoleDatas(Role role);
 }

+ 7 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/RoleServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
 
 import com.xintong.visualinspection.bean.Role;
 import com.xintong.visualinspection.dao.master.RoleDao;
+import com.xintong.visualinspection.pojo.RoleData;
 import com.xintong.visualinspection.service.BaseService;
 import com.xintong.visualinspection.service.RoleService;
 
@@ -105,5 +106,11 @@ public class RoleServiceImpl extends BaseService implements RoleService {
 		roleDao.roleBindJob(part);
 	}
 
+
+	@Override
+	public List<RoleData> getRoleDatas(Role role) {
+		return roleDao.getRolesCount(role);
+	}
+
     
 }