调整人员管理模块

This commit is contained in:
wanggeng888 2021-06-17 18:13:05 +08:00
parent 5322f8d174
commit 7b22636da0
6 changed files with 92 additions and 228 deletions

View File

@ -50,7 +50,7 @@ public class CheckApp2Controller extends AbstractController {
@ApiImplicitParam(name = "checkId", value = "原检查ID", paramType = "path") @ApiImplicitParam(name = "checkId", value = "原检查ID", paramType = "path")
}) })
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("save") @PostMapping("save-re")
@CheckRequestBodyAnnotation @CheckRequestBodyAnnotation
public SuccessResult saveRe(@RequestHeader("token") String token, public SuccessResult saveRe(@RequestHeader("token") String token,
@PathVariable("checkId") String checkId, @PathVariable("checkId") String checkId,

View File

@ -26,10 +26,6 @@ public class GridPersonnelDTO implements Serializable {
private String userId; private String userId;
@ApiModelProperty(name = "userName", value = "用户名称") @ApiModelProperty(name = "userName", value = "用户名称")
private String userName; private String userName;
@ApiModelProperty(name = "departmentId", value = "部门ID")
private String departmentId;
@ApiModelProperty(name = "departmentName", value = "部门名称")
private String departmentName;
@ApiModelProperty(name = "area1", value = "1级区域") @ApiModelProperty(name = "area1", value = "1级区域")
private String area1; private String area1;
@ApiModelProperty(name = "area1Name", value = "1级区域名称") @ApiModelProperty(name = "area1Name", value = "1级区域名称")
@ -54,10 +50,6 @@ public class GridPersonnelDTO implements Serializable {
private String leaderUserId; private String leaderUserId;
@ApiModelProperty(name = "leaderUserName", value = "领导用户昵称") @ApiModelProperty(name = "leaderUserName", value = "领导用户昵称")
private String leaderUserName; private String leaderUserName;
@ApiModelProperty(name = "leaderDepartmentId", value = "领导部门ID")
private String leaderDepartmentId;
@ApiModelProperty(name = "leaderDepartmentName", value = "领导部门名称")
private String leaderDepartmentName;
@ApiModelProperty(name = "personType", value = "人员类型") @ApiModelProperty(name = "personType", value = "人员类型")
private String personType; private String personType;
@ApiModelProperty(name = "gridType", value = "网格类型") @ApiModelProperty(name = "gridType", value = "网格类型")

View File

@ -29,10 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/** /**
* @ClassName: GridPersonnelServiceImpl * @ClassName: GridPersonnelServiceImpl
@ -203,7 +200,9 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson
@Override @Override
public List<GridPersonnelDTO> list(Map<String, Object> params) throws SearchException { public List<GridPersonnelDTO> list(Map<String, Object> params) throws SearchException {
return gridPersonnelDao.listGridPersonnel(params); List<GridPersonnelDTO> gridPersonnelDTOs = gridPersonnelDao.listGridPersonnel(params);
setGridPersonnelUserInfo(gridPersonnelDTOs);
return gridPersonnelDTOs;
} }
@Override @Override
@ -222,9 +221,8 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson
} }
page.getParams().put("userIds", userIds); page.getParams().put("userIds", userIds);
} }
List<GridPersonnelDTO> gridPersonnelDTOs = gridPersonnelDao.listGridPersonnel(page.getParams()); List<GridPersonnelDTO> gridPersonnelDTOs = list(page.getParams());
PageInfo<GridPersonnelDTO> pageInfo = new PageInfo<>(gridPersonnelDTOs); PageInfo<GridPersonnelDTO> pageInfo = new PageInfo<>(gridPersonnelDTOs);
setGridPersonnelUserInfo(gridPersonnelDTOs);
return new SuccessResultList<>(gridPersonnelDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); return new SuccessResultList<>(gridPersonnelDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
} }
@ -350,50 +348,24 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson
* @param gridPersonnelDTOs * @param gridPersonnelDTOs
*/ */
private void setGridPersonnelUserInfo(List<GridPersonnelDTO> gridPersonnelDTOs) { private void setGridPersonnelUserInfo(List<GridPersonnelDTO> gridPersonnelDTOs) {
List<String> userIds = new ArrayList<>(); if (gridPersonnelDTOs.isEmpty()) {
StringBuilder userIdsSB = new StringBuilder();
for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) {
if (userIdsSB.length() > 0) {
userIdsSB.append("_");
}
String userId = gridPersonnelDTO.getUserId();
userIdsSB.append(userId);
userIds.add(userId);
}
if (userIds.isEmpty()) {
return; return;
} }
// 账号信息 Set<String> userIdSet = new HashSet<>();
Map<String, Object> params = getHashMap(2);
params.put("userIds", userIdsSB.toString());
JSONArray userJSONArray = userService.listUserByIds(params);
// 动态个人信息
JSONArray userInfoJSONArray = userService.listDynamicUserInfoByIds(userIds);
for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) { for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) {
String userId = gridPersonnelDTO.getUserId(); userIdSet.add(gridPersonnelDTO.getUserId());
// 设置账号 userIdSet.add(gridPersonnelDTO.getLeaderUserId());
if (!userJSONArray.isEmpty()) { }
for (int i = 0; i < userJSONArray.size(); i++) { // 账号信息
JSONObject userJSONObject = userJSONArray.getJSONObject(i); List<UserResourceBO> userResourceBOs = userService.listUserResourceByIds(new ArrayList<>(userIdSet));
if (!StringUtils.equals(userId, userJSONObject.getString("userId"))) { for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) {
continue; for (UserResourceBO userResourceBO : userResourceBOs) {
} if (StringUtils.equals(gridPersonnelDTO.getUserId(), userResourceBO.getUserId())) {
gridPersonnelDTO.setUserPhone(userJSONObject.getString("userPhone")); gridPersonnelDTO.setUserName(userResourceBO.getUserName());
break; gridPersonnelDTO.setUserPhone(userResourceBO.getUserPhone());
} }
} if (StringUtils.equals(gridPersonnelDTO.getLeaderUserId(), userResourceBO.getUserId())) {
// 个人信息 gridPersonnelDTO.setLeaderUserName(userResourceBO.getUserName());
if (!userInfoJSONArray.isEmpty()) {
for (int i = 0; i < userInfoJSONArray.size(); i++) {
JSONObject userInfoJSONObject = userInfoJSONArray.getJSONObject(i);
if (!StringUtils.equals(userId, userInfoJSONObject.getString("userId"))) {
continue;
}
gridPersonnelDTO.setUserSex(userInfoJSONObject.getString("userSex"));
gridPersonnelDTO.setUserBirth(userInfoJSONObject.getString("userBirth"));
gridPersonnelDTO.setUserExplain(userInfoJSONObject.getString("userExplain"));
gridPersonnelDTO.setUserNation(userInfoJSONObject.getString("userNation"));
break;
} }
} }
} }

View File

@ -8,8 +8,6 @@
<id column="grid_personnel_id" property="gridPersonnelId"/> <id column="grid_personnel_id" property="gridPersonnelId"/>
<result column="user_id" property="userId"/> <result column="user_id" property="userId"/>
<result column="user_name" property="userName"/> <result column="user_name" property="userName"/>
<result column="department_id" property="departmentId"/>
<result column="department_name" property="departmentName"/>
<result column="area1" property="area1"/> <result column="area1" property="area1"/>
<result column="area1_name" property="area1Name"/> <result column="area1_name" property="area1Name"/>
<result column="area2" property="area2"/> <result column="area2" property="area2"/>
@ -21,9 +19,6 @@
<result column="area5" property="area5"/> <result column="area5" property="area5"/>
<result column="area5_name" property="area5Name"/> <result column="area5_name" property="area5Name"/>
<result column="leader_user_id" property="leaderUserId"/> <result column="leader_user_id" property="leaderUserId"/>
<result column="leader_department_id" property="leaderDepartmentId"/>
<result column="leader_user_name" property="leaderUserName"/>
<result column="leader_department_name" property="leaderDepartmentName"/>
<result column="level" property="level"/> <result column="level" property="level"/>
<result column="person_type" property="personType"/> <result column="person_type" property="personType"/>
<result column="grid_type" property="gridType"/> <result column="grid_type" property="gridType"/>
@ -35,18 +30,12 @@
INSERT INTO gen_grid_personnel( INSERT INTO gen_grid_personnel(
grid_personnel_id, grid_personnel_id,
user_id, user_id,
user_name,
department_id,
department_name,
area1, area1,
area2, area2,
area3, area3,
area4, area4,
area5, area5,
leader_user_id, leader_user_id,
leader_user_name,
leader_department_id,
leader_department_name,
person_type, person_type,
grid_type, grid_type,
level, level,
@ -58,18 +47,12 @@
) VALUES( ) VALUES(
#{gridPersonnelId}, #{gridPersonnelId},
#{userId}, #{userId},
#{userName},
#{departmentId},
#{departmentName},
#{area1}, #{area1},
#{area2}, #{area2},
#{area3}, #{area3},
#{area4}, #{area4},
#{area5}, #{area5},
#{leaderUserId}, #{leaderUserId},
#{leaderUserName},
#{leaderDepartmentId},
#{leaderDepartmentName},
#{personType}, #{personType},
#{gridType}, #{gridType},
#{level}, #{level},
@ -104,15 +87,6 @@
<if test="userId != null and userId != ''"> <if test="userId != null and userId != ''">
user_id = #{userId}, user_id = #{userId},
</if> </if>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="departmentId != null and departmentId != ''">
department_id = #{departmentId},
</if>
<if test="departmentName != null and departmentName != ''">
department_name = #{departmentName},
</if>
<if test="area1 != null"> <if test="area1 != null">
area1 = #{area1}, area1 = #{area1},
</if> </if>
@ -131,15 +105,6 @@
<if test="leaderUserId != null and leaderUserId != ''"> <if test="leaderUserId != null and leaderUserId != ''">
leader_user_id = #{leaderUserId}, leader_user_id = #{leaderUserId},
</if> </if>
<if test="leaderUserName != null and leaderUserName != ''">
leader_user_name = #{leaderUserName},
</if>
<if test="leaderDepartmentId != null and leaderDepartmentId != ''">
leader_department_id = #{leaderDepartmentId},
</if>
<if test="leaderDepartmentName != null and leaderDepartmentName != ''">
leader_department_name = #{leaderDepartmentName},
</if>
<if test="personType != null and personType != ''"> <if test="personType != null and personType != ''">
person_type = #{personType}, person_type = #{personType},
</if> </if>
@ -159,18 +124,12 @@
<select id="getGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO" useCache="false"> <select id="getGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO" useCache="false">
SELECT SELECT
t1.user_id, t1.user_id,
t1.user_name,
t1.department_id,
t1.department_name,
t1.area1, t1.area1,
t1.area2, t1.area2,
t1.area3, t1.area3,
t1.area4, t1.area4,
t1.area5, t1.area5,
t1.leader_user_id, t1.leader_user_id,
t1.leader_user_name,
t1.leader_department_id,
t1.leader_department_name,
t1.person_type, t1.person_type,
t1.grid_type, t1.grid_type,
t1.level, t1.level,
@ -193,9 +152,6 @@
<select id="listGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO" useCache="true"> <select id="listGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO" useCache="true">
SELECT SELECT
t1.user_id, t1.user_id,
t1.user_name,
t1.department_id,
t1.department_name,
t1.area1, t1.area1,
dt1.dictionary_name area1_name, dt1.dictionary_name area1_name,
t1.area2, t1.area2,
@ -207,9 +163,6 @@
t1.area5, t1.area5,
dt5.dictionary_name area5_name, dt5.dictionary_name area5_name,
t1.leader_user_id, t1.leader_user_id,
t1.leader_user_name,
t1.leader_department_id,
t1.leader_department_name,
t1.person_type, t1.person_type,
t1.grid_type, t1.grid_type,
t1.level, t1.level,
@ -338,18 +291,12 @@
<select id="listGridPersonnelSimple" parameterType="map" resultMap="gridPersonnelDTO" useCache="true"> <select id="listGridPersonnelSimple" parameterType="map" resultMap="gridPersonnelDTO" useCache="true">
SELECT SELECT
t1.user_id, t1.user_id,
t1.user_name,
t1.department_id,
t1.department_name,
t1.area1, t1.area1,
t1.area2, t1.area2,
t1.area3, t1.area3,
t1.area4, t1.area4,
t1.area5, t1.area5,
t1.leader_user_id, t1.leader_user_id,
t1.leader_user_name,
t1.leader_department_id,
t1.leader_department_name,
t1.person_type, t1.person_type,
t1.grid_type, t1.grid_type,
t1.level, t1.level,

View File

@ -22,17 +22,11 @@
<div class="layui-card-body" style="padding: 15px;"> <div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm"> <form class="layui-form layui-form-pane" lay-filter="dataForm">
<input type="hidden" id="leaderUserId" name="leaderUserId"/> <input type="hidden" id="leaderUserId" name="leaderUserId"/>
<input type="hidden" id="leaderUserName" name="leaderUserName"/>
<input type="hidden" id="leaderDepartmentId" name="leaderDepartmentId"/>
<input type="hidden" id="leaderDepartmentName" name="leaderDepartmentName"/>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">用户</label> <label class="layui-form-label">用户</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="hidden" id="userId" name="userId" value=""> <input type="hidden" id="userId" name="userId" value="">
<input type="hidden" id="userName" name="userName" value=""> <input type="text" class="layui-input" id="userName" name="userName" placeholder="请选择用户" readonly style="cursor:pointer;">
<input type="hidden" id="departmentId" name="departmentId" value="">
<input type="hidden" id="departmentName" name="departmentName" value="">
<input type="text" id="userIdSelectUser" class="layui-input" placeholder="请选择用户" data-name="userId" readonly style="cursor:pointer;">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -67,7 +61,7 @@
<select name="area2leaderUserId" lay-filter="area2leaderUserId"> <select name="area2leaderUserId" lay-filter="area2leaderUserId">
<option value="">选择上级领导</option> <option value="">选择上级领导</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.userId}}|{{item.userName}}|{{item.departmentId}}|{{item.departmentName}}">{{item.userName}}</option> <option value="{{item.userId}}">{{item.userName}}</option>
{{# } }} {{# } }}
</select> </select>
</script> </script>
@ -94,7 +88,7 @@
<select name="area3leaderUserId" lay-filter="area3leaderUserId"> <select name="area3leaderUserId" lay-filter="area3leaderUserId">
<option value="">选择上级领导</option> <option value="">选择上级领导</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.userId}}|{{item.userName}}|{{item.departmentId}}|{{item.departmentName}}">{{item.userName}}</option> <option value="{{item.userId}}">{{item.userName}}</option>
{{# } }} {{# } }}
</select> </select>
</script> </script>
@ -121,7 +115,7 @@
<select name="area4leaderUserId" lay-filter="area4leaderUserId"> <select name="area4leaderUserId" lay-filter="area4leaderUserId">
<option value="">选择上级领导</option> <option value="">选择上级领导</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.userId}}|{{item.userName}}|{{item.departmentId}}|{{item.departmentName}}">{{item.userName}}</option> <option value="{{item.userId}}">{{item.userName}}</option>
{{# } }} {{# } }}
</select> </select>
</script> </script>
@ -148,7 +142,7 @@
<select name="area5leaderUserId" lay-filter="area5leaderUserId"> <select name="area5leaderUserId" lay-filter="area5leaderUserId">
<option value="">选择上级领导</option> <option value="">选择上级领导</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.userId}}|{{item.userName}}|{{item.departmentId}}|{{item.departmentName}}">{{item.userName}}</option> <option value="{{item.userId}}">{{item.userName}}</option>
{{# } }} {{# } }}
</select> </select>
</script> </script>
@ -227,52 +221,6 @@
form.render('radio', 'dataForm'); form.render('radio', 'dataForm');
} }
// 初始化用户ID选择人员
function initUserIdSelectUser() {
$(document.body).on('click', '#userIdSelectUser', function() {
top.dialog.dialogData.selectedUsers = [{
userId: $('#userId').val(),
departmentId: $('#departmentId').val()
}];
top.dialog.open({
url: top.restAjax.path('route/tree/treeuser', []),
title: '选择组织部门人员',
width: '500px',
height: '500px',
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length == 1) {
var selectedUsersId = '';
var selectedUserName = '';
var selectedDepartmentId = '';
var selectedDepartmentName = '';
var showSelectedUsersVal = '';
for(var j = 0, selectUser = selectedUsers[j]; selectUser = selectedUsers[j++];) {
selectedUsersId = selectUser.userId;
selectedUserName = selectUser.userName;
selectedDepartmentId = selectUser.departmentId;
selectedDepartmentName = selectUser.userTitle.split('】')[0].substr(1);
showSelectedUsersVal = selectUser.userTitle;
}
$('#userId').val(selectedUsersId);
$('#userName').val(selectedUserName);
$('#departmentId').val(selectedDepartmentId);
$('#departmentName').val(selectedDepartmentName);
$('#userIdSelectUser').val(showSelectedUsersVal);
} else if(selectedUsers != null && selectedUsers.length > 1) {
top.dialog.msg('只能选择一位人员');
} else {
$('#userId').val('');
$('#userName').val('');
$('#departmentId').val('');
$('#departmentName').val('');
$('#userIdSelectUser').val('');
}
}
});
});
}
// 初始化选择框、单选、复选模板 // 初始化选择框、单选、复选模板
function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) { function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) {
laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) { laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) {
@ -389,7 +337,6 @@
// 初始化内容 // 初始化内容
function initData() { function initData() {
initUserIdSelectUser();
initArea1Select(); initArea1Select();
initArea2Select(); initArea2Select();
if(level > 1) { if(level > 1) {
@ -445,6 +392,37 @@
return false; return false;
}); });
$(document).on('click', '#userName', function() {
top.dialog.dialogData.selectedUserIds = $('#userId').val();
top.dialog.user({
url: top.restAjax.path('route/system/user/select-department-user.html', []),
title: '选择组织部门人员',
width: '500px',
height: '500px',
onClose: function () {
var userIds = '';
var userNames = '';
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
if(selectedUsers.length > 1) {
top.dialog.msg('最多选择一名人员,请重新选择');
return false;
}
for (var i = 0, item; item = selectedUsers[i++];) {
if(userIds.length > 0) {
userIds += ',';
userNames += ',';
}
userIds += item.userId;
userNames += item.userName;
}
}
$('#userId').val(userIds);
$('#userName').val(userNames);
}
});
});
$('.close').on('click', function() { $('.close').on('click', function() {
closeBox(); closeBox();
}); });

View File

@ -22,17 +22,11 @@
<div class="layui-card-body" style="padding: 15px;"> <div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm"> <form class="layui-form layui-form-pane" lay-filter="dataForm">
<input type="hidden" id="leaderUserId" name="leaderUserId"/> <input type="hidden" id="leaderUserId" name="leaderUserId"/>
<input type="hidden" id="leaderUserName" name="leaderUserName"/>
<input type="hidden" id="leaderDepartmentId" name="leaderDepartmentId"/>
<input type="hidden" id="leaderDepartmentName" name="leaderDepartmentName"/>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">用户</label> <label class="layui-form-label">用户</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="hidden" id="userId" name="userId" value=""> <input type="hidden" id="userId" name="userId" value="">
<input type="hidden" id="userName" name="userName" value=""> <input type="text" class="layui-input" id="userName" name="userName" placeholder="请选择用户" readonly style="cursor:pointer;">
<input type="hidden" id="departmentId" name="departmentId" value="">
<input type="hidden" id="departmentName" name="departmentName" value="">
<input type="text" id="userIdSelectUser" class="layui-input" placeholder="请选择用户" data-name="userId" readonly style="cursor:pointer;">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -67,7 +61,7 @@
<select name="area2leaderUserId" lay-filter="area2leaderUserId"> <select name="area2leaderUserId" lay-filter="area2leaderUserId">
<option value="">选择上级领导</option> <option value="">选择上级领导</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.userId}}|{{item.userName}}|{{item.departmentId}}|{{item.departmentName}}">{{item.userName}}</option> <option value="{{item.userId}}">{{item.userName}}</option>
{{# } }} {{# } }}
</select> </select>
</script> </script>
@ -94,7 +88,7 @@
<select name="area3leaderUserId" lay-filter="area3leaderUserId"> <select name="area3leaderUserId" lay-filter="area3leaderUserId">
<option value="">选择上级领导</option> <option value="">选择上级领导</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.userId}}|{{item.userName}}|{{item.departmentId}}|{{item.departmentName}}">{{item.userName}}</option> <option value="{{item.userId}}">{{item.userName}}</option>
{{# } }} {{# } }}
</select> </select>
</script> </script>
@ -121,7 +115,7 @@
<select name="area4leaderUserId" lay-filter="area4leaderUserId"> <select name="area4leaderUserId" lay-filter="area4leaderUserId">
<option value="">选择上级领导</option> <option value="">选择上级领导</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.userId}}|{{item.userName}}|{{item.departmentId}}|{{item.departmentName}}">{{item.userName}}</option> <option value="{{item.userId}}">{{item.userName}}</option>
{{# } }} {{# } }}
</select> </select>
</script> </script>
@ -148,7 +142,7 @@
<select name="area5leaderUserId" lay-filter="area5leaderUserId"> <select name="area5leaderUserId" lay-filter="area5leaderUserId">
<option value="">选择上级领导</option> <option value="">选择上级领导</option>
{{# for(var i = 0, item; item = d[i++];) { }} {{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.userId}}|{{item.userName}}|{{item.departmentId}}|{{item.departmentName}}">{{item.userName}}</option> <option value="{{item.userId}}">{{item.userName}}</option>
{{# } }} {{# } }}
</select> </select>
</script> </script>
@ -229,54 +223,6 @@
form.render('radio', 'dataForm'); form.render('radio', 'dataForm');
} }
// 初始化用户ID选择人员
function initUserIdSelectUser() {
$('#userIdSelectUser').val('【'+ $('#departmentName').val() +'】'+ $('#userName').val());
$(document.body).on('click', '#userIdSelectUser', function() {
top.dialog.dialogData.selectedUsers = [{
userId: $('#userId').val(),
departmentId: $('#departmentId').val()
}];
top.dialog.open({
url: top.restAjax.path('route/tree/treeuser', []),
title: '选择组织部门人员',
width: '500px',
height: '500px',
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length == 1) {
var selectedUsersId = '';
var selectedUserName = '';
var selectedDepartmentId = '';
var selectedDepartmentName = '';
var showSelectedUsersVal = '';
for(var j = 0, selectUser = selectedUsers[j]; selectUser = selectedUsers[j++];) {
selectedUsersId = selectUser.userId;
selectedUserName = selectUser.userName;
selectedDepartmentId = selectUser.departmentId;
selectedDepartmentName = selectUser.userTitle.split('】')[0].substr(1);
showSelectedUsersVal = selectUser.userTitle;
}
$('#userId').val(selectedUsersId);
$('#userName').val(selectedUserName);
$('#departmentId').val(selectedDepartmentId);
$('#departmentName').val(selectedDepartmentName);
$('#userIdSelectUser').val(showSelectedUsersVal);
} else if(selectedUsers != null && selectedUsers.length > 1) {
top.dialog.msg('只能选择一位人员');
} else {
$('#userId').val('');
$('#userName').val('');
$('#departmentId').val('');
$('#departmentName').val('');
$('#userIdSelectUser').val('');
}
}
});
});
}
// 初始化选择框、单选、复选模板 // 初始化选择框、单选、复选模板
function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) { function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) {
laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) { laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) {
@ -492,8 +438,6 @@
form.val('dataForm', dataFormData); form.val('dataForm', dataFormData);
form.render(null, 'dataForm'); form.render(null, 'dataForm');
initUserIdSelectUser();
initArea1Select(data['area1'], function() { initArea1Select(data['area1'], function() {
var leader = data['leaderUserId'] +'|'+ data['leaderUserName'] +'|'+ data['leaderDepartmentId']+'|'+ data['leaderDepartmentName']; var leader = data['leaderUserId'] +'|'+ data['leaderUserName'] +'|'+ data['leaderDepartmentId']+'|'+ data['leaderDepartmentName'];
initArea2Select(data['area1'], data['area2'], function() { initArea2Select(data['area1'], data['area2'], function() {
@ -571,6 +515,37 @@
return false; return false;
}); });
$(document).on('click', '#userName', function() {
top.dialog.dialogData.selectedUserIds = $('#userId').val();
top.dialog.user({
url: top.restAjax.path('route/system/user/select-department-user.html', []),
title: '选择组织部门人员',
width: '500px',
height: '500px',
onClose: function () {
var userIds = '';
var userNames = '';
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
if(selectedUsers.length > 1) {
top.dialog.msg('最多选择一名人员,请重新选择');
return false;
}
for (var i = 0, item; item = selectedUsers[i++];) {
if(userIds.length > 0) {
userIds += ',';
userNames += ',';
}
userIds += item.userId;
userNames += item.userName;
}
}
$('#userId').val(userIds);
$('#userName').val(userNames);
}
});
});
$('.close').on('click', function() { $('.close').on('click', function() {
closeBox(); closeBox();
}); });