diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 8dbec80e..22aa8b97 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -5917,7 +5917,7 @@ namespace AMESCoreStudio.Web.Controllers if (ModelState.IsValid) { IResultModel result; - result = await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(model)); + result = await _pcsApi.PostBarcodeItemAddnew(JsonConvert.SerializeObject(model)); if (result.Success) @@ -5964,13 +5964,12 @@ namespace AMESCoreStudio.Web.Controllers [ResponseCache(Duration = 0)] [HttpGet] - public async Task GetBarcodeItemByUnitAsync(string ID) + public async Task GetBarcodeItemByUnit2Async(string ID) { string str, str1; var strA = ID.Split("="); str = strA[0]; str1 = strA[1]; - //WO0002A10001 if (ID is null) return Json(new Table() { count = 0, data = null }); @@ -5986,6 +5985,30 @@ namespace AMESCoreStudio.Web.Controllers return Json(new Table() { count = 0, data = null }); } + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetBarcodeItemByUnitAsync(string unitId,string barcodeNo) + { + //string str, str1; + //var strA = ID.Split("="); + //str = strA[0]; + //str1 = strA[1]; + //WO0002A10001 + + if (barcodeNo is null) + return Json(new Table() { count = 0, data = null }); + + var result = await _pcsApi.GetBItemByStr(unitId, barcodeNo); + //var result = await _pcsApi.GetBarcodeItemByUnit(ID); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + #endregion #region PCS027 組件資料整批刪除 diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 680571f8..380106fd 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -808,6 +808,13 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpPost("api/BarcodeItems")] ITask> PostBarcodeItem([FromBody, RawJsonContent] string model); + /// + /// 新增組件 + /// + /// + [WebApiClient.Attributes.HttpPost("api/BarcodeItems/PCS024")] + ITask> PostBarcodeItemAddnew([FromBody, RawJsonContent] string model); + /// /// 更新組件 /// diff --git a/AMESCoreStudio.Web/Views/PCS/PCS024.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS024.cshtml index 56af9284..ce8a025d 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS024.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS024.cshtml @@ -1,221 +1,108 @@ -@{ - ViewData["Title"] = "组件資料新增"; - Layout = "~/Views/Shared/_AMESLayout.cshtml"; -} - -
-
-
-
-
@ViewBag.Title
-
-
-
-
-
-
-
- -
- -
- -
-
- -
-
-
- - -
-
-
-
- -
-
-
-
-
-@section Scripts{ - - +@{ + ViewData["Title"] = "组件資料新增"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+ +
+
+
+
+
+@section Scripts{ + } \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/PCS/PCS024C.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS024C.cshtml index 988176df..c08e7e85 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS024C.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS024C.cshtml @@ -34,7 +34,7 @@ - +
@@ -84,7 +84,7 @@ $("#Role").change(function () { var data = $("#Role").val(); console.info(data); - $("#RuleStationID").val(data); + $("#StationID").val(data); }) function getRoles(data) { diff --git a/AMESCoreStudio.Web/Views/PCS/PCS025.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS025.cshtml index 0dcaa9eb..abe614ea 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS025.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS025.cshtml @@ -148,7 +148,7 @@ if (keywords) { hg.msghide("刷新数据!"); table.reload('test', { - url: '/PCS/GetBarcodeItemByUnit/', + url: '/PCS/GetBarcodeItemByUnit2/', where: { ID: aa } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS026.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS026.cshtml index 9ae54a2f..249b3226 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS026.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS026.cshtml @@ -171,7 +171,7 @@ if (keywords) { hg.msghide("刷新数据!"); table.reload('test', { - url: '/PCS/GetBarcodeItemByUnit/', + url: '/PCS/GetBarcodeItemByUnit2/', where: { ID: aa } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs index 92c7746f..fcba13ab 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs @@ -502,7 +502,49 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES //_context.Entry(barcodeItem.B).State = EntityState.Detached; //_context.BarcodeItems.Add(barcodeItem); _context.Set().Add(barcodeItem); - + + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + } + + /// + /// 新增條碼资料 + /// + /// + /// + // POST: api/BarcodeItems + // To protect from overposting attacks, enable the specific properties you want to bind to, for + // more details, see https://go.microsoft.com/fwlink/?linkid=2123754. + [HttpPost("PCS024")] + public async Task> PostBarcodeItemsAddnew(BarcodeItem barcodeItem) + { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + barcodeItem.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result; + barcodeItem.B.BarcodeID = barcodeItem.BarcodeID; + + if (PartNoExists(barcodeItem.PartNo)) + { + result.Success = false; + result.Msg = "組件條碼重複"; + return result; + } + + try + { + _context.BarcodeItems.Add(barcodeItem); + _context.Entry(barcodeItem.B).State = EntityState.Detached; + _context.Entry(barcodeItem).State = EntityState.Added; + //_context.Set().Add(barcodeItem); + await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK";