| HTML/js/public.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| HTML/views/ASNSetting/ArrivalNotice.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Wms/Model/ModelVm/BllAsnVm/ArrivalNoticeVm.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Wms/WMS.IBLL/IBllAsnServer/IArrivalNoticeServer.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Wms/Wms/Controllers/BllAsnController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
HTML/js/public.js
@@ -2,7 +2,7 @@ // var IP = "http://172.16.71.101:8082/";//接口IP //var IP = "http://localhost:13243/api"; //var IP = "http://localhost:50515/api"; //本地 var IP="https://localhost:5001/api"; var IP="https://localhost:44363/api"; // var IP = "http://localhost:44318/api"; //var IP = "http://192.168.1.6:8017"; //var IP = "http://192.168.1.226:8086"; HTML/views/ASNSetting/ArrivalNotice.html
@@ -291,6 +291,9 @@ <button style="margin-right: 5px;" class="layui-btn layui-btn-sm layuiadmin-btn-list addClass" lay-event="add" > <i class="layui-icon"></i>添加 </button> <button style="margin-right: 5px;" id="daoru" class="layui-btn layui-btn-sm layuiadmin-btn-list DaoRuClass" lay-event="import" > <i class="layui-icon"></i>导入 </button> </script> <script type="text/html" id="toolbarDemoList"> @@ -399,11 +402,14 @@ <script> var uid = $.cookie('userId'); layui.extend({ excel: '../../layuiadmin/layui/layui_exts/excel' // {/}的意思即代表采用自有路径,即不跟随 base 路径 }) layui.config({ base: '../../layuiadmin/' //静态资源所在路径 }).extend({ index: 'lib/index' //主入口模块 }).use(['index', 'form', 'table', 'laypage', 'layer', 'laydate'], function () { }).use(['index', 'form', 'table', 'laypage', 'layer', 'laydate', 'upload', 'excel'], function () { var doing = true; @@ -411,6 +417,8 @@ form = layui.form, laypage = layui.laypage, layer = layui.layer; var upload = layui.upload; laydate = layui.laydate; @@ -591,10 +599,130 @@ }, cols: colsJson2 }); //绑定导入 upload.render({ elem: '#daoru' //绑定元素 , url: '' //上传接口 , auto: false //是否选完文件后自动上传。如果设定 false,那么需要设置 bindAction 参数来指向一个其它按钮提交上传 , exts: 'slx|excel|xlsx' //允许上传的文件后缀 , accept: 'file' //指定允许上传时校验的文件类型 //, bindAction: '#daoru' //指向一个按钮触发上传 , choose: function (obj) {// 选择文件回调 console.log(obj); var files = obj.pushFile(); //将每次选择的文件追加到文件队列 var fileArr = Object.values(files);// 注意这里的数据需要是数组,所以需要转换一下 console.log(fileArr) // 用完就清理掉,避免多次选中相同文件时出现问题 for (var index in files) { console.log(index); if (files.hasOwnProperty(index)) { delete files[index]; } } console.log("abs"); uploadExcel(fileArr); // 如果只需要最新选择的文件,可以这样写: uploadExcel([files.pop()]) } , done: function (res) { console.log(res); //上传完毕回调 } , error: function (res) { console.log(res); //请求异常回调 } }); }); //#endregion } // 导入入库单据 function uploadExcel(files) { var noticeList = []; try { var excel = layui.excel; excel.importExcel(files, { // 读取数据的同时梳理数据 fields: { 'SkuNo': 'A', //物料号 'SkuName': 'B', //物料名称 'Qty': 'C', //数量 'LotNo': 'D', //批次 'LotText': 'E', //批次描述 'SupplierLot': 'F', //供货批次 'Lot1': 'G', //生产日期 'Lot2': 'H', //过期日期 'CustomerNo': 'I', //供应商编码 'CustomerName': 'J', //供应商名称 } }, function (data) { console.log(data); // var arr = new Array(); //excel第一行不读取、设置为标题 for (i = 1; i < data[0].Sheet1.length; i++) { var noticeDetailList = []; var Qty = 0; if (data[0].Sheet1[i].Qty) { Qty = parseFloat(data[0].Sheet1[i].Qty); } var noticeDetail={ SkuNo: data[0].Sheet1[i].SkuNo.toString(), SkuName: data[0].Sheet1[i].SkuName.toString(), Qty: Qty, LotNo: data[0].Sheet1[i].LotNo.toString(), LotText: data[0].Sheet1[i].LotText, SupplierLot: data[0].Sheet1[i].SupplierLot.toString(), Lot1: data[0].Sheet1[i].Lot1, Lot2: data[0].Sheet1[i].Lot2, }; noticeDetailList.push(noticeDetail); var notice = { Type:'1', CustomerNo: data[0].Sheet1[i].CustomerNo.toString(), CustomerName: data[0].Sheet1[i].CustomerName.toString(), AsnDetail:noticeDetailList }; noticeList.push(notice); } var param = { "ListArrivalNotice": noticeList, } console.log('param:'+param) layer.load();//打开loading sendData(IP + "/BllAsn/ImportArrivalNotice", param, 'post', function (res) { console.log(res); layer.closeAll(); //关闭loading if (res.code == 0) { //成功 layer.msg(res.msg, { icon: 1, time: 2000 //2秒关闭(如果不配置,默认是3秒) }, function () { refreshTable(); doing = true }); } else { //不成功 if (res.msg == undefined) { layer.msg("导入数据格式有误!", { icon: 2, time: 3000 //2秒关闭(如果不配置,默认是3秒) }, function () { refreshTable(); doing = true }); } else { layer.msg(res.msg, { icon: 2, time: 2000 //2秒关闭(如果不配置,默认是3秒) }, function () { refreshTable(); doing = true }); } } }); }); } catch (e) { layer.alert(e.message); } } function setRight() { $(function () { $(".addClass").hide(); Wms/Model/ModelVm/BllAsnVm/ArrivalNoticeVm.cs
@@ -108,4 +108,11 @@ public int? CreateUser { get; set; } } public class ArrivalNoticeVms { public int? CreateUser { get; set; } public List<ArrivalNoticeVm> ListArrivalNotice { get; set; } } } Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
@@ -275,7 +275,7 @@ try { if (model.Origin == "录入") if (model.Origin == "录入" || model.Origin == "导入") { model.ASNNo = new Common().GetMaxNo("ASN"); } @@ -290,6 +290,7 @@ throw new Exception("单据类型不可为空!"); } } lock (AsnLock) { @@ -422,12 +423,16 @@ { throw new Exception("不免检物料过期日期转换失败"); } lot1 = lot12.ToString(); lot2 = lot22.ToString(); lot1 = lot12.ToString("yyyy-MM-dd"); lot2 = lot22.ToString("yyyy-MM-dd"); } if (string.IsNullOrWhiteSpace(detailModel.PackagNo)) { throw new Exception("包装不能为空"); detailModel.PackagNo = sku.PackagNo; if (string.IsNullOrWhiteSpace(detailModel.PackagNo)) { throw new Exception("包装不能为空"); } } // 计算出总金额 detailModel.Money = detailModel.Price * detailModel.Qty; @@ -436,7 +441,7 @@ ASNNo = model.ASNNo, SkuNo = detailModel.SkuNo, SkuName = detailModel.SkuName, Standard = detailModel.Standard, Standard = sku.Standard, LotNo = detailModel.LotNo == null ? "" : detailModel.LotNo.Trim(), LotText = detailModel.LotText, Qty = (decimal)detailModel.Qty, @@ -500,6 +505,63 @@ } } //导入入库单据 public string ImportArrivalNotice(ArrivalNoticeVms models) { string strMessage = ""; try { if (models.ListArrivalNotice.Count <= 0) { strMessage = "-1:文件内无数据请核实!"; } var num = 0; int CreateUser = Convert.ToInt32(models.CreateUser); List<string> noticeList = new List<string>(); foreach (ArrivalNoticeVm model in models.ListArrivalNotice) { try { model.CreateUser = models.CreateUser; model.Origin = "导入"; var msg = AddArrivalNotice(model); strMessage += msg; if (msg == "") { num += 1; var hasBoxItem = noticeList.Exists(x => x == model.ASNNo); if (!hasBoxItem) { noticeList.Add(model.ASNNo); } } } catch { // ignored } } if (num > 0) { new OperationASNServer().AddLogOperationAsn("入库作业", "入库单据", $"共导入了{noticeList.Count}条单据", "导入", $"共导入了{noticeList.Count}条单据", CreateUser); } if (strMessage.Contains("-1") && num > 0) { return "部分导入成功" + strMessage; } if (num > 0) { return "导入成功" + strMessage; } return strMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// <summary> /// 编辑入库单据 /// </summary> Wms/WMS.IBLL/IBllAsnServer/IArrivalNoticeServer.cs
@@ -49,6 +49,8 @@ /// <param name="model"></param> /// <returns></returns> string AddArrivalNotice(ArrivalNoticeVm model); //导入入库单据 string ImportArrivalNotice(ArrivalNoticeVms models); /// <summary> /// 编辑入库单 /// </summary> Wms/Wms/Controllers/BllAsnController.cs
@@ -162,6 +162,44 @@ return Ok(new { code = 1, msg = e.Message }); } } /// <summary> /// 入库单据导入 /// </summary> /// <param name="models"></param> /// <returns></returns> [HttpPost] public IActionResult ImportArrivalNotice(ArrivalNoticeVms models) { try { var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } models.CreateUser = int.Parse(UserId); string strMessage = _arrivalNoticeSvc.ImportArrivalNotice(models); if (strMessage.Contains("-1")) { return Ok(new { code = 1, msg = strMessage }); } else { return Ok(new { code = 0, msg = strMessage }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } [HttpPost] public IActionResult EditArrivalNotice(ArrivalNoticeVm model)