添加打印模板配置
This commit is contained in:
1 parent
b627851ab5
commit
ebdd40c518
22 files changed
+585
-191
No files matched your search
@@ -0,0 +1,228 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web;
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
[Area("configs")]
|
||||
[ActionDescription("打印模板配置")]
|
||||
public partial class PrintConfigController : BaseController
|
||||
{
|
||||
private readonly IUnitWork _unitWork;
|
||||
|
||||
public PrintConfigController(IUnitWork unitWork)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
#region Search
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
[HttpPost]
|
||||
public string Search(PrintConfigSearcher searcher)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigListVM>(passInit: true);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
vm.Searcher = searcher;
|
||||
return vm.GetJson(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vm.GetError();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Create
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create()
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult Create(PrintConfigVM vm)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoAdd();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Edit
|
||||
[ActionDescription("Sys.Edit")]
|
||||
public ActionResult Edit(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Edit")]
|
||||
[HttpPost]
|
||||
[ValidateFormItemOnly]
|
||||
public ActionResult Edit(PrintConfigVM vm)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.DoEdit();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
vm.DoReInit();
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Delete
|
||||
[ActionDescription("Sys.Delete")]
|
||||
public ActionResult Delete(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Delete")]
|
||||
[HttpPost]
|
||||
public ActionResult Delete(string id, IFormCollection nouse)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
vm.DoDelete();
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Details
|
||||
[ActionDescription("Sys.Details")]
|
||||
public ActionResult Details(string id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigVM>(id);
|
||||
return PartialView(vm);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BatchEdit
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchEdit")]
|
||||
public ActionResult BatchEdit(string[] IDs)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchEdit")]
|
||||
public ActionResult DoBatchEdit(PrintConfigBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (!ModelState.IsValid || !vm.DoBatchEdit())
|
||||
{
|
||||
return PartialView("BatchEdit",vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchEditSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BatchDelete
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult BatchDelete(string[] IDs)
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigBatchVM>(Ids: IDs);
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.BatchDelete")]
|
||||
public ActionResult DoBatchDelete(PrintConfigBatchVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (!ModelState.IsValid || !vm.DoBatchDelete())
|
||||
{
|
||||
return PartialView("BatchDelete",vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Import
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import()
|
||||
{
|
||||
var vm = Wtm.CreateVM<PrintConfigImportVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Import")]
|
||||
public ActionResult Import(PrintConfigImportVM vm, IFormCollection nouse)
|
||||
{
|
||||
if (vm.ErrorListVM.EntityList.Count > 0 || !vm.BatchSaveData())
|
||||
{
|
||||
return PartialView(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.ImportSuccess", vm.EntityList.Count.ToString()]);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Export
|
||||
[ActionDescription("Sys.Export")]
|
||||
[HttpPost]
|
||||
public IActionResult ExportExcel(PrintConfigListVM vm)
|
||||
{
|
||||
return vm.GetExportData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class PrintConfigBatchVM : BaseBatchVM<PrintConfig, PrintConfig_BatchEdit>
|
||||
{
|
||||
public PrintConfigBatchVM()
|
||||
{
|
||||
ListVM = new PrintConfigListVM();
|
||||
LinkedVM = new PrintConfig_BatchEdit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class to define batch edit fields
|
||||
/// </summary>
|
||||
public class PrintConfig_BatchEdit : BaseVM
|
||||
{
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class PrintConfigTemplateVM : BaseTemplateVM
|
||||
{
|
||||
[Display(Name = "PrintConfig.Name")]
|
||||
public ExcelPropety Name_Excel = ExcelPropety.CreateProperty<PrintConfig>(x => x.Name);
|
||||
[Display(Name = "PrintConfig.Template")]
|
||||
public ExcelPropety Template_Excel = ExcelPropety.CreateProperty<PrintConfig>(x => x.Template);
|
||||
[Display(Name = "PrintConfig.TestData")]
|
||||
public ExcelPropety TestData_Excel = ExcelPropety.CreateProperty<PrintConfig>(x => x.TestData);
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PrintConfigImportVM : BaseImportVM<PrintConfigTemplateVM, PrintConfig>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class PrintConfigListVM : BasePagedListVM<PrintConfig_View, PrintConfigSearcher>
|
||||
{
|
||||
protected override List<GridAction> InitGridAction()
|
||||
{
|
||||
return new List<GridAction>
|
||||
{
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "configs", dialogWidth: 800),
|
||||
this.MakeStandardAction("PrintConfig", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "configs"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected override IEnumerable<IGridColumn<PrintConfig_View>> InitGridHeader()
|
||||
{
|
||||
return new List<GridColumn<PrintConfig_View>>{
|
||||
this.MakeGridHeader(x => x.Name),
|
||||
this.MakeGridHeader(x => x.Template),
|
||||
this.MakeGridHeader(x => x.TestData),
|
||||
this.MakeGridHeaderAction(width: 200)
|
||||
};
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<PrintConfig_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<PrintConfig>()
|
||||
.CheckContain(Searcher.Name, x=>x.Name)
|
||||
.Select(x => new PrintConfig_View
|
||||
{
|
||||
ID = x.ID,
|
||||
Name = x.Name,
|
||||
Template = x.Template,
|
||||
TestData = x.TestData,
|
||||
})
|
||||
.OrderBy(x => x.ID);
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PrintConfig_View : PrintConfig{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class PrintConfigSearcher : BaseSearcher
|
||||
{
|
||||
[Display(Name = "PrintConfig.Name")]
|
||||
public String Name { get; set; }
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class PrintConfigVM : BaseCRUDVM<PrintConfig>
|
||||
{
|
||||
|
||||
public PrintConfigVM()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DoAdd()
|
||||
{
|
||||
base.DoAdd();
|
||||
}
|
||||
|
||||
public override void DoEdit(bool updateAllFields = false)
|
||||
{
|
||||
base.DoEdit(updateAllFields);
|
||||
}
|
||||
|
||||
public override void DoDelete()
|
||||
{
|
||||
base.DoDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
@model HHWMS.Web.PrintConfigBatchVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.BatchDeleteConfirm"]</wt:quote>
|
||||
<wt:hidden field="Ids" />
|
||||
<wt:grid vm="ListVM" use-local-data="true" height="300" hidden-checkbox="true" hidden-panel="true"/>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton theme=" ButtonThemeEnum.Warm" text="@Localizer["Sys.Delete"]"/>
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@@ -0,0 +1,14 @@
|
||||
@model HHWMS.Web.PrintConfigBatchVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<div style="margin-bottom:10px">@Localizer["Sys.BatchEditConfirm"] </div>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
</wt:row>
|
||||
<wt:hidden field="Ids" />
|
||||
<wt:grid vm="ListVM" use-local-data="true" height="300" hidden-checkbox="true" hidden-panel="true"/>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@@ -0,0 +1,14 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="Entity.Name" />
|
||||
<wt:textbox field="Entity.Template" />
|
||||
<wt:textbox field="Entity.TestData" />
|
||||
</wt:row>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@@ -0,0 +1,16 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.Name" />
|
||||
<wt:display field="Entity.Template" />
|
||||
<wt:display field="Entity.TestData" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ID" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton theme=" ButtonThemeEnum.Warm" text="@Localizer["Sys.Delete"]"/>
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@@ -0,0 +1,13 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.Name" />
|
||||
<wt:display field="Entity.Template" />
|
||||
<wt:display field="Entity.TestData" />
|
||||
</wt:row>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@@ -0,0 +1,15 @@
|
||||
@model HHWMS.Web.PrintConfigVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:textbox field="Entity.Name" />
|
||||
<wt:textbox field="Entity.Template" />
|
||||
<wt:textbox field="Entity.TestData" />
|
||||
</wt:row>
|
||||
<wt:hidden field="Entity.ID" />
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@@ -0,0 +1,14 @@
|
||||
@model HHWMS.Web.PrintConfigImportVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:downloadTemplateButton vm="@Model" />
|
||||
</wt:row>
|
||||
<wt:upload field="UploadFileId" label-text="@Model.Localizer["Sys.UploadTemplate"]" upload-type="ExcelFile" />
|
||||
<wt:grid vm="ErrorListVM" use-local-data="true" hidden-checkbox="true" hidden-grid-index="true" hidden-panel="true" height="300"/>
|
||||
<wt:row align="AlignEnum.Right">
|
||||
<wt:submitbutton />
|
||||
<wt:closebutton />
|
||||
</wt:row>
|
||||
</wt:form>
|
||||
@@ -0,0 +1,9 @@
|
||||
@model HHWMS.Web.PrintConfigListVM
|
||||
@inject IStringLocalizer<Program> Localizer;
|
||||
|
||||
<wt:searchpanel vm="@Model" reset-btn="true">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Three">
|
||||
<wt:textbox field="Searcher.Name" />
|
||||
</wt:row>
|
||||
</wt:searchpanel>
|
||||
<wt:grid vm="@Model" url="/configs/PrintConfig/Search"/>
|
||||
@@ -118,114 +118,6 @@ namespace HHWMS.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult CreateDetails(int id)
|
||||
{
|
||||
var vm = Wtm.CreateVM<ReceiptDetailVM>(passInit: true);
|
||||
vm.Entity.ReceiptHeaderId = id;
|
||||
vm.Entity.ReceiptHeader = new ReceiptHeader();
|
||||
//vm.Entity.ReceiptHeader.Code = vm.DC.Set<ReceiptHeader>().Find(id).Code;
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("Sys.Create")]
|
||||
public ActionResult CreateDetails(ReceiptDetailVM vm)
|
||||
{
|
||||
var header = _unitwork.FindSingle<ReceiptHeader>(x => x.ID == vm.Entity.ReceiptHeaderId);
|
||||
if(header.FirstStatus != ReceiptStatusEnum.新建)
|
||||
{
|
||||
return FFResult().Alert("主单据不是新建状态,不能新建明细!");
|
||||
}
|
||||
var plList = vm.Entity.MaterialCode.Split("\n");
|
||||
var slList = vm.Entity.Lot.Split("\n");
|
||||
var detailList = new List<ReceiptDetail>();
|
||||
foreach(var item in plList)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
detailList.Add(new ReceiptDetail
|
||||
{
|
||||
UniqueCode = item,
|
||||
Status = 0,
|
||||
ZoneCode = ZoneCodeEnum.盘料库,
|
||||
ReceiptHeaderId = vm.Entity.ReceiptHeaderId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in slList)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item))
|
||||
{
|
||||
detailList.Add(new ReceiptDetail
|
||||
{
|
||||
UniqueCode = item,
|
||||
ZoneCode = ZoneCodeEnum.散料库,
|
||||
Status = 0,
|
||||
ReceiptHeaderId = vm.Entity.ReceiptHeaderId
|
||||
});
|
||||
}
|
||||
}
|
||||
var uniqueGroup = detailList.GroupBy(x => x.UniqueCode);
|
||||
|
||||
if (uniqueGroup.Any(x => x.Count() > 1))
|
||||
{
|
||||
var codeList = uniqueGroup.Where(x => x.Count() > 1)
|
||||
.Select(x => x.Key)
|
||||
.ToList();
|
||||
return FFResult().Alert($"新增明细中,存在重复的唯一码!{String.Join(", ", codeList.ToArray())}");
|
||||
}
|
||||
|
||||
// 判断唯一码是否已在库内
|
||||
var reDetailList = _unitwork.Find<ReceiptDetail>(x => x.Status == ReceiptStatusEnum.新建)
|
||||
.Select(x => new { x.UniqueCode, x.ReceiptHeader.Code })
|
||||
.ToList();
|
||||
var reDel = reDetailList.Select(x => x.UniqueCode)
|
||||
.Intersect(detailList.Select(x => x.UniqueCode));
|
||||
if (reDel.Count() > 0)
|
||||
{
|
||||
var tt= reDetailList.Where(x => reDel.Contains(x.UniqueCode))
|
||||
.ToList();
|
||||
var returnStr = "";
|
||||
foreach (var item in tt)
|
||||
{
|
||||
returnStr += $"单号:{item.Code};唯一码:{item.UniqueCode};";
|
||||
}
|
||||
return FFResult().Alert($"新增明细中,存在已添加的唯一码!{returnStr}");
|
||||
}
|
||||
|
||||
// 判断唯一码是否已在库内
|
||||
var invList = _unitwork.Find<Inventory>(x => 1 == 1)
|
||||
.Select(x => x.UniqueCode)
|
||||
.ToList();
|
||||
if(invList.Intersect(detailList.Select(x => x.UniqueCode)).Count() > 0)
|
||||
{
|
||||
return FFResult().Alert("新增明细中,存在已在库内的唯一码!");
|
||||
}
|
||||
// 补充物料明细
|
||||
foreach (var item in detailList)
|
||||
{
|
||||
var materialqr = _unitwork.FindSingle<MaterialQr>(x => x.UniqueCode.Equals(item.UniqueCode));
|
||||
if(materialqr == null)
|
||||
{
|
||||
return FFResult().Alert("新增明细中,存在不是WMS生成的唯一码!");
|
||||
}
|
||||
var material = _unitwork.FindSingle<Material>(x => x.QRCode.Equals(materialqr.QRCode));
|
||||
item.MaterialCode = material.MaterialCode;
|
||||
item.MaterialName = material.MaterialName;
|
||||
item.MaterialSpec = material.MaterialSpec;
|
||||
item.MaterialType = material.MaterialType;
|
||||
item.MaterialUnit = material.MaterialUnit;
|
||||
item.Batch = material.Batch;
|
||||
item.Qty = material.Qty;
|
||||
item.SupplierCode = material.SupplierCode;
|
||||
item.CreateBy = Wtm.LoginUserInfo.ITCode;
|
||||
item.CreateTime = DateTime.Now;
|
||||
}
|
||||
_unitwork.BatchAdd(detailList.ToArray());
|
||||
return FFResult().CloseDialog().RefreshGrid(index: 1);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Edit
|
||||
|
||||
Reference in new issue
Block a user