Bez popisu

Add.html 16KB

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