diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index 38880e6f..04bd82a1 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -656,7 +656,6 @@ namespace AMESCoreStudio.Web.Controllers return View(model); } - // 添加 [HttpPost] public async Task FQC007Async(FqcDto model) { @@ -670,17 +669,6 @@ namespace AMESCoreStudio.Web.Controllers result = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); - //if (result.Success) - //{ - // var _msg = "新增成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - //} - //else - //{ - // ModelState.AddModelError("error", result.Msg); - //} - - if (result.Data.Count() != 0) { model = result.Data.FirstOrDefault(); @@ -697,6 +685,7 @@ namespace AMESCoreStudio.Web.Controllers return View("FQC007", model); } + #region 抽驗 [HttpGet] public async Task FQC007C(string inhouseNo, string seq) { @@ -770,6 +759,12 @@ namespace AMESCoreStudio.Web.Controllers NgMemo = model.NgMemo, NgReasonNo = model.NgReasonNo }; + + if (string.IsNullOrWhiteSpace(FqcResultDetail.ExtraBarcodeNo)) + { + ModelState.AddModelError("error", "找不到該筆資料的客戶序號"); + return View("FQC007C", model); + } #endregion #region 判斷已有抽驗過 @@ -827,21 +822,17 @@ namespace AMESCoreStudio.Web.Controllers result = await _fqcApi.PutFqcResultMaster(JsonConvert.SerializeObject(FqcResultMaster)); FqcResultDetail.FqcID = result_FqcResultMaster.FirstOrDefault().FqcID; } - - //IResultModel result_QnfInfo; - - IResultModel result_detail; result_detail = await _fqcApi.PostFqcResultDetail(JsonConvert.SerializeObject(FqcResultDetail)); if (result_detail.Success) { var _msg = "新增成功!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); + return RedirectToAction("WindowReload", "Home", new { msg = _msg }); } else { - ModelState.AddModelError("error", result.Msg); + ModelState.AddModelError("error", result_detail.Msg); } @@ -849,44 +840,59 @@ namespace AMESCoreStudio.Web.Controllers } #endregion + #region 檢驗結果 [HttpGet] - public async Task FQC007B(string inhouseNo, string seq , int fqc) + public async Task FQC007B(string inhouseNo, string seq, int fqc) { var model = new FqcResultMaster(); model.InhouseNo = inhouseNo; model.SeqID = int.Parse(seq); model.FqcID = fqc; + var result = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); + var fqcItem = result.Data.FirstOrDefault(); + + //當抽驗數量 小於 抽樣數量就離開 + if (fqcItem.QcQty > fqcItem.PassQty + fqcItem.FailQty) + { + var _msg = "抽樣數量不足,無法判定"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + + // 判斷狀態選擇 + if (fqcItem.FailQty >= fqcItem.ReQty) + model.QaResult = "R"; + else + model.QaResult = "P"; + return View(model); } [HttpPost] - public async Task FQC007BAsync(FqcResultMaster model) + public async Task FQC007BAsync(FqcResultMaster model, string Result) { - var fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID); - var fqcInhouseMaster = await _fqcApi.GetFqcInhouseMaster(model.InhouseNo, model.SeqID); - if (model.QaResult == "P") + var FqcQuery = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); + var fqcItem = FqcQuery.Data.FirstOrDefault(); + // 判斷狀態選擇 + if (fqcItem.FailQty >= fqcItem.ReQty) { - fqcResultMaster.QaResult = model.QaResult; - fqcResultMaster.QaMeno = model.QaMeno; - fqcResultMaster.EndTime = DateTime.Now; - fqcResultMaster.UpdateDate = DateTime.Now; - - fqcInhouseMaster.Status = model.QaResult; - fqcInhouseMaster.UpdateDate = DateTime.Now; + if (model.QaResult == "P" && string.IsNullOrWhiteSpace(model.SpecialPo)) + { + ModelState.AddModelError("error", "請輸入特採單號"); + return View("FQC007B", model); + } } - else - { - fqcResultMaster.QaResult = model.QaResult; - fqcResultMaster.QaMeno = model.QaMeno; - fqcResultMaster.EndTime = DateTime.Now; - fqcResultMaster.UpdateDate = DateTime.Now; - fqcInhouseMaster.Status = model.QaResult; - fqcInhouseMaster.UpdateDate = DateTime.Now; + var fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID); + var fqcInhouseMaster = await _fqcApi.GetFqcInhouseMaster(model.InhouseNo, model.SeqID); - //var qngInfo = new QngInfo(); - //qngInfo.FqcID = model.FqcID; - } + fqcResultMaster.QaResult = model.QaResult; + fqcResultMaster.QaMeno = model.QaMeno; + fqcResultMaster.EndTime = DateTime.Now; + fqcResultMaster.UpdateDate = DateTime.Now; + fqcResultMaster.SpecialPo = model.SpecialPo; + + fqcInhouseMaster.Status = model.QaResult; + fqcInhouseMaster.UpdateDate = DateTime.Now; IResultModel result; result = await _fqcApi.PutFqcInhouseMaster(JsonConvert.SerializeObject(fqcInhouseMaster)); @@ -894,16 +900,18 @@ namespace AMESCoreStudio.Web.Controllers if (result.Success) { var _msg = "新增成功!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); + return RedirectToAction("WindowReload", "Home", new { msg = _msg }); } else { ModelState.AddModelError("error", result.Msg); } - return View("FQC007B", model); } + #endregion + + #endregion #region FQC008 FQC查詢 public IActionResult FQC008() diff --git a/AMESCoreStudio.Web/Controllers/HomeController.cs b/AMESCoreStudio.Web/Controllers/HomeController.cs index 885bb965..88d35d82 100644 --- a/AMESCoreStudio.Web/Controllers/HomeController.cs +++ b/AMESCoreStudio.Web/Controllers/HomeController.cs @@ -112,6 +112,17 @@ namespace AMESCoreStudio.Web.Controllers return View(); } + /// + /// 彈子視窗關閉後,刷新母視窗整個頁面 + /// + /// Msg提示訊息 + /// + public IActionResult WindowReload(string msg = "保存成功!") + { + ViewBag.Msg = msg; + return View(); + } + public IActionResult Privacy() { return View(); diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml index 20ff146b..118bec7f 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml @@ -205,7 +205,7 @@ -
+