Browse Source
2.修改異常類別維護PPS006 3.修改流程資料維護BAS009 4.修改流程站別維護BAS010 5.修改流程規則維護BAS011 6.修改菜單樣式,修改模組名稱字體顏色PTD
17 changed files with 951 additions and 28 deletions
@ -0,0 +1,172 @@ |
|||||
|
@{ |
||||
|
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 class="layui-form-item layui-layout-left"> |
||||
|
<div class="layui-inline"> |
||||
|
<label class="layui-form-label">請選擇群組</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<select id="errorGroup" lay-filter="errorGroup" lay-verify="required" lay-submit asp-items="@ViewBag.ErrorGroupList"> |
||||
|
</select> |
||||
|
</div> |
||||
|
<input id="errorGroupNo" type="hidden" name="errorGroupNo" value="0" /> |
||||
|
<label class="layui-form-label">請選擇類別</label> |
||||
|
<div class="layui-input-inline"> |
||||
|
<select id="errorClass" lay-filter="errorClass" lay-verify="required" lay-submit asp-items="@ViewBag.ErrorClassList"> |
||||
|
</select> |
||||
|
</div> |
||||
|
<input id="errorClassNo" type="hidden" name="errorClassNo" value="0" /> |
||||
|
</div> |
||||
|
<div class="layui-inline layui-show-xs-block"> |
||||
|
<button 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> |
||||
|
<div class="layui-card-body"> |
||||
|
<table class="layui-hide" id="test" lay-filter="test"></table> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts{ |
||||
|
<script type="text/javascript"> |
||||
|
|
||||
|
function getErrorClassList(data) |
||||
|
{ |
||||
|
$.ajax( |
||||
|
{ |
||||
|
url: "@Url.Action("GetErrorClassJson", "PPS")", |
||||
|
dataType: 'json', |
||||
|
data: { "group_no": $("#errorGroupNo").val()}, |
||||
|
//contentType: "application/json", |
||||
|
type: 'post', |
||||
|
success: function (result) |
||||
|
{ |
||||
|
console.info(result.data); |
||||
|
$("#errorClass").empty();//清空下拉框的值 |
||||
|
$.each(result.data, function (index, item) { |
||||
|
$("#errorClass").append(new Option(item.text, item.value));// 下拉菜单里添加元素 |
||||
|
//$("#errorClass").append($("<option>").text(item.text).val(item.value)) |
||||
|
}); |
||||
|
|
||||
|
layui.form.render("select");//重新渲染 固定写法 |
||||
|
}, |
||||
|
error: function (result) |
||||
|
{ |
||||
|
alert(result); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
layui.use(['form', 'layer'], function () { |
||||
|
form = layui.form; |
||||
|
|
||||
|
form.on('select(errorGroup)', function (data) { |
||||
|
$("#errorGroupNo").val(data.value); |
||||
|
|
||||
|
getErrorClassList(data.value); |
||||
|
|
||||
|
var qs = $('button[lay-filter="querysubmit"]'); |
||||
|
qs.click(); |
||||
|
|
||||
|
hg.msghide("刷新数据!"); |
||||
|
table && table.reload(); |
||||
|
}); |
||||
|
|
||||
|
form.on('select(errorClass)', function (data) { |
||||
|
$("#errorClassNo").val(data.value); |
||||
|
|
||||
|
var qs = $('button[lay-filter="querysubmit"]'); |
||||
|
qs.click(); |
||||
|
|
||||
|
hg.msghide("刷新数据!"); |
||||
|
table && table.reload(); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
//监听表单提交事件 |
||||
|
hg.form.onsubmit('querysubmit', function (data) { |
||||
|
table && table.reload(data); |
||||
|
}); |
||||
|
var tableCols = [[ |
||||
|
{ |
||||
|
field: 'reasonNo', |
||||
|
width: 200, |
||||
|
title: '異常原因代碼' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'reasonDesc', |
||||
|
title: '異常原因描述' |
||||
|
}, |
||||
|
{ |
||||
|
field: 'errorType', |
||||
|
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.reasonNo) { |
||||
|
var no = errorGroupNo.value; |
||||
|
hg.open('修改異常原因', '/PPS/PPS007U/' + obj.data.reasonNo + ',' + no, 800, 640); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//通过行tool删除,lay-event="del" |
||||
|
function del(obj) { |
||||
|
if (obj.data.reasonNo) { |
||||
|
hg.confirm("異常原因:" + obj.data.reasonDesc + ",确定要删除吗?", function () { |
||||
|
$.ajax({ |
||||
|
url: '/PPS/PPS007D', |
||||
|
data: { id: obj.data.reasonNo }, |
||||
|
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 () { |
||||
|
var id = errorClassNo.value; |
||||
|
var no = errorGroupNo.value; |
||||
|
hg.open('新增異常原因', '/PPS/PPS007C/' + id + ',' + no, 800, 640); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
]; |
||||
|
//基本数据表格 |
||||
|
var table = hg.table.datatable('test', '異常原因維護', '/PPS/GetErrorReasonsByClass/' + errorClassNo.value, {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']); |
||||
|
</script> |
||||
|
} |
@ -0,0 +1,88 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.ErrorReason |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "PPS007C"; |
||||
|
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="PPS007CSave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ReasonNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ReasonNo" class="form-control col-sm-9" placeholder="請輸入異常原因代碼" /> |
||||
|
<span asp-validation-for="ReasonNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ClassNo" class="control-label col-sm-3"></label> |
||||
|
<select asp-for="ClassNo" asp-items="@ViewBag.ErrorClassList" class="custom-select col-sm-9"></select> |
||||
|
<span asp-validation-for="ClassNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ReasonDesc" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ReasonDesc" class="form-control col-sm-9" placeholder="請輸入異常原因描述" /> |
||||
|
<span asp-validation-for="ReasonDesc" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ReasonDescEn" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ReasonDescEn" class="form-control col-sm-9" placeholder="請輸入異常原因英文描述" /> |
||||
|
<span asp-validation-for="ReasonDescEn" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ResponseDept" class="control-label col-sm-3"></label> |
||||
|
<select asp-for="ResponseDept" asp-items="@ViewBag.ResponseDeptList" class="custom-select col-sm-9"></select> |
||||
|
<span asp-validation-for="ResponseDept" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ErrorType" class="control-label col-sm-3"></label> |
||||
|
<select asp-for="ErrorType" asp-items="Html.GetEnumSelectList<AMESCoreStudio.WebApi.EnumErrorType>()" class="custom-select col-sm-8"></select> |
||||
|
<span asp-validation-for="ErrorType" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="KpiNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="KpiNo" class="form-control col-sm-9" placeholder="請輸入內部流程代碼" /> |
||||
|
<span asp-validation-for="KpiNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CostNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="CostNo" class="form-control col-sm-9" placeholder="請輸入成本屬性代碼" /> |
||||
|
<span asp-validation-for="CostNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="SectionNo" class="control-label col-sm-3"></label> |
||||
|
<select asp-for="SectionNo" asp-items="@ViewBag.SectionList" class="custom-select col-sm-9"></select> |
||||
|
<span asp-validation-for="SectionNo" 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,88 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.ErrorReason |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "PPS007U"; |
||||
|
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="PPS007USave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ReasonNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ReasonNo" class="form-control col-sm-9" placeholder="請輸入異常原因代碼" /> |
||||
|
<span asp-validation-for="ReasonNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ClassNo" class="control-label col-sm-3"></label> |
||||
|
<select asp-for="ClassNo" asp-items="@ViewBag.ErrorClassList" class="custom-select col-sm-9"></select> |
||||
|
<span asp-validation-for="ClassNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ReasonDesc" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ReasonDesc" class="form-control col-sm-9" placeholder="請輸入異常原因描述" /> |
||||
|
<span asp-validation-for="ReasonDesc" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ReasonDescEn" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ReasonDescEn" class="form-control col-sm-9" placeholder="請輸入異常原因英文描述" /> |
||||
|
<span asp-validation-for="ReasonDescEn" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ResponseDept" class="control-label col-sm-3"></label> |
||||
|
<select asp-for="ResponseDept" asp-items="@ViewBag.ResponseDeptList" class="custom-select col-sm-9"></select> |
||||
|
<span asp-validation-for="ResponseDept" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ErrorType" class="control-label col-sm-3"></label> |
||||
|
<select asp-for="ErrorType" asp-items="Html.GetEnumSelectList<AMESCoreStudio.WebApi.EnumErrorType>()" class="custom-select col-sm-8"></select> |
||||
|
<span asp-validation-for="ErrorType" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="KpiNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="KpiNo" class="form-control col-sm-9" placeholder="請輸入內部流程代碼" /> |
||||
|
<span asp-validation-for="KpiNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="CostNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="CostNo" class="form-control col-sm-9" placeholder="請輸入成本屬性代碼" /> |
||||
|
<span asp-validation-for="CostNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="SectionNo" class="control-label col-sm-3"></label> |
||||
|
<select asp-for="SectionNo" asp-items="@ViewBag.SectionList" class="custom-select col-sm-9"></select> |
||||
|
<span asp-validation-for="SectionNo" 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,196 @@ |
|||||
|
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; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 異常原因維護
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class ErrorReasonsController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
public ErrorReasonsController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/ErrorReasons
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<ErrorReason>>> GetErrorReason() |
||||
|
{ |
||||
|
IQueryable<ErrorReason> q = _context.ErrorReasons; |
||||
|
|
||||
|
q = q.OrderBy(p => p.ReasonNo); |
||||
|
|
||||
|
var errorReason = await q.ToListAsync(); |
||||
|
|
||||
|
return errorReason; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/ErrorReasons/5
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<IEnumerable<ErrorReason>>> GetErrorReason(string id) |
||||
|
{ |
||||
|
IQueryable<ErrorReason> q = _context.ErrorReasons; |
||||
|
q = q.Where(p => p.ReasonNo.Equals(id)); |
||||
|
|
||||
|
var errorReason = await q.ToListAsync(); |
||||
|
|
||||
|
if (errorReason == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return errorReason; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据異常類別獲取該類別異常原因資料
|
||||
|
/// </summary>
|
||||
|
/// <param name="no"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/ErrorReasons/Class/S
|
||||
|
[HttpGet("Class/{no}")] |
||||
|
public async Task<ActionResult<IEnumerable<ErrorReason>>> GetErrorReasonByClass(string no) |
||||
|
{ |
||||
|
IQueryable<ErrorReason> q = _context.ErrorReasons; |
||||
|
|
||||
|
if (no != null) |
||||
|
{ |
||||
|
if (no != "*") |
||||
|
{ |
||||
|
q = q.Where(p => p.ClassNo.Equals(no)); |
||||
|
} |
||||
|
} |
||||
|
q = q.OrderBy(p => p.ClassNo + p.ReasonNo); |
||||
|
|
||||
|
var errorReason = await q.ToListAsync(); |
||||
|
|
||||
|
if (errorReason == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return errorReason; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <param name="errorReason"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// PUT: api/ErrorReasons/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<ActionResult<ErrorReason>> PutErrorReason(string id, [FromBody] ErrorReason errorReason) |
||||
|
{ |
||||
|
if (id != errorReason.ReasonNo) |
||||
|
{ |
||||
|
return BadRequest(); |
||||
|
} |
||||
|
|
||||
|
_context.Entry(errorReason).State = EntityState.Modified; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateConcurrencyException) |
||||
|
{ |
||||
|
if (!ErrorReasonExists(id)) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return errorReason; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="errorReason"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// POST: api/ErrorReasons
|
||||
|
// 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<ActionResult<ErrorReason>> PostErrorReason(ErrorReason errorReason) |
||||
|
{ |
||||
|
_context.ErrorReasons.Add(errorReason); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateException) |
||||
|
{ |
||||
|
if (ErrorReasonExists(errorReason.ReasonNo)) |
||||
|
{ |
||||
|
return Conflict(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return CreatedAtAction("GetErrorReason", new { id = errorReason.ReasonNo }, errorReason); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// DELETE: api/ErrorReasons/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ActionResult<ErrorReason>> DeleteErrorReason(string id) |
||||
|
{ |
||||
|
var errorReason = await _context.ErrorReasons.Where(p => p.ReasonNo == id).FirstOrDefaultAsync(); |
||||
|
|
||||
|
if (errorReason == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
_context.ErrorReasons.Remove(errorReason); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
return errorReason; |
||||
|
} |
||||
|
|
||||
|
private bool ErrorReasonExists(string id) |
||||
|
{ |
||||
|
return _context.ErrorReasons.Any(e => e.ReasonNo == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
using System.ComponentModel; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
public enum EnumErrorType |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 外部異常
|
||||
|
/// </summary>
|
||||
|
[Description("外部異常")] |
||||
|
[Display(Name = "外部異常")] |
||||
|
External, |
||||
|
/// <summary>
|
||||
|
/// 內部異常
|
||||
|
/// </summary>
|
||||
|
[Description("內部異常")] |
||||
|
[Display(Name = "內部異常")] |
||||
|
Internal |
||||
|
} |
||||
|
} |
@ -0,0 +1,103 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Runtime.Serialization; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 异常代码资料表
|
||||
|
/// </summary>
|
||||
|
[Table("ERROR_REASON", Schema = "JHAMES")] |
||||
|
[DataContract] |
||||
|
public class ErrorReason |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 異常原因代碼
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("REASON_NO")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "異常原因代碼")] |
||||
|
[StringLength(6, ErrorMessage = "{0},不能大于{1}")] |
||||
|
[DataMember] |
||||
|
public string ReasonNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 異常類別代碼
|
||||
|
/// </summary>
|
||||
|
[Column("CLASS_NO")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "異常類別代碼")] |
||||
|
[StringLength(6, ErrorMessage = "{0},不能大于{1}")] |
||||
|
[DataMember] |
||||
|
public string ClassNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 異常原因描述
|
||||
|
/// </summary>
|
||||
|
[Column("REASON_DESC")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "異常原因描述")] |
||||
|
[StringLength(100, ErrorMessage = "{0},不能大于{1}")] |
||||
|
[DataMember] |
||||
|
public string ReasonDesc { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 異常原因英文描述
|
||||
|
/// </summary>
|
||||
|
[Column("REASON_DESC_EN")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "異常原因英文描述")] |
||||
|
[StringLength(100, ErrorMessage = "{0},不能大于{1}")] |
||||
|
[DataMember] |
||||
|
public string ReasonDescEn { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 內外部損耗分類
|
||||
|
/// </summary>
|
||||
|
[Column("ERROR_TYPE")] |
||||
|
[Display(Name = "內外部損耗分類")] |
||||
|
[DataMember] |
||||
|
public EnumErrorType ErrorType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 責任單位
|
||||
|
/// </summary>
|
||||
|
[Column("RESPONSE_DEPT")] |
||||
|
[DataMember] |
||||
|
[Required] |
||||
|
[Display(Name = "責任單位")] |
||||
|
public int ResponseDept { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 內部流程代碼
|
||||
|
/// </summary>
|
||||
|
[Column("KPI_NO")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "內部流程代碼")] |
||||
|
[StringLength(20, ErrorMessage = "{0},不能大于{1}")] |
||||
|
[DataMember] |
||||
|
public string KpiNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 成本屬性代碼
|
||||
|
/// </summary>
|
||||
|
[Column("COST_NO")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[Display(Name = "成本屬性代碼")] |
||||
|
[StringLength(6, ErrorMessage = "{0},不能大于{1}")] |
||||
|
[DataMember] |
||||
|
public string CostNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 生產單位
|
||||
|
/// </summary>
|
||||
|
[Column("SECTION_NO")] |
||||
|
[DataMember] |
||||
|
[Display(Name = "生產單位")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
[StringLength(6, ErrorMessage = "{0},不能大于{1}")] |
||||
|
public string SectionNo { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue