update_employee.ftl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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;width: 80%;border:1px solid rgba(0,0,0,.1);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: 8px 20px;width: 150px; background-color: #fff;color: #32a3d8;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
  22. .my-btn-submit{padding: 8px 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;height: 34px; -webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/select-11.png) right center no-repeat;background-size:auto 100%;}
  24. input[type=radio]{-webkit-appearance:none;appearance:none;background: url(${path}/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(${path}/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">/</span> 员工管理
  32. <span class="c-gray en">/</span> 修改员工
  33. <a class="btn radius r" 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. <input type="hidden" name="employeeId" value="${employee.employeeId!}">
  40. <input type="hidden" id="oldNo" value="${employee.employeeNo!}" >
  41. <div class="input-box"><span class="input-dic">员工编号</span>&nbsp;&nbsp;<input class="my-input" name="employeeNo" id="employeeNo" type="text" value="${employee.employeeNo!}" placeholder="请输入员工编号" required maxlength="10" /> </div>
  42. <div class="input-box"><span class="input-dic">员工姓名</span>&nbsp;&nbsp;<input class="my-input" name="employeeName" id="employeeName" type="text" value="${employee.employeeName!}" placeholder="请输入2-10位中文" required maxlength="10" minlength="2" /> </div>
  43. <div class="input-box"><span class="input-dic">手机号码</span>&nbsp;&nbsp;<input class="my-input" name="employeeTel" id="employeeTel" type="text" value="${employee.employeeTel!}" placeholder="请输入11位的手机号码" /> </div>
  44. <div class="input-box"><span class="input-dic" style="margin-top: 0">员工状态</span>&nbsp;&nbsp;
  45. <input type="radio" id="employeeState1" name="employeeState" value="1" <#if employee.employeeState == 1>checked</#if>/><label for="employeeState1">在职</label>
  46. <input type="radio" id="employeeState2" name="employeeState" value="0" <#if employee.employeeState == 0>checked</#if>/><label for="employeeState2">离职</label>
  47. </div>
  48. <div class="input-box"><span class="input-dic" style="margin-top: 0">清空卡权限</span>
  49. <input type="radio" id="employeeClearPower1" name="employeeClearPower" value="0" <#if employee.employeeClearPower == 0>checked</#if>/><label for="employeeClearPower1">具有</label>
  50. <input type="radio" id="employeeClearPower2" name="employeeClearPower" value="1" <#if employee.employeeClearPower == 1>checked</#if>/><label for="employeeClearPower2">不具有</label>
  51. </div>
  52. <div class="input-box"><span class="input-dic">入职日期</span>&nbsp;&nbsp;<input class="my-input-date" type="text" name="employeeEntryDate" id="employeeEntryDate" value="${(employee.employeeEntryDate?string("yyyy-MM-dd"))!''}" placeholder="请选择入职日期" onclick="WdatePicker({skin:'whyGreen'})" readonly="readonly"/> </div>
  53. <div class="input-box" id="isDeparture" style="<#if employee.employeeState == 1>display: none</#if>"><span class="input-dic">离职日期</span>&nbsp;&nbsp;<input class="my-input-date" type="text" name="employeeDepartureDate" id="employeeDepartureDate" value="${(employee.employeeDepartureDate?string("yyyy-MM-dd"))!''}" placeholder="请选择离职日期" onclick="WdatePicker({ dateFmt:'yyyy-MM-dd',skin:'whyGreen' })" readonly="readonly"/> </div>
  54. <div class="input-box"><span class="input-dic">员工岗位</span>&nbsp;&nbsp;<input class="my-input" type="text" name="employeePost" id="employeePost" value="${employee.employeePost!}" placeholder="请输入2-20位中文、英文字符描述" required maxlength="20" minlength="2" /> </div>
  55. <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="${employee.employeeLine!}" placeholder="请输入2-30位中文、英文、数字字符描述" required maxlength="30" minlength="2" /> </div>
  56. <div style="clear: both;"></div>
  57. <div class="input-box"><span class="input-dic">员工备注</span>&nbsp;&nbsp;
  58. <textarea rows="3" cols="20" class="my-textarea" name="employeeDesc" id="employeeDesc" maxlength="200">${employee.employeeDesc!}</textarea>
  59. </div>
  60. <div>
  61. <#--<button type="reset" class="my-btn-reset">重置</button>--><button type="submit" class="my-btn-submit">确认提交</button>
  62. </div>
  63. </div>
  64. </form>
  65. </article>
  66. <script type="text/javascript" src="${path}/common/lib/My97DatePicker/4.8/WdatePicker.js"></script>
  67. <script type="text/javascript">
  68. //动态显示隐藏所属菜单
  69. $(document).on('click', '.menuSubid input[type=radio]', function() {
  70. isSelectShow($(this).val())
  71. })
  72. var check_name = /^[a-zA-Z0-9\u4e00-\u9fa5]+$/;
  73. var cnen_name = /^[a-zA-Z\u4e00-\u9fa5]+$/;
  74. var china_name = /^[\u4e00-\u9fa5]+$/;
  75. var en_name = /^[a-zA-Z0-9]+$/;
  76. $(function(){
  77. //var validator = $("#form-admin-addEmployee").validate();
  78. $("#form-admin-addEmployee").submit(function(){
  79. if(!ptsValiDataEmNo()){
  80. return false;
  81. };
  82. var employeeName = $("#employeeName").val();
  83. if(!(china_name.test(employeeName))){
  84. layer.msg('员工姓名格式不正确', {icon: 5, time: 1000});
  85. return false;
  86. }
  87. if(!ptsValiDataTel()){
  88. return false;
  89. };
  90. if($("#employeeEntryDate").val() == null || $("#employeeEntryDate").val() == ""){
  91. layer.msg('入职日期不能为空', {icon: 5, time: 1000});
  92. return false;
  93. };
  94. //离职日期
  95. var employeeState = $("[name='employeeState']:checked").val();
  96. if(employeeState == 0){
  97. if($("#employeeDepartureDate").val() == null || $("#employeeDepartureDate").val() == ""){
  98. layer.msg('离职日期不能为空', {icon: 5, time: 1000});
  99. return false;
  100. }
  101. var employeeEntryDate = $("[name='employeeEntryDate']").val();
  102. var employeeDepartureDate = $("[name='employeeDepartureDate']").val();
  103. if(!CompareDate(employeeDepartureDate,employeeEntryDate)){
  104. layer.msg('离职日期不能在入职日期之前', {icon: 5, time: 1000});
  105. return false;
  106. }
  107. }
  108. var employeePost = $("#employeePost").val();
  109. if(!(cnen_name.test(employeePost))){
  110. layer.msg('员工岗位格式不正确', {icon: 5, time: 1000});
  111. return false;
  112. }
  113. var employeeLine = $("#employeeLine").val();
  114. if(!(check_name.test(employeeLine))){
  115. layer.msg('拉线格式不正确', {icon: 5, time: 1000});
  116. return false;
  117. }
  118. // var employeeDesc = $("#employeeDesc").val();
  119. // if( employeeDesc != null && employeeDesc != "" && typeof(employeeDesc) != "undefined"){
  120. // alert("++"+employeeDesc+"+++");
  121. // if(!(check_name.test(employeeDesc))){
  122. // layer.msg('员工备注格式不正确', {icon: 5, time: 1000});
  123. // return false;
  124. // }
  125. // }
  126. ajaxReq();
  127. return false;
  128. })
  129. })
  130. /*比较时间*/
  131. function CompareDate(d1,d2)
  132. {
  133. return ((new Date(d1.replace(/-/g,"\/"))) > (new Date(d2.replace(/-/g,"\/"))));
  134. }
  135. /*实时监听文本框-- 员工编号*/
  136. // document.getElementById("employeeNo").addEventListener("input", function(){
  137. // ptsValiDataEmNo();
  138. // });
  139. function ajaxReq(){
  140. var data = formatJSON();
  141. $.ajax({
  142. cache: true,
  143. type: "POST",
  144. data: data,
  145. url: "${path}/admin/employee/update_employee",
  146. async: false,
  147. success: function(data){
  148. if (data.returnCode == 200) {
  149. window.location.href = '${path}/admin/employee/_employee_list'
  150. }
  151. },
  152. error: function(XmlHttpRequest, textStatus, errorThrown){
  153. }
  154. });
  155. }
  156. /*验证编号*/
  157. function ptsValiDataEmNo() {
  158. var thVal = $("#employeeNo").val();
  159. if( thVal == null || thVal == "" || typeof(thVal) == "undefined"){
  160. return false;
  161. }
  162. if($("#oldNo").val() == thVal){
  163. return true;
  164. }
  165. if(!(en_name.test(thVal))){
  166. layer.msg('员工编码格式不正确', {icon: 5, time: 1000});
  167. return false;
  168. }
  169. var flag = false;
  170. $.ajax({
  171. cache: true,
  172. type: "POST",
  173. data: {
  174. employeeNo:thVal
  175. },
  176. url: "${path}/admin/employee/is_employee",
  177. async: false,
  178. success: function(data){
  179. if (data.returnCode == 200) {
  180. layer.msg('该员工编号已存在', {icon: 5, time: 1000});
  181. flag = false;
  182. }else{
  183. flag = true;
  184. }
  185. },
  186. error: function(XmlHttpRequest, textStatus, errorThrown){
  187. flag = false;
  188. }
  189. });
  190. return flag;
  191. }
  192. /*验证手机号码*/
  193. function ptsValiDataTel() {
  194. var thVal = $("#employeeTel").val();
  195. if(!(/^(\s*|1[34578]\d{9})$/.test(thVal))){
  196. layer.msg('手机号码格式化不正确', {icon: 5, time: 1000});
  197. return false;
  198. }else{
  199. return true;
  200. }
  201. }
  202. /*将表单format为JSON*/
  203. function formatJSON() {
  204. var serializeObj={};
  205. $($("#form-admin-addEmployee").serializeArray()).each(function(){
  206. if (this.value != "" && this.value != null) {
  207. serializeObj[this.name]=this.value;
  208. }
  209. });
  210. return serializeObj;
  211. }
  212. $(function(){
  213. //监听离职状态,离职的才有离职时间
  214. $("[name='employeeState']").change(function(){
  215. $("[name='employeeDepartureDate']").val("");
  216. var departureDate = $("[name='employeeState']:checked").val();
  217. if(departureDate == "0"){
  218. $("#isDeparture").show();
  219. }else{
  220. $("#isDeparture").hide();
  221. }
  222. })
  223. })
  224. </script>
  225. </body>
  226. </html>