18 changed files with 1237 additions and 2 deletions
@ -0,0 +1,131 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using AMESCoreStudio.Web.Models; |
||||
|
using Newtonsoft.Json; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
|
||||
|
namespace AMESCoreStudio.Web.Controllers |
||||
|
{ |
||||
|
public class KCSController : Controller |
||||
|
{ |
||||
|
private readonly ILogger<KCSController> _logger; |
||||
|
public readonly IKCS _kcsApi; |
||||
|
|
||||
|
public KCSController(ILogger<KCSController> logger, IKCS kcsApi) |
||||
|
{ |
||||
|
_logger = logger; |
||||
|
_kcsApi = kcsApi; |
||||
|
} |
||||
|
|
||||
|
#region KCS002序號料號維護相關
|
||||
|
|
||||
|
public IActionResult KCS002() |
||||
|
{ |
||||
|
return View(); |
||||
|
} |
||||
|
|
||||
|
//新增頁面
|
||||
|
public IActionResult KCS002C() |
||||
|
{ |
||||
|
return View(); |
||||
|
} |
||||
|
|
||||
|
//修改页面
|
||||
|
[HttpGet] |
||||
|
public async Task<IActionResult> KCS002UAsync(string id) |
||||
|
{ |
||||
|
var result = await _kcsApi.GetPartMap(id); |
||||
|
|
||||
|
if (result.Count == 0) |
||||
|
{ |
||||
|
return View(); |
||||
|
} |
||||
|
return View(result[0]); |
||||
|
} |
||||
|
|
||||
|
public async Task<IActionResult> KCS002DAsync(string id) |
||||
|
{ |
||||
|
var result = await _kcsApi.DeletePartMap(id); |
||||
|
return Json(new Result() { success = true, msg = "" }); |
||||
|
} |
||||
|
|
||||
|
//頁面提交,id=0 添加,id>0 修改
|
||||
|
[HttpPost] |
||||
|
public async Task<IActionResult> KCS002CSaveAsync(PartMap model) |
||||
|
{ |
||||
|
if (ModelState.IsValid) |
||||
|
{ |
||||
|
IResultModel result; |
||||
|
|
||||
|
result = await _kcsApi.PostPartMap(JsonConvert.SerializeObject(model)); |
||||
|
|
||||
|
|
||||
|
if (result.Success) |
||||
|
{ |
||||
|
var _msg = "添加成功!"; |
||||
|
return RedirectToAction("Refresh", "Home", new { msg = _msg }); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (result.Errors.Count > 0) |
||||
|
{ |
||||
|
ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
ModelState.AddModelError("error", result.Msg); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return View("KCS002C", model); |
||||
|
} |
||||
|
|
||||
|
public async Task<IActionResult> KCS002USaveAsync(PartMap model) |
||||
|
{ |
||||
|
if (ModelState.IsValid) |
||||
|
{ |
||||
|
IResultModel result; |
||||
|
|
||||
|
result = await _kcsApi.PutPartMap(model.CorpSN, JsonConvert.SerializeObject(model)); |
||||
|
|
||||
|
if (result.Success) |
||||
|
{ |
||||
|
var _msg = "修改成功!"; |
||||
|
return RedirectToAction("Refresh", "Home", new { msg = _msg }); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (result.Errors.Count > 0) |
||||
|
{ |
||||
|
ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
ModelState.AddModelError("error", result.Msg); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return View("PPS002U", model); |
||||
|
} |
||||
|
|
||||
|
[ResponseCache(Duration = 0)] |
||||
|
[HttpGet] |
||||
|
public async Task<IActionResult> GetPartMapsAsync(int page = 1, int limit = 10) |
||||
|
{ |
||||
|
var result_total = await _kcsApi.GetPartMaps(0, limit); |
||||
|
var result = await _kcsApi.GetPartMaps(page, limit); |
||||
|
|
||||
|
if (result.Count > 0) |
||||
|
{ |
||||
|
return Json(new Table() { code = 0, msg = "", data = result, count = result_total.Count }); |
||||
|
} |
||||
|
|
||||
|
return Json(new Table() { count = 0, data = null }); |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using WebApiClient; |
||||
|
using WebApiClient.Attributes; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.WebApi.Models.BAS; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
|
||||
|
namespace AMESCoreStudio.Web |
||||
|
{ |
||||
|
[JsonReturn] |
||||
|
public interface IKCS:IHttpApi |
||||
|
{ |
||||
|
#region KCS002 序號料號維護
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增序號料號
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpPost("api/PartMaps")] |
||||
|
ITask<ResultModel<PartMap>> PostPartMap([FromBody, RawJsonContent] string model); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新序號料號
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpPut("api/PartMaps/{id}")] |
||||
|
ITask<ResultModel<PartMap>> PutPartMap(string id, [FromBody, RawJsonContent] string model); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 刪除序號料號
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpDelete("api/PartMaps/{id}")] |
||||
|
ITask<ResultModel<PartMap>> DeletePartMap(string id); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根據ID獲取指定序號料號資料
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpGet("api/PartMaps/{id}")] |
||||
|
ITask<List<PartMap>> GetPartMap(string id); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 獲取序號料號資料
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[WebApiClient.Attributes.HttpGet("api/PartMaps")] |
||||
|
ITask<List<PartMap>> GetPartMaps(int page = 1, int limit = 10); |
||||
|
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
@ -0,0 +1,90 @@ |
|||||
|
@{ |
||||
|
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"> |
||||
|
<table class="layui-hide" id="test" lay-filter="test"></table> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts{ |
||||
|
<script type="text/javascript"> |
||||
|
//监听表单提交事件 |
||||
|
hg.form.onsubmit('querysubmit', function (data) { |
||||
|
table && table.reload(data); |
||||
|
}); |
||||
|
var tableCols = [[ |
||||
|
{ |
||||
|
field: 'corpSN', |
||||
|
width: 200, |
||||
|
title: '序號' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'corpPN', |
||||
|
title: '料號' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'right', |
||||
|
width: 200, |
||||
|
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> <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del">删除</a>' |
||||
|
} |
||||
|
}] |
||||
|
]; |
||||
|
|
||||
|
//通过行tool编辑,lay-event="edit" |
||||
|
function edit(obj) { |
||||
|
if (obj.data.corpSN) { |
||||
|
hg.open('修改序號料號', '/KCS/KCS002U/' + obj.data.corpSN, 640,320); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//通过行tool删除,lay-event="del" |
||||
|
function del(obj) { |
||||
|
if (obj.data.corpSN) { |
||||
|
hg.confirm("序號料號:" + obj.data.corpSN + "," + obj.data.corpPN + ",确定要删除吗?", function () { |
||||
|
$.ajax({ |
||||
|
url: '/KCS/KCS002D', |
||||
|
data: { id: obj.data.corpSN }, |
||||
|
type: 'POST', |
||||
|
success: function (data) { |
||||
|
if (data.success) { |
||||
|
obj.del(); //只删本地数据 |
||||
|
hg.msghide("删除成功!"); |
||||
|
} |
||||
|
else { |
||||
|
hg.msg(data.msg); |
||||
|
} |
||||
|
}, |
||||
|
error: function () { |
||||
|
hg.msg("网络请求失败!"); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
var toolbar = [{ |
||||
|
text: '新增', |
||||
|
layuiicon: '', |
||||
|
class: 'layui-btn-normal', |
||||
|
handler: function () { |
||||
|
hg.open('新增序號料號', '/KCS/KCS002C', 640, 320); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
]; |
||||
|
//基本数据表格 |
||||
|
var table = hg.table.datatable('test', '序號料號維護', '/KCS/GetPartMaps', {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']); |
||||
|
</script> |
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.PartMap |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "KCS002C"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; } |
||||
|
|
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !important; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" method="post" asp-action="KCS002CSave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CorpSN" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="CorpSN" class="form-control col-sm-9" placeholder="請輸入序號" /> |
||||
|
<span asp-validation-for="CorpSN" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CorpPN" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="CorpPN" class="form-control col-sm-9" placeholder="請輸入料號" /> |
||||
|
<span asp-validation-for="CorpPN" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</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"> |
||||
|
$(document).ready(function () { |
||||
|
var error = '@Html.ValidationMessage("error")'; |
||||
|
if ($(error).text() != '') { |
||||
|
parent.hg.msg(error); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,53 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.PartMap |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "KCS002U"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; } |
||||
|
|
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !important; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" method="post" asp-action="KCS002USave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CorpSN" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="CorpSN" class="form-control col-sm-9" placeholder="請輸入序號" readonly="readonly" /> |
||||
|
<span asp-validation-for="CorpSN" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CorpPN" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="CorpPN" class="form-control col-sm-9" placeholder="請輸入料號" /> |
||||
|
<span asp-validation-for="CorpPN" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</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"> |
||||
|
$(document).ready(function () { |
||||
|
var error = '@Html.ValidationMessage("error")'; |
||||
|
if ($(error).text() != '') { |
||||
|
parent.hg.msg(error); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,90 @@ |
|||||
|
@{ |
||||
|
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"> |
||||
|
<table class="layui-hide" id="test" lay-filter="test"></table> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts{ |
||||
|
<script type="text/javascript"> |
||||
|
//监听表单提交事件 |
||||
|
hg.form.onsubmit('querysubmit', function (data) { |
||||
|
table && table.reload(data); |
||||
|
}); |
||||
|
var tableCols = [[ |
||||
|
{ |
||||
|
field: 'itemNo', |
||||
|
width: 200, |
||||
|
title: '組件類別代碼' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'itemName', |
||||
|
title: '組件類別名稱' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'right', |
||||
|
width: 200, |
||||
|
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> <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del">删除</a>' |
||||
|
} |
||||
|
}] |
||||
|
]; |
||||
|
|
||||
|
//通过行tool编辑,lay-event="edit" |
||||
|
function edit(obj) { |
||||
|
if (obj.data.itemNo) { |
||||
|
hg.open('修改組件類別', '/PPS/PPS015U/' + obj.data.itemNo, 640,320); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//通过行tool删除,lay-event="del" |
||||
|
function del(obj) { |
||||
|
if (obj.data.itemNo) { |
||||
|
hg.confirm("組件類別:" + obj.data.itemName + ",确定要删除吗?", function () { |
||||
|
$.ajax({ |
||||
|
url: '/PPS/PPS015D', |
||||
|
data: { id: obj.data.itemNo }, |
||||
|
type: 'POST', |
||||
|
success: function (data) { |
||||
|
if (data.success) { |
||||
|
obj.del(); //只删本地数据 |
||||
|
hg.msghide("删除成功!"); |
||||
|
} |
||||
|
else { |
||||
|
hg.msg(data.msg); |
||||
|
} |
||||
|
}, |
||||
|
error: function () { |
||||
|
hg.msg("网络请求失败!"); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
var toolbar = [{ |
||||
|
text: '新增', |
||||
|
layuiicon: '', |
||||
|
class: 'layui-btn-normal', |
||||
|
handler: function () { |
||||
|
hg.open('新增組件類別', '/PPS/PPS015C', 640, 320); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
]; |
||||
|
//基本数据表格 |
||||
|
var table = hg.table.datatable('test', '組件類別維護', '/PPS/GetRepairItems', {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']); |
||||
|
</script> |
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.RepairItem |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "PPS015C"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; } |
||||
|
|
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !important; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" method="post" asp-action="PPS015CSave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ItemNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ItemNo" class="form-control col-sm-9" placeholder="請輸入組件類別代碼" /> |
||||
|
<span asp-validation-for="ItemNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ItemName" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ItemName" class="form-control col-sm-9" placeholder="請輸入組件類別名稱" /> |
||||
|
<span asp-validation-for="ItemName" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</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"> |
||||
|
$(document).ready(function () { |
||||
|
var error = '@Html.ValidationMessage("error")'; |
||||
|
if ($(error).text() != '') { |
||||
|
parent.hg.msg(error); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,53 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.RepairItem |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "PPS015U"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; } |
||||
|
|
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !important; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" method="post" asp-action="PPS015USave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ItemNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ItemNo" class="form-control col-sm-9" placeholder="請輸入組件類別代碼" readonly="readonly" /> |
||||
|
<span asp-validation-for="ItemNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ItemName" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ItemName" class="form-control col-sm-9" placeholder="請輸入組件類別名稱" /> |
||||
|
<span asp-validation-for="ItemName" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</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"> |
||||
|
$(document).ready(function () { |
||||
|
var error = '@Html.ValidationMessage("error")'; |
||||
|
if ($(error).text() != '') { |
||||
|
parent.hg.msg(error); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,191 @@ |
|||||
|
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 PartMapsController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
public PartMapsController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/PartMaps
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<PartMap>>> GetPartMap(int page = 1, int limit = 10) |
||||
|
{ |
||||
|
IQueryable<PartMap> q = _context.PartMaps; |
||||
|
if (page > 0) |
||||
|
{ |
||||
|
q = q.OrderBy(p => p.CorpSN).Skip((page - 1) * limit).Take(limit); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
q = q.OrderBy(p => p.CorpSN); |
||||
|
} |
||||
|
|
||||
|
var partMap = await q.ToListAsync(); |
||||
|
return partMap; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/PartMaps/5
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<IEnumerable<PartMap>>> GetPartMap(string id) |
||||
|
{ |
||||
|
IQueryable<PartMap> q = _context.PartMaps; |
||||
|
q = q.Where(p => p.CorpSN == id); |
||||
|
|
||||
|
var partMap = await q.ToListAsync(); |
||||
|
|
||||
|
if (partMap == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return partMap; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <param name="partMap"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// PUT: api/PartMaps/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<PartMap>> PutPartMap(string id, [FromBody] PartMap partMap) |
||||
|
{ |
||||
|
ResultModel<PartMap> result = new ResultModel<PartMap>(); |
||||
|
|
||||
|
if (id != partMap.CorpSN) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "序號錯誤"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
_context.Entry(partMap).State = EntityState.Modified; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateConcurrencyException) |
||||
|
{ |
||||
|
if (!PartMapExists(id)) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "序號不存在"; |
||||
|
return result; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="partMap"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// POST: api/PartMaps
|
||||
|
// 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<PartMap>> PostPartMap([FromBody]PartMap partMap) |
||||
|
{ |
||||
|
ResultModel<PartMap> result = new ResultModel<PartMap>(); |
||||
|
|
||||
|
_context.PartMaps.Add(partMap); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateException) |
||||
|
{ |
||||
|
if (PartMapExists(partMap.CorpSN)) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "序號重複"; |
||||
|
return result; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// DELETE: api/PartMaps/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ResultModel<PartMap>> DeletePartMap(string id) |
||||
|
{ |
||||
|
ResultModel<PartMap> result = new ResultModel<PartMap>(); |
||||
|
|
||||
|
var partMap = await _context.PartMaps.FindAsync(id); |
||||
|
if (partMap == null) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "序號不存在"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
_context.PartMaps.Remove(partMap); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
private bool PartMapExists(string id) |
||||
|
{ |
||||
|
return _context.PartMaps.Any(e => e.CorpSN == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,189 @@ |
|||||
|
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 RepairItemsController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
public RepairItemsController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/RepairItems
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<RepairItem>>> GetRepairItem(int page = 1, int limit = 10) |
||||
|
{ |
||||
|
IQueryable<RepairItem> q = _context.RepairItems; |
||||
|
if (page > 0) |
||||
|
{ |
||||
|
q = q.OrderBy(p => p.ItemNo).Skip((page - 1) * limit).Take(limit); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
q = q.OrderBy(p => p.ItemNo); |
||||
|
} |
||||
|
|
||||
|
var repairItem = await q.ToListAsync(); |
||||
|
return repairItem; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/RepairItems/5
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<IEnumerable<RepairItem>>> GetRepairItem(string id) |
||||
|
{ |
||||
|
IQueryable<RepairItem> q = _context.RepairItems; |
||||
|
q = q.Where(p => p.ItemNo.Equals(id)); |
||||
|
|
||||
|
var repairItem = await q.ToListAsync(); |
||||
|
|
||||
|
if (repairItem == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return repairItem; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <param name="repairItem"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// PUT: api/RepairItems/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<RepairItem>> PutRepairItem(string id, [FromBody] RepairItem repairItem) |
||||
|
{ |
||||
|
ResultModel<RepairItem> result = new ResultModel<RepairItem>(); |
||||
|
|
||||
|
if (id != repairItem.ItemNo) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "組件類別代碼錯誤"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
_context.Entry(repairItem).State = EntityState.Modified; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateConcurrencyException) |
||||
|
{ |
||||
|
if (!RepairItemExists(id)) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "組件類別代碼不存在"; |
||||
|
return result; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="repairItem"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// POST: api/RepairItems
|
||||
|
// 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<RepairItem>> PostRepairItem([FromBody] RepairItem repairItem) |
||||
|
{ |
||||
|
ResultModel<RepairItem> result = new ResultModel<RepairItem>(); |
||||
|
_context.RepairItems.Add(repairItem); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateException) |
||||
|
{ |
||||
|
if (RepairItemExists(repairItem.ItemNo)) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "組件類別代碼重複"; |
||||
|
return result; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// DELETE: api/RepairItems/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ResultModel<RepairItem>> DeleteRepairItem(string id) |
||||
|
{ |
||||
|
ResultModel<RepairItem> result = new ResultModel<RepairItem>(); |
||||
|
var repairItem = await _context.RepairItems.FindAsync(id); |
||||
|
if (repairItem == null) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "組件類別不存在"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
_context.RepairItems.Remove(repairItem); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
private bool RepairItemExists(string id) |
||||
|
{ |
||||
|
return _context.RepairItems.Any(e => e.ItemNo == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Runtime.Serialization; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 序號料號資料表
|
||||
|
/// </summary>
|
||||
|
[Table("PART_MAP", Schema = "JHAMES")] |
||||
|
public class PartMap |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 序號
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("CORP_SN")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "序號")] |
||||
|
[StringLength(40, ErrorMessage = "{0},不能大于{1}")] |
||||
|
[DataMember] |
||||
|
public string CorpSN { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號
|
||||
|
/// </summary>
|
||||
|
[Column("CORP_PN")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "料號")] |
||||
|
[StringLength(30, ErrorMessage = "{0},不能大于{1}")] |
||||
|
public string CorpPN { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 序號狀態
|
||||
|
/// </summary>
|
||||
|
[Column("SN_STATUS")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "序號狀態")] |
||||
|
public int SNStatus { get; set; } = 0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立者
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_USERID")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "建立者")] |
||||
|
public decimal CreateUserID { get; set; } = 0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立時間
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_DATE")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "建立時間")] |
||||
|
public DateTime CreateDate { get; set; } = DateTime.Now; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 修改時間
|
||||
|
/// </summary>
|
||||
|
[Column("UPDATE_DATE")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "修改時間")] |
||||
|
public DateTime UpdateDate { get; set; } = DateTime.Now; |
||||
|
} |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Runtime.Serialization; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 組件類別資料表
|
||||
|
/// </summary>
|
||||
|
[Table("REPAIR_ITEM", Schema = "JHAMES")] |
||||
|
[DataContract] |
||||
|
public class RepairItem |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 組件類別代碼
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("ITEM_NO")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "組件類別代碼")] |
||||
|
[StringLength(6, ErrorMessage = "{0},不能大于{1}")] |
||||
|
[DataMember] |
||||
|
public string ItemNo { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 組件類別名稱
|
||||
|
/// </summary>
|
||||
|
[Column("ITEM_NAME")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "組件類別名稱")] |
||||
|
[StringLength(50, ErrorMessage = "{0},不能大于{1}")] |
||||
|
public string ItemName { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue