diff --git a/AMESCoreStudio.Web/Views/PTD/PTD002.cshtml b/AMESCoreStudio.Web/Views/PTD/PTD002.cshtml index fa3368ff..b82fdd10 100644 --- a/AMESCoreStudio.Web/Views/PTD/PTD002.cshtml +++ b/AMESCoreStudio.Web/Views/PTD/PTD002.cshtml @@ -344,6 +344,10 @@ var material = document.getElementById('PartNumber'); var table = layui.table; var rowAmount = table.cache['query'].length; + if (SNData.value.trim() == "") { + hg.msg('SN不得為空!'); + return; + } var arr = SNData.value.split('\n'); $.each(arr, function (index, SN) { @@ -376,10 +380,10 @@ var tableData = layui.table.cache['query']; - if (customer === "") { - hg.msg('Customer不得為空!'); - return; // Do not add the row - } + //if (customer === "") { + // hg.msg('Customer不得為空!'); + // return; // Do not add the row + //} if (material === "") { hg.msg('料號不得為空!'); return; // Do not add the row diff --git a/AMESCoreStudio.Web/Views/PTD/PTD006.cshtml b/AMESCoreStudio.Web/Views/PTD/PTD006.cshtml index cc792b47..e3ee0943 100644 --- a/AMESCoreStudio.Web/Views/PTD/PTD006.cshtml +++ b/AMESCoreStudio.Web/Views/PTD/PTD006.cshtml @@ -158,6 +158,9 @@
+
+ +
@@ -285,11 +288,33 @@ var endSN = document.getElementById('endSN'); var frontSN = document.getElementById('frontSN'); - endSN.focus(); - endSN.select(); + if (frontSN.value.trim() == "") { + hg.msg('SN不得為空!'); + return; + } if (document.getElementById('PCSUnit').checked) { - endSN.value = frontSN.value; + var recordType = document.getElementById('recordType'); + var dnNo = document.getElementById('recordNumber'); + var lineNo = document.getElementById('lineNo'); + var material = document.getElementById('PartNumber'); + + var newRowData = { + recordType: recordType.value, + dnNo: dnNo.value, + lineNo: lineNo.value, + material: material.value, + sn: frontSN.value + }; + // Add the new row data to the table + hg.table.addRow('query', newRowData); + + frontSN.focus(); + frontSN.select(); + } + else { + endSN.focus(); + endSN.select(); } } @@ -336,8 +361,12 @@ var material = document.getElementById('PartNumber'); var table = layui.table; var rowAmount = table.cache['query'].length; - + if (SNData.value.trim() == "") { + hg.msg('SN不得為空!'); + return; + } var arr = SNData.value.split('\n'); + console.log(arr); $.each(arr, function (index, SN) { rowAmount++; var newRowData = { @@ -355,6 +384,49 @@ event.preventDefault(); } }); + $('#delAll').on('click', function () { + hg.confirm("請確認是否整批刪除?", function () { + var tableData = layui.table.cache['query']; + + $.each(tableData, function (index, data) { + $.ajax({ + url: '/PTD/PTD006D', + data: { sn: data.sn }, + type: 'POST', + success: function (res) { + if (res.success) { + if (index == (tableData.length - 1)) { + // 重新加载表格数据 + layui.table.reload('query', { + data: tableData, + page: false, + limit: 2000 + }); + calculateRowCount(tableData); + hg.msg('刪除成功'); + } + } + else { + hg.msg(res.msg); + + // 重新加载表格数据 + layui.table.reload('query', { + data: tableData, + page: false, + limit: 2000 + }); + calculateRowCount(tableData); + + } + }, + error: function () { + hg.msg("網路請求失敗!"); + } + }); + }); + + }); + }); function getItemDesc(itemNo) { $.ajax({ @@ -401,10 +473,10 @@ var rbu = document.getElementById('RBU').value; var customer = document.getElementById('Customer').value; //卡控material & customer不得為空 - if (customer === "") { - hg.msg('Customer不得為空!'); - return; // Do not add the row - } + //if (customer === "") { + // hg.msg('Customer不得為空!'); + // return; // Do not add the row + //} if (rowData.material === "") { hg.msg('料號不得為空!'); return; // Do not add the row @@ -461,7 +533,6 @@ hg.confirm("SN:" + obj.data.sn + ",確定要刪除嗎?", function () { // 获取表格数据 var tableData = layui.table.cache['query']; - // 找到要删除的行的索引 var rowIndex = tableData.findIndex(function (row) { return row.sn === obj.data.sn; @@ -588,7 +659,7 @@ } ]]; //基本数据表格 - var table = hg.table.datatable('query', '備貨資訊', '/PTD/PTD006Query', {}, tableCols, "", true, 'full-100', ['filter', 'print', 'exports']); + var table = hg.table.datatable('query', '備貨資訊', '/PTD/PTD006Query', {}, tableCols, toolbar, true, 'full-100', ['exports']); }