diff --git a/AMESCoreStudio.Web/Controllers/BASController.cs b/AMESCoreStudio.Web/Controllers/BASController.cs index fa56ea09..0ca94cab 100644 --- a/AMESCoreStudio.Web/Controllers/BASController.cs +++ b/AMESCoreStudio.Web/Controllers/BASController.cs @@ -2703,13 +2703,15 @@ namespace AMESCoreStudio.Web.Controllers [ResponseCache(Duration = 0)] [HttpGet] - public async Task GetSerialRulesAsync() + public async Task 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 GetSerialRuleByItemNoAsync(string ID) + public async Task 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 }); diff --git a/AMESCoreStudio.Web/HttpApis/IBAS.cs b/AMESCoreStudio.Web/HttpApis/IBAS.cs index c8ff1776..d1debc33 100644 --- a/AMESCoreStudio.Web/HttpApis/IBAS.cs +++ b/AMESCoreStudio.Web/HttpApis/IBAS.cs @@ -875,14 +875,14 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/SerialRules")] - ITask> GetSerialRules(); + ITask> GetSerialRules(int page = 0, int limit = 10); /// /// 獲取出貨序號編碼規則ByItemNo /// /// [WebApiClient.Attributes.HttpGet("api/SerialRules/ItemNo/{id}")] - ITask> GetSerialRuleByItemNo(string id); + ITask> GetSerialRuleByItemNo(string id, int page = 0, int limit = 10); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesController.cs index bd846188..91f4de1d 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/SerialRulesController.cs @@ -30,15 +30,24 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } /// - /// 查詢出貨序號編碼規則資料檔 + /// /// + /// + /// /// - // GET: api/ [HttpGet] - public async Task>> GetSerialRule() + public async Task>> GetSerialRule(int page = 0, int limit = 10) { IQueryable 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 } /// - /// 料號基本資料檔 to ItemNo + /// /// - /// ItemNo + /// + /// + /// /// [HttpGet("ItemNo/{id}")] - public async Task>> GetSerialRuleByItemNo(string id) + public async Task>> GetSerialRuleByItemNo(string id, int page = 0, int limit = 10) { IQueryable 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)