btxtgxq-system-city/src/main/resources/static/route/reportcase/select-street-person.html

230 lines
10 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<base href="/servicecity/">
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" type="text/css" href="assets/js/vendor/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="assets/js/easyui/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="assets/js/easyui/themes/icon.css"/>
<link rel="stylesheet" type="text/css" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/minimal.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/system.css">
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<style>
.edit-button-footer2{
background-color: #F8F8F8 !important;
text-align: center;
}
.btn-primary{
background-color: #009688;
border-color: #009688;
}
.dept-selector .selector-tree .selector-tree-wrapper {
overflow: auto;
}
.list-group {
margin-bottom: 0;
}
</style>
</head>
<body>
<div id="app" class="easyui-layout easyui-layout-dialog dept-selector">
<!-- 已选人员区域 -->
<input type="hidden" id="selectedUserIds"/>
<div class="selector-title" data-options="region:'north'">
<div id="selectUsers" class="selector-title-wrapper"></div>
</div>
<!-- 左侧组织列表 -->
<div class="selector-tree" data-options="region:'west',split:false,collapsible:false,border:true">
<div class="selector-tree-wrapper">
<ul id="leftTree" class="ztree"></ul>
</div>
</div>
<!-- 右侧人员列表 -->
<div class="selector-body" data-options="region:'center',border:true">
<div class="selector-body-wrapper">
<div class="selector-body-search">
<input type="text" class="form-control" id="name" placeholder="检索用户名" oninput="searchUser()"/>
</div>
<div id="users" class="selector-body-content list-group"></div>
</div>
</div>
<div class="edit-button-footer2">
<div class="col-sm-offset-4 col-sm-8">
<button type="button" class="layui-btn" onclick="confirmBox()">确认</button>
<!--
<button type="button" class="btn btn-default" onclick="closeBox()">关闭</button>
-->
</div>
</div>
</div>
<script type="text/javascript" src="assets/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="assets/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="assets/js/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="assets/js/vendor/zTree3/js/jquery.ztree.all.js"></script>
<script type="text/javascript" src="assets/js/common.js"></script>
<script type="text/javascript">
var hrefParams = top.restAjax.params(window.location.href);
var selectedUserIds = hrefParams.selectedUserIds;
var reportCaseId = hrefParams.reportCaseId;
var $win = $(window);
if(typeof (selectedUserIds) === 'undefined'){
selectedUserIds = '';
}
if(typeof (reportCaseId) === 'undefined'){
reportCaseId = '';
}
$('#selectedUserIds').val(selectedUserIds);
// 是否单选
var single = hrefParams.single;
var selectDepartmentUserArray = [];
$(function() {
$('#app').fadeTo(1000, 1);
$('#users').css({
height: ($win.height() - 158) +'px',
overflow: 'auto'
})
initThree();
initSelectedUsers();
top.dialog.dialogData.selectedDepartmentUsers = null;
});
// 初始化选择的人员
function initSelectedUsers() {
if(selectedUserIds != '') {
top.restAjax.get(top.restAjax.path('api/userlocation/list-user-by-ids', []), {userIds : selectedUserIds}, null, function(code, data) {
for(var i = 0, item; item = data[i++]; ) {
selectUser(item.userId, item.userName, item.userUsername);
}
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 初始化树
function initThree() {
var setting = {
async: {
enable: true,
autoLoad: true,
type: 'get',
url: top.restAjax.path('api/bindingdepartment/list-area-community-tree', []),
autoParam:['id'],
otherParam:{reportCaseId : reportCaseId},
dataFilter: function(treeId, parentNode, childNodes) {
if (!childNodes) return null;
for (var i=0, l = childNodes.length; i<l; i++) {
childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
}
return childNodes;
}
},
callback: {
onClick: function(event, treeId, treeNode) {
initUsers(treeNode.pId,treeNode.id);
return false;
}
},
view: {
fontCss: {'color': 'black'}
}
};
var zTree = $.fn.zTree.init($("#leftTree"), setting);
//zTree.addNodes(null, {id: '0', pId: '-1', name: '未划分人员', url: 'javascript:;', isParent: 'true'})
}
// 初始化人员列表
function initUsers(areaId, communityId) {
top.restAjax.get(top.restAjax.path('api/bindingdepartment/list-grid-user/{areaId}/{communityId}',
[areaId,communityId]), {reportCaseId : reportCaseId}, null, function(code, data) {
$('#users').empty();
var userDom = '';
for(var i = 0, item; item = data[i++];) {
var avatarDom;
if(null == item.userAvatar || '' == item.userAvatar) {
avatarDom = '<img class="user-avatar" src="assets/images/profile-photo.jpg"/> '
} else {
avatarDom = '<img class="user-avatar" src="route/file/downloadfile/false/'+ item.userAvatar +'"/> ';
}
userDom += '<a id="user_' + item.userId + '" href="javascript:;" class="users list-group-item" onclick="selectUser(\''+ item.userId +'\', \''+ item.userName +'\', \''+ item.phone +'\')">'+ avatarDom + item.userName + '['+ item.phone + ']<br/>' + item.prefixUserName + '</a>';
}
$('#users').append(userDom);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 人员是否已经选择
function isUserSelected(userId) {
var isSelected = false;
for(var i = 0, item; item = selectDepartmentUserArray[i++];) {
if(item.userId == userId) {
isSelected = true;
break;
}
}
return isSelected;
}
// 删除已经选择的人员
function removeSelectedUser(userId) {
for(var i = 0, item; item = selectDepartmentUserArray[i]; i++) {
if(item.userId == userId) {
selectDepartmentUserArray.splice(i, 1);
$('#selected_user_'+ userId).remove();
break;
}
}
}
// 清空已经选择的人员
function clearSelectedUser() {
selectDepartmentUserArray.splice(0, selectDepartmentUserArray.length);
$('.selected_user').remove();
}
// 添加人员
function addSelectedUser(userId, userName, userUsername) {
selectDepartmentUserArray.push({
userId: userId,
userName: userName,
userUsername: userUsername
});
$('#selectUsers').append('<a id="selected_user_'+ userId +'" href="javascript:;" class="btn btn-success btn-xs selected_user">'+ userName +' <i class="fa fa-close" onclick="removeSelectedUser(\''+ userId +'\')"></i></a>');
}
// 选择人员
function selectUser(userId, userName, userUsername) {
// 如果是单选
if(single == 'true') {
clearSelectedUser();
addSelectedUser(userId, userName, userUsername);
return;
}
if(!isUserSelected(userId)) {
addSelectedUser(userId, userName, userUsername);
}
}
// 筛选人员
function searchUser() {
$('.users').hide().filter(":contains('" + $('#name').val() + "')").show();
}
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
function confirmBox() {
top.dialog.dialogData.selectedDepartmentUsers = selectDepartmentUserArray;
closeBox();
}
</script>
</body>
</html>