12345市长热线标准版-前端

Add.html 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. <input type="text" id="startTime" class="laydate-icon" style="height: 32px;">-
  37. <input type="text" id="endTime" class="laydate-icon" style="height: 32px;">
  38. </td>
  39. </tr>
  40. <tr>
  41. <th>角色:</th>
  42. <td>
  43. <select name="" id="role" class="select_"></select>
  44. <select name="" id="zx" class="select_"></select>
  45. </td>
  46. </tr>
  47. <tr>
  48. <th >内容:</th>
  49. <td colspan="2">
  50. <textarea data-adaptheight id="content" name="" rows="" cols=""></textarea>
  51. </td>
  52. </tr>
  53. </table>
  54. <div class="btn_box">
  55. <button class="btns">保存</button>
  56. </div>
  57. </div>
  58. <script src="../js/adjustHeight.js"></script>
  59. <script src="../css/laydate/laydate.js"></script>
  60. <script >
  61. laydate.skin('blue');
  62. laydate({
  63. elem: '#startTime',
  64. event: 'focus',
  65. });
  66. laydate({
  67. elem: '#endTime',
  68. event: 'focus'
  69. });
  70. $(document).ready(function(){
  71. $(".btns").click(function(){
  72. if(!$("#title").val()){
  73. layer.msg("输入标题");
  74. }
  75. else if(!$("#startTime").val()){
  76. layer.msg("输入选择日期");
  77. }else if(!$("#endTime").val()){
  78. layer.msg("输入选择日期");
  79. }else{
  80. // if($('#role').val()==0){
  81. // role=$('#role').val();
  82. // user=0;
  83. // }else{
  84. // role=$('#role').val();
  85. // user=$('#role').val();
  86. // }
  87. var user=$("#zx").val();
  88. var role=$('#role').val();
  89. Add(user,role)
  90. }
  91. })
  92. //获取下拉框
  93. $.getJSON(huayi.config.callcenter_url + "Notice/GetRoleList", {
  94. "token": $.cookie("token")
  95. }, function(result) {
  96. if(result.state.toLowerCase() == "success") {
  97. goodslist = result.data;
  98. bindseat($("#role"));
  99. }
  100. });
  101. //下拉框
  102. function bindseat(obj) {
  103. obj.empty();
  104. obj.append('<option value="0" selected="selected">所有角色</option>');
  105. $(goodslist).each(function(i, n) {
  106. obj.append('<option value="' + n.F_RoleId + '">' + n.F_RoleName + '</option>');
  107. })
  108. }
  109. $.getJSON(huayi.config.callcenter_url + "Notice/GetUserListByRoleId", {
  110. "token":$.cookie("token"),"roleid":0
  111. }, function(result) {
  112. if(result.state.toLowerCase() == "success") {
  113. goodslist = result.data;
  114. bindZX($("#zx"));
  115. }
  116. });
  117. function bindZX(obj) {
  118. obj.empty();
  119. obj.append('<option value="0" selected="selected">所有人</option>');
  120. $(goodslist).each(function(i, n) {
  121. obj.append('<option value="' + n.F_UserId + '">' + n.F_UserCode + '</option>');
  122. })
  123. }
  124. $("#role").change(function(){
  125. var pid=$(this).val();
  126. $.getJSON(huayi.config.callcenter_url + "Notice/GetUserListByRoleId", {
  127. "token":$.cookie("token"),"roleid":pid
  128. }, function(result) {
  129. if(result.state.toLowerCase() == "success") {
  130. goodslist = result.data;
  131. bindZX($("#zx"));
  132. }
  133. });
  134. })
  135. })
  136. function Add(user,role){
  137. $.post(huayi.config.callcenter_url + "Notice/AddNotice", {
  138. title:$("#title").val(),
  139. content:$("#content").val(),
  140. stime:$("#startTime").val(),
  141. etime:$('#endTime').val(),
  142. token: $.cookie("token"),
  143. userid:user,
  144. roleid:role
  145. }, function(result) {
  146. result = JSON.parse(result);
  147. if(result.state.toLowerCase() == "success") {
  148. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  149. parent.layer.close(index); //再执行关闭
  150. parent.initTable();
  151. parent.layer.msg("添加成功");
  152. }
  153. })
  154. }
  155. function GetData() {
  156. var date = new Date;
  157. var year = date.getFullYear();
  158. var month = date.getMonth() + 1;
  159. var strDate = date.getDate();
  160. month = (month <= 9 ? "0" + month : month);
  161. strDate = (strDate <= 9 ? "0" + strDate : strDate)
  162. var mydate = (year.toString() + '-' + month.toString() + '-' + strDate.toString());
  163. $("#startTime").val(mydate);
  164. $("#endTime").val(mydate);
  165. }
  166. GetData();
  167. </script>
  168. </body>
  169. </html>