Browse Source

员工设备下拉框修改

wangxiaoming 7 years ago
parent
commit
ff362d8de3

+ 8 - 4
watero-rst-web/src/main/webapp/WEB-INF/views/pts/device/device_list.ftl

@@ -7,8 +7,12 @@
         *{padding: 0;margin: 0;}
         .my-input{border: 1px solid rgba(0,0,0,.1);padding: 1px 5px;height: 32px;margin-right: 10px;}
         .my-input::-webkit-input-placeholder,.my-select{color: #dcdcdc;}
-        .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;height: 34px;margin: 0 10px; -webkit-appearance:none;appearance:none;background: url(images/select-1.png) right center no-repeat;background-size:auto 100%;}
+        .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;height: 34px;margin: 0 10px; -webkit-appearance:none;appearance:none;background: url(/rst/common/images/pts/select-1.png) right center no-repeat;background-size:auto 100%;}
         .my-btn-search{border: 1px solid #32a3d8;padding: 1px 25px;height: 32px;background-color: #32a3d8;color: #fff;}
+        .barcodeImg{margin:10px 0px}
+        .table-bg thead th{background-color: #e2f6ff;}
+        input[type=radio]{-webkit-appearance:none;appearance:none;background: url(/rst/common/images/pts/radio-1.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
+        input[type=radio]:checked{-webkit-appearance:none;appearance:none;background: url(/rst/common/images/pts/radio-2.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
     </style>
 <#include "/base/list_base.ftl">
 </head>
@@ -23,13 +27,13 @@
         <form name="form1" action="${path}/admin/equipment/select_device_list" method="post">
             <button type="button" style="cursor:pointer;float: left;" class="my-btn-search" onclick="add_device();">添加设备</button>
             <input class="my-input" type="text" name="deviceNumber" value="${deviceNumber!}" placeholder="请输入设备编号"/>
-            <select class="select" name="deviceStatus" style="height: 30px;width: 150px">
+            <input class="my-input" type="text" name="deviceName" value="${deviceName!}" placeholder="请输入设备名称"/>
+            <input class="my-input" type="text" name="deviceRemake" value="${deviceRemake!}" placeholder="请输入备注"/>
+            <select class="my-select" name="deviceStatus" style="height: 30px;width: 150px">
                 <option value ="">全部</option>
                 <option value ="0" <#if deviceStatus??><#if deviceStatus == 0>selected="selected"</#if></#if>>停止使用</option>
                 <option value ="1" <#if deviceStatus??><#if deviceStatus == 1>selected="selected"</#if></#if>>正常使用</option>
             </select>
-            <input class="my-input" type="text" name="deviceName" value="${deviceName!}" placeholder="请输入设备名称"/>
-            <input class="my-input" type="text" name="deviceRemake" value="${deviceRemake!}" placeholder="请输入备注"/>
             <button style="cursor:pointer;" type="submit" class="my-btn-search">搜索</button>
         </form>
     </div>

+ 12 - 4
watero-rst-web/src/main/webapp/WEB-INF/views/pts/employee/employee_list.ftl

@@ -11,7 +11,15 @@
 <#include "/base/list_base.ftl">
     <title>员工列表</title>
     <style>
+        *{padding: 0;margin: 0;}
+        .my-input{border: 1px solid rgba(0,0,0,.1);padding: 1px 5px;height: 32px;margin-right: 10px;}
+        .my-input::-webkit-input-placeholder,.my-select{color: #dcdcdc;}
+        .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;height: 34px;margin: 0 10px; -webkit-appearance:none;appearance:none;background: url(/rst/common/images/pts/select-1.png) right center no-repeat;background-size:auto 100%;}
         .my-btn-search{border: 1px solid #32a3d8;padding: 1px 25px;height: 32px;background-color: #32a3d8;color: #fff;}
+        .barcodeImg{margin:10px 0px}
+        .table-bg thead th{background-color: #e2f6ff;}
+        input[type=radio]{-webkit-appearance:none;appearance:none;background: url(/rst/common/images/pts/radio-1.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
+        input[type=radio]:checked{-webkit-appearance:none;appearance:none;background: url(/rst/common/images/pts/radio-2.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
     </style>
 </head>
 <body>
@@ -24,10 +32,10 @@
     <div class="text-c">
         <form action="${path}/admin/employee/_employee_list" method="post">
             <button type="button" style="cursor:pointer; float: left;" class="my-btn-search" onclick="toAddEmployee();">增加员工</button>
-            <input type="text" class="input-text" style="width:150px" value="${employeeNo!}" placeholder="员工编号" id="employeeNo" name="employeeNo">
-            <input type="text" class="input-text" style="width:150px" value="${employeeName!}" placeholder="员工姓名" id="employeeName" name="employeeName">
-            <input type="text" class="input-text" style="width:150px" value="${employeeTel!}" placeholder="员工电话" id="employeeTel" name="employeeTel">
-            <select class="select" name="employeeState" style="height: 30px;width: 150px">
+            <input type="text" class="my-input"  style="width:150px" value="${employeeNo!}" placeholder="员工编号" id="employeeNo" name="employeeNo">
+            <input type="text" class="my-input"  style="width:150px" value="${employeeName!}" placeholder="员工姓名" id="employeeName" name="employeeName">
+            <input type="text" class="my-input"  style="width:150px" value="${employeeTel!}" placeholder="员工电话" id="employeeTel" name="employeeTel">
+            <select class="my-select" name="employeeState" style="height: 30px;width: 150px">
                 <option value ="">全部</option>
                 <option value ="1" <#if employeeState??><#if employeeState == "1">selected="selected"</#if></#if>>在职</option>
                 <option value ="0" <#if employeeState??><#if employeeState == "0">selected="selected"</#if></#if>>离职</option>

+ 95 - 46
watero-rst-web/src/main/webapp/WEB-INF/views/pts/employee/save_employee.ftl

@@ -68,44 +68,69 @@
     $(document).on('click', '.menuSubid input[type=radio]', function() {
         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();
             return false;
         })
-
     })
 
+    function CompareDate(d1,d2)
+    {
+        return ((new Date(d1.replace(/-/g,"\/"))) > (new Date(d2.replace(/-/g,"\/"))));
+    }
+
     /* ajax请求*/
     function ajaxReq(){
         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({
             cache: true,
             type: "POST",
@@ -147,33 +192,37 @@
             async: false,
             success: function(data){
                 if (data.returnCode == 200) {
-                    $("#employeeNoMsg").html("该员工编号已存在");
-                    return false;
+                    //$("#employeeNoMsg").html("该员工编号已存在");
+                    layer.msg('该员工编号已存在', {icon: 5, time: 1000});
+                    flag = false;
                 }else{
-                    $("#employeeNoMsg").html("");
-                    return true;
+                    //$("#employeeNoMsg").html("");
+                    flag = true;
                 }
             },
             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))){
-            $("#employeeTelMsg").html("手机号码错误");
+            //$("#employeeTelMsg").html("手机号码错误");
+            layer.msg('手机号码格式化不正确', {icon: 5, time: 1000});
             return false;
         }else{
-            $("#employeeTelMsg").html("");
+            //$("#employeeTelMsg").html("");
             return true;
         }
     }
 
     /*将表单format为JSON*/
     function formatJSON() {
-        debugger;
         var serializeObj={};
         $($("#form-admin-addEmployee").serializeArray()).each(function(){
             if (this.value != "" && this.value != null) {

+ 11 - 9
watero-rst-web/src/main/webapp/WEB-INF/views/pts/employee/update_employee.ftl

@@ -119,12 +119,14 @@
                 return false;
             }
 
-            var employeeDesc = $("#employeeDesc").val();
-            if(!(check_name.test(employeeDesc))){
-                layer.msg('员工备注格式不正确', {icon: 5, time: 1000});
-                return false;
-            }
-
+//            var employeeDesc = $("#employeeDesc").val();
+//            if( employeeDesc != null && employeeDesc != "" && typeof(employeeDesc) != "undefined"){
+//                alert("++"+employeeDesc+"+++");
+//                if(!(check_name.test(employeeDesc))){
+//                    layer.msg('员工备注格式不正确', {icon: 5, time: 1000});
+//                    return false;
+//                }
+//            }
             ajaxReq();
             return false;
         })
@@ -137,9 +139,9 @@
     }
 
     /*实时监听文本框-- 员工编号*/
-    document.getElementById("employeeNo").addEventListener("input", function(){
-        ptsValiDataEmNo();
-    });
+//    document.getElementById("employeeNo").addEventListener("input", function(){
+//        ptsValiDataEmNo();
+//    });
 
     function ajaxReq(){
         var data = formatJSON();