259 lines
10 KiB
Plaintext
259 lines
10 KiB
Plaintext
<!DOCTYPE html
|
||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
|
||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
|
||
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
|
||
<style type="text/css">
|
||
.select2-container .select2-selection--single {
|
||
height: 34px;
|
||
line-height: 34px;
|
||
}
|
||
|
||
.select2-selection__arrow {
|
||
margin-top: 3px;
|
||
}
|
||
</style>
|
||
<script type="text/javascript">
|
||
function doupdate() {
|
||
$("#editForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#editForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/user/updateUser.do", $("#editForm").serialize(), function (data) {
|
||
if (data.res == 1) {
|
||
//保存权限
|
||
var val = $('#_roles').val();
|
||
var rolestr = "";
|
||
$.each(val, function (index, value, array) {
|
||
if (rolestr != "") {
|
||
rolestr += ","
|
||
}
|
||
rolestr += value;
|
||
})
|
||
$.post(ext.contextPath + "/user/updateRoleUser.do", { rolestr: rolestr, userid: data.id }, function (data1) {
|
||
if (data1 < 0) {
|
||
showAlert('d', '权限保存失败');
|
||
} else {
|
||
closeModal('subModal');
|
||
$("#table").bootstrapTable('refresh');
|
||
}
|
||
|
||
});
|
||
} else if (data.res == 0) {
|
||
showAlert('d', '用户信息保存失败');
|
||
} else {
|
||
showAlert('d', data.res);
|
||
}
|
||
}, 'json');
|
||
}
|
||
}
|
||
var showUnit4SelectFun = function () {
|
||
$.post(ext.contextPath + '/user/showUnit4Select_Limited.do', { formId: "editForm", hiddenId: "pid", textId: "_pname" }, function (data) {
|
||
$("#unit4SelectDiv").html(data);
|
||
openModal("unit4SelectModal_Limited");
|
||
});
|
||
};
|
||
|
||
$("#editForm").bootstrapValidator({
|
||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||
fields: {
|
||
name: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '登陆名不能为空'
|
||
}
|
||
}
|
||
},
|
||
_pname: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '公司/部门不能为空'
|
||
}
|
||
}
|
||
},
|
||
_roles: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '权限不能为空'
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
function loadRole() {
|
||
$.post(ext.contextPath + "/user/getJsonRole.do", { companyId: $("#pid").val() }, function (data) {
|
||
var select = $("#_roles").select2({
|
||
data: data,
|
||
placeholder: '请选择',//默认文字提示
|
||
allowClear: false,//允许清空
|
||
escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||
language: "zh-CN",
|
||
minimumInputLength: 0,
|
||
minimumResultsForSearch: 5,//数据超过十个启用搜索框
|
||
multiple: true,
|
||
formatResult: function formatRepo(repo) { return repo.text; }, // 函数用来渲染结果
|
||
formatSelection: function formatRepoSelection(repo) { return repo.text; } // 函数用于呈现当前的选择
|
||
});
|
||
}, 'json');
|
||
}
|
||
function positionApi() {
|
||
$.post(ext.contextPath + "/user/getPositionTagId.do", { cardid: '${user.cardid}' }, function (data) {
|
||
if(data.length>0){
|
||
$(".cardid_input").remove();
|
||
$(".cardid_select").show();
|
||
var selelct_ = $("#cardid").select2({
|
||
data: data,
|
||
cache: false,
|
||
placeholder: '请选择',//默认文字提示
|
||
allowClear: true,//允许清空
|
||
escapeMarkup: function (markup) {
|
||
return markup;
|
||
}, // 自定义格式化防止xss注入
|
||
language: "zh-CN",
|
||
minimumInputLength: 0,
|
||
minimumResultsForSearch: 10,//数据超过10个,显示搜索框
|
||
formatResult: function formatRepo(repo) {
|
||
console.log("repo is ", repo)
|
||
return repo.text;
|
||
}, // 函数用来渲染结果
|
||
formatSelection: function formatRepoSelection(repo) {
|
||
console.log("repo1 is ", repo)
|
||
return repo.text;
|
||
} // 函数用于呈现当前的选择
|
||
});
|
||
selelct_.val('${user.cardid}').trigger("change");
|
||
}else{
|
||
$(".cardid_select").remove();
|
||
}
|
||
}, 'json');
|
||
}
|
||
|
||
$(function () {
|
||
$("#sex").select2({ minimumResultsForSearch: 10 }).val("${user.sex}").trigger("change");
|
||
$("#active").select2({ minimumResultsForSearch: 10 }).val("${user.active}").trigger("change");
|
||
$.post(ext.contextPath + "/user/getJsonRole.do", { companyId: "${user.pid}" }, function (data) {
|
||
var selelct = $("#_roles").select2({
|
||
data: data,
|
||
placeholder: '请选择',//默认文字提示
|
||
allowClear: false,//允许清空
|
||
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 roleitems = new Array();
|
||
var roles = JSON.parse('${roles}');
|
||
for (var i = 0; i < roles.length; i++) {
|
||
roleitems.push(roles[i].id);
|
||
}
|
||
//console.log("roles", roles);
|
||
selelct.val(roleitems).trigger("change");
|
||
}, 'json');
|
||
positionApi();
|
||
});
|
||
</script>
|
||
<div class="modal fade" id="subModal">
|
||
<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">×</span></button>
|
||
<h4 class="modal-title">编辑界面</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<!-- 新增界面formid强制为editForm -->
|
||
<form class="form-horizontal" id="editForm">
|
||
<div id="alertDiv"></div>
|
||
<input type="hidden" name="id" value="${user.id }" />
|
||
<!-- 界面提醒div强制id为alertdiv -->
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*登录名</label>
|
||
<div class="col-sm-10">
|
||
<input type="text" class="form-control" id="name" name="name" placeholder="登录名" value="${user.name}" style="border-radius:4px">
|
||
</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="caption" name="caption" placeholder="姓名" style="border-radius:4px"
|
||
value="${user.caption}">
|
||
</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="userCardId" name="userCardId" placeholder="工号" style="border-radius:4px"
|
||
value="${user.userCardId}">
|
||
</div>
|
||
<label class="col-sm-2 control-label">性别</label>
|
||
<div class="col-sm-4">
|
||
<select id="sex" name="sex" class="form-control select2">
|
||
<option value="1">男</option>
|
||
<option value="0">女</option>
|
||
</select>
|
||
</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="_pname" name="_pname" placeholder="公司/部门" style="border-radius:4px;background-color: white"
|
||
onclick="showUnit4SelectFun();" value="${user._pname}" readonly />
|
||
<input id="pid" name="pid" type="hidden" value="${user.pid}" />
|
||
</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="mobile" name="mobile" placeholder="手机" value="${user.mobile}" style="border-radius:4px">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<%--<label class="col-sm-2 control-label">QQ号</label>
|
||
<div class="col-sm-10">
|
||
<input type="text" class="form-control" id="qq" name="qq" placeholder="请输入QQ号码" value="${user.qq}" style="border-radius:4px">
|
||
</div>--%>
|
||
<label class="col-sm-2 control-label">定位卡号</label>
|
||
<div class="col-sm-10">
|
||
<select class="form-control select2 cardid_select" id="cardid" name="cardid"
|
||
style="width: 95%; display: none">
|
||
</select>
|
||
<input type="text" class="form-control cardid_input" id="cardid" name="cardid" placeholder="人员定位卡号" value="${user.cardid}" style="border-radius:4px;">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*权限</label>
|
||
<div class="col-sm-10">
|
||
<select class="form-control select2" id="_roles" name="_roles" style="width: 100%;">
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">用户状态</label>
|
||
<div class="col-sm-10">
|
||
<select id="active" name="active" class="form-control select2">
|
||
<option value="1">启用</option>
|
||
<option value="0">禁用</option>
|
||
<option value="2">退休</option>
|
||
<option value="3">离职</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">顺序</label>
|
||
<div class="col-sm-10">
|
||
<input type="number" class="form-control" id="morder" name="morder" value="${user.morder}" style="border-radius:4px">
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" onclick="doupdate()">保存</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div> |