Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/user/findUser.jsp
2026-01-16 14:13:44 +08:00

399 lines
15 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<script type="text/javascript">
//var companyId = "";
var doSearchUser = function() {
$("#table_user").bootstrapTable('refresh');
};
/* function doSelect(dialog,grid) {
//var checkedItems = $("#table_user").bootstrapTable('getAllSelections');
var datas="";
datas_name="";
$.each(selectionIds, function(index, item){
if(datas!=""){
datas+=",";
}
datas+=item;
});
$.post(ext.contextPath + '/user/getUsersByIds.do', {userIds : datas}, function(resp) {
$.each(resp, function(index, item){
if(datas_name!=""){
datas_name+=",";
}
datas_name+=item.caption;
});
//$('#${param.formId} #${param.hiddenId}' ).val(datas);
//$('#${param.formId} #${param.textId}').val(datas_name);
closeModal("user4SelectModal")
},'json');
}; */
/* function doSelect(){
var checkedItems = $("#table_user").bootstrapTable('getAllSelections');
//console.log(checkedItems);
var id="";
var name="";
$.each(checkedItems,function(index,value){
name+=checkedItems[index].name+",";
id+=checkedItems[index].id+",";
})
//console.log("name如下============");
//console.log(name);
$('#userName').text(name);
$('#userId').val(id);
closeModal("user4SelectModal");
$('#companySelectTreeSecond').html('');
} */
function doSelect(){
//console.log("doSelect selectionIds==================="+selectionIds);
var ids="";
if(selectionIds.length>0){
for(var i=0;i<selectionIds.length;i++){
//console.log(i+"================"+selectionIds[i]);
ids+=selectionIds[i]+",";
}
} else{
closeModal("user4SelectModal");
return;
}
//console.log("ids selectionIds==================="+ids);
var id="";
var name="";
$.post(ext.contextPath + "/user/findUserByIds.do", {userIdsStr:ids}, function (data) {
console.log({data});
$.each(data,function(index,value){
id+=data[index].id+",";
name+=data[index].caption+",";
})
//console.log({id});
//console.log({name});
$('#userName').text(name);
$('#userId').val(id);
closeModal("user4SelectModal");
$('#companySelectTreeSecond').html('');
},'json');
}
function stateFormatter(value, row, index) {
var flag=false;
$.each(eval('${users}'), function(index, item){
if(row.id==item.id){
flag=true;
}
});
if (flag)
return {
checked : true//设置选中
};
return value;
}
var $table;
var switchStatus=false;
var selectionIds = []; //保存选中ids
var selectionIds = []; //保存选中ids
function initialSelectionIds(){
var userIds='${users}';
var check_array='';
if(userIds.length>0){
check_array=userIds.split(",");
}
//console.log("userIds=============================="+userIds);
if(''!=check_array && check_array!=null && check_array.length>0){
selectionIds =new Array(check_array.length);
for(var i=0;i<check_array.length;i++){
selectionIds[i]=check_array[i];
}
}
}
/* function getCheckedIds(){
var ids="";
var check_array =eval('${users}');
$.each(check_array, function(index, item){
if(ids!=""){
ids+=",";
}
ids+=item.id;
});
return ids;
} */
function queryParams(params) {
var temp={
rows: params.limit, // 每页要显示的数据条数
page: params.offset/params.limit+1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
search_name: $('#search_userName').val(),
search_pid:companyId,
//pid:companyId,
jobIds:$('#jobIds').val()
};
return temp;
}
$(function() {
//简易公司combotree
$.post(ext.contextPath + "/user/showCompanySelectTree.do", {}, function (data) {
$('#companySelectTreeSecond').html(data);
});
$("#search_userName").keyup(function(){
if (event.keyCode == 13) {
event.preventDefault();
//回车查询
doSearchUser();
event.stopPropagation();
}
})
/* //简易公司combotree
$.post(ext.contextPath + '/user/getAllCompanyForTree.do', { ng: '' }, function (data) {
if ((data.length == 1 && data.nodes != "") || data.length > 1) {
$('#companiestree').treeview({
data: data,
showBorder: false,
levels: 3,
});
$('#companiestree').on('nodeSelected', function (event, data) {
$("#search_userPid").val(data.id);
$("#coname_input").val(data.text);
document.getElementById('user_tree').style.display = "none";
companyId= data.id;
doSearchUser();
});
}
}, 'json');
//防止点击树的+号收起下拉框
$("#user_tree").on("click", function (e) {
event.stopPropagation();
});
//点击空白隐藏树
$(document).click(function (e) {
var divTree = $('#user_tree'); // 设置目标区域
if (!divTree.is(e.target) && divTree.has(e.target).length === 0) {
divTree.hide()
}
}) */
initialSelectionIds();
//20200416 start==============================================
$table=$("#table_user").bootstrapTable({ // 对应table标签的id
//url: ext.contextPath + '/user/getUserForSelects.do', // 获取表格数据的url
url: ext.contextPath + '/user/getUsers.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
clickToSelect:true,
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20], // 设置页面可以显示的数据条数
pageSize: 20, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
clickToSelect:true,
//responseHandler:responseHandler, //在渲染页面数据之前执行的方法,此配置很重要!!!!!!!
queryParams: queryParams,
queryParamsType: "limit",
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
columns: [
{
checkbox: true, // 显示一个勾选框
formatter: function (i,row) { // 每次加载 checkbox 时判断当前 row 的 id 是否已经存在全局 Set() 里
if($.inArray(row.id,Array.from(selectionIds))!=-1){ // 因为 Set是集合,需要先转换成数组
return {
checked : true // 存在则选中
}
}
}
},{
field: 'caption',
title: "姓名",
align: 'center',
valign: 'middle',
width: '30%'
},{
field: '_pname',
title: "公司/部门",
align: 'center',
valign: 'middle',
width: '70%'
}
],
onLoadSuccess: function(){ //加载成功时执行
adjustBootstrapTableView("table_user");
},
onLoadError: function(){ //加载失败时执行
console.info("加载数据失败");
},
/**
jQuery 事件: click-row.bs.table
参数: row, $element, field
详情:
用户点击一行时触发,参数包含:
row: 与单击的行对应的记录。
$element: tr元素。
field:与单击的单元格对应的字段名称。
*/
onCheck:function(row, $element, field){
//console.log("selectionIds onClickRow========1=========="+row.id);
//console.log("selectionIds onClickRow========1=========="+selectionIds);
if(selectionIds.length >0 && ''!=selectionIds ){
var num=$.inArray(row.id,selectionIds);
if(num == -1){
//console.log("=======调用了我1=======");
selectionIds.push(row.id);
}
}else if(selectionIds.length <=0 || ''==selectionIds){
//console.log("=======调用了我2=======");
selectionIds.push(row.id);
}
//console.log("selectionIds onClickRow========2=========="+selectionIds);
},
/**
jQuery 事件: uncheck.bs.table
参数: row, $element
详情:
当用户取消选中一行时触发,参数包含:
row: 与单击的行对应的记录。
$element: 未选中DOM元素。
*/
onUncheck:function(row, $element){
var num=$.inArray( row.id, selectionIds );
if(num!=-1){
selectionIds.splice(num,1);
}
//console.log("selectionIds onUncheck===================="+selectionIds);
},
})
//绑定选中事件、取消事件、全部选中、全部取消
/* $table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e,rows, obj) {
var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
return row.id;
});
func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference';
selectionIds = _[func](selectionIds, ids);
if('check'==e.type){
obj.parent().addClass("checked");
}else{
obj.parent().removeClass("checked");
}
//adjustBootstrapTableView("table_user");
}); */
//20200416 end==============================================
});
//选中事件操作数组
/* var union = function(array,ids){
$.each(ids, function (i, id) {
if($.inArray(id,array)==-1){
array[array.length] = id;
}
});
return array;
}; */
//取消选中事件操作数组
/* var difference = function(array,ids){
$.each(ids, function (i, id) {
var index = $.inArray(id,array);
if(index!=-1){
array.splice(index, 1);
}
});
return array;
}; */
//var _ = {"union":union,"difference":difference};
//表格分页之前处理多选框数据
/* function responseHandler(res) {
$.each(res.rows, function (i, row) {
row.checkStatus = $.inArray(row.id, selectionIds) != -1; //判断当前行的数据id是否存在与选中的数组存在则将多选框状态变为true
});
return res;
} */
var initFun = function(){
}
</script>
<div class="modal fade" id="user4SelectModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">选择用户</h4>
</div>
<div class="modal-body " style="width:100%">
<div id="alertDiv"></div>
<div class="form-inline">
<div class="form-group">
<input type="hidden" id="jobIds"name="jobIds" class="form-control" placeholder="职位Ids" value="${jobIds }">
<!-- <ul id="companyForUserSelect" style="list-style-type:none;padding-left:0px;width:260px;">
<li class="dropdown" style="width:260px;">
Menu toggle button
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
style="width:260px;" onclick="document.getElementById('user_tree').style.display = 'block';">
<div class="input-group">
<span class="input-group-addon"
style="height:34px;color:#000000;border-top-left-radius: 4px;border-bottom-left-radius: 4px;font-weight:bold">公司:</span>
<input class="form-control " id="coname_input" name="coname_input" placeholder="请选择"
style="height:34px;width: 200px;border-top-right-radius: 4px;border-bottom-right-radius: 4px;"
readonly />
</div>/input-group
</a>
<ul id="user_tree" class="dropdown-menu" data-stopPropagation="true">
<li class="header">
<div id="companiestree" style="width: 250px;height:300px; overflow:auto;"></div>
</li>
</ul>
</li>
</ul> -->
<div id="companySelectTreeSecond"></div>
</div>
<div class="input-group input-group-sm pull-right" style="width: 250px;">
<input type="text" id="search_userName" autocomplete="off" name="search_userName" class="form-control" style="height:34px" placeholder="姓名">
<div class="input-group-btn">
<button class="btn btn-default" onclick="doSearchUser();" style="height:34px"><i class="fa fa-search"></i></button>
</div>
</div>
</div>
<table id="table_user"></table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" onclick="doSelect()">确认</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>