|
@@ -68,44 +68,69 @@
|
|
$(document).on('click', '.menuSubid input[type=radio]', function() {
|
|
$(document).on('click', '.menuSubid input[type=radio]', function() {
|
|
isSelectShow($(this).val())
|
|
isSelectShow($(this).val())
|
|
})
|
|
})
|
|
|
|
+ var check_name = /^[a-zA-Z0-9\u4e00-\u9fa5]+$/;
|
|
|
|
+ var cnen_name = /^[a-zA-Z\u4e00-\u9fa5]+$/;
|
|
|
|
+ var china_name = /^[\u4e00-\u9fa5]+$/;
|
|
|
|
|
|
- /* $(function(){
|
|
|
|
- $("#form-admin-addEmployee").validate({
|
|
|
|
- rules:{
|
|
|
|
- subName:{
|
|
|
|
- required:true,
|
|
|
|
- minlength:4,
|
|
|
|
- maxlength:30
|
|
|
|
|
|
+ $(function(){
|
|
|
|
+ //var validator = $("#form-admin-addEmployee").validate();
|
|
|
|
+ $("#form-admin-addEmployee").submit(function(){
|
|
|
|
+ if(!ptsValiDataEmNo()){
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ var employeeName = $("#employeeName").val();
|
|
|
|
+ if(!(china_name.test(employeeName))){
|
|
|
|
+ layer.msg('员工姓名格式不正确', {icon: 5, time: 1000});
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!ptsValiDataTel()){
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if($("#employeeEntryDate").val() == null || $("#employeeEntryDate").val() == ""){
|
|
|
|
+ layer.msg('入职日期不能为空', {icon: 5, time: 1000});
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //离职日期
|
|
|
|
+ var employeeState = $("[name='employeeState']:checked").val();
|
|
|
|
+ if(employeeState == 0){
|
|
|
|
+ if($("#employeeDepartureDate").val() == null || $("#employeeDepartureDate").val() == ""){
|
|
|
|
+ layer.msg('离职日期不能为空', {icon: 5, time: 1000});
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+ var employeeEntryDate = $("[name='employeeEntryDate']").val();
|
|
|
|
+ var employeeDepartureDate = $("[name='employeeDepartureDate']").val();
|
|
|
|
+ if(!CompareDate(employeeDepartureDate,employeeEntryDate)){
|
|
|
|
+ layer.msg('离职日期不能再入职日期之前', {icon: 5, time: 1000});
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- },
|
|
|
|
- onkeyup:false,
|
|
|
|
- focusCleanup:true,
|
|
|
|
- success:"valid",
|
|
|
|
- submitHandler:function(form){
|
|
|
|
- $.post(root_path + "/admin/employee/save_employee", formatJSON(),function(result){
|
|
|
|
- if (result.returnCode != 200 || result.returnCode != 200) {
|
|
|
|
- layer.msg('录入失败,请重试!',{icon: 5,time:3000});
|
|
|
|
- } else {
|
|
|
|
- layer.msg('录入成功!!',{icon: 1,time:2000}, function () {
|
|
|
|
- // 关闭当前页面,并刷新父级页面
|
|
|
|
- window.location.href= '${path}/admin/employee/list_employee';
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
}
|
|
}
|
|
- });
|
|
|
|
- });*/
|
|
|
|
|
|
|
|
|
|
+ var employeePost = $("#employeePost").val();
|
|
|
|
+ if(!(cnen_name.test(employeePost))){
|
|
|
|
+ layer.msg('员工岗位格式不正确', {icon: 5, time: 1000});
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// var employeeDesc = $("#employeeDesc").val();
|
|
|
|
+// if(!(check_name.test(employeeDesc))){
|
|
|
|
+// layer.msg('员工备注格式不正确', {icon: 5, time: 1000});
|
|
|
|
+// return false;
|
|
|
|
+// }
|
|
|
|
|
|
- $(function(){
|
|
|
|
- //var validator = $("#form-admin-addEmployee").validate();
|
|
|
|
- $("#form-admin-addEmployee").submit(function(){
|
|
|
|
ajaxReq();
|
|
ajaxReq();
|
|
return false;
|
|
return false;
|
|
})
|
|
})
|
|
-
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ function CompareDate(d1,d2)
|
|
|
|
+ {
|
|
|
|
+ return ((new Date(d1.replace(/-/g,"\/"))) > (new Date(d2.replace(/-/g,"\/"))));
|
|
|
|
+ }
|
|
|
|
+
|
|
/* ajax请求*/
|
|
/* ajax请求*/
|
|
function ajaxReq(){
|
|
function ajaxReq(){
|
|
var data = formatJSON();
|
|
var data = formatJSON();
|
|
@@ -126,17 +151,37 @@
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /*实时监听文本框-- 员工编号*/
|
|
|
|
- document.getElementById("employeeNo").addEventListener("input", function(){
|
|
|
|
- ptsValiDataEmNo(this.value);
|
|
|
|
- });
|
|
|
|
- /*实时监听文本框-- 手机号码*/
|
|
|
|
- document.getElementById("employeeTel").addEventListener("input", function(){
|
|
|
|
- ptsValiDataTel(this.value);
|
|
|
|
- });
|
|
|
|
|
|
+ /*实时监听文本框-- 员工编号*/
|
|
|
|
+// document.getElementById("employeeNo").addEventListener("input", function(){
|
|
|
|
+// ptsValiDataEmNo();
|
|
|
|
+// });
|
|
|
|
+// /*实时监听文本框-- 手机号码*/
|
|
|
|
+// document.getElementById("employeeTel").addEventListener("input", function(){
|
|
|
|
+// ptsValiDataTel(this.value);
|
|
|
|
+// });
|
|
|
|
+//
|
|
|
|
+// /*实时监听文本框-- 员工姓名*/
|
|
|
|
+// document.getElementById("employeeName").addEventListener("input", function(){
|
|
|
|
+// ptsValiDataTel(this.value);
|
|
|
|
+// });
|
|
|
|
+// /*实时监听文本框-- 手机号码*/
|
|
|
|
+// document.getElementById("employeeTel").addEventListener("input", function(){
|
|
|
|
+// ptsValiDataTel(this.value);
|
|
|
|
+// });
|
|
|
|
|
|
/*验证编号*/
|
|
/*验证编号*/
|
|
- function ptsValiDataEmNo(thVal) {
|
|
|
|
|
|
+ function ptsValiDataEmNo() {
|
|
|
|
+ var thVal = $("#employeeNo").val();
|
|
|
|
+
|
|
|
|
+ if( thVal == null || thVal == "" || typeof(thVal) == "undefined"){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!(check_name.test(thVal))){
|
|
|
|
+ layer.msg('员工编码格式不正确', {icon: 5, time: 1000});
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ var flag = false;
|
|
$.ajax({
|
|
$.ajax({
|
|
cache: true,
|
|
cache: true,
|
|
type: "POST",
|
|
type: "POST",
|
|
@@ -147,33 +192,37 @@
|
|
async: false,
|
|
async: false,
|
|
success: function(data){
|
|
success: function(data){
|
|
if (data.returnCode == 200) {
|
|
if (data.returnCode == 200) {
|
|
- $("#employeeNoMsg").html("该员工编号已存在");
|
|
|
|
- return false;
|
|
|
|
|
|
+ //$("#employeeNoMsg").html("该员工编号已存在");
|
|
|
|
+ layer.msg('该员工编号已存在', {icon: 5, time: 1000});
|
|
|
|
+ flag = false;
|
|
}else{
|
|
}else{
|
|
- $("#employeeNoMsg").html("");
|
|
|
|
- return true;
|
|
|
|
|
|
+ //$("#employeeNoMsg").html("");
|
|
|
|
+ flag = true;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
error: function(XmlHttpRequest, textStatus, errorThrown){
|
|
error: function(XmlHttpRequest, textStatus, errorThrown){
|
|
-
|
|
|
|
|
|
+ flag = false;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ return flag;
|
|
}
|
|
}
|
|
|
|
|
|
/*验证手机号码*/
|
|
/*验证手机号码*/
|
|
- function ptsValiDataTel(thVal) {
|
|
|
|
|
|
+ function ptsValiDataTel() {
|
|
|
|
+ var thVal = $("#employeeTel").val();
|
|
|
|
+
|
|
if(!(/^1[34578]\d{9}$/.test(thVal))){
|
|
if(!(/^1[34578]\d{9}$/.test(thVal))){
|
|
- $("#employeeTelMsg").html("手机号码错误");
|
|
|
|
|
|
+ //$("#employeeTelMsg").html("手机号码错误");
|
|
|
|
+ layer.msg('手机号码格式化不正确', {icon: 5, time: 1000});
|
|
return false;
|
|
return false;
|
|
}else{
|
|
}else{
|
|
- $("#employeeTelMsg").html("");
|
|
|
|
|
|
+ //$("#employeeTelMsg").html("");
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*将表单format为JSON*/
|
|
/*将表单format为JSON*/
|
|
function formatJSON() {
|
|
function formatJSON() {
|
|
- debugger;
|
|
|
|
var serializeObj={};
|
|
var serializeObj={};
|
|
$($("#form-admin-addEmployee").serializeArray()).each(function(){
|
|
$($("#form-admin-addEmployee").serializeArray()).each(function(){
|
|
if (this.value != "" && this.value != null) {
|
|
if (this.value != "" && this.value != null) {
|