save_employee.ftl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="Cache-Control" content="no-siteapp" />
  9. <#include "/base/add_base.ftl">
  10. <link href="${path}/common/lib/jquery.ui/jquery-ui.css" rel="stylesheet" type="text/css" />
  11. <style>
  12. .my-title{font-weight: 500;padding-left: 15px;position: relative;}
  13. .my-title:after{content: '';position: absolute;left: 0;top:12%;width: 3px;height: 80%;background: #32a3d8;}
  14. .my-input{padding: 5px 10px;width: 80%;border:1px solid rgba(0,0,0,.1);}
  15. .my-input-date{padding: 5px 10px;border:1px solid rgba(0,0,0,.1);width: 80%;background: url(${path}/common/images/pts//rili-1.png) 98.5% center no-repeat; background-size:auto 80%;}
  16. .input-box{margin: 18px 0;}
  17. .input-dic{float: left;margin:5px 10px 0 0;font-size: 12px;}
  18. .add-list{list-style-type: none;padding: 10px;background-color: #f5f5f5;width: 60%;float: left;margin: 0;}
  19. .add-list>li{margin: 10px 0;}
  20. .my-textarea{padding: 5px 10px;width: 80%;border:1px solid rgba(0,0,0,.1);}
  21. .my-btn-reset{padding: 6px 20px;width: 150px; background-color: #fff;color: #32a3d8;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
  22. .my-btn-submit{padding: 6px 20px;width: 150px; background-color: #32a3d8;color: #fff;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
  23. .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;width: 60%; height: 34px;margin: 0 10px; -webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/select-1.png) right center no-repeat #fff;background-size:auto 100%;}
  24. 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;}
  25. 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;}
  26. </style>
  27. <title>添加员工- 员工管理 - RST</title>
  28. </head>
  29. <body>
  30. <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
  31. <span class="c-gray en">&gt;</span> 员工管理
  32. <span class="c-gray en">&gt;</span> 添加员工
  33. <a class="btn radius r" style="line-height:1.6em;margin-top:3px;background: #32a3d8;color: #fff;border:1px solid #32a3d8;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
  34. </nav>
  35. <article class="page-container">
  36. <form class="form form-horizontal" id="form-admin-addEmployee">
  37. <div style="padding: 10px;width: 600px;margin: 0 auto;">
  38. <div class="my-title">员工信息</div>
  39. <div class="input-box"><span class="input-dic">员工编号</span>&nbsp;&nbsp;<input class="my-input" name="employeeNo" id="employeeNo" type="text" value="" placeholder="请输入员工编号" required maxlength="10" /> <span style="color: red;" id="employeeNoMsg"></span></div>
  40. <div class="input-box"><span class="input-dic">员工姓名</span>&nbsp;&nbsp;<input class="my-input" name="employeeName" id="employeeName" type="text" value="" placeholder="请输入2-10位中文" required maxlength="10" minlength="2" /> </div>
  41. <div class="input-box"><span class="input-dic">手机号码</span>&nbsp;&nbsp;<input class="my-input" name="employeeTel" id="employeeTel" type="text" value="" placeholder="请输入11位的手机号码" required maxlength="11" minlength="11" /><span style="color: red;" id="employeeTelMsg"></span> </div>
  42. <div class="input-box"><span class="input-dic">员工状态</span>&nbsp;&nbsp;
  43. <input type="radio" id="employeeState1" name="employeeState" value="1" checked/><label for="employeeState1">在职</label>
  44. <input type="radio" id="employeeState2" name="employeeState" value="0"/><label for="employeeState2">离职</label>
  45. </div>
  46. <div class="input-box"><span class="input-dic" style="margin-top: 0">清空卡权限</span>
  47. <input type="radio" id="employeeClearPower1" name="employeeClearPower" value="0" /><label for="employeeClearPower1">具有</label>
  48. <input type="radio" id="employeeClearPower2" name="employeeClearPower" value="1" checked /><label for="employeeClearPower2">不具有</label>
  49. </div>
  50. <div class="input-box"><span class="input-dic">入职日期</span>&nbsp;&nbsp;<input class="my-input-date" type="text" name="employeeEntryDate" id="employeeEntryDate" value="" placeholder="请选择入职日期" onclick="WdatePicker({skin:'whyGreen'})" readonly="readonly" /> </div>
  51. <div class="input-box" id="isDeparture"><span class="input-dic">离职日期</span>&nbsp;&nbsp;<input class="my-input-date" type="text" name="employeeDepartureDate" id="employeeDepartureDate" value="" placeholder="请选择离职日期" onclick="WdatePicker({ dateFmt:'yyyy-MM-dd',skin:'whyGreen',minDate:'#F{$dp.$D(\'employeeEntryDate\')||\'%y-%M-%d\'}' })" readonly="readonly"/></div>
  52. <div class="input-box"><span class="input-dic">员工岗位</span>&nbsp;&nbsp;<input class="my-input" type="text" name="employeePost" id="employeePost" value="" placeholder="请输入2-20位中文、英文字符描述" required maxlength="20" minlength="2" /> </div>
  53. <div class="input-box"><span class="input-dic">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;拉线</span>&nbsp;&nbsp;<input class="my-input" type="text" name="employeeLine" id="employeeLine" value="" placeholder="请输入2-30位中文、英文、数字字符描述" required maxlength="30" minlength="2" /> </div>
  54. <div style="clear: both;"></div>
  55. <div class="input-box"><span class="input-dic">员工备注</span>&nbsp;&nbsp;
  56. <textarea rows="3" cols="20" class="my-textarea" name="employeeDesc" id="employeeDesc" maxlength="200" msg="员工备注" ></textarea>
  57. </div>
  58. <div>
  59. <button type="reset" class="my-btn-reset">重置</button><button type="submit" class="my-btn-submit" >确认提交</button>
  60. </div>
  61. </div>
  62. </form>
  63. </article>
  64. <script type="text/javascript" src="${path}/common/lib/My97DatePicker/4.8/WdatePicker.js"></script>
  65. <script type="text/javascript">
  66. //动态显示隐藏所属菜单
  67. $(document).on('click', '.menuSubid input[type=radio]', function() {
  68. isSelectShow($(this).val())
  69. })
  70. var check_name = /^[a-zA-Z0-9\u4e00-\u9fa5]+$/;
  71. var cnen_name = /^[a-zA-Z\u4e00-\u9fa5]+$/;
  72. var china_name = /^[\u4e00-\u9fa5]+$/;
  73. var en_name = /^[a-zA-Z0-9]+$/;
  74. $(function(){
  75. //var validator = $("#form-admin-addEmployee").validate();
  76. $("#form-admin-addEmployee").submit(function(){
  77. if(!ptsValiDataEmNo()){
  78. return false;
  79. };
  80. var employeeName = $("#employeeName").val();
  81. if(!(china_name.test(employeeName))){
  82. layer.msg('员工姓名格式不正确', {icon: 5, time: 1000});
  83. return false;
  84. }
  85. if(!ptsValiDataTel()){
  86. return false;
  87. };
  88. if($("#employeeEntryDate").val() == null || $("#employeeEntryDate").val() == ""){
  89. layer.msg('入职日期不能为空', {icon: 5, time: 1000});
  90. return false;
  91. };
  92. //离职日期
  93. var employeeState = $("[name='employeeState']:checked").val();
  94. if(employeeState == 0){
  95. if($("#employeeDepartureDate").val() == null || $("#employeeDepartureDate").val() == ""){
  96. layer.msg('离职日期不能为空', {icon: 5, time: 1000});
  97. return false;
  98. };
  99. var employeeEntryDate = $("[name='employeeEntryDate']").val();
  100. var employeeDepartureDate = $("[name='employeeDepartureDate']").val();
  101. if(!CompareDate(employeeDepartureDate,employeeEntryDate)){
  102. layer.msg('离职日期不能在入职日期之前', {icon: 5, time: 1000});
  103. return false;
  104. }
  105. }
  106. var employeePost = $("#employeePost").val();
  107. if(!(cnen_name.test(employeePost))){
  108. layer.msg('员工岗位格式不正确', {icon: 5, time: 1000});
  109. return false;
  110. }
  111. var employeeLine = $("#employeeLine").val();
  112. if(!(check_name.test(employeeLine))){
  113. layer.msg('拉线格式不正确', {icon: 5, time: 1000});
  114. return false;
  115. }
  116. // var employeeDesc = $("#employeeDesc").val();
  117. // if(!(check_name.test(employeeDesc))){
  118. // layer.msg('员工备注格式不正确', {icon: 5, time: 1000});
  119. // return false;
  120. // }
  121. ajaxReq();
  122. return false;
  123. })
  124. })
  125. function CompareDate(d1,d2)
  126. {
  127. return ((new Date(d1.replace(/-/g,"\/"))) > (new Date(d2.replace(/-/g,"\/"))));
  128. }
  129. /* ajax请求*/
  130. function ajaxReq(){
  131. var data = formatJSON();
  132. $.ajax({
  133. cache: true,
  134. type: "POST",
  135. data: data,
  136. url: "${path}/admin/employee/save_employee",
  137. async: false,
  138. success: function(data){
  139. if (data.returnCode == 200) {
  140. window.location.href = '${path}//admin/employee/_employee_list'
  141. }
  142. },
  143. error: function(XmlHttpRequest, textStatus, errorThrown){
  144. }
  145. });
  146. }
  147. /*实时监听文本框-- 员工编号*/
  148. // document.getElementById("employeeNo").addEventListener("input", function(){
  149. // ptsValiDataEmNo();
  150. // });
  151. // /*实时监听文本框-- 手机号码*/
  152. // document.getElementById("employeeTel").addEventListener("input", function(){
  153. // ptsValiDataTel(this.value);
  154. // });
  155. //
  156. // /*实时监听文本框-- 员工姓名*/
  157. // document.getElementById("employeeName").addEventListener("input", function(){
  158. // ptsValiDataTel(this.value);
  159. // });
  160. // /*实时监听文本框-- 手机号码*/
  161. // document.getElementById("employeeTel").addEventListener("input", function(){
  162. // ptsValiDataTel(this.value);
  163. // });
  164. /*验证编号*/
  165. function ptsValiDataEmNo() {
  166. var thVal = $("#employeeNo").val();
  167. if( thVal == null || thVal == "" || typeof(thVal) == "undefined"){
  168. return false;
  169. }
  170. if(!(en_name.test(thVal))){
  171. layer.msg('员工编码格式不正确', {icon: 5, time: 1000});
  172. return false;
  173. }
  174. var flag = false;
  175. $.ajax({
  176. cache: true,
  177. type: "POST",
  178. data: {
  179. employeeNo:thVal
  180. },
  181. url: "${path}/admin/employee/is_employee",
  182. async: false,
  183. success: function(data){
  184. if (data.returnCode == 200) {
  185. //$("#employeeNoMsg").html("该员工编号已存在");
  186. layer.msg('该员工编号已存在', {icon: 5, time: 1000});
  187. flag = false;
  188. }else{
  189. //$("#employeeNoMsg").html("");
  190. flag = true;
  191. }
  192. },
  193. error: function(XmlHttpRequest, textStatus, errorThrown){
  194. flag = false;
  195. }
  196. });
  197. return flag;
  198. }
  199. /*验证手机号码*/
  200. function ptsValiDataTel() {
  201. var thVal = $("#employeeTel").val();
  202. if(!(/^1[34578]\d{9}$/.test(thVal))){
  203. //$("#employeeTelMsg").html("手机号码错误");
  204. layer.msg('手机号码格式化不正确', {icon: 5, time: 1000});
  205. return false;
  206. }else{
  207. //$("#employeeTelMsg").html("");
  208. return true;
  209. }
  210. }
  211. /*将表单format为JSON*/
  212. function formatJSON() {
  213. var serializeObj={};
  214. $($("#form-admin-addEmployee").serializeArray()).each(function(){
  215. if (this.value != "" && this.value != null) {
  216. serializeObj[this.name]=this.value;
  217. }
  218. });
  219. return serializeObj;
  220. }
  221. $(function(){
  222. //隐藏离职日期
  223. $("#isDeparture").hide();
  224. //监听离职状态,离职的才有离职时间
  225. $("[name='employeeState']").change(function(){
  226. $("[name='employeeDepartureDate']").val("");
  227. var departureDate = $("[name='employeeState']:checked").val();
  228. if(departureDate == "0"){
  229. $("#isDeparture").show();
  230. }else{
  231. $("#isDeparture").hide();
  232. }
  233. })
  234. })
  235. </script>
  236. </body>
  237. </html>