diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 421198ef..b96d2356 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -1478,8 +1478,6 @@ namespace AMESCoreStudio.Web.Controllers var q1 = await _pcsApi.GetMaterialSopQuery(itemNo: model.wipAtt.ItemNO); model.materialSops = q1.Data; - model.WipKps = await _pcsApi.GetWipKpByWipNo(model.wipInfo.WipNO); - model.wipBoard = await _pcsApi.GetWipBoard(model.wipInfo.WipNO); model.wipSystem = await _pcsApi.GetWipSystem(model.wipInfo.WipNO); @@ -1491,6 +1489,12 @@ namespace AMESCoreStudio.Web.Controllers model.wipBarcodeOther = await _pcsApi.GetWipBarcodeOther(model.wipInfo.WipNO); model.Outfits = await _pcsApi.GetMaterialOutfitByItemNo(model.wipAtt.ItemNO); + + model.WipKps = await _pcsApi.GetWipKpByWipNo(model.wipInfo.WipNO); + + model.WipOutfits = await _pcsApi.GetWipOutfitByWipNo(model.wipInfo.WipNO); + + model.WipSops = await _pcsApi.GetWipSopByWipNo(model.wipInfo.WipNO); } await GetProductType(); await GetFactoryInfo(); @@ -3655,20 +3659,6 @@ namespace AMESCoreStudio.Web.Controllers return Json(new Table() { count = 0, data = null }); } - [HttpPost] - public async Task PCS030StateAsync(int MaterialSopID, bool state) - { - - //IResultModel result; - if (!state) - await _pcsApi.PutMaterialSop(MaterialSopID, "N"); - else - await _pcsApi.PutMaterialSop(MaterialSopID, "Y"); - - var _msg = "修改成功!"; - return Json(_msg); - } - [HttpGet] public async Task PCS030C() { @@ -3678,7 +3668,7 @@ namespace AMESCoreStudio.Web.Controllers } [HttpPost] - public async Task PCS030CAsync(MaterialSop model, IFormFile formFile) + public async Task PCS030Async(MaterialSop model, IFormFile formFile) { //string FileName = string.Empty; //string NewName = string.Empty; @@ -3738,40 +3728,51 @@ namespace AMESCoreStudio.Web.Controllers await GetFactoryUnit(); GetSOPTypeSelect(); - IResultModel result; - result = await _pcsApi.PostMaterialSop(JsonConvert.SerializeObject(model)); - if (model.MaterialSopID == 0) - { - - } - else + if (ModelState.IsValid) { - //result = await _basApi.putmat(model.FactoryID, JsonConvert.SerializeObject(model)); - } + IResultModel result; + if (model.MaterialSopID == 0) + { + result = await _pcsApi.PostMaterialSop(JsonConvert.SerializeObject(model)); + } + else + { + result = await _pcsApi.PutMaterialSop(JsonConvert.SerializeObject(model)); + } - if (result.Success) - { - var _msg = model.MaterialSopID == 0 ? "新增成功!" : "修改成功!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); - } - else - { - if (result.Errors != null) + if (result.Success) { - ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg); + var _msg = model.MaterialSopID == 0 ? "新增成功!" : "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); } else { + ModelState.AddModelError("error", result.Msg); } } - if (model.MaterialSopID == 0) { return View("PCS030C", model); } return View("PCS030U", model); + + } + + [HttpGet] + public async Task PCS030U(int id) + { + var result = await _pcsApi.GetMaterialSop(id); + GetSOPTypeSelect(); + await GetFactoryUnit(); + return View(result); + } + + public async Task PCS030DAsync(int id) + { + var result = await _pcsApi.DeleteMaterialSop(id); + return Json(new Result() { success = result.Success, msg = result.Msg }); } [HttpPost] diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 20c70381..af33c3be 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -618,8 +618,16 @@ namespace AMESCoreStudio.Web /// /// - [WebApiClient.Attributes.HttpPut("api/MaterialSop/{id}/{state}")] - ITask> PutMaterialSop(int id, string state); + [WebApiClient.Attributes.HttpPut("api/MaterialSop")] + ITask> PutMaterialSop([FromBody, RawJsonContent] string model); + + /// + /// SOP文件變更狀態 + /// + /// + + [WebApiClient.Attributes.HttpDelete("api/MaterialSop/{id}")] + ITask> DeleteMaterialSop(int id); #endregion #region PCS024組件維護相關 diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml index 15e5fbad..54dfce20 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml @@ -1065,6 +1065,11 @@ title: 'SOP文件敘述', sort: true }, + { + field: 'sopPath', + title: '檔案路徑', + sort: true + }, { field: 'sopTypeName', title: 'SOP類型', diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml index 8a6a5682..e327e4c5 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml @@ -406,18 +406,18 @@ - 治具NO + 設備編碼 - 治具名稱 + 設備名稱 - 流程名稱ID + 生產單位 - @foreach (var index in Model.Outfits) + @foreach (var index in Model.WipOutfits) { @@ -425,10 +425,10 @@ @index.OutfitNo - @index.StationType + @index.PartNo - @index.RuleStationID + @index.UnitNoName j++; @@ -954,9 +954,41 @@ @* SOP文件 sheet *@ -
-
-
+
+
+ + @{ int l = 0;} + + + + + + + + + + @foreach (var index in Model.WipSops) + { + + + + + + + l++; + } + +
SOP文件敘述檔案路徑SOP類型生產單位
+ + @index.SOPName + + @index.SOPPath + + @index.SOPTypeName + + @index.UnitNoName +
+
@@ -1006,15 +1038,16 @@ alert("TAB"); table && table.reload(data); }); + + ////转换静态表格 + //table.init('demo', { + // height: 315 //设置高度 + // , limit: 10 //注意:请务必确保 limit 参数(默认:10)是与你服务端限定的数据条数一致 + // //支持所有基础参数 + //}); }); var tableCols = [[ - { - field: 'itemNo', - width: 150, - title: '料號', - sort: true - }, { field: 'unitName', title: '生產單位', @@ -1026,6 +1059,11 @@ title: 'SOP敘述', sort: true }, + { + field: 'sopPath', + title: '檔案路徑', + sort: true + }, { field: 'sopTypeName', title: 'SOP類型', @@ -1043,24 +1081,6 @@ } }] ]; - //通过行tool编辑,lay-event="show" - function show(obj) { - layui.use('layer', function () { - var layer = layui.layer; - layer.open({ - type: 2, - area: ['900px', '650px'], - fixed: false, //不固定 - maxmin: true, - content: obj.data.filePath + obj.data.newName - }); - }); - }; - - //基本数据表格 - var table = hg.table.datatable('query', 'SOP文件查詢維護', '/PCS/PCS030Query?itemNo='+"@Model.wipAtt.ItemNO", {}, tableCols, false, 'full-100'); - - } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS030.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS030.cshtml index b3a91d2e..79f4f960 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS030.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS030.cshtml @@ -142,27 +142,6 @@ }); - - //監聽state操作 - form.on('switch(state)', function (obj) { - var checked = obj.elem.checked; - var strSplit = this.value; - - $.ajax({ - url: '@Url.Action("PCS030State", "PCS")', - dataType: 'json', - data: { "materialSopID": strSplit, "state": checked }, - cache: false, - type: "POST", - success: function (data, textStatus, jqXHR) { - var qs = $('button[lay-filter="querysubmit"]'); - qs.click(); - }, - error: function (jqXHR, textStatus, errorThrown) { - alert("Found error when using Ajax!!"); - } - }); - }); }); //alert(roleId.value); @@ -188,28 +167,34 @@ { field: 'unitName', title: '生產單位', - width: 200, + width: 150, sort: true }, { field: 'sopName', - title: '檔案名稱', + title: 'SOP文件敘述', sort: true }, { - field: 'SopTypeName', + field: 'sopPath', + title: '檔案路徑', + sort: true + }, + { + field: 'sopTypeName', title: 'SOP類型', width: 100, sort: true }, { field: 'right', - width: 80, + width: 140, title: '操作', align: 'center', fixed: 'right', templet: function (d) { - return '' + return '修改 删除' +/* < button class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" lay - event="show" > 預覽*/ } }] ]; @@ -225,7 +210,38 @@ content: obj.data.filePath + obj.data.newName }); }); - }; + }; + + function edit(obj) { + if (obj.data.materialSopID) { + hg.open('修改SOP文件', '/PCS/PCS030U/' + obj.data.materialSopID, 480, 480); + } + } + + function del(obj) { + if (obj.data.materialSopID) { + hg.confirm("檔案名稱:【" + obj.data.sopName + "】,確定要刪除嗎?", function () { + $.ajax({ + url: '/PCS/PCS030D', + data: { id: obj.data.materialSopID }, + 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: '', diff --git a/AMESCoreStudio.Web/Views/PCS/PCS030C.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS030C.cshtml index 98a8eaf1..39a851f5 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS030C.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS030C.cshtml @@ -13,7 +13,7 @@
-
+
@@ -36,23 +36,17 @@
-
- - -
+ +
-
-
- -
- - -
+ +
+
@@ -60,7 +54,7 @@
- +
@@ -81,6 +75,11 @@ } + diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialSopController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialSopController.cs index 2a8760a6..5c6f39c3 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialSopController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialSopController.cs @@ -112,7 +112,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { q = q.Where(w => w.CreateDate <= DateTime.Parse(date_end)); } - ResultModel result = new ResultModel(); result.Data = await q.Select(s => new MaterialSopDto { @@ -125,8 +124,12 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES CreateDate = s.CreateDate, CreateUserID = s.CreateUserID, UpdateDate = s.UpdateDate, - UpdateUserID = s.UpdateUserID, - }).ToListAsync(); + UpdateUserID = s.UpdateUserID + //SopTypeName = Enums.GetDisplayName((Enums.EnumWipSopType)Enum.Parse(typeof(Enums.EnumWipSopType), s.SopType)) + }).ToListAsync(); + + result.Data.Select(s => + s.SopTypeName = Enums.GetDisplayName((Enums.EnumWipSopType)Enum.Parse(typeof(Enums.EnumWipSopType), s.SopType))).ToList(); return result; } @@ -154,22 +157,16 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } - [HttpPut("{id}/{state}")] - public async Task> PutMaterialSop(int id, string state) + [HttpPut] + public async Task> PutMaterialSop(MaterialSop materialSop) { ResultModel result = new ResultModel(); - var materialSop = new MaterialSop - { - MaterialSopID = id, - UpdateUserID = 1, - UpdateDate = System.DateTime.Now - - }; - _context.Attach(materialSop); - - // 指定更新某個欄位 - _context.Entry(materialSop).Property(p => p.UpdateUserID).IsModified = true; - _context.Entry(materialSop).Property(p => p.UpdateDate).IsModified = true; + _context.Entry(materialSop).State = EntityState.Modified; + materialSop.UpdateDate = DateTime.Now; + materialSop.UpdateUserID = 0; + // 指定不更新某個欄位 + _context.Entry(materialSop).Property("CreateDate").IsModified = false; + _context.Entry(materialSop).Property("CreateUserID").IsModified = false; try { @@ -185,10 +182,38 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - // DELETE api//5 + /// + /// 刪除 + /// + /// D + /// [HttpDelete("{id}")] - public void Delete(int id) + public async Task> DeleteMaterialSop(int id) { + ResultModel result = new ResultModel(); + var materialSop = await _context.MaterialSops.FindAsync(id); + + try + { + if (materialSop == null) + { + result.Success = false; + result.Msg = "找不到要刪除資料"; + } + else + { + _context.MaterialSops.Remove(materialSop); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; } } } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs index ef631a01..d2d09d39 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs @@ -81,7 +81,11 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES UnitNoName = q2.UnitName }; - return await q.ToListAsync(); + var result = await q.ToListAsync(); + result.Select(s => s.SOPTypeName + = Enums.GetDisplayName((Enums.EnumWipSopType)Enum.Parse(typeof(Enums.EnumWipSopType), s.SOPType))).ToList(); + + return result; } /// diff --git a/AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs index af28defc..84401700 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs @@ -45,6 +45,13 @@ namespace AMESCoreStudio.WebApi.DTO.AMES public string SOPType { get; set; } + + /// + /// SOP類型_名稱 + /// + + public string SOPTypeName { get; set; } + /// /// 生產單位代號 ///