48 changed files with 2818 additions and 2629 deletions
File diff suppressed because it is too large
@ -0,0 +1,174 @@ |
|||||
|
@{ |
||||
|
ViewData["Title"] = "客戶資料維護"; |
||||
|
Layout = "~/Views/Shared/_AMESLayout.cshtml"; |
||||
|
} |
||||
|
|
||||
|
<div class="layui-card"> |
||||
|
<div class="layui-card-header"> |
||||
|
<div class="layui-form"> |
||||
|
<div class="layui-form-item "> |
||||
|
<div class="layui-inline"><i class="fa fa-file-text-o fa-fw"></i> @ViewBag.Title</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-card-body"> |
||||
|
<div class="layui-form" style="margin-bottom:5px;"> |
||||
|
<div class="layui-form-item"> |
||||
|
<div class="layui-col-sm3"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label" style="width:70px">料號:</label> |
||||
|
<div class="layui-input-inline" style="width:120px"> |
||||
|
<input id="MaterialNo" name="MaterialNo" autocomplete="off" oninput="let p=this.selectionStart;this.value=this.value.trim();this.setSelectionRange(p, p);" class="layui-input" placeholder="請輸入料號"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-col-sm3"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label" style="width:70px">客戶代號:</label> |
||||
|
<div class="layui-input-inline" style="width:150px"> |
||||
|
<input id="CustomerID" name="CustomerID" autocomplete="off" oninput="let p=this.selectionStart;this.value=this.value.trim();this.setSelectionRange(p, p);" class="layui-input" placeholder="請輸入客戶代號"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-col-sm3"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label" style="width:70px">客戶名稱:</label> |
||||
|
<div class="layui-input-inline" style="width:150px"> |
||||
|
<input id="CustomerName" name="CustomerName" autocomplete="off" oninput="let p=this.selectionStart;this.value=this.value.trim();this.setSelectionRange(p, p);" class="layui-input" placeholder="請輸入客戶代號"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-col-sm3"> |
||||
|
<button id="querysubmit" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="querysubmit"> |
||||
|
<i class="layui-icon layui-icon-sm"></i> |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<table class="layui-hide" id="test" lay-filter="test"></table> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts { |
||||
|
<script type="text/javascript"> |
||||
|
var tableCols = [[ |
||||
|
{ |
||||
|
field: 'materialNo', |
||||
|
title: '料號', |
||||
|
sort: true |
||||
|
}, |
||||
|
{ |
||||
|
field: 'customerID', |
||||
|
title: '客戶代號', |
||||
|
sort: true |
||||
|
}, |
||||
|
{ |
||||
|
field: 'customerName', |
||||
|
title: '客戶名稱', |
||||
|
sort: true |
||||
|
}, |
||||
|
{ |
||||
|
field: 'right', |
||||
|
width: 200, |
||||
|
title: '操作', |
||||
|
fixed: 'right', |
||||
|
templet: function (d) { |
||||
|
var btn = '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-edit" lay-event="edit">修改</a>'; |
||||
|
btn += '<a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del">刪除</a>'; |
||||
|
return btn; |
||||
|
} |
||||
|
} |
||||
|
]]; |
||||
|
|
||||
|
|
||||
|
// 修改 |
||||
|
function edit(obj) { |
||||
|
console.log("修改"); |
||||
|
console.log("obj", obj); |
||||
|
console.log("obj.data", obj.data); |
||||
|
console.log("obj.data.materialNo", obj.data.materialNo); |
||||
|
if (obj.data.materialNo) { |
||||
|
console.log('修改', obj.data.materialNo) |
||||
|
hg.open('修改料號對應客戶資料', '/BAS/BAS020U/' + obj.data.materialNo , 640, 550); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 刪除 |
||||
|
function del(obj) { |
||||
|
console.log("刪除"); |
||||
|
if (obj.data.materialNo) { |
||||
|
hg.confirm("料號:" + obj.data.materialNo + ",確定要刪除嗎?", function () { |
||||
|
$.ajax({ |
||||
|
url: '/BAS/BAS020D', |
||||
|
data: { materialNo: obj.data.materialNo }, |
||||
|
type: 'POST', |
||||
|
success: function (data) { |
||||
|
if (data.success) { |
||||
|
obj.del(); |
||||
|
hg.msghide("刪除成功!"); |
||||
|
} else { |
||||
|
hg.msg("刪除失敗,原因:" + data.msg); |
||||
|
} |
||||
|
}, |
||||
|
error: function () { |
||||
|
hg.msg("刪除失敗!"); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
layui.use(['form', 'layer', 'laydate', 'table'], function () { |
||||
|
var form = layui.form; |
||||
|
var table = layui.table; |
||||
|
|
||||
|
// 搜索按鈕點擊事件 |
||||
|
$('#querysubmit').click(function () { |
||||
|
renderTable(); |
||||
|
}); |
||||
|
|
||||
|
// 渲染數據表格 |
||||
|
function renderTable() { |
||||
|
console.log("ABC",$("#MaterialNo").val()) |
||||
|
console.log("ABB",$("#CustomerName").val()) |
||||
|
table.render({ |
||||
|
elem: '#test', |
||||
|
url: '/BAS/GetPnQcCustomerRecordsByCriteria', |
||||
|
where: { |
||||
|
materialNo: $("#MaterialNo").val(), |
||||
|
customerName: $("#CustomerName").val(), |
||||
|
customerID: $("#CustomerID").val() |
||||
|
}, |
||||
|
cols: tableCols, |
||||
|
page: { curr: 1 }, // 預設從第一頁開始 |
||||
|
limit: 20, // 預設每頁顯示 20 筆 |
||||
|
toolbar: ' <div id="toolbar"><button class="layui-btn layui-btn-sm layui-btn-normal" id="addButton"><i class="layui-icon"></i> 新增</button></div>', |
||||
|
defaultToolbar: ['filter', 'print', 'exports'], |
||||
|
done: function(res, curr, count){ |
||||
|
console.log("res.data",res.data); // 列出查詢的資料 |
||||
|
// 新增按鈕點擊事件 |
||||
|
$('#addButton').click(function () { |
||||
|
hg.open('新增料號對應客戶資料', '/BAS/BAS020C', 640, 550); |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
// 監聽工具列事件 |
||||
|
table.on('tool(test)', function(obj){ |
||||
|
console.log("obj.event", obj.event); |
||||
|
var event = obj.event; |
||||
|
if(event === 'edit'){ |
||||
|
edit(obj); |
||||
|
} else if(event === 'del'){ |
||||
|
del(obj); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
renderTable(); // 初始化表格 |
||||
|
}); |
||||
|
</script> |
||||
|
} |
||||
|
|
||||
|
|
@ -0,0 +1,126 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.PnQcCustomerRecord |
||||
|
|
||||
|
@{ |
||||
|
ViewData["Title"] = "BAS020C"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; |
||||
|
} |
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !重要; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" method="post" asp-action="BAS020CSave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
<input type="hidden" asp-for="CreateUserID" value="@ViewBag.UserID" /> |
||||
|
<input type="hidden" asp-for="UpdateUserID" value="@ViewBag.UserID" /> |
||||
|
<input type="hidden" asp-for="CreateDate" value="@System.DateTime.Now" /> |
||||
|
<input type="hidden" asp-for="UpdateDate" value="@System.DateTime.Now" /> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="MaterialNo" class="control-label col-sm-3">料號:</label> |
||||
|
<input asp-for="MaterialNo" class="form-control col-sm-9" id="MaterialNo" /> |
||||
|
<span asp-validation-for="MaterialNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CustomerID" class="control-label col-sm-3">客戶代號:</label> |
||||
|
<input asp-for="CustomerID" class="form-control col-sm-9" id="CustomerID" /> |
||||
|
<span asp-validation-for="CustomerID" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CustomerName" class="control-label col-sm-3">客戶名稱</label> |
||||
|
<input asp-for="CustomerName" class="form-control col-sm-9" id="CustomerName"/> |
||||
|
<span asp-validation-for="CustomerName" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</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> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span> |
||||
|
<div class="form-group"> |
||||
|
<input type="submit" value="儲存" class="btn btn-primary offset-sm-3" /> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts { |
||||
|
@{ |
||||
|
await Html.RenderPartialAsync("_ValidationScriptsPartial"); |
||||
|
await Html.RenderPartialAsync("_FileinputScriptsPartial"); |
||||
|
} |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
layui.use(['form', 'layer'], function () { |
||||
|
var form = layui.form; |
||||
|
var layer = layui.layer; |
||||
|
|
||||
|
// 防止輸入前後空白和特殊字元 |
||||
|
function validateInput(input) { |
||||
|
var value = input.value.trim(); |
||||
|
if (value !== input.value) { |
||||
|
input.value = value; |
||||
|
showError(input, "輸入文字包含前後空白!"); |
||||
|
} else { |
||||
|
clearError(input); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function showError(input, message) { |
||||
|
layer.msg(message, { icon: 5, time: 2000 }); |
||||
|
var errorSpan = $(input).next('.text-danger'); |
||||
|
errorSpan.text(message); |
||||
|
} |
||||
|
|
||||
|
function clearError(input) { |
||||
|
var errorSpan = $(input).next('.text-danger'); |
||||
|
errorSpan.text(''); |
||||
|
} |
||||
|
|
||||
|
$('#MaterialNo, #CustomerID, #CustomerName').on('input', function () { |
||||
|
validateInput(this); |
||||
|
}); |
||||
|
|
||||
|
$('form').on('submit', function (e) { |
||||
|
console.log('formsubmit') |
||||
|
e.preventDefault(); |
||||
|
var isValid = true; |
||||
|
$('#MaterialNo, #CustomerID, #CustomerName').each(function () { |
||||
|
validateInput(this); |
||||
|
if ($(this).next('.text-danger').text() !== '') { |
||||
|
isValid = false; |
||||
|
} |
||||
|
}); |
||||
|
if (isValid) { |
||||
|
console.log('isValid') |
||||
|
$.ajax({ |
||||
|
url: $(this).attr('action'), |
||||
|
type: 'POST', |
||||
|
data: $(this).serialize(), |
||||
|
success: function (response) { |
||||
|
if (response.success) { |
||||
|
layer.msg('儲存成功!', { icon: 1, time: 2000 }, function () { |
||||
|
window.parent.location.reload(); // 刷新父頁面 |
||||
|
var index = parent.layer.getFrameIndex(window.name); // 獲取窗口索引 |
||||
|
parent.layer.close(index); // 關閉當前窗口 |
||||
|
}); |
||||
|
} else { |
||||
|
layer.msg('新增失敗:' + response.msg, { icon: 5, time: 2000 }); |
||||
|
} |
||||
|
}, |
||||
|
error: function () { |
||||
|
layer.msg('新增失敗!', { icon: 5, time: 2000 }); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
</script> |
||||
|
} |
||||
|
|
@ -0,0 +1,125 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.PnQcCustomerRecord |
||||
|
|
||||
|
@{ |
||||
|
ViewData["Title"] = "BAS020U"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; |
||||
|
} |
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !重要; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" method="post" asp-action="BAS020USave" id="saveForm"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
<input type="hidden" asp-for="UpdateUserID" value="@ViewBag.UserID" /> |
||||
|
<input type="hidden" asp-for="UpdateDate" value="@System.DateTime.Now" /> |
||||
|
<input type="hidden" asp-for="MaterialNo" value="@Model.MaterialNo" /> <!-- 新增這行隱藏的輸入欄位 --> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="MaterialNo" class="control-label col-sm-3">料號:</label> |
||||
|
<input asp-for="MaterialNo" class="form-control col-sm-9" id="MaterialNo" readonly /> <!-- 將這行設為只讀 --> |
||||
|
<span asp-validation-for="MaterialNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CustomerID" class="control-label col-sm-3">客戶代號:</label> |
||||
|
<input asp-for="CustomerID" class="form-control col-sm-9" id="CustomerID" /> |
||||
|
<span asp-validation-for="CustomerID" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CustomerName" class="control-label col-sm-3">客戶名稱</label> |
||||
|
<input asp-for="CustomerName" class="form-control col-sm-9" id="CustomerName" /> |
||||
|
<span asp-validation-for="CustomerName" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</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> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span> |
||||
|
<div class="form-group"> |
||||
|
<input type="submit" value="儲存" class="btn btn-primary offset-sm-3" /> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts { |
||||
|
@{ |
||||
|
await Html.RenderPartialAsync("_ValidationScriptsPartial"); |
||||
|
await Html.RenderPartialAsync("_FileinputScriptsPartial"); |
||||
|
} |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
layui.use(['form', 'layer'], function () { |
||||
|
console.log('Layui') |
||||
|
var form = layui.form; |
||||
|
var layer = layui.layer; |
||||
|
|
||||
|
// 防止輸入前後空白和特殊字元 |
||||
|
function validateInput(input) { |
||||
|
var value = input.value.trim(); |
||||
|
if (value !== input.value) { |
||||
|
input.value = value; |
||||
|
showError(input, "輸入文字包含前後空白!"); |
||||
|
} else { |
||||
|
clearError(input); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function showError(input, message) { |
||||
|
layer.msg(message, { icon: 5, time: 2000 }); |
||||
|
var errorSpan = $(input).next('.text-danger'); |
||||
|
errorSpan.text(message); |
||||
|
} |
||||
|
|
||||
|
function clearError(input) { |
||||
|
var errorSpan = $(input).next('.text-danger'); |
||||
|
errorSpan.text(''); |
||||
|
} |
||||
|
|
||||
|
$('#MaterialNo, #CustomerID, #CustomerName').on('input', function () { |
||||
|
validateInput(this); |
||||
|
}); |
||||
|
|
||||
|
$('form').on('submit', function (e) { |
||||
|
console.log('formsubmit') |
||||
|
e.preventDefault(); |
||||
|
var isValid = true; |
||||
|
$('#MaterialNo, #CustomerID, #CustomerName').each(function () { |
||||
|
validateInput(this); |
||||
|
if ($(this).next('.text-danger').text() !== '') { |
||||
|
isValid = false; |
||||
|
} |
||||
|
}); |
||||
|
if (isValid) { |
||||
|
console.log('isValid') |
||||
|
$.ajax({ |
||||
|
url: $(this).attr('action'), |
||||
|
type: 'POST', |
||||
|
data: $(this).serialize(), |
||||
|
success: function (response) { |
||||
|
if (response.success) { |
||||
|
layer.msg('儲存成功!', { icon: 1, time: 2000 }, function () { |
||||
|
window.parent.location.reload(); // 刷新父頁面 |
||||
|
var index = parent.layer.getFrameIndex(window.name); // 獲取窗口索引 |
||||
|
parent.layer.close(index); // 關閉當前窗口 |
||||
|
}); |
||||
|
} else { |
||||
|
layer.msg('儲存失敗!', { icon: 5, time: 2000 }); |
||||
|
} |
||||
|
}, |
||||
|
error: function (response) { |
||||
|
layer.msg('儲存失敗!', { icon: 5, time: 2000 }); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
</script> |
||||
|
} |
@ -0,0 +1,142 @@ |
|||||
|
@{ |
||||
|
ViewData["Title"] = "組件清單查詢"; |
||||
|
Layout = "~/Views/Shared/_AMESLayout.cshtml"; |
||||
|
} |
||||
|
|
||||
|
<div class="layui-card"> |
||||
|
<div class="layui-card-header"> |
||||
|
<div class="layui-form"> |
||||
|
<div class="layui-form-item "> |
||||
|
<div class="layui-inline"><i class="fa fa-file-text-o fa-fw"></i> @ViewBag.Title</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-card-body"> |
||||
|
<div class="layui-form" style="margin-bottom:5px;"> |
||||
|
<div class="layui-form-item"> |
||||
|
<div class="layui-col-md10"> |
||||
|
<div class="layui-col-sm3"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label" style="width:70px">生產序號:</label> |
||||
|
<div class="layui-input-inline" style="width:150px"> |
||||
|
<input id="BarCodeNo" name="BarCodeNo" autocomplete="off" class="layui-input" placeholder="請輸入生產序號"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-col-sm3"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label" style="width:70px">工單:</label> |
||||
|
<div class="layui-input-inline" style="width:150px"> |
||||
|
<input id="WipNo" name="WipNo" autocomplete="off" class="layui-input" placeholder="請輸入工單"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-col-sm3"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label" style="width:70px">組件代碼:</label> |
||||
|
<div class="layui-input-inline" style="width:150px"> |
||||
|
<input id="ItemNo" name="ItemNo" autocomplete="off" oninput="let p=this.selectionStart;this.value=this.value.trim();this.setSelectionRange(p, p);" class="layui-input" placeholder="請輸入組件代碼"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-col-sm3"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label" style="width:70px">組件條碼:</label> |
||||
|
<div class="layui-input-inline" style="width:150px"> |
||||
|
<input id="PartNo" name="PartNo" autocomplete="off" oninput="let p=this.selectionStart;this.value=this.value.trim();this.setSelectionRange(p, p);" class="layui-input" placeholder="請輸入組件條碼"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="layui-col-md2"> |
||||
|
<button id="querysubmit" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="querysubmit"> |
||||
|
<i class="layui-icon layui-icon-sm"></i> |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<table class="layui-hide" id="test" lay-filter="test"></table> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts { |
||||
|
<script type="text/javascript"> |
||||
|
var tableCols = [[ |
||||
|
{ |
||||
|
field: 'wipNo', |
||||
|
title: '工單號碼', |
||||
|
}, |
||||
|
{ |
||||
|
field: 'barcodeNo', |
||||
|
title: '生產序號', |
||||
|
}, |
||||
|
{ |
||||
|
field: 'stationName', |
||||
|
title: '站別名稱', |
||||
|
}, |
||||
|
{ |
||||
|
field: 'itemNoName', |
||||
|
title: '組件名稱', |
||||
|
}, |
||||
|
{ |
||||
|
field: 'partNo', |
||||
|
title: '組件條碼', |
||||
|
}, |
||||
|
{ |
||||
|
field: 'kpItemNo', |
||||
|
title: '組件料號', |
||||
|
}, |
||||
|
{ |
||||
|
field: 'createUser', |
||||
|
title: '綁入人員', |
||||
|
}, |
||||
|
{ |
||||
|
field: 'createDate', |
||||
|
title: '綁入時間', |
||||
|
templet: '<div>{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd HH:mm:ss") }}</div>' |
||||
|
} |
||||
|
]]; |
||||
|
|
||||
|
layui.use(['form', 'layer', 'laydate', 'table'], function () { |
||||
|
var form = layui.form; |
||||
|
var table = layui.table; |
||||
|
|
||||
|
// 搜索按鈕點擊事件 |
||||
|
$('#querysubmit').click(function (e) { |
||||
|
e.preventDefault(); // 防止表單提交 |
||||
|
console.log("搜索按鈕點擊事件") |
||||
|
renderTable(); |
||||
|
}); |
||||
|
|
||||
|
// 渲染數據表格 |
||||
|
function renderTable() { |
||||
|
console.log("渲染數據表格") |
||||
|
console.log("BarCodeNo", $("#BarCodeNo").val()) |
||||
|
console.log("WipNo", $("#WipNo").val()) |
||||
|
console.log("ItemNo", $("#ItemNo").val()) |
||||
|
console.log("PartNo", $("#PartNo").val()) |
||||
|
table.render({ |
||||
|
elem: '#test', |
||||
|
url: '/PCS/GetComponents', |
||||
|
where: { |
||||
|
barcodeNo: $("#BarCodeNo").val(), |
||||
|
wipNo: $("#WipNo").val(), |
||||
|
itemNo: $("#ItemNo").val(), |
||||
|
partNo: $("#PartNo").val() |
||||
|
}, |
||||
|
cols: tableCols, |
||||
|
defaultToolbar: ['filter', 'print', 'exports'], |
||||
|
done: function(res, curr, count){ |
||||
|
if (res.count == 0) { |
||||
|
$(".layui-table-main").html('<div class="layui-none">無資料</div>'); |
||||
|
} |
||||
|
console.log("res.data",res.data); // 列出查詢的資料 |
||||
|
} |
||||
|
}); |
||||
|
console.log("tableCols", tableCols); |
||||
|
} |
||||
|
renderTable(); // 初始化表格 |
||||
|
}); |
||||
|
</script> |
||||
|
} |
@ -0,0 +1,199 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 料號對應工項資料檔
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class PnQcCustomerRecordsController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
public PnQcCustomerRecordsController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號流程查詢 By料號、客戶代號、客戶名稱
|
||||
|
/// </summary>
|
||||
|
/// <param name="materialNo">料號</param>
|
||||
|
/// <param name="customerID">客戶代號</param>
|
||||
|
/// <param name="customerName">客戶名稱</param>
|
||||
|
/// <returns></returns>
|
||||
|
/// Get: api/PnQcCustomerRecords/Query/GetPnQcCustomerRecordsByCriteria
|
||||
|
[HttpGet("Query")] |
||||
|
public async Task<ActionResult<IEnumerable<PnQcCustomerRecord>>> GetPnQcCustomerRecordsByCriteria(string materialNo, string customerName, string customerID, int page = 0, int limit = 10) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var query = _context.PnQcCustomerRecords.AsQueryable(); |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(materialNo)) |
||||
|
{ |
||||
|
query = query.Where(record => record.MaterialNo.Contains(materialNo)); |
||||
|
} |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(customerID)) |
||||
|
{ |
||||
|
query = query.Where(record => record.CustomerID.Contains(customerID)); |
||||
|
} |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(customerName)) |
||||
|
{ |
||||
|
query = query.Where(record => record.CustomerName.Contains(customerName)); |
||||
|
} |
||||
|
query = query.OrderByDescending(record => record.CreateDate); |
||||
|
|
||||
|
return await query.ToListAsync(); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
return StatusCode(500, new { message = ex.Message }); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號流程查詢 By料號、客戶代號、客戶名稱
|
||||
|
/// </summary>
|
||||
|
/// <param name="materialNo">料號</param>
|
||||
|
/// <returns></returns>
|
||||
|
/// Get: api/PnQcCustomerRecords/GetPnQcCustomerRecordsByMaterialNo
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<PnQcCustomerRecord>>> GetPnQcCustomerRecordsByMaterialNo(string materialNo) |
||||
|
{ |
||||
|
|
||||
|
var query = _context.PnQcCustomerRecords.AsQueryable(); |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(materialNo)) |
||||
|
{ |
||||
|
query = query.Where(record => record.MaterialNo == materialNo); |
||||
|
} |
||||
|
|
||||
|
return await query.ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新料號對應客戶資料檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="pnQcCustomerRecord"></param>
|
||||
|
/// <returns></returns>
|
||||
|
/// Put: api/PnQcCustomerRecords/{materialNo}
|
||||
|
[HttpPut("{materialNo}")] |
||||
|
public async Task<ResultModel<PnQcCustomerRecord>> PnQcCustomerRecords(string materialNo, PnQcCustomerRecord pnQcCustomerRecord) |
||||
|
{ |
||||
|
ResultModel<PnQcCustomerRecord> result = new ResultModel<PnQcCustomerRecord>(); |
||||
|
|
||||
|
// 查找對應的記錄
|
||||
|
var existingRecord = await _context.PnQcCustomerRecords |
||||
|
.Where(record => record.MaterialNo == materialNo) |
||||
|
.FirstOrDefaultAsync(); |
||||
|
|
||||
|
if (existingRecord == null) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "Record not found"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
// 更新資料
|
||||
|
existingRecord.UpdateDate = pnQcCustomerRecord.UpdateDate; |
||||
|
existingRecord.UpdateUserID = pnQcCustomerRecord.UpdateUserID; |
||||
|
existingRecord.CustomerName = pnQcCustomerRecord.CustomerName; |
||||
|
existingRecord.CustomerID = pnQcCustomerRecord.CustomerID; |
||||
|
|
||||
|
// 不更新某些屬性
|
||||
|
_context.Entry(existingRecord).State = EntityState.Modified; |
||||
|
_context.Entry(existingRecord).Property("MaterialNo").IsModified = false; |
||||
|
_context.Entry(existingRecord).Property("CreateDate").IsModified = false; |
||||
|
_context.Entry(existingRecord).Property("CreateUserID").IsModified = false; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException?.Message ?? ex.Message; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增料號對應客戶資料檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="pnQcCustomerRecord"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<PnQcCustomerRecord>> PostPnQcCustomerRecord(PnQcCustomerRecord pnQcCustomerRecord) |
||||
|
{ |
||||
|
ResultModel<PnQcCustomerRecord> result = new ResultModel<PnQcCustomerRecord>(); |
||||
|
_context.PnQcCustomerRecords.Add(pnQcCustomerRecord); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 刪除料號對客戶資料檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
/// Delete: api/PnQcCustomerRecords/{materialNo}
|
||||
|
[HttpDelete("{material}")] |
||||
|
public async Task<ResultModel<string>> DeletePnQcCustomerRecord(string material) |
||||
|
{ |
||||
|
ResultModel<string> result = new ResultModel<string>(); |
||||
|
var pnQcCustomerRecord = await _context.PnQcCustomerRecords.FindAsync(material); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (pnQcCustomerRecord == null) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "找不到要刪除資料"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
_context.PnQcCustomerRecords.Remove(pnQcCustomerRecord); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.InnerException.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
} |
File diff suppressed because it is too large
@ -0,0 +1,156 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Net.Http; |
||||
|
using System.Net.Http.Headers; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Newtonsoft.Json; |
||||
|
using System.Text; |
||||
|
using AMESCoreStudio.WebApi.Extensions; //擴充EF Core語法
|
||||
|
using Dapper; |
||||
|
using System.Data; |
||||
|
using AMESCoreStudio.WebApi.Models.aValue_API; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.aValue_API |
||||
|
{ |
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class ESUNAMESNoticeController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _amesContext; |
||||
|
private readonly ESUNAMESContext _esuContext; |
||||
|
private readonly IConfiguration _config; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建構式
|
||||
|
/// </summary>
|
||||
|
public ESUNAMESNoticeController(AMESContext aMESContext, ESUNAMESContext eSUNAMESContext, IConfiguration configuration) |
||||
|
{ |
||||
|
_amesContext = aMESContext; |
||||
|
_esuContext = eSUNAMESContext; |
||||
|
_config = configuration; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 刪除昶亨TempTable
|
||||
|
/// </summary>
|
||||
|
/// <param name="wipNo"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpDelete("ESUNAMESTempTableByAvalueWipNo")] |
||||
|
public bool DeleteESUNAMESTempTableByAvalueWipNo(string wipNo) |
||||
|
{ |
||||
|
using (var connection = _esuContext.Database.GetDbConnection()) |
||||
|
{ |
||||
|
var sql = "DELETE FROM jhames.WIP_BARCODE_FROM_AVALUE WHERE AV_WIP_NO = :WipNo"; |
||||
|
var rowsAffected = connection.Execute(sql, new { WipNo = wipNo }); |
||||
|
return rowsAffected > 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 寫進昶亨TempTable
|
||||
|
/// </summary>
|
||||
|
/// <param name="models"></param>
|
||||
|
/// <param name="userName"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost("ESUNAMESTempTableByAvalue")] |
||||
|
public async Task<IActionResult> PostESUNAMESTempTableByAvalue([FromBody] List<WipBarcodeOther> models, [FromQuery] string userName) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
using (var connection = _esuContext.Database.GetDbConnection()) |
||||
|
{ |
||||
|
var sql = @"
|
||||
|
INSERT INTO jhames.WIP_BARCODE_FROM_AVALUE (AV_WIP_NO, START_NO, END_NO, CREATE_DATE, CREATE_USER_NAME) |
||||
|
VALUES (:WipNO, :StartNO, :EndNO, :CreateDate, :CreateUserName)";
|
||||
|
|
||||
|
const int batchSize = 100; // 每批次插入的資料量
|
||||
|
for (int i = 0; i < models.Count; i += batchSize) |
||||
|
{ |
||||
|
var batch = models.Skip(i).Take(batchSize).Select(model => new |
||||
|
{ |
||||
|
WipNO = model.WipNO, |
||||
|
StartNO = model.StartNO, |
||||
|
EndNO = model.EndNO, |
||||
|
CreateDate = DateTime.Now, |
||||
|
CreateUserName = userName |
||||
|
}).ToList(); |
||||
|
|
||||
|
await connection.ExecuteAsync(sql, batch); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Ok(new { Message = "資料已成功寫進昶亨TempTable" }); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
return BadRequest(new { Message = ex.Message }); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 抓取安勤對應昶亨工單
|
||||
|
/// </summary>
|
||||
|
/// <param name="wipNo"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpGet("AvalueCorrespondingESUNAMESWipInfo")] |
||||
|
public bool GetAvalueCorrespondingESUNAMESWipInfo([FromQuery] string wipNo) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
using (var connection = _esuContext.Database.GetDbConnection()) |
||||
|
{ |
||||
|
var sql = "SELECT COUNT(1) FROM jhames.wip_info WHERE related_wo_no = :WipNo"; |
||||
|
var exists = connection.ExecuteScalar<bool>(sql, new { WipNo = wipNo }); |
||||
|
return exists; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 判斷有昶亨有無設定出貨序號,有的話就抓取資料
|
||||
|
/// </summary>
|
||||
|
/// <param name="wipNo"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpGet("CheckESUNAMESShipmentNo")] |
||||
|
public ActionResult<List<ESUNAMESNotice>> GetCheckESUNAMESShipmentNo([FromQuery] string wipNo) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
using (var connection = _esuContext.Database.GetDbConnection()) |
||||
|
{ |
||||
|
var sql = @"
|
||||
|
select * from wip_barcode_other where wip_no in |
||||
|
( |
||||
|
select distinct WIP_NO from jhames.wip_info where related_wo_no=:WipNo |
||||
|
)";
|
||||
|
|
||||
|
var result = connection.Query<ESUNAMESNotice>(sql, new { WipNo = wipNo }).ToList(); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
return BadRequest(new { Message = ex.Message }); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,66 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Runtime.Serialization; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 料號對應客戶資料檔
|
||||
|
/// </summary>
|
||||
|
[Table("PN_QC_CUSTOMER_RECORD", Schema = "JHAMES")] |
||||
|
[DataContract] |
||||
|
public class PnQcCustomerRecord |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 料號
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("MATERIAL_NO")] |
||||
|
[DataMember] |
||||
|
public string MaterialNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 客戶代號
|
||||
|
/// </summary>
|
||||
|
[Column("CUSTOMER_ID")] |
||||
|
[DataMember] |
||||
|
public string CustomerID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 客戶名稱
|
||||
|
/// </summary>
|
||||
|
[Column("CUSTOMER_NAME")] |
||||
|
[DataMember] |
||||
|
public string CustomerName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立人員
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_USERID")] |
||||
|
[DataMember] |
||||
|
public int CreateUserID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立時間
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_DATE")] |
||||
|
[DataMember] |
||||
|
public DateTime CreateDate { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改人員
|
||||
|
/// </summary>
|
||||
|
[Column("UPDATE_USERID")] |
||||
|
[DataMember] |
||||
|
public int UpdateUserID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改時間
|
||||
|
/// </summary>
|
||||
|
[Column("UPDATE_DATE")] |
||||
|
[DataMember] |
||||
|
public DateTime UpdateDate { get; set; } |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
namespace AMESCoreStudio.WebApi.Models.aValue_API |
||||
|
{ |
||||
|
|
||||
|
public partial class ESUNAMESNotice |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 工單號碼
|
||||
|
/// </summary>
|
||||
|
public string WiP_NO { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 關聯工單
|
||||
|
/// </summary>
|
||||
|
public string RELATED_WO_NO { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 開始序號
|
||||
|
/// </summary>
|
||||
|
public string START_NO { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 結束序號
|
||||
|
/// </summary>
|
||||
|
public string END_NO { get; set; } |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.aValue_API |
||||
|
{ |
||||
|
|
||||
|
public partial class WipBarcodeFromAvalue |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 安勤工單號碼
|
||||
|
/// </summary>
|
||||
|
public string AV_WIP_NO { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 開始出貨序號
|
||||
|
/// </summary>
|
||||
|
public string START_NO { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 結束出貨序號
|
||||
|
/// </summary>
|
||||
|
public string END_NO { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立日期
|
||||
|
/// </summary>
|
||||
|
public DateTime CREATE_DATE { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立人員(誰修改出貨序號)
|
||||
|
/// </summary>
|
||||
|
public string CREATE_USER_NAME { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue