/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:超级管理员 * 日 期:2019-04-11 10:31 * 描 述:公文发送 */ var refreshGirdData; var bootstrap = function ($, learun) { "use strict"; var processId = ''; var page = { init: function () { page.initGird(); page.bind(); }, bind: function () { $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { page.search(queryJson); }, 220, 400); // 刷新 $('#lr_refresh').on('click', function () { location.reload(); }); // 新增 $('#lr_add').on('click', function () { learun.layerForm({ id: 'form', title: '新增', url: top.$.rootUrl + '/EducationalAdministration/Sys_SendFile/Form', width: 800, height: 700, callBack: function (id) { var res = false; // 验证数据 res = top[id].validForm(); // 保存数据 if (res) { res = top[id].save('', function () { page.search(); }); } return res; } }); }); // 编辑 $('#lr_edit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('SFileId'); if (learun.checkrow(keyValue)) { var SendFlag = $('#gridtable').jfGridValue('SendFlag'); if (SendFlag !== 0) { learun.alert.warning("当前项目已提交不能编辑!"); return; } learun.layerForm({ id: 'form', title: '编辑', url: top.$.rootUrl + '/EducationalAdministration/Sys_SendFile/Form?keyValue=' + keyValue, width: 800, height: 700, callBack: function (id) { var res = false; // 验证数据 res = top[id].validForm(); // 保存数据 if (res) { res = top[id].save('', function () { page.search(); }); } return res; } }); } }); // 查看 $('#lr_view').on('click', function () { var keyValue = $('#gridtable').jfGridValue('SFileId'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'form', title: '查看', url: top.$.rootUrl + '/EducationalAdministration/Sys_SendFile/FormView?keyValue=' + keyValue, width: 800, height: 700, btn: null }); } }); // 查阅情况 $('#lr_read').on('click', function () { var keyValue = $('#gridtable').jfGridValue('SFileId'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'form', title: '查阅情况', url: top.$.rootUrl + '/EducationalAdministration/Sys_SendFile/ReadList?keyValue=' + keyValue, width: 850, height: 400, btn: null }); } }); // 删除 $('#lr_delete').on('click', function () { var keyValue = $('#gridtable').jfGridValue('SFileId'); if (learun.checkrow(keyValue)) { var SendFlag = $('#gridtable').jfGridValue('SendFlag'); if (SendFlag !== 0) { learun.alert.warning("当前项目已提交不能删除!"); return; } learun.layerConfirm('是否确认删除该项!', function (res) { if (res) { learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/Sys_SendFile/DeleteForm', { keyValue: keyValue }, function () { refreshGirdData(); }); } }); } }); //  提交 $('#lr_submit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('SFileId'); if (learun.checkrow(keyValue)) { var SendFlag = $('#gridtable').jfGridValue('SendFlag'); if (SendFlag !== 0) { learun.alert.warning("当前项目已提交,请耐心等待审批!"); return; } top.layer.confirm('请选择模板?', { btn: ['同师', '幼师'] }, function () { learun.layerConfirm('是否确认提交该项!(同师)', function (res) { if (res) { processId = learun.newGuid(); learun.postForm(top.$.rootUrl + '/EducationalAdministration/Sys_SendFile/ChangeStatusById', { keyValue: keyValue, processId: processId }, function (res) { res.type = 1; refreshGirdData(res, {}); }); } }); }, function () { learun.layerConfirm('是否确认提交该项!(幼师)', function (res) { if (res) { processId = learun.newGuid(); learun.postForm(top.$.rootUrl + '/EducationalAdministration/Sys_SendFile/ChangeStatusById', { keyValue: keyValue, processId: processId }, function (res) { res.type = 2; refreshGirdData(res, {}); }); } }); }); } }); }, // 初始化列表 initGird: function () { $('#gridtable').lrAuthorizeJfGrid({ url: top.$.rootUrl + '/EducationalAdministration/Sys_SendFile/GetPageList', headData: [ { label: "主题", name: "Title", width: 300, align: "left" }, { label: "接收对象", name: "SendType", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'FileSendType', callback: function (_data) { callback(_data.text); } }); } }, { label: "接收人", name: "Receiver", width: 300, align: "left" }, { label: "下发人", name: "Sender", width: 100, align: "left" }, { label: "下发时间", name: "SendTime", width: 150, align: "left" }, { label: "状态", name: "SendFlag", width: 100, align: "left", formatter: function (cellvalue, row) { if (cellvalue === 1) { return '审批中'; } else if (cellvalue === 2) { return '已下发'; } else { return '草稿'; } } }, ], mainId: 'SFileId', isPage: true }); page.search(); }, search: function (param) { param = param || {}; $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } }; refreshGirdData = function (res, postData) { if (res && res.code && res.code == 200) { // 发起流程 learun.workflowapi.create({ isNew: true, schemeCode: res.type === 1 ? 'Sys_SendFile' :'Sys_SendFileYS',// 填写流程对应模板编号 processId: processId, processName: '公文下发审批',// 对应流程名称 processLevel: '1', description: '', formData: JSON.stringify(postData), callback: function (res, data) { } }); } page.search(); }; page.init(); }