/* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn) * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 * 创建人:超级管理员 * 日 期:2022-03-02 10:37 * 描 述:教材库存表 */ var acceptClick; var keyValue = request('keyValue'); // 设置权限 var setAuthorize; // 设置表单数据 var setFormData; // 验证数据是否填写完整 var validForm; // 保存数据 var save; var selectedRow; var refreshGirdData; var tempdatra = new Array(); var bootstrap = function ($, learun) { "use strict"; // 设置权限 setAuthorize = function (data) { }; var page = { init: function () { $('.lr-form-wrap').lrscroll(); $("#detailadd").on('click', function () { selectedRow = null; learun.layerForm({ id: 'formTextBookIn', title: '申请出库', url: top.$.rootUrl + '/EducationalAdministration/TextBookOut/FormOut', width: 800, height: 500, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); }); $("#detaildel").on('click', function () { var keyValue = $('#TextBookOut').jfGridValue('ID'); if (learun.checkrow(keyValue)) { learun.layerConfirm('是否确认删除该项!', function (res, index) { if (res) { $.each(tempdatra, function (key, val) { if (tempdatra[key].ID === keyValue) { tempdatra.splice(key, 1); } }); $('#TextBookOut').jfGridSet('refreshdata', tempdatra); learun.layerClose(window.name); top.layer.close(index); } }); } }); page.bind(); page.initData(); }, bind: function () { $('#LessonNo').lrDataSourceSelect({ code: 'LessonInfo', value: 'lessonno', text: 'lessonname' }); $('#TextBookOut').jfGrid({ headData: [ { label: '出库单', name: 'BookCode', width: 180, align: 'left' }, { label: "专业部", name: "DeptNo", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdDeptInfo', key: value, keyId: 'deptno', callback: function (_data) { callback(_data['deptname']); } }); } }, { label: "专业", name: "MajorNo", width: 120, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'CdMajorInfo', key: value, keyId: 'majorno', callback: function (_data) { callback(_data['majorname']); } }); } }, { label: "课程", name: "LessonNo", width: 150, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'LessonInfo', key: value, keyId: 'lessonno', callback: function (_data) { callback(_data['lessonname']); } }); } }, { label: "班级", name: "ClassNo", width: 100, align: "left", formatterAsync: function (callback, value, row, op, $cell) { learun.clientdata.getAsync('custmerData', { url: '/LR_SystemModule/DataSource/GetDataTable?code=' + 'bjsj', key: value, keyId: 'classno', callback: function (_data) { callback(_data['classname']); } }); } }, { label: '学年', name: 'AcademicYearNo', width: 80, align: 'left' }, { label: '学期', name: 'Semester', width: 80, align: 'left' }, { label: '领用人', name: 'Recipient', width: 100, align: 'left' }, { label: '出库数量', name: 'Variate', width: 100, align: 'left' }, { label: '出库时间', name: 'CreateTime', width: 200, align: 'left' }, { label: '出库用户', name: 'CrateUserID', width: 100, align: 'left' }, { label: '备注', name: 'Remark', width: 100, align: 'left' }, ], height: 400, mainId: 'CreateTime desc', reloadSelected: false, }); }, initData: function () { if (!!keyValue) { $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookOut/GetFormDataEdit?keyValue=' + keyValue, function (data) { for (var id in data) { if (!!data[id].length && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); } else { $('[data-table="' + id + '"]').lrSetFormData(data[id]); } } }); } } }; refreshGirdData = function (temprow) { var ifnewrow = true; $.each(tempdatra, function (key, val) { if (tempdatra[key].BookCode === temprow.InOutBook) { tempdatra[key] = temprow; ifnewrow = false; } }); if (ifnewrow) { tempdatra.push(temprow); } $('#TextBookOut').jfGridSet('refreshdata', tempdatra); }; // 设置表单数据 setFormData = function (processId, param, callback) { if (!!processId) { $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookOut/GetFormDataByProcessId?processId=' + processId, function (data) { for (var id in data) { if (!!data[id] && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); } else { if (id == 'TextBookOut' && data[id]) { keyValue = data[id].ID; } $('[data-table="' + id + '"]').lrSetFormData(data[id]); } } }); } } // 验证数据是否填写完整 validForm = function () { var datas = $('#TextBookOut').jfGridGet('rowdatas'); if (datas == null || datas.length == 0) { learun.alert.warning("申请未包含出库申请!请先添加入库申请!"); return false; } return true; }; // 保存数据 save = function (callBack) { var postData = {}; var formData = $('[data-table="TextBookInOut"]').lrGetFormData(); postData.strEntity = JSON.stringify(formData); postData.strTextBookOutList = JSON.stringify($('#TextBookOut').jfGridGet('rowdatas')); $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TextBookOut/SaveForm?keyValue=' + keyValue, postData, function (res) { // 保存成功后才回调 if (!!callBack) { callBack(); } }); }; page.init(); }