虞城12345_前端

Add.html 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. }if(!$("#startTime").val()){
  73. layer.msg("输入选择日期");
  74. }
  75. var user=$("#zx").val();
  76. var role=$('#role').val();
  77. Add(user,role)
  78. })
  79. //获取下拉框
  80. $.getJSON(huayi.config.callcenter_url + "Notice/GetRoleList", {
  81. "token": $.cookie("token")
  82. }, function(result) {
  83. if(result.state.toLowerCase() == "success") {
  84. goodslist = result.data;
  85. bindseat($("#role"));
  86. }
  87. });
  88. //下拉框
  89. function bindseat(obj) {
  90. obj.empty();
  91. obj.append('<option value="0" selected="selected">所有角色</option>');
  92. $(goodslist).each(function(i, n) {
  93. obj.append('<option value="' + n.F_RoleId + '">' + n.F_RoleName + '</option>');
  94. })
  95. }
  96. $.getJSON(huayi.config.callcenter_url + "Notice/GetUserListByRoleId", {
  97. "token":$.cookie("token"),"roleid":0
  98. }, function(result) {
  99. if(result.state.toLowerCase() == "success") {
  100. goodslist = result.data;
  101. bindZX($("#zx"));
  102. }
  103. });
  104. function bindZX(obj) {
  105. obj.empty();
  106. obj.append('<option value="0" selected="selected">所有人</option>');
  107. $(goodslist).each(function(i, n) {
  108. obj.append('<option value="' + n.F_UserId + '">' + n.F_UserCode + '</option>');
  109. })
  110. }
  111. $("#role").change(function(){
  112. var pid=$(this).val();
  113. $.getJSON(huayi.config.callcenter_url + "Notice/GetUserListByRoleId", {
  114. "token":$.cookie("token"),"roleid":pid
  115. }, function(result) {
  116. if(result.state.toLowerCase() == "success") {
  117. goodslist = result.data;
  118. bindZX($("#zx"));
  119. }
  120. });
  121. })
  122. })
  123. function Add(user,role){
  124. $.post(huayi.config.callcenter_url + "Notice/AddNotice", {
  125. title:$("#title").val(),
  126. content:$("#content").val(),
  127. stime:$('#startTime').val() && $('#startTime').val().split('~')[0],
  128. etime:$('#startTime').val() && $('#startTime').val().split('~')[1],
  129. token: $.cookie("token"),
  130. userid:user,
  131. roleid:role
  132. }, function(result) {
  133. result = JSON.parse(result);
  134. if(result.state.toLowerCase() == "success") {
  135. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  136. parent.layer.close(index); //再执行关闭
  137. parent.initTable();
  138. parent.layer.msg("添加成功");
  139. }
  140. })
  141. }
  142. // function GetData() {
  143. // var date = new Date;
  144. // var year = date.getFullYear();
  145. // var month = date.getMonth() + 1;
  146. // var strDate = date.getDate();
  147. // month = (month <= 9 ? "0" + month : month);
  148. // strDate = (strDate <= 9 ? "0" + strDate : strDate)
  149. // var mydate = (year.toString() + '-' + month.toString() + '-' + strDate.toString());
  150. // $('#startTime').val() && $('#startTime').val().split('~')[0]
  151. // }
  152. // GetData();
  153. </script>
  154. </body>
  155. </html>