2024-07-17 09:44:55 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
|
|
|
|
|
<link rel="stylesheet" type="text/css" media="screen" href="../../layui/css/layui.css">
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
|
|
|
|
<form class="form-horizontal" onsubmit="return false" id="form">
|
|
|
|
|
<fieldset>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label"><label style="color: red">*</label>用户名</label>
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
<input class="form-control" placeholder="用户名" type="text" name="username" maxlength="50"
|
|
|
|
|
data-bv-notempty="true"
|
|
|
|
|
data-bv-notempty-message="用户名 不能为空">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label"><label style="color: red">*</label>登录名</label>
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
<input class="form-control" placeholder="登录名" type="text" name="loginName" maxlength="50"
|
|
|
|
|
data-bv-notempty="true"
|
|
|
|
|
data-bv-notempty-message="登录名 不能为空">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label"><label style="color: red">*</label>密码</label>
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
<input class="form-control" placeholder="密码" type="text" name="password" id="password" maxlength="50"
|
|
|
|
|
data-bv-notempty="true"
|
|
|
|
|
data-bv-notempty-message="密码 不能为空">
|
|
|
|
|
<span id="password-error" style="color: red;"></span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">手机号</label>
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
<input class="form-control" placeholder="手机号" type="text" maxlength="11" name="phone" id="phone">
|
|
|
|
|
<span id="phone-error" style="color: red;"></span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">邮箱</label>
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
<input class="form-control" placeholder="邮箱" type="text" maxlength="25" name="email">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">性别</label>
|
|
|
|
|
<div class="col-md-10" style="width: 100px">
|
|
|
|
|
<select class="form-control input-sm" name="sex" id="sex">
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">组织机构</label>
|
|
|
|
|
<div class="col-md-10" style="width: 200px">
|
|
|
|
|
<select class="form-control input-sm" name="orgId" id="orgId">
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">所属单位</label>
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
<input class="form-control" placeholder="所属单位" type="text" maxlength="25" name="unit">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">所属部门</label>
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
<input class="form-control" placeholder="所属部门" type="text" maxlength="25" name="dept">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">登录权限</label>
|
|
|
|
|
<div class="checkbox" id="loginType">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">角色</label>
|
|
|
|
|
<div class="radio" id="roleId">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-md-2 control-label">用户状态</label>
|
|
|
|
|
<div class="col-md-10" style="width: 200px">
|
|
|
|
|
<select class="form-control input-sm" name="status" id="status">
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="form-actions">
|
|
|
|
|
<div class="row" align="center">
|
|
|
|
|
<div class="col-md-12">
|
|
|
|
|
<button class="btn btn-primary" onclick="location.href='userList.html'">返回</button>
|
|
|
|
|
<button class="btn btn-primary" type="submit" onclick="add()">
|
|
|
|
|
<i class="fa fa-save"></i> 保存
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</fieldset>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
<script type="text/javascript" src="../../js/publicJs.js"></script>
|
2024-08-23 10:54:22 +08:00
|
|
|
<script type="text/javascript" src="../../js/libs/jquery-3.7.0.min.js"></script>
|
2024-07-17 09:44:55 +08:00
|
|
|
<script type="text/javascript" src="../../js/jq.js"></script>
|
|
|
|
|
<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
|
|
|
|
|
<script type="text/javascript" src="../../js/common.js"></script>
|
|
|
|
|
<script type="text/javascript" src="../../js/my/roles/role.js"></script>
|
|
|
|
|
<script type="text/javascript" src="../../js/my/loginType/loginType.js"></script>
|
|
|
|
|
<script type="text/javascript" src="../../js/my/aes.js"></script>
|
|
|
|
|
<script type="text/javascript" src="../../layui/layui.js"></script>
|
|
|
|
|
<script type="text/javascript" src="../../js/dict.js"></script>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
// 获取手机号输入框元素和错误提示元素
|
|
|
|
|
var phoneError = document.getElementById('phone-error');
|
|
|
|
|
var passwordError = document.getElementById('password-error');
|
|
|
|
|
|
|
|
|
|
layui.use(['layer','laydate','form'], function(){
|
|
|
|
|
var layer = layui.layer;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
showDictSelect("sex", "sex");
|
|
|
|
|
showDictSelect("orgId", "org_id");
|
|
|
|
|
showDictSelect("status", "user_code");
|
|
|
|
|
initRoles();
|
|
|
|
|
initLoginType();
|
|
|
|
|
|
|
|
|
|
$('#form').bootstrapValidator();
|
|
|
|
|
|
|
|
|
|
function add() {
|
|
|
|
|
var bootstrapValidator = $("#form").data('bootstrapValidator');
|
|
|
|
|
bootstrapValidator.validate();
|
|
|
|
|
if (!bootstrapValidator.isValid()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var formdata = $("#form").serializeObject();
|
|
|
|
|
|
|
|
|
|
var phoneRegex = /^1[3456789]\d{9}$/;
|
|
|
|
|
|
|
|
|
|
getPasswordConfig(function(data) {
|
|
|
|
|
var passwordPattern = data.passwordRegex;
|
|
|
|
|
var passwordTip = data.tip;
|
|
|
|
|
|
|
|
|
|
var passwordRegex = new RegExp(passwordPattern);
|
|
|
|
|
|
|
|
|
|
if (passwordRegex.test(formdata.password)) {
|
|
|
|
|
passwordError.textContent = ''; // 清空错误信息
|
|
|
|
|
} else if (formdata.password === '') {
|
|
|
|
|
passwordError.textContent = ''; // 清空错误信息
|
|
|
|
|
} else {
|
|
|
|
|
passwordError.textContent = passwordTip;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (phoneRegex.test(formdata.phone)) {
|
|
|
|
|
phoneError.textContent = ''; // 清空错误信息
|
|
|
|
|
} else if (formdata.phone === '') {
|
|
|
|
|
phoneError.textContent = ''; // 清空错误信息
|
|
|
|
|
} else {
|
|
|
|
|
phoneError.textContent = '手机号格式不正确,请重新输入!';
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
formdata.loginType = getCheckedLoginTypes().join(); // 使用join()函数将数组元素拼接成字符串
|
|
|
|
|
|
|
|
|
|
// 对表单数据进行加密处理
|
|
|
|
|
formdata.loginName = encryptCBC(formdata.loginName);
|
|
|
|
|
formdata.username = encryptCBC(formdata.username);
|
|
|
|
|
formdata.password = encryptCBC(formdata.password);
|
|
|
|
|
formdata.phone = encryptCBC(formdata.phone);
|
|
|
|
|
formdata.email = encryptCBC(formdata.email);
|
|
|
|
|
formdata.unit = encryptCBC(formdata.unit);
|
|
|
|
|
formdata.dept = encryptCBC(formdata.dept);
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'post',
|
|
|
|
|
url: ctxPath + '/users',
|
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
|
data: JSON.stringify(formdata),
|
|
|
|
|
success: function(data) {
|
|
|
|
|
layer.msg("添加成功", {shift: -1, time: 1000}, function(){
|
|
|
|
|
location.href = ctxPath + "/pages/user/userList.html";
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPasswordConfig(callback) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'get',
|
|
|
|
|
url: ctxPath + '/users/getPasswordConfig/' + '1',
|
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
|
success: function(data) {
|
|
|
|
|
callback(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|