diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index b8189b17..f283b2a5 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -1469,6 +1469,10 @@ namespace AMESCoreStudio.Web.Controllers var model = await _fqcApi.GetFqcResultMasterBlobByFqcID(fqc); fqcDto.fqcResultMasterBlobs = model; fqcDto.FqcID = fqc; + // 取檢驗結果 + var fqcResult = await _fqcApi.GetFqcResultMaster(fqc); + if (fqcResult != null) + fqcDto.StatusName = fqcResult.QaResult; return View(fqcDto); } @@ -1559,6 +1563,19 @@ namespace AMESCoreStudio.Web.Controllers return File(memoryStream, contentType, FileName); } + /// + /// 刪除工單檔案 + /// + /// 工單號碼 + /// 檔案名稱 + /// + [HttpPost] + public async Task DeleteFqcResultMasterBlob(int fqcId, string fileName) + { + var result = await _fqcApi.DeleteFqcResultMasterBlob(fqcId, fileName); + return Json(new Result() { success = result.Success, msg = result.Msg, data = null }); + } + /// /// 获取文件ContentType /// diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index 16fda0cd..424c17e2 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -508,6 +508,16 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpDelete("api/FqcResultMaster/{id}")] ITask> DeleteFqcResultMaster(int id); + + /// + /// 刪除FQC 附件檔案 + /// + /// + /// + /// + [WebApiClient.Attributes.HttpDelete("api/FqcResultMasterBlob/ByFileName")] + ITask> DeleteFqcResultMasterBlob(int fqcId, string fileName); + #endregion #region FQC008 FQC查詢 diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml index 890f1625..1bfe5e1e 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml @@ -674,7 +674,7 @@ layer.open({ title: '文件上傳', type: 2, - area: ['600px', '400px'], + area: ['1000px', '400px'], fixed: false, //不固定 maxmin: true, content: '/FQC/FQC007D?fqc=@Model.FqcID' diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml index fd8804b9..3d10b031 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml @@ -21,7 +21,7 @@ 檔案名稱 檔案路徑 預覽 - 下載 + 功能 @@ -39,6 +39,7 @@ 下載 + } @@ -73,7 +74,7 @@ }); - //通过行tool编辑,lay-event="show" + //通过行tool編輯,lay-event="show" function show(obj) { var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();; var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();; @@ -104,7 +105,41 @@ if ($(error).text() != '') { parent.hg.msg(error); } + + if ('@Model.StatusName' == "A"){ + $("#deleteFile").show(); + } }); + + // 檔案刪除 + function deleteFile(obj) { + var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); + layer.confirm(`確定是否要刪除【${FileName}】檔案?`, { + btn: ['確定', '取消'] + }, function () { + layer.closeAll('dialog'); + $.ajax({ + url: '@Url.Action("DeleteFqcResultMasterBlob", "FQC")', + dataType: 'json', + data: { "fqcId": '@Model.FqcID', "fileName": FileName }, + cache: false, + type: "POST", + success: function (result) { + // 錯誤訊息 + if (!result.success) { + parent.hg.msg(result.msg); + } + else { + var row = $(obj).closest("TR"); + row.hide(); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert("檔案刪除失敗,請洽系統管理員!!"); + } + }); + }) + } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC008.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC008.cshtml index 98f2b0d3..c0a6ca03 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC008.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC008.cshtml @@ -265,7 +265,7 @@ //alert(param); //基本数据表格 //var table = hg.table.datatable('query', 'FQC查詢', '/FQC/FQC008Query2/' + param, {}, tableCols, '', true, 'full-100', ['filter', 'print', 'exports']); - var table = hg.table.datatable('query', 'FQC查詢', '/FQC/FQC008Query2', { factoryID: $("#factoryID").val() }, tableCols, '', true, 'full-100', ['filter', 'print', 'exports']); + var table = hg.table.datatable('query', 'FQC查詢', '/FQC/FQC008Query2', { factoryID: $("#factoryID").val() }, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']); //通过行tool编辑,lay-event="edit" function edit(obj) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs index b5eb65de..530943a0 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs @@ -112,20 +112,43 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - // DELETE: api/FqcResultMasterBlob/5 - [HttpDelete("{id}")] - public async Task> DeleteFqcResultMasterBlob(int id) + /// + /// 刪除 FQC附件 + /// + /// fqcId + /// 檔案名稱 + /// + [HttpDelete("ByFileName")] + public async Task> DeleteFqcResultMasterBlob(int fqcId, string fileName) { - var fqcResultMasterBlob = await _context.FqcResultMasterBlobs.FindAsync(id); - if (fqcResultMasterBlob == null) + ResultModel result = new ResultModel(); + if (fqcId == 0 || string.IsNullOrWhiteSpace(fileName)) { - return NotFound(); + result.Success = false; + result.Msg = "請輸入要刪除的資料"; } - - _context.FqcResultMasterBlobs.Remove(fqcResultMasterBlob); - await _context.SaveChangesAsync(); - - return fqcResultMasterBlob; + else + { + var fqcResultMasterBlobs = await _context.FqcResultMasterBlobs.Where(w => w.FqcID == fqcId && + w.ImageName.Trim().ToUpper() == fileName.Trim().ToUpper()).ToListAsync(); + + if (fqcResultMasterBlobs.Count() != 0) + { + try + { + _context.FqcResultMasterBlobs.Remove(fqcResultMasterBlobs.FirstOrDefault()); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + } + } + return result; } private bool FqcResultMasterBlobExists(int id)