WMS/HHWMS.Web/Areas/Inventory/Controllers/InventoryApiController.cs

56 lines
1.7 KiB
C#

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using WalkingTec.Mvvm.Mvc;
using HHWMS.Web;
using HHWMS.Web.Models;
namespace HHWMS.Web.Controllers
{
[Area("inventory")]
[Public]
[ActionDescription("库存管理")]
[ApiController]
[Route("api/Inventory")]
public partial class InventoryApiController : BaseApiController
{
[ActionDescription("Sys.Search")]
[HttpPost("Search")]
[Public]
public IActionResult Search(InventoryApiSearcher searcher)
{
if (ModelState.IsValid)
{
var vm = Wtm.CreateVM<InventoryApiListVM>(passInit: true);
// 默认按入库时间倒序:最新入库的库存排在最前
searcher.SortInfo = new SortInfo()
{
Property = "Createtime",
Direction = SortDir.Desc
};
searcher.IsPlainText = false;
searcher.IsEnumToString = true;
vm.Searcher = searcher;
if (searcher.WareHouse.ToLower() == "mj")
vm.Searcher.ZoneId = 1025;
else if (searcher.WareHouse.ToLower() == "xb")
vm.Searcher.ZoneId = 1027;
else if (searcher.WareHouse.ToLower() == "cp")
vm.Searcher.ZoneId = 1028;
var data = vm.GetJson();
return Content(data);
}
else
{
return BadRequest(ModelState.GetErrorJson());
}
}
}
}