睢县12345_前端

Add.html 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <script src="../Script/Common/huayi.load.js"></script>
  6. <script src="../Script/Common/huayi.config.js"></script>
  7. <!--<link href="../css/layer/need/layer.css" />-->
  8. <link rel="stylesheet" href="../css/init.css" />
  9. <title></title>
  10. <style>
  11. .BiaoTi{
  12. width: 100%;
  13. text-align:center;
  14. border-color:#ccc ;
  15. border:1px solid #ccc;
  16. }
  17. textarea{
  18. border-color:#ccc ;
  19. border:1px solid #ccc;
  20. height: 100px;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <div class="Common">
  26. <table >
  27. <tr>
  28. <th>标题:</th>
  29. <td>
  30. <input class="BiaoTi" id="title" type="text" style="" />
  31. </td>
  32. </tr>
  33. <tr>
  34. <th >有效期:</th>
  35. <td >
  36. <div class="time-box form-group" style="width: 230px;">
  37. <i class="tub fa fa-calendar"></i>
  38. <input class="form-control" type="text" id="startTime" placeholder="有效期">
  39. </div>
  40. </td>
  41. </tr>
  42. <tr>
  43. <th>角色:</th>
  44. <td>
  45. <select name="" id="role" class="select_"></select>
  46. <select name="" id="zx" class="select_"></select>
  47. </td>
  48. </tr>
  49. <tr>
  50. <th >内容:</th>
  51. <td colspan="2">
  52. <textarea data-adaptheight id="content" name="" rows="" cols=""></textarea>
  53. </td>
  54. </tr>
  55. </table>
  56. <div class="btn_box">
  57. <button class="btns">保存</button>
  58. </div>
  59. </div>
  60. <script src="../js/adjustHeight.js"></script>
  61. <script src="../js/laydate/laydate.js"></script>
  62. <script >
  63. laydate.render({
  64. elem: '#startTime',
  65. range: '~',
  66. theme: '#00a1cb',
  67. });
  68. $(document).ready(function(){
  69. $(".btns").click(function(){
  70. if(!$("#title").val()){
  71. layer.msg("输入标题");
  72. return
  73. }if(!$("#startTime").val()){
  74. layer.msg("输入选择日期");
  75. return
  76. }
  77. var user=$("#zx").val();
  78. var role=$('#role').val();
  79. Add(user,role)
  80. })
  81. //获取下拉框
  82. $.getJSON(huayi.config.callcenter_url + "Notice/GetRoleList", {
  83. "token": $.cookie("token")
  84. }, function(result) {
  85. if(result.state.toLowerCase() == "success") {
  86. goodslist = result.data;
  87. bindseat($("#role"));
  88. }
  89. });
  90. //下拉框
  91. function bindseat(obj) {
  92. obj.empty();
  93. obj.append('<option value="0" selected="selected">所有角色</option>');
  94. $(goodslist).each(function(i, n) {
  95. obj.append('<option value="' + n.F_RoleId + '">' + n.F_RoleName + '</option>');
  96. })
  97. }
  98. $.getJSON(huayi.config.callcenter_url + "Notice/GetUserListByRoleId", {
  99. "token":$.cookie("token"),"roleid":0
  100. }, function(result) {
  101. if(result.state.toLowerCase() == "success") {
  102. goodslist = result.data;
  103. bindZX($("#zx"));
  104. }
  105. });
  106. function bindZX(obj) {
  107. obj.empty();
  108. obj.append('<option value="0" selected="selected">所有人</option>');
  109. $(goodslist).each(function(i, n) {
  110. obj.append('<option value="' + n.F_UserId + '">' + n.F_UserCode + '</option>');
  111. })
  112. }
  113. $("#role").change(function(){
  114. var pid=$(this).val();
  115. $.getJSON(huayi.config.callcenter_url + "Notice/GetUserListByRoleId", {
  116. "token":$.cookie("token"),"roleid":pid
  117. }, function(result) {
  118. if(result.state.toLowerCase() == "success") {
  119. goodslist = result.data;
  120. bindZX($("#zx"));
  121. }
  122. });
  123. })
  124. })
  125. function Add(user,role){
  126. $.post(huayi.config.callcenter_url + "Notice/AddNotice", {
  127. title:$("#title").val(),
  128. content:$("#content").val(),
  129. stime:$('#startTime').val() && $('#startTime').val().split('~')[0],
  130. etime:$('#startTime').val() && $('#startTime').val().split('~')[1],
  131. token: $.cookie("token"),
  132. userid:user,
  133. roleid:role
  134. }, function(result) {
  135. result = JSON.parse(result);
  136. if(result.state.toLowerCase() == "success") {
  137. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  138. parent.layer.close(index); //再执行关闭
  139. parent.initTable();
  140. parent.layer.msg("添加成功");
  141. }
  142. })
  143. }
  144. // function GetData() {
  145. // var date = new Date;
  146. // var year = date.getFullYear();
  147. // var month = date.getMonth() + 1;
  148. // var strDate = date.getDate();
  149. // month = (month <= 9 ? "0" + month : month);
  150. // strDate = (strDate <= 9 ? "0" + strDate : strDate)
  151. // var mydate = (year.toString() + '-' + month.toString() + '-' + strDate.toString());
  152. // $('#startTime').val() && $('#startTime').val().split('~')[0]
  153. // }
  154. // GetData();
  155. </script>
  156. </body>
  157. </html>