Browse Source

1. FQC抽驗查詢加入匯出功能

2. FQC附件加入刪除功能
PTD
Sai 2 years ago
parent
commit
afeb899549
  1. 17
      AMESCoreStudio.Web/Controllers/FQCController.cs
  2. 10
      AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs
  3. 2
      AMESCoreStudio.Web/Views/FQC/FQC007.cshtml
  4. 39
      AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml
  5. 2
      AMESCoreStudio.Web/Views/FQC/FQC008.cshtml
  6. 45
      AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs

17
AMESCoreStudio.Web/Controllers/FQCController.cs

@ -1469,6 +1469,10 @@ namespace AMESCoreStudio.Web.Controllers
var model = await _fqcApi.GetFqcResultMasterBlobByFqcID(fqc); var model = await _fqcApi.GetFqcResultMasterBlobByFqcID(fqc);
fqcDto.fqcResultMasterBlobs = model; fqcDto.fqcResultMasterBlobs = model;
fqcDto.FqcID = fqc; fqcDto.FqcID = fqc;
// 取檢驗結果
var fqcResult = await _fqcApi.GetFqcResultMaster(fqc);
if (fqcResult != null)
fqcDto.StatusName = fqcResult.QaResult;
return View(fqcDto); return View(fqcDto);
} }
@ -1559,6 +1563,19 @@ namespace AMESCoreStudio.Web.Controllers
return File(memoryStream, contentType, FileName); return File(memoryStream, contentType, FileName);
} }
/// <summary>
/// 刪除工單檔案
/// </summary>
/// <param name="wipNo">工單號碼</param>
/// <param name="fileName">檔案名稱</param>
/// <returns></returns>
[HttpPost]
public async Task<JsonResult> DeleteFqcResultMasterBlob(int fqcId, string fileName)
{
var result = await _fqcApi.DeleteFqcResultMasterBlob(fqcId, fileName);
return Json(new Result() { success = result.Success, msg = result.Msg, data = null });
}
/// <summary> /// <summary>
/// 获取文件ContentType /// 获取文件ContentType
/// </summary> /// </summary>

10
AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs

@ -508,6 +508,16 @@ namespace AMESCoreStudio.Web
/// <returns></returns> /// <returns></returns>
[WebApiClient.Attributes.HttpDelete("api/FqcResultMaster/{id}")] [WebApiClient.Attributes.HttpDelete("api/FqcResultMaster/{id}")]
ITask<ResultModel<FqcResultMaster>> DeleteFqcResultMaster(int id); ITask<ResultModel<FqcResultMaster>> DeleteFqcResultMaster(int id);
/// <summary>
/// 刪除FQC 附件檔案
/// </summary>
/// <param name="wipNo"></param>
/// <param name="fileName"></param>
/// <returns></returns>
[WebApiClient.Attributes.HttpDelete("api/FqcResultMasterBlob/ByFileName")]
ITask<ResultModel<FqcResultMasterBlob>> DeleteFqcResultMasterBlob(int fqcId, string fileName);
#endregion #endregion
#region FQC008 FQC查詢 #region FQC008 FQC查詢

2
AMESCoreStudio.Web/Views/FQC/FQC007.cshtml

@ -674,7 +674,7 @@
layer.open({ layer.open({
title: '文件上傳', title: '文件上傳',
type: 2, type: 2,
area: ['600px', '400px'], area: ['1000px', '400px'],
fixed: false, //不固定 fixed: false, //不固定
maxmin: true, maxmin: true,
content: '/FQC/FQC007D?fqc=@Model.FqcID' content: '/FQC/FQC007D?fqc=@Model.FqcID'

39
AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml

@ -21,7 +21,7 @@
<th lay-data="{field:'username', width:100}">檔案名稱</th> <th lay-data="{field:'username', width:100}">檔案名稱</th>
<th lay-data="{field:'experience', width:80, sort:true}">檔案路徑</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>
<th lay-data="{field:'right', width:80, sort:true}">下載</th> <th lay-data="{field:'right', width:200, sort:true}">功能</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -39,6 +39,7 @@
</td> </td>
<td> <td>
<a class="layui-btn layui-btn-normal layui-btn-xs" onclick="filedownload(this)">下載</a> <a class="layui-btn layui-btn-normal layui-btn-xs" onclick="filedownload(this)">下載</a>
<a id="deleteFile" style="display:none" class="layui-btn layui-btn-normal layui-btn-xs layui-btn-danger" onclick="deleteFile(this)">刪除</a>
</td> </td>
</tr> </tr>
} }
@ -73,7 +74,7 @@
}); });
//通过行tool编辑,lay-event="show" //通过行tool編輯,lay-event="show"
function show(obj) { function show(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();; var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();;
var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();; var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();;
@ -104,7 +105,41 @@
if ($(error).text() != '') { if ($(error).text() != '') {
parent.hg.msg(error); 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("檔案刪除失敗,請洽系統管理員!!");
}
});
})
}
</script> </script>

2
AMESCoreStudio.Web/Views/FQC/FQC008.cshtml

@ -265,7 +265,7 @@
//alert(param); //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/' + 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" //通过行tool编辑,lay-event="edit"
function edit(obj) { function edit(obj) {

45
AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs

@ -112,20 +112,43 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
return result; return result;
} }
// DELETE: api/FqcResultMasterBlob/5 /// <summary>
[HttpDelete("{id}")] /// 刪除 FQC附件
public async Task<ActionResult<FqcResultMasterBlob>> DeleteFqcResultMasterBlob(int id) /// </summary>
/// <param name="fqcId">fqcId</param>
/// <param name="fileName">檔案名稱</param>
/// <returns></returns>
[HttpDelete("ByFileName")]
public async Task<ResultModel<FqcResultMasterBlob>> DeleteFqcResultMasterBlob(int fqcId, string fileName)
{ {
var fqcResultMasterBlob = await _context.FqcResultMasterBlobs.FindAsync(id); ResultModel<FqcResultMasterBlob> result = new ResultModel<FqcResultMasterBlob>();
if (fqcResultMasterBlob == null) if (fqcId == 0 || string.IsNullOrWhiteSpace(fileName))
{ {
return NotFound(); result.Success = false;
result.Msg = "請輸入要刪除的資料";
} }
else
_context.FqcResultMasterBlobs.Remove(fqcResultMasterBlob); {
await _context.SaveChangesAsync(); var fqcResultMasterBlobs = await _context.FqcResultMasterBlobs.Where(w => w.FqcID == fqcId &&
w.ImageName.Trim().ToUpper() == fileName.Trim().ToUpper()).ToListAsync();
return fqcResultMasterBlob;
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) private bool FqcResultMasterBlobExists(int id)

Loading…
Cancel
Save