diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 09713100..1f3bc85b 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.StaticFiles; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -26,7 +27,6 @@ using ClosedXML.Excel; namespace AMESCoreStudio.Web.Controllers { - public class PCSController : Controller { @@ -2961,6 +2961,42 @@ namespace AMESCoreStudio.Web.Controllers } } + /// + /// 檔案下載 + /// + /// 路徑 + /// 檔名 + /// + public async Task FileDownload(string Path, string FileName) + { + var path = $@"{_env.WebRootPath}\{Path}{FileName}"; + var memoryStream = new MemoryStream(); + using (var stream = new FileStream(path, FileMode.Open)) + { + await stream.CopyToAsync(memoryStream); + } + memoryStream.Seek(0, SeekOrigin.Begin); + string contentType = await GetFileContentTypeAsync(FileName); + // 回傳檔案到 Client 需要附上 Content Type,否則瀏覽器會解析失敗。 + return File(memoryStream, contentType, FileName); + } + + /// + /// 获取文件ContentType + /// + /// 文件名称 + /// + public async static Task GetFileContentTypeAsync(string fileName) + { + return await Task.Run(() => + { + string suffix = Path.GetExtension(fileName); + var provider = new FileExtensionContentTypeProvider(); + var contentType = provider.Mappings[suffix]; + return contentType; + }); + } + #region PCS034 工單投產可修改 public async Task PCS034(int id) { @@ -7618,7 +7654,7 @@ namespace AMESCoreStudio.Web.Controllers } - private async Task PCS0311inhouse(string InhouseNo, string boxNo, int seq, string recordNumber,string locationNo) + private async Task PCS0311inhouse(string InhouseNo, string boxNo, int seq, string recordNumber, string locationNo) { /* 1.依barcodeinfo 查詢 該箱號所屬序號 * 2.查詢所有序號查詢該流程 是否為最後一個流程(入庫),即在可入庫狀態 @@ -7696,7 +7732,7 @@ namespace AMESCoreStudio.Web.Controllers //修改FQC_inhouse_Master LocationNO var fqcInhouseMaster = await _fqcApi.GetFqcInhouseMaster(InhouseNo, seq); fqcInhouseMaster.LocationNo = locationNo; - + var result_FQC = await _fqcApi.PutFqcInhouseMaster(JsonConvert.SerializeObject(fqcInhouseMaster)); if (!result_FQC.Success) { diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml index 00e25e21..c0c3b18e 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml @@ -471,18 +471,12 @@
- - - + + + @* - - *@ + + *@
@@ -498,9 +492,7 @@
- + @**@
@@ -522,9 +514,7 @@
- +
@@ -853,9 +843,7 @@
- +
@@ -966,8 +954,8 @@ @index.SOPName @* - @index.SOPPath - *@ + @index.SOPPath + *@ @index.SOPTypeName @@ -1027,13 +1015,15 @@ @* 上傳資料sheet *@
+ **預覽只能顯示圖檔、PDF、文字檔**
- - + + + @@ -1049,6 +1039,9 @@ + } @@ -1136,6 +1129,15 @@ }); }; + // 檔案下載 + function filedownload(obj) { + var Path = $(obj).closest("TR").find('span[id*=Filepath]').text(); + var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); + filePath = `/PCS/FileDownload?Path=${Path}&FileName=${FileName}`; + console.log(filePath); + $(obj).attr("href", filePath); + }; + var tableCols = [[ { field: 'unitName', diff --git a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml index 789afbd3..226d0700 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml @@ -1043,47 +1043,52 @@ @* 上傳資料sheet *@ -
-
-
檔案名稱檔案路徑檔案名稱檔案路徑 預覽下載
預覽 + 下載 +
- +
+ **預覽只能顯示圖檔、PDF、文字檔** +
+
+ + + + + + + + + + @foreach (var index in Model.wipInfoBlobs) + { - - - + + + + - - - @foreach (var index in Model.wipInfoBlobs) - { - - - - - - } - -
檔案名稱檔案路徑預覽下載
檔案名稱檔案路徑預覽 + @index.ImageName + + @index.Filepath + + 預覽 + + 下載 +
- @index.ImageName - - @index.Filepath - - 預覽 -
-
-
-
- - - -
+ } + + +
+
+
+ + +
+
@Html.ValidationMessage("error") @@ -1369,6 +1374,15 @@ }); }; + // 檔案下載 + function filedownload(obj) { + var Path = $(obj).closest("TR").find('span[id*=Filepath]').text(); + var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); + filePath = `/PCS/FileDownload?Path=${Path}&FileName=${FileName}`; + console.log(filePath); + $(obj).attr("href", filePath); + }; + function getFlowRuleList(data) { $.ajax( diff --git a/AMESCoreStudio.Web/Views/PCS/PCS034.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS034.cshtml index 8a4f2ead..f78021fa 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS034.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS034.cshtml @@ -25,9 +25,9 @@ - @* *@ + @* *@ - @* *@ + @* *@ @@ -941,8 +941,8 @@ SOP文件敘述 @* - 檔案路徑 - *@ + 檔案路徑 + *@ SOP類型 @@ -963,8 +963,8 @@ @* - - *@ + + *@ @@ -1031,47 +1031,52 @@
@* 上傳資料sheet *@ -
-
- - +
+ **預覽只能顯示圖檔、PDF、文字檔** +
+
+ + + + + + + + + + @foreach (var index in Model.wipInfoBlobs) + { - - - + + + + - - - @foreach (var index in Model.wipInfoBlobs) - { - - - - - - } - -
檔案名稱檔案路徑預覽下載
檔案名稱檔案路徑預覽 + @index.ImageName + + @index.Filepath + + 預覽 + + 下載 +
- @index.ImageName - - @index.Filepath - - 預覽 -
-
-
-
- - - -
+ } + + +
+
+
+ + +
+
@Html.ValidationMessage("error") @@ -1311,6 +1316,15 @@ }); }; + // 檔案下載 + function filedownload(obj) { + var Path = $(obj).closest("TR").find('span[id*=Filepath]').text(); + var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); + filePath = `/PCS/FileDownload?Path=${Path}&FileName=${FileName}`; + console.log(filePath); + $(obj).attr("href", filePath); + }; + function getFlowRuleList(data) { $.ajax( diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index 6f985630..d35a745c 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -736,7 +736,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { q = q.Where(w => w.factoryNo == value.factoryno); } - + q.Take(1000); // 紀錄筆數 result.DataTotal = q.Count();