Commit c7180a0d authored by 季圣华's avatar 季圣华
Browse files

优化角色和按钮权限

parent 92a4a79f
This diff is collapsed.
[
{
"id": 1,
"text": "导入导出"
"text": "编辑"
},
{
"id": 2,
"text": "启用禁用"
"text": "审核反审核"
},
{
"id": 3,
"text": "审核反审核"
"text": "导入导出"
},
{
"id": 4,
"text": "打印"
"text": "启用禁用"
},
{
"id": 5,
"text": "打印"
},
{
"id": 6,
"text": "作废"
}
]
\ No newline at end of file
......@@ -26,9 +26,11 @@
var btnEnableList = getBtnStr(); //获取按钮的权限
var mPropertyList = ""; //商品属性列表
var defaultAccountId = 0; //默认账户id
var roleType = ""; //角色类型
$(function(){
//初始化系统基础信息
getType();
getRoleType();
initSystemData_UB();
initSystemData_depot();
initSystemData_account();
......@@ -142,6 +144,21 @@
amountNum = "CXD";
}
}
function getRoleType(){
$.ajax({
type:"get",
url: "/user/getRoleTypeByUserId",
async: false,
success: function (res) {
if (res && res.code === 200) {
roleType = res.data.roleType;
}
else {
roleType = null;
}
}
});
}
//初始化系统基础信息
function initSystemData_UB(){
$.ajax({
......@@ -360,8 +377,8 @@
}
}
];
//如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
if(btnEnableList && btnEnableList.indexOf(3)>-1 && listTitle.indexOf("订单")>-1){
//如果允许的按钮列表中存在就显示,2-代表审核|反审核的权限
if(btnEnableList && btnEnableList.indexOf(2)>-1 && listTitle.indexOf("订单")>-1){
isHiddenStatus = false; //显示
tableToolBar.push({
id:'okDepotHead',
......@@ -2214,6 +2231,7 @@
search: JSON.stringify({
type: listType,
subType: listSubType,
roleType: roleType,
state: $.trim($("#searchState").val()),
number: $.trim($("#searchNumber").val()),
beginTime: beginTime,
......
......@@ -245,7 +245,7 @@
url: url,
valueField: 'id',
textField: 'text',
panelHeight: 120,
panelHeight: 160,
multiple: true,
method: 'get'
});
......
......@@ -31,8 +31,8 @@
</div>
<div class="form-group">
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a>
<a id="btnSetFunctions" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配功能'>分配功能</a>&nbsp;&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a>&nbsp;
<a id="btnSetFunctions" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配功能'>分配功能</a>&nbsp;
<a id="btnSetPushBtn" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配按钮'>分配按钮</a>
</div>
</div>
......@@ -50,6 +50,24 @@
data-options="required:true,validType:'length[2,30]'" style="width: 230px;"/>
</td>
</tr>
<tr>
<td>数据类型&nbsp;&nbsp;</td>
<td style="padding:5px">
<select name="type" id="type" class="easyui-combobox"
data-options="required:true,panelHeight:'auto'" style="width: 230px;">
<option value="全部数据">全部数据</option>
<option value="本部门数据">本部门数据</option>
<option value="个人数据">个人数据</option>
<option value="自定义数据">自定义数据</option>
</select>
</td>
</tr>
<tr>
<td>描述&nbsp;&nbsp;</td>
<td style="padding:5px">
<input name="description" id="description" class="easyui-textbox" data-options="multiline:true" style="width: 230px;height: 40px;"/>
</td>
</tr>
</table>
</form>
</div>
......@@ -110,7 +128,9 @@
return str;
}
},
{title: '角色名称', field: 'name', width: 200}
{title: '角色名称', field: 'name', width: 200},
{title: '数据类型', field: 'type', width: 200},
{title: '描述', field: 'description', width: 200}
]],
toolbar: [
{
......@@ -147,7 +167,7 @@
//兼容 IE,firefox 兼容
var obj = e.srcElement ? e.srcElement : e.target;
//绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
if (k == "13" && (obj.id == "name" || obj.id == "sort" || obj.id == "remark")) {
if (k == "13" && (obj.id == "name" || obj.id == "description")) {
$("#saveRole").click();
}
//搜索按钮添加快捷键
......@@ -258,13 +278,9 @@
var oldName = "";
function addRole() {
$("#sort").val("");
$("#remark").val("");
$('#roleFM').form('clear');
$('#roleDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui/themes/icons/edit_add.png"/>&nbsp;增加角色信息');
$(".window-mask").css({width: webW, height: webH});
$("#name").val("").focus();
//$('#roleFM').form('clear');
oldName = "";
roleID = 0;
url = '/role/add';
......@@ -305,6 +321,8 @@
function editRole(index) {
var rowsdata = $("#tableData").datagrid("getRows")[index];
$("#name").textbox("setValue", rowsdata.name);
$("#type").combobox("setValue", rowsdata.type);
$("#description").textbox("setValue", rowsdata.description);
oldName = rowsdata.name;
$('#roleDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui/themes/icons/pencil.png"/>&nbsp;编辑角色信息');
$(".window-mask").css({width: webW, height: webH});
......
......@@ -19,6 +19,8 @@
<body>
<!-- 数据显示table -->
<div style="padding-bottom: 10px;">
<a id="btnAllCheck" class="easyui-linkbutton">全选</a>&nbsp;
<a id="btnAllCancel" class="easyui-linkbutton">全取消</a>&nbsp;
<a id="btnOK" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
</div>
<div id="pushList">
......@@ -83,7 +85,7 @@
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < pushBtnJSON.length; j++) {
if (pushBtnJSON[j].id === arr[i] - 0) {
str += "<input type='checkbox' value='" + pushBtnJSON[j].id + "' />" + pushBtnJSON[j].text;
str += "<input type='checkbox' value='" + pushBtnJSON[j].id + "' />" + pushBtnJSON[j].text + " ";
}
}
}
......@@ -211,6 +213,40 @@
}
$(this).closest(".datagrid-row").find("[field='Id']").attr("data-btn", checkStr);
});
//全选
$("#btnAllCheck").off("click").on("click", function () {
bindBody.find(".datagrid-row").each(function () {
$(this).find("[field='PushBtnList']").find("input").each(function () {
$(this).prop("checked", "checked");
});
$(this).find("[field='PushBtnList']").find("input").each(function () {
var checkStr = "";
$(this).closest(".datagrid-cell").find("input").each(function () {
var thisValue = $(this).val(); //勾选的值
var isChecked = $(this).prop("checked");
if (isChecked) {
checkStr = checkStr + thisValue + ",";
}
});
if (checkStr) {
checkStr = checkStr.substring(0, checkStr.length - 1);
}
$(this).closest(".datagrid-row").find("[field='Id']").attr("data-btn", checkStr);
});
});
});
//全取消
$("#btnAllCancel").off("click").on("click", function () {
bindBody.find(".datagrid-row").each(function () {
$(this).find("[field='Id']").attr("data-btn", "");
$(this).find("[field='PushBtnList']").find("input").each(function () {
$(this).prop("checked", "");
});
});
});
}, 500);
$("#btnOK").off("click").on("click", function () {
......
......@@ -35,9 +35,9 @@
</div>
<div class="form-group">
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a>
<a id="btnSetRole" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配角色'>分配角色</a>
<a id="btnSetDepart" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配仓库'>分配仓库</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a>&nbsp;
<a id="btnSetRole" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配角色'>分配角色</a>&nbsp;
<a id="btnSetDepart" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配仓库'>分配仓库</a>&nbsp;
<a id="btnSetCustomer" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配客户'>分配客户</a>
</div>
</div>
......
......@@ -368,7 +368,7 @@ public class DepotHeadController {
String updated = body.getUpdated();
Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString());
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null);
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null);
if(count>= billsNumLimit) {
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
......
......@@ -106,6 +106,8 @@ public class UserController {
//验证通过 ,可以登录,放入session,记录登录日志
user = userService.getUserByLoginName(loginName);
request.getSession().setAttribute("user",user);
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
request.getSession().setAttribute("roleType",roleType);
if(user.getTenantId()!=null) {
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
if(tenant!=null) {
......@@ -346,4 +348,19 @@ public class UserController {
}
return arr;
}
@GetMapping("/getRoleTypeByUserId")
public BaseResponseInfo getRoleTypeByUserId(HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
try {
Map<String, Object> data = new HashMap<String, Object>();
data.put("roleType", request.getSession().getAttribute("roleType"));
res.code = 200;
res.data = data;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取失败";
}
return res;
}
}
......@@ -21,6 +21,7 @@ public interface DepotHeadMapperEx {
List<DepotHeadVo4List> selectByConditionDepotHead(
@Param("type") String type,
@Param("subType") String subType,
@Param("handsPersonId") Long handsPersonId,
@Param("number") String number,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
......@@ -32,6 +33,7 @@ public interface DepotHeadMapperEx {
Long countsByDepotHead(
@Param("type") String type,
@Param("subType") String subType,
@Param("handsPersonId") Long handsPersonId,
@Param("number") String number,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
......
......@@ -32,12 +32,13 @@ public class DepotHeadComponent implements ICommonQuery {
String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type");
String subType = StringUtil.getInfo(search, "subType");
String roleType = StringUtil.getInfo(search, "roleType");
String number = StringUtil.getInfo(search, "number");
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
String materialParam = StringUtil.getInfo(search, "materialParam");
String depotIds = StringUtil.getInfo(search, "depotIds");
return depotHeadService.select(type, subType, number, beginTime, endTime, materialParam, depotIds, QueryUtils.offset(map), QueryUtils.rows(map));
return depotHeadService.select(type, subType, roleType, number, beginTime, endTime, materialParam, depotIds, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
......@@ -45,12 +46,13 @@ public class DepotHeadComponent implements ICommonQuery {
String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type");
String subType = StringUtil.getInfo(search, "subType");
String roleType = StringUtil.getInfo(search, "roleType");
String number = StringUtil.getInfo(search, "number");
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
String materialParam = StringUtil.getInfo(search, "materialParam");
String depotIds = StringUtil.getInfo(search, "depotIds");
return depotHeadService.countDepotHead(type, subType, number, beginTime, endTime, materialParam, depotIds);
return depotHeadService.countDepotHead(type, subType, roleType, number, beginTime, endTime, materialParam, depotIds);
}
@Override
......
......@@ -79,12 +79,17 @@ public class DepotHeadService {
return list;
}
public List<DepotHeadVo4List> select(String type, String subType, String number, String beginTime, String endTime,
public List<DepotHeadVo4List> select(String type, String subType, String roleType, String number, String beginTime, String endTime,
String materialParam, String depotIds, int offset, int rows)throws Exception {
Long handsPersonId = null;
User user = userService.getCurrentUser();
if("个人数据".equals(roleType)) {
handsPersonId = user.getId();
}
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list=null;
try{
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, number, beginTime, endTime, materialParam, depotIds, offset, rows);
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, handsPersonId, number, beginTime, endTime, materialParam, depotIds, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
......@@ -118,13 +123,16 @@ public class DepotHeadService {
return resList;
}
public Long countDepotHead(String type, String subType, String number, String beginTime, String endTime,
public Long countDepotHead(String type, String subType, String roleType,String number, String beginTime, String endTime,
String materialParam, String depotIds) throws Exception{
Long handsPersonId = null;
User user = userService.getCurrentUser();
if("个人数据".equals(roleType)) {
handsPersonId = user.getId();
}
Long result=null;
try{
result=depotHeadMapperEx.countsByDepotHead(type, subType, number, beginTime, endTime, materialParam, depotIds);
result=depotHeadMapperEx.countsByDepotHead(type, subType, handsPersonId, number, beginTime, endTime, materialParam, depotIds);
}catch(Exception e){
JshException.readFail(logger, e);
}
......
package com.jsh.erp.service.user;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.service.role.RoleService;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.OrgaUserRel;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserEx;
import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.datasource.mappers.UserMapperEx;
import com.jsh.erp.datasource.vo.TreeNodeEx;
......@@ -61,6 +59,8 @@ public class UserService {
private TenantService tenantService;
@Resource
private UserBusinessService userBusinessService;
@Resource
private RoleService roleService;
public User getUser(long id)throws Exception {
User result=null;
......@@ -675,4 +675,35 @@ public class UserService {
}
return list;
}
/**
* 根据用户id查询角色类型
* @param userId
* @return
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String getRoleTypeByUserId(long userId) throws Exception {
List<UserBusiness> list = userBusinessService.getBasicData(String.valueOf(userId), "UserRole");
UserBusiness ub = null;
if(list.size() > 0) {
ub = list.get(0);
String values = ub.getValue();
String roleId = null;
if(values!=null) {
values = values.replaceAll("\\[\\]",",").replace("[","").replace("]","");
}
String [] valueArray=values.split(",");
if(valueArray.length>0) {
roleId = valueArray[0];
}
Role role = roleService.getRole(Long.parseLong(roleId));
if(role!=null) {
return role.getType();
} else {
return null;
}
} else {
return null;
}
}
}
......@@ -55,6 +55,9 @@
<if test="subType != null">
and dh.sub_type='${subType}'
</if>
<if test="handsPersonId != null">
and dh.hands_person_id='${handsPersonId}'
</if>
<if test="number != null">
and dh.number like '%${number}%'
</if>
......@@ -89,6 +92,9 @@
<if test="subType != null">
and sub_type='${subType}'
</if>
<if test="handsPersonId != null">
and hands_person_id='${handsPersonId}'
</if>
<if test="number != null">
and number like '%${number}%'
</if>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment