Browse Source

1.修改BAS019分页

PTD
Marvin 2 years ago
parent
commit
bbaab4d7d5
  1. 16
      AMESCoreStudio.Web/Controllers/BASController.cs
  2. 4
      AMESCoreStudio.Web/HttpApis/IBAS.cs
  3. 34
      AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesController.cs

16
AMESCoreStudio.Web/Controllers/BASController.cs

@ -2703,13 +2703,15 @@ namespace AMESCoreStudio.Web.Controllers
[ResponseCache(Duration = 0)]
[HttpGet]
public async Task<IActionResult> GetSerialRulesAsync()
public async Task<IActionResult> GetSerialRulesAsync(int page = 0, int limit = 10)
{
var result = await _basApi.GetSerialRules();
var result = await _basApi.GetSerialRules(page,limit);
var result_total = await _basApi.GetSerialRules(0, limit);
if (result.Count > 0)
{
return Json(new Table() { code = 0, msg = "", data = result, count = result.Count });
return Json(new Table() { code = 0, msg = "", data = result, count = result_total.Count });
}
return Json(new Table() { count = 0, data = null });
@ -2729,13 +2731,15 @@ namespace AMESCoreStudio.Web.Controllers
}
public async Task<IActionResult> GetSerialRuleByItemNoAsync(string ID)
public async Task<IActionResult> GetSerialRuleByItemNoAsync(string ID, int page = 0, int limit = 10)
{
var result = await _basApi.GetSerialRuleByItemNo(ID);
var result = await _basApi.GetSerialRuleByItemNo(ID, page, limit);
var result_total = await _basApi.GetSerialRuleByItemNo(ID, 0, limit);
if (result.Count > 0)
{
return Json(new Table() { code = 0, msg = "", data = result, count = result.Count });
return Json(new Table() { code = 0, msg = "", data = result, count = result_total.Count });
}
return Json(new Table() { count = 0, data = null });

4
AMESCoreStudio.Web/HttpApis/IBAS.cs

@ -875,14 +875,14 @@ namespace AMESCoreStudio.Web
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/SerialRules")]
ITask<List<SerialRule>> GetSerialRules();
ITask<List<SerialRule>> GetSerialRules(int page = 0, int limit = 10);
/// <summary>
/// 獲取出貨序號編碼規則ByItemNo
/// </summary>
/// <returns></returns>
[WebApiClient.Attributes.HttpGet("api/SerialRules/ItemNo/{id}")]
ITask<List<SerialRule>> GetSerialRuleByItemNo(string id);
ITask<List<SerialRule>> GetSerialRuleByItemNo(string id, int page = 0, int limit = 10);

34
AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesController.cs

@ -30,15 +30,24 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
/// <summary>
/// 查詢出貨序號編碼規則資料檔
///
/// </summary>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
// GET: api/<SerialRuleController>
[HttpGet]
public async Task<ActionResult<IEnumerable<SerialRule>>> GetSerialRule()
public async Task<ActionResult<IEnumerable<SerialRule>>> GetSerialRule(int page = 0, int limit = 10)
{
IQueryable<SerialRule> q = _context.SerialRules;
q = q.OrderBy(p => p.SerialRuleID);
if (page > 0)
{
q = q.OrderBy(p => p.SerialRuleID).Skip((page - 1) * limit).Take(limit);
}
else
{
q = q.OrderBy(p => p.SerialRuleID);
}
//q = q.OrderBy(p => p.SerialRuleID);
var SerialRule = await q.ToListAsync();
return SerialRule;
}
@ -58,17 +67,26 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
/// <summary>
/// 料號基本資料檔 to ItemNo
///
/// </summary>
/// <param name="ItemNo">ItemNo</param>
/// <param name="id"></param>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
[HttpGet("ItemNo/{id}")]
public async Task<ActionResult<IEnumerable<SerialRule>>> GetSerialRuleByItemNo(string id)
public async Task<ActionResult<IEnumerable<SerialRule>>> GetSerialRuleByItemNo(string id, int page = 0, int limit = 10)
{
IQueryable<SerialRule> q = _context.SerialRules;
q = q.Where(p => p.ItemNo == id);
if (page > 0)
{
q = q.OrderBy(p => p.SerialRuleID).Skip((page - 1) * limit).Take(limit);
}
else
{
q = q.OrderBy(p => p.SerialRuleID);
}
var SerialRule = await q.ToListAsync();
if (SerialRule == null)

Loading…
Cancel
Save