添加选择人员的功能

This commit is contained in:
qiankunpingtai
2019-03-14 11:09:38 +08:00
parent 85d5098d0d
commit 08d3490a5f
11 changed files with 286 additions and 4 deletions

View File

@@ -99,4 +99,7 @@
}
.icon-basket_add{
background:url('icons/basket_add.png') no-repeat center center;
}
.icon-user{
background:url('icons/user.png') no-repeat center center;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

View File

@@ -80,8 +80,11 @@
<td>负责人</td>
<td style="padding:5px">
<input name="principalName" id="principalName"
style="width: 230px;height: 20px" readonly="readonly"/>
style="width: 175px;height: 20px" readonly="readonly"/>
<a href="javascript:void(0)" class="l-btn l-btn-plain" group="" id="lookForSelectUser">
<span class="l-btn-left"><span class="l-btn-text icon-search l-btn-icon-left"></span></span></a>
<input name="principal" id="principal" type="hidden"/>
<input name="selectType" id="selectType" type="hidden"/>
</td>
</tr>
<tr>
@@ -104,6 +107,9 @@
<a href="javascript:void(0)" id="cancelDepot" class="easyui-linkbutton" iconCls="icon-cancel"
onclick="javascript:$('#depotDlg').dialog('close')">取消</a>
</div>
<div id="forSelectUserDlg" class="easyui-dialog" style="width:380px;padding:10px 20px"
closed="true" modal="true" cache="false" collapsible="false" closable="true">
</div>
<script type="text/javascript">
//初始化界面
@@ -164,7 +170,7 @@
formatter: function (value, rec) {
var str = '';
var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.sort + 'AaBb' + rec.remark + 'AaBb'
+ rec.address + 'AaBb' + rec.warehousing + 'AaBb' + rec.truckage+ transferUndefined(rec.principalName)+transferUndefined(rec.principal);
+ rec.address + 'AaBb' + rec.warehousing + 'AaBb' + rec.truckage+'AaBb'+ transferUndefined(rec.principalName)+'AaBb'+transferUndefined(rec.principal);
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editDepot(\'' + rowInfo + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="删除" src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteDepot(' + rec.id + ');"/>';
return str;
@@ -324,7 +330,7 @@
$(".window-mask").css({width: webW, height: webH});
$('#depotFM').form('clear');
$("#name").focus();
$("#selectType").val("principal");
oldDepot = "";
depotID = 0;
url = '/depot/add';
@@ -370,7 +376,9 @@
$("#address").val(depotInfo[4]);
$("#warehousing").val(depotInfo[5]);
$("#truckage").val(depotInfo[6]);
$("#principalName").val(depotInfo[7]);
$("#principal").val(depotInfo[8]);
$("#selectType").val("principal");
oldDepot = depotInfo[1];
$('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑仓库信息');
$(".window-mask").css({width: webW, height: webH});
@@ -486,6 +494,19 @@
parent.addTab(currentRow[0].id + "单元", "/pages/materials/building.jsp?ProjectId=" + currentRow[0].id, "");
});
//查询负责人信息
$("#lookForSelectUser").on("click", function () {
$('#forSelectUserDlg').dialog({
title: '负责人选择',
width: webW/2,
height: webH/2,
closed: false,
cache: false,
href: '/pages/manage/user_forselect.html',
modal: true,
resizable:true
});
});
</script>
</body>
</html>

View File

@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<title>机构选择</title>
<meta charset="utf-8">
<!-- 指定以IE8的方式来渲染 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/>
<script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/>
<link type="text/css" rel="stylesheet" href="/css/common.css"/>
<script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/js/common/common.js"></script>
</head>
<body>
<!-- 数据显示table -->
<div>
<ul id="ttForSelect"></ul>
</div>
<script type="text/javascript">
$(function () {
$('#ttForSelect').tree({
url: '/user/getOrganizationUserTree',
animate: true,
onDblClick: function (node) {
//双击修改
forSelectUser(node);
}
});
function forSelectUser(node) {
var selectType=$("#selectType").val();
console.log(node);
if(!node.attributes.type){
return;
}
if(selectType=='principal'){
$("#principalName").val(node.text);
$("#principal").val(node.id);
}else if(selectType=='org'){
$("#orgAbr").val(node.text);
$("#orgaId").val(node.id);
}
$('#forSelectUserDlg').dialog('close');
}
});
</script>
</body>
</html>

View File

@@ -1,6 +1,7 @@
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -10,6 +11,8 @@ import com.jsh.erp.datasource.entities.DepotEx;
import com.jsh.erp.datasource.entities.SerialNumberEx;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserEx;
import com.jsh.erp.datasource.vo.TreeNode;
import com.jsh.erp.datasource.vo.TreeNodeEx;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.*;
import org.slf4j.Logger;
@@ -311,5 +314,18 @@ public class UserController {
userService.batDeleteUser(ids);
return result;
}
@RequestMapping("/getOrganizationUserTree")
public JSONArray getOrganizationUserTree()throws Exception{
JSONArray arr=new JSONArray();
List<TreeNodeEx> organizationUserTree= userService.getOrganizationUserTree();
if(organizationUserTree!=null&&organizationUserTree.size()>0){
for(TreeNodeEx node:organizationUserTree){
String str=JSON.toJSONString(node);
JSONObject obj=JSON.parseObject(str);
arr.add(obj) ;
}
}
return arr;
}
}

View File

@@ -3,6 +3,8 @@ package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserEx;
import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.vo.TreeNode;
import com.jsh.erp.datasource.vo.TreeNodeEx;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@@ -31,4 +33,7 @@ public interface UserMapperEx {
@Param("loginame") String loginame);
int batDeleteOrUpdateUser(@Param("ids") String ids[], @Param("status") byte status);
List<TreeNodeEx> getNodeTree();
List<TreeNodeEx> getNextNodeTree(Map<String, Object> parameterMap);
}

View File

@@ -0,0 +1,30 @@
package com.jsh.erp.datasource.vo;
/**
* Description
*
* @Author: qiankunpingtai
* @Date: 2019/3/13 18:11
*/
public class NodeAttributes {
//编号
private String no;
//类型
private Integer type;
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}

View File

@@ -0,0 +1,96 @@
package com.jsh.erp.datasource.vo;
import java.util.List;
/**
* Description
*
* @Author: qiankunpingtai
* @Date: 2019/3/13 18:10
*/
public class TreeNodeEx {
/**
* id主键
* */
private Long id;
/**
* text显示的文本
* */
private String text;
/**
*state节点状态'open' 或 'closed',默认:'open'。如果为'closed'的时候,将不自动展开该节点。
* */
private String state="open";
/**
*iconCls 节点图标id
* */
private String iconCls;
/**
* checked 是否被选中
* */
private boolean checked;
/**
*attributes 自定义属性
* */
private NodeAttributes attributes;
/**
* children 子节点
* */
private List<TreeNode> children;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getIconCls() {
return iconCls;
}
public void setIconCls(String iconCls) {
this.iconCls = iconCls;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public NodeAttributes getAttributes() {
return attributes;
}
public void setAttributes(NodeAttributes attributes) {
this.attributes = attributes;
}
public List<TreeNode> getChildren() {
return children;
}
public void setChildren(List<TreeNode> children) {
this.children = children;
}
}

View File

@@ -10,6 +10,8 @@ import com.jsh.erp.datasource.entities.UserEx;
import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.datasource.mappers.UserMapperEx;
import com.jsh.erp.datasource.vo.TreeNode;
import com.jsh.erp.datasource.vo.TreeNodeEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
import com.jsh.erp.utils.ExceptionCodeConstants;
@@ -398,4 +400,7 @@ public class UserService {
}
}
public List<TreeNodeEx> getOrganizationUserTree() {
return userMapperEx.getNodeTree();
}
}

View File

@@ -132,4 +132,56 @@
</foreach>
)
</update>
<resultMap id="BaseTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNodeEx">
<result column="id" property="id"/>
<result column="text" property="text"/>
<association property="attributes" javaType="com.jsh.erp.datasource.vo.NodeAttributes">
<id column="orgNo" property="no"></id>
<result column="type" property="type"></result>
</association>
<collection column="{orgId=id,orgNo=orgNo}" property="children" javaType="java.util.ArrayList"
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
</resultMap>
<resultMap id="NextTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNodeEx">
<result column="id" property="id"/>
<result column="text" property="text"/>
<result column="iconCls" property="iconCls"/>
<association property="attributes" javaType="com.jsh.erp.datasource.vo.NodeAttributes">
<id column="orgNo" property="no"></id>
<result column="type" property="type"></result>
</association>
<collection column="{orgId=id,orgNo=orgNo}" property="children" javaType="java.util.ArrayList"
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
</resultMap>
<select id="getNextNodeTree" resultMap="NextTreeResultMap">
select id , text,orgNo,sort ,iconCls,type from (
SELECT
org.id, org.org_abr as text,org.org_no as orgNo,org.sort as sort,null as iconCls,'0' as type
FROM jsh_organization org
WHERE org.org_parent_no = #{orgNo}
and org.org_stcd !='5'
union all
select
user.id,user.username as text, null as orgNo,rel.user_blng_orga_dspl_seq as sort,'icon-user' as iconCls,'1' as type
from jsh_user user,jsh_orga_user_rel rel
where
1=1
and user.id=rel.user_id
and rel.orga_id=#{orgId}
and rel.delete_flag !='1'
and user.status not in ('1','2')
) node
order by sort asc
</select>
<select id="getNodeTree" resultMap="BaseTreeResultMap">
SELECT
id, org_abr as text,org_no as orgNo,'0' as type
FROM jsh_organization
WHERE org_parent_no = -1
and org_stcd !='5'
order by sort asc
</select>
</mapper>