From bf21dd51d183526475f13f7f73271bdb3ba34bca Mon Sep 17 00:00:00 2001 From: Marvin Date: Fri, 30 Dec 2022 16:06:13 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E5=89=8D=E5=88=A4=E7=BB=B4?= =?UTF-8?q?=E4=BF=AE=E8=BE=93=E5=85=A5=201.1."=E7=B5=84=E4=BB=B6=E4=BB=A3?= =?UTF-8?q?=E7=A2=BC"=E5=88=AA=E9=99=A4,=20=E5=9C=A8=E7=B6=AD=E4=BF=AE?= =?UTF-8?q?=E6=96=99=E8=99=9F=E4=B8=8B=E9=9D=A2=E6=96=B0=E5=A2=9E"?= =?UTF-8?q?=E7=B6=AD=E4=BF=AE=E6=96=99=E8=99=9F=E6=8F=8F=E8=BF=B0"=20,=20?= =?UTF-8?q?=E9=A1=9E=E4=BC=BC=E7=B6=AD=E4=BF=AE=E6=96=B9=E5=BC=8F=E4=BB=A3?= =?UTF-8?q?=E7=A2=BC=E8=BC=B8=E5=85=A5=E4=BB=A3=E7=A2=BCenter=E5=BE=8C?= =?UTF-8?q?=E5=B8=B6=E5=87=BA=E6=8F=8F=E8=BF=B0(=20Table:=20PLM=5FMETERIAL?= =?UTF-8?q?=5FINFO,=20=E6=A0=B9=E6=93=9A=E6=96=99=E8=99=9F=20METERIALNO?= =?UTF-8?q?=E5=B8=B6=E5=87=BA=20=E6=96=99=E8=99=9F=E6=8F=8F=E8=BF=B0=20MET?= =?UTF-8?q?ERIAL=5FDESC=20)=201.2.=20=E6=96=B0=E7=B5=84=E4=BB=B6=E5=BA=8F?= =?UTF-8?q?=E8=99=9F=E7=A7=BB=E8=87=B3=E8=88=8A=E7=B5=84=E4=BB=B6=E5=BA=8F?= =?UTF-8?q?=E8=99=9F=E7=9A=84=E5=BE=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/REPController.cs | 16 ++++++++ AMESCoreStudio.Web/HttpApis/AMES/IPPS.cs | 7 +++- AMESCoreStudio.Web/Views/REP/REP001R.cshtml | 38 ++++++++++++++++--- .../AMES/PlmMeterialInfoeController.cs | 13 ++++++- 4 files changed, 65 insertions(+), 9 deletions(-) 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; }