No Description

Add.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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. width: 100%;
  70. background: #fff;
  71. text-align: center;
  72. padding: 10px 15px;
  73. height: auto;
  74. overflow-y: initial;
  75. }
  76. .common table {
  77. width: 100%;
  78. }
  79. .common table th {
  80. padding: 5px 8px 5px 0;
  81. text-align: right;
  82. width: 20%;
  83. }
  84. .common table td {
  85. padding: 6px 0 5px 10px;
  86. text-align: left;
  87. color: #717171;
  88. line-height: 200%;
  89. }
  90. .common table td textarea {
  91. width: 100%;
  92. vertical-align: middle;
  93. resize: none;
  94. outline: none;
  95. }
  96. .time-box {
  97. position: relative;
  98. padding-left: 0;
  99. }
  100. i.tub {
  101. position: absolute;
  102. right: 26px;
  103. top: 8px;
  104. font-size: 18px;
  105. color: #00a0ca;
  106. }
  107. </style>
  108. </head>
  109. <body>
  110. <div class="common">
  111. <table>
  112. <tr>
  113. <th>标题:</th>
  114. <td>
  115. <input class="BiaoTi" id="title" type="text" style="" />
  116. </td>
  117. </tr>
  118. <tr>
  119. <th>有效期:</th>
  120. <td>
  121. <div class="col-md-6 time-box">
  122. <i class="tub fa fa-calendar"></i>
  123. <input class="form-control" type="text" id="greetingTimes">
  124. </div>
  125. </td>
  126. </tr>
  127. <tr>
  128. <th>角色:</th>
  129. <td>
  130. <!--<select name="" id="role" class="select_"></select>-->
  131. <!--<span>所有角色</span>-->
  132. <div class="inpBox" id="organizer">
  133. <!--<input id="citySel" class="inps" readonly />-->
  134. <input type="hidden" id="OPID" />
  135. <!--<i class="xl xl_one" id="xl_one"></i>-->
  136. <div id="menuContent" class="menuContent">
  137. <ul id="treeDemo" class="ztree"></ul>
  138. </div>
  139. </div>
  140. <!--<select name="" id="zx" class="select_"></select>-->
  141. </td>
  142. <th></th>
  143. <td>
  144. <!--<span>所有人</span>-->
  145. </td>
  146. </tr>
  147. <tr>
  148. <th>内容:</th>
  149. <td colspan="2">
  150. <textarea data-adaptheight id="content" name="" rows="" cols=""></textarea>
  151. </td>
  152. </tr>
  153. </table>
  154. <div class="btn_box">
  155. <button class="btns">保存</button>
  156. </div>
  157. </div>
  158. <script src="../js/adjustHeight.js"></script>
  159. <!--<script src="../css/laydate/laydate.js"></script>-->
  160. <script src="../js/zTree/jquery.ztree.core.js"></script>
  161. <script src="../js/zTree/jquery.ztree.excheck.min.js"></script>
  162. <script src="../js/kindeditor/kindeditor-all-min.js"></script>
  163. <script src="../js/kindeditor/lang/zh-CN.js"></script>
  164. <script>
  165. laydate.render({
  166. elem: '#greetingTimes',
  167. range: '~',
  168. // type: 'datetime',
  169. //max : 31,
  170. min: 0,
  171. theme: '#00a1cb',
  172. });
  173. $(document).ready(function () {
  174. //编辑器配置
  175. KindEditor.ready(function (K) {
  176. window.editor = K.create('#content', {
  177. //urlType: 'domain',
  178. imgMaxSize: 10 * 1024 * 1024,
  179. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  180. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  181. allowFileManager: true
  182. }); //添加弹出框编辑器
  183. });
  184. $(".btns").click(function () {
  185. if (!$("#title").val()) {
  186. layer.msg("输入标题");
  187. } else if (!$("#greetingTimes").val()) {
  188. layer.msg("输入选择日期");
  189. } else {
  190. // if($('#role').val()==0){
  191. // role=$('#role').val();
  192. // user=0;
  193. // }else{
  194. // role=$('#role').val();
  195. // user=$('#role').val();
  196. // }
  197. var user = $('#OPID').val();
  198. var role = $('#OPIDs').val();
  199. var ztree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);
  200. console.log(ztree);
  201. var app = [];
  202. var app2 = [];
  203. var user;
  204. var role;
  205. if (ztree.length > 0) {
  206. var Id = [];
  207. $.each(ztree, function (i, n) {
  208. if (n.F_Pid == 0) {
  209. Id.push(n.F_Id);
  210. } else {
  211. app.push(n.F_Id);
  212. }
  213. app2 = Id;
  214. });
  215. user = app.join(',');
  216. role = app2.join(',')
  217. }
  218. Add(user, role)
  219. }
  220. })
  221. })
  222. function Add(user, role) {
  223. $.post(huayi.config.callcenter_url + "Notice/AddNotice", {
  224. title: $("#title").val(),
  225. //content: $("#content").val(),
  226. content: encodeURIComponent(editor.html()),
  227. stime: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[0],//开始时间
  228. etime: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[1],//结束时间
  229. token: $.cookie("token"),
  230. userid: user,
  231. roleid: role
  232. }, function (result) {
  233. result = JSON.parse(result);
  234. if (result.state.toLowerCase() == "success") {
  235. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  236. parent.layer.close(index); //再执行关闭
  237. parent.initTable();
  238. parent.layer.msg("添加成功");
  239. }
  240. })
  241. }
  242. function GetData() {
  243. var date = new Date;
  244. var year = date.getFullYear();
  245. var month = date.getMonth() + 1;
  246. var strDate = date.getDate();
  247. month = (month <= 9 ? "0" + month : month);
  248. strDate = (strDate <= 9 ? "0" + strDate : strDate)
  249. var mydate = (year.toString() + '-' + month.toString() + '-' + strDate.toString());
  250. $('#greetingTimes').val(mydate + ' ~ ' + mydate)
  251. }
  252. GetData();
  253. var saveArr = []
  254. tree(saveArr);
  255. // $("#xl_one").click(function() {
  256. // $(this).parent().find(".menuContent").toggle();
  257. // });
  258. // $('.inps').focus(function() {
  259. // $('#menuContent').css('display', 'block')
  260. // })
  261. // $('#menuContent').mouseleave(function() {
  262. // $(this).css('display', 'none')
  263. // })
  264. //树形结构 所有角色
  265. function tree(saveArr) {
  266. $.get(huayi.config.callcenter_url + 'Notice/GetRoleUsersList', {
  267. "token": $.cookie("token"),
  268. }, function (result) {
  269. result = $.parseJSON(result);
  270. $.fn.zTree.init($("#treeDemo"), setting, result.data);
  271. });
  272. }
  273. var setting = {
  274. check: {
  275. enable: true,
  276. // chkboxType: {"Y":"", "N":""},
  277. },
  278. data: {
  279. key: {
  280. name: "F_Name"
  281. },
  282. simpleData: {
  283. enable: true,
  284. idKey: "F_Id",
  285. pIdKey: "F_Pid",
  286. rootPId: 0
  287. }
  288. },
  289. callback: {
  290. onCheck: zTreeOnClick
  291. }
  292. };
  293. function zTreeOnClick(event, treeId, treeNode) {
  294. var name = treeNode.name;
  295. // var c="";
  296. // for(var i=0;i<nodes.length;i++){
  297. // if(nodes[i].isParent!=true){
  298. // c+=nodes[i].id+",";
  299. // console.log(c);
  300. // }
  301. // }
  302. };
  303. function zTreeOnClick(e, treeId, treeNode) {
  304. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  305. nodes = zTree.getCheckedNodes(true);
  306. console.log(treeNode)
  307. var v = "",
  308. opid = '';
  309. for (var i = 0, l = nodes.length; i < l; i++) {
  310. v += nodes[i].F_Name + ",";
  311. console.log(v);
  312. opid += nodes[i].F_DeptId + ","
  313. }
  314. if (v.length > 0) v = v.substring(0, v.length - 1);
  315. var cityObj = $("#citySel");
  316. cityObj.val(v);
  317. $("#citySel").val(v);
  318. console.log(opid);
  319. if (opid.length > 0) opid = opid.substring(0, opid.length - 1);
  320. $('#OPID').attr("value", opid);
  321. $('#OPIDs').attr("value", opid);
  322. }
  323. </script>
  324. </body>
  325. </html>