|
| 1 | +<!-- @format --> |
| 2 | + |
| 3 | +<!DOCTYPE html> |
| 4 | +<html lang="en"> |
| 5 | + <head> |
| 6 | + <meta charset="UTF-8" /> |
| 7 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 8 | + <title>Document</title> |
| 9 | + </head> |
| 10 | + <body> |
| 11 | + <table width="100%" border="0" style="border-spacing: 2px 2px"> |
| 12 | + <tr style="height: 30px; background-color: #ebeff4"> |
| 13 | + <td class="lotid-td">HA21A0897</td> |
| 14 | + <td><input class="item-input" type="text" style="background-color: #a6f9d7" placeholder="820001000010" /></td> |
| 15 | + </tr> |
| 16 | + <tr style="height: 30px; background-color: #ebeff4"> |
| 17 | + <td class="lotid-td">HA21A0898</td> |
| 18 | + <td><input class="item-input" type="text" placeholder="820001000011" /></td> |
| 19 | + <td><input class="item-input" type="text" placeholder="820001000012" /></td> |
| 20 | + <td><input class="item-input" type="text" placeholder="820001000012" /></td> |
| 21 | + <td><input class="item-input" type="text" placeholder="820001000012" /></td> |
| 22 | + <td><input class="item-input" type="text" placeholder="820001000012" /></td> |
| 23 | + </tr> |
| 24 | + </table> |
| 25 | + <button onclick="xxx()">xxxxx</button> |
| 26 | + </body> |
| 27 | + |
| 28 | + <script type="text/javascript" src="../../link-js/jquery/jquery-1.8.3.js"></script> |
| 29 | + <script> |
| 30 | + $(function () { |
| 31 | + var inputs = $(".item-input") |
| 32 | + // 遍历找到的元素并获取值 |
| 33 | + inputs.each(function () { |
| 34 | + $(this).keyup(function (event) { |
| 35 | + if (event.keyCode === 13) { |
| 36 | + alert("你输入的内容为:" + $(this).attr("placeholder") + "," + $(this).val()) |
| 37 | + } |
| 38 | + }) |
| 39 | + }) |
| 40 | + }) |
| 41 | + function xxx() { |
| 42 | + const datas = [ |
| 43 | + { lotItems: [{ itemId: "820001000010", itemRrn: 10505849 }], lotId: "HA21A0897" }, |
| 44 | + { |
| 45 | + lotItems: [ |
| 46 | + { itemId: "820001000010", itemRrn: 10505849 }, |
| 47 | + { itemId: "820001000010", itemRrn: 10505849 } |
| 48 | + ], |
| 49 | + lotId: "HA21A0898" |
| 50 | + } |
| 51 | + ] |
| 52 | + const inputs = $(".item-input") |
| 53 | + const ndatas = {} |
| 54 | + datas.forEach((data) => { |
| 55 | + ndatas[data.lotId] = data.lotItems.map((l) => l.itemId) |
| 56 | + }) |
| 57 | + console.log("ndatas", ndatas) |
| 58 | + |
| 59 | + let result = true |
| 60 | + inputs.each(function () { |
| 61 | + const lotId = $(this).parent().parent().children(".lotid-td")[0].innerText |
| 62 | + const itemId = $(this).val() |
| 63 | + if (!itemId) { |
| 64 | + result = false |
| 65 | + alert("请扫描料号!") |
| 66 | + return false |
| 67 | + } |
| 68 | + const itemArray = ndatas[lotId] |
| 69 | + if (!itemArray.includes(itemId)) { |
| 70 | + result = false |
| 71 | + alert(itemId + ",不在批次物料列表中,请检查!") |
| 72 | + return false |
| 73 | + } |
| 74 | + }) |
| 75 | + if (!result) return false |
| 76 | + alert("XXXXX!") |
| 77 | + } |
| 78 | + </script> |
| 79 | +</html> |
0 commit comments