/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) * Copyright (c) 2013-2018 北京泉江科技有限公司 * 创建人:超级管理员 * 日 期:2019-03-29 11:49 * 描 述:出库申请 */ var refreshGirdData; 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: '3', selectfn: function (begin, end) { startTime = begin; endTime = end; page.search(); } }); $('#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: 'formAss_AssetsOutApply', title: '新增', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/Form', width: 1000, height: 700, 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('AOId'); if (learun.checkrow(keyValue)) { var AAStatus = $('#gridtable').jfGridValue('AOStatus'); if (AAStatus !== 0) { learun.alert.warning("当前项目已提交不能编辑!"); return; } learun.layerForm({ id: 'formAss_AssetsOutApply', title: '编辑', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/Form?keyValue=' + keyValue, width: 1000, 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('AOId'); if (learun.checkrow(keyValue)) { learun.layerForm({ id: 'formAss_AssetsInfoApply', title: '查看调拨申请', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/FormView?keyValue=' + keyValue, width: 1000, height: 600, btn: null }); } }); // 删除 $('#lr_delete').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AOId'); if (learun.checkrow(keyValue)) { var AAStatus = $('#gridtable').jfGridValue('AOStatus'); if (AAStatus !== 0) { learun.alert.warning("当前项目已提交不能删除!"); return; } learun.layerConfirm('是否确认删除该项!', function (res) { if (res) { learun.deleteForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/DeleteForm', { keyValue: keyValue }, function () { refreshGirdData(); }); } }); } }); //  提交 $('#lr_submit').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AOId'); if (learun.checkrow(keyValue)) { var AAStatus = $('#gridtable').jfGridValue('AOStatus'); if (AAStatus !== 0) { learun.alert.warning("当前项目已提交,请耐心等待审批!"); return; } learun.layerConfirm('是否确认提交该项!', function (res) { if (res) { processId = learun.newGuid(); learun.postForm(top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/ChangeStatusById', { keyValue: keyValue, processId: processId }, function (res) { refreshGirdData(res, {}); }); } }); } }); //缺货单 $('#lr_incom').on('click', function () { var keyValue = $('#gridtable').jfGridValue('AOId'); if (learun.checkrow(keyValue)) { var AOAIId = $('#gridtable').jfGridValue('AOAIId'); if (AOAIId == null || AOAIId === undefined || AOAIId === "") { learun.alert.warning("当前项目不含缺货单!"); return; } learun.layerForm({ id: 'formAss_AssetsOutApplyIncomplete', title: '查看缺货单', url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApplyIncomplete/Form?keyValue=' + keyValue, width: 1000, height: 700, btn: ["调拨", "关闭"], callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); } }); }, // 初始化列表 initGird: function () { $('#gridtable').lrAuthorizeJfGrid({ url: top.$.rootUrl + '/AssetManagementSystem/Ass_AssetsOutApply/GetPageList', headData: [ { label: "调拨单流水号", name: "AOCode", width: 200, align: "left" }, { label: "调拨总价", name: "AOPrice", width: 100, align: "left" }, //{ // label: "出库原因", name: "AOReasonType", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { // learun.clientdata.getAsync('dataItem', { // key: value, // code: 'ReasonType', // callback: function (_data) { // callback(_data.text); // } // }); // } //}, { label: "项目名称", name: "AOProjectName", width: 150, align: "left" }, { label: "申请时间", name: "AOCreateTime", width: 150, align: "left" }, { label: "申请人", name: "AOCreateUserId", 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: "AOStatus", width: 100, align: "left", formatter: function (cellvalue, row) { if (cellvalue === 1) { return '审批中'; } else if (cellvalue === 2) { return '审批通过'; } else { return '草稿'; } } }, { label: "调拨状态", name: "AOOutStatus", width: 100, align: "left", formatter: function (cellvalue, row) { if (cellvalue === 0) { return '待调拨'; } else if (cellvalue === 2) { return '调拨完成'; } else { return '部分调拨'; } } } ], mainId: 'AOId', isPage: true, sidx: 'AOCreateTime', sord: 'DASC' }); }, search: function (param) { param = param || {}; param.StartTime = startTime; param.EndTime = endTime; $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); } }; refreshGirdData = function (res, postData) { if (res && res.code && res.code == 200) { // 发起流程 var postData = { schemeCode: 'Ass_AssetsOutApply',// 填写流程对应模板编号 processId: processId, level: '1', }; learun.httpAsync('Post', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/CreateFlow', postData, function (data) { learun.loading(false); }); } page.search(); }; page.init(); }