index.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. <!doctype html>
  2. <!--李士越 首件检验检验端-->
  3. <html lang="en">
  4. <head>
  5. <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  6. <meta http-equiv="Pragma" content="no-cache" />
  7. <meta http-equiv="Expires" content="0" />
  8. <meta charset="utf-8">
  9. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  10. <link rel="shortcut icon" href="/img/logo.png" />
  11. <link rel="bookmark" href="/img/logo.png" />
  12. <link rel="stylesheet" href="/plugins/bootstrap-4.3.1/css/bootstrap.min.css">
  13. <link rel="stylesheet" href="/plugins/font-awesome-4.7.0/css/font-awesome.min.css">
  14. <link href="/Plugins/bootstrap-select/css/bootstrap-select.min.css" rel="stylesheet" />
  15. <link rel="stylesheet" href="../common/StyleSheet.css" />
  16. <link href="/Plugins/bootstrap-4.3.1/css/bootstrap4-modal-fullscreen.css" rel="stylesheet" />
  17. <script src="/Plugins/jquery-3.4.1/jquery-3.4.1.min.js"></script>
  18. <script src="/Plugins/virtualkeyboard/xvirtualkeyboard.js"></script>
  19. <style type="text/css">
  20. .outlayer {
  21. box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075);
  22. border-radius: .25rem;
  23. background-color: #fff;
  24. box-sizing: border-box;
  25. padding: 1rem 1.5rem .5rem 1.5rem;
  26. margin: 1rem 1.5rem .5rem 1.5rem;
  27. }
  28. .layer {
  29. padding: 0;
  30. margin-left: 0;
  31. margin-right: 0;
  32. }
  33. .formrow {
  34. display: flex;
  35. flex-wrap: wrap;
  36. width: 100%;
  37. }
  38. /* 切换栏*/
  39. .tab {
  40. width: 100%;
  41. position: relative;
  42. padding: 0;
  43. }
  44. .tab_list {
  45. width: 100%;
  46. }
  47. .tab_list ul {
  48. padding-left: 0;
  49. margin: 0;
  50. }
  51. .tab_list li {
  52. width: 25%;
  53. height: 45px;
  54. list-style: none;
  55. line-height: 45px;
  56. text-align: center;
  57. float: left;
  58. }
  59. .tab_list .current {
  60. background-color: #138496;
  61. color: #fff;
  62. }
  63. .tab_con {
  64. width: 100%;
  65. }
  66. /*展示区块*/
  67. .item {
  68. width: 100%;
  69. font-size: 20px;
  70. text-align: center;
  71. background: #efefef;
  72. top: 50px;
  73. position: absolute;
  74. }
  75. table {
  76. width: 100%;
  77. border-collapse: collapse;
  78. }
  79. th, td {
  80. border: 1px solid #000;
  81. text-align: center;
  82. }
  83. th {
  84. background-color: #f2f2f2;
  85. }
  86. /*单选框*/
  87. input[type="radio"] {
  88. width: 20px;
  89. height: 20px;
  90. }
  91. /*表格输入框*/
  92. .checkbox {
  93. text-align: center;
  94. }
  95. /*表格输入框*/
  96. .hidden-style {
  97. width: 100%;
  98. /* 移除边框 */
  99. border: none;
  100. /* 设置背景透明 */
  101. background: transparent;
  102. /* 移除阴影 */
  103. box-shadow: none;
  104. /* 移除焦点时的轮廓线 */
  105. outline: none;
  106. /* 移除内边距 */
  107. padding: 0;
  108. /* 移除外边距 */
  109. margin: 0;
  110. /* 继承父元素的字体大小 */
  111. font-size: inherit;
  112. }
  113. /*签字版*/
  114. .tablet {
  115. flex: 1;
  116. text-shadow: 0px 0px 0px #000000;
  117. color: black
  118. }
  119. .frame {
  120. width: 100%;
  121. height: 370px;
  122. }
  123. .col-0 {
  124. -ms-flex: 0 0 4.333333%;
  125. flex: 0 0 4.333333%;
  126. max-width: 4.333333%;
  127. }
  128. .table-container {
  129. position: relative;
  130. max-height: 720px;
  131. /* 允许垂直滚动 */
  132. overflow-y: auto;
  133. /* 为容器添加边框 */
  134. border: 1px solid #ddd;
  135. }
  136. /* 通用的表头和表体单元格样式 */
  137. .table-cell {
  138. padding: 8px;
  139. border: 1px solid #ddd;
  140. }
  141. /* 固定表头的样式 */
  142. .sticky-table-header th {
  143. position: sticky;
  144. top: 0;
  145. background-color: #d6d8db;
  146. /* 确保表头位于其他内容之上 */
  147. z-index: 2;
  148. /* 为表头添加底部边框以区分 */
  149. border-bottom: 2px solid #ddd;
  150. }
  151. </style>
  152. <title>东科软件</title>
  153. </head>
  154. <body class="bg-light">
  155. <!--导航菜单-->
  156. <script src="../common/navbar.js"></script>
  157. <!--对话框-->
  158. <!--<script src="../common/dialog.js"></script>-->
  159. <!--顶部-->
  160. <div class="outlayer">
  161. <!--产品条码区块-->
  162. <div class="formrow">
  163. <div class="form-group col-4 mb-1">
  164. <label for="产品条码">产品条码</label>
  165. <input value="" onkeydown="if (event.keyCode == 13) loadProduct();" type="text" class="form-control" id="urltext" placeholder="请输入" required>
  166. </div>
  167. <div class="form-group col-8 align-self-end mb-1">
  168. <button onclick="loadProduct()" type="button" class="btn btn-info btn-block">产品查询</button>
  169. </div>
  170. </div>
  171. </div>
  172. <div class="outlayer">
  173. <div class="formrow">
  174. <div class="form-group col-2 mb-1" style="max-width: 15%; flex: 10%; -ms-flex:10%">
  175. <label>首件登记单号</label>
  176. <input id="REGISTERNO" readonly type="text" class="form-control border-secondary">
  177. </div>
  178. <div class="form-group col-0 mb-1">
  179. <label>生产车间</label>
  180. <input id="WORKSHOP" readonly type="text" class="form-control border-secondary">
  181. </div>
  182. <div class="form-group col-2 mb-1" style="max-width: 10%; flex: 10%; -ms-flex:10%">
  183. <label>产品名称</label>
  184. <input id="GOODSNAME" readonly type="text" class="form-control border-secondary">
  185. </div>
  186. <div class="form-group col-1 mb-1">
  187. <label>产品型号</label>
  188. <input id="GOODSCODE" readonly type="text" class="form-control border-secondary">
  189. </div>
  190. <div class="form-group col-1 mb-1">
  191. <label>日期</label>
  192. <input id="DATA" readonly type="text" class="form-control border-secondary">
  193. </div>
  194. <div class="form-group col-1 mb-1">
  195. <label>产品类型</label>
  196. <input id="产品类型" readonly type="text" class="form-control border-secondary">
  197. </div>
  198. <div class="form-group col-2 mb-1">
  199. <label>物料编码</label>
  200. <input id="MATERIALCODE" readonly type="text" class="form-control border-secondary">
  201. </div>
  202. <div class="form-group col-0 mb-1">
  203. <label>首件数量</label>
  204. <input id="FIRQUANTITY" readonly type="text" class="form-control border-secondary">
  205. </div>
  206. <div class="form-group col-1 mb-1">
  207. <label>检验依据</label>
  208. <input id="检验依据" readonly type="text" class="form-control border-secondary">
  209. </div>
  210. <div >
  211. <button id="showtest" onclick="showtest()" type="button" class="btn btn-info btn-block" style="margin-top:30px; ">查看型式检验</button>
  212. </div>
  213. <div>
  214. <button id="complete" onclick="submit(true)" type="button" class="btn btn-info btn-block" style="margin-top:30px; margin-left:30px;">检验完成</button>
  215. </div>
  216. </div>
  217. </div>
  218. <!--下部-->
  219. <!--左侧产品条码-->
  220. <div class="outlayer" style="height: 500px">
  221. <div class='tab'>
  222. <div class='tab_list'>
  223. <ul id="myList">
  224. <li></li>
  225. </ul>
  226. </div>
  227. <div id="container" class='tab_con'>
  228. </div>
  229. </div>
  230. </div>
  231. <div class="outlayer">
  232. <div class="form-group col-12 align-self-end mb-1">
  233. <button onclick="submit(false)" type="button" class="btn btn-info btn-block">提交</button>
  234. </div>
  235. </div>
  236. <!--型式检验弹窗-->
  237. <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  238. <div class="modal-dialog" style="max-width:90%;">
  239. <div class="modal-content" >
  240. <div class="modal-header" style=" display: block;" >
  241. <h5 style="text-align: center; font-weight: bold;">检验报告</h5>
  242. </div>
  243. <div class="modal-body" >
  244. <div class="table-container">
  245. <table id="showtestTable" class="table">
  246. </table>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. <script>
  253. /**总单id */
  254. let REGISTERID;
  255. /**产品条码 */
  256. let barcode = '';
  257. /**填写记录数据 */
  258. let data = [];
  259. /**tab栏数据 */
  260. let li = [];
  261. /**登录数据源 */
  262. let jsonUser;
  263. /**查看型式检验是否可点击 */
  264. var button = document.getElementById('showtest');
  265. // 初始设置按钮为不可点击
  266. button.disabled = true;
  267. /**型式检验数据 */
  268. let showtestData = [];
  269. /**加载前调用*/
  270. $(document).ready(function () {
  271. loadData();
  272. });
  273. //加载 生产工号
  274. function loadData() {
  275. //检查登录状态
  276. $.get('api/LogInCheck_WCF.ashx', function (data) {
  277. var json = JSON.parse(data);
  278. if (json["success"] == true) {
  279. //保存登录数据源
  280. jsonUser = json["rows"];
  281. }
  282. else {
  283. swal({
  284. title: '登录异常!',
  285. text: '请您先登录系统!',
  286. icon: 'error',
  287. button: '确定'
  288. }).then(function () {
  289. window.location = '/main/login/login.html';
  290. });
  291. }
  292. });
  293. }
  294. /**获取切换栏 */
  295. const getli = async () => {
  296. //清空li
  297. li.length = 0;
  298. // 获取tab栏数据
  299. const data = await $.ajax({
  300. url: 'api/GetCheckBarcode.ashx?m=getli',
  301. dataType: "json",
  302. type: "get"
  303. });
  304. // 处理数据
  305. for (var i = 0; i < data.length; i++) {
  306. // 创建item和表格
  307. await createtable(data[i]);
  308. // 添加tab栏数据
  309. await li.push(data[i]);
  310. }
  311. // 调用函数来填充列表
  312. await populateList(li);
  313. }
  314. /**
  315. * 创建表格
  316. * @param tableid
  317. */
  318. const createtable = (tableid) => {
  319. /**找到要创建的位置*/
  320. const container = document.getElementById('container');
  321. /**创建div结构 */
  322. const div = document.createElement('div');
  323. //赋值class
  324. div.className = 'item';
  325. /**创建表格 */
  326. const table = document.createElement('table');
  327. //设置属性
  328. table.style.width = '100%';
  329. table.id = tableid
  330. /**创建表头 */
  331. const thead = document.createElement('thead');
  332. const headerRow = document.createElement('tr');
  333. /**创建表头数据 */
  334. headerRow.className = 'table-secondary';
  335. ['检验项目', '要求', '判定结果', '异常情况'].forEach(headerText => {
  336. const th = document.createElement('th');
  337. th.scope = 'col';
  338. th.textContent = headerText;
  339. headerRow.appendChild(th);
  340. });
  341. thead.appendChild(headerRow);
  342. /**创建表体 */
  343. const tbody = document.createElement('tbody');
  344. //依次填充结构
  345. table.appendChild(thead);
  346. table.appendChild(tbody);
  347. div.appendChild(table);
  348. container.appendChild(div);
  349. }
  350. /**
  351. * 填充li
  352. * @param items li集合
  353. */
  354. const populateList = async (items) => {
  355. /**获取 ul*/
  356. const ul = document.getElementById('myList');
  357. // 清空现有的 <li> 元素
  358. ul.innerHTML = '';
  359. for (var i = 0; i < items.length; i++) {
  360. var item = items[i];
  361. /**获取当前li */
  362. const liElement = document.createElement('li');
  363. //第一个li
  364. if (i === 0) {
  365. //添加class(选中效果)
  366. liElement.classList.add('current');
  367. }
  368. //添加名称
  369. liElement.textContent = item;
  370. //将li放入ul中
  371. ul.appendChild(liElement);
  372. //生成该li对应的内容
  373. await gettxt(item);
  374. }
  375. //li初始化和点击事件
  376. await lionclick();
  377. await initializeRadioListeners();
  378. await addinputvalue(barcode);
  379. }
  380. /**li与div联动(tabs) */
  381. const lionclick = () => {
  382. var lis = document.querySelectorAll('.tab_list li');
  383. var items = document.querySelectorAll('.item');
  384. // 设置所有 li 的 data-index 属性
  385. lis.forEach(function (li, index) {
  386. li.setAttribute('data-index', index);
  387. });
  388. // 函数:根据 current li 显示对应的 item
  389. function showCorrectItem() {
  390. var currentIndex = null;
  391. // 查找带有 class="current" 的 li 的索引
  392. lis.forEach(function (li, index) {
  393. if (li.classList.contains('current')) {
  394. currentIndex = index;
  395. }
  396. });
  397. // 隐藏所有 item
  398. items.forEach(function (item) {
  399. item.style.display = 'none';
  400. });
  401. // 显示对应的 item
  402. items[currentIndex].style.display = 'block';
  403. }
  404. // 页面加载完成后调用
  405. showCorrectItem();
  406. // 设置 li 的点击事件
  407. lis.forEach(function (li) {
  408. li.addEventListener('click', function () {
  409. // 重置所有 li 的类名
  410. lis.forEach(function (otherLi) {
  411. otherLi.classList.remove('current');
  412. });
  413. // 设置当前 li 的类名为 'current'
  414. this.classList.add('current');
  415. // 显示对应的 item
  416. showCorrectItem(); // 调用函数来更新显示
  417. });
  418. });
  419. };
  420. /**
  421. * 获取表格内容
  422. * @param ITEMSYTPE 类型
  423. */
  424. const gettxt = async (ITEMSYTPE) => {
  425. //获取表格内容
  426. const data = await $.ajax({
  427. url: 'api/GetCheckBarcode.ashx?m=gettable',
  428. data: { 'ITEMSYTPE': ITEMSYTPE },
  429. dataType: "json",
  430. type: "post"
  431. });
  432. // 处理数据
  433. for (var i = 0; i < data.length; i++) {
  434. //填充表格数据
  435. await fillTable(data, ITEMSYTPE);
  436. await initializeRadioListeners();
  437. }
  438. }
  439. /**
  440. * 表格填充数据
  441. * @param data 数据
  442. * @param tableid 表格id
  443. */
  444. const fillTable = (data, tableid) => {
  445. const tbodySelector = '#' + tableid + ' tbody';
  446. const tbody = document.querySelector(tbodySelector);
  447. // 清空容器
  448. while (tbody.firstChild) {
  449. tbody.removeChild(tbody.firstChild);
  450. }
  451. // 遍历数据数组,并为每个项目创建一个新的表格行
  452. /* data.forEach(item => {*/
  453. for (const item of data) {
  454. // 创建一个新的表格行
  455. const tr = document.createElement('tr');
  456. tr.id = item.ITEMSID;
  457. // 创建并填充第一个 <td> 元素(检验项目)
  458. const tdItemsName = document.createElement('td');
  459. tdItemsName.textContent = item.ITEMSNAME;
  460. tr.appendChild(tdItemsName);
  461. if (item.ITEMSID == 20) {
  462. const tdAbnormality = document.createElement('td');
  463. tdAbnormality.className = 'text';
  464. tdAbnormality.colSpan = 3;
  465. tdAbnormality.innerHTML = '<input type="text" class="hidden-style">';
  466. tr.appendChild(tdAbnormality);
  467. tbody.appendChild(tr);
  468. continue;
  469. }
  470. // 创建并填充第二个 <td> 元素(要求)
  471. const tdItemsInfo = document.createElement('td');
  472. tdItemsInfo.textContent = item.ITEMSINFO;
  473. tr.appendChild(tdItemsInfo);
  474. //创建了空的 <td> 元素
  475. const tdResult = document.createElement('td');
  476. tdResult.className = 'radio';
  477. // 创建第一个单选按钮
  478. const radioOk = document.createElement('input');
  479. radioOk.type = 'radio';
  480. radioOk.name = item.ITEMSID;
  481. radioOk.value = '1';
  482. // 创建与单选按钮相邻的文本节点 "OK"
  483. const textOk = document.createTextNode('OK');
  484. // 创建第二个单选按钮
  485. const radioNg = document.createElement('input');
  486. radioNg.type = 'radio';
  487. radioNg.name = item.ITEMSID;
  488. radioNg.value = '0';
  489. // 创建与单选按钮相邻的文本节点 "NG"
  490. const textNg = document.createTextNode('NG');
  491. // 将元素添加到 tdResult 中
  492. tdResult.appendChild(radioOk);
  493. tdResult.appendChild(textOk);
  494. tdResult.appendChild(radioNg);
  495. tdResult.appendChild(textNg);
  496. // 添加 radio buttons
  497. tr.appendChild(tdResult);
  498. const tdAbnormality = document.createElement('td');
  499. tdAbnormality.className = 'text';
  500. tdAbnormality.innerHTML = '<input type="text" class="hidden-style">';
  501. tr.appendChild(tdAbnormality);
  502. // 将新的表格行添加到 tbody 中
  503. tbody.appendChild(tr);
  504. };
  505. }
  506. /**定义一个函数来初始化所有单选按钮的事件监听器 */
  507. const initializeRadioListeners = () => {
  508. /**获取所有单选按钮*/
  509. const radioButtons = document.querySelectorAll('input[type="radio"]');
  510. /**获取所有输入框*/
  511. const textButtons = document.querySelectorAll('input[type="text"]');
  512. /**为每个单选按钮添加事件监听器*/
  513. radioButtons.forEach(radio => {
  514. radio.addEventListener('change', handleRadioChange);
  515. });
  516. /**为每个输入框 添加事件监听器*/
  517. textButtons.forEach(text => {
  518. text.addEventListener('change', handleRadioChange);
  519. });
  520. };
  521. /**产品查询 */
  522. const loadProduct = async () => {
  523. barcode = '';
  524. data.length = 0;
  525. /**获取输入框的值 */
  526. var productBarcode = document.getElementById('urltext').value;
  527. //产品条码赋值
  528. barcode = productBarcode;
  529. /**总单信息数据 */
  530. const checkdata = await check(barcode);
  531. //未查到总单信息
  532. if (checkdata[0] == null) {
  533. return swal({
  534. text: '产品条码无效或无可用首件登记单!',
  535. button: true,
  536. icon: 'error',
  537. closeOnClickOutside: false
  538. }).then(document.getElementById('urltext').value = '');
  539. }
  540. //总单id赋值
  541. REGISTERID = checkdata[0].REGISTERID;
  542. /**判断总单是否过量 */
  543. const result = await $.ajax({
  544. url: 'api/GetCheckBarcode.ashx?m=checkcount',
  545. data: { "REGISTERID": REGISTERID, "BARCODE": barcode },
  546. dataType: "json",
  547. type: "post"
  548. });
  549. if (result) {
  550. await swal({
  551. text: '首件数量已足够!',
  552. button: true,
  553. icon: 'error',
  554. closeOnClickOutside: false
  555. }).then(document.getElementById('urltext').value = '');
  556. return window.location.reload();
  557. }
  558. /**查询型式检验 */
  559. const resultTest = await $.ajax({
  560. url: 'api/GetCheckBarcode.ashx?m=showtest',
  561. data: { "BARCODE": barcode },
  562. dataType: "json",
  563. type: "post"
  564. });
  565. if (resultTest.length > 0) {
  566. button.disabled = false;
  567. showtestData = resultTest;
  568. }
  569. //顶部信息展示区块赋值
  570. $('#REGISTERNO').val(checkdata[0].REGISTERNO);
  571. //生产车间
  572. $('#WORKSHOP').val(checkdata[0].WORKSHOP);
  573. $('#GOODSNAME').val(checkdata[0].GOODSNAME);
  574. $('#GOODSCODE').val(checkdata[0].GOODSCODE);
  575. $('#DATA').val(checkdata[0].DATA);
  576. $('#产品类型').val(checkdata[0].产品类型);
  577. $('#MATERIALCODE').val(checkdata[0].MATERIALCODE);
  578. $('#FIRQUANTITY').val(checkdata[0].FIRQUANTITY);
  579. $('#检验依据').val(checkdata[0].检验依据);
  580. //装填tab栏(重新绘制页面)
  581. await getli();
  582. await addinputvalue(barcode);
  583. // 清空输入框
  584. //document.getElementById('urltext').value = '';
  585. };
  586. /**
  587. * barcode校验
  588. * @param barcode 产品条码
  589. */
  590. const check = async (barcode) => {
  591. /**获取总单信息对象*/
  592. let GOODS = {
  593. GOODSID: '',
  594. GOODSNAME: '',
  595. LOGOID: ''
  596. }
  597. //调用顺序不可变
  598. //根据barcode获取产品ID产品名称
  599. await $.ajax({
  600. url: 'api/GetCheckBarcode.ashx?m=checkbarcode',
  601. data: { 'barcode': barcode },
  602. dataType: "json",
  603. type: "post",
  604. success: function (data) {
  605. GOODS.GOODSID = data[0].GOODSID;
  606. GOODS.GOODSNAME = data[0].GOODSNAME;
  607. GOODS.LOGOID = data[0].LOGOID;
  608. }
  609. });
  610. //添加总单信息
  611. return $.ajax({
  612. url: 'api/GetCheckBarcode.ashx?m=getfirstregister',
  613. data: GOODS,
  614. dataType: "json",
  615. type: "post"
  616. });
  617. }
  618. /**
  619. * 监视各个tab栏内数据
  620. * @param tableId 表格id
  621. */
  622. const getItem = (tableId) => {
  623. /**根据id获取表格 */
  624. const table = document.getElementById(tableId);
  625. /**根据表格获取所有行 */
  626. const rows = table.getElementsByTagName('tr');
  627. /**跳过表头*/
  628. for (let i = 1; i < rows.length; i++) {
  629. /**获取当前行 */
  630. const cells = rows[i].getElementsByTagName('td');
  631. /**查找包含单选按钮的单元格*/
  632. const radioCell = Array.from(cells).find(cell => cell.classList.contains('radio'));
  633. /**单选值 */
  634. let judgmentResult = null;
  635. //单选时
  636. if (radioCell) {
  637. /**获取单选集合 */
  638. const radioButtons = radioCell.getElementsByTagName('input');
  639. //遍历
  640. for (let j = 0; j < radioButtons.length; j++) {
  641. //被选中
  642. if (radioButtons[j].checked) {
  643. //赋值
  644. judgmentResult = radioButtons[j].value;
  645. break;
  646. }
  647. }
  648. }
  649. // 查找包含文本输入框的单元格
  650. const checkboxCell = Array.from(cells).find(cell => cell.classList.contains('text'));
  651. /**输入框值 */
  652. let textInputValue = '';
  653. //赋值
  654. if (checkboxCell) {
  655. const textInput = checkboxCell.getElementsByTagName('input')[0];
  656. textInputValue = textInput.value.trim();
  657. }
  658. /**获取当前行的单选值以及输入框的值 */
  659. const item = {
  660. ITEMSID: rows[i].id,
  661. judgmentResult: judgmentResult,
  662. textInputValue: textInputValue,
  663. };
  664. // 检查 data 数组中是否已经存在具有相同 ITEMSID 的条目
  665. let existingItem = data.find(itemInArray => itemInArray.ITEMSID === item.ITEMSID);
  666. if (existingItem) {
  667. // 如果存在,则更新该条目的值
  668. existingItem.judgmentResult = judgmentResult;
  669. existingItem.textInputValue = textInputValue;
  670. } else {
  671. // 如果不存在,则添加新条目
  672. data.push(item);
  673. }
  674. }
  675. };
  676. /**定义一个函数来处理单选按钮值和输入框的变化*/
  677. const handleRadioChange = async (event) => {
  678. /**获取触发事件*/
  679. const trigger = event.target;
  680. /**获取所在的行*/
  681. const row = trigger.closest('tr');
  682. if (row !== null) {
  683. const tableId = row.closest('table').id;
  684. /**调用getItem函数来获取当前表格的数据*/
  685. await getItem(tableId);
  686. }
  687. };
  688. /**提交 */
  689. const submit = async (complete) => {
  690. /**获取输入框的值 */
  691. var productBarcode = document.getElementById('urltext').value;
  692. // 检查输入是否为空
  693. if (productBarcode.trim() === '') {
  694. swal({
  695. text: '请输入产品条码!',
  696. button: true,
  697. icon: 'error',
  698. closeOnClickOutside: false
  699. });
  700. return;
  701. }
  702. const result = await $.ajax({
  703. url: 'api/GetCheckBarcode.ashx?m=check',
  704. dataType: "json",
  705. type: "post",
  706. contentType: "application/json; charset=utf-8",
  707. data: JSON.stringify({
  708. "REGISTERID": REGISTERID, "barcode": barcode, "accountId": jsonUser.accountId, "userId": jsonUser.userId, "data": data, "complete": complete
  709. })
  710. })
  711. await swal({
  712. text: result.result ? '保存成功!' : '保存失败',
  713. button: true,
  714. icon: result.result ? 'success' : 'error',
  715. closeOnClickOutside: false
  716. });
  717. window.location.reload();
  718. }
  719. /**
  720. * 根据barcode查找填写过数据
  721. * @param barcode
  722. */
  723. const addinputvalue = async (barcode) => {
  724. /**barcode查找填写过数据 */
  725. const data = await $.ajax({
  726. url: 'api/GetCheckBarcode.ashx?m=getregister',
  727. dataType: "json",
  728. type: "post",
  729. data: { 'BARCODE': barcode }
  730. })
  731. // 处理数据
  732. for (var i = 0; i < data.Result.length; i++) {
  733. //将数据回显
  734. await setval(data.Result[i]);
  735. }
  736. }
  737. /**
  738. * 将数据放置table中
  739. * @param data 数据-
  740. */
  741. const setval = async (data) => {
  742. /**根据表格指定行 */
  743. const specificRow = await document.getElementById(data.ITEMSID);
  744. /**获取当前行 */
  745. const cells = await specificRow.getElementsByTagName('td');
  746. if (data.ITEMSID == 20) {
  747. // 查找包含文本输入框的单元格
  748. const checkboxCell = Array.from(cells).find(cell => cell.classList.contains('text')).getElementsByTagName('input')[0];
  749. //赋值
  750. checkboxCell.value = data.ITEMSREMARKS.trim();
  751. //将表格数据放置在对象中
  752. await getItem(data.ITEMSYTPE);
  753. return;
  754. }
  755. /**查找包含单选按钮的单元格*/
  756. const radioCell = Array.from(cells).find(cell => cell.classList.contains('radio'));
  757. /**获取单选输入框 */
  758. const radioInputs = radioCell.getElementsByTagName('input');
  759. //赋值
  760. if (data.ITEMSVALUE == '1') {
  761. radioInputs[0].checked = true;
  762. } else if (data.ITEMSVALUE == '0') {
  763. radioInputs[1].checked = true;
  764. }
  765. // 查找包含文本输入框的单元格
  766. const checkboxCell = Array.from(cells).find(cell => cell.classList.contains('text')).getElementsByTagName('input')[0];
  767. //赋值
  768. checkboxCell.value = data.ITEMSREMARKS.trim();
  769. //将表格数据放置在对象中
  770. await getItem(data.ITEMSYTPE);
  771. }
  772. /**查看型式检验按钮 */
  773. const showtest = async () => {
  774. const table = document.getElementById('showtestTable');
  775. // 清空表格内容
  776. while (table.firstChild) {
  777. table.removeChild(table.firstChild);
  778. }
  779. /**创建表头 */
  780. const thead = document.createElement('thead');
  781. thead.className = 'sticky-table-header';
  782. const headerRow = document.createElement('tr');
  783. /**创建表头数据 */
  784. headerRow.className = 'table-secondary';
  785. ['序号', '产品型号', '产品名称', '检验时间', '检验项目', '检验标准', '单位', '数值','结果'].forEach(headerText => {
  786. const th = document.createElement('th');
  787. th.scope = 'col';
  788. th.textContent = headerText;
  789. th.className = 'table-cell';
  790. headerRow.appendChild(th);
  791. });
  792. thead.appendChild(headerRow);
  793. /**创建表体 */
  794. const tbody = document.createElement('tbody');
  795. for (var i = 0; i < showtestData.length; i++) {
  796. const tr = document.createElement('tr');
  797. var keys = Object.keys(showtestData[i]);
  798. for (var k = 0; k < keys.length; k++) {
  799. const td = document.createElement('td');
  800. td.textContent = showtestData[i][keys[k]];
  801. td.className = 'table-cell';
  802. tr.appendChild(td);
  803. }
  804. tbody.appendChild(tr);
  805. }
  806. //依次填充结构
  807. table.appendChild(thead);
  808. table.appendChild(tbody);
  809. $('#exampleModal').modal('show')
  810. }
  811. </script>
  812. <!--版权信息-->
  813. <script src="../common/footer.js"></script>
  814. <script src="/Plugins/bootstrap-4.3.1/js/bootstrap.bundle.min.js"></script>
  815. <script src="/Plugins/bootstrap-select/js/bootstrap-select.min.js"></script>
  816. <script src="/Plugins/sweetalert/sweetalert.min.js"></script>
  817. <script src="/Plugins/xrequest/xrequest.min.js"></script>
  818. <script src="../Common/xuwell.js"></script>
  819. </body>
  820. </html>