From 9a7c14853a53c9f12562d0d8ac771b4163f463ea Mon Sep 17 00:00:00 2001 From: "BB.Wang" Date: Thu, 23 Feb 2023 12:33:57 +0800 Subject: [PATCH] =?UTF-8?q?YIRU=E6=9B=B4=E6=96=B0=E7=A8=8B=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E7=84=A1=E5=BA=8F=E8=99=9F=E5=B7=A5=E5=96=AE=E5=85=A5?= =?UTF-8?q?=E5=BA=AB=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 40 +++++++++++++++---- AMESCoreStudio.Web/Views/PCS/PCS024.cshtml | 35 +++++++++++++++- .../AMES/FqcInhouseDetailController.cs | 9 +++-- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 1d04be66..6c9b06df 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -6538,14 +6538,21 @@ namespace AMESCoreStudio.Web.Controllers public async Task PCS024C(string id) { var result = await _pcsApi.GetBarcodeInfoesByNo(id); + if (result.Count > 0) + { + var tt = result[0]; + ViewBag.BarcodeID = tt.BarcodeID; + ViewBag.WipID = tt.WipID; + ViewBag.BarcodeNo = id; - var tt = result[0]; - ViewBag.BarcodeID = tt.BarcodeID; - ViewBag.WipID = tt.WipID; - ViewBag.BarcodeNo = id; - await GetFactoryUnit(); - //await GetStations(); - await GetItems(); + await GetFactoryUnit(); + //await GetStations(); + await GetItems(); + } + else + { + ViewBag.BarcodeNo = "查無序號請重新輸入"; + } return View(); } @@ -6570,6 +6577,20 @@ namespace AMESCoreStudio.Web.Controllers return Json(new Result() { success = true, msg = "" }); } + [HttpGet] + public async Task GetBarcodeInfoesByNoAsync(string id) + { + var result = await _pcsApi.GetBarcodeInfoesByNo(id); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = 1 }); + } + + return Json(new Table() { count = 0, data = null }); + } + + //頁面提交,id=0 添加,id>0 修改 [HttpPost] public async Task PCS024CSaveAsync(BarcodeItem model) @@ -8351,7 +8372,7 @@ namespace AMESCoreStudio.Web.Controllers } #endregion } - + public static class ObjectExtension { public static T GetAttributeFrom(this object instance, string propertyName) where T : Attribute @@ -8362,4 +8383,7 @@ namespace AMESCoreStudio.Web.Controllers return (T)property.GetCustomAttributes(attributeType, false).FirstOrDefault(); } } + + + } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS024.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS024.cshtml index 8c83d445..7d8623e2 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS024.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS024.cshtml @@ -94,9 +94,14 @@ //新增 $('#btnAdd').click(function () { + + var keywords = $('#barcodeNo').val(); + getBarcodeinfo(keywords); var keywords = $('#barcodeNo').val(); if (keywords) - hg.open('新增組件資料', '/PCS/PCS024C/' + keywords, 640, 480); + { + hg.open('新增組件資料', '/PCS/PCS024C/' + keywords, 640, 480); + } else alert("請先輸入內部條碼!!"); }); @@ -112,5 +117,33 @@ var table = hg.table.datatable('test', '組件資料', '/PCS/GetBarcodeItemByUnit?unitId=' + unit + '&barcodeNo=' + barcode, {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']); }; + + + function getBarcodeinfo(barcodeNO) { + if (barcodeNO) { + + $.ajax({ + url: "/PCS/GetBarcodeInfoesByNo", + data: { id: barcodeNO }, + dataType: 'json', + contentType: "application/json", + type: 'get', + success: function (result) { + if (result.data) { + + } + else { + + alert('查無此序號請確認序號是否正確!!!'); + + return false; + } + + } + }); + } + }; + + } \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs index b3cdf6fe..1010329b 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs @@ -259,13 +259,14 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES [HttpDelete("{id}")] public async Task> DeleteFqcInhouseDetail(string id) { - + ResultModel result = new ResultModel(); var fqcInhouseDetail = await _context.FqcInhouseDetails.Where(p => p.InhouseNo == id).FirstOrDefaultAsync(); if (fqcInhouseDetail == null) - { - return NotFound(); - } + { + + return fqcInhouseDetail; + } _context.FqcInhouseDetails.Remove(fqcInhouseDetail); await _context.SaveChangesAsync();