diff --git a/AMESCoreStudio.Web/Controllers/REPController.cs b/AMESCoreStudio.Web/Controllers/REPController.cs index 4d3d72c9..aad91ce3 100644 --- a/AMESCoreStudio.Web/Controllers/REPController.cs +++ b/AMESCoreStudio.Web/Controllers/REPController.cs @@ -194,6 +194,22 @@ namespace AMESCoreStudio.Web.Controllers return Json(new { data = item }); } + [HttpPost] + public async Task GetMaterialDescJson(string part_no) + { + var result = await _ppsApi.GetPlmMeterialInfo(part_no); + + var item = new List(); + + for (int i = 0; i < result.Count; i++) + { + item.Add(new SelectListItem(result[i].MeterialDesc, result[i].MeterialNo.ToString())); + } + + //将数据Json化并传到前台视图 + return Json(new { data = item }); + } + [HttpPost] public async Task GetErrorCodeJson(string ng_no) { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs index 01e8d955..ec262aa0 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs @@ -653,6 +653,11 @@ namespace AMESCoreStudio.Web #endregion - + /// + /// 根據PLM料號獲取指定資料 + /// + /// + [WebApiClient.Attributes.HttpGet("/api/PlmMeterialInfoe/{id}")] + ITask> GetPlmMeterialInfo(string id); } } diff --git a/AMESCoreStudio.Web/Views/REP/REP001R.cshtml b/AMESCoreStudio.Web/Views/REP/REP001R.cshtml index a5c32267..6f3cb1f3 100644 --- a/AMESCoreStudio.Web/Views/REP/REP001R.cshtml +++ b/AMESCoreStudio.Web/Views/REP/REP001R.cshtml @@ -265,7 +265,8 @@
- + +
@@ -277,11 +278,6 @@ - -
- - -
@@ -434,6 +430,28 @@ }); }; + function getMaterialDesc(data) + { + $.ajax( + { + url: "@Url.Action("GetMaterialDescJson", "REP")", + dataType: 'json', + data: { "part_no": data}, + type: 'post', + success: function (result) + { + console.info(result.data); + $.each(result.data, function (index, item) { + $("#txtPartNoDesc").val(item.text); + }); + }, + error: function (result) + { + alert(result); + } + }); + }; + function getErrorCode(data) { $.ajax( @@ -475,6 +493,14 @@ }); + $('#txtPartNo').on('keypress', function (event) { + + if (event.keyCode == 13) { + getMaterialDesc($('#txtPartNo').val()); + } + + }); + $('#txtNgNo').on('keypress', function (event) { if (event.keyCode == 13) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/PlmMeterialInfoeController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/PlmMeterialInfoeController.cs index d7e647d0..b88baf00 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/PlmMeterialInfoeController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/PlmMeterialInfoeController.cs @@ -38,9 +38,18 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// PLM料號 /// [HttpGet("{id}")] - public async Task> GetPlmMeterialInfo(string id) + public async Task>> GetPlmMeterialInfo(string id) { - var plmMeterialInfo = await _context.PlmMeterialInfos.FindAsync(id); + IQueryable q = _context.PlmMeterialInfos; + q = q.Where(p => p.MeterialNo.Equals(id)); + + var plmMeterialInfo = await q.ToListAsync(); + + if (plmMeterialInfo == null) + { + return NotFound(); + } + return plmMeterialInfo; }