first commit
This commit is contained in:
508
WebRoot/jsp/user/deptEdit.jsp
Normal file
508
WebRoot/jsp/user/deptEdit.jsp
Normal file
@ -0,0 +1,508 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
|
||||
<%request.setAttribute("Flag_Active",com.sipai.tools.CommString.Flag_Active);%>
|
||||
<%request.setAttribute("Flag_Unactive",com.sipai.tools.CommString.Flag_Unactive);%>
|
||||
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security"%>
|
||||
<script type="text/javascript">
|
||||
/*** 上半部分 */
|
||||
var showCompany4SelectFun = function () {
|
||||
$.post(ext.contextPath + '/user/showCompany4Select.do', { formId: "deptForm", hiddenId: "pid", textId: "_pname" }, function (data) {
|
||||
$("#company4SelectDiv").html(data);
|
||||
openModal("company4SelectModal");
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
function doSaveDept() {
|
||||
$("#deptForm").data('bootstrapValidator').resetForm();
|
||||
$("#deptForm").bootstrapValidator('validate');//提交验证
|
||||
if ($("#deptForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||||
$.post(ext.contextPath + "/user/updateDept.do", $("#deptForm").serialize(), function (data) {
|
||||
if (data.res == "1") {
|
||||
//若是小组则添加小组权限和工艺段
|
||||
//保存权限
|
||||
var valrole = $('#_roles').val();
|
||||
var rolestr = "";
|
||||
if (valrole != null) {
|
||||
$.each(valrole, function (index, value, array) {
|
||||
if (rolestr != "") {
|
||||
rolestr += ",";
|
||||
}
|
||||
rolestr += value;
|
||||
});
|
||||
}
|
||||
$.post(ext.contextPath + "/user/updateRoleDept.do", { deptid: data.id, rolestr_new: rolestr, rolestr_old: $('#_roles_old').val() }, function (data1) {
|
||||
if (data1 < 0) {
|
||||
showAlert('d', '权限保存失败,请至编辑页面重新保存');
|
||||
}
|
||||
});
|
||||
|
||||
//保存区域
|
||||
var valarea = $('#_area').val();
|
||||
var areastr = "";
|
||||
if (valarea != null) {
|
||||
$.each(valarea, function (index, value, array) {
|
||||
if (areastr != "") {
|
||||
areastr += ",";
|
||||
}
|
||||
areastr += value;
|
||||
});
|
||||
}
|
||||
|
||||
$.post(ext.contextPath + "/user/updateDeptArea.do", { deptid: data.id, areastr: areastr }, function (data1) {
|
||||
if (data1 < 0) {
|
||||
showAlert('d', '区域保存失败,请至编辑页面重新保存');
|
||||
}
|
||||
})
|
||||
initTreeView();
|
||||
} else {
|
||||
showAlert('d', '保存失败');
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
}
|
||||
|
||||
$("#deptForm").bootstrapValidator({
|
||||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||||
fields: {
|
||||
name: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '名称不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
_pname: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '上级不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
morder: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '顺序不能为空'
|
||||
},
|
||||
regexp: {
|
||||
regexp: /^[0-9]*$/,
|
||||
message: '顺序必须为数字'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function delDept() {
|
||||
swal({
|
||||
text: "您确定要删除此记录?",
|
||||
dangerMode: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: "取消",
|
||||
value: null,
|
||||
visible: true,
|
||||
classname: "btn btn-default btn-sm",
|
||||
closeModal: true,
|
||||
},
|
||||
confirm: {
|
||||
text: "确定",
|
||||
value: true,
|
||||
visible: true,
|
||||
classname: "btn btn-danger btn-sm",
|
||||
closeModal: true
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(function (willDelete) {
|
||||
if (willDelete) {
|
||||
$.post(ext.contextPath + '/user/deleteDept.do', $("#deptForm").serialize(), function (data) {
|
||||
if (data.res > 0) {
|
||||
showAlert('s', '删除成功');
|
||||
initTreeView();
|
||||
} else {
|
||||
showAlert('d', '删除失败');
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
}
|
||||
var showRoleSelectFun = function () {
|
||||
$.post(ext.contextPath + "/user/getJsonRoleByBizid.do", { bizid: $('#pid').val() }, function (data) {
|
||||
var select = $("#_roles").select2({
|
||||
data: data,
|
||||
placeholder: '请选择',//默认文字提示
|
||||
allowClear: true,//允许清空
|
||||
escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||||
language: "zh-CN",
|
||||
minimumInputLength: 0,
|
||||
minimumResultsForSearch: 10,//数据超过十个启用搜索框
|
||||
multiple: true,
|
||||
formatResult: function formatRepo(repo) { return repo.text; }, // 函数用来渲染结果
|
||||
formatSelection: function formatRepoSelection(repo) { return repo.text; } // 函数用于呈现当前的选择
|
||||
});
|
||||
var items = new Array();
|
||||
/* $.each(JSON.parse(roles),function(index,value,array){
|
||||
items.put(value.id);
|
||||
}); */
|
||||
}, 'json');
|
||||
};
|
||||
|
||||
var initSelectFun = function () {
|
||||
var roleitems = new Array();
|
||||
var rolestr_old = "";
|
||||
var roles = JSON.parse('${roles}');
|
||||
for (var i = 0; i < roles.length; i++) {
|
||||
roleitems.push(roles[i].id);
|
||||
rolestr_old += roles[i].id + ",";
|
||||
}
|
||||
//console.log("roles", roles);
|
||||
$("#_roles").val(roleitems).trigger("change");
|
||||
$("#_roles_old").val(rolestr_old);
|
||||
|
||||
var areaitems = new Array();
|
||||
var areas = JSON.parse('${areas}');
|
||||
for (var i = 0; i < areas.length; i++) {
|
||||
areaitems.push(areas[i].id);
|
||||
}
|
||||
//console.log("areas", areas);
|
||||
$("#_area").val(areaitems).trigger("change");
|
||||
}
|
||||
|
||||
var showAreaSelectFun = function () {
|
||||
$.post(ext.contextPath + "/timeEfficiency/patrolArea/getPatrolArea4Select.do", { bizId: $('#pid').val() }, function (data) {
|
||||
var select = $("#_area").select2({
|
||||
data: data,
|
||||
placeholder: '请选择',//默认文字提示
|
||||
allowClear: true,//允许清空
|
||||
escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||||
language: "zh-CN",
|
||||
minimumInputLength: 0,
|
||||
minimumResultsForSearch: 10,//数据超过十个启用搜索框
|
||||
multiple: true,
|
||||
formatResult: function formatRepo(repo) { return repo.text; }, // 函数用来渲染结果
|
||||
formatSelection: function formatRepoSelection(repo) { return repo.text; } // 函数用于呈现当前的选择
|
||||
});
|
||||
}, 'json');
|
||||
};
|
||||
|
||||
/*** 下半部分 */
|
||||
var addUserFun = function () {
|
||||
$.post(ext.contextPath + '/user/addUser.do', {}, function (data) {
|
||||
$("#userDiv").html(data + "<div id='unit4SelectDiv'></div> ");
|
||||
openModal('subModal');
|
||||
});
|
||||
};
|
||||
var delUserFun = function () {
|
||||
var checkedItems = $("#table").bootstrapTable('getSelections');
|
||||
var datas = "";
|
||||
$.each(checkedItems, function (index, item) {
|
||||
datas += item.id + ",";
|
||||
});
|
||||
if (datas == "") {
|
||||
showAlert('d', '请先选择记录', 'mainAlertdiv');
|
||||
} else {
|
||||
swal({
|
||||
text: "您确定要禁用这些用户吗?",
|
||||
dangerMode: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: "取消",
|
||||
value: null,
|
||||
visible: true,
|
||||
classname: "btn btn-default btn-sm",
|
||||
closeModal: true,
|
||||
},
|
||||
confirm: {
|
||||
text: "确定",
|
||||
value: true,
|
||||
visible: true,
|
||||
classname: "btn btn-danger btn-sm",
|
||||
closeModal: true
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(function (willDelete) {
|
||||
if (willDelete) {
|
||||
$.post(ext.contextPath + '/user/deleteDept.do', { ids: datas }, function (data) {
|
||||
if (data > 0) {
|
||||
$("#table").bootstrapTable('refresh');
|
||||
} else {
|
||||
showAlert('d', '禁用失败', 'mainAlertdiv');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var editUserFun = function (id) {
|
||||
$.post(ext.contextPath + '/user/editUser.do', { id: id }, function (data) {
|
||||
$("#userDiv").html(data);
|
||||
openModal('subModal');
|
||||
});
|
||||
};
|
||||
|
||||
//重置密码
|
||||
var pwdFun = function (id) {
|
||||
swal({
|
||||
text: "您确定要重置密码吗?",
|
||||
dangerMode: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: "取消",
|
||||
value: null,
|
||||
visible: true,
|
||||
classname: "btn btn-default btn-sm",
|
||||
closeModal: true,
|
||||
},
|
||||
confirm: {
|
||||
text: "确定",
|
||||
value: true,
|
||||
visible: true,
|
||||
classname: "btn btn-danger btn-sm",
|
||||
closeModal: true
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(function (willDelete) {
|
||||
if (willDelete) {
|
||||
$.post(ext.contextPath + '/user/resetPassword.do', { id: id }, function (data) {
|
||||
if (data == 1) {
|
||||
showAlert('s', '重置成功', 'mainAlertdiv');
|
||||
$("#table").bootstrapTable('refresh');
|
||||
} else {
|
||||
showAlert('d', '重置失败', 'mainAlertdiv');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
$(function () {
|
||||
$("#active").select2({ minimumResultsForSearch: 10 }).val("${dept.active}").trigger("change");
|
||||
//$("#active").select2({ minimumResultsForSearch: 10 }).val("${dept.active}");
|
||||
fixSelect2ToForm("active");
|
||||
$("#table").bootstrapTable({ // 对应table标签的id
|
||||
url: ext.contextPath + '/user/getUsersById.do?id=${dept.id}', // 获取表格数据的url
|
||||
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||||
striped: true, //表格显示条纹,默认为false
|
||||
pagination: true, // 在表格底部显示分页组件,默认false
|
||||
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
|
||||
pageSize: 50, // 页面数据条数
|
||||
pageNumber: 1, // 首页页码
|
||||
sidePagination: 'server', // 设置为服务器端分页
|
||||
queryParams: function (params) { // 请求服务器数据时发送的参数,可以在这里添加额外的查询参数,返回false则终止请求
|
||||
return {
|
||||
rows: params.limit, // 每页要显示的数据条数
|
||||
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
|
||||
sort: params.sort, // 要排序的字段
|
||||
order: params.order // 排序规则
|
||||
}
|
||||
},
|
||||
sortName: 'id', // 要排序的字段
|
||||
sortOrder: 'desc', // 排序规则
|
||||
columns: [/*{
|
||||
checkbox: true, // 显示一个勾选框
|
||||
},*/
|
||||
{
|
||||
field: 'name', // 返回json数据中的name
|
||||
title: '登录名', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle' // 上下居中
|
||||
}, {
|
||||
field: 'caption', // 返回json数据中的name
|
||||
title: '姓名', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle' // 上下居中
|
||||
}, {
|
||||
field: 'sex', // 返回json数据中的name
|
||||
title: '性别', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle',
|
||||
formatter: function (value, row, index) {
|
||||
if (value == '0') {
|
||||
return '女';
|
||||
} else {
|
||||
return '男';
|
||||
}
|
||||
}
|
||||
}, {
|
||||
field: '_pname', // 返回json数据中的name
|
||||
title: '公司/部门', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle' // 上下居中
|
||||
}, {
|
||||
field: 'active', // 返回json数据中的name
|
||||
title: '状态', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle',
|
||||
formatter: function (value, row, index) {
|
||||
switch (value) {
|
||||
case '0':
|
||||
return '禁用';
|
||||
case '1':
|
||||
return '启用';
|
||||
case '2':
|
||||
return '退休';
|
||||
case '3':
|
||||
return '离职';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
}/*,{
|
||||
title: "操作",
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
// width: 60, // 定义列的宽度,单位为像素px
|
||||
formatter: function (value, row, index) {
|
||||
var str = '';
|
||||
str+='<button class="btn btn-default btn-sm" title="编辑" onclick="editUserFun(\'' + row.id + '\')"><i class="fa fa-edit"></i></button>';
|
||||
str+='<button class="btn btn-default btn-sm" title="重置密码" onclick="pwdFun(\'' + row.id + '\')"><i class="fa fa-repeat"></i></button>';
|
||||
str='<div class="btn-group" >'+str+'</div>';
|
||||
return str;
|
||||
/* return '<i class="fa fa-edit" onclick="editFun()(\'' + row.id + '\')></i>';
|
||||
}
|
||||
}*/
|
||||
],
|
||||
onLoadSuccess: function () { //加载成功时执行
|
||||
$(".bs-checkbox").css({ 'text-align': 'center', 'vertical-align': 'middle' })
|
||||
},
|
||||
onLoadError: function () { //加载失败时执行
|
||||
console.info("加载数据失败");
|
||||
}
|
||||
});
|
||||
|
||||
showRoleSelectFun();
|
||||
showAreaSelectFun();
|
||||
setTimeout("initSelectFun()", "1000"); //延迟执行
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">详情</h3>
|
||||
|
||||
<div class="box-tools pull-right">
|
||||
<a onclick="doSaveDept()" class="btn btn-box-tool" data-toggle="tooltip" title="保存"><i
|
||||
class="glyphicon glyphicon-floppy-disk"></i></a>
|
||||
<security:authorize buttonUrl="user/deleteCompany.do">
|
||||
<a onclick="delDept()" class="btn btn-box-tool" data-toggle="tooltip" title="删除"><i
|
||||
class="glyphicon glyphicon-trash"></i></a>
|
||||
</security:authorize>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body ">
|
||||
<form class="form-horizontal " id="deptForm">
|
||||
<input id="id" name="id" type="hidden" value="${dept.id}" />
|
||||
<!-- 界面提醒div强制id为alertDiv -->
|
||||
<div id="alertDiv"></div>
|
||||
<div id="company4SelectDiv"></div>
|
||||
<div class="form-group">
|
||||
|
||||
<label class="col-sm-2 control-label">*名称</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="名称"
|
||||
style="border-radius:4px" value="${dept.name }">
|
||||
</div>
|
||||
<label class="col-sm-2 control-label">*上级</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="_pname" name="_pname" placeholder="上级"
|
||||
style="border-radius:4px;background-color: white" readonly onclick="showCompany4SelectFun();"
|
||||
value="${pname}">
|
||||
<input id="pid" name="pid" type="hidden" value="${dept.pid}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">*编号</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="code" name ="code" placeholder="编号" value="${dept.code}" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group">
|
||||
<label class="col-sm-2 control-label">简称</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="sname" name ="sname" placeholder="简称" value="${dept.sname}">
|
||||
</div>
|
||||
<div id="biz_id" style="display:none;">
|
||||
<label class="col-sm-2 control-label">水厂编号</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="id" name ="id" placeholder="编号" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label class="col-sm-2 control-label">办公室</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="office" name ="office" placeholder="地址" value="${dept.office}">
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">*顺序</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="morder" name="morder" placeholder="顺序"
|
||||
style="border-radius:4px" value="${dept.morder}">
|
||||
</div>
|
||||
<security:authorize buttonUrl="user/deleteCompany.do">
|
||||
<label class="col-sm-2 control-label">启用</label>
|
||||
<div class="col-sm-4">
|
||||
<select id="active" name="active" class="form-control select2">
|
||||
<option value="${Flag_Active}">启用</option>
|
||||
<option value="${Flag_Unactive}">禁用</option>
|
||||
</select>
|
||||
</div>
|
||||
</security:authorize>
|
||||
</div>
|
||||
|
||||
<div id="dept_unique" class="form-group">
|
||||
<label class="col-sm-2 control-label">权限</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control select2" id="_roles" name="_roles"></select>
|
||||
<input id="_roles_old" name="_roles_old" type="hidden" />
|
||||
</div>
|
||||
<label class="col-sm-2 control-label">区域</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control select2" id="_area" name="_area">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box box-solid">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">人员</h3>
|
||||
|
||||
<div class="box-tools pull-right">
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body ">
|
||||
<div>
|
||||
<div id="alertDiv_user"></div>
|
||||
<!--
|
||||
<div class="btn-group" style="width: 220px;padding-bottom:10px;">
|
||||
<button type="button" class="btn btn-default" onclick="addUserFun();"><i class="fa fa-plus"></i> 新增</button>
|
||||
<button type="button" class="btn btn-default" onclick="delUserFun();"><i class="fa fa-plus-square"></i> 删除</button>
|
||||
|
||||
</div>-->
|
||||
<div id="userDiv"></div>
|
||||
<div id="user4SelectDiv_func"></div>
|
||||
<br>
|
||||
<table id="table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user