From 8b3f1748c7bb04016918ada2ec33cfaff6c365f6 Mon Sep 17 00:00:00 2001 From: Sai Date: Fri, 2 Jan 2026 09:56:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=20PCS002=E8=88=87PCS005=20=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E4=BA=86=20=E5=81=9C=E7=94=A8/=E5=95=9F=E7=94=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=202.=20PCS006=E6=96=B0=E5=A2=9E=E5=88=A4=E6=96=B7?= =?UTF-8?q?=E5=81=9C=E7=94=A8=E6=99=82=EF=BC=8C=E7=84=A1=E6=B3=95=E9=BB=9E?= =?UTF-8?q?=E6=93=8A=E9=96=8B=E7=B7=9A=203.=20=E9=81=8E=E7=AB=99=E5=88=A4?= =?UTF-8?q?=E6=96=B7=E5=B7=A5=E5=96=AE=E7=8B=80=E6=85=8B=E6=98=AF=E5=81=9C?= =?UTF-8?q?=E7=94=A8=204.=20Table=20WIP=5FSTATUS=20=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?=E7=8B=80=E6=85=8B=3D>D=20=E6=8F=8F=E8=BF=B0=3D>Disable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 144 ++++++++++++++++++ AMESCoreStudio.Web/Views/PCS/PCS002.cshtml | 97 +++++++++++- AMESCoreStudio.Web/Views/PCS/PCS005.cshtml | 86 +++++++++-- AMESCoreStudio.Web/Views/PCS/PCS006.cshtml | 2 +- .../Controllers/AMES/WipInfosController.cs | 25 ++- .../BLL/BarCodeCheckNewController.cs | 48 +++--- 6 files changed, 346 insertions(+), 56 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 08c3ec4..6437d9b 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -3447,6 +3447,7 @@ namespace AMESCoreStudio.Web.Controllers /// public async Task PCS002QueryAsync(string unitno, string wipNo, string itemNo, int page = 0, int limit = 10) { + // 查詢 N 狀態 已會排除 E與C狀態 IResultModel result = await _pcsApi.GetWipInfoSelectParameter(unitno: unitno , wipno: wipNo , itemno: itemNo @@ -3458,8 +3459,80 @@ namespace AMESCoreStudio.Web.Controllers { return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); } + return Json(new Table() { count = 0, data = null }); } + + /// + /// PCS002 停用/啟用工單 + /// + /// 工單ID + /// 目前狀態 + /// 目標狀態 (D=停用, N=啟用) + /// + [HttpPost] + public async Task PCS002ToggleStatus(int wipID, string currentStatus, string targetStatus) + { + try + { + // 驗證狀態切換是否合法 + if (currentStatus == "E" || currentStatus == "C") + { + return Json(new Result() { success = false, msg = "已完工或已刪除的工單無法停用/啟用" }); + } + + // 停用操作:只有 A、N、S 狀態可以停用 + if (targetStatus == "D") + { + if (currentStatus != "A" && currentStatus != "N" && currentStatus != "S") + { + return Json(new Result() { success = false, msg = "只有 A、N、S 狀態的工單可以停用" }); + } + } + // 啟用操作:只有 D 狀態可以啟用 + else if (targetStatus == "N") + { + if (currentStatus != "D") + { + return Json(new Result() { success = false, msg = "只有停用狀態的工單可以啟用" }); + } + } + else + { + return Json(new Result() { success = false, msg = "無效的狀態值" }); + } + + // 檢查工單是否存在 + var wipInfo = await _pcsApi.GetWipInfo(wipID); + if (wipInfo == null || wipInfo.Count == 0) + { + return Json(new Result() { success = false, msg = "工單不存在" }); + } + + // 更新工單狀態 + WipLog wipLog = new WipLog(); + wipLog.WipID = wipID; + wipLog.WipDesc = "."; + wipLog.StatusNO = targetStatus; + wipLog.CreateUserID = GetLogInUserID(); + await _pcsApi.PostWipLog(JsonConvert.SerializeObject(wipLog)); + var result = await _pcsApi.PutWipinfoToStatusNO(wipID, targetStatus); + + if (result.Success) + { + var action = targetStatus == "D" ? "停用" : "啟用"; + return Json(new Result() { success = true, msg = action + "成功" }); + } + else + { + return Json(new Result() { success = false, msg = result.Msg ?? "操作失敗" }); + } + } + catch (Exception ex) + { + return Json(new Result() { success = false, msg = "系統錯誤:" + ex.Message }); + } + } #endregion #region PCS004 工單內部條碼區間設定 @@ -3914,6 +3987,77 @@ namespace AMESCoreStudio.Web.Controllers var result = await _pcsApi.DeleteWipinfo(id); return Json(new Result() { success = true, msg = "刪除成功" }); } + + /// + /// PCS005 停用/啟用工單 + /// + /// 工單ID + /// 目前狀態 + /// 目標狀態 (D=停用, N=啟用) + /// + [HttpPost] + public async Task PCS005ToggleStatus(int wipID, string currentStatus, string targetStatus) + { + try + { + // 驗證狀態切換是否合法 + if (currentStatus == "E" || currentStatus == "C") + { + return Json(new Result() { success = false, msg = "已完工或已刪除的工單無法停用/啟用" }); + } + + // 停用操作:只有 A、N、S 狀態可以停用 + if (targetStatus == "D") + { + if (currentStatus != "A" && currentStatus != "N" && currentStatus != "S") + { + return Json(new Result() { success = false, msg = "只有 A、N、S 狀態的工單可以停用" }); + } + } + // 啟用操作:只有 D 狀態可以啟用 + else if (targetStatus == "N") + { + if (currentStatus != "D") + { + return Json(new Result() { success = false, msg = "只有停用狀態的工單可以啟用" }); + } + } + else + { + return Json(new Result() { success = false, msg = "無效的狀態值" }); + } + + // 檢查工單是否存在 + var wipInfo = await _pcsApi.GetWipInfo(wipID); + if (wipInfo == null || wipInfo.Count == 0) + { + return Json(new Result() { success = false, msg = "工單不存在" }); + } + + // 更新工單狀態 + WipLog wipLog = new WipLog(); + wipLog.WipID = wipID; + wipLog.WipDesc = "."; + wipLog.StatusNO = targetStatus; + wipLog.CreateUserID = GetLogInUserID(); + await _pcsApi.PostWipLog(JsonConvert.SerializeObject(wipLog)); + var result = await _pcsApi.PutWipinfoToStatusNO(wipID, targetStatus); + + if (result.Success) + { + var action = targetStatus == "D" ? "停用" : "啟用"; + return Json(new Result() { success = true, msg = action + "成功" }); + } + else + { + return Json(new Result() { success = false, msg = result.Msg ?? "操作失敗" }); + } + } + catch (Exception ex) + { + return Json(new Result() { success = false, msg = "系統錯誤:" + ex.Message }); + } + } #endregion #region PCS006 工單開線收線作業 diff --git a/AMESCoreStudio.Web/Views/PCS/PCS002.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS002.cshtml index ba24fff..405fb84 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS002.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS002.cshtml @@ -6,6 +6,19 @@ Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + +
@@ -56,15 +69,13 @@ @section Scripts{ diff --git a/AMESCoreStudio.Web/Views/PCS/PCS005.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS005.cshtml index c290e84..e5b5a09 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS005.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS005.cshtml @@ -7,12 +7,16 @@ }
@@ -60,6 +64,7 @@ @@ -132,7 +137,6 @@ } }); - }); //监听表单提交事件 @@ -212,11 +216,29 @@ }, { field: 'right', - width: 80, + width: 150, title: '@Localizer["Action"]', fixed: 'right', templet: function (d) { - return '@Localizer["View"]' + var detailBtn = '@Localizer["View"]'; + var toggleBtn = ''; + + // 如果是停用狀態,嘗試設置整行樣式 + if (d.statusNo === 'D') { + setTimeout(function () { + var index = d.LAY_TABLE_INDEX; + $('.layui-table-view[lay-id="query"] tr[data-index="' + index + '"]').addClass('layui-table-gray-row'); + }, 100); + } + + if (d.statusNo === 'D') { + // 狀態為 D(停用)時顯示啟用按鈕 + toggleBtn = '啟用'; + } else if (d.statusNo === 'A' || d.statusNo === 'N' || d.statusNo === 'S') { + // 狀態為 A、N 或 S 時顯示停用按鈕 + toggleBtn = '停用'; + } + return detailBtn + ' ' + toggleBtn; } } ] @@ -260,6 +282,50 @@ }); } + // 停用/啟用工單 + function toggleStatus(obj, targetStatus) { + var action = targetStatus === 'D' ? '停用' : '啟用'; + var confirmMsg = '確定要' + action + '工單號碼【' + obj.data.wipNo + '】嗎?'; + + hg.confirm(confirmMsg, function () { + $.ajax({ + url: '/PCS/PCS005ToggleStatus', + data: { + wipID: obj.data.wipID, + currentStatus: obj.data.statusNo, + targetStatus: targetStatus + }, + type: 'POST', + success: function (data) { + if (data.success) { + hg.msghide(action + '成功!'); + // 重新載入表格 + layui.use('table', function () { + var table = layui.table; + table.reload('query'); + }); + } + else { + hg.msg(data.msg); + } + }, + error: function () { + hg.msg("網路請求失敗!"); + } + }); + }); + } + + //通过行tool停用,lay-event="disable" + function disable(obj) { + toggleStatus(obj, 'D'); + } + + //通过行tool啟用,lay-event="enable" + function enable(obj) { + toggleStatus(obj, 'N'); + } + var param = unitNo.value + '_' + wipNo.value + '_' + itemNo.value + '_' + factoryNo.value; var table = hg.table.datatable('query', '工單資料查詢', '/PCS/PCS005Query/' + param, {}, tableCols, "", true, 'full-100', ['filter', 'print', 'exports']); @@ -269,6 +335,8 @@ {{ '完工' }} {{# } else if(d.statusNo === 'C'){ }} {{ '刪除' }} + {{# } else if(d.statusNo === 'D'){ }} + {{ '停用' }} {{# } else { }} {{ '未完工' }} {{# } }} diff --git a/AMESCoreStudio.Web/Views/PCS/PCS006.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS006.cshtml index b6cd38f..14cc23a 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS006.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS006.cshtml @@ -71,7 +71,7 @@