9 changed files with 638 additions and 0 deletions
@ -0,0 +1,95 @@ |
|||
@{ |
|||
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: 'keyPartNo', |
|||
title: '組件料號' |
|||
}, |
|||
{ |
|||
field: 'keyPartSn', |
|||
width: 300, |
|||
title: '組件序號' |
|||
}, |
|||
{ |
|||
field: 'poNo', |
|||
width: 200, |
|||
title: '訂單No' |
|||
}, |
|||
{ |
|||
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.keyPartSn) { |
|||
hg.open('修改組件料號序號', '/KCS/KCS004U/' + obj.data.keyPartSn, 640,320); |
|||
} |
|||
} |
|||
|
|||
//通过行tool删除,lay-event="del" |
|||
function del(obj) { |
|||
if (obj.data.keyPartSn) { |
|||
hg.confirm("組件料號序號:" + obj.data.keyPartNo + "," + obj.data.keyPartSn + ",确定要删除吗?", function () { |
|||
$.ajax({ |
|||
url: '/KCS/KCS004D', |
|||
data: { id: obj.data.keyPartSn }, |
|||
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/KCS004C', 640, 320); |
|||
|
|||
} |
|||
} |
|||
]; |
|||
//基本数据表格 |
|||
var table = hg.table.datatable('test', '組件料號序號維護', '/KCS/GetKPLinks', {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']); |
|||
</script> |
|||
} |
@ -0,0 +1,58 @@ |
|||
@model AMESCoreStudio.WebApi.Models.AMES.KPLink |
|||
|
|||
|
|||
@{ ViewData["Title"] = "KCS004C"; |
|||
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="KCS004CSave"> |
|||
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
|||
|
|||
<div class="form-group form-inline my-sm-1"> |
|||
<label asp-for="KeyPartNo" class="control-label col-sm-3"></label> |
|||
<input asp-for="KeyPartNo" class="form-control col-sm-9" placeholder="請輸入組件料號" /> |
|||
<span asp-validation-for="KeyPartNo" class="text-danger offset-sm-3 my-sm-1"></span> |
|||
</div> |
|||
<div class="form-group form-inline my-sm-1"> |
|||
<label asp-for="KeyPartSn" class="control-label col-sm-3"></label> |
|||
<input asp-for="KeyPartSn" class="form-control col-sm-9" placeholder="請輸入組件序號" /> |
|||
<span asp-validation-for="KeyPartSn" class="text-danger offset-sm-3 my-sm-1"></span> |
|||
</div> |
|||
<div class="form-group form-inline my-sm-1"> |
|||
<label asp-for="PoNo" class="control-label col-sm-3"></label> |
|||
<input asp-for="PoNo" class="form-control col-sm-9" placeholder="請輸入訂單號碼" /> |
|||
<span asp-validation-for="PoNo" 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,58 @@ |
|||
@model AMESCoreStudio.WebApi.Models.AMES.KPLink |
|||
|
|||
|
|||
@{ ViewData["Title"] = "KCS004U"; |
|||
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="KCS004USave"> |
|||
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
|||
|
|||
<div class="form-group form-inline my-sm-1"> |
|||
<label asp-for="KeyPartNo" class="control-label col-sm-3"></label> |
|||
<input asp-for="KeyPartNo" class="form-control col-sm-9" placeholder="請輸入組件料號" /> |
|||
<span asp-validation-for="KeyPartNo" class="text-danger offset-sm-3 my-sm-1"></span> |
|||
</div> |
|||
<div class="form-group form-inline my-sm-1"> |
|||
<label asp-for="KeyPartSn" class="control-label col-sm-3"></label> |
|||
<input asp-for="KeyPartSn" class="form-control col-sm-9" placeholder="請輸入組件序號" readonly="readonly" /> |
|||
<span asp-validation-for="KeyPartSn" class="text-danger offset-sm-3 my-sm-1"></span> |
|||
</div> |
|||
<div class="form-group form-inline my-sm-1"> |
|||
<label asp-for="PoNo" class="control-label col-sm-3"></label> |
|||
<input asp-for="PoNo" class="form-control col-sm-9" placeholder="請輸入訂單號碼" /> |
|||
<span asp-validation-for="PoNo" 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,190 @@ |
|||
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 KPLinksController : ControllerBase |
|||
{ |
|||
private readonly AMESContext _context; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="context"></param>
|
|||
public KPLinksController(AMESContext context) |
|||
{ |
|||
_context = context; |
|||
} |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
// GET: api/KPLinks
|
|||
[HttpGet] |
|||
public async Task<ActionResult<IEnumerable<KPLink>>> GetKPLink(int page = 1, int limit = 10) |
|||
{ |
|||
IQueryable<KPLink> q = _context.KPLinks; |
|||
if (page > 0) |
|||
{ |
|||
q = q.OrderBy(p => p.KeyPartNo + p.KeyPartSn).Skip((page - 1) * limit).Take(limit); |
|||
} |
|||
else |
|||
{ |
|||
q = q.OrderBy(p => p.KeyPartNo + p.KeyPartSn); |
|||
} |
|||
|
|||
var kpLink = await q.ToListAsync(); |
|||
return kpLink; |
|||
} |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <returns></returns>
|
|||
// GET: api/KPLinks/5
|
|||
[HttpGet("{id}")] |
|||
public async Task<ActionResult<IEnumerable<KPLink>>> GetKPLink(string id) |
|||
{ |
|||
IQueryable<KPLink> q = _context.KPLinks; |
|||
q = q.Where(p => p.KeyPartSn.Equals(id)); |
|||
|
|||
var kpLink = await q.ToListAsync(); |
|||
|
|||
if (kpLink == null) |
|||
{ |
|||
return NotFound(); |
|||
} |
|||
|
|||
return kpLink; |
|||
} |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <param name="kPLink"></param>
|
|||
/// <returns></returns>
|
|||
// PUT: api/KPLinks/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<KPLink>> PutKPLink(string id, [FromBody]KPLink kPLink) |
|||
{ |
|||
ResultModel<KPLink> result = new ResultModel<KPLink>(); |
|||
|
|||
if (id != kPLink.KeyPartSn) |
|||
{ |
|||
result.Success = false; |
|||
result.Msg = "序號錯誤"; |
|||
return result; |
|||
} |
|||
|
|||
_context.Entry(kPLink).State = EntityState.Modified; |
|||
|
|||
try |
|||
{ |
|||
await _context.SaveChangesAsync(); |
|||
} |
|||
catch (DbUpdateConcurrencyException) |
|||
{ |
|||
if (!KPLinkExists(id)) |
|||
{ |
|||
result.Success = false; |
|||
result.Msg = "序號不存在"; |
|||
return result; |
|||
} |
|||
else |
|||
{ |
|||
throw; |
|||
} |
|||
} |
|||
|
|||
result.Success = true; |
|||
result.Msg = "OK"; |
|||
return result; |
|||
} |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="kPLink"></param>
|
|||
/// <returns></returns>
|
|||
// POST: api/KPLinks
|
|||
// 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<KPLink>> PostKPLink([FromBody]KPLink kPLink) |
|||
{ |
|||
ResultModel<KPLink> result = new ResultModel<KPLink>(); |
|||
_context.KPLinks.Add(kPLink); |
|||
try |
|||
{ |
|||
await _context.SaveChangesAsync(); |
|||
} |
|||
catch (DbUpdateException) |
|||
{ |
|||
if (KPLinkExists(kPLink.KeyPartSn)) |
|||
{ |
|||
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/KPLinks/5
|
|||
[HttpDelete("{id}")] |
|||
public async Task<ResultModel<KPLink>> DeleteKPLink(string id) |
|||
{ |
|||
ResultModel<KPLink> result = new ResultModel<KPLink>(); |
|||
|
|||
var kPLink = await _context.KPLinks.FindAsync(id); |
|||
if (kPLink == null) |
|||
{ |
|||
result.Success = false; |
|||
result.Msg = "序號不存在"; |
|||
return result; |
|||
} |
|||
|
|||
_context.KPLinks.Remove(kPLink); |
|||
await _context.SaveChangesAsync(); |
|||
|
|||
result.Success = true; |
|||
result.Msg = "OK"; |
|||
return result; |
|||
} |
|||
|
|||
private bool KPLinkExists(string id) |
|||
{ |
|||
return _context.KPLinks.Any(e => e.KeyPartSn == id); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,83 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.ComponentModel.DataAnnotations.Schema; |
|||
using System.Runtime.Serialization; |
|||
|
|||
namespace AMESCoreStudio.WebApi.Models.AMES |
|||
{ |
|||
/// <summary>
|
|||
/// 組件料號序號資料表
|
|||
/// </summary>
|
|||
[Table("KP_LINK", Schema = "JHAMES")] |
|||
public class KPLink |
|||
{ |
|||
/// <summary>
|
|||
/// 組件料號
|
|||
/// </summary>
|
|||
|
|||
[Column("KEY_PART_NO")] |
|||
[Required(ErrorMessage = "{0},不能空白")] |
|||
[Display(Name = "組件料號")] |
|||
[StringLength(20, ErrorMessage = "{0},不能大于{1}")] |
|||
[DataMember] |
|||
public string KeyPartNo { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 組件序號
|
|||
/// </summary>
|
|||
[Key] |
|||
[Column("KEY_PART_SN")] |
|||
[DataMember] |
|||
[Required(ErrorMessage = "{0},不能空白")] |
|||
[Display(Name = "組件序號")] |
|||
[StringLength(40, ErrorMessage = "{0},不能大于{1}")] |
|||
public string KeyPartSn { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 訂單NO
|
|||
/// </summary>
|
|||
[Column("PO_NO")] |
|||
[DataMember] |
|||
[Required(ErrorMessage = "{0},不能空白")] |
|||
[Display(Name = "訂單NO")] |
|||
[StringLength(20, ErrorMessage = "{0},不能大于{1}")] |
|||
public string PoNo { get; set; } |
|||
|
|||
/// <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_USERID")] |
|||
[DataMember] |
|||
[Required(ErrorMessage = "{0},不能空白")] |
|||
[Display(Name = "建立者")] |
|||
public decimal UpdateUserID { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 修改時間
|
|||
/// </summary>
|
|||
[Column("UPDATE_DATE")] |
|||
[DataMember] |
|||
[Required(ErrorMessage = "{0},不能空白")] |
|||
[Display(Name = "修改時間")] |
|||
public DateTime UpdateDate { get; set; } = DateTime.Now; |
|||
} |
|||
} |
Loading…
Reference in new issue