Нет описания

Add.html 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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 class="files-wrappper">
  148. <th class="Importent">附件:</th>
  149. <td colspan="5">
  150. <div class="fileBox"></div>
  151. <!--<span class="fjnr"></span>-->
  152. <input class="input" type="file" name="upFile" id="upFile" multiple="multiple"
  153. style="display: none" />
  154. <input class="input" type="button" value="上传" id="scwj" />
  155. <!--<input class="input" type="button" value="删除附件" id="scfj" style="display:none;" />-->
  156. <input type="hidden" id="file" />
  157. <span style="color: #ff0000; border: none">
  158. (文件格式为png,jpg,mp4,mp3,pdf,doc,docx,xls,xlsx)
  159. </span>
  160. </td>
  161. </tr>
  162. <tr>
  163. <th>内容:</th>
  164. <td colspan="2">
  165. <textarea data-adaptheight id="content" name="" rows="" cols=""></textarea>
  166. </td>
  167. </tr>
  168. </table>
  169. <div class="btn_box">
  170. <button class="btns">保存</button>
  171. </div>
  172. </div>
  173. <script src="../js/adjustHeight.js"></script>
  174. <!--<script src="../css/laydate/laydate.js"></script>-->
  175. <script src="../js/zTree/jquery.ztree.core.js"></script>
  176. <script src="../js/zTree/jquery.ztree.excheck.min.js"></script>
  177. <script src="../js/kindeditor/kindeditor-all-min.js"></script>
  178. <script src="../js/kindeditor/lang/zh-CN.js"></script>
  179. <script src="../Script/Common/huayi.common.js"></script>
  180. <script>
  181. laydate.render({
  182. elem: '#greetingTimes',
  183. range: '~',
  184. // type: 'datetime',
  185. //max : 31,
  186. min: 0,
  187. theme: '#00a1cb',
  188. });
  189. $(document).ready(function () {
  190. //编辑器配置
  191. KindEditor.ready(function (K) {
  192. window.editor = K.create('#content', {
  193. //urlType: 'domain',
  194. imgMaxSize: 10 * 1024 * 1024,
  195. uploadJson: '../../js/kindeditor/asp.net/upload_json.ashx',
  196. fileManagerJson: '../../js/kindeditor/asp.net/file_manager_json.ashx',
  197. allowFileManager: true
  198. }); //添加弹出框编辑器
  199. });
  200. $(".btns").click(function () {
  201. if (!$("#title").val()) {
  202. layer.msg("输入标题");
  203. } else if (!$("#greetingTimes").val()) {
  204. layer.msg("输入选择日期");
  205. } else {
  206. // if($('#role').val()==0){
  207. // role=$('#role').val();
  208. // user=0;
  209. // }else{
  210. // role=$('#role').val();
  211. // user=$('#role').val();
  212. // }
  213. var user = $('#OPID').val();
  214. var role = $('#OPIDs').val();
  215. var ztree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);
  216. console.log(ztree);
  217. var app = [];
  218. var app2 = [];
  219. var user;
  220. var role;
  221. if (ztree.length > 0) {
  222. var Id = [];
  223. $.each(ztree, function (i, n) {
  224. if (n.F_Pid == 0) {
  225. Id.push(n.F_Id);
  226. } else {
  227. app.push(n.F_Id);
  228. }
  229. app2 = Id;
  230. });
  231. user = app.join(',');
  232. role = app2.join(',')
  233. }
  234. Add(user, role)
  235. }
  236. })
  237. })
  238. function Add(user, role) {
  239. $.post(huayi.config.callcenter_url + "Notice/AddNotice", {
  240. title: $("#title").val(),
  241. //content: $("#content").val(),
  242. content: encodeURIComponent(editor.html()),
  243. stime: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[0], //开始时间
  244. etime: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[1], //结束时间
  245. token: $.cookie("token"),
  246. userid: user,
  247. roleid: role,
  248. file: $("#file").val(),
  249. }, function (result) {
  250. result = JSON.parse(result);
  251. if (result.state.toLowerCase() == "success") {
  252. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  253. parent.layer.close(index); //再执行关闭
  254. parent.initTable();
  255. parent.layer.msg("添加成功");
  256. }
  257. })
  258. }
  259. function GetData() {
  260. var date = new Date;
  261. var year = date.getFullYear();
  262. var month = date.getMonth() + 1;
  263. var strDate = date.getDate();
  264. month = (month <= 9 ? "0" + month : month);
  265. strDate = (strDate <= 9 ? "0" + strDate : strDate)
  266. var mydate = (year.toString() + '-' + month.toString() + '-' + strDate.toString());
  267. $('#greetingTimes').val(mydate + ' ~ ' + mydate)
  268. }
  269. GetData();
  270. var saveArr = []
  271. tree(saveArr);
  272. // $("#xl_one").click(function() {
  273. // $(this).parent().find(".menuContent").toggle();
  274. // });
  275. // $('.inps').focus(function() {
  276. // $('#menuContent').css('display', 'block')
  277. // })
  278. // $('#menuContent').mouseleave(function() {
  279. // $(this).css('display', 'none')
  280. // })
  281. //树形结构 所有角色
  282. function tree(saveArr) {
  283. $.get(huayi.config.callcenter_url + 'Notice/GetRoleUsersList', {
  284. "token": $.cookie("token"),
  285. }, function (result) {
  286. result = $.parseJSON(result);
  287. $.fn.zTree.init($("#treeDemo"), setting, result.data);
  288. });
  289. }
  290. var setting = {
  291. check: {
  292. enable: true,
  293. // chkboxType: {"Y":"", "N":""},
  294. },
  295. data: {
  296. key: {
  297. name: "F_Name"
  298. },
  299. simpleData: {
  300. enable: true,
  301. idKey: "F_Id",
  302. pIdKey: "F_Pid",
  303. rootPId: 0
  304. }
  305. },
  306. callback: {
  307. onCheck: zTreeOnClick
  308. }
  309. };
  310. function zTreeOnClick(event, treeId, treeNode) {
  311. var name = treeNode.name;
  312. // var c="";
  313. // for(var i=0;i<nodes.length;i++){
  314. // if(nodes[i].isParent!=true){
  315. // c+=nodes[i].id+",";
  316. // console.log(c);
  317. // }
  318. // }
  319. };
  320. function zTreeOnClick(e, treeId, treeNode) {
  321. var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
  322. nodes = zTree.getCheckedNodes(true);
  323. console.log(treeNode)
  324. var v = "",
  325. opid = '';
  326. for (var i = 0, l = nodes.length; i < l; i++) {
  327. v += nodes[i].F_Name + ",";
  328. console.log(v);
  329. opid += nodes[i].F_DeptId + ","
  330. }
  331. if (v.length > 0) v = v.substring(0, v.length - 1);
  332. var cityObj = $("#citySel");
  333. cityObj.val(v);
  334. $("#citySel").val(v);
  335. console.log(opid);
  336. if (opid.length > 0) opid = opid.substring(0, opid.length - 1);
  337. $('#OPID').attr("value", opid);
  338. $('#OPIDs').attr("value", opid);
  339. }
  340. $("#scwj").click(function () {
  341. $("#upFile").trigger("click");
  342. });
  343. $("#upFile").change(function () {
  344. upload('upFile',".fileBox",['png','jpg','mp3','mp4','pdf','doc','docx','xls','xlsx'],'#file');
  345. });
  346. // //上传文件
  347. // function upload() {
  348. // var Files = document.getElementById("upFile").files;
  349. // if (Files.length > 0) {
  350. // var formData = new FormData();
  351. // for (var i = 0; i < Files.length; i++) {
  352. // formData.append("file" + i, Files[i]);
  353. // }
  354. // formData.append("token", $.cookie("token"));
  355. // var typeName = Files[0].name.split(".")[Files[0].name.split(".").length-1];
  356. // if (
  357. // typeName == "png" ||
  358. // typeName == "jpg" ||
  359. // typeName == "mp4" ||
  360. // typeName == "mp3" ||
  361. // typeName == "pdf" ||
  362. // typeName == "doc" ||
  363. // typeName == "docx" ||
  364. // typeName == "xls" ||
  365. // typeName == "xlsx"
  366. // ) {
  367. // $.ajax({
  368. // url: huayi.config.callcenter_url +
  369. // "/WorkOrder/UploadFile",
  370. // type: "POST",
  371. // data: formData,
  372. // /**
  373. // *必须false才会自动加上正确的Content-Type
  374. // */
  375. // contentType: false,
  376. // /**
  377. // * 必须false才会避开jQuery对 formdata 的默认处理
  378. // * XMLHttpRequest会对 formdata 进行正确的处理
  379. // */
  380. // processData: false,
  381. // success: function (result) {
  382. // document.getElementById(
  383. // "upFile"
  384. // ).outerHTML = document.getElementById(
  385. // "upFile"
  386. // ).outerHTML;
  387. // $("#upFile").change(function () {
  388. // upload();
  389. // });
  390. // var r = $.parseJSON(result);
  391. // if (r.state.toLowerCase() == "success") {
  392. // $(".fjnr").text(r.data[0].F_FileName);
  393. // var a = r.data;
  394. // $(a).each(function (i, n) {
  395. // var strs =
  396. // '<span class="files" fiel-num="' +
  397. // n.F_FileId +
  398. // '">' +
  399. // n.F_FileName.substring(19) +
  400. // '<i class="fa fa-remove del_file"></i></span>';
  401. // $(strs)
  402. // .appendTo($(".fileBox"))
  403. // .find(".del_file")
  404. // .click(function (event) {
  405. // event.stopPropagation();
  406. // $(this).parent().remove();
  407. // file_num();
  408. // });
  409. // });
  410. // file_num();
  411. // }
  412. // },
  413. // });
  414. // } else {
  415. // layer.msg("格式不正确");
  416. // }
  417. // } else {
  418. // layer.confirm("请上传文件!", {
  419. // btn: ["确定"],
  420. // });
  421. // }
  422. // }
  423. // //上传文件隐藏域值
  424. // function file_num() {
  425. // var str = "";
  426. // var Str;
  427. // $(".fileBox .files").each(function (j, m) {
  428. // var aa = $(m).attr("fiel-num");
  429. // console.log(aa);
  430. // str += aa + ",";
  431. // Str =
  432. // str.substring(str.length - 1) == "," ?
  433. // str.substring(0, str.length - 1) :
  434. // str;
  435. // });
  436. // $("#file").val(Str);
  437. // }
  438. </script>
  439. </body>
  440. </html>