/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 * Copyright (c) 2013-2017 * 创建人:陈彬彬 * 日 期:2017.06.04 * 描 述:邮件管理 */ var refreshsendtableGirdData; var refreshdrafttableGirdData; var refreshreceivetableGirdData; var refreshdeletedtableGirdData; var sendthismessage; var bootstrap = function ($, learun) { "use strict"; var datebegin = ''; var dateend = ''; var selectedRow = ''; var currentPage = '2'; var page = { init: function () { page.initleft(); page.initGrid(); page.bind(); }, bind: function () { $('.datetime').each(function () { $(this).lrdate({ dfdata: [ { name: '清空', begin: function () { return '' }, end: function () { return '' } }, { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }, { 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') } }, { 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') } }, { 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') } }, ], // 月 mShow: false, premShow: false, // 季度 jShow: false, prejShow: false, // 年 ysShow: false, yxShow: false, preyShow: false, yShow: false, // 默认 dfvalue: '0', selectfn: function (begin, end) { datebegin = begin; dateend = end; page.search(); } }); }); // 查询 $('#btn_Search').on('click', function () { var keyword = $('#txt_Keyword').val(); page.search({ keyword: keyword }); }); // 刷新 $('#lr_refresh').on('click', function () { location.reload(); }); //编辑 $('#lr_edit').on('click', function () { var keyValue = ''; keyValue = $('#drafttable').jfGridValue('MESSAGEID'); if (learun.checkrow(keyValue)) { top.layer.open({ id: 'sendform', title: '发邮件', type: 2, skin: 'lr-layer', btn: ['发送', '保存草稿', '关闭'], content: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/Form?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['sendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); }, yes: function (index, layero) { top['sendform'].acceptClick(sendthismessage); top['sendform'] = null; top.layer.close(index); } , btn2: function (index, layero) { top['sendform'].acceptClick(refreshsendtableGirdData); top['sendform'] = null; top.layer.close(index); } , btn3: function (index, layero) { top['sendform'] = null; top.layer.close(index); } }); } }); // 收邮件 $('#lr_receive').on('click', function () { refreshreceivetableGirdData(); }); // 查看 $('#lr_detail').on('click', function () { var keyValue = ''; if (currentPage == '2') { keyValue = $('#receivetable').jfGridValue('MESSAGEID'); if (learun.checkrow(keyValue)) { top.layer.open({ id: 'viewform', title: '查看', type: 2, skin: 'lr-layer', btn: ['回复', '转发', '关闭'], content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormView?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); //自动已读 learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Read', { keyValue: keyValue }, function () { refreshreceivetableGirdData(); }); }, yes: function (index, layero) { top.layer.open({ id: 'resendform', title: '回复邮件', type: 2, skin: 'lr-layer', btn: ['发送', '保存草稿', '关闭'], content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Form?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['resendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); }, yes: function (index, layero) { top['resendform'].acceptClick(sendthismessage); top['resendform'] = null; top.layer.close(index); } , btn2: function (index, layero) { top['resendform'].acceptClick(refreshsendtableGirdData); top['resendform'] = null; top.layer.close(index); } , btn3: function (index, layero) { top['resendform'] = null; top.layer.close(index); } }); top['viewform'] = null; top.layer.close(index); }, btn2: function (index, layero) { top.layer.open({ id: 'chsendform', title: '转发邮件', type: 2, skin: 'lr-layer', btn: ['发送', '保存草稿', '关闭'], content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormCh?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['chsendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); }, yes: function (index, layero) { top['chsendform'].acceptClick(sendthismessage); top['chsendform'] = null; top.layer.close(index); } , btn2: function (index, layero) { top['chsendform'].acceptClick(refreshsendtableGirdData); top['chsendform'] = null; top.layer.close(index); } , btn3: function (index, layero) { top['chsendform'] = null; top.layer.close(index); } }); top['viewform'] = null; top.layer.close(index); }, btn3: function (index, layero) { top['viewform'] = null; top.layer.close(index); } }); } } else if (currentPage == '3') { keyValue = $('#sendtable').jfGridValue('MESSAGEID'); if (learun.checkrow(keyValue)) { top.layer.open({ id: 'viewform', title: '查看', type: 2, skin: 'lr-layer-nobtn', btn: null, content: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/FormView?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); }, end: function () { top['viewform'] = null; } }); } } else { keyValue = $('#deletedtable').jfGridValue('MESSAGEID'); if (learun.checkrow(keyValue)) { top.layer.open({ id: 'viewform', title: '查看', type: 2, skin: 'lr-layer-nobtn', btn: null, content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormView?keyValue=' + keyValue, area: ['800px', '700px'], success: function (layero, index) { top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); //自动已读 learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Read', { keyValue: keyValue }, function () { refreshdeletedtableGirdData(); }); }, end: function () { top['viewform'] = null; } }); } } }); // 删除 $('#lr_delete').on('click', function () { var keyValue = ''; if (currentPage == '2') { keyValue = $('#receivetable').jfGridValue('MESSAGEID'); } else if (currentPage == '3') { keyValue = $('#sendtable').jfGridValue('MESSAGEID'); } else if (currentPage == '4') { keyValue = $('#drafttable').jfGridValue('MESSAGEID'); } else { keyValue = $('#deletedtable').jfGridValue('MESSAGEID'); } if (learun.checkrow(keyValue)) { learun.layerConfirm('是否确认删除该项!', function (res) { if (res) { if (currentPage == '2') { learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/VDeleteForm', { keyValue: keyValue }, function () { refreshreceivetableGirdData(); refreshdeletedtableGirdData(); }); } else if (currentPage == '5') { learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/DeleteForm', { keyValue: keyValue }, function () { refreshdeletedtableGirdData(); }); } else if (currentPage == '3') { learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/DeleteForm', { keyValue: keyValue }, function () { refreshsendtableGirdData(); }); } else { learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/DeleteForm', { keyValue: keyValue }, function () { refreshdrafttableGirdData(); }); } } }); } }); // 清空已删除 $('#lr_clear').on('click', function () { learun.layerConfirm('是否确认清空!', function (res) { if (res) { learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/AllDeleteForm', { userId: userId }, function () { refreshdeletedtableGirdData(); }); } }); }); }, initleft: function () { $("#lr_edit").hide(); $("#lr_clear").hide(); $('#sendtable').css('display', "none"); $('#drafttable').css('display', "none"); $('#deletedtable').css('display', "none"); $('#lr_left_list li').on('click', function () { var $this = $(this); var $parent = $this.parent(); $parent.find('.active').removeClass('active'); $this.addClass('active'); var data_value = $this[0].dataset.value; switch (data_value) { case "1"://写邮件 $("#lr_edit").hide(); $("#lr_receive").hide(); $("#lr_clear").hide(); $("#lr_detail").hide(); $("#lr_delete").hide(); top.layer.open({ id: 'sendform', title: '发邮件', type: 2, skin: 'lr-layer', btn: ['发送', '保存草稿', '关闭'], content: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/Form', area: ['800px', '700px'], success: function (layero, index) { top['sendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames); }, yes: function (index, layero) { var flag = true; flag = top['sendform'].acceptClick(sendthismessage); if (!!flag) { learun.layerClose('', index); } } , btn2: function (index, layero) { var flag = true; flag = top['sendform'].acceptClick(refreshdrafttableGirdData); if (!!flag) { learun.layerClose('', index); } return false; } , btn3: function (index, layero) { top['sendform'] = null; top.layer.close(index); } }); currentPage = '1'; break; case "2"://收件箱 $("#lr_edit").hide(); $("#lr_clear").hide(); $('#lr_receive').show(); $("#lr_detail").show(); $("#lr_delete").show(); $('#sendtable').css('display', "none"); $('#drafttable').css('display', "none"); $('#deletedtable').css('display', "none"); $('#receivetable').css('display', ""); currentPage = '2'; break; case "3"://已发送 $("#lr_edit").hide(); $("#lr_receive").hide(); $("#lr_clear").hide(); $('#lr_detail').show(); $("#lr_delete").show(); $('#receivetable').css('display', "none"); $('#drafttable').css('display', "none"); $('#deletedtable').css('display', "none"); $('#sendtable').css('display', ""); currentPage = '3'; break; case "4"://草稿箱 $("#lr_receive").hide(); $("#lr_clear").hide(); $('#lr_detail').hide(); $("#lr_edit").show(); $("#lr_delete").show(); $('#receivetable').css('display', "none"); $('#drafttable').css('display', ""); $('#deletedtable').css('display', "none"); $('#sendtable').css('display', "none"); currentPage = '4'; break; case "5"://已删除 $("#lr_edit").hide(); $("#lr_receive").hide(); $("#lr_clear").show(); $('#lr_detail').show(); $("#lr_delete").show(); $('#receivetable').css('display', "none"); $('#drafttable').css('display', "none"); $('#deletedtable').css('display', ""); $('#sendtable').css('display', "none"); currentPage = '5'; break; default: break; } page.search(); }); }, initGrid: function () { $('#sendtable').jfGrid({ url: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/GetPageList', headData: [ { label: "收件人", name: "RECEIVER", width: 200, align: "left" }, { label: "抄送", name: "RECEIVERToo", width: 200, align: "left" }, { label: "密送", name: "RECEIVERS", width: 200, align: "left" }, { label: "主题", name: "TITLE", width: 400, align: "left" }, { label: "发件时间", name: "SENDTIME", width: 150, align: "left", formatter: function (cellvalue) { return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss'); } } ], mainId: 'MESSAGEID', isPage: true, sidx: 'SENDTIME', sord: 'DESC' }); $('#receivetable').jfGrid({ url: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/GetPageList', headData: [ { label: "发件人", name: "SENDER", width: 200, align: "left" }, { label: "主题", name: "TITLE", width: 400, align: "left" }, { label: "状态", name: "READFLAG", width: 100, align: "left", formatter: function (cellvalue) { return cellvalue === 0 ? "未读" : "已读"; } }, { label: "收件时间", name: "SENDTIME", width: 150, align: "left", formatter: function (cellvalue) { return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss'); } } ], mainId: 'MESSAGEID', isPage: true, sidx: 'SENDTIME', sord: 'DESC' }); $('#drafttable').jfGrid({ url: top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/GetPageList', headData: [ { label: "收件人", name: "RECEIVER", width: 200, align: "left" }, { label: "抄送", name: "RECEIVERToo", width: 200, align: "left" }, { label: "密送", name: "RECEIVERS", width: 200, align: "left" }, { label: "主题", name: "TITLE", width: 400, align: "left" }, { label: "发件时间", name: "SENDTIME", width: 150, align: "left", formatter: function (cellvalue) { return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss'); } } ], mainId: 'MESSAGEID', isPage: true, sidx: 'SENDTIME', sord: 'DESC' }); $('#deletedtable').jfGrid({ url: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/GetPageList', headData: [ { label: "发件人", name: "SENDER", width: 200, align: "left" }, { label: "主题", name: "TITLE", width: 400, align: "left" }, { label: "状态", name: "READFLAG", width: 100, align: "left", formatter: function (cellvalue) { return cellvalue === 0 ? "未读" : "已读"; } }, { label: "收件时间", name: "SENDTIME", width: 150, align: "left", formatter: function (cellvalue) { return learun.formatDate(cellvalue, 'yyyy-MM-dd hh:mm:ss'); } } ], mainId: 'MESSAGEID', isPage: true, sidx: 'SENDTIME', sord: 'DESC' }); page.search(); }, search: function (param) { param = param || {}; param.userId = userId; param.StartTime = datebegin; param.EndTime = dateend; if (currentPage == '2') { param.DelFlag = 0; $('#receivetable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } else if (currentPage == '3') { param.SendFLAG = 1; $('#sendtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } else if (currentPage == '4') { param.SendFLAG = 0; $('#drafttable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } else { param.DelFlag = 1; $('#deletedtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } } }; refreshsendtableGirdData = function () { page.search(); }; refreshreceivetableGirdData = function () { page.search(); }; refreshdrafttableGirdData = function () { page.search(); }; refreshdeletedtableGirdData = function () { page.search(); }; sendthismessage = function (id) { learun.loading(true, '发送中...'); learun.postForm(top.$.rootUrl + '/EducationalAdministration/SYS_SendMessage/Send', { MESSAGEID: id }, function () { refreshsendtableGirdData(); top.learun.layerClose(window.name); }); }; page.init(); }