/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:超级管理员 * 日 期:2019-03-25 17:19 * 描 述:采购申请表 */ var refreshGirdData; var selectedRow; var bootstrap = function ($, learun) { "use strict"; var startTime; var endTime; var processId = ''; var page = { init: function () { page.initGird(); page.bind(); }, bind: function () { // 时间搜索框 $('#datesearch').lrdate({ dfdata: [ { 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: '2', selectfn: function (begin, end) { startTime = begin; endTime = end; page.search(); } }); $('#multiple_condition_query').lrMultipleQuery(function (queryJson) { page.search(queryJson); }, 220, 400); $('#PACreateUserId').lrUserSelect(0); $('#PACreateDeptId').lrselect({ type: 'tree', // 展开最大高度 maxHeight: 200, // 是否允许搜索 allowSearch: true, // 访问数据接口地址 url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree' }); // 刷新 $('#lr_refresh').on('click', function () { location.reload(); }); // 新增 $('#lr_add').on('click', function () { learun.layerForm({ id: 'formAss_PurchaseApply', title: '新增', url: top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/Form', width: 1000, height: 600, callBack: function (id) { var res = false; // 验证数据 res = top[id].validForm(); // 保存数据 if (res) { //processId = learun.newGuid(); //res = top[id].save(processId, refreshGirdData); res = top[id].save('', function () { page.search(); }); } return res; } }); }); // 编辑 $('#lr_edit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('PAId'); selectedRow = $('#gridtable').jfGridGet('rowdata'); if (learun.checkrow(keyValue)) { if (selectedRow.PAStatus == 1) {//提交 learun.alert.warning("当前采购申请记录已提交,请等待审批!"); return false; } else if (selectedRow.PAStatus == 2) {//审批通过 learun.alert.warning("当前采购申请记录已通过审批,无法编辑!"); return false; } learun.layerForm({ id: 'formAss_PurchaseApply', title: '编辑', url: top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/Form?keyValue=' + keyValue, width: 1000, height: 600, callBack: function (id) { var res = false; // 验证数据 res = top[id].validForm(); // 保存数据 if (res) { res = top[id].save('', function () { page.search(); }); } return res; } }); } }); // 删除 $('#lr_delete').on('click', function () { var keyValue = $('#gridtable').jfGridValue('PAId'); selectedRow = $('#gridtable').jfGridGet('rowdata'); if (learun.checkrow(keyValue)) { if (selectedRow.PAStatus !== 0) { learun.alert.warning("当前采购申请记录已提交,无法删除!"); return false; } learun.layerConfirm('是否确认删除该项!', function (res) { if (res) { learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/DeleteForm', { keyValue: keyValue }, function () { //refreshGirdData(); page.search(); }); } }); } }); // 提交 $('#lr_submit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('PAId'); selectedRow = $('#gridtable').jfGridGet('rowdata'); if (learun.checkrow(keyValue)) { if (selectedRow.PAStatus !== 0) { learun.alert.warning("当前采购申请记录已提交!"); return false; } learun.layerConfirm('是否确认提交该项!', function (res) { if (res) { processId = learun.newGuid(); learun.postForm(top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/ModifyPAStatus', { keyValue: keyValue, pastatus: 1, processId: processId }, function (res) { selectedRow.PAProcessId = processId; refreshGirdData(res, selectedRow); }); } }); } }); // 查看 $('#lr_view').on('click', function () { var keyValue = $('#gridtable').jfGridValue('PAId'); selectedRow = $('#gridtable').jfGridGet('rowdata'); if (learun.checkrow(keyValue)) { if (selectedRow.PAStatus == 0) { learun.alert.warning("当前采购申请记录未提交,请提交后再查看!"); return false; } learun.layerForm({ id: 'formviewAss_PurchaseApply', title: '查看', url: top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/FormView?keyValue=' + keyValue, width: 1000, height: 600, btn: null }); } }); $('#lr_print').on('click', function () { var processId = $('#gridtable').jfGridValue('PAProcessId'); learun.httpSync( 'get', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/GetFirstTaskByProcessId', { processId: processId }, function (data) { var taskId = data.taskId; learun.frameTab.open({ F_ModuleId: processId + taskId, F_Icon: 'fa magic', F_FullName: '查看流程进度', F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/NWFContainerForm?tabIframeId=' + processId + taskId + '&type=look' + "&processId=" + processId + "&taskId=" + taskId }); }) }); }, // 初始化列表 initGird: function () { $('#gridtable').lrAuthorizeJfGrid({ url: top.$.rootUrl + '/AssetManagementSystem/Ass_PurchaseApply/GetPageList', headData: [ { label: "采购申请单号", name: "PACode", width: 200, align: "left" }, { label: "申请人", name: "PACreateUserId", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('user', { key: value, callback: function (_data) { callback(_data.name); } }); } }, { label: "联系方式", name: "PACreateUserPhone", width: 100, align: "left" }, { label: "申请部门", name: "PACreateDeptId", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'classdata', key: value, keyId: 'id', callback: function (_data) { callback(_data['name']); } }); } }, { label: "资产属性", name: "PAssType", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('dataItem', { key: value, code: 'AssType', callback: function (_data) { callback(_data.text); } }); } }, { label: "所需总金额", name: "PAPrice", width: 100, align: "left" }, { label: "期望采购时间", name: "PAName", width: 130, align: "left" }, { label: "申请时间", name: "PACreateTime", width: 130, align: "left" }, { label: "审批状态", name: "PAStatus", width: 100, align: "left", formatter: function (cellvalue, row) { if (cellvalue == 1) { return '审批中'; } else if (cellvalue == 2) { return '审批通过'; } else { return '草稿'; } } }, { label: "审核意见", name: "POpinion", width: 130, align: "left" }, { label: "采购状态", name: "PStatus", width: 100, align: "left", formatter: function (cellvalue, row) { if (cellvalue == 1) { return '采购中'; } else if (cellvalue == 2) { return '已采购'; } else { return '未采购'; } } }, { label: "是否入库", name: "PIsInStorage", width: 130, align: "left" }, ], mainId: 'PAId', isPage: true, sidx: 'PACreateTime', sord: 'DESC' }); }, search: function (param) { param = param || {}; param.StartTime = startTime; param.EndTime = endTime; //param.PACreateUserId = learun.clientdata.get(['userinfo']).userId; $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } }; refreshGirdData = function (res, postData) { if (res.code == 200) { // 发起流程 //learun.workflowapi.create({ // isNew: true, // schemeCode: 'Ass_PurchaseApply',// 填写流程对应模板编号 // processId: processId, // processName: '采购申请',// 对应流程名称 // processLevel: '1', // description: '', // formData: JSON.stringify(postData), // callback: function (res, data) { // } //}); var postData = { schemeCode: 'Ass_PurchaseApply',// 填写流程对应模板编号 processId: processId, level: '1', }; learun.httpAsync('Post', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/CreateFlow', postData, function (data) { learun.loading(false); }); page.search(); } }; page.init(); }