diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/TextBookInController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/TextBookInController.cs index 5f756e976..612ce696f 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/TextBookInController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/TextBookInController.cs @@ -58,7 +58,15 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { return View(); } - + /// + /// 明细删除 + /// + /// + [HttpGet] + public ActionResult FormDelete() + { + return View(); + } #endregion #region 获取数据 @@ -104,6 +112,22 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers return Success(jsonData); } + /// + /// 获取表单数据 + /// + /// 主键 + /// + [HttpGet] + [AjaxOnly] + public ActionResult GetFormDataEdit(string keyValue) + { + var TextBookInOutData = textBookInOutIBLL.GetKCEntity(keyValue); + var jsonData = new + { + TextBookInOut = TextBookInOutData, + }; + return Success(jsonData); + } #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Form.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Form.js index 6594e58da..86974f38f 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Form.js @@ -92,8 +92,7 @@ var bootstrap = function ($, learun) { }, initData: function () { if (!!keyValue) { - $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookIn/GetFormData?keyValue=' + keyValue, function (data) { - console.log(data); + $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookIn/GetFormDataEdit?keyValue=' + keyValue, function (data) { for (var id in data) { if (!!data[id].length && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/FormDelete.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/FormDelete.cshtml new file mode 100644 index 000000000..a05adea86 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/FormDelete.cshtml @@ -0,0 +1,55 @@ +@{ + ViewBag.Title = "教材库存表"; + Layout = "~/Views/Shared/_Form.cshtml"; +} +
+
+
库存单
+ +
+
+
课程
+
+
+
+
所选书籍
+ +
+
+
出版号
+ +
+
+
作者
+ +
+
+
其他作者
+ +
+
+
出版社
+ +
+
+
版次
+ +
+
+
当前库存
+ +
+
+
备注
+ +
+
+
明细操作
+ @**@ + +
+
+
+
+
+@Html.AppendJsFile("/Areas/EducationalAdministration/Views/TextBookIn/FormDelete.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/FormDelete.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/FormDelete.js new file mode 100644 index 000000000..68bb22f01 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/FormDelete.js @@ -0,0 +1,131 @@ +/* * 版 本 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 DelkeyValue = request('DelkeyValue'); +// 设置权限 +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(); + page.bind(); + page.initData(); + }, + bind: function () { + $('#LessonNo').lrDataSourceSelect({ code: 'LessonInfo', value: 'lessonno', text: 'lessonname' }); + $('#TextBookIn').jfGrid({ + headData: [ + { label: '入库单', name: 'BookCode', width: 180, 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, + }); + $("#detaildel").on('click', function () { + var NewkeyValue = $('#TextBookIn').jfGridValue('ID'); + if (learun.checkrow(NewkeyValue)) { + learun.layerConfirm('是否确认删除该项!', function (res, index) { + if (res) { + learun.deleteForm(top.$.rootUrl + '/EducationalAdministration/TextBookIn/DeleteForm', { keyValue: NewkeyValue }, function () { + refreshGirdData(); + learun.layerClose(window.name); + }); + } + }); + } + }); + }, + initData: function () { + if (!!keyValue) { + $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookIn/GetFormData?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); + } + + $('#TextBookIn').jfGridSet('refreshdata', tempdatra); + }; + // 设置表单数据 + setFormData = function (processId, param, callback) { + if (!!processId) { + $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookIn/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 == 'TextBookIn' && data[id]) { + keyValue = data[id].ID; + } + $('[data-table="' + id + '"]').lrSetFormData(data[id]); + } + } + }); + } + } + // 验证数据是否填写完整 + validForm = function () { + var datas = $('#TextBookIn').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.strTextBookInList = JSON.stringify($('#TextBookIn').jfGridGet('rowdatas')); + $.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/TextBookIn/SaveForm?keyValue=' + keyValue, postData, function (res) { + // 保存成功后才回调 + if (!!callBack) { + callBack(); + } + }); + }; + page.init(); +} diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Index.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Index.cshtml index ac1e680f3..36c5eecce 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Index.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Index.cshtml @@ -25,6 +25,7 @@ diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Index.js index 8a2490d8a..4117cd9cc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextBookIn/Index.js @@ -59,6 +59,20 @@ var bootstrap = function ($, learun) { }); } }); + // 删除 + $('#lr_delete').on('click', function () { + var keyValue = $('#gridtable').jfGridValue('ID'); + if (learun.checkrow(keyValue)) { + learun.layerForm({ + id: 'formdelete', + title: '删除明细', + url: top.$.rootUrl + '/EducationalAdministration/TextBookIn/FormDelete?keyValue=' + keyValue, + width: 1000, + height: 700, + btn: null, + }); + } + }); }, // 初始化列表 initGird: function () { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextbookInOut/Form.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextbookInOut/Form.js index 25576af1a..e4ab805d0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextbookInOut/Form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextbookInOut/Form.js @@ -79,7 +79,6 @@ var bootstrap = function ($, learun) { initData: function () { if (!!keyValue) { $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/TextBookInOut/GetFormData?keyValue=' + keyValue, function (data) { - console.log(data); for (var id in data) { if (!!data[id].length && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextbookInOut/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextbookInOut/Index.js index fa6d1ca63..b14b3e7c6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextbookInOut/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/TextbookInOut/Index.js @@ -10,7 +10,6 @@ var bootstrap = function ($, learun) { var page = { init: function () { page.initGird(); - console.log(223223223); page.bind(); }, bind: function () { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index a6dc13ab8..4cd870a24 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -1178,6 +1178,7 @@ + @@ -7615,6 +7616,7 @@ + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TextBookIn/TextBookInService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TextBookIn/TextBookInService.cs index bbad32cb9..314c0eaf3 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TextBookIn/TextBookInService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/TextBookIn/TextBookInService.cs @@ -115,12 +115,42 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// 主键 public void DeleteEntity(string keyValue) { + var db = this.BaseRepository("CollegeMIS").BeginTrans(); try { - this.BaseRepository("CollegeMIS").Delete(t => t.ID == keyValue); + decimal? Num = 0; + var keyValueArr = keyValue.Split(','); + foreach (var item in keyValueArr) + { + var entity = BaseRepository("CollegeMIS").FindEntity(x => x.ID == item); + if (entity != null) + { + Num += entity.variate; + var InOutEntity = db.FindEntity(x => x.BookCode == entity.InOutCode); + if (InOutEntity != null) + { + InOutEntity.FinallyNum = InOutEntity.FinallyNum - Num; + if (InOutEntity.FinallyNum == 0 || InOutEntity.FinallyNum > 0) + { + db.Delete(entity); + db.Update(InOutEntity); + } + else + { + db.Rollback(); + } + } + else + { + db.Rollback(); + } + } + } + db.Commit(); } catch (Exception ex) { + db.Rollback(); if (ex is ExceptionEx) { throw;