商丘12345 前端

Add.html 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. <script src="../js/laydate/laydate.js"></script>
  8. <!--<link href="../css/layer/need/layer.css" />-->
  9. <link rel="stylesheet" href="../css/init.css" />
  10. <link rel="stylesheet" href="../js/zTree/zTreeStyle.css" />
  11. <title></title>
  12. <style>
  13. .BiaoTi {
  14. width: 100%;
  15. text-align: center;
  16. border-color: #ccc;
  17. border: 1px solid #ccc;
  18. }
  19. textarea {
  20. border-color: #ccc;
  21. border: 1px solid #ccc;
  22. height: 100px;
  23. }
  24. .xl {
  25. display: inline-block;
  26. background: url(../img/dropDown.png) no-repeat;
  27. height: 100%;
  28. background-position: center center;
  29. width: 20px;
  30. position: absolute;
  31. right: 0;
  32. top: 0px;
  33. /* background-color: #f7bc8b; */
  34. cursor: pointer;
  35. }
  36. ul.ztree {
  37. /*margin-top: 10px;*/
  38. width: 161px;
  39. overflow-y: scroll;
  40. overflow-x: auto;
  41. }
  42. #organizer {
  43. height: 25px;
  44. width: 170px;
  45. display: inline-block;
  46. position: relative;
  47. height: 135px;
  48. overflow: hidden;
  49. }
  50. #menuContent {
  51. background: #fff;
  52. position: absolute;
  53. width: 100%;
  54. border: 1px solid #ccc;
  55. right: 0;
  56. top: 0;
  57. z-index: 10;
  58. /*display: none;*/
  59. overflow-y: auto;
  60. height: 100%;
  61. }
  62. .ztree li span {
  63. line-height: 16px;
  64. margin-right: 2px;
  65. padding: 0;
  66. border: none;
  67. }
  68. .Common{
  69. overflow-y:initial
  70. }
  71. .time-box{
  72. position: relative;
  73. padding-left: 0;
  74. }
  75. i.tub {
  76. position: absolute;
  77. right: 26px;
  78. top: 8px;
  79. font-size: 18px;
  80. color: #00a0ca;
  81. }
  82. </style>
  83. </head>
  84. <body>
  85. <div class="Common">
  86. <table>
  87. <tr>
  88. <th>标题:</th>
  89. <td>
  90. <input class="BiaoTi" id="title" type="text" style="" />
  91. </td>
  92. </tr>
  93. <tr>
  94. <th>有效期:</th>
  95. <td>
  96. <div class="col-md-6 time-box">
  97. <i class="tub fa fa-calendar"></i>
  98. <input class="form-control" type="text" id="greetingTimes">
  99. </div>
  100. </td>
  101. </tr>
  102. <tr>
  103. <th>角色:</th>
  104. <td>
  105. <!--<select name="" id="role" class="select_"></select>-->
  106. <!--<span>所有角色</span>-->
  107. <div class="inpBox" id="organizer">
  108. <!--<input id="citySel" class="inps" readonly />-->
  109. <input type="hidden" id="OPID" />
  110. <!--<i class="xl xl_one" id="xl_one"></i>-->
  111. <div id="menuContent" class="menuContent">
  112. <ul id="treeDemo" class="ztree">
  113. </ul>
  114. </div>
  115. </div>
  116. <!--<select name="" id="zx" class="select_"></select>-->
  117. </td>
  118. <th></th>
  119. <td>
  120. <!--<span>所有人</span>-->
  121. </td>
  122. </tr>
  123. <tr>
  124. <th>内容:</th>
  125. <td colspan="2">
  126. <textarea data-adaptheight id="content" name="" rows="" cols=""></textarea>
  127. </td>
  128. </tr>
  129. </table>
  130. <div class="btn_box">
  131. <button class="btns">保存</button>
  132. </div>
  133. </div>
  134. <script src="../js/adjustHeight.js"></script>
  135. <!--<script src="../css/laydate/laydate.js"></script>-->
  136. <script src="../js/zTree/jquery.ztree.core.js"></script>
  137. <script src="../js/zTree/jquery.ztree.excheck.min.js"></script>
  138. <script>
  139. laydate.render({
  140. elem: '#greetingTimes',
  141. range: '~',
  142. // type: 'datetime',
  143. //max : 31,
  144. min: 0,
  145. theme: '#00a1cb',
  146. });
  147. $(document).ready(function() {
  148. $(".btns").click(function() {
  149. if(!$("#title").val()) {
  150. layer.msg("输入标题");
  151. } else if(!$("#greetingTimes").val()) {
  152. layer.msg("输入选择日期");
  153. } else {
  154. // if($('#role').val()==0){
  155. // role=$('#role').val();
  156. // user=0;
  157. // }else{
  158. // role=$('#role').val();
  159. // user=$('#role').val();
  160. // }
  161. var user = $('#OPID').val();
  162. var role = $('#OPIDs').val();
  163. var ztree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);
  164. console.log(ztree);
  165. var app = [];
  166. var app2=[];
  167. var user;
  168. var role;
  169. if(ztree.length > 0) {
  170. var Id=[];
  171. $.each(ztree, function(i, n) {
  172. if(n.F_Pid==0){
  173. Id.push(n.F_Id);
  174. }else{
  175. app.push(n.F_Id);
  176. }
  177. app2=Id;
  178. });
  179. user=app.join(',');
  180. role=app2.join(',')
  181. }
  182. Add(user,role)
  183. }
  184. })
  185. })
  186. function Add(user, role) {
  187. $.post(huayi.config.callcenter_url + "Notice/AddNotice", {
  188. title: $("#title").val(),
  189. content: $("#content").val(),
  190. stime: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[0],//开始时间
  191. etime: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[1],//结束时间
  192. token: $.cookie("token"),
  193. userid: user,
  194. roleid: role
  195. }, function(result) {
  196. result = JSON.parse(result);
  197. if(result.state.toLowerCase() == "success") {
  198. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  199. parent.layer.close(index); //再执行关闭
  200. parent.initTable();
  201. parent.layer.msg("添加成功");
  202. }
  203. })
  204. }
  205. function GetData() {
  206. var date = new Date;
  207. var year = date.getFullYear();
  208. var month = date.getMonth() + 1;
  209. var strDate = date.getDate();
  210. month = (month <= 9 ? "0" + month : month);
  211. strDate = (strDate <= 9 ? "0" + strDate : strDate)
  212. var mydate = (year.toString() + '-' + month.toString() + '-' + strDate.toString());
  213. $('#greetingTimes').val(mydate+' ~ '+mydate)
  214. }
  215. GetData();
  216. var saveArr = []
  217. tree(saveArr);
  218. // $("#xl_one").click(function() {
  219. // $(this).parent().find(".menuContent").toggle();
  220. // });
  221. // $('.inps').focus(function() {
  222. // $('#menuContent').css('display', 'block')
  223. // })
  224. // $('#menuContent').mouseleave(function() {
  225. // $(this).css('display', 'none')
  226. // })
  227. //树形结构 所有角色
  228. function tree(saveArr) {
  229. $.get(huayi.config.callcenter_url + 'Notice/GetRoleUsersList', {
  230. "token": $.cookie("token"),
  231. }, function(result) {
  232. result = $.parseJSON(result);
  233. $.fn.zTree.init($("#treeDemo"), setting, result.data);
  234. });
  235. }
  236. var setting = {
  237. check: {
  238. enable: true,
  239. // chkboxType: {"Y":"", "N":""},
  240. },
  241. data: {
  242. key: {
  243. name: "F_Name"
  244. },
  245. simpleData: {
  246. enable: true,
  247. idKey: "F_Id",
  248. pIdKey: "F_Pid",
  249. rootPId: 0
  250. }
  251. },
  252. callback: {
  253. onCheck: zTreeOnClick
  254. }
  255. };
  256. function zTreeOnClick(event, treeId, treeNode) {
  257. var name = treeNode.name;
  258. // var c="";
  259. // for(var i=0;i<nodes.length;i++){
  260. // if(nodes[i].isParent!=true){
  261. // c+=nodes[i].id+",";
  262. // console.log(c);
  263. // }
  264. // }
  265. };
  266. function zTreeOnClick(e, treeId, treeNode) {
  267. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  268. nodes = zTree.getCheckedNodes(true);
  269. console.log(treeNode)
  270. var v = "",
  271. opid = '';
  272. for(var i = 0, l = nodes.length; i < l; i++) {
  273. v += nodes[i].F_Name + ",";
  274. console.log(v);
  275. opid += nodes[i].F_DeptId + ","
  276. }
  277. if(v.length > 0) v = v.substring(0, v.length - 1);
  278. var cityObj = $("#citySel");
  279. cityObj.val(v);
  280. $("#citySel").val(v);
  281. console.log(opid);
  282. if(opid.length > 0) opid = opid.substring(0, opid.length - 1);
  283. $('#OPID').attr("value", opid);
  284. $('#OPIDs').attr("value", opid);
  285. }
  286. </script>
  287. </body>
  288. </html>