信阳市12345_前端

BlackWhiteAdd.html 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <script src="../js/huayi.load.js"></script>
  6. <script src="../js/laydate/laydate.js"></script>
  7. <link href="../js/laydate/theme/default/laydate.css" />
  8. <title>添加</title>
  9. <style>
  10. </style>
  11. </head>
  12. <body>
  13. <input type="hidden" id="PID" value="" />
  14. <div class="wrapper wrapper-content animated fadeInRight">
  15. <div style="padding: 10px" class="tj_content clearFix">
  16. <div class="Common">
  17. <table>
  18. <tr>
  19. <th style="width:120px;"><span style="color:red;">*</span>手机号:</th>
  20. <td>
  21. <input type="text" id="mobile" class="form-control" maxlength="12" />
  22. </td>
  23. </tr>
  24. <tr>
  25. <th style="width:120px;"><span style="color:red;">*</span>类型:</th>
  26. <td>
  27. <label>
  28. <input type="radio" name="type" value="1" checked />
  29. 黑名单
  30. </label>
  31. <label>
  32. <input type="radio" name="type" value="2" />
  33. 白名单
  34. </label>
  35. </td>
  36. </tr>
  37. <tr class="start">
  38. <th style="width:120px;"><span style="color:red;">*</span>开始时间:</th>
  39. <td>
  40. <input type="text" id="startTime" class="form-control" />
  41. </td>
  42. </tr>
  43. <tr class="end">
  44. <th style="width:120px;"><span style="color:red;">*</span>结束时间:</th>
  45. <td>
  46. <input type="text" id="endTime" class="form-control" />
  47. </td>
  48. </tr>
  49. <tr >
  50. <th style="width:120px;">备注:</th>
  51. <td>
  52. <input type="text" id="remark" class="form-control" />
  53. </td>
  54. </tr>
  55. <tr>
  56. <td colspan="4" style="text-align: center">
  57. <button class="btns save">保存</button>
  58. </td>
  59. </tr>
  60. </table>
  61. </div>
  62. </div>
  63. </div>
  64. <script>
  65. var id = helper.request.queryString("id");
  66. $(document).ready(function () {
  67. laydate.render({
  68. elem: '#startTime',
  69. event: 'focus',
  70. type:'datetime'
  71. });
  72. laydate.render({
  73. elem: '#endTime',
  74. event: 'focus',
  75. type: 'datetime'
  76. });
  77. $(".save").click(function () {
  78. Add();
  79. });
  80. $("input[name='type']").change(function () {
  81. var val = $("input[name='type']:checked").val();
  82. if (val == '1') {
  83. $(".start").show();
  84. $(".end").show();
  85. }
  86. else {
  87. $(".start").hide();
  88. $(".end").hide();
  89. }
  90. })
  91. if (id) {
  92. $.getJSON(huayi.config.callcenter_url + "SystemApi/GetBlackWhite", {
  93. mobile: id
  94. }, function (data) {
  95. if (data.state.toLowerCase() == "success") {
  96. var model = data.data;
  97. $("#mobile").attr("readonly", true);
  98. $("#mobile").val(model.mobile);
  99. $("input[name=type][value='" + model.type + "']").attr('checked', true);
  100. $("input[name='type']").trigger("change");
  101. $("#startTime").val(model.startTime);
  102. $("#endTime").val(model.endTime);
  103. $("#remark").val(model.remark);
  104. }
  105. });
  106. }
  107. });
  108. //修改工单
  109. function Add() {
  110. var mobile = $("#mobile").val();
  111. if (!mobile) {
  112. layer.confirm("请输入手机号!", {
  113. btn: ['确定'] //按钮
  114. });
  115. return;
  116. }
  117. else {
  118. if (mobile.length > 12) {
  119. layer.confirm("手机号不能超过12位!", {
  120. btn: ['确定'] //按钮
  121. });
  122. return;
  123. }
  124. }
  125. var type = $("input[name='type']:checked").val();
  126. if (type == '1') {
  127. if (!$("#startTime").val()) {
  128. layer.confirm("请选择开始时间!", {
  129. btn: ['确定'] //按钮
  130. });
  131. return;
  132. }
  133. if (!$("#endTime").val()) {
  134. layer.confirm("请选择结束时间!", {
  135. btn: ['确定'] //按钮
  136. });
  137. return;
  138. }
  139. }
  140. var api;
  141. if (id) {
  142. api = "SystemApi/EditBlackWhite";
  143. } else {
  144. api = "SystemApi/AddBlackWhite";
  145. }
  146. $.post(huayi.config.callcenter_url + api, {
  147. mobile: $("#mobile").val(),
  148. type: $("input[name='type']:checked").val(),
  149. startTime: type == '2' ? '' : $("#startTime").val(),
  150. endTime: type == '2' ? '' : $("#endTime").val(),
  151. remark: $("#remark").val()
  152. }, function (data) {
  153. if (data.state.toLowerCase() == "success") {
  154. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  155. parent.layer.close(index); //再执行关闭
  156. parent.$("#tableList").bootstrapTable("refresh");
  157. parent.layer.msg("保存成功");
  158. }
  159. });
  160. }
  161. </script>
  162. </body>
  163. </html>