392 lines
12 KiB
Plaintext
392 lines
12 KiB
Plaintext
<%@ page contentType="text/html;charset=UTF-8" %>
|
||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %>
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<%@include file="../baseset.jsp" %>
|
||
<%@include file="../systemset.jsp" %>
|
||
<link rel="stylesheet" href="${bonuspath}/static/plugins/zTree/3.5/zTreeStyle.css" />
|
||
<script src="${bonuspath}/static/plugins/zTree/3.5/jquery.ztree.core-3.5.min.js"></script>
|
||
|
||
<title></title>
|
||
<style type="text/css">
|
||
.p{
|
||
margin:1% 2% 0 1%;
|
||
}
|
||
.flag{
|
||
width:15%;
|
||
text-align: right;
|
||
}
|
||
.flag>span{
|
||
padding-right:1em;
|
||
}
|
||
.con{
|
||
width:35%;
|
||
text-align: left;
|
||
}
|
||
.lang{
|
||
valign:middle;
|
||
width:80%;
|
||
text-align: left;
|
||
}
|
||
.inp{
|
||
width:80%;
|
||
}
|
||
|
||
.linp{
|
||
width:91.5%;
|
||
}
|
||
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="p">
|
||
<form id="addUserForm" method="POST" onsubmit="return false;" >
|
||
<table id="baseTable" cellspacing="0" cellpadding="0" border="0" style="margin: 2em 1em;" class="customTable">
|
||
<input type="hidden" value="${user.id}" name="id" />
|
||
<tbody>
|
||
<tr class="FormData">
|
||
<td class="flag"><span><font color="red">*</font>身份证号:</span></td>
|
||
<td class="con">
|
||
<input class="inp" jyValidate="required" onblur="checkLoginNameIsExist(this)" value="${user.loginName}" name="loginName" type="text" />
|
||
</td>
|
||
<td class="flag"><span><font color="red">*</font>姓名:</span></td>
|
||
<td class="con">
|
||
<input maxlength="8" class="inp" jyValidate="required" name="name" value="${user.name}" type="text" />
|
||
</td>
|
||
</tr>
|
||
<tr class="FormData">
|
||
<td class="flag"><span><font color="red">*</font>性别:</span></td>
|
||
<td class="con">
|
||
<select name="sex" jyValidate="required" class="js-example-basic-single form-control inp" >
|
||
<option value="">--请选择性别--</option>
|
||
<option value="1" <c:if test="${user.sex eq 1}">selected="selected"</c:if>>--男--</option>
|
||
<option value="0" <c:if test="${user.sex eq 0}">selected="selected"</c:if>>--女--</option>
|
||
|
||
</select>
|
||
</td>
|
||
<td class="flag"><span>联系电话:</span></td>
|
||
<td class="con">
|
||
<input maxlength="11" class="inp" name="telphone" value="${user.telphone}" type="text" />
|
||
</td>
|
||
</tr>
|
||
<tr class="FormData">
|
||
<td class="flag"><span><font color="red">*</font>系统角色:</span></td>
|
||
<td class="con">
|
||
<select name="roleArr" jyValidate="required" id="aaa" multiple="multiple" class="js-example-basic-single form-control inp" >
|
||
<option value="">-- 请选择角色 --</option>
|
||
<c:forEach items="${roles}" var="role">
|
||
<option value="${role.id}" <c:if test="${!empty rmap['r'.concat(role.id) ]}">status="1" selected="selected"</c:if> >${role.name}</option>
|
||
</c:forEach>
|
||
</select>
|
||
</td>
|
||
|
||
<td class="flag"><span><font color="red">*</font>所属部门:</span></td>
|
||
<td class="con">
|
||
<input class="inp" id="orgName" readonly="readonly" value="${user.org.name}" jyValidate="required" type="text" onclick="showRole(); return false;" />
|
||
<input type="hidden" id="orgId" name="orgId" value="${user.org.id}" >
|
||
<div id='orgContent' class="menuContent ztreeMC" style="display: none;width:25%; position: absolute;z-index: 999;background-color: #e7e7e7;">
|
||
<ul id="orgTree" class="ztree accountOrgTree"></ul>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr class="FormData">
|
||
<td class="flag"><span style="color: green;">绿色通道:</span></td>
|
||
<td class="con">
|
||
<input class="inp" jyValidate="posnum" value="${user.greenScore}" name="greenScore" type="text" placeholder="在此设置此人考试成绩" />
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</form>
|
||
</div>
|
||
<script type="text/javascript">
|
||
|
||
$(function () {
|
||
$.fn.modal.Constructor.prototype.enforceFocus = function(){};
|
||
$(".js-example-basic-single").select2({
|
||
"language": "zh-CN"
|
||
});
|
||
$(".select2-search").hide();
|
||
loadOrgTree();
|
||
|
||
if('${opt}' == 'view'){
|
||
$("#baseTable").find("select,input").attr("disabled","disabled");
|
||
}
|
||
|
||
});
|
||
|
||
|
||
function updateUser(){
|
||
|
||
if(JY.Validate.newForm("addUserForm")){
|
||
|
||
var data = paramConversionToObjOfForm("addUserForm");
|
||
|
||
var rAdd = [];
|
||
|
||
$("#aaa").find("option[status='1']:not(:selected)").each(function(){
|
||
rAdd.push({id:$(this).attr("value"),opt:'delete',userId:data.id})
|
||
})
|
||
|
||
$("#aaa").find("option:not([status='1']):selected").each(function(){
|
||
rAdd.push({id:$(this).attr("value"),opt:'insert',userId:data.id})
|
||
})
|
||
|
||
if(rAdd.length == 0){
|
||
delete data.roleArr;
|
||
}else{
|
||
data.roleArr = rAdd;
|
||
}
|
||
|
||
console.log("data:",data);
|
||
|
||
var idx = layer.msg('正在提交保存,请稍等...', {
|
||
icon: 16
|
||
,shade: 0.01
|
||
,time:'-1'
|
||
});
|
||
$.ajax({
|
||
type:"POST",
|
||
url:bonuspath +'/backstage/user/updateUser',
|
||
data: JSON.stringify(data),
|
||
dataType:"json",
|
||
contentType:"application/json",
|
||
success:function(data){
|
||
layer.close(idx);
|
||
if(data.res == 1){
|
||
var indexMsg = layer.confirm("<h4 style='color:red'>"+data.resMsg+"</h4>", {btn: ['关闭']},function(){
|
||
layer.close(indexMsg);
|
||
var i = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
||
parent.getbaseList();
|
||
parent.layer.close(i);
|
||
});
|
||
}else{
|
||
var indexMsg = layer.confirm(data.resMsg, {btn: ['关闭']},function(){
|
||
layer.close(indexMsg);
|
||
});
|
||
}
|
||
},
|
||
error:function(data){
|
||
layer.msg("数据加载失败!",{icon:2,time:2000})
|
||
layer.close(idx);
|
||
}
|
||
})
|
||
}
|
||
|
||
}
|
||
|
||
|
||
function addUser(){
|
||
console.log("====新增入口===")
|
||
if(JY.Validate.newForm("addUserForm")){
|
||
console.log("====进入入口===")
|
||
var data = paramConversionToObjOfForm("addUserForm");
|
||
console.log("data=",data);
|
||
var rAdd = data.roleArr;
|
||
|
||
for(var i = 0;i < rAdd.length ;i++){
|
||
var o = {id:rAdd[i]};
|
||
rAdd[i] = o;
|
||
}
|
||
|
||
data.roleArr = rAdd;
|
||
|
||
|
||
|
||
//return;
|
||
console.log("data:",data);
|
||
|
||
var idx = layer.msg('正在提交保存,请稍等...', {
|
||
icon: 16
|
||
,shade: 0.01
|
||
,time:'-1'
|
||
});
|
||
$.ajax({
|
||
type:"POST",
|
||
url:bonuspath +'/backstage/user/addUser',
|
||
data: JSON.stringify(data),
|
||
dataType:"json",
|
||
contentType:"application/json",
|
||
success:function(data){
|
||
layer.close(idx);
|
||
if(data.res == 1){
|
||
var indexMsg = layer.confirm("<h4 style='color:red'>"+data.resMsg+"</h4>", {btn: ['关闭']},function(){
|
||
layer.close(indexMsg);
|
||
var i = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
||
parent.getbaseList();
|
||
parent.layer.close(i);
|
||
});
|
||
}else{
|
||
var indexMsg = layer.confirm(data.resMsg, {btn: ['关闭']},function(){
|
||
layer.close(indexMsg);
|
||
});
|
||
}
|
||
},
|
||
error:function(data){
|
||
layer.msg("数据加载失败!",{icon:2,time:2000})
|
||
layer.close(idx);
|
||
}
|
||
})
|
||
}else{
|
||
console.log("====ckuw===")
|
||
}
|
||
}
|
||
|
||
/**
|
||
*
|
||
*/
|
||
function checkLoginNameIsExist(that){
|
||
var loginName = $(that).val();
|
||
if(JY.Object.notNull(loginName)){
|
||
var idx = layer.msg('正在校验身份证是否合法,请稍等...', {
|
||
icon: 16
|
||
,shade: 0.01
|
||
,time:'-1'
|
||
});
|
||
$.ajax({
|
||
type:"POST",
|
||
url:bonuspath +'/backstage/user/checkLoginNameIsExist',
|
||
data: JSON.stringify({loginName:loginName}),
|
||
dataType:"json",
|
||
contentType:"application/json",
|
||
success:function(data){
|
||
layer.close(idx);
|
||
if(data.res == 1){
|
||
if(isIdCard(loginName)) {
|
||
layer.close(indexMsg);
|
||
} else {
|
||
var html = "<h4 style='color:red;'>请输入合法身份证号</h4>";
|
||
var idcardMsg = layer.confirm(html, {btn: ['关闭']},function(){
|
||
layer.close(idcardMsg);
|
||
$(that).val("");
|
||
$(that).focus();
|
||
});
|
||
}
|
||
}else{
|
||
if(data.res == 2){
|
||
var html = "<h4 style='color:red;'>该身份证号已与"+data.obj.orgName+"的"+data.obj.name+"重复,请您重新填写!</h4>";
|
||
var indexMsg = layer.confirm(html, {btn: ['关闭']},function(){
|
||
layer.close(indexMsg);
|
||
$(that).val("");
|
||
$(that).focus();
|
||
});
|
||
}else{
|
||
var indexMsg = layer.confirm(data.resMsg, {btn: ['关闭']},function(){
|
||
layer.close(indexMsg);
|
||
});
|
||
}
|
||
}
|
||
},
|
||
error:function(data){
|
||
layer.msg("数据加载失败!",{icon:2,time:2000})
|
||
layer.close(idx);
|
||
}
|
||
})
|
||
}
|
||
|
||
}
|
||
|
||
//身份证验证
|
||
function isIdCard(idCard) {
|
||
// 15位和18位身份证号码的正则表达式
|
||
var regIdCard = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
|
||
|
||
// 如果通过该验证,说明身份证格式正确,但准确性还需计算
|
||
if (regIdCard.test(idCard)) {
|
||
if (idCard.length == 18) {
|
||
var idCardWi = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); // 将前17位加权因子保存在数组里
|
||
var idCardY = new Array(1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2); // 这是除以11后,可能产生的11位余数、验证码,也保存成数组
|
||
var idCardWiSum = 0; // 用来保存前17位各自乖以加权因子后的总和
|
||
for (var i = 0; i < 17; i++) {
|
||
idCardWiSum += idCard.substring(i, i + 1) * idCardWi[i];
|
||
}
|
||
var idCardMod = idCardWiSum % 11;// 计算出校验码所在数组的位置
|
||
var idCardLast = idCard.substring(17);// 得到最后一位身份证号码
|
||
// 如果等于2,则说明校验码是10,身份证号码最后一位应该是X
|
||
if (idCardMod == 2) {
|
||
if (idCardLast == "X" || idCardLast == "x") {
|
||
//alert("恭喜通过验证啦!");
|
||
return true;
|
||
} else {
|
||
//alert("身份证号码错误!");
|
||
return false;
|
||
}
|
||
} else {
|
||
// 用计算出的验证码与最后一位身份证号码匹配,如果一致,说明通过,否则是无效的身份证号码
|
||
if (idCardLast == idCardY[idCardMod]) {
|
||
//alert("恭喜通过验证啦!");
|
||
return true;
|
||
} else {
|
||
//alert("身份证号码错误!");
|
||
return false;
|
||
}
|
||
}
|
||
}else{
|
||
return true;
|
||
}
|
||
} else {
|
||
//alert("身份证格式不正确!");
|
||
return false;
|
||
}
|
||
}
|
||
|
||
var preisShow=false;//窗口是否显示
|
||
|
||
function showRole() {
|
||
if(preisShow){
|
||
hideRole();
|
||
}else{
|
||
var obj = $("#orgName");
|
||
var offpos = $("#orgName").position();
|
||
$("#orgContent").css({width:offpos.width+"px",left:offpos.left+"px",top:offpos.top+obj.heigth+"px"}).slideDown("fast");
|
||
preisShow=true;
|
||
}
|
||
}
|
||
|
||
function hideRole(){
|
||
$("#orgContent").fadeOut("fast");
|
||
preisShow=false;
|
||
}
|
||
|
||
function loadOrgTree(){
|
||
JY.Ajax.doRequest(null,bonuspath +'/backstage/user/orgTree',null,function(data){
|
||
$.fn.zTree.init($("#orgTree"),{view:{dblClickExpand:true,selectedMulti:false,nameIsHTML:true},data:{simpleData:{enable: true}},callback:{onClick:clickRole}},data.obj);
|
||
});
|
||
}
|
||
|
||
function clickRole(e, treeId, treeNode) {
|
||
// var check = (treeNode && !treeNode.isParent);
|
||
|
||
if(!treeNode.isParent){
|
||
var check = (treeNode);
|
||
if(check){
|
||
var zTree = $.fn.zTree.getZTreeObj("orgTree"),
|
||
nodes = zTree.getSelectedNodes(),v ="",n ="",o="",p="";
|
||
for (var i=0, l=nodes.length; i<l; i++) {
|
||
v += nodes[i].name + ",";//获取name值
|
||
n += nodes[i].id + ",";//获取id值
|
||
o += nodes[i].other + ",";//获取自定义值
|
||
var pathNodes=nodes[i].getPath();
|
||
for(var y=0;y<pathNodes.length;y++){
|
||
p+=pathNodes[y].name+"/";//获取path/name值
|
||
}
|
||
}
|
||
if (v.length > 0 ) v = v.substring(0, v.length-1);
|
||
if (n.length > 0 ) n = n.substring(0, n.length-1);
|
||
if (o.length > 0 ) o = o.substring(0, o.length-1);
|
||
if (p.length > 0 ) p = p.substring(0, p.length-1);
|
||
|
||
$("#orgName").val(p);
|
||
$("#orgId").val(n);
|
||
hideRole();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
</script>
|
||
</body>
|
||
</html> |