272 lines
7.5 KiB
C#
272 lines
7.5 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using WalkingTec.Mvvm.Core;
|
|
using WalkingTec.Mvvm.Mvc;
|
|
using WalkingTec.Mvvm.Core.Extensions;
|
|
using HHWMS.Web.Models;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace HHWMS.Web.Controllers
|
|
{
|
|
[Area("receipt")]
|
|
[ActionDescription("入库单明细")]
|
|
public partial class ReceiptDetailController : BaseController
|
|
{
|
|
private readonly IUnitWork _unitwork;
|
|
public ReceiptDetailController(IUnitWork unitwork)
|
|
{
|
|
_unitwork = unitwork;
|
|
}
|
|
#region Search
|
|
[ActionDescription("Sys.Search")]
|
|
public ActionResult Index()
|
|
{
|
|
var vm = Wtm.CreateVM<ReceiptDetailListVM>();
|
|
return PartialView(vm);
|
|
}
|
|
|
|
[ActionDescription("Sys.Search")]
|
|
[HttpPost]
|
|
public string Search(ReceiptDetailSearcher searcher)
|
|
{
|
|
var vm = Wtm.CreateVM<ReceiptDetailListVM>(passInit: true);
|
|
if (ModelState.IsValid)
|
|
{
|
|
vm.Searcher = searcher;
|
|
return vm.GetJson(false);
|
|
}
|
|
else
|
|
{
|
|
return vm.GetError();
|
|
}
|
|
}
|
|
|
|
[ActionDescription("Sys.Search")]
|
|
[HttpPost]
|
|
public string Search2(ReceiptDetailListVM2 vm)
|
|
{
|
|
vm.Searcher.Page = vm.FC.GetValue<int>("Page");
|
|
vm.Searcher.Limit = vm.FC.GetValue<int>("Limit");
|
|
return vm.GetJson(false);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Create
|
|
[ActionDescription("Sys.Create")]
|
|
public ActionResult Create()
|
|
{
|
|
var vm = Wtm.CreateVM<ReceiptDetailVM>();
|
|
return PartialView(vm);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ActionDescription("Sys.Create")]
|
|
public ActionResult Create(ReceiptDetailVM vm)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return PartialView(vm);
|
|
}
|
|
else
|
|
{
|
|
vm.DoAdd();
|
|
if (!ModelState.IsValid)
|
|
{
|
|
vm.DoReInit();
|
|
return PartialView(vm);
|
|
}
|
|
else
|
|
{
|
|
return FFResult().CloseDialog().RefreshGrid();
|
|
}
|
|
}
|
|
}
|
|
|
|
[ActionDescription("Sys.Create")]
|
|
public ActionResult Create2(int id)
|
|
{
|
|
var vm = Wtm.CreateVM<ReceiptDetailVM>(passInit: true);
|
|
vm.Entity.HeaderId = 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 Create2(ReceiptDetailVM vm)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return PartialView(vm);
|
|
}
|
|
else
|
|
{
|
|
vm.DoAdd();
|
|
if (!ModelState.IsValid)
|
|
{
|
|
vm.DoReInit();
|
|
return PartialView(vm);
|
|
}
|
|
else
|
|
{
|
|
return FFResult().CloseDialog().RefreshGrid(index: 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Edit
|
|
[ActionDescription("Sys.Edit")]
|
|
public ActionResult Edit(string id)
|
|
{
|
|
var vm = Wtm.CreateVM<ReceiptDetailVM>(id);
|
|
return PartialView(vm);
|
|
}
|
|
|
|
[ActionDescription("Sys.Edit")]
|
|
[HttpPost]
|
|
[ValidateFormItemOnly]
|
|
public ActionResult Edit(ReceiptDetailVM 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<ReceiptDetailVM>(id);
|
|
return PartialView(vm);
|
|
}
|
|
|
|
[ActionDescription("Sys.Delete")]
|
|
[HttpPost]
|
|
public ActionResult Delete(string id, IFormCollection nouse)
|
|
{
|
|
var vm = Wtm.CreateVM<ReceiptDetailVM>(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<ReceiptDetailVM>(id);
|
|
return PartialView(vm);
|
|
}
|
|
#endregion
|
|
|
|
#region BatchEdit
|
|
[HttpPost]
|
|
[ActionDescription("Sys.BatchEdit")]
|
|
public ActionResult BatchEdit(string[] IDs)
|
|
{
|
|
var vm = Wtm.CreateVM<ReceiptDetailBatchVM>(Ids: IDs);
|
|
return PartialView(vm);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ActionDescription("Sys.BatchEdit")]
|
|
public ActionResult DoBatchEdit(ReceiptDetailBatchVM 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<ReceiptDetailBatchVM>(Ids: IDs);
|
|
return PartialView(vm);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ActionDescription("Sys.BatchDelete")]
|
|
public ActionResult DoBatchDelete(ReceiptDetailBatchVM 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<ReceiptDetailImportVM>();
|
|
return PartialView(vm);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ActionDescription("Sys.Import")]
|
|
public ActionResult Import(ReceiptDetailImportVM 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(ReceiptDetailListVM vm)
|
|
{
|
|
return vm.GetExportData();
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|