diff --git a/AMESCoreStudio.Web/Controllers/KCSController.cs b/AMESCoreStudio.Web/Controllers/KCSController.cs index 03267dbc..59a10db5 100644 --- a/AMESCoreStudio.Web/Controllers/KCSController.cs +++ b/AMESCoreStudio.Web/Controllers/KCSController.cs @@ -21,6 +21,21 @@ namespace AMESCoreStudio.Web.Controllers _kcsApi = kcsApi; } + private async Task GetMaxClassGroup() + { + var result = await _kcsApi.GetMACInfo("DESC"); + + if (result.Count == 0) + { + ViewBag.MaxClassGroup = ""; + } + else + { + ViewBag.MaxClassGroup = result[0].ClassGroup; + } + + } + private async Task GetItemType() { var ItemTypeList = new List(); @@ -53,6 +68,116 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.SNIntervalList = SNIntervalList; } + #region KCS001 MAC資料維護相關 + + public IActionResult KCS001() + { + return View(); + } + + //新增頁面 + public async Task KCS001C() + { + await GetMaxClassGroup(); + + return View(); + } + + //修改页面 + [HttpGet] + public async Task KCS001UAsync(string id) + { + var result = await _kcsApi.GetMACInfo(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task KCS001DAsync(string id) + { + var result = await _kcsApi.DeleteMACInfo(id); + return Json(new Result() { success = true, msg = "" }); + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task KCS001CSaveAsync(MACInfo model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _kcsApi.PostMACInfo(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("KCS001C", model); + } + + public async Task KCS001USaveAsync(MACInfo model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _kcsApi.PutMACInfo(model.Class + "," + model.ClassGroup, 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("KCS001U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetMACInfoesAsync(int page = 1, int limit = 10) + { + var result_total = await _kcsApi.GetMACInfoes(0, limit); + var result = await _kcsApi.GetMACInfoes(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 + #region KCS002序號料號維護相關 public IActionResult KCS002() @@ -141,7 +266,7 @@ namespace AMESCoreStudio.Web.Controllers } } } - return View("PPS002U", model); + return View("KCS002U", model); } [ResponseCache(Duration = 0)] @@ -249,7 +374,7 @@ namespace AMESCoreStudio.Web.Controllers } } } - return View("PPS004U", model); + return View("KCS004U", model); } [ResponseCache(Duration = 0)] @@ -363,7 +488,7 @@ namespace AMESCoreStudio.Web.Controllers } } } - return View("PPS006U", model); + return View("KCS006U", model); } [ResponseCache(Duration = 0)] diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs index 1dd5c89a..b5f22270 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IKCS.cs @@ -12,6 +12,45 @@ namespace AMESCoreStudio.Web [JsonReturn] public interface IKCS:IHttpApi { + #region KCS001 MAC資料維護 + + /// + /// 新增MAC資料 + /// + /// + [WebApiClient.Attributes.HttpPost("api/MACInfoes")] + ITask> PostMACInfo([FromBody, RawJsonContent] string model); + + /// + /// 更新MAC資料 + /// + /// + [WebApiClient.Attributes.HttpPut("api/MACInfoes/{id}")] + ITask> PutMACInfo(string id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除MAC資料 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/MACInfoes/{id}")] + ITask> DeleteMACInfo(string id); + + /// + /// 根據ID獲取指定MAC資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/MACInfoes/{id}")] + ITask> GetMACInfo(string id); + + /// + /// 獲取MAC資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/MACInfoes")] + ITask> GetMACInfoes(int page = 1, int limit = 10); + + #endregion + #region KCS002 序號料號維護 /// diff --git a/AMESCoreStudio.Web/Views/Home/Framework.cshtml b/AMESCoreStudio.Web/Views/Home/Framework.cshtml index 7ff45a52..e610b0b3 100644 --- a/AMESCoreStudio.Web/Views/Home/Framework.cshtml +++ b/AMESCoreStudio.Web/Views/Home/Framework.cshtml @@ -217,6 +217,9 @@ 組件控管模組