You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

524 lines
25 KiB

  1. /*
  2. * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  3. * Copyright (c) 2013-2017
  4. * 创建人:陈彬彬
  5. * 日 期:2017.06.04
  6. * 描 述:邮件管理
  7. */
  8. var refreshsendtableGirdData;
  9. var refreshdrafttableGirdData;
  10. var refreshreceivetableGirdData;
  11. var refreshdeletedtableGirdData;
  12. var sendthismessage;
  13. var bootstrap = function ($, learun) {
  14. "use strict";
  15. var datebegin = '';
  16. var dateend = '';
  17. var selectedRow = '';
  18. var currentPage = '2';
  19. var page = {
  20. init: function () {
  21. page.initleft();
  22. page.initGrid();
  23. page.bind();
  24. },
  25. bind: function () {
  26. $('.datetime').each(function () {
  27. $(this).lrdate({
  28. dfdata: [
  29. { name: '清空', begin: function () { return '' }, end: function () { return '' } },
  30. { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  31. { name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  32. { name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  33. { name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  34. ],
  35. // 月
  36. mShow: false,
  37. premShow: false,
  38. // 季度
  39. jShow: false,
  40. prejShow: false,
  41. // 年
  42. ysShow: false,
  43. yxShow: false,
  44. preyShow: false,
  45. yShow: false,
  46. // 默认
  47. dfvalue: '0',
  48. selectfn: function (begin, end) {
  49. datebegin = begin;
  50. dateend = end;
  51. page.search();
  52. }
  53. });
  54. });
  55. // 查询
  56. $('#btn_Search').on('click', function () {
  57. var keyword = $('#txt_Keyword').val();
  58. page.search({ keyword: keyword });
  59. });
  60. // 刷新
  61. $('#lr_refresh').on('click', function () {
  62. location.reload();
  63. });
  64. //编辑
  65. $('#lr_edit').on('click', function () {
  66. var keyValue = '';
  67. keyValue = $('#drafttable').jfGridValue('MESSAGEID');
  68. if (learun.checkrow(keyValue)) {
  69. top.layer.open({
  70. id: 'sendform',
  71. title: '发邮件',
  72. type: 2,
  73. skin: 'lr-layer',
  74. btn: ['发送', '保存草稿', '关闭'],
  75. content: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/Form?keyValue=' + keyValue,
  76. area: ['800px', '700px'],
  77. success: function (layero, index) {
  78. top['sendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  79. },
  80. yes: function (index, layero) {
  81. top['sendform'].acceptClick(sendthismessage);
  82. top['sendform'] = null;
  83. top.layer.close(index);
  84. }
  85. , btn2: function (index, layero) {
  86. top['sendform'].acceptClick(refreshsendtableGirdData);
  87. top['sendform'] = null;
  88. top.layer.close(index);
  89. }
  90. , btn3: function (index, layero) {
  91. top['sendform'] = null;
  92. top.layer.close(index);
  93. }
  94. });
  95. }
  96. });
  97. // 收邮件
  98. $('#lr_receive').on('click', function () {
  99. refreshreceivetableGirdData();
  100. });
  101. // 查看
  102. $('#lr_detail').on('click', function () {
  103. var keyValue = '';
  104. if (currentPage == '2') {
  105. keyValue = $('#receivetable').jfGridValue('MESSAGEID');
  106. if (learun.checkrow(keyValue)) {
  107. top.layer.open({
  108. id: 'viewform',
  109. title: '查看',
  110. type: 2,
  111. skin: 'lr-layer',
  112. btn: ['回复', '转发', '关闭'],
  113. content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormView?keyValue=' + keyValue,
  114. area: ['800px', '700px'],
  115. success: function (layero, index) {
  116. top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  117. //自动已读
  118. learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Read', { keyValue: keyValue }, function () {
  119. refreshreceivetableGirdData();
  120. });
  121. },
  122. yes: function (index, layero) {
  123. top.layer.open({
  124. id: 'resendform',
  125. title: '回复邮件',
  126. type: 2,
  127. skin: 'lr-layer',
  128. btn: ['发送', '保存草稿', '关闭'],
  129. content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Form?keyValue=' + keyValue,
  130. area: ['800px', '700px'],
  131. success: function (layero, index) {
  132. top['resendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  133. },
  134. yes: function (index, layero) {
  135. top['resendform'].acceptClick(sendthismessage);
  136. top['resendform'] = null;
  137. top.layer.close(index);
  138. }
  139. , btn2: function (index, layero) {
  140. top['resendform'].acceptClick(refreshsendtableGirdData);
  141. top['resendform'] = null;
  142. top.layer.close(index);
  143. }
  144. , btn3: function (index, layero) {
  145. top['resendform'] = null;
  146. top.layer.close(index);
  147. }
  148. });
  149. top['viewform'] = null;
  150. top.layer.close(index);
  151. },
  152. btn2: function (index, layero) {
  153. top.layer.open({
  154. id: 'chsendform',
  155. title: '转发邮件',
  156. type: 2,
  157. skin: 'lr-layer',
  158. btn: ['发送', '保存草稿', '关闭'],
  159. content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormCh?keyValue=' + keyValue,
  160. area: ['800px', '700px'],
  161. success: function (layero, index) {
  162. top['chsendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  163. },
  164. yes: function (index, layero) {
  165. top['chsendform'].acceptClick(sendthismessage);
  166. top['chsendform'] = null;
  167. top.layer.close(index);
  168. }
  169. , btn2: function (index, layero) {
  170. top['chsendform'].acceptClick(refreshsendtableGirdData);
  171. top['chsendform'] = null;
  172. top.layer.close(index);
  173. }
  174. , btn3: function (index, layero) {
  175. top['chsendform'] = null;
  176. top.layer.close(index);
  177. }
  178. });
  179. top['viewform'] = null;
  180. top.layer.close(index);
  181. },
  182. btn3: function (index, layero) {
  183. top['viewform'] = null;
  184. top.layer.close(index);
  185. }
  186. });
  187. }
  188. }
  189. else if (currentPage == '3') {
  190. keyValue = $('#sendtable').jfGridValue('MESSAGEID');
  191. if (learun.checkrow(keyValue)) {
  192. top.layer.open({
  193. id: 'viewform',
  194. title: '查看',
  195. type: 2,
  196. skin: 'lr-layer-nobtn',
  197. btn: null,
  198. content: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/FormView?keyValue=' + keyValue,
  199. area: ['800px', '700px'],
  200. success: function (layero, index) {
  201. top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  202. },
  203. end: function () {
  204. top['viewform'] = null;
  205. }
  206. });
  207. }
  208. } else {
  209. keyValue = $('#deletedtable').jfGridValue('MESSAGEID');
  210. if (learun.checkrow(keyValue)) {
  211. top.layer.open({
  212. id: 'viewform',
  213. title: '查看',
  214. type: 2,
  215. skin: 'lr-layer-nobtn',
  216. btn: null,
  217. content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormView?keyValue=' + keyValue,
  218. area: ['800px', '700px'],
  219. success: function (layero, index) {
  220. top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  221. //自动已读
  222. learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Read', { keyValue: keyValue }, function () {
  223. refreshdeletedtableGirdData();
  224. });
  225. },
  226. end: function () {
  227. top['viewform'] = null;
  228. }
  229. });
  230. }
  231. }
  232. });
  233. // 删除
  234. $('#lr_delete').on('click', function () {
  235. var keyValue = '';
  236. if (currentPage == '2') {
  237. keyValue = $('#receivetable').jfGridValue('MESSAGEID');
  238. }
  239. else if (currentPage == '3') {
  240. keyValue = $('#sendtable').jfGridValue('MESSAGEID');
  241. }
  242. else if (currentPage == '4') {
  243. keyValue = $('#drafttable').jfGridValue('MESSAGEID');
  244. } else {
  245. keyValue = $('#deletedtable').jfGridValue('MESSAGEID');
  246. }
  247. if (learun.checkrow(keyValue)) {
  248. learun.layerConfirm('是否确认删除该项!', function (res) {
  249. if (res) {
  250. if (currentPage == '2') {
  251. learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/VDeleteForm', { keyValue: keyValue }, function () {
  252. refreshreceivetableGirdData();
  253. refreshdeletedtableGirdData();
  254. });
  255. } else if (currentPage == '5') {
  256. learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/DeleteForm', { keyValue: keyValue }, function () {
  257. refreshdeletedtableGirdData();
  258. });
  259. } else if (currentPage == '3') {
  260. learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/DeleteForm', { keyValue: keyValue }, function () {
  261. refreshsendtableGirdData();
  262. });
  263. }
  264. else {
  265. learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/DeleteForm', { keyValue: keyValue }, function () {
  266. refreshdrafttableGirdData();
  267. });
  268. }
  269. }
  270. });
  271. }
  272. });
  273. // 清空已删除
  274. $('#lr_clear').on('click', function () {
  275. learun.layerConfirm('是否确认清空!', function (res) {
  276. if (res) {
  277. learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/AllDeleteForm', { userId: userId }, function () {
  278. refreshdeletedtableGirdData();
  279. });
  280. }
  281. });
  282. });
  283. },
  284. initleft: function () {
  285. $("#lr_edit").hide();
  286. $("#lr_clear").hide();
  287. $('#sendtable').css('display', "none");
  288. $('#drafttable').css('display', "none");
  289. $('#deletedtable').css('display', "none");
  290. $('#lr_left_list li').on('click', function () {
  291. var $this = $(this);
  292. var $parent = $this.parent();
  293. $parent.find('.active').removeClass('active');
  294. $this.addClass('active');
  295. var data_value = $this[0].dataset.value;
  296. switch (data_value) {
  297. case "1"://写邮件
  298. $("#lr_edit").hide();
  299. $("#lr_receive").hide();
  300. $("#lr_clear").hide();
  301. $("#lr_detail").hide();
  302. $("#lr_delete").hide();
  303. top.layer.open({
  304. id: 'sendform',
  305. title: '发邮件',
  306. type: 2,
  307. skin: 'lr-layer',
  308. btn: ['发送', '保存草稿', '关闭'],
  309. content: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/Form',
  310. area: ['800px', '700px'],
  311. success: function (layero, index) {
  312. top['sendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  313. },
  314. yes: function (index, layero) {
  315. var flag = true;
  316. flag = top['sendform'].acceptClick(sendthismessage);
  317. if (!!flag) {
  318. learun.layerClose('', index);
  319. }
  320. }
  321. , btn2: function (index, layero) {
  322. var flag = true;
  323. flag = top['sendform'].acceptClick(refreshdrafttableGirdData);
  324. if (!!flag) {
  325. learun.layerClose('', index);
  326. }
  327. return false;
  328. }
  329. , btn3: function (index, layero) {
  330. top['sendform'] = null;
  331. top.layer.close(index);
  332. }
  333. });
  334. currentPage = '1';
  335. break;
  336. case "2"://收件箱
  337. $("#lr_edit").hide();
  338. $("#lr_clear").hide();
  339. $('#lr_receive').show();
  340. $("#lr_detail").show();
  341. $("#lr_delete").show();
  342. $('#sendtable').css('display', "none");
  343. $('#drafttable').css('display', "none");
  344. $('#deletedtable').css('display', "none");
  345. $('#receivetable').css('display', "");
  346. currentPage = '2';
  347. break;
  348. case "3"://已发送
  349. $("#lr_edit").hide();
  350. $("#lr_receive").hide();
  351. $("#lr_clear").hide();
  352. $('#lr_detail').show();
  353. $("#lr_delete").show();
  354. $('#receivetable').css('display', "none");
  355. $('#drafttable').css('display', "none");
  356. $('#deletedtable').css('display', "none");
  357. $('#sendtable').css('display', "");
  358. currentPage = '3';
  359. break;
  360. case "4"://草稿箱
  361. $("#lr_receive").hide();
  362. $("#lr_clear").hide();
  363. $('#lr_detail').hide();
  364. $("#lr_edit").show();
  365. $("#lr_delete").show();
  366. $('#receivetable').css('display', "none");
  367. $('#drafttable').css('display', "");
  368. $('#deletedtable').css('display', "none");
  369. $('#sendtable').css('display', "none");
  370. currentPage = '4';
  371. break;
  372. case "5"://已删除
  373. $("#lr_edit").hide();
  374. $("#lr_receive").hide();
  375. $("#lr_clear").show();
  376. $('#lr_detail').show();
  377. $("#lr_delete").show();
  378. $('#receivetable').css('display', "none");
  379. $('#drafttable').css('display', "none");
  380. $('#deletedtable').css('display', "");
  381. $('#sendtable').css('display', "none");
  382. currentPage = '5';
  383. break;
  384. default: break;
  385. }
  386. page.search();
  387. });
  388. },
  389. initGrid: function () {
  390. $('#sendtable').jfGrid({
  391. url: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/GetPageList',
  392. headData: [
  393. { label: "收件人", name: "RECEIVER", width: 200, align: "left" },
  394. { label: "抄送", name: "RECEIVERToo", width: 200, align: "left" },
  395. { label: "密送", name: "RECEIVERS", width: 200, align: "left" },
  396. { label: "主题", name: "TITLE", width: 400, align: "left" },
  397. {
  398. label: "发件时间", name: "SENDTIME", width: 150, align: "left",
  399. formatter: function (cellvalue) {
  400. return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss');
  401. }
  402. }
  403. ],
  404. mainId: 'MESSAGEID',
  405. isPage: true,
  406. sidx: 'SENDTIME',
  407. sord: 'DESC'
  408. });
  409. $('#receivetable').jfGrid({
  410. url: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/GetPageList',
  411. headData: [
  412. { label: "发件人", name: "SENDER", width: 200, align: "left" },
  413. { label: "主题", name: "TITLE", width: 400, align: "left" },
  414. {
  415. label: "状态", name: "READFLAG", width: 100, align: "left",
  416. formatter: function (cellvalue) {
  417. return cellvalue === 0 ? "<span class=\"label label-danger\">未读</span>" : "<span class=\"label label-success\">已读</span>";
  418. }
  419. },
  420. {
  421. label: "收件时间", name: "SENDTIME", width: 150, align: "left",
  422. formatter: function (cellvalue) {
  423. return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss');
  424. }
  425. }
  426. ],
  427. mainId: 'MESSAGEID',
  428. isPage: true,
  429. sidx: 'SENDTIME',
  430. sord: 'DESC'
  431. });
  432. $('#drafttable').jfGrid({
  433. url: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/GetPageList',
  434. headData: [
  435. { label: "收件人", name: "RECEIVER", width: 200, align: "left" },
  436. { label: "抄送", name: "RECEIVERToo", width: 200, align: "left" },
  437. { label: "密送", name: "RECEIVERS", width: 200, align: "left" },
  438. { label: "主题", name: "TITLE", width: 400, align: "left" },
  439. {
  440. label: "发件时间", name: "SENDTIME", width: 150, align: "left",
  441. formatter: function (cellvalue) {
  442. return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss');
  443. }
  444. }
  445. ],
  446. mainId: 'MESSAGEID',
  447. isPage: true,
  448. sidx: 'SENDTIME',
  449. sord: 'DESC'
  450. });
  451. $('#deletedtable').jfGrid({
  452. url: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/GetPageList',
  453. headData: [
  454. { label: "发件人", name: "SENDER", width: 200, align: "left" },
  455. { label: "主题", name: "TITLE", width: 400, align: "left" },
  456. {
  457. label: "状态", name: "READFLAG", width: 100, align: "left",
  458. formatter: function (cellvalue) {
  459. return cellvalue === 0 ? "<span class=\"label label-danger\">未读</span>" : "<span class=\"label label-success\">已读</span>";
  460. }
  461. },
  462. {
  463. label: "收件时间", name: "SENDTIME", width: 150, align: "left",
  464. formatter: function (cellvalue) {
  465. return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss');
  466. }
  467. }
  468. ],
  469. mainId: 'MESSAGEID',
  470. isPage: true,
  471. sidx: 'SENDTIME',
  472. sord: 'DESC'
  473. });
  474. page.search();
  475. },
  476. search: function (param) {
  477. param = param || {};
  478. param.userId = userId;
  479. param.StartTime = datebegin;
  480. param.EndTime = dateend;
  481. if (currentPage == '2') {
  482. param.DelFlag = 0;
  483. $('#receivetable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  484. } else if (currentPage == '3') {
  485. param.SendFLAG = 1;
  486. $('#sendtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  487. } else if (currentPage == '4') {
  488. param.SendFLAG = 0;
  489. $('#drafttable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  490. } else {
  491. param.DelFlag = 1;
  492. $('#deletedtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  493. }
  494. }
  495. };
  496. refreshsendtableGirdData = function () {
  497. page.search();
  498. };
  499. refreshreceivetableGirdData = function () {
  500. page.search();
  501. };
  502. refreshdrafttableGirdData = function () {
  503. page.search();
  504. };
  505. refreshdeletedtableGirdData = function () {
  506. page.search();
  507. };
  508. sendthismessage = function (id) {
  509. learun.loading(true, '发送中...');
  510. learun.postForm(top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/Send', { MESSAGEID: id }, function () {
  511. refreshsendtableGirdData();
  512. top.learun.layerClose(window.name);
  513. });
  514. };
  515. page.init();
  516. }