4 changed files with 565 additions and 14 deletions
@ -0,0 +1,155 @@ |
|||
@model AMESCoreStudio.WebApi.Models.AMES.InspectionResultBlob |
|||
|
|||
|
|||
|
|||
@{ ViewData["Title"] = "SPC005R"; |
|||
Layout = "~/Views/Shared/_AMESLayout.cshtml"; } |
|||
|
|||
<style> |
|||
.control-label { |
|||
justify-content: flex-end !important; |
|||
} |
|||
|
|||
.text-error { |
|||
color: #dc3545 !important; |
|||
} |
|||
|
|||
.my-read-only-class { |
|||
cursor: not-allowed; |
|||
} |
|||
</style> |
|||
|
|||
<div class="layui-card"> |
|||
<div class="layui-card-body"> |
|||
<form enctype="multipart/form-data" class="layui-form" method="post" asp-action="SPC005RSave"> |
|||
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
|||
<input type="hidden" id="id" asp-for="InspectionID" value="@ViewBag.MasterID" /> |
|||
<input type="hidden" id="itemID" asp-for="InspectionItemID" value="@ViewBag.ItemID" /> |
|||
<div class="layui-form-item" style="text-align:center"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-btn"> |
|||
<input type="file" name="formFile"> |
|||
</label> |
|||
<input type="submit" id="asubmit" value="上傳" class="layui-btn layui-icon " /> |
|||
</div> |
|||
</div> |
|||
<div style="text-align:center"> |
|||
<div class="layui-inline"> |
|||
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span> |
|||
@* <input type="submit" id="asubmit" value="上傳" class="layui-btn layui-btn-normal layui-btn-xs layui-icon " /> *@ |
|||
</div> |
|||
</div> |
|||
</form> |
|||
@* SOP文件 sheet *@ |
|||
<table class="layui-hide" id="sop" lay-filter="sop"></table> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
@section Scripts { |
|||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); |
|||
await Html.RenderPartialAsync("_FileinputScriptsPartial"); } |
|||
|
|||
<script type="text/javascript"> |
|||
//layui.use(['form', 'layer', 'laydate'], function () { |
|||
// form = layui.form; |
|||
// |
|||
// form.on('select(Type)', function (data) { |
|||
// var data = $("#Type").val(); |
|||
// getInspectionForms(data); |
|||
// }); |
|||
// |
|||
//}); |
|||
hg.form.onsubmit('asubmit', function (data) { |
|||
tt(); |
|||
//table && table.reload(data); |
|||
}); |
|||
//通过行tool编辑,lay-event="show" |
|||
function show(obj) { |
|||
layui.use('layer', function () { |
|||
var layer = layui.layer; |
|||
layer.open({ |
|||
type: 2, |
|||
title: '預覽文件', |
|||
shadeClose: true,//点击遮罩关闭层 |
|||
shade: 0.8, |
|||
area: ['90%', '90%'], |
|||
content: obj.data.filePath + obj.data.newName, //iframe的url |
|||
zIndex: 19891014, |
|||
//iframe: { |
|||
// src:obj.data.filePath + obj.data.newName |
|||
// |
|||
//} |
|||
}); |
|||
}); |
|||
|
|||
}; |
|||
//通过行tool删除,lay-event="del" |
|||
function del(obj) { |
|||
if (obj.data.imageName) { |
|||
hg.confirm("圖片資料:" + obj.data.imageName + ",确定要删除吗?", function () { |
|||
$.ajax({ |
|||
url: '/REP/REP001D', |
|||
data: { id: obj.data.imageName }, |
|||
type: 'POST', |
|||
success: function (data) { |
|||
if (data.success) { |
|||
obj.del(); //只删本地数据 |
|||
hg.msghide("删除成功!"); |
|||
} |
|||
else { |
|||
hg.msg(data.msg); |
|||
} |
|||
}, |
|||
error: function () { |
|||
hg.msg("网络请求失败!"); |
|||
} |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
@* SOP文件 sheet *@ |
|||
var tableCols = [[ |
|||
{ |
|||
field: 'imageName', |
|||
title: '檔案名稱', |
|||
sort: true |
|||
}, |
|||
{ |
|||
field: 'createDate', |
|||
templet: '<div>{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd") }}</div>' |
|||
}, |
|||
{ |
|||
field: 'right', |
|||
width: 80, |
|||
title: '操作', |
|||
align: 'center', |
|||
fixed: 'right', |
|||
templet: function (d) { |
|||
return '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" lay-event="show">預覽</a>' |
|||
} |
|||
}] |
|||
]; |
|||
//基本数据表格 |
|||
var table; |
|||
$(function () { |
|||
tt(); |
|||
}); |
|||
function tt() { |
|||
//基本数据表格 |
|||
table = hg.table.datatable('sop', '巡檢上傳文件', '/SPC/GetInspectionResultBlobsByQuery?id=' + @ViewBag.MasterID +'&itemID=' + @ViewBag.ItemID, {}, tableCols, false, 'full-100'); |
|||
}; |
|||
|
|||
$(document).ready(function () { |
|||
var error = '@Html.ValidationMessage("error")'; |
|||
if ($(error).text() != '') { |
|||
parent.hg.msg(error); |
|||
} |
|||
}); |
|||
|
|||
</script> |
|||
|
|||
|
|||
} |
|||
|
@ -0,0 +1,198 @@ |
|||
@model AMESCoreStudio.WebApi.Models.AMES.InspectionResultMaster |
|||
|
|||
|
|||
@{ ViewData["Title"] = "SPC005U"; |
|||
Layout = "~/Views/Shared/_AMESLayout.cshtml"; |
|||
//Layout = "~/Views/Shared/_FormLayout.cshtml"; |
|||
} |
|||
<style> |
|||
.layui-table-cell { |
|||
overflow: visible !important; |
|||
} |
|||
|
|||
td .layui-form-select { |
|||
margin-top: -10px; |
|||
margin-left: -10px; |
|||
margin-right: -10px; |
|||
} |
|||
</style> |
|||
<div class="layui-card"> |
|||
<div class="layui-card-body"> |
|||
<label class="layui-form-label" value="@ViewBag.FormName"></label> |
|||
<label class="layui-form-label" value="@ViewBag.InspectionForm"></label> |
|||
<form id="modelform" method="post"> |
|||
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
|||
<input type="hidden" id="InspectionID" asp-for="InspectionID" /> |
|||
<input type="hidden" id="InspectionFormID" asp-for="InspectionFormID" /> |
|||
<input type="hidden" asp-for="CreateUserID" /> |
|||
<input type="hidden" asp-for="UpdateUserID" value="0" /> |
|||
<input type="hidden" asp-for="CreateDate" /> |
|||
<input type="hidden" asp-for="UpdateDate" value="@System.DateTime.Now" /> |
|||
<input type="hidden" asp-for="StatusNo" /> |
|||
<div class="form-inline "> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-input-inline"> |
|||
<label asp-for="WipNo" class="control-label col-sm-2"></label> |
|||
<input id="WipNo" asp-for="WipNo" type="text" class="layui-input" readonly> |
|||
</div> |
|||
<div class="layui-input-inline"> |
|||
<label asp-for="ItemNo" class="control-label col-sm-2"></label> |
|||
<input id="ItemNo" asp-for="ItemNo" class="layui-input" readonly> |
|||
</div> |
|||
<div class="layui-input-inline"> |
|||
<label asp-for="BarcodeNo" class="control-label col-sm-2"></label> |
|||
<input id="BarcodeNo" asp-for="BarcodeNo" class="layui-input" readonly> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span> |
|||
</form> |
|||
<form id="modeltable" method="post"> |
|||
<table class="layui-hide" id="test" lay-filter="test" lay-data="{id:'test'}"></table> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
|
|||
@section Scripts { |
|||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); |
|||
await Html.RenderPartialAsync("_FileinputScriptsPartial"); } |
|||
|
|||
@*回復*@ |
|||
<script type="text/html" id="selectResult"> |
|||
<select name="selectResult" lay-filter="selectResult" id="selectResult" data-value={{d.result}} class="layui-form" disabled> |
|||
<option value="NA">N/A</option> |
|||
<option value="P">PASS</option> |
|||
<option value="F">FAIL </option> |
|||
</select> |
|||
</script> |
|||
@*線別*@ |
|||
<script type="text/html" id="selectLine"> |
|||
<select name="selectLine" lay-filter="selectLine" id="selectLine" data-value={{d.lineID}} asp-items="@ViewBag.LineList" class="layui-form" disabled> |
|||
</select> |
|||
</script> |
|||
@*站別*@ |
|||
<script type="text/html" id="selectStation"> |
|||
<select name="selectStation" lay-filter="selectStation" id="selectStation" data-value={{d.ruleStationID}} asp-items="@ViewBag.StationList" class="layui-form" disabled> |
|||
</select> |
|||
</script> |
|||
@*缺失單位*@ |
|||
<script type="text/html" id="selectDept"> |
|||
<select name="selectDept" lay-filter="selectDept" id="selectDept" data-value={{d.missingUnitNo}} asp-items="@ViewBag.FactoryUnit" class="layui-form" disabled> |
|||
</select> |
|||
</script> |
|||
@*缺失人員*@ |
|||
<script type="text/html" id="selectUser"> |
|||
<select name="selectUser" lay-filter="selectUser" id="selectUser" data-value={{d.missingUserID}} lay-search='' asp-items="@ViewBag.UserList" class="layui-form" disabled> |
|||
</select> |
|||
</script> |
|||
<script type="text/javascript"> |
|||
|
|||
layui.use(['form', 'layer', 'table', 'laytpl', 'laydate'], function () { |
|||
var layer = layui.layer, |
|||
$ = layui.jquery, |
|||
form = layui.form, |
|||
table = layui.table; |
|||
|
|||
itemslist(); |
|||
function itemslist() { |
|||
var formID = $("#InspectionID").val(); |
|||
table.render({ |
|||
elem: '#test', |
|||
url: '/SPC/GetInspectionResultDetails?id=' + formID, |
|||
id: 'test', |
|||
toolbar: '#toolBar', |
|||
//height:720, |
|||
page: false, |
|||
cols: [[ |
|||
{ field: 'inspectionItemID', width: 50, title: '#', }, |
|||
{ |
|||
field: 'inspectionItem', |
|||
title: '項目', |
|||
align: 'left', |
|||
width: 450, |
|||
sort: true, |
|||
templet: function (d) { |
|||
return d.inspectionItem['inspectionItemName']; |
|||
} |
|||
}, |
|||
{ |
|||
field: 'inspectionItem', |
|||
title: '標準值', |
|||
minwidth: 80, |
|||
align: 'left', |
|||
templet: function (d) { |
|||
return d.inspectionItem['inspectionItemValue']; |
|||
} |
|||
}, |
|||
{ field: 'result', title: '稽核結果', width: 100, align: "left", templet: '#selectResult' }, |
|||
{ field: 'lineID', title: '線別', width: 100, align: "left", templet: '#selectLine' }, |
|||
{ field: 'ruleStationID', title: '站別', width: 100, align: "left", templet: '#selectStation' }, |
|||
{ field: 'location', title: '插件位置', width: 100, align: "left" }, |
|||
{ field: 'missingUnitNo', title: '缺失單位', width: 100, align: "left", templet: '#selectDept' }, |
|||
{ field: 'missingUserID', title: '缺失人員', width: 100, align: "left", templet: '#selectUser' }, |
|||
{ field: 'missingRemark', title: '備註', width: 250, align: "left"},//templet: '#inputTest' |
|||
{ |
|||
field: 'right', |
|||
width: 100, |
|||
title: '操作', |
|||
fixed: 'right', |
|||
templet: function (d) { |
|||
return '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-edit" lay-event="edit">檢視文件</a> ' |
|||
} |
|||
} |
|||
]], |
|||
done: function (res, curr, count) { |
|||
$(".layui-table-main tr").each(function (index, val) { |
|||
$($(".layui-table-fixed .layui-table-body tbody tr")[index]).height($(val).height()); |
|||
}); |
|||
layui.each($('select'), function (index, item) { |
|||
var elem = $(item); |
|||
elem.val(elem.data('value')).parents('div.layui-table-cell').css('overflow', 'visible'); |
|||
}); |
|||
form.render(); |
|||
} |
|||
}); |
|||
} |
|||
/*表格列表操作*/ |
|||
table.on('tool(test)', function (obj) { |
|||
var data = obj.data, layEvent = obj.event; |
|||
if (layEvent === 'edit') { |
|||
var id = $("#InspectionID").val(); |
|||
if (obj.data.inspectionItemID) { |
|||
layer.open({ |
|||
type: 2 //此處以iframe舉例 |
|||
, title: '上傳文件' |
|||
, area: ['480px', '400px'] |
|||
, shade: 0 |
|||
, maxmin: true |
|||
, offset: 'auto'//顯示座標-auto居中 |
|||
, content: "/SPC/SPC005R?id=" + id + "&itemID=" + obj.data.inspectionItemID |
|||
//, btn: ['關閉'] |
|||
, yes: function () { |
|||
//layer.close(); |
|||
if (layer.confirm('確定要關閉麼')) { |
|||
layer.close(index); |
|||
} |
|||
// $(that).click(); |
|||
} |
|||
, zIndex: 19891014 //layer.zIndex //重點1 |
|||
, success: function (layero) { |
|||
layer.setTop(layero); //重點2 |
|||
} |
|||
}); |
|||
//hg.open('上傳文件', '/SPC/SPC005R?id=' + id + '&itemID=' + obj.data.inspectionItemID, 1080, 640); |
|||
} |
|||
} |
|||
}); |
|||
}); |
|||
$(document).ready(function () { |
|||
var error = '@Html.ValidationMessage("error")'; |
|||
if ($(error).text() != '') { |
|||
parent.hg.msg(error); |
|||
} |
|||
}); |
|||
</script> |
|||
} |
|||
|
@ -0,0 +1,199 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using AMESCoreStudio.WebApi; |
|||
using AMESCoreStudio.WebApi.Models.AMES; |
|||
using AMESCoreStudio.CommonTools.Result; |
|||
|
|||
|
|||
namespace AMESCoreStudio.WebApi.Controllers.AMES |
|||
{ |
|||
/// <summary>
|
|||
/// 巡檢類別資料维护
|
|||
/// </summary>
|
|||
[Route("api/[controller]")]
|
|||
[ApiController] |
|||
public class InspectionResultBlobsController : ControllerBase |
|||
{ |
|||
private readonly AMESContext _context; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="context"></param>
|
|||
public InspectionResultBlobsController(AMESContext context) |
|||
{ |
|||
_context = context; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取全部巡檢類別資料
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
// GET: api/InspectionResultBlobs
|
|||
[HttpGet] |
|||
public async Task<ActionResult<IEnumerable<InspectionResultBlob>>> GetInspectionResultBlobs() |
|||
{ |
|||
IQueryable<InspectionResultBlob> q = _context.InspectionResultBlobs; |
|||
q = q.OrderBy(p => p.InspectionID); |
|||
q = q.OrderBy(p => p.InspectionItemID); |
|||
|
|||
var InspectionResultBlobs = await q.ToListAsync(); |
|||
|
|||
return InspectionResultBlobs; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 用ID获取该巡檢類別資料
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <returns></returns>
|
|||
// GET: api/InspectionResultBlobs/5
|
|||
[HttpGet("{id}")] |
|||
public async Task<ActionResult<IEnumerable<InspectionResultBlob>>> GetInspectionResultBlobs(int id) |
|||
{ |
|||
|
|||
IQueryable<InspectionResultBlob> q = _context.InspectionResultBlobs; |
|||
q = q.Where(p => p.InspectionID.Equals(id)); |
|||
var InspectionResultBlob = await q.ToListAsync(); |
|||
|
|||
if (InspectionResultBlob == null) |
|||
{ |
|||
return NotFound(); |
|||
} |
|||
|
|||
return InspectionResultBlob; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取该巡檢表單Blob By Query
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <param name="itemID"></param>
|
|||
/// <returns></returns>
|
|||
// GET: api/InspectionResultBlobs/Query/5
|
|||
[HttpGet("Query/{id}/{itemID}")] |
|||
public async Task<ActionResult<IEnumerable<InspectionResultBlob>>> GetInspectionResultBlobsByQuery(int id, int itemID) |
|||
{ |
|||
|
|||
IQueryable<InspectionResultBlob> q = _context.InspectionResultBlobs; |
|||
q = q.Where(p => p.InspectionID.Equals(id)); |
|||
q = q.Where(p => p.InspectionItemID.Equals(itemID)); |
|||
var InspectionResultBlob = await q.ToListAsync(); |
|||
|
|||
if (InspectionResultBlob.Count == 0 ) |
|||
{ |
|||
return InspectionResultBlob; |
|||
} |
|||
|
|||
return InspectionResultBlob; |
|||
} |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 更新巡檢類別資料
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <param name="InspectionResultBlob"></param>
|
|||
/// <returns></returns>
|
|||
// PUT: api/InspectionResultBlobs/5
|
|||
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
|||
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
|
|||
[HttpPut("{id}")] |
|||
public async Task<ResultModel<InspectionResultBlob>> PutInspectionResultBlobs(int id, [FromBody] InspectionResultBlob InspectionResultBlob) |
|||
{ |
|||
ResultModel<InspectionResultBlob> result = new ResultModel<InspectionResultBlob>(); |
|||
if (id != InspectionResultBlob.InspectionID) |
|||
{ |
|||
result.Success = false; |
|||
result.Msg = "序號錯誤"; |
|||
return result; |
|||
} |
|||
|
|||
_context.Entry(InspectionResultBlob).State = EntityState.Modified; |
|||
|
|||
try |
|||
{ |
|||
await _context.SaveChangesAsync(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
result.Success = false; |
|||
result.Msg = e.Message; |
|||
return result; |
|||
} |
|||
|
|||
result.Success = true; |
|||
result.Msg = "OK"; |
|||
return result; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 新增巡檢類別資料
|
|||
/// </summary>
|
|||
/// <param name="InspectionResultBlob"></param>
|
|||
/// <returns></returns>
|
|||
// POST: api/InspectionResultBlobs
|
|||
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
|||
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
|
|||
[HttpPost] |
|||
public async Task<ResultModel<InspectionResultBlob>> PostInspectionResultBlobs(InspectionResultBlob InspectionResultBlob) |
|||
{ |
|||
ResultModel<InspectionResultBlob> result = new ResultModel<InspectionResultBlob>(); |
|||
Helper helper = new Helper(_context); |
|||
_context.InspectionResultBlobs.Add(InspectionResultBlob); |
|||
try |
|||
{ |
|||
await _context.SaveChangesAsync(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
result.Success = false; |
|||
result.Msg = e.Message; |
|||
return result; |
|||
} |
|||
|
|||
result.Success = true; |
|||
result.Msg = "OK"; |
|||
return result; |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 删除巡檢類別資料
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <returns></returns>
|
|||
// DELETE: api/InspectionResultBlobs/5
|
|||
[HttpDelete("{id}")] |
|||
public async Task<ResultModel<InspectionResultBlob>> DeleteInspectionResultBlobs(int id) |
|||
{ |
|||
ResultModel<InspectionResultBlob> result = new ResultModel<InspectionResultBlob>(); |
|||
var inspectionType = await _context.InspectionResultBlobs.Where(m => m.InspectionID == id).FirstOrDefaultAsync(); |
|||
if (inspectionType == null) |
|||
{ |
|||
result.Success = false; |
|||
result.Msg = "序號不存在"; |
|||
return result; |
|||
} |
|||
|
|||
_context.InspectionResultBlobs.Remove(inspectionType); |
|||
await _context.SaveChangesAsync(); |
|||
|
|||
result.Success = true; |
|||
result.Msg = "OK"; |
|||
return result; |
|||
} |
|||
|
|||
private bool InspectionResultBlobsExists(int id) |
|||
{ |
|||
return _context.InspectionResultBlobs.Any(e => e.InspectionID == id); |
|||
} |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue