diff --git a/AMESCoreStudio.Web/Controllers/KCSController.cs b/AMESCoreStudio.Web/Controllers/KCSController.cs index 8f9448b8..83b17659 100644 --- a/AMESCoreStudio.Web/Controllers/KCSController.cs +++ b/AMESCoreStudio.Web/Controllers/KCSController.cs @@ -192,12 +192,21 @@ namespace AMESCoreStudio.Web.Controllers return View("KCS001U", model); } + [HttpPost] + public async Task GetClassGroupDataAsync(string group_no) + { + var result = await _kcsApi.GetMACInfoes4KCS001(null, group_no, 0, 10); + + //将数据Json化并传到前台视图 + return Json(new { data = result }); + } + [ResponseCache(Duration = 0)] [HttpGet] - public async Task GetMACInfoesAsync(int page = 0, int limit = 10) + public async Task GetMACInfoesAsync(string itemNO,string classGroupNo,int page = 0, int limit = 10) { - var result_total = await _kcsApi.GetMACInfoes(0, limit); - var result = await _kcsApi.GetMACInfoes(page, limit); + var result_total = await _kcsApi.GetMACInfoes4KCS001(itemNO,classGroupNo,0, limit); + var result = await _kcsApi.GetMACInfoes4KCS001(itemNO, classGroupNo, page, limit); if (result.Count > 0) { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs index 9fe3f517..1abcc256 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs @@ -49,6 +49,13 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/MACInfoes")] ITask> GetMACInfoes(int page = 0, int limit = 10); + /// + /// 獲取MAC資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/MACInfoes/GetMACInfoes4KCS001")] + ITask> GetMACInfoes4KCS001(string itemNO, string classGroupNo, int page = 0, int limit = 10); + #endregion #region KCS002 序號料號維護 diff --git a/AMESCoreStudio.Web/Views/KCS/KCS001.cshtml b/AMESCoreStudio.Web/Views/KCS/KCS001.cshtml index 2d5c2f3f..5dd3fff5 100644 --- a/AMESCoreStudio.Web/Views/KCS/KCS001.cshtml +++ b/AMESCoreStudio.Web/Views/KCS/KCS001.cshtml @@ -12,6 +12,35 @@
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+
diff --git a/AMESCoreStudio.Web/Views/KCS/KCS001C.cshtml b/AMESCoreStudio.Web/Views/KCS/KCS001C.cshtml index 3420e02d..72af2ec3 100644 --- a/AMESCoreStudio.Web/Views/KCS/KCS001C.cshtml +++ b/AMESCoreStudio.Web/Views/KCS/KCS001C.cshtml @@ -18,18 +18,19 @@
- + +
+
+ + + +
-
- - - -
@@ -37,22 +38,22 @@
- +
- +
- +
- +
@@ -71,7 +72,7 @@
- +
@@ -113,6 +114,42 @@ if ($(error).text() != '') { parent.hg.msg(error); } + + function setClassGroupData(data) + { + var idx = 0; + $.ajax({ + type: "post", + url: '/KCS/GetClassGroupData?group_no=' + data, + contentType: "application/json; charset=utf-8", + dataType: 'json', + success: function (response) { + $.each(response, function (i, item) { + idx = idx + 1; + $('#macMax').val(item[0]["max"]); + $('#macMin').val(item[0]["min"]); + $('#macValue').val(item[0]["value"]); + $('#macTitle').val(item[0]["title"]); + $('#macSafeQty').val(item[0]["safeQty"]); + }); + }, + error: function () { + alert("查無組代碼資料!"); + } + }); + + if (idx == 0) { + $('#macMax').val(''); + $('#macMin').val(''); + $('#macValue').val(''); + $('#macTitle').val(''); + $('#macSafeQty').val(''); + } + } + + $('#btnQuery').click(function () { + setClassGroupData(classGroupNo.value); + }); }); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/MACInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/MACInfoesController.cs index 65602d01..ea2cc8ae 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/MACInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/MACInfoesController.cs @@ -51,6 +51,48 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return macInfo; } + /// + /// + /// + /// + /// + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task>> GetMACInfoes4KCS001(string itemNO,string classGroupNo,int page = 1, int limit = 10) + { + IQueryable q = _context.MACInfoes; + if (itemNO != null) + { + if (itemNO != "") + { + q = q.Where(m => m.Class == itemNO); + } + } + + if (classGroupNo != null) + { + if (classGroupNo != "") + { + q = q.Where(m => m.ClassGroup == classGroupNo); + } + } + + if (page > 0) + { + q = q.OrderBy(p => p.Class + p.ClassGroup).Skip((page - 1) * limit).Take(limit); + } + else + { + q = q.OrderBy(p => p.Class + p.ClassGroup); + } + + var macInfo = await q.ToListAsync(); + return macInfo; + } + /// /// ///