forked from p81075629/datagear
完善角色管理功能
This commit is contained in:
parent
3099af5d99
commit
67b478c768
|
@ -53,7 +53,7 @@ public class Authorization extends AbstractStringIdEntity implements CreateUserE
|
|||
private String permission;
|
||||
|
||||
/** 是否已禁用 */
|
||||
private boolean disabled = false;
|
||||
private boolean enabled = false;
|
||||
|
||||
/** 授权创建用户 */
|
||||
private User createUser;
|
||||
|
@ -140,14 +140,14 @@ public class Authorization extends AbstractStringIdEntity implements CreateUserE
|
|||
return PERMISSION_WRITE.equals(this.permission);
|
||||
}
|
||||
|
||||
public boolean isDisabled()
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return disabled;
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.disabled = disabled;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,11 @@ public class Role extends AbstractStringIdEntity
|
|||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 是否已禁用 */
|
||||
private boolean disabled = false;
|
||||
/** 描述 */
|
||||
private String description;
|
||||
|
||||
/** 是否启用 */
|
||||
private boolean enabled = true;
|
||||
|
||||
public Role()
|
||||
{
|
||||
|
@ -43,13 +46,23 @@ public class Role extends AbstractStringIdEntity
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isDisabled()
|
||||
public String getDescription()
|
||||
{
|
||||
return disabled;
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled)
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.disabled = disabled;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,8 @@ CREATE TABLE DATAGEAR_ROLE
|
|||
(
|
||||
ROLE_ID VARCHAR(50) NOT NULL,
|
||||
ROLE_NAME VARCHAR(100) NOT NULL,
|
||||
ROLE_DISABLED VARCHAR(10) NOT NULL,
|
||||
ROLE_DESCRIPTION VARCHAR(200),
|
||||
ROLE_ENABLED VARCHAR(10) NOT NULL,
|
||||
ROLE_CREATE_TIME TIMESTAMP,
|
||||
PRIMARY KEY (ROLE_ID)
|
||||
);
|
||||
|
@ -135,7 +136,7 @@ CREATE TABLE DATAGEAR_AUTHORIZATION
|
|||
AUTH_TARGET VARCHAR(200) NOT NULL,
|
||||
AUTH_TARGET_TYPE VARCHAR(50) NOT NULL,
|
||||
AUTH_PERMISSION VARCHAR(50) NOT NULL,
|
||||
AUTH_DISABLED VARCHAR(10) NOT NULL,
|
||||
AUTH_ENABLED VARCHAR(10) NOT NULL,
|
||||
AUTH_CREATE_TIME TIMESTAMP,
|
||||
AUTH_CREATE_USER_ID VARCHAR(50),
|
||||
PRIMARY KEY (AUTH_ID)
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
INSERT INTO DATAGEAR_AUTHORIZATION
|
||||
(
|
||||
AUTH_ID, AUTH_SOURCE, AUTH_SOURCE_TYPE, AUTH_TARGET, AUTH_TARGET_TYPE,
|
||||
AUTH_PERMISSION, AUTH_DISABLED, AUTH_CREATE_USER_ID
|
||||
AUTH_PERMISSION, AUTH_ENABLED, AUTH_CREATE_USER_ID
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{entity.id}, #{entity.source}, #{entity.sourceType}, #{entity.target}, #{entity.targetType},
|
||||
#{entity.permission}, #{entity.disabled},#{entity.createUser.id}
|
||||
#{entity.permission}, #{entity.enabled},#{entity.createUser.id}
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
AUTH_TARGET = #{entity.target},
|
||||
AUTH_TARGET_TYPE = #{entity.targetType},
|
||||
AUTH_PERMISSION = #{entity.permission},
|
||||
AUTH_DISABLED = #{entity.disabled}
|
||||
AUTH_ENABLED = #{entity.enabled}
|
||||
WHERE
|
||||
AUTH_ID = #{entity.id}
|
||||
<if test="OPERATOR != null and OPERATOR.admin != true">
|
||||
|
@ -88,17 +88,16 @@
|
|||
A.AUTH_TARGET AS ${_iq_}target${_iq_},
|
||||
A.AUTH_TARGET_TYPE AS ${_iq_}targetType${_iq_},
|
||||
A.AUTH_PERMISSION AS ${_iq_}permission${_iq_},
|
||||
A.AUTH_DISABLED AS ${_iq_}disabled${_iq_},
|
||||
A.AUTH_ENABLED AS ${_iq_}enabled${_iq_},
|
||||
A.AUTH_CREATE_TIME AS ${_iq_}ceateTime${_iq_},
|
||||
A.AUTH_CREATE_USER_ID AS ${_iq_}createUser.id${_iq_},
|
||||
B.USER_NAME AS ${_iq_}createUser.name${_iq_},
|
||||
B.USER_REAL_NAME AS ${_iq_}createUser.realName${_iq_},
|
||||
(CASE WHEN B.USER_IS_ADMIN IS NULL THEN '0' ELSE B.USER_IS_ADMIN END) AS ${_iq_}createUser.admin${_iq_},
|
||||
(CASE WHEN B.USER_ID IS NULL THEN '1' ELSE '0' END) AS ${_iq_}createUser.anonymous${_iq_},
|
||||
B.USER_IS_ADMIN AS ${_iq_}createUser.admin${_iq_},
|
||||
B.USER_CREATE_TIME AS ${_iq_}createUser.createTime${_iq_}
|
||||
FROM
|
||||
DATAGEAR_AUTHORIZATION A
|
||||
LEFT JOIN
|
||||
INNER JOIN
|
||||
DATAGEAR_USER B
|
||||
ON
|
||||
A.AUTH_CREATE_USER_ID = B.USER_ID
|
||||
|
|
|
@ -6,18 +6,19 @@
|
|||
<insert id="insert">
|
||||
INSERT INTO DATAGEAR_ROLE
|
||||
(
|
||||
ROLE_ID, ROLE_NAME, ROLE_DISABLED
|
||||
ROLE_ID, ROLE_NAME, ROLE_DESCRIPTION, ROLE_ENABLED
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{entity.id}, #{entity.name}, #{entity.disabled}
|
||||
#{entity.id}, #{entity.name}, #{entity.description}, #{entity.enabled}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE DATAGEAR_ROLE SET
|
||||
ROLE_NAME = #{entity.name},
|
||||
ROLE_DISABLED = #{entity.disabled}
|
||||
ROLE_DESCRIPTION = #{entity.description},
|
||||
ROLE_ENABLED = #{entity.enabled}
|
||||
WHERE
|
||||
ROLE_ID = #{entity.id}
|
||||
<if test="OPERATOR != null and OPERATOR.admin != true">
|
||||
|
@ -78,7 +79,8 @@
|
|||
SELECT
|
||||
A.ROLE_ID AS ${_iq_}id${_iq_},
|
||||
A.ROLE_NAME AS ${_iq_}name${_iq_},
|
||||
A.ROLE_DISABLED AS ${_iq_}disabled${_iq_}
|
||||
A.ROLE_DESCRIPTION AS ${_iq_}description${_iq_},
|
||||
A.ROLE_ENABLED AS ${_iq_}enabled${_iq_}
|
||||
FROM
|
||||
DATAGEAR_ROLE A
|
||||
</sql>
|
||||
|
@ -89,6 +91,7 @@
|
|||
AND
|
||||
(
|
||||
${_iq_}name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}description${_iq_} LIKE #{queryKeyword}
|
||||
)
|
||||
</if>
|
||||
<include refid="common.queryCondition" />
|
||||
|
|
|
@ -79,19 +79,23 @@
|
|||
A.RU_ID AS ${_iq_}id${_iq_},
|
||||
A.RU_ROLE_ID AS ${_iq_}role.id${_iq_},
|
||||
B.ROLE_NAME AS ${_iq_}role.name${_iq_},
|
||||
B.ROLE_DISABLED AS ${_iq_}role.disabled${_iq_},
|
||||
B.ROLE_DESCRIPTION AS ${_iq_}role.description${_iq_},
|
||||
B.ROLE_ENABLED AS ${_iq_}role.enabled${_iq_},
|
||||
A.RU_USER_ID AS ${_iq_}user.id${_iq_},
|
||||
C.USER_NAME AS ${_iq_}user.name${_iq_},
|
||||
C.USER_REAL_NAME AS ${_iq_}user.realName${_iq_},
|
||||
(CASE WHEN C.USER_IS_ADMIN IS NULL THEN '0' ELSE C.USER_IS_ADMIN END) AS ${_iq_}user.admin${_iq_},
|
||||
(CASE WHEN C.USER_ID IS NULL THEN '1' ELSE '0' END) AS ${_iq_}user.anonymous${_iq_},
|
||||
C.USER_IS_ADMIN AS ${_iq_}user.admin${_iq_},
|
||||
C.USER_CREATE_TIME AS ${_iq_}user.createTime${_iq_}
|
||||
FROM
|
||||
DATAGEAR_ROLE_USER A,
|
||||
DATAGEAR_ROLE B,
|
||||
DATAGEAR_ROLE_USER A
|
||||
INNER JOIN
|
||||
DATAGEAR_ROLE B
|
||||
ON
|
||||
A.RU_ROLE_ID = B.ROLE_ID
|
||||
INNER JOIN
|
||||
DATAGEAR_USER C
|
||||
WHERE
|
||||
A.RU_ROLE_ID = B.ROLE_ID AND A.RU_USER_ID = C.USER_ID
|
||||
ON
|
||||
A.RU_USER_ID = C.USER_ID
|
||||
</sql>
|
||||
|
||||
<sql id="queryCondition">
|
||||
|
@ -100,6 +104,7 @@
|
|||
AND
|
||||
(
|
||||
${_iq_}role.name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}role.description${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}user.name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}user.realName${_iq_} LIKE #{queryKeyword}
|
||||
)
|
||||
|
|
|
@ -10,6 +10,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.datagear.management.domain.Role;
|
||||
import org.datagear.management.domain.RoleUser;
|
||||
import org.datagear.management.domain.User;
|
||||
import org.datagear.management.service.RoleService;
|
||||
import org.datagear.management.service.RoleUserService;
|
||||
import org.datagear.persistence.PagingQuery;
|
||||
|
@ -77,6 +79,9 @@ public class RoleController extends AbstractController
|
|||
@RequestMapping("/add")
|
||||
public String add(HttpServletRequest request, org.springframework.ui.Model model)
|
||||
{
|
||||
Role role = new Role();
|
||||
|
||||
model.addAttribute("role", role);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "role.addRole");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveAdd");
|
||||
|
||||
|
@ -178,9 +183,85 @@ public class RoleController extends AbstractController
|
|||
return roles;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/user/query")
|
||||
public String userQuery(HttpServletRequest request, HttpServletResponse response,
|
||||
org.springframework.ui.Model model, @RequestParam("id") String id)
|
||||
{
|
||||
Role role = this.roleService.getById(id);
|
||||
|
||||
if (role == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
model.addAttribute("role", role);
|
||||
|
||||
return "/role/role_user_grid";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/user/queryData", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public List<RoleUser> userQueryData(HttpServletRequest request, HttpServletResponse response) throws Exception
|
||||
{
|
||||
PagingQuery pagingQuery = getPagingQuery(request, null);
|
||||
|
||||
List<RoleUser> roleUsers = this.roleUserService.query(pagingQuery);
|
||||
|
||||
return roleUsers;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "user/saveAdd", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> userSaveAdd(HttpServletRequest request, HttpServletResponse response,
|
||||
RoleUsersForm roleUsersForm)
|
||||
{
|
||||
Role role = roleUsersForm.getRole();
|
||||
List<User> users = roleUsersForm.getUsers();
|
||||
|
||||
if (isEmpty(role) || isEmpty(users))
|
||||
throw new IllegalInputException();
|
||||
|
||||
for (User user : users)
|
||||
{
|
||||
RoleUser roleUser = new RoleUser(IDUtil.uuid(), role, user);
|
||||
this.roleUserService.add(roleUser);
|
||||
}
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String buildMessageCode(String code)
|
||||
{
|
||||
return buildMessageCode("user", code);
|
||||
}
|
||||
|
||||
public static class RoleUsersForm
|
||||
{
|
||||
private Role role;
|
||||
private List<User> users;
|
||||
|
||||
public RoleUsersForm()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public Role getRole()
|
||||
{
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Role role)
|
||||
{
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public List<User> getUsers()
|
||||
{
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(List<User> users)
|
||||
{
|
||||
this.users = users;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,8 +208,13 @@ public class UserController extends AbstractController
|
|||
@RequestMapping(value = "/select")
|
||||
public String select(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model)
|
||||
{
|
||||
boolean isMultipleSelect = false;
|
||||
if (request.getParameter("multiple") != null)
|
||||
isMultipleSelect = true;
|
||||
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "user.selectUser");
|
||||
model.addAttribute(KEY_SELECTONLY, "true");
|
||||
model.addAttribute(KEY_SELECTONLY, true);
|
||||
model.addAttribute("isMultipleSelect", isMultipleSelect);
|
||||
|
||||
return "/user/user_grid";
|
||||
}
|
||||
|
|
|
@ -41,12 +41,8 @@
|
|||
<intercept-url pattern="/user/query" access="ROLE_ADMIN" />
|
||||
|
||||
<!-- 角色管理 -->
|
||||
<intercept-url pattern="/role/add" access="ROLE_ADMIN" />
|
||||
<intercept-url pattern="/role/saveAdd" access="ROLE_ADMIN" />
|
||||
<intercept-url pattern="/role/edit" access="ROLE_ADMIN" />
|
||||
<intercept-url pattern="/role/saveEdit" access="ROLE_ADMIN" />
|
||||
<intercept-url pattern="/role/delete" access="ROLE_ADMIN" />
|
||||
<intercept-url pattern="/role/query" access="ROLE_ADMIN" />
|
||||
<intercept-url pattern="/role/select" access="ROLE_USER" />
|
||||
<intercept-url pattern="/role/**" access="ROLE_ADMIN" />
|
||||
|
||||
<!-- 全局设置 -->
|
||||
<intercept-url pattern="/globalSetting/**" access="ROLE_ADMIN" />
|
||||
|
@ -63,7 +59,7 @@
|
|||
<intercept-url pattern="/notification/**" access="IS_AUTHENTICATED_ANONYMOUSLY, ROLE_USER" />
|
||||
<intercept-url pattern="/changeThemeData/**" access="IS_AUTHENTICATED_ANONYMOUSLY, ROLE_USER" />
|
||||
|
||||
<intercept-url pattern="/**" access="#{sercurityDisableAnonymous ? 'ROLE_USER, ROLE_ADMIN' : 'IS_AUTHENTICATED_ANONYMOUSLY, ROLE_USER, ROLE_ADMIN'}" />
|
||||
<intercept-url pattern="/**" access="#{sercurityDisableAnonymous ? 'ROLE_USER' : 'IS_AUTHENTICATED_ANONYMOUSLY, ROLE_USER'}" />
|
||||
|
||||
<!-- 表单登录页登录 -->
|
||||
<form-login login-page="/login" login-processing-url="/login/doLogin"
|
||||
|
|
|
@ -61,6 +61,8 @@ rowNumber=\u884C\u53F7
|
|||
download=\u4E0B\u8F7D
|
||||
downloadAll=\u4E0B\u8F7D\u5168\u90E8
|
||||
return=\u8FD4\u56DE
|
||||
id=ID
|
||||
confirmDelete=\u786E\u5B9A\u5220\u9664\u9009\u4E2D\u6761\u76EE\u5417\uFF1F
|
||||
|
||||
dataTables.noData=\u6CA1\u6709\u6570\u636E
|
||||
dataTables.zeroRecords=\u6CA1\u6709\u7ED3\u679C
|
||||
|
@ -319,7 +321,7 @@ user.viewUser=\u67E5\u770B\u7528\u6237
|
|||
user.manageUser=\u7BA1\u7406\u7528\u6237
|
||||
user.selectUser=\u9009\u62E9\u7528\u6237
|
||||
user.personalSet=\u4E2A\u4EBA\u8BBE\u7F6E
|
||||
user.user.id=ID
|
||||
user.id=ID
|
||||
user.name=\u7528\u6237\u540D
|
||||
user.password=\u5BC6\u7801
|
||||
user.realName=\u59D3\u540D
|
||||
|
@ -517,7 +519,10 @@ role.editRole=\u7F16\u8F91\u7528\u6237\u7EC4
|
|||
role.viewRole=\u67E5\u770B\u7528\u6237\u7EC4
|
||||
role.manageRole=\u7BA1\u7406\u7528\u6237\u7EC4
|
||||
role.selectRole=\u9009\u62E9\u7528\u6237\u7EC4
|
||||
role.editUser=\u7F16\u8F91\u7528\u6237
|
||||
role.editAuthorization=\u7F16\u8F91\u6743\u9650
|
||||
role.id=ID
|
||||
role.name=\u540D\u79F0
|
||||
role.disabled=\u662F\u5426\u7981\u7528
|
||||
role.description=\u63CF\u8FF0
|
||||
role.enabled=\u662F\u5426\u542F\u7528
|
||||
role.confirmDelete=\u786E\u5B9A\u5220\u9664\u9009\u4E2D\u7684\u7528\u6237\u7EC4\u5417\uFF1F
|
|
@ -29,14 +29,22 @@ readonly 是否只读操作,允许为null
|
|||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='role.disabled' /></label>
|
||||
<label><@spring.message code='role.description' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<div class="roleDisabled-radios">
|
||||
<label for="${pageId}-roleDisabledYes"><@spring.message code='yes' /></label>
|
||||
<input type="radio" id="${pageId}-roleDisabledYes" name="disabled" value="1" <#if (role.disabled)!false>checked="checked"</#if> />
|
||||
<label for="${pageId}-roleDisabledNo"><@spring.message code='no' /></label>
|
||||
<input type="radio" id="${pageId}-roleDisabledNo" name="disabled" value="0" <#if !((role.disabled)!false)>checked="checked"</#if> />
|
||||
<textarea name="description" class="ui-widget ui-widget-content">${(role.description)!''?html}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='role.enabled' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<div class="roleEnabled-radios">
|
||||
<label for="${pageId}-roleEnabledYes"><@spring.message code='yes' /></label>
|
||||
<input type="radio" id="${pageId}-roleEnabledYes" name="enabled" value="1" <#if (role.enabled)!false>checked="checked"</#if> />
|
||||
<label for="${pageId}-roleEnabledNo"><@spring.message code='no' /></label>
|
||||
<input type="radio" id="${pageId}-roleEnabledNo" name="enabled" value="0" <#if !((role.enabled)!false)>checked="checked"</#if> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -56,8 +64,8 @@ readonly 是否只读操作,允许为null
|
|||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element());
|
||||
po.element("input[name='disabled']").checkboxradio({icon:false});
|
||||
po.element(".roleDisabled-radios").controlgroup();
|
||||
po.element("input[name='enabled']").checkboxradio({icon:false});
|
||||
po.element(".roleEnabled-radios").controlgroup();
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,8 @@ selectonly 是否选择操作,允许为null
|
|||
<#else>
|
||||
<input name="addButton" type="button" value="<@spring.message code='add' />" />
|
||||
<input name="editButton" type="button" value="<@spring.message code='edit' />" />
|
||||
<input name="editUserButton" type="button" value="<@spring.message code='role.editUser' />" />
|
||||
<input name="editAuthorizationButton" type="button" value="<@spring.message code='role.editAuthorization' />" />
|
||||
<input name="viewButton" type="button" value="<@spring.message code='view' />" />
|
||||
<input name="deleteButton" type="button" value="<@spring.message code='delete' />" />
|
||||
</#if>
|
||||
|
@ -58,10 +60,29 @@ selectonly 是否选择操作,允许为null
|
|||
};
|
||||
|
||||
<#if !selectonly>
|
||||
po.element("input[name=addButton]").click(function()
|
||||
po.element("input[name=addButton]").click(function()
|
||||
{
|
||||
po.open(po.url("add"),
|
||||
{
|
||||
po.open(po.url("add"),
|
||||
pageParam :
|
||||
{
|
||||
afterSave : function()
|
||||
{
|
||||
po.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=editButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("edit"),
|
||||
{
|
||||
data : data,
|
||||
pageParam :
|
||||
{
|
||||
afterSave : function()
|
||||
|
@ -71,28 +92,24 @@ selectonly 是否选择操作,允许为null
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=editButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("edit"),
|
||||
{
|
||||
data : data,
|
||||
pageParam :
|
||||
{
|
||||
afterSave : function()
|
||||
{
|
||||
po.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</#if>
|
||||
});
|
||||
|
||||
po.element("input[name=editUserButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var options =
|
||||
{
|
||||
data : {"id" : row.id}
|
||||
};
|
||||
|
||||
$.setGridPageHeightOption(options);
|
||||
|
||||
po.open(po.url("user/query"), options);
|
||||
});
|
||||
});
|
||||
</#if>
|
||||
|
||||
po.element("input[name=viewButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
|
@ -143,8 +160,8 @@ selectonly 是否选择操作,允许为null
|
|||
});
|
||||
});
|
||||
|
||||
var columnDisabled = $.buildDataTablesColumnSimpleOption("<@spring.message code='role.disabled' />", "disabled");
|
||||
columnDisabled.render = function(data, type, row, meta)
|
||||
var columnEnabled = $.buildDataTablesColumnSimpleOption("<@spring.message code='role.enabled' />", "enabled");
|
||||
columnEnabled.render = function(data, type, row, meta)
|
||||
{
|
||||
if(data == true)
|
||||
data = "<@spring.message code='yes' />";
|
||||
|
@ -157,7 +174,8 @@ selectonly 是否选择操作,允许为null
|
|||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='role.id' />", "id", true),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='role.name' />", "name"),
|
||||
columnDisabled
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='role.description' />", "description"),
|
||||
columnEnabled
|
||||
];
|
||||
var tableSettings = po.buildDataTableSettingsAjax(tableColumns, po.url("queryData"));
|
||||
po.initDataTable(tableSettings);
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<#include "../include/import_global.ftl">
|
||||
<#include "../include/html_doctype.ftl">
|
||||
<html>
|
||||
<head>
|
||||
<#include "../include/html_head.ftl">
|
||||
<title><#include "../include/html_title_app_name.ftl"><@spring.message code='role.editUser' /></title>
|
||||
</head>
|
||||
<body class="fill-parent">
|
||||
<#if !isAjaxRequest>
|
||||
<div class="fill-parent">
|
||||
</#if>
|
||||
<div id="${pageId}" class="page-grid page-grid-hidden-foot page-grid-role-user">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<#include "../include/page_obj_searchform.html.ftl">
|
||||
</div>
|
||||
<div class="operation">
|
||||
<input name="addButton" type="button" value="<@spring.message code='add' />" />
|
||||
<input name="deleteButton" type="button" value="<@spring.message code='delete' />" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<table id="${pageId}-table" width="100%" class="hover stripe">
|
||||
</table>
|
||||
</div>
|
||||
<div class="foot">
|
||||
<div class="pagination-wrapper">
|
||||
<div id="${pageId}-pagination" class="pagination"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<#if !isAjaxRequest>
|
||||
</div>
|
||||
</#if>
|
||||
<#include "../include/page_js_obj.ftl">
|
||||
<#include "../include/page_obj_searchform_js.ftl">
|
||||
<#include "../include/page_obj_grid.ftl">
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element(".operation"));
|
||||
|
||||
po.role = <@writeJson var=role />;
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
return "${contextPath}/role/user/" + action;
|
||||
};
|
||||
|
||||
po.element("input[name=addButton]").click(function()
|
||||
{
|
||||
var options =
|
||||
{
|
||||
pageParam :
|
||||
{
|
||||
submit : function(users)
|
||||
{
|
||||
var data = {role : po.role, users : users};
|
||||
|
||||
$.post(po.url("saveAdd"), data, function()
|
||||
{
|
||||
po.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.setGridPageHeightOption(options);
|
||||
|
||||
po.open("${contextPath}/user/select?multiple", options);
|
||||
});
|
||||
|
||||
po.element("input[name=deleteButton]").click(
|
||||
function()
|
||||
{
|
||||
po.executeOnSelects(function(rows)
|
||||
{
|
||||
po.confirm("<@spring.message code='confirmDelete' />",
|
||||
{
|
||||
"confirm" : function()
|
||||
{
|
||||
var data = $.getPropertyParamString(rows, "id");
|
||||
|
||||
$.post(po.url("delete"), data, function()
|
||||
{
|
||||
po.refresh();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "id", true),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "user.id", true),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='user.name' />", "user.name"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='user.realName' />", "user.realName")
|
||||
];
|
||||
var tableSettings = po.buildDataTableSettingsAjax(tableColumns, po.url("queryData"));
|
||||
po.initDataTable(tableSettings);
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -5,6 +5,7 @@ titleMessageKey 标题标签I18N关键字,不允许null
|
|||
selectonly 是否选择操作,允许为null
|
||||
-->
|
||||
<#assign selectonly=(selectonly!false)>
|
||||
<#assign isMultipleSelect=(isMultipleSelect!false)>
|
||||
<html>
|
||||
<head>
|
||||
<#include "../include/html_head.ftl">
|
||||
|
@ -128,8 +129,22 @@ selectonly 是否选择操作,允许为null
|
|||
});
|
||||
</#if>
|
||||
|
||||
<#if selectonly>
|
||||
po.element("input[name=confirmButton]").click(function()
|
||||
{
|
||||
<#if isMultipleSelect>
|
||||
po.executeOnSelects(function(rows)
|
||||
{
|
||||
var close = po.pageParamCall("submit", rows);
|
||||
|
||||
//单选默认关闭
|
||||
if(close == undefined)
|
||||
close = true;
|
||||
|
||||
if(close)
|
||||
po.close();
|
||||
});
|
||||
<#else>
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var close = po.pageParamCall("submit", row);
|
||||
|
@ -141,7 +156,9 @@ selectonly 是否选择操作,允许为null
|
|||
if(close)
|
||||
po.close();
|
||||
});
|
||||
</#if>
|
||||
});
|
||||
</#if>
|
||||
|
||||
po.buildTableColumValueOption = function(title, data, hidden)
|
||||
{
|
||||
|
@ -160,23 +177,11 @@ selectonly 是否选择操作,允许为null
|
|||
return option;
|
||||
};
|
||||
|
||||
var columnAdmin = po.buildTableColumValueOption("<@spring.message code='user.admin' />", "admin");
|
||||
columnAdmin.render = function(data, type, row, meta)
|
||||
{
|
||||
if(data == true)
|
||||
data = "<@spring.message code='yes' />";
|
||||
else
|
||||
data = "<@spring.message code='no' />";
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
var tableColumns = [
|
||||
po.buildTableColumValueOption("<@spring.message code='user.user.id' />", "id", true),
|
||||
po.buildTableColumValueOption("<@spring.message code='user.id' />", "id", true),
|
||||
po.buildTableColumValueOption("<@spring.message code='user.name' />", "name"),
|
||||
po.buildTableColumValueOption("<@spring.message code='user.realName' />", "realName"),
|
||||
po.buildTableColumValueOption("<@spring.message code='user.email' />", "email"),
|
||||
columnAdmin,
|
||||
po.buildTableColumValueOption("<@spring.message code='user.createTime' />", "createTime")
|
||||
];
|
||||
var tableSettings = po.buildDataTableSettingsAjax(tableColumns, po.url("queryData"));
|
||||
|
|
|
@ -737,6 +737,7 @@
|
|||
visible : !hidden,
|
||||
render: function(data, type, row, meta)
|
||||
{
|
||||
data = $.truncateIf(data);
|
||||
return $.escapeHtml(data);
|
||||
},
|
||||
defaultContent: "",
|
||||
|
|
Loading…
Reference in New Issue