Index: ssts-web/src/main/webapp/js/common.js =================================================================== diff -u -r16123 -r16279 --- ssts-web/src/main/webapp/js/common.js (.../common.js) (revision 16123) +++ ssts-web/src/main/webapp/js/common.js (.../common.js) (revision 16279) @@ -2264,8 +2264,8 @@ arg.userIdsArray = $Id("userIds").value.split(";"); arg.userNamesArray = $Id("userNames").value.split(";"); - - var selectedUsersArray = openModalWindow(WWWROOT+'/common/selPersonByOrgUnitByExt.jsp', arg, '600', '300'); + arg.action = 'includeUsers'; + var selectedUsersArray = openModalWindow(WWWROOT+'/common/selPersonByOrgUnitByExt.jsp', arg, '700', '430'); var userIds = ''; var userNames = ''; Index: forgon-tools/src/main/java/com/forgon/tools/util/PageUtil.java =================================================================== diff -u -r16111 -r16279 --- forgon-tools/src/main/java/com/forgon/tools/util/PageUtil.java (.../PageUtil.java) (revision 16111) +++ forgon-tools/src/main/java/com/forgon/tools/util/PageUtil.java (.../PageUtil.java) (revision 16279) @@ -7,6 +7,7 @@ import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.log4j.Logger; +import org.hibernate.Criteria; import java.util.List; import java.util.Map; @@ -15,10 +16,14 @@ * Created by zhonghaowen on 2016/11/23. * 分页工具类 */ -public class PageUtil { +public final class PageUtil { private static final Logger logger = Logger.getLogger(PageUtil.class); + private PageUtil() { + //no instance + } + /** * 获得分页参数 * @@ -27,10 +32,7 @@ public static PageEntity getPagePara() { int start = StrutsParamUtils.getPraramValue("start", 0); int limit = StrutsParamUtils.getPraramValue("limit", 0); - PageEntity pageEntity = new PageEntity(); - pageEntity.setStart(start); - pageEntity.setLimit(limit); - return pageEntity; + return new PageEntity(start, limit); } /** @@ -55,25 +57,34 @@ } /** + * 分页方法 + * + * @param pageEntity 分页的实体类 + * @param list 要分页的list + * @return + */ + public static List startPage(PageEntity pageEntity, List list) { + pageEntity = (PageEntity) ObjectUtil.buildObjectIfNull(pageEntity, PageEntity.class); + return startPage(pageEntity.getStart(), pageEntity.getLimit(), list); + } + + /** * 输出结果到页面 * * @param list 需要输出的list * @param pageEntity 分页的实体类 */ public static void outPutResult(PageEntity pageEntity, List list) { - if (pageEntity == null) { - pageEntity = new PageEntity(); - } try { + pageEntity = (PageEntity) ObjectUtil.buildObjectIfNull(pageEntity, PageEntity.class); List> reList = PageUtil.startPage(pageEntity.getStart(), pageEntity.getLimit(), list); JSONObject jsonObject = new JSONObject(); Map map = pageEntity.getMap(); if (!map.isEmpty()) { BeanUtils.populate(jsonObject, map); } if (CollectionUtils.isNotEmpty(list)) { - jsonObject.put("data", reList); - jsonObject.put("totalCount", list.size()); + jsonObject = buildOutPutProperty(jsonObject, reList, list.size()); //如果不需要转义,直接输出 if (pageEntity.getNeedToEscape() == false) { StrutsResponseUtils.output(jsonObject); @@ -85,14 +96,60 @@ StrutsResponseUtils.output(result); } else { - jsonObject.put("data", ""); - jsonObject.put("totalCount", 0); - StrutsResponseUtils.output(jsonObject); + StrutsResponseUtils.output(buildOutPutProperty(jsonObject, "", 0)); } } catch (Exception e) { logger.error(e, e); throw new RuntimeException(e); } } + + + /** + * 构造要返回页面的参数 + * + * @param jsonObject 返回的json对象 + * @param result 返回的结果 + * @param totalCount 返回结果的条数 + * @return + */ + public static JSONObject buildOutPutProperty(JSONObject jsonObject, Object result, Integer totalCount) { + // jsonObject = jsonObject == null ? new JSONObject() : jsonObject; + jsonObject = (JSONObject) ObjectUtil.buildObjectIfNull(jsonObject, JSONObject.class); + if (result == null) { + logger.warn("参数异常!分页结果集为空"); + result = ""; + totalCount = 0; + } + jsonObject.put("data", result); + jsonObject.put("totalCount", totalCount); + return jsonObject; + } + + /** + * 构造要返回页面的参数 + * + * @param jsonObject 返回的json对象 + * @param pageEntity 分页实体类(里面有分页的结果和分页的总条数) + * @return + */ + public static JSONObject buildOutPutProperty(JSONObject jsonObject, PageEntity pageEntity) { + return buildOutPutProperty(jsonObject, pageEntity.getList(), pageEntity.getCount()); + } + + /** + * 构建分页Criteria + * + * @param criteria Criteria + * @param pageEntity 分页实体类 + */ + public static void buildPage(Criteria criteria, PageEntity pageEntity) { + int start = pageEntity.getStart(); + int limit = pageEntity.getLimit(); + if (start >= 0 && limit > 0) { + criteria.setFirstResult(start); + criteria.setMaxResults(limit); + } + } } Index: ssts-web/src/main/resources/spring/applicationContext-service.xml =================================================================== diff -u -r15543 -r16279 --- ssts-web/src/main/resources/spring/applicationContext-service.xml (.../applicationContext-service.xml) (revision 15543) +++ ssts-web/src/main/resources/spring/applicationContext-service.xml (.../applicationContext-service.xml) (revision 16279) @@ -885,4 +885,5 @@ + \ No newline at end of file Index: forgon-core/src/main/java/com/forgon/directory/service/DirectoryReHandler.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/directory/service/DirectoryReHandler.java (revision 0) +++ forgon-core/src/main/java/com/forgon/directory/service/DirectoryReHandler.java (revision 16279) @@ -0,0 +1,173 @@ +package com.forgon.directory.service; + +import com.forgon.entity.PageEntity; +import com.forgon.security.model.User; +import com.forgon.tools.Constants; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.json.JSONUtil; +import com.forgon.tools.util.PageUtil; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.commons.collections.map.HashedMap; +import org.apache.log4j.Logger; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * Created by zhonghaowen on 2016/12/16. + */ +public class DirectoryReHandler { + + protected final Logger logger = Logger.getLogger(this.getClass()); + + private static DirectoryReHandler directoryReHandler; + + private DirectoryReHandler() { + } + + + public static DirectoryReHandler getInstance() { + if (directoryReHandler == null) { + synchronized (DirectoryReHandler.class) { + if (directoryReHandler == null) { + directoryReHandler = new DirectoryReHandler(); + } + } + } + return directoryReHandler; + } + + /** + * 把结果输出到页面(默认不重新构造返回结果) + * + * @param pageResult {@link PageEntity} + * @param ifReturnId 是否要返回id加名字的 + */ + public void outPutUserResult(PageEntity pageResult, boolean ifReturnId) { + this.outPutUserResult(pageResult, ifReturnId, false); + } + + /** + * 把结果输出到页面 + * + * @param pageResult {@link PageEntity} + * @param ifReturnId 是否要返回id加名字的 + * @param needRebuild 是否需要重新构造返回结果 + */ + public void outPutUserResult(PageEntity pageResult, boolean ifReturnId, boolean needRebuild) { + // 返回页面之前去除多余的属性 + JSONArray allUsers = this.buildJSONArray(pageResult.getList()); + if (needRebuild) { + this.rebuildResult(allUsers, ifReturnId); + } + JSONObject json = PageUtil.buildOutPutProperty(null, allUsers, pageResult.getCount()); + StrutsResponseUtils.output(json); + } + + /** + * 解释当前的列表,构建返回的部门列表(state对应部门名称,sign按照部门编号+#*+部门名称) + * + * @param lists 要处理的列表 + * @return + */ + public List> buildOrgUnit(List lists) { + try { + //*号要转义 + String separator = "%&\\*"; + String separator2 = "#*"; + List> result = new LinkedList<>(); + result.add(this.createSelect("所有用户", "")); + for (String list : lists) { + String[] tempArray = list.split(separator); + Map select = this.createSelect(tempArray[0], tempArray[1] + separator2 + tempArray[0]); + result.add(select); + } + return result; + } + catch (Exception e) { + logger.error(e); + throw new RuntimeException(e); + } + } + + /** + * 构建角色下拉框的key和value值 + * + * @param roleList 角色的列表 + * @return + */ + public List> buildRole(String roleList) { + try { + String separator = com.forgon.Constants.IDS_SEPARATOR; + String separator2 = "#\\*"; + List> result = new LinkedList<>(); + result.add(this.createSelect("所有用户", "")); + String[] splits = roleList.split(separator); + for (String split : splits) { + String[] tempArray = split.split(separator2); + Map map = this.createSelect(tempArray[1], tempArray[0] + "#*" + tempArray[1]); + result.add(map); + } + return result; + } + catch (Exception e) { + logger.error(e); + throw new RuntimeException(e); + } + } + + /** + * 创建下拉框的key和value + * + * @return + */ + private Map createSelect(String state, String sign) { + Map map = new HashedMap(); + map.put("state", state); + map.put("sign", sign); + return map; + } + + /** + * 将结果放到JSONArray,因为返回页面只需要用到id,name,fullName,并不需要其他属性 + * + * @param lists 结果集 + * @return + */ + private JSONArray buildJSONArray(List lists) { + JSONArray array = new JSONArray(); + for (User user : lists) { + JSONObject obj = new JSONObject(); + obj.put("id", user.getId()); + obj.put("name", user.getName()); + obj.put("fullName", user.getFullName()); + array.add(obj); + } + return array; + } + + /** + * 重新构建返回页面的result,将name按照一定的规则进行拼接 + * + * @param users 原来的结果 + * @param ifReturnId + */ + private void rebuildResult(JSONArray users, boolean ifReturnId) { + for (int i = 0; i < users.size(); i++) { + String userIdAndName; + JSONObject json = users.getJSONObject(i); + Long userId = json.getLong("id"); + String name = JSONUtil.defaultIfEmpty(json, "name", ""); + String fullName = JSONUtil.defaultIfEmpty(json, "fullName", ""); + if (ifReturnId) { + userIdAndName = userId + Constants.USER_GROUP_ID_NAME_SEPRATOR + fullName; + } + else { + userIdAndName = com.forgon.tools.Constants.PREFIX_USERID + name + Constants.USER_GROUP_ID_NAME_SEPRATOR + fullName; + } + json.put("userIdAndName", userIdAndName); + } + } +} Index: forgon-core/src/main/java/com/forgon/directory/service/DirectoryManagerImpl.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/directory/service/DirectoryManagerImpl.java (revision 0) +++ forgon-core/src/main/java/com/forgon/directory/service/DirectoryManagerImpl.java (revision 16279) @@ -0,0 +1,172 @@ +package com.forgon.directory.service; + +import com.forgon.directory.vo.DirectoryVo; +import com.forgon.entity.PageEntity; +import com.forgon.security.model.User; +import com.forgon.security.service.RoleManager; +import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.util.ObjectUtil; +import com.forgon.tools.util.PageUtil; +import org.apache.commons.collections.map.HashedMap; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.hibernate.Criteria; +import org.hibernate.Session; +import org.hibernate.criterion.Disjunction; +import org.hibernate.criterion.MatchMode; +import org.hibernate.criterion.Projections; +import org.hibernate.criterion.Restrictions; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Created by zhonghaowen on 2016/12/7. + */ +public class DirectoryManagerImpl implements DirectoryManager { + + protected final Logger logger = Logger.getLogger(this.getClass()); + + private ObjectDao objectDao; + + private SysUserManager sysUserManager; + + private RoleManager roleManager; + + public void setObjectDao(ObjectDao objectDao) { + this.objectDao = objectDao; + } + + public void setSysUserManager(SysUserManager sysUserManager) { + this.sysUserManager = sysUserManager; + } + + public void setRoleManager(RoleManager roleManager) { + this.roleManager = roleManager; + } + + @Override + public List findUserByOrgUnitCodeList(String orgUnitCode) { + return sysUserManager.findUserListByOrgUnitCode(orgUnitCode); + } + + @Override + public List findAllUserByRoleId(String roleId) { + return roleManager.getAllUserByRoleId(roleId); + } + + + @Override + public PageEntity findAllUserByMotion(PageEntity pageEntity, String condition, String motion) { + try { + pageEntity = (PageEntity) ObjectUtil.buildObjectIfNull(pageEntity, PageEntity.class); + List lists = new ArrayList<>(); + if ("roleId".equals(motion)) { + lists = this.findAllUserByRoleId(condition); + } + else if ("orgUnitCode".equals(motion)) { + lists = this.findUserByOrgUnitCodeList(condition); + } + pageEntity.setCount(lists.size()); + //先进行分页截取,再遍历重新build返回页面的参数 + List reLists = PageUtil.startPage(pageEntity, lists); + pageEntity.setList(reLists); + return pageEntity; + } + catch (Exception e) { + logger.error(e); + throw new RuntimeException(e); + } + } + + + @Override + public PageEntity findAllUserByCondition(PageEntity pageEntity, User userCondition, Map otherCondition) { + try { + Session session = objectDao.getHibernateSession(); + Criteria criteria = session.createCriteria(User.class); + pageEntity = (PageEntity) ObjectUtil.buildObjectIfNull(pageEntity, PageEntity.class); + this.buildUserConditionCriteria(criteria, userCondition); + this.buildOtherConditionOrCriteria(criteria, otherCondition); + //使用投影获得总条数 + Integer count = Integer.parseInt(criteria.setProjection(Projections.rowCount()).uniqueResult().toString()); + pageEntity.setCount(count); + //将投影清空,如果不设置为null,结果集会不正常 + criteria.setProjection(null); + PageUtil.buildPage(criteria, pageEntity); + pageEntity.setList(criteria.list()); + return pageEntity; + } + catch (Exception e) { + logger.error(e); + throw new RuntimeException(e); + } + } + + + @Override + public Map buildQueryCondition(DirectoryVo directoryVo) { + Map condition = new HashedMap(); + String[] userNamesArrays = directoryVo.getUserNamesArrays(); + if (ArrayUtils.isNotEmpty(userNamesArrays)) { + condition.put("fullNames", userNamesArrays); + } + Long[] userIds = directoryVo.getUserIds(); + if (ArrayUtils.isNotEmpty(userIds)) { + condition.put("userIds", userIds); + } + String[] names = directoryVo.getNames(); + if (ArrayUtils.isNotEmpty(names)) { + condition.put("names", names); + } + return condition; + } + + + /** + * 构建or条件的criteria + * + * @param criteria + * @param otherCondition 其他的条件 + */ + private void buildOtherConditionOrCriteria(Criteria criteria, Map otherCondition) { + if (otherCondition != null) { + String[] fullNames; + Object objFullNames = otherCondition.get("fullNames"); + Disjunction disjunction = Restrictions.disjunction(); + if (objFullNames != null && ArrayUtils.isNotEmpty((fullNames = (String[]) objFullNames))) { + disjunction.add(Restrictions.or(Restrictions.in("fullName", Arrays.asList(fullNames)))); + } + Long[] userIds; + Object objUserIds = otherCondition.get("userIds"); + if (objUserIds != null && ArrayUtils.isNotEmpty((userIds = (Long[]) objUserIds))) { + disjunction.add(Restrictions.or(Restrictions.in("id", Arrays.asList(userIds)))); + } + String[] names; + Object objNames = otherCondition.get("names"); + if (objNames != null && ArrayUtils.isNotEmpty((names = (String[]) objNames))) { + disjunction.add(Restrictions.or(Restrictions.in("name", Arrays.asList(names)))); + } + criteria.add(disjunction); + } + } + + /** + * 构建User条件的criteria + * + * @param criteria + * @param userCondition 用户的条件 + */ + private void buildUserConditionCriteria(Criteria criteria, User userCondition) { + userCondition = (User) ObjectUtil.buildObjectIfNull(userCondition, User.class); + String fullName = userCondition.getFullName(); + if (StringUtils.isNotBlank(fullName)) { + criteria.add(Restrictions.ilike("fullName", fullName, MatchMode.ANYWHERE)); + } + } + + +} Index: ssts-web/src/main/webapp/js/extendProJs.js =================================================================== diff -u --- ssts-web/src/main/webapp/js/extendProJs.js (revision 0) +++ ssts-web/src/main/webapp/js/extendProJs.js (revision 16279) @@ -0,0 +1,29 @@ +/** + * Created by zhonghaowen on 2016/12/12. + * 扩展JS,用于扩展原生js的方法 + */ + +/** + * 使用jquery的方法根据值来移除数组对应的选项(如果有多个重复的值都会移除) + * @param oldArray 旧的数组 + * @param val 要移除的值 + * @returns {*} + */ +Array.prototype.removeArray = function (val) { + var me = this; + var arr = $.grep(me, function (n, i) { + return n != val; + }); + return arr; +} + +/** + * 扩展原生数组,为其添加根据值来移除对应的元素的方法(如果有多个重复的值,只会移除第一个) + * @param val + */ +Array.prototype.remove = function (val) { + var index = this.indexOf(val); + if (index > -1) { + this.splice(index, 1); + } +}; \ No newline at end of file Index: ssts-web/src/main/webapp/common/orgUnitHelper.js =================================================================== diff -u --- ssts-web/src/main/webapp/common/orgUnitHelper.js (revision 0) +++ ssts-web/src/main/webapp/common/orgUnitHelper.js (revision 16279) @@ -0,0 +1,298 @@ +/** + * Created by zhonghaowen on 2016/12/9. + */ + +var OrgUnitHelper = (function () { + + function OrgUnitFactory() { + this.getUserObj = function () { + return userObj; + } + this.getDeptObj = function () { + return deptObj; + } + }; + + var userObj = {}; + + /** + * 获得user的model + * @returns {[*,*,*,*]} + */ + userObj.getUserModel = function () { + var userModel = [ + new Ext.grid.CheckboxSelectionModel(), + {header: 'id', dataIndex: 'id', width: 100, sortable: true, hidden: true}, + {header: '编号', dataIndex: 'name', width: 100, sortable: true, hidden: false}, + {header: '姓名', dataIndex: 'fullName', width: 100, sortable: true} + ]; + return userModel; + } + + /** + * 获得user的store + * @param url store的地址 + * @returns {Ext.data.JsonStore} + */ + userObj.getUserStore = function (url) { + var userStore = new Ext.data.JsonStore({ + autoDestroy: true, + fields: ['id', 'name', 'fullName'], + url: url || WWWROOT + '/systemmanage/directoryAction!findAllUser.do', + root: 'data', + baseParams: {ifReturnId: false}, + //改写分页传递参数 + // paramNames: {start: 'start', limit: 'limit'} + totalProperty: 'totalCount', + listeners: { + beforeload: function (store, options) { + //读取上次所选的请求参数 + /* var lastOptions = store.lastOptions; + if (lastOptions){ + var orgUnitCode = lastOptions.params.orgUnitCode; + var fullName = lastOptions.params.fullName; + //如果上次的orgUnitCode存在且这次的orgUnitCode为空,则设置orgUnitCode(这种情况是用户进行了翻页) + if (!Ext.isEmpty(orgUnitCode) && Ext.isEmpty(options.params.orgUnitCode)){ + options.params['orgUnitCode'] = orgUnitCode; + } + + }*/ + } + } + } + ); + return userStore; + } + + /** + * 点击保存后根据action从缓存中读取结果并放回(负责人只返回名字,分管领导返回id + #* + 名字,包含用户返回USERID_ + name + #* + 名字) + * @param saveCache 页面中缓存的数据 + * @param action 对应的行为(负责人,分属领导,包含用户) + * @returns {Array} + */ + userObj.setReturnResult = function (saveCache, action) { + var returnArr = []; + if ('principal' == action) { + for (var pro in saveCache) { + var fullName = saveCache[pro]['fullName']; + returnArr.push(fullName); + } + } + else if ('leader' == action) { + for (var pro in saveCache) { + var fullName = saveCache[pro]['fullName']; + var id = saveCache[pro]['id']; + returnArr.push(id + "#*" + fullName); + } + } + else if ('includeUsers' == action) { + for (var pro in saveCache) { + var name = saveCache[pro]['name']; + var fullName = saveCache[pro]['fullName']; + returnArr.push("USERID_" + name + "#*" + fullName); + } + } + return returnArr; + } + + /** + * 根据提供的store创建对应的显示人员的表格 + * @param userStore + * @returns {Ext.grid.GridPanel|*} + */ + userObj.getPeopleGrid = function (userStore, userModel, pageSize) { + var peopleGrid = new Ext.grid.GridPanel({ + store: userStore, + //用于多选 + sm: new Ext.grid.CheckboxSelectionModel(), + columns: userModel, + height: 300, + width: 250, + bbar: new Ext.PagingToolbar({ + store: userStore, + pageSize: pageSize || 100 + }), + viewConfig: { + //让grid的列自动填满grid的整个宽度,不用一列一列的设定宽度。 + forceFit: true + } + }); + return peopleGrid; + } + + /** + * 设置缓存,将页面打开后第一次加载出来的结果缓存到saveCache中(以{id:data}的形式) + * @param records 要缓存的结果 + * @param option + * @param saveCache 要缓存的地方 + */ + userObj.setSaveCache = function (records, option, saveCache) { + Ext.each(records, function (record) { + var id = record.get('id'); + saveCache[id] = record.data; + }); + } + + /** + * 加载左边的store + * @param userStore 对应的store + * @param pageSize 分页大小 + */ + userObj.loadUserStore1 = function (userStore, pageSize) { + userStore.load({params: {start: 0, limit: pageSize}}); + } + + /** + * 加载右边的store + * @param userStore 对应的store + * @param para 要请求的参数(包括:action,userNamesArrays,userIdsArray,pageSize) + */ + userObj.loadUserStore2 = function (userStore, para) { + var me = this; + var action = para.action; + var userNamesArrays = para.userNamesArrays; + var userIdsArray = para.userIdsArray; + var pageSize = para.pageSize; + //如果是组织人,用名字来查找 + if ('principal' == action) { + userStore.load({ + params: {start: 0, limit: pageSize, userNamesArrays: userNamesArrays}, + callback: function (records, option) { + me.setSaveCache(records, option, saveCache); + } + }); + } + //如果是包含用户,用页面传进来的userIdsArray就是相当于User表中的name,所以用name来查找 + else if ('includeUsers' == action) { + userStore.load({ + params: {start: 0, limit: pageSize, names: me.getIds(userIdsArray)}, + callback: function (records, option) { + me.setSaveCache(records, option, saveCache); + } + }); + } + //如果是分属领导,则用id来查找 + else if ('leader' == action) { + userStore.load({ + params: {start: 0, limit: pageSize, userIds: userIdsArray}, + callback: function (records, option) { + me.setSaveCache(records, option, saveCache); + } + }); + } + } + + /** + * 根据提供的用户id数组格式返回id数组 + * @param userIdsArray + * @returns {Array} + */ + userObj.getIds = function (userIdsArray) { + var sign = "USERID_"; + var ids = []; + Ext.each(userIdsArray, function (item) { + var id = item.split(sign); + ids.push(id[1]); + }); + return ids; + } + + var deptObj = {}; + + /** + * 获得部门的store + * @returns {Ext.data.Store} + */ + deptObj.getDeptStore = function () { + var deptStore = new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url: WWWROOT + '/systemmanage/directoryAction!findAllOrgUnitName.do', + method: 'POST' + }), + reader: new Ext.data.JsonReader({ + totalProperty: 'totalCount', + root: 'data' + }, [ + {name: 'sign', mapping: 'sign'}, + {name: 'state', mapping: 'state'} + ]), + listeners: { + beforeload: function (store, option) { + // store.baseParams['wareHouseId'] = top.Ext.getCmp('cssdWareHouse').getValue(); + } + } + }); + return deptStore; + } + + /** + * + * 获得所属部门的combo + * + * @param deptStore 所属部门的数据源 + * @param para 其他参(有pageSize和select事件) + * @returns + */ + deptObj.getAllOrgUnitListCombo = function (deptStore, para) { + var pageSize = para.pageSize || 80; + var allOrgUnitListCombo = { + xtype: 'combo', + id: 'allOrgUnitList2', + fieldLabel: '所属部门', + name: 'allOrgUnitList2', + minChars: 0, + valueField: 'sign', + displayField: 'state', + store: deptStore, + forceSelection: true, + triggerAction: 'all', + //选择框的下箭头 + // hideTrigger: true, + queryParam: 'spell', + lazyInit: true, + typeAhead: true, + mode: 'remote', + pageSize: pageSize, + width: 180, + listWidth: 400, + anchor: '60%', + editable: false, + msgTarget: 'side', + selectOnFocus: true, + listeners: { + select: para.evn + } + }; + return allOrgUnitListCombo; + } + + //测试返回值用的 + deptObj.test = function (selectedUsersArray) { + if (selectedUsersArray.length > 0) { + for (var i = 0; i < selectedUsersArray.length; i++) { + var userStr = selectedUsersArray[i]; + if (userIds == '') { + userIds = userStr.split('#*')[0]; + } + else { + userIds += ';' + userStr.split('#*')[0]; + } + if (userNames == '') { + userNames = userStr.split('#*')[1]; + } + else { + userNames += ';' + userStr.split('#*')[1]; + } + } + } + console.log(userIds); + console.log(userNames); + } + + + return new OrgUnitFactory(); + + +})(); + + Index: forgon-core/src/main/java/com/forgon/directory/action/DirectoryAction.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/directory/action/DirectoryAction.java (revision 0) +++ forgon-core/src/main/java/com/forgon/directory/action/DirectoryAction.java (revision 16279) @@ -0,0 +1,146 @@ +package com.forgon.directory.action; + +import com.forgon.directory.service.DirectoryHelper; +import com.forgon.directory.service.DirectoryManager; +import com.forgon.directory.service.DirectoryReHandler; +import com.forgon.directory.vo.DirectoryVo; +import com.forgon.entity.PageEntity; +import com.forgon.security.model.User; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.util.PageUtil; +import com.opensymphony.xwork2.ModelDriven; +import com.opensymphony.xwork2.Preparable; +import net.sf.json.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Created by zhonghaowen on 2016/12/7. + */ +@ParentPackage(value = "default") +// @ParentPackage(value = "json-default") +@Namespace(value = "/systemmanage") +@Action(value = "directoryAction") +public class DirectoryAction implements ModelDriven, Preparable { + + protected final Logger logger = Logger.getLogger(this.getClass()); + + private DirectoryHelper directoryHelper; + + private DirectoryManager directoryManagerImpl; + + private DirectoryVo directoryVo = new DirectoryVo(); + + + public DirectoryVo getDirectoryVo() { + return directoryVo; + } + + public void setDirectoryVo(DirectoryVo directoryVo) { + this.directoryVo = directoryVo; + } + + public void setDirectoryHelper(DirectoryHelper directoryHelper) { + this.directoryHelper = directoryHelper; + } + + public void setDirectoryManagerImpl(DirectoryManager directoryManagerImpl) { + this.directoryManagerImpl = directoryManagerImpl; + } + + /** + * 根据用户点击选择类别的下拉框加载对应所属部门combo的数据源action + */ + // @Action(results = {@Result(type = "json")}) + public void findAllOrgUnitName() { + try { + String selectedType = directoryVo.getSelectedType(); + PageEntity pageEntity = PageUtil.getPagePara(); + //如果是按角色查询 + if (StringUtils.isNotBlank(selectedType) && "role".equals(selectedType)) { + String allRole = directoryHelper.findAllRole(); + List> reList = DirectoryReHandler.getInstance().buildRole(allRole); + PageUtil.outPutResult(pageEntity, reList); + } + //按用户和按部门 + else { + String[] array = directoryHelper.findAllOrgUnitNameArray(); + List list = PageUtil.startPage(pageEntity, Arrays.asList(array)); + //先进行分页,然后再进行重新处理 + List> reList = DirectoryReHandler.getInstance().buildOrgUnit(list); + JSONObject json = PageUtil.buildOutPutProperty(null, reList, array.length); + StrutsResponseUtils.output(json); + } + } + catch (Exception e) { + logger.error(e, e); + throw new RuntimeException(e); + } + } + + /** + * 根据部门编号,用户的名字,角色id查找对应的用户action + */ + // @Action(results = {@Result(type = "json")}) + public void findAllUser() { + try { + String motion = directoryVo.getMotion(); + PageEntity pageResult; + if ("orgUnitCode".equals(motion)) { + pageResult = directoryManagerImpl.findAllUserByMotion(PageUtil.getPagePara(), directoryVo.getOrgUnitCode(), motion); + } + else if ("roleId".equals(motion)) { + pageResult = directoryManagerImpl.findAllUserByMotion(PageUtil.getPagePara(), directoryVo.getRoleId(), motion); + } + else { + User user = new User(); + user.setFullName(directoryVo.getFullName()); + pageResult = directoryManagerImpl.findAllUserByCondition(PageUtil.getPagePara(), user, null); + } + DirectoryReHandler.getInstance().outPutUserResult(pageResult, directoryVo.isIfReturnId(), true); + } + catch (Exception e) { + logger.error(e, e); + throw new RuntimeException(e); + } + } + + /** + * 查找已存在的用户 + */ + // @Action(results = {@Result(type = "json")}) + public void findExitsUser() { + try { + Map condition = directoryManagerImpl.buildQueryCondition(directoryVo); + if (condition.size() != 0) { + PageEntity pageResult = directoryManagerImpl.findAllUserByCondition(PageUtil.getPagePara(), null, condition); + DirectoryReHandler.getInstance().outPutUserResult(pageResult, directoryVo.isIfReturnId()); + return; + } + //如果没有条件,则不返回任何数据 + PageUtil.outPutResult(null, null); + } + catch (Exception e) { + logger.error(e, e); + throw new RuntimeException(e); + } + } + + + @Override + public DirectoryVo getModel() { + return directoryVo; + } + + @Override + public void prepare() throws Exception { + + } +} Index: ssts-web/src/main/webapp/common/selPersonByOrgUnitByExt.jsp =================================================================== diff -u -r12331 -r16279 --- ssts-web/src/main/webapp/common/selPersonByOrgUnitByExt.jsp (.../selPersonByOrgUnitByExt.jsp) (revision 12331) +++ ssts-web/src/main/webapp/common/selPersonByOrgUnitByExt.jsp (.../selPersonByOrgUnitByExt.jsp) (revision 16279) @@ -5,36 +5,37 @@ <%@ include file="/common/clearCache.jsp"%> 选择用户 - - - - - - - - - - - - - + -
+
+ + + + + + + + + + + + + \ No newline at end of file Index: ssts-web/src/main/webapp/common/selPersonByOrgUnitByExt.js =================================================================== diff -u -r12331 -r16279 --- ssts-web/src/main/webapp/common/selPersonByOrgUnitByExt.js (.../selPersonByOrgUnitByExt.js) (revision 12331) +++ ssts-web/src/main/webapp/common/selPersonByOrgUnitByExt.js (.../selPersonByOrgUnitByExt.js) (revision 16279) @@ -1,17 +1,267 @@ var formPanel; +var pageSize = 100; var arg = dialogArguments; var userIds = arg.userIds; var userNames = arg.userNames; - var userIdsArray = arg.userIdsArray; var userNamesArray = arg.userNamesArray; +var action = arg.action; +// var action = 'leader'; +// var action = 'principal'; +// var action = 'includeUsers'; +// var userIds = ''; +// var userNames = ''; +// var userNamesArray = ['admin','李镜波']; +// var userIdsArray = ['USERID_00003']; +// var userIdsArray = ['USERID_1962','USERID_1966']; +// var userIdsArray = null; + + +var leftGrid; +var rightGrid; +//用于缓存左边store查询的条件 +var leftSearchCache = {}; +//缓存右边store的数据 +var saveCache = {}; +//用于缓存右边store查询的条件 +var rightSearchCache = {}; +//部门搜索的缓存 +var deptSearchCache = {}; +var deptObj = OrgUnitHelper.getDeptObj(); +var userObj = OrgUnitHelper.getUserObj(); +var userModel = userObj.getUserModel(); +//部门store +var deptStore2 = deptObj.getDeptStore(); +deptStore2.addListener('beforeload',function (store, options) { + Ext.apply(options.params, deptSearchCache); +}); +//左边用户的store +var userStore = userObj.getUserStore(); +userStore.addListener('beforeload',function (store, options) { + Ext.apply(options.params, leftSearchCache); +}); +//右边用户的store +var userStore2 = userObj.getUserStore(WWWROOT + '/systemmanage/directoryAction!findExitsUser.do'); +userStore2.addListener('beforeload',function (store, options) { + // 从缓存中读取数据,把数据赋值到请求中(用于用户进行了翻页) + Ext.apply(options.params, rightSearchCache); +}); + +//事件处理对象 +var evtObj = {}; + +/** + * 当所属部门变化,根据缓存的条件重新加载store + * @param store 部门的store + * @param cache 缓存 + */ +evtObj.loadStoreByMotion = function (store, cache) { + var selectedOrgUnit = formPanel.findById('allOrgUnitList2').getValue(); + cache['fullName'] = ''; + if (selectedOrgUnit.Trim() == "") { + cache['orgUnitCode'] = ''; + cache['motion'] = ''; + cache['roleId'] = ''; + } + else { + var selObj = formPanel.findById('selTypeList'); + var selectedType = selObj.getValue(); + if (selectedType == "role") { + var roleId = selectedOrgUnit.split("#*")[0]; + cache['roleId'] = roleId; + cache['motion'] = 'roleId'; + } + else { + var PREFIX_ORGUNIT = "ORGUNIT_"; + var orgUnitCode = selectedOrgUnit.split("#*")[0].substring(PREFIX_ORGUNIT.length); + cache['orgUnitCode'] = orgUnitCode; + cache['motion'] = 'orgUnitCode'; + } + } + store.load({params: {start: 0, limit: pageSize}}); +} + +/** + * 删除 + */ +evtObj.removeClick = function () { + var selections = rightGrid.getSelections(); + if (selections.length < 1 ){ + alert('请选择要移除的用户!'); + return false; + } + Ext.each(selections, function (select) { + var id = select.get('id'); + //从缓存中删除对应的记录 + delete saveCache[id]; + }); + setRightSearchCondition(saveCache); + userStore2.load({params: {start: userStore2.lastOptions.params.start, limit: pageSize}}); +} + +/** + * 删除全部 + */ +evtObj.removeAllClick = function () { + //清空保存的数据 + saveCache = {}; + rightSearchCache['userIds'] = null; + rightSearchCache['userNamesArrays'] = null; + userStore2.removeAll(); + userStore2.load({params: {start: 0, limit: pageSize}}); +} + +/** + * 添加 + */ +evtObj.addClick = function () { + var me = this; + me.handleAdd(leftGrid.getSelections()); +} + +/** + * 添加全部 + */ +evtObj.addAllClick = function () { + var me = this; + //从左边的store里查找对应的数据,并放置在缓存中 + me.handleAdd(userStore.data.items); +} + +/** + * 处理添加 + * @param selections 需要添加的数据 + */ +evtObj.handleAdd = function (selections) { + if (selections.length < 1 ){ + alert('请选择要添加的用户!'); + return false; + } + Ext.each(selections, function (select) { + var ele = select.get('id'); + //从缓存中查找是否已经存在此记录,如果不存在则添加到缓存中 + if (Ext.isEmpty(saveCache[ele])) { + //把选择的用户放在缓存中 + saveCache[ele] = select.data; + } + else { + alert("【" + select.get('fullName') + "】已存在,添加失败!"); + // return false就会中断操作,暂时默认遇到重复不添加,只给予提示,后续的继续执行 + } + }); + setRightSearchCondition(saveCache); + userStore2.load({params: {start: 0, limit: pageSize}}); +} + +/** + * 根据名字查询用户 + * @returns {boolean} + */ +evtObj.searchUser = function () { + var chkName = document.getElementById("userName").value.Trim(); + leftSearchCache['motion'] = ''; + leftSearchCache['roleId'] = ''; + leftSearchCache['orgUnitCode'] = ''; + //清空下拉选项 + Ext.getCmp('allOrgUnitList2').setValue(''); + if (chkName.Trim() == "") { + leftSearchCache.fullName = ''; + userStore.load({params: {start: 0, limit: pageSize}}); + return false; + } + //把查询的数据缓存到leftSearchCache中,用于翻页的时候把数据传到后台 + leftSearchCache.fullName = chkName; + userStore.load({params: {start: 0, limit: pageSize}}); +} + +/** + * 当所属部门变化 + */ +evtObj.changeOrgUnit = function () { + evtObj.loadStoreByMotion(userStore, leftSearchCache); +} + +/** + * 当选择类别变化 + */ +evtObj.changeType = function () { + var selObj = formPanel.findById('selTypeList'); + var selectedType = selObj.getValue(); + //缓存选了的类型 + deptSearchCache['selectedType'] = selectedType; + deptStore2.load({ + params: {start: 0, limit: pageSize} + }); +} + +/** + * 获得所属部门的combo + */ +function buildAllOrgUnitListCombo() { + var para = { + pageSize : pageSize, + evn : evtObj.changeOrgUnit + } + return deptObj.getAllOrgUnitListCombo(deptStore2, para); + +} + +/** + * 创建左边的人员列表 + * @param userStore 对应的数据源 + * @returns {Ext.grid.GridPanel|*|*} + */ +function createLeftGird(userStore) { + leftGrid = userObj.getPeopleGrid(userStore, userModel, pageSize); + return leftGrid; +} + +/** + * 创建右边的人员列表 + * @param userStore 对应的数据源 + * @returns {Ext.grid.GridPanel|*|*} + */ +function createRightGird(userStore) { + rightGrid = userObj.getPeopleGrid(userStore, userModel, pageSize); + return rightGrid; +} + +/** + * 加载user的store + */ +function loadUserStore() { + //加载左边的store + userObj.loadUserStore1(userStore, pageSize); + //加载右边的store + var para = { + userNamesArrays : userNamesArray, + userIdsArray : userIdsArray, + pageSize : pageSize, + action : action + } + userObj.loadUserStore2(userStore2, para); +} + +/** + * 通过遍历saveCache的属性,获取所有id,然后把id以数组的形式保存起来放在rightSearchCache的userIds属性里 + * 用于缓存右边grid的查询条件 + * @param saveCache + */ +function setRightSearchCondition(saveCache) { + var userIds = []; + for (var pro in saveCache){ + userIds.push(pro); + } + rightSearchCache['userIds'] = userIds; +} + function okData() { var selLength = document.getElementById("seletedList").options.length; var returnArr = []; - for (var i = 0; i < selLength; i++) { - var seletedValue = document.getElementById("seletedList").options[i].value.Trim(); + for (var i = 0; i < selLength; i++) { + var seletedValue = document.getElementById("seletedList").options[i].value.Trim(); if (seletedValue != 'undefined' && seletedValue != '') { returnArr.push(seletedValue); @@ -21,6 +271,16 @@ self.close(); } +/** + * 点击保存 + */ +function okData2() { + var returnArr = userObj.setReturnResult(saveCache, action); + // deptObj.test2(returnArr); + self.returnValue = returnArr; + self.close(); +} + function validateSelectedPerson(){ var selectedItems = $Id('seletedList'); if(selectedItems.options.length>=1){ @@ -303,6 +563,14 @@ ['',''] ]; + +var deptStore = new Ext.data.SimpleStore({ + fields: ['state','sign'], + autoLoad:false, + data : Ext.allOrgUnitList.states +}); + + Ext.onReady(function(){ formPanel = new Ext.form.FormPanel({ @@ -323,32 +591,38 @@ fields: ['state','sign'], data : Ext.selTypeList.states }), - listeners :{select: changeType}, + listeners :{select: evtObj.changeType}, displayField:'state', valueField: 'sign', typeAhead: true, mode: 'local', triggerAction: 'all', selectOnFocus:true }), - new Ext.form.ComboBox({ - fieldLabel: '所属部门', - id: 'allOrgUnitList', - anchor: '60%', - editable: false, - msgTarget: 'side', - store: new Ext.data.SimpleStore({ - fields: ['state','sign'], - data : Ext.allOrgUnitList.states - }), - listeners :{select: changeOrgUnit}, - displayField:'state', - valueField: 'sign', - typeAhead: true, - mode: 'local', - triggerAction: 'all', - selectOnFocus:true - }), + // new Ext.form.ComboBox({ + // fieldLabel: '所属部门', + // id: 'allOrgUnitList', + // anchor: '60%', + // editable: false, + // msgTarget: 'side', + // width : 180, + // listWidth : 400, + // forceSelection : true, + // lazyInit : false, + // store: deptStore, + // listeners : { + // select: changeOrgUnit + // }, + // displayField:'state', + // valueField: 'sign', + // typeAhead: true, + // mode: 'local', + // triggerAction: 'all', + // selectOnFocus:true + // }), + + buildAllOrgUnitListCombo(), + { layout:'column', id: 'userPanel', @@ -365,8 +639,8 @@ listeners :{ specialKey :function(field,e){ if (e.getKey() == Ext.EventObject.ENTER){ - searchUser(); - } + evtObj.searchUser(); + } } } }] @@ -377,23 +651,27 @@ new Ext.Button({ text: '查询', handler: function (){ - searchUser(); + evtObj.searchUser(); + // searchUser2(); } })] }] }, { layout:'column', id: 'selectPanel', - anchor:'70%', + anchor:'95%', items:[{ columnWidth:.38, layout: 'form', - items: [{ - xtype:'panel', - width: 150, - html:selectHtmlStr - }] + items: [ + // { + // xtype:'panel', + // width: 150, + // html:selectHtmlStr + // } + createLeftGird(userStore) + ] },{ columnWidth:.24, layout: 'form', @@ -407,7 +685,7 @@ return ; }; } - addClick(); + evtObj.addClick(); return false; } @@ -416,41 +694,47 @@ text:'删除<<', style:'margin: 15px 0px 10px 24px;', handler: function(){ - removeClick();return false; + evtObj.removeClick();return false; } }), new Ext.Button({ text:'添加所有>>', hidden:isOnlyOne ? true : false, style:'margin: 15px 0px 10px 10px;', handler: function(){ - addAllClick();return false; + evtObj.addAllClick();return false; } }), new Ext.Button({ text:'删除所有<<', hidden:isOnlyOne ? true : false, style:'margin: 15px 0px 10px 10px;', handler: function(){ - removeAllClick();return false; + evtObj.removeAllClick();return false; } - })] + }) + ] },{ - columnWidth:.38, + columnWidth:.30, + // columnWidth:.38, layout: 'form', - items: [{ - xtype:'panel', - width: 150, - //anchor:'100%', - html:"" - }] + items: [ + // { + // xtype:'panel', + // width: 150, + // //anchor:'100%', + // html:"" + // } + // , + createRightGird(userStore2) + ] }] } ], buttons: [{ text: '保存', handler: function(){ - okData(); + okData2(); } },{ text: '取消', @@ -462,6 +746,6 @@ var selTypeListObj = formPanel.findById('selTypeList'); selTypeListObj.setValue("user"); - - changeType(); + loadUserStore(); + // changeType(); }); \ No newline at end of file Index: forgon-core/src/main/java/com/forgon/directory/vo/DirectoryVo.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/directory/vo/DirectoryVo.java (revision 0) +++ forgon-core/src/main/java/com/forgon/directory/vo/DirectoryVo.java (revision 16279) @@ -0,0 +1,141 @@ +package com.forgon.directory.vo; + +import java.util.Arrays; + +/** + * Created by zhonghaowen on 2016/12/15. + */ +public class DirectoryVo { + + /** + * 查询的动作,即所属部门下拉框选中的类型(角色id还是部门编号)或者输入名称搜索 + */ + private String motion; + + /** + * 部门编号 + */ + private String orgUnitCode; + + /** + * 角色id + */ + private String roleId; + + /** + * user表的fullName + */ + private String fullName; + + /** + * 按角色查询,用户,按部门标识(根据这个重新加载所属部门的下拉数据) + */ + private String selectedType; + + /** + * 返回页面的标识规则 + */ + private boolean ifReturnId; + + /** + * user表的name数组 + */ + private String[] names; + + /** + * user表的fullName数组 + */ + private String[] userNamesArrays; + + /** + * user表的id数组 + */ + private Long[] userIds; + + public String[] getNames() { + return names; + } + + public void setNames(String[] names) { + this.names = names; + } + + public String getMotion() { + return motion; + } + + public void setMotion(String motion) { + this.motion = motion; + } + + public String getOrgUnitCode() { + return orgUnitCode; + } + + public void setOrgUnitCode(String orgUnitCode) { + this.orgUnitCode = orgUnitCode; + } + + public String getRoleId() { + return roleId; + } + + public void setRoleId(String roleId) { + this.roleId = roleId; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String getSelectedType() { + return selectedType; + } + + public void setSelectedType(String selectedType) { + this.selectedType = selectedType; + } + + public boolean isIfReturnId() { + return ifReturnId; + } + + public void setIfReturnId(boolean ifReturnId) { + this.ifReturnId = ifReturnId; + } + + public String[] getUserNamesArrays() { + return userNamesArrays; + } + + public void setUserNamesArrays(String[] userNamesArrays) { + this.userNamesArrays = userNamesArrays; + } + + public Long[] getUserIds() { + return userIds; + } + + public void setUserIds(Long[] userIds) { + this.userIds = userIds; + } + + @Override + public String toString() { + return "DirectoryVo{" + + "motion='" + motion + '\'' + + ", orgUnitCode='" + orgUnitCode + '\'' + + ", roleId='" + roleId + '\'' + + ", fullName='" + fullName + '\'' + + ", selectedType='" + selectedType + '\'' + + ", ifReturnId=" + ifReturnId + + ", names=" + Arrays.toString(names) + + ", userNamesArrays=" + Arrays.toString(userNamesArrays) + + ", userIds=" + Arrays.toString(userIds) + + '}'; + } +} Index: forgon-tools/src/main/java/com/forgon/entity/PageEntity.java =================================================================== diff -u -r15924 -r16279 --- forgon-tools/src/main/java/com/forgon/entity/PageEntity.java (.../PageEntity.java) (revision 15924) +++ forgon-tools/src/main/java/com/forgon/entity/PageEntity.java (.../PageEntity.java) (revision 16279) @@ -3,6 +3,8 @@ import org.apache.commons.collections.map.HashedMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; /** @@ -27,6 +29,40 @@ private boolean needToEscape; /** + * 总数量 + */ + private int count; + + /** + * 分页的结果 + */ + private List list = new LinkedList(); + + public PageEntity() { + } + + public PageEntity(int start, int limit) { + this.start = start; + this.limit = limit; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + /** * 输出到页面有可能需要用到的参数 */ private Map map = new HashedMap(); @@ -69,6 +105,7 @@ "start=" + start + ", limit=" + limit + ", needToEscape=" + needToEscape + + ", count=" + count + ", map=" + map + '}'; } Index: forgon-core/src/main/java/com/forgon/directory/service/DirectoryManager.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/directory/service/DirectoryManager.java (revision 0) +++ forgon-core/src/main/java/com/forgon/directory/service/DirectoryManager.java (revision 16279) @@ -0,0 +1,61 @@ +package com.forgon.directory.service; + +import com.forgon.directory.vo.DirectoryVo; +import com.forgon.entity.PageEntity; +import com.forgon.security.model.User; +import net.sf.json.JSONArray; + +import java.util.List; +import java.util.Map; + +/** + * Created by zhonghaowen on 2016/12/7. + */ +public interface DirectoryManager { + + + /** + * 根据条件查询对应的用户 + * + * @param pageEntity 分页实体类 + * @param userCondition 要查询的条件 + * @param otherCondition 其他的条件,用于扩展 + * @return + */ + PageEntity findAllUserByCondition(PageEntity pageEntity, User userCondition, Map otherCondition); + + /** + * 根据部门编号来查找对应的用户(用List返回) + * + * @param orgUnitCode 部门编号 + * @return + */ + List findUserByOrgUnitCodeList(String orgUnitCode); + + /** + * 根据角色id来查找对应的用户 + * + * @param roleId 角色id + * @return + */ + List findAllUserByRoleId(String roleId); + + /** + * 根据用户选择的下拉来查询对应的用户 + * + * @param pageEntity 分页实体类 + * @param condition roleId或者orgUnitCode + * @param motion 用户下拉的类别(部门,用户,角色) + * @return + */ + PageEntity findAllUserByMotion(PageEntity pageEntity, String condition, String motion); + + + /** + * 根据directoryVo来构造查询条件 + * + * @param directoryVo {@link DirectoryVo} + * @return + */ + Map buildQueryCondition(DirectoryVo directoryVo); +} Index: forgon-tools/src/main/java/com/forgon/tools/util/ObjectUtil.java =================================================================== diff -u --- forgon-tools/src/main/java/com/forgon/tools/util/ObjectUtil.java (revision 0) +++ forgon-tools/src/main/java/com/forgon/tools/util/ObjectUtil.java (revision 16279) @@ -0,0 +1,32 @@ +package com.forgon.tools.util; + +import org.apache.log4j.Logger; + +/** + * Created by zhonghaowen on 2016/12/9. + */ +public final class ObjectUtil { + + private static final Logger logger = Logger.getLogger(ObjectUtil.class); + + private ObjectUtil() { + //no instance + } + + /** + * 如果该对象为空,则利用反射来创建对应的类 + * + * @param obj 要实例化的类 + * @param clazz 对应的class + * @return + */ + public static Object buildObjectIfNull(Object obj, Class clazz) { + try { + return obj == null ? clazz.newInstance() : obj; + } + catch (Exception e) { + logger.error("实例化失败:" + e); + throw new RuntimeException(); + } + } +} Index: ssts-web/src/main/webapp/js/Ext2CompUtil.js =================================================================== diff -u -r16102 -r16279 --- ssts-web/src/main/webapp/js/Ext2CompUtil.js (.../Ext2CompUtil.js) (revision 16102) +++ ssts-web/src/main/webapp/js/Ext2CompUtil.js (.../Ext2CompUtil.js) (revision 16279) @@ -73,6 +73,7 @@ triggerAction: comboConfig.triggerAction || 'all', mode: comboConfig.mode, store: comboConfig.store, + pageSize: comboConfig.pageSize || false, listeners: comboConfig.listeners || { select: function (combo, record, index) { } Index: ssts-web/src/main/webapp/systemmanage/orgUnitExt.js =================================================================== diff -u -r15215 -r16279 --- ssts-web/src/main/webapp/systemmanage/orgUnitExt.js (.../orgUnitExt.js) (revision 15215) +++ ssts-web/src/main/webapp/systemmanage/orgUnitExt.js (.../orgUnitExt.js) (revision 16279) @@ -19,8 +19,9 @@ arg.userIdsArray = userIds.split(";"); arg.userNamesArray = userNames.split(";"); - - var selectLeadersArray = openModalWindow(WWWROOT+'/common/selPersonByOrgUnitByExt.jsp', arg, '600', '300'); + arg.action = action; + + var selectLeadersArray = openModalWindow(WWWROOT+'/common/selPersonByOrgUnitByExt.jsp', arg, '700', '430'); if(selectLeadersArray != null){ if(action == 'principal'){//负责人 @@ -94,10 +95,14 @@ name: 'parentId' },{ xtype:'hidden', + // fieldLabel: 'userIds', + // xtype: 'textfield', id:'userIds', name: 'userIds' },{ xtype:'hidden', + // fieldLabel: 'leaderIds', + // xtype: 'textfield', id:'leaderIds', name:'leaderIds' },{