Browse Source

1. 工單資料 上傳檔案加入檔案下載功能

PTD
ray 2 years ago
parent
commit
d105cabda8
  1. 40
      AMESCoreStudio.Web/Controllers/PCSController.cs
  2. 50
      AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml
  3. 86
      AMESCoreStudio.Web/Views/PCS/PCS003.cshtml
  4. 98
      AMESCoreStudio.Web/Views/PCS/PCS034.cshtml
  5. 2
      AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs

40
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
}
}
/// <summary>
/// 檔案下載
/// </summary>
/// <param name="Path">路徑</param>
/// <param name="FileName">檔名</param>
/// <returns></returns>
public async Task<IActionResult> 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);
}
/// <summary>
/// 获取文件ContentType
/// </summary>
/// <param name="fileName">文件名称</param>
/// <returns></returns>
public async static Task<string> 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<IActionResult> PCS034(int id)
{
@ -7618,7 +7654,7 @@ namespace AMESCoreStudio.Web.Controllers
}
private async Task<Result> PCS0311inhouse(string InhouseNo, string boxNo, int seq, string recordNumber,string locationNo)
private async Task<Result> PCS0311inhouse(string InhouseNo, string boxNo, int seq, string recordNumber, string locationNo)
{
/* 1.barcodeinfo
* 2. ()

50
AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml

@ -471,18 +471,12 @@
<label class="layui-form-label">DIP</label>
<div class="layui-input-block">
<cl-checkbox asp-items="@ViewBag.GetCheckboxDIP" asp-for="wipBoard.DipSides" asp-skin="defult"></cl-checkbox>
<input @if (Model.wipBoard != null) {
@(Model.wipBoard.DipCarrier == "Y" ? "checked" : "")
} type="checkbox" title="CARRIER" name="wipBoard.DipCarrier" />
<input @if (Model.wipBoard != null) {
@(Model.wipBoard.DipTape == "Y" ? "checked" : "")
} type="checkbox" title="貼付膠帶" name="wipBoard.DipTape" />
<input @if (Model.wipBoard != null) {
@(Model.wipBoard.DipSolderMask == "Y" ? "checked" : "")
} type="checkbox" title="點防焊膠" name="wipBoard.SmdSolderMask" />
<input @if (Model.wipBoard != null) { @(Model.wipBoard.DipCarrier == "Y" ? "checked" : "") } type="checkbox" title="CARRIER" name="wipBoard.DipCarrier" />
<input @if (Model.wipBoard != null) { @(Model.wipBoard.DipTape == "Y" ? "checked" : "") } type="checkbox" title="貼付膠帶" name="wipBoard.DipTape" />
<input @if (Model.wipBoard != null) { @(Model.wipBoard.DipSolderMask == "Y" ? "checked" : "") } type="checkbox" title="點防焊膠" name="wipBoard.SmdSolderMask" />
@*<input asp-for="wipBoard.DipCarrier" type="checkbox" title="CARRIER" />
<input asp-for="wipBoard.DipTape" type="checkbox" title="貼付膠帶" />
<input asp-for="wipBoard.SmdSolderMask" type="checkbox" title="點防焊膠" />*@
<input asp-for="wipBoard.DipTape" type="checkbox" title="貼付膠帶" />
<input asp-for="wipBoard.SmdSolderMask" type="checkbox" title="點防焊膠" />*@
</div>
</div>
</div>
@ -498,9 +492,7 @@
<div class="layui-inline">
<label class="layui-form-label">燒錄</label>
<div class="layui-input-inline">
<input @if (Model.wipBoard != null) {
@(Model.wipBoard.Burn == "Y" ? "checked" : "")
} type="checkbox" title="是否燒入" name="wipBoard.Burn" />
<input @if (Model.wipBoard != null) { @(Model.wipBoard.Burn == "Y" ? "checked" : "") } type="checkbox" title="是否燒入" name="wipBoard.Burn" />
@*<input asp-for="wipBoard.Burn" type="checkbox" title="是否燒入" />*@
</div>
<div class="layui-input-inline">
@ -522,9 +514,7 @@
<div class="layui-form-item">
<div class="layui-inline">
<input @if (Model.wipBoard != null) {
@(Model.wipBoard.ISPartsBake == "Y" ? "checked" : "")
} type="checkbox" title="零件是否需要烘烤" name="wipBoard.ISPartsBake" />
<input @if (Model.wipBoard != null) { @(Model.wipBoard.ISPartsBake == "Y" ? "checked" : "") } type="checkbox" title="零件是否需要烘烤" name="wipBoard.ISPartsBake" />
</div>
<div class="layui-inline">
<label class="layui-form-label">零件烘烤溫度</label>
@ -853,9 +843,7 @@
<div class="layui-inline">
<label class="layui-form-label">FINE_PACKAGE</label>
<div class="layui-input-inline">
<input type="checkbox" title="是否為精裝" @if (Model.wipSystem != null) {
@(Model.wipSystem.FinePackage == "Y" ? "checked" : "")
} />
<input type="checkbox" title="是否為精裝" @if (Model.wipSystem != null) { @(Model.wipSystem.FinePackage == "Y" ? "checked" : "") } />
</div>
</div>
@ -966,8 +954,8 @@
@index.SOPName
</td>
@*<td>
@index.SOPPath
</td>*@
@index.SOPPath
</td>*@
<td>
@index.SOPTypeName
</td>
@ -1027,13 +1015,15 @@
@* 上傳資料sheet *@
<div class="layui-tab-item">
<span style="color:red">**預覽只能顯示圖檔、PDF、文字檔**</span>
<div class="layui-form-item">
<table lay-filter="demo" class="layui-table">
<thead>
<tr>
<th lay-data="{field:'username', width:100}">檔案名稱</th>
<th lay-data="{field:'experience', width:80, sort:true}">檔案路徑</th>
<th lay-data="{field:'username'}">檔案名稱</th>
<th lay-data="{field:'experience', sort:true}">檔案路徑</th>
<th lay-data="{field:'right', width:80, sort:true}">預覽</th>
<th lay-data="{field:'right', width:80, sort:true}">下載</th>
</tr>
</thead>
<tbody>
@ -1049,6 +1039,9 @@
<td>
<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" onclick="show(this)">預覽</a>
</td>
<td>
<a class="layui-btn layui-btn-normal layui-btn-xs" onclick="filedownload(this)">下載</a>
</td>
</tr>
}
</tbody>
@ -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',

86
AMESCoreStudio.Web/Views/PCS/PCS003.cshtml

@ -1043,47 +1043,52 @@
</div>
@* 上傳資料sheet *@
<div class="layui-tab-item">
<div class="layui-form-item">
<table lay-filter="demo" class="layui-table">
<thead>
<div class="layui-tab-item">
<span style="color:red">**預覽只能顯示圖檔、PDF、文字檔**</span>
<div class="layui-form-item">
<table lay-filter="demo" class="layui-table">
<thead>
<tr>
<th lay-data="{field:'username'}">檔案名稱</th>
<th lay-data="{field:'experience', sort:true}">檔案路徑</th>
<th lay-data="{field:'right', width:80, sort:true}">預覽</th>
<th lay-data="{field:'right', width:80, sort:true}">下載</th>
</tr>
</thead>
<tbody>
@foreach (var index in Model.wipInfoBlobs)
{
<tr>
<th lay-data="{field:'username', width:100}">檔案名稱</th>
<th lay-data="{field:'experience', width:80, sort:true}">檔案路徑</th>
<th lay-data="{field:'right', width:80, sort:true}">預覽</th>
<td>
<span id="FileName">@index.ImageName</span>
</td>
<td>
<span id="Filepath">@index.Filepath</span>
</td>
<td>
<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" onclick="show(this)">預覽</a>
</td>
<td>
<a class="layui-btn layui-btn-normal layui-btn-xs" onclick="filedownload(this)">下載</a>
</td>
</tr>
</thead>
<tbody>
@foreach (var index in Model.wipInfoBlobs)
{
<tr>
<td>
<span id="FileName">@index.ImageName</span>
</td>
<td>
<span id="Filepath">@index.Filepath</span>
</td>
<td>
<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" onclick="show(this)">預覽</a>
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label" asp-for="wipInfoBlob.ImageName">檔案</label>
<label class="layui-btn">
<input type="file" name="formFile">
@*<i class="layui-icon">&#xe67c;</i>上傳文件*@
</label>
<input type="hidden" asp-for="wipInfoBlob.ImageName">
</div>
}
</tbody>
</table>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label" asp-for="wipInfoBlob.ImageName">檔案</label>
<label class="layui-btn">
<input type="file" name="formFile">
@*<i class="layui-icon">&#xe67c;</i>上傳文件*@
</label>
<input type="hidden" asp-for="wipInfoBlob.ImageName">
</div>
</div>
</div>
</div>
</div>
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span>
@ -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(

98
AMESCoreStudio.Web/Views/PCS/PCS034.cshtml

@ -25,9 +25,9 @@
<input asp-for="wipInfo.WipID" type="hidden" value="@Model.wipInfo.WipID" />
<input asp-for="wipInfo.UnitNO" type="hidden" value="@Model.wipInfo.UnitNO" />
<input asp-for="wipInfo.WipNO" type="hidden" value="@Model.wipInfo.WipNO" />
@* <input asp-for="wipInfo.PlanQTY" type="hidden" value="@Model.wipInfo.PlanQTY" />*@
@* <input asp-for="wipInfo.PlanQTY" type="hidden" value="@Model.wipInfo.PlanQTY" />*@
<input asp-for="wipInfo.WipType" type="hidden" value="@Model.wipInfo.WipType" />
@* <input asp-for="wipInfo.FlowRuleID" type="hidden" value="@Model.wipInfo.FlowRuleID" />*@
@* <input asp-for="wipInfo.FlowRuleID" type="hidden" value="@Model.wipInfo.FlowRuleID" />*@
<input asp-for="wipAtt.ItemNO" type="hidden" value="@Model.wipAtt.ItemNO" />
<input asp-for="wipBarcodeOther.OtherID" type="hidden" value="@if(Model.wipBarcodeOther != null){ @Model.wipBarcodeOther.OtherID }" />
<input asp-for="wipMAC.WipNO" type="hidden" value="@if(Model.wipMAC != null){ @Model.wipMAC.WipNO }" />
@ -941,8 +941,8 @@
SOP文件敘述
</th>
@*<th>
檔案路徑
</th>*@
檔案路徑
</th>*@
<th>
SOP類型
</th>
@ -963,8 +963,8 @@
<input onkeypress="if( event.keyCode == 13 ) { return false; }" class="layui-input" asp-for="@index.SOPName" name="WipSops[@i].SOPName" />
</td>
@*<td>
<input onkeypress="if( event.keyCode == 13 ) { return false; }" class="layui-input" asp-for="@index.SOPPath" name="WipSops[@i].SOPPath" />
</td>*@
<input onkeypress="if( event.keyCode == 13 ) { return false; }" class="layui-input" asp-for="@index.SOPPath" name="WipSops[@i].SOPPath" />
</td>*@
<td>
<select asp-for="@index.SOPType" name="WipSops[@i].SOPType" asp-items="@ViewBag.GetSOPTypeSelect" class=""></select>
</td>
@ -1031,47 +1031,52 @@
</div>
@* 上傳資料sheet *@
<div class="layui-tab-item">
<div class="layui-form-item">
<table lay-filter="demo" class="layui-table">
<thead>
<div class="layui-tab-item">
<span style="color:red">**預覽只能顯示圖檔、PDF、文字檔**</span>
<div class="layui-form-item">
<table lay-filter="demo" class="layui-table">
<thead>
<tr>
<th lay-data="{field:'username', width:100}">檔案名稱</th>
<th lay-data="{field:'experience', width:80, sort:true}">檔案路徑</th>
<th lay-data="{field:'right', width:80, sort:true}">預覽</th>
<th lay-data="{field:'right', width:80, sort:true}">下載</th>
</tr>
</thead>
<tbody>
@foreach (var index in Model.wipInfoBlobs)
{
<tr>
<th lay-data="{field:'username', width:100}">檔案名稱</th>
<th lay-data="{field:'experience', width:80, sort:true}">檔案路徑</th>
<th lay-data="{field:'right', width:80, sort:true}">預覽</th>
<td>
<span id="FileName">@index.ImageName</span>
</td>
<td>
<span id="Filepath">@index.Filepath</span>
</td>
<td>
<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" onclick="show(this)">預覽</a>
</td>
<td>
<a class="layui-btn layui-btn-normal layui-btn-xs" onclick="filedownload(this)">下載</a>
</td>
</tr>
</thead>
<tbody>
@foreach (var index in Model.wipInfoBlobs)
{
<tr>
<td>
<span id="FileName">@index.ImageName</span>
</td>
<td>
<span id="Filepath">@index.Filepath</span>
</td>
<td>
<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" onclick="show(this)">預覽</a>
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label" asp-for="wipInfoBlob.ImageName">檔案</label>
<label class="layui-btn">
<input type="file" name="formFile">
@*<i class="layui-icon">&#xe67c;</i>上傳文件*@
</label>
<input type="hidden" asp-for="wipInfoBlob.ImageName">
</div>
}
</tbody>
</table>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label" asp-for="wipInfoBlob.ImageName">檔案</label>
<label class="layui-btn">
<input type="file" name="formFile">
@*<i class="layui-icon">&#xe67c;</i>上傳文件*@
</label>
<input type="hidden" asp-for="wipInfoBlob.ImageName">
</div>
</div>
</div>
</div>
</div>
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span>
@ -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(

2
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();

Loading…
Cancel
Save