diff --git a/AMESCoreStudio.Web/Controllers/BASController.cs b/AMESCoreStudio.Web/Controllers/BASController.cs index d6a088d2..3b45e9ed 100644 --- a/AMESCoreStudio.Web/Controllers/BASController.cs +++ b/AMESCoreStudio.Web/Controllers/BASController.cs @@ -116,6 +116,55 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.TestTypeList = TestTypeItems; } + private async Task GetFlowRuleList() + { + var result = await _basApi.GetFlowRules(); + + var FlowRuleItems = new List(); + FlowRuleItems.Add(new SelectListItem("N/A", "0")); + for (int i = 0; i < result.Count; i++) + { + FlowRuleItems.Add(new SelectListItem(result[i].UnitNo + result[i].FlowRuleName, result[i].FlowRuleID.ToString())); + } + ViewBag.FlowRuleList = FlowRuleItems; + } + + private async Task GetStationList() + { + var result = await _basApi.GetStationses(); + + var StationItems = new List(); + for (int i = 0; i < result.Count; i++) + { + StationItems.Add(new SelectListItem(result[i].UnitNo + result[i].StationName, result[i].StationID.ToString())); + } + ViewBag.StationList = StationItems; + } + + private async Task GetRuleStationList(int id) + { + var result = await _basApi.GetRuleStationsByFlow(id); + + var RuleStationItems = new List(); + for (int i = 0; i < result.Count; i++) + { + RuleStationItems.Add(new SelectListItem(result[i].Station.UnitNo + result[i].Station.StationName, result[i].RuleStationID.ToString())); + } + ViewBag.RuleStationList = RuleStationItems; + } + + private async Task GetNextStationList(int id) + { + var result = await _basApi.GetRuleStationsByFlow(id); + + var NextStationItems = new List(); + for (int i = 0; i < result.Count; i++) + { + NextStationItems.Add(new SelectListItem(result[i].Station.UnitNo + result[i].Station.StationName, result[i].StationID.ToString())); + } + ViewBag.NextStationList = NextStationItems; + } + #endregion #region BAS001工廠资料维护相关 @@ -784,6 +833,416 @@ namespace AMESCoreStudio.Web.Controllers #endregion + #region BAS009流程資料維護相關 + + public async Task BAS009() + { + await GetFactoryUnitList(); + + return View(); + } + + //新增頁面 + public async Task BAS009C(string id) + { + await GetFactoryUnitList(); + + var model = new FlowRule(); + if (id != null) + { + if (id != "") + { + model.UnitNo = id; + } + } + + return View(model); + } + + //修改页面 + [HttpGet] + public async Task BAS009UAsync(int id) + { + await GetFactoryUnitList(); + + var result = await _basApi.GetFlowRule(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task BAS009DAsync(int id) + { + var result = await _basApi.DeleteFlowRule(id); + return Json(new Result() { success = true, msg = "" }); + } + + public async Task BAS009DAllAsync(int[] ids) + { + if (ids.Length > 0) + { + var result = await _basApi.DeleteFlowRule(ids[0]); + for (int i = 1; i < ids.Length; i++) + { + result = await _basApi.DeleteFlowRule(ids[i]); + } + + return Json(new Result() { success = true, msg = "" }); + } + else + { + return Json(new Result() { success = false, msg = "" }); + } + + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task BAS009SaveAsync(FlowRule model) + { + if (ModelState.IsValid) + { + IResultModel result; + if (model.FlowRuleID == 0) + { + result = await _basApi.PostFlowRule(JsonConvert.SerializeObject(model)); + } + else + { + result = await _basApi.PutFlowRule(model.FlowRuleID, JsonConvert.SerializeObject(model)); + } + + if (!result.Success) + { + var _msg = model.FlowRuleID == 0 ? "添加成功!" : "修改成功!"; + 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); + } + } + } + if (model.FlowRuleID == 0) + { + return View("BAS009C", model); + } + return View("BAS009U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetFlowRulesAsync() + { + var result = await _basApi.GetFlowRules(); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetFlowRulesByUnitAsync(string unitNo) + { + if (unitNo == null) + { + unitNo = "0"; + } + var result = await _basApi.GetFlowRulesByUnit(unitNo); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + #endregion + + #region BAS010流程站別維護相關 + + public async Task BAS010() + { + await GetFlowRuleList(); + + return View(); + } + + //新增頁面 + public async Task BAS010C(int id) + { + await GetFlowRuleList(); + await GetStationList(); + + ViewBag.FlowRuleID = id; + + var model = new RuleStation(); + if (id > 0) + { + model.FlowRuleID = id; + } + + return View(model); + } + + //修改页面 + [HttpGet] + public async Task BAS010UAsync(int id) + { + await GetFlowRuleList(); + await GetStationList(); + + var result = await _basApi.GetRuleStation(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task BAS010DAsync(int id) + { + var result = await _basApi.DeleteRuleStation(id); + return Json(new Result() { success = true, msg = "" }); + } + + public async Task BAS010DAllAsync(int[] ids) + { + if (ids.Length > 0) + { + var result = await _basApi.DeleteRuleStation(ids[0]); + for (int i = 1; i < ids.Length; i++) + { + result = await _basApi.DeleteRuleStation(ids[i]); + } + + return Json(new Result() { success = true, msg = "" }); + } + else + { + return Json(new Result() { success = false, msg = "" }); + } + + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task BAS010SaveAsync(RuleStation model) + { + if (ModelState.IsValid) + { + IResultModel result; + if (model.RuleStationID == 0) + { + result = await _basApi.PostRuleStation(JsonConvert.SerializeObject(model)); + } + else + { + result = await _basApi.PutRuleStation(model.RuleStationID, JsonConvert.SerializeObject(model)); + } + + if (!result.Success) + { + var _msg = model.RuleStationID == 0 ? "添加成功!" : "修改成功!"; + 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); + } + } + } + if (model.RuleStationID == 0) + { + return View("BAS010C", model); + } + return View("BAS010U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetRuleStationsAsync() + { + var result = await _basApi.GetRuleStations(); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetRuleStationsByFlowAsync(int id) + { + var result = await _basApi.GetRuleStationsByFlow(id); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + #endregion + + #region BAS011流程站別規則維護相關 + + public async Task BAS011() + { + await GetFlowRuleList(); + + return View(); + } + + //新增頁面 + public async Task BAS011C(int id) + { + await GetFlowRuleList(); + await GetRuleStationList(id); + await GetNextStationList(id); + + return View(); + } + + //修改页面 + [HttpGet] + public async Task BAS011UAsync(int id) + { + await GetFlowRuleList(); + var result2 = await _basApi.GetRuleStation(id); + int flowId = result2[0].FlowRuleID; + await GetRuleStationList(flowId); + await GetNextStationList(flowId); + + var result = await _basApi.GetRules(id); + + if (result.Count == 0) + { + return View(); + } + return View(result[0]); + } + + public async Task BAS011DAsync(int id) + { + var result = await _basApi.DeleteRules(id); + return Json(new Result() { success = true, msg = "" }); + } + + public async Task BAS011DAllAsync(int[] ids) + { + if (ids.Length > 0) + { + var result = await _basApi.DeleteRules(ids[0]); + for (int i = 1; i < ids.Length; i++) + { + result = await _basApi.DeleteRules(ids[i]); + } + + return Json(new Result() { success = true, msg = "" }); + } + else + { + return Json(new Result() { success = false, msg = "" }); + } + + } + + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task BAS011SaveAsync(Rules model) + { + if (ModelState.IsValid) + { + IResultModel result; + if (model.CreateDate == System.DateTime.MinValue) + { + result = await _basApi.PostRules(JsonConvert.SerializeObject(model)); + } + else + { + result = await _basApi.PutRules(model.RuleStationID, JsonConvert.SerializeObject(model)); + } + + if (!result.Success) + { + var _msg = model.CreateDate == System.DateTime.MinValue ? "添加成功!" : "修改成功!"; + 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); + } + } + } + if (model.CreateDate == System.DateTime.MinValue) + { + return View("BAS011C", model); + } + return View("BAS011U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetRulesesAsync() + { + var result = await _basApi.GetRuleses(); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetRulesesByFlowAsync(int flowId) + { + var result = await _basApi.GetRulesesByFlow(flowId); + + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + #endregion + #region BAS014責任單位资料维护相关 public IActionResult BAS014() diff --git a/AMESCoreStudio.Web/HttpApis/IBAS.cs b/AMESCoreStudio.Web/HttpApis/IBAS.cs index 60360e8e..c812d599 100644 --- a/AMESCoreStudio.Web/HttpApis/IBAS.cs +++ b/AMESCoreStudio.Web/HttpApis/IBAS.cs @@ -291,6 +291,144 @@ namespace AMESCoreStudio.Web #endregion + #region BAS009流程資料維護相關 + + /// + /// 新增流程 + /// + /// + [WebApiClient.Attributes.HttpPost("api/FlowRules")] + ITask> PostFlowRule([FromBody, RawJsonContent] string model); + + /// + /// 更新流程 + /// + /// + [WebApiClient.Attributes.HttpPut("api/FlowRules/{id}")] + ITask> PutFlowRule(int id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除流程 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/FlowRules/{id}")] + ITask> DeleteFlowRule(int id); + + /// + /// 根據ID獲取指定流程資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/FlowRules/{id}")] + ITask> GetFlowRule(int id); + + /// + /// 獲取流程資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/FlowRules")] + ITask> GetFlowRules(); + + /// + /// 根据製程單位獲取流程資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/FlowRules/Unit/{no}")] + ITask> GetFlowRulesByUnit(string no); + + #endregion + + #region BAS010流程資料維護相關 + + /// + /// 新增流程站別 + /// + /// + [WebApiClient.Attributes.HttpPost("api/RuleStations")] + ITask> PostRuleStation([FromBody, RawJsonContent] string model); + + /// + /// 更新流程站別 + /// + /// + [WebApiClient.Attributes.HttpPut("api/RuleStations/{id}")] + ITask> PutRuleStation(int id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除流程站別 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/RuleStations/{id}")] + ITask> DeleteRuleStation(int id); + + /// + /// 根據ID獲取指定流程站別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/RuleStations/{id}")] + ITask> GetRuleStation(int id); + + /// + /// 獲取流程站別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/RuleStations")] + ITask> GetRuleStations(); + + /// + /// 根据流程ID獲取流程站別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/RuleStations/Flow/{id}")] + ITask> GetRuleStationsByFlow(int id); + + #endregion + + #region BAS011流程規則維護相關 + + /// + /// 新增流程規則 + /// + /// + [WebApiClient.Attributes.HttpPost("api/Rules")] + ITask> PostRules([FromBody, RawJsonContent] string model); + + /// + /// 更新流程站別 + /// + /// + [WebApiClient.Attributes.HttpPut("api/Rules/{id}")] + ITask> PutRules(int id, [FromBody, RawJsonContent] string model); + + /// + /// 刪除流程站別 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/Rules/{id}")] + ITask> DeleteRules(int id); + + /// + /// 根據ID獲取指定流程站別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/Rules/{id}")] + ITask> GetRules(int id); + + /// + /// 獲取流程站別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/Rules")] + ITask> GetRuleses(); + + /// + /// 根据流程ID獲取流程站別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/Rules/Flow/{id}")] + ITask> GetRulesesByFlow(int id); + + #endregion + #region BAS014責任單位資料維護相關 /// diff --git a/AMESCoreStudio.Web/Views/BAS/BAS009.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS009.cshtml new file mode 100644 index 00000000..a25ec9c1 --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS009.cshtml @@ -0,0 +1,199 @@ +@{ + ViewData["Title"] = "流程資料管理"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + + + +
+
+
+
+
@ViewBag.Title
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/BAS/BAS009C.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS009C.cshtml new file mode 100644 index 00000000..8a675265 --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS009C.cshtml @@ -0,0 +1,71 @@ +@model AMESCoreStudio.WebApi.Models.BAS.FlowRule + + +@{ ViewData["Title"] = "BAS009C"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + +
+
+
+
+ + +
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ @Html.ValidationMessage("error") +
+ +
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/BAS/BAS009U.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS009U.cshtml new file mode 100644 index 00000000..337cab21 --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS009U.cshtml @@ -0,0 +1,73 @@ +@model AMESCoreStudio.WebApi.Models.BAS.FlowRule + +@{ + ViewData["Title"] = "BAS009U"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; +} + + + +
+
+
+
+ + + + +
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ +
+ +
+
+
+ +@section Scripts { + @{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); + } + + +} diff --git a/AMESCoreStudio.Web/Views/BAS/BAS010.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS010.cshtml new file mode 100644 index 00000000..9eaea35a --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS010.cshtml @@ -0,0 +1,206 @@ +@{ + ViewData["Title"] = "流程站別管理"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + + + +
+
+
+
+
@ViewBag.Title
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/BAS/BAS010C.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS010C.cshtml new file mode 100644 index 00000000..4dcf1ab3 --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS010C.cshtml @@ -0,0 +1,76 @@ +@model AMESCoreStudio.WebApi.Models.BAS.RuleStation + + +@{ ViewData["Title"] = "BAS010C"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + +
+
+
+
+ + +
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/BAS/BAS010U.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS010U.cshtml new file mode 100644 index 00000000..35e14ff2 --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS010U.cshtml @@ -0,0 +1,77 @@ +@model AMESCoreStudio.WebApi.Models.BAS.RuleStation + +@{ + ViewData["Title"] = "BAS010U"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; +} + + + +
+
+
+
+ + + +
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + + +
+
+ +
+ +
+
+
+ +@section Scripts { + @{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); + } + + +} diff --git a/AMESCoreStudio.Web/Views/BAS/BAS011.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS011.cshtml new file mode 100644 index 00000000..288bc2f1 --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS011.cshtml @@ -0,0 +1,206 @@ +@{ + ViewData["Title"] = "流程站別規則管理"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + + + +
+
+
+
+
@ViewBag.Title
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/BAS/BAS011C.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS011C.cshtml new file mode 100644 index 00000000..d1081d51 --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS011C.cshtml @@ -0,0 +1,75 @@ +@model AMESCoreStudio.WebApi.Models.BAS.Rules + + +@{ ViewData["Title"] = "BAS011C"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + +
+
+
+
+ +
+ + + +
+
+ + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + + +
+
+ + + +
+ @Html.ValidationMessage("error") +
+ +
+ +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/BAS/BAS011U.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS011U.cshtml new file mode 100644 index 00000000..ad80c321 --- /dev/null +++ b/AMESCoreStudio.Web/Views/BAS/BAS011U.cshtml @@ -0,0 +1,77 @@ +@model AMESCoreStudio.WebApi.Models.BAS.Rules + +@{ + ViewData["Title"] = "BAS010U"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; +} + + + +
+
+
+
+ + + +
+ + + +
+
+ + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + + +
+
+ + + +
+
+ +
+ +
+
+
+ +@section Scripts { + @{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); + } + + +} diff --git a/AMESCoreStudio.Web/Views/Home/Framework.cshtml b/AMESCoreStudio.Web/Views/Home/Framework.cshtml index 18ec02ab..dbf4501b 100644 --- a/AMESCoreStudio.Web/Views/Home/Framework.cshtml +++ b/AMESCoreStudio.Web/Views/Home/Framework.cshtml @@ -120,10 +120,10 @@
  • - + 基本資料模組 -