first commit
This commit is contained in:
323
WebRoot/jsp/process/routineWorkRelease4slect.jsp
Normal file
323
WebRoot/jsp/process/routineWorkRelease4slect.jsp
Normal file
@ -0,0 +1,323 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<script type="text/javascript">
|
||||
var ckids='${param.ckids}';
|
||||
|
||||
var doSearchUser = function() {
|
||||
$("#table_user").bootstrapTable('refresh');
|
||||
};
|
||||
function doSelect() {
|
||||
var planStartDate=$('#planStartDate').val();
|
||||
// console.log(ckids);
|
||||
if(planStartDate==""){
|
||||
showAlert('d', '请先选择计划日期', 'mainAlertdiv');
|
||||
}else{
|
||||
var checkedItems = $("#table_user").bootstrapTable('getAllSelections');
|
||||
var userdatas="";
|
||||
$.each(selectionIds, function(index, item){
|
||||
if(userdatas!=""){
|
||||
userdatas+=",";
|
||||
}
|
||||
userdatas+=item;
|
||||
});
|
||||
// console.log(userdatas);
|
||||
if(userdatas==""){
|
||||
showAlert('d', '请先选择人员', 'mainAlertdiv');
|
||||
}else{
|
||||
var arr = ckids.split(",");
|
||||
var sucnum=0;
|
||||
var failnum=0;
|
||||
var totalnum=arr.length;
|
||||
// console.log(arr);
|
||||
// console.log(totalnum);
|
||||
$.each(arr, function(index, item){
|
||||
$.ajax({
|
||||
type: "GET",//请求方式
|
||||
url: ext.contextPath + '/process/routineWork/startProcess2.do',
|
||||
data: {
|
||||
id:item,unitId:unitId,planStartDate:planStartDate,receiveUserIds:userdatas
|
||||
},
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data.res == 1) {
|
||||
sucnum++;
|
||||
} else if (data.res == 0) {
|
||||
failnum++;
|
||||
} else {
|
||||
failnum++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(sucnum==totalnum){
|
||||
$("#table").bootstrapTable('refresh');
|
||||
closeModal("user4SelectModal");
|
||||
showAlert('s', '一共成功下发'+sucnum+'条记录!', 'alertDiv');
|
||||
}else{
|
||||
$("#table").bootstrapTable('refresh');
|
||||
closeModal("user4SelectModal");
|
||||
showAlert('s', '一共下发'+totalnum+'条记录,'+sucnum+'条成功,'+failnum+'条失败!', 'alertDiv');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
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
|
||||
function initialSelectionIds(){
|
||||
var check_array =eval('${users}');
|
||||
if(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].id;
|
||||
}
|
||||
}
|
||||
}
|
||||
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(),
|
||||
pid:checkedid,
|
||||
// jobIds:$('#jobIds').val()
|
||||
};
|
||||
return temp;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
var myDate = new Date;
|
||||
var year = myDate.getFullYear(); //获取当前年
|
||||
var mon = myDate.getMonth() + 1; //获取当前月
|
||||
var day = myDate.getDate(); //获取当前日
|
||||
if(Number(mon)<10){
|
||||
mon="0"+mon
|
||||
}
|
||||
if(Number(day)<10){
|
||||
day="0"+day
|
||||
}
|
||||
$("#planStartDate").val(year + "-" + mon + "-" + day);
|
||||
|
||||
$('#planStartDate').datepicker({
|
||||
language: 'zh-CN',
|
||||
autoclose: true,
|
||||
todayHighlight: true,
|
||||
format: 'yyyy-mm-dd',
|
||||
});
|
||||
|
||||
$("#search_userName").keyup(function(){
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
//回车查询
|
||||
doSearchUser();
|
||||
event.stopPropagation();
|
||||
}
|
||||
})
|
||||
|
||||
initTreeViewOnlyByUser();
|
||||
|
||||
initialSelectionIds();
|
||||
|
||||
$table=$("#table_user").bootstrapTable({ // 对应table标签的id
|
||||
url: ext.contextPath + '/user/getUserForSelects.do', // 获取表格数据的url
|
||||
//cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||||
clickToSelect:true,
|
||||
striped: true, //表格显示条纹,默认为false
|
||||
pagination: true, // 在表格底部显示分页组件,默认false
|
||||
pageList: [10, 20], // 设置页面可以显示的数据条数
|
||||
pageSize: 10, // 页面数据条数
|
||||
pageNumber: 1, // 首页页码
|
||||
sidePagination: 'server', // 设置为服务器端分页
|
||||
clickToSelect:true,
|
||||
responseHandler:responseHandler, //在渲染页面数据之前执行的方法,此配置很重要!!!!!!!
|
||||
queryParams: queryParams,
|
||||
queryParamsType: "limit",
|
||||
sortName: 'id', // 要排序的字段
|
||||
sortOrder: 'desc', // 排序规则
|
||||
/* showColumns: true,
|
||||
showRefresh: true, */
|
||||
columns: [
|
||||
{
|
||||
checkbox: true, // 显示一个勾选框
|
||||
//formatter: stateFormatter
|
||||
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("加载数据失败");
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
//绑定选中事件、取消事件、全部选中、全部取消
|
||||
$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");
|
||||
});
|
||||
});
|
||||
//选中事件操作数组
|
||||
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 checkedid="";
|
||||
function initTreeViewOnlyByUser() {
|
||||
$.post(ext.contextPath + '/user/getAllParentByUnitId.do', {unitId:unitId,maintainerSt:'false'}, function (data) {
|
||||
$('#companytree').treeview({
|
||||
data: data,
|
||||
showBorder: true,
|
||||
levels: 3,
|
||||
});
|
||||
$('#companytree').on('nodeSelected', function (event, data) {
|
||||
checkedid=data.id;
|
||||
doSearchUser();
|
||||
});
|
||||
}, 'json');
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<div class="modal fade" id="user4SelectModal">
|
||||
<div class="modal-dialog" style="width: 800px;">
|
||||
<div class="modal-content" style="float:left;width:100%;">
|
||||
<div class="modal-header" style="float:left;width:100%;">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">选择用户</h4>
|
||||
</div>
|
||||
<div style="float:left;width:100%;padding-top: 10px;">
|
||||
<div id="mainAlertdiv"></div>
|
||||
|
||||
<div class="col-sm-5">
|
||||
<div class="col-sm-12" >
|
||||
<div class="input-group input-group-sm pull-left" 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>
|
||||
<div class="col-sm-12" style="padding-top: 5px;">
|
||||
<div id="companytree" style="height:100%;overflow:auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-7">
|
||||
<div class="col-sm-12" >
|
||||
<div class="input-group input-group-sm pull-left" >
|
||||
<label class="col-sm-4 control-label" style="line-height: 34px;">*计划日期</label>
|
||||
<div class="col-sm-6" style="padding-left: 0px;">
|
||||
<div class="input-group date">
|
||||
<div class="input-group-addon">
|
||||
<i class="fa fa-calendar"></i>
|
||||
</div>
|
||||
<input type="text" class="form-control" id="planStartDate" name="planStartDate"
|
||||
style="width: 132px;" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12" style="padding-top: 5px;">
|
||||
<table id="table_user"></table>
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
Reference in New Issue
Block a user