| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838 |
- <!doctype html>
- <!--李士越 首件检验检验端-->
- <html lang="en">
- <head>
- <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
- <meta http-equiv="Pragma" content="no-cache" />
- <meta http-equiv="Expires" content="0" />
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <link rel="shortcut icon" href="/img/logo.png" />
- <link rel="bookmark" href="/img/logo.png" />
- <link rel="stylesheet" href="/plugins/bootstrap-4.3.1/css/bootstrap.min.css">
- <link rel="stylesheet" href="/plugins/font-awesome-4.7.0/css/font-awesome.min.css">
- <link href="/Plugins/bootstrap-select/css/bootstrap-select.min.css" rel="stylesheet" />
- <link rel="stylesheet" href="../common/StyleSheet.css" />
- <link href="/Plugins/bootstrap-4.3.1/css/bootstrap4-modal-fullscreen.css" rel="stylesheet" />
- <script src="/Plugins/jquery-3.4.1/jquery-3.4.1.min.js"></script>
- <script src="/Plugins/virtualkeyboard/xvirtualkeyboard.js"></script>
- <style type="text/css">
- .outlayer {
- box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075);
- border-radius: .25rem;
- background-color: #fff;
- box-sizing: border-box;
- padding: 1rem 1.5rem .5rem 1.5rem;
- margin: 1rem 1.5rem .5rem 1.5rem;
- }
- .layer {
- padding: 0;
- margin-left: 0;
- margin-right: 0;
- }
- .formrow {
- display: flex;
- flex-wrap: wrap;
- width: 100%;
- }
- /* 切换栏*/
- .tab {
- width: 100%;
- position: relative;
- padding: 0;
- }
- .tab_list {
- width: 100%;
- }
- .tab_list ul {
- padding-left: 0;
- margin: 0;
- }
- .tab_list li {
- width: 25%;
- height: 45px;
- list-style: none;
- line-height: 45px;
- text-align: center;
- float: left;
- }
- .tab_list .current {
- background-color: #138496;
- color: #fff;
- }
- .tab_con {
- width: 100%;
- }
- /*展示区块*/
- .item {
- width: 100%;
- font-size: 20px;
- text-align: center;
- background: #efefef;
- top: 50px;
- position: absolute;
- }
- table {
- width: 100%;
- border-collapse: collapse;
- }
- th, td {
- border: 1px solid #000;
- text-align: center;
- }
- th {
- background-color: #f2f2f2;
- }
- /*单选框*/
- input[type="radio"] {
- width: 20px;
- height: 20px;
- }
- /*表格输入框*/
- .checkbox {
- text-align: center;
- }
- /*表格输入框*/
- .hidden-style {
- width: 100%;
- /* 移除边框 */
- border: none;
- /* 设置背景透明 */
- background: transparent;
- /* 移除阴影 */
- box-shadow: none;
- /* 移除焦点时的轮廓线 */
- outline: none;
- /* 移除内边距 */
- padding: 0;
- /* 移除外边距 */
- margin: 0;
- /* 继承父元素的字体大小 */
- font-size: inherit;
- }
- /*签字版*/
- .tablet {
- flex: 1;
- text-shadow: 0px 0px 0px #000000;
- color: black
- }
- .frame {
- width: 100%;
- height: 370px;
- }
- .col-0 {
- -ms-flex: 0 0 4.333333%;
- flex: 0 0 4.333333%;
- max-width: 4.333333%;
- }
- .table-container {
- position: relative;
- max-height: 720px;
- /* 允许垂直滚动 */
- overflow-y: auto;
- /* 为容器添加边框 */
- border: 1px solid #ddd;
- }
- /* 通用的表头和表体单元格样式 */
- .table-cell {
- padding: 8px;
- border: 1px solid #ddd;
- }
- /* 固定表头的样式 */
- .sticky-table-header th {
- position: sticky;
- top: 0;
- background-color: #d6d8db;
- /* 确保表头位于其他内容之上 */
- z-index: 2;
- /* 为表头添加底部边框以区分 */
- border-bottom: 2px solid #ddd;
- }
- </style>
- <title>东科软件</title>
- </head>
- <body class="bg-light">
- <!--导航菜单-->
- <script src="../common/navbar.js"></script>
- <!--对话框-->
- <!--<script src="../common/dialog.js"></script>-->
- <!--顶部-->
- <div class="outlayer">
- <!--产品条码区块-->
- <div class="formrow">
- <div class="form-group col-4 mb-1">
- <label for="产品条码">产品条码</label>
- <input value="" onkeydown="if (event.keyCode == 13) loadProduct();" type="text" class="form-control" id="urltext" placeholder="请输入" required>
- </div>
- <div class="form-group col-8 align-self-end mb-1">
- <button onclick="loadProduct()" type="button" class="btn btn-info btn-block">产品查询</button>
- </div>
- </div>
- </div>
- <div class="outlayer">
- <div class="formrow">
- <div class="form-group col-2 mb-1" style="max-width: 15%; flex: 10%; -ms-flex:10%">
- <label>首件登记单号</label>
- <input id="REGISTERNO" readonly type="text" class="form-control border-secondary">
- </div>
- <div class="form-group col-0 mb-1">
- <label>生产车间</label>
- <input id="WORKSHOP" readonly type="text" class="form-control border-secondary">
- </div>
- <div class="form-group col-2 mb-1" style="max-width: 10%; flex: 10%; -ms-flex:10%">
- <label>产品名称</label>
- <input id="GOODSNAME" readonly type="text" class="form-control border-secondary">
- </div>
- <div class="form-group col-1 mb-1">
- <label>产品型号</label>
- <input id="GOODSCODE" readonly type="text" class="form-control border-secondary">
- </div>
- <div class="form-group col-1 mb-1">
- <label>日期</label>
- <input id="DATA" readonly type="text" class="form-control border-secondary">
- </div>
- <div class="form-group col-1 mb-1">
- <label>产品类型</label>
- <input id="产品类型" readonly type="text" class="form-control border-secondary">
- </div>
- <div class="form-group col-2 mb-1">
- <label>物料编码</label>
- <input id="MATERIALCODE" readonly type="text" class="form-control border-secondary">
- </div>
- <div class="form-group col-0 mb-1">
- <label>首件数量</label>
- <input id="FIRQUANTITY" readonly type="text" class="form-control border-secondary">
- </div>
- <div class="form-group col-1 mb-1">
- <label>检验依据</label>
- <input id="检验依据" readonly type="text" class="form-control border-secondary">
- </div>
- <div >
- <button id="showtest" onclick="showtest()" type="button" class="btn btn-info btn-block" style="margin-top:30px; ">查看型式检验</button>
- </div>
- <div>
- <button id="complete" onclick="submit(true)" type="button" class="btn btn-info btn-block" style="margin-top:30px; margin-left:30px;">检验完成</button>
- </div>
- </div>
- </div>
- <!--下部-->
- <!--左侧产品条码-->
- <div class="outlayer" style="height: 500px">
- <div class='tab'>
- <div class='tab_list'>
- <ul id="myList">
- <li></li>
- </ul>
- </div>
- <div id="container" class='tab_con'>
- </div>
- </div>
- </div>
- <div class="outlayer">
- <div class="form-group col-12 align-self-end mb-1">
- <button onclick="submit(false)" type="button" class="btn btn-info btn-block">提交</button>
- </div>
- </div>
- <!--型式检验弹窗-->
- <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
- <div class="modal-dialog" style="max-width:90%;">
- <div class="modal-content" >
- <div class="modal-header" style=" display: block;" >
- <h5 style="text-align: center; font-weight: bold;">检验报告</h5>
- </div>
- <div class="modal-body" >
- <div class="table-container">
- <table id="showtestTable" class="table">
-
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- /**总单id */
- let REGISTERID;
- /**产品条码 */
- let barcode = '';
- /**填写记录数据 */
- let data = [];
- /**tab栏数据 */
- let li = [];
- /**登录数据源 */
- let jsonUser;
- /**查看型式检验是否可点击 */
- var button = document.getElementById('showtest');
- // 初始设置按钮为不可点击
- button.disabled = true;
- /**型式检验数据 */
- let showtestData = [];
- /**加载前调用*/
- $(document).ready(function () {
- loadData();
- });
- //加载 生产工号
- function loadData() {
- //检查登录状态
- $.get('api/LogInCheck_WCF.ashx', function (data) {
- var json = JSON.parse(data);
- if (json["success"] == true) {
- //保存登录数据源
- jsonUser = json["rows"];
- }
- else {
- swal({
- title: '登录异常!',
- text: '请您先登录系统!',
- icon: 'error',
- button: '确定'
- }).then(function () {
- window.location = '/main/login/login.html';
- });
- }
- });
- }
- /**获取切换栏 */
- const getli = async () => {
- //清空li
- li.length = 0;
- // 获取tab栏数据
- const data = await $.ajax({
- url: 'api/GetCheckBarcode.ashx?m=getli',
- dataType: "json",
- type: "get"
- });
- // 处理数据
- for (var i = 0; i < data.length; i++) {
- // 创建item和表格
- await createtable(data[i]);
- // 添加tab栏数据
- await li.push(data[i]);
- }
- // 调用函数来填充列表
- await populateList(li);
- }
- /**
- * 创建表格
- * @param tableid
- */
- const createtable = (tableid) => {
- /**找到要创建的位置*/
- const container = document.getElementById('container');
- /**创建div结构 */
- const div = document.createElement('div');
- //赋值class
- div.className = 'item';
- /**创建表格 */
- const table = document.createElement('table');
- //设置属性
- table.style.width = '100%';
- table.id = tableid
- /**创建表头 */
- const thead = document.createElement('thead');
- const headerRow = document.createElement('tr');
- /**创建表头数据 */
- headerRow.className = 'table-secondary';
- ['检验项目', '要求', '判定结果', '异常情况'].forEach(headerText => {
- const th = document.createElement('th');
- th.scope = 'col';
- th.textContent = headerText;
- headerRow.appendChild(th);
- });
- thead.appendChild(headerRow);
- /**创建表体 */
- const tbody = document.createElement('tbody');
- //依次填充结构
- table.appendChild(thead);
- table.appendChild(tbody);
- div.appendChild(table);
- container.appendChild(div);
- }
- /**
- * 填充li
- * @param items li集合
- */
- const populateList = async (items) => {
- /**获取 ul*/
- const ul = document.getElementById('myList');
- // 清空现有的 <li> 元素
- ul.innerHTML = '';
- for (var i = 0; i < items.length; i++) {
- var item = items[i];
- /**获取当前li */
- const liElement = document.createElement('li');
- //第一个li
- if (i === 0) {
- //添加class(选中效果)
- liElement.classList.add('current');
- }
- //添加名称
- liElement.textContent = item;
- //将li放入ul中
- ul.appendChild(liElement);
- //生成该li对应的内容
- await gettxt(item);
- }
- //li初始化和点击事件
- await lionclick();
- await initializeRadioListeners();
- await addinputvalue(barcode);
- }
- /**li与div联动(tabs) */
- const lionclick = () => {
- var lis = document.querySelectorAll('.tab_list li');
- var items = document.querySelectorAll('.item');
- // 设置所有 li 的 data-index 属性
- lis.forEach(function (li, index) {
- li.setAttribute('data-index', index);
- });
- // 函数:根据 current li 显示对应的 item
- function showCorrectItem() {
- var currentIndex = null;
- // 查找带有 class="current" 的 li 的索引
- lis.forEach(function (li, index) {
- if (li.classList.contains('current')) {
- currentIndex = index;
- }
- });
- // 隐藏所有 item
- items.forEach(function (item) {
- item.style.display = 'none';
- });
- // 显示对应的 item
- items[currentIndex].style.display = 'block';
- }
- // 页面加载完成后调用
- showCorrectItem();
- // 设置 li 的点击事件
- lis.forEach(function (li) {
- li.addEventListener('click', function () {
- // 重置所有 li 的类名
- lis.forEach(function (otherLi) {
- otherLi.classList.remove('current');
- });
- // 设置当前 li 的类名为 'current'
- this.classList.add('current');
- // 显示对应的 item
- showCorrectItem(); // 调用函数来更新显示
- });
- });
- };
- /**
- * 获取表格内容
- * @param ITEMSYTPE 类型
- */
- const gettxt = async (ITEMSYTPE) => {
- //获取表格内容
- const data = await $.ajax({
- url: 'api/GetCheckBarcode.ashx?m=gettable',
- data: { 'ITEMSYTPE': ITEMSYTPE },
- dataType: "json",
- type: "post"
- });
- // 处理数据
- for (var i = 0; i < data.length; i++) {
- //填充表格数据
- await fillTable(data, ITEMSYTPE);
- await initializeRadioListeners();
- }
- }
- /**
- * 表格填充数据
- * @param data 数据
- * @param tableid 表格id
- */
- const fillTable = (data, tableid) => {
- const tbodySelector = '#' + tableid + ' tbody';
- const tbody = document.querySelector(tbodySelector);
- // 清空容器
- while (tbody.firstChild) {
- tbody.removeChild(tbody.firstChild);
- }
- // 遍历数据数组,并为每个项目创建一个新的表格行
- /* data.forEach(item => {*/
- for (const item of data) {
- // 创建一个新的表格行
- const tr = document.createElement('tr');
- tr.id = item.ITEMSID;
- // 创建并填充第一个 <td> 元素(检验项目)
- const tdItemsName = document.createElement('td');
- tdItemsName.textContent = item.ITEMSNAME;
- tr.appendChild(tdItemsName);
- if (item.ITEMSID == 20) {
- const tdAbnormality = document.createElement('td');
- tdAbnormality.className = 'text';
- tdAbnormality.colSpan = 3;
- tdAbnormality.innerHTML = '<input type="text" class="hidden-style">';
- tr.appendChild(tdAbnormality);
- tbody.appendChild(tr);
- continue;
- }
- // 创建并填充第二个 <td> 元素(要求)
- const tdItemsInfo = document.createElement('td');
- tdItemsInfo.textContent = item.ITEMSINFO;
- tr.appendChild(tdItemsInfo);
- //创建了空的 <td> 元素
- const tdResult = document.createElement('td');
- tdResult.className = 'radio';
- // 创建第一个单选按钮
- const radioOk = document.createElement('input');
- radioOk.type = 'radio';
- radioOk.name = item.ITEMSID;
- radioOk.value = '1';
- // 创建与单选按钮相邻的文本节点 "OK"
- const textOk = document.createTextNode('OK');
- // 创建第二个单选按钮
- const radioNg = document.createElement('input');
- radioNg.type = 'radio';
- radioNg.name = item.ITEMSID;
- radioNg.value = '0';
- // 创建与单选按钮相邻的文本节点 "NG"
- const textNg = document.createTextNode('NG');
- // 将元素添加到 tdResult 中
- tdResult.appendChild(radioOk);
- tdResult.appendChild(textOk);
- tdResult.appendChild(radioNg);
- tdResult.appendChild(textNg);
- // 添加 radio buttons
- tr.appendChild(tdResult);
- const tdAbnormality = document.createElement('td');
- tdAbnormality.className = 'text';
- tdAbnormality.innerHTML = '<input type="text" class="hidden-style">';
- tr.appendChild(tdAbnormality);
- // 将新的表格行添加到 tbody 中
- tbody.appendChild(tr);
- };
- }
- /**定义一个函数来初始化所有单选按钮的事件监听器 */
- const initializeRadioListeners = () => {
- /**获取所有单选按钮*/
- const radioButtons = document.querySelectorAll('input[type="radio"]');
- /**获取所有输入框*/
- const textButtons = document.querySelectorAll('input[type="text"]');
- /**为每个单选按钮添加事件监听器*/
- radioButtons.forEach(radio => {
- radio.addEventListener('change', handleRadioChange);
- });
- /**为每个输入框 添加事件监听器*/
- textButtons.forEach(text => {
- text.addEventListener('change', handleRadioChange);
- });
- };
- /**产品查询 */
- const loadProduct = async () => {
- barcode = '';
- data.length = 0;
- /**获取输入框的值 */
- var productBarcode = document.getElementById('urltext').value;
- //产品条码赋值
- barcode = productBarcode;
- /**总单信息数据 */
- const checkdata = await check(barcode);
- //未查到总单信息
- if (checkdata[0] == null) {
- return swal({
- text: '产品条码无效或无可用首件登记单!',
- button: true,
- icon: 'error',
- closeOnClickOutside: false
- }).then(document.getElementById('urltext').value = '');
- }
- //总单id赋值
- REGISTERID = checkdata[0].REGISTERID;
- /**判断总单是否过量 */
- const result = await $.ajax({
- url: 'api/GetCheckBarcode.ashx?m=checkcount',
- data: { "REGISTERID": REGISTERID, "BARCODE": barcode },
- dataType: "json",
- type: "post"
- });
- if (result) {
- await swal({
- text: '首件数量已足够!',
- button: true,
- icon: 'error',
- closeOnClickOutside: false
- }).then(document.getElementById('urltext').value = '');
- return window.location.reload();
- }
- /**查询型式检验 */
- const resultTest = await $.ajax({
- url: 'api/GetCheckBarcode.ashx?m=showtest',
- data: { "BARCODE": barcode },
- dataType: "json",
- type: "post"
- });
- if (resultTest.length > 0) {
- button.disabled = false;
- showtestData = resultTest;
- }
- //顶部信息展示区块赋值
- $('#REGISTERNO').val(checkdata[0].REGISTERNO);
- //生产车间
- $('#WORKSHOP').val(checkdata[0].WORKSHOP);
- $('#GOODSNAME').val(checkdata[0].GOODSNAME);
- $('#GOODSCODE').val(checkdata[0].GOODSCODE);
- $('#DATA').val(checkdata[0].DATA);
- $('#产品类型').val(checkdata[0].产品类型);
- $('#MATERIALCODE').val(checkdata[0].MATERIALCODE);
- $('#FIRQUANTITY').val(checkdata[0].FIRQUANTITY);
- $('#检验依据').val(checkdata[0].检验依据);
- //装填tab栏(重新绘制页面)
- await getli();
- await addinputvalue(barcode);
- // 清空输入框
- //document.getElementById('urltext').value = '';
- };
- /**
- * barcode校验
- * @param barcode 产品条码
- */
- const check = async (barcode) => {
- /**获取总单信息对象*/
- let GOODS = {
- GOODSID: '',
- GOODSNAME: '',
- LOGOID: ''
- }
- //调用顺序不可变
- //根据barcode获取产品ID产品名称
- await $.ajax({
- url: 'api/GetCheckBarcode.ashx?m=checkbarcode',
- data: { 'barcode': barcode },
- dataType: "json",
- type: "post",
- success: function (data) {
- GOODS.GOODSID = data[0].GOODSID;
- GOODS.GOODSNAME = data[0].GOODSNAME;
- GOODS.LOGOID = data[0].LOGOID;
- }
- });
- //添加总单信息
- return $.ajax({
- url: 'api/GetCheckBarcode.ashx?m=getfirstregister',
- data: GOODS,
- dataType: "json",
- type: "post"
- });
- }
- /**
- * 监视各个tab栏内数据
- * @param tableId 表格id
- */
- const getItem = (tableId) => {
- /**根据id获取表格 */
- const table = document.getElementById(tableId);
- /**根据表格获取所有行 */
- const rows = table.getElementsByTagName('tr');
- /**跳过表头*/
- for (let i = 1; i < rows.length; i++) {
- /**获取当前行 */
- const cells = rows[i].getElementsByTagName('td');
- /**查找包含单选按钮的单元格*/
- const radioCell = Array.from(cells).find(cell => cell.classList.contains('radio'));
- /**单选值 */
- let judgmentResult = null;
- //单选时
- if (radioCell) {
- /**获取单选集合 */
- const radioButtons = radioCell.getElementsByTagName('input');
- //遍历
- for (let j = 0; j < radioButtons.length; j++) {
- //被选中
- if (radioButtons[j].checked) {
- //赋值
- judgmentResult = radioButtons[j].value;
- break;
- }
- }
- }
- // 查找包含文本输入框的单元格
- const checkboxCell = Array.from(cells).find(cell => cell.classList.contains('text'));
- /**输入框值 */
- let textInputValue = '';
- //赋值
- if (checkboxCell) {
- const textInput = checkboxCell.getElementsByTagName('input')[0];
- textInputValue = textInput.value.trim();
- }
- /**获取当前行的单选值以及输入框的值 */
- const item = {
- ITEMSID: rows[i].id,
- judgmentResult: judgmentResult,
- textInputValue: textInputValue,
- };
- // 检查 data 数组中是否已经存在具有相同 ITEMSID 的条目
- let existingItem = data.find(itemInArray => itemInArray.ITEMSID === item.ITEMSID);
- if (existingItem) {
- // 如果存在,则更新该条目的值
- existingItem.judgmentResult = judgmentResult;
- existingItem.textInputValue = textInputValue;
- } else {
- // 如果不存在,则添加新条目
- data.push(item);
- }
- }
- };
- /**定义一个函数来处理单选按钮值和输入框的变化*/
- const handleRadioChange = async (event) => {
- /**获取触发事件*/
- const trigger = event.target;
- /**获取所在的行*/
- const row = trigger.closest('tr');
- if (row !== null) {
- const tableId = row.closest('table').id;
- /**调用getItem函数来获取当前表格的数据*/
- await getItem(tableId);
- }
- };
- /**提交 */
- const submit = async (complete) => {
- /**获取输入框的值 */
- var productBarcode = document.getElementById('urltext').value;
- // 检查输入是否为空
- if (productBarcode.trim() === '') {
- swal({
- text: '请输入产品条码!',
- button: true,
- icon: 'error',
- closeOnClickOutside: false
- });
- return;
- }
- const result = await $.ajax({
- url: 'api/GetCheckBarcode.ashx?m=check',
- dataType: "json",
- type: "post",
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify({
- "REGISTERID": REGISTERID, "barcode": barcode, "accountId": jsonUser.accountId, "userId": jsonUser.userId, "data": data, "complete": complete
- })
- })
- await swal({
- text: result.result ? '保存成功!' : '保存失败',
- button: true,
- icon: result.result ? 'success' : 'error',
- closeOnClickOutside: false
- });
- window.location.reload();
- }
- /**
- * 根据barcode查找填写过数据
- * @param barcode
- */
- const addinputvalue = async (barcode) => {
- /**barcode查找填写过数据 */
- const data = await $.ajax({
- url: 'api/GetCheckBarcode.ashx?m=getregister',
- dataType: "json",
- type: "post",
- data: { 'BARCODE': barcode }
- })
- // 处理数据
- for (var i = 0; i < data.Result.length; i++) {
- //将数据回显
- await setval(data.Result[i]);
- }
- }
- /**
- * 将数据放置table中
- * @param data 数据-
- */
- const setval = async (data) => {
- /**根据表格指定行 */
- const specificRow = await document.getElementById(data.ITEMSID);
- /**获取当前行 */
- const cells = await specificRow.getElementsByTagName('td');
- if (data.ITEMSID == 20) {
- // 查找包含文本输入框的单元格
- const checkboxCell = Array.from(cells).find(cell => cell.classList.contains('text')).getElementsByTagName('input')[0];
- //赋值
- checkboxCell.value = data.ITEMSREMARKS.trim();
- //将表格数据放置在对象中
- await getItem(data.ITEMSYTPE);
- return;
- }
- /**查找包含单选按钮的单元格*/
- const radioCell = Array.from(cells).find(cell => cell.classList.contains('radio'));
- /**获取单选输入框 */
- const radioInputs = radioCell.getElementsByTagName('input');
- //赋值
- if (data.ITEMSVALUE == '1') {
- radioInputs[0].checked = true;
- } else if (data.ITEMSVALUE == '0') {
- radioInputs[1].checked = true;
- }
- // 查找包含文本输入框的单元格
- const checkboxCell = Array.from(cells).find(cell => cell.classList.contains('text')).getElementsByTagName('input')[0];
- //赋值
- checkboxCell.value = data.ITEMSREMARKS.trim();
- //将表格数据放置在对象中
- await getItem(data.ITEMSYTPE);
- }
- /**查看型式检验按钮 */
- const showtest = async () => {
- const table = document.getElementById('showtestTable');
- // 清空表格内容
- while (table.firstChild) {
- table.removeChild(table.firstChild);
- }
- /**创建表头 */
- const thead = document.createElement('thead');
- thead.className = 'sticky-table-header';
- const headerRow = document.createElement('tr');
- /**创建表头数据 */
- headerRow.className = 'table-secondary';
- ['序号', '产品型号', '产品名称', '检验时间', '检验项目', '检验标准', '单位', '数值','结果'].forEach(headerText => {
- const th = document.createElement('th');
- th.scope = 'col';
- th.textContent = headerText;
- th.className = 'table-cell';
- headerRow.appendChild(th);
- });
- thead.appendChild(headerRow);
- /**创建表体 */
- const tbody = document.createElement('tbody');
- for (var i = 0; i < showtestData.length; i++) {
- const tr = document.createElement('tr');
- var keys = Object.keys(showtestData[i]);
- for (var k = 0; k < keys.length; k++) {
- const td = document.createElement('td');
- td.textContent = showtestData[i][keys[k]];
- td.className = 'table-cell';
- tr.appendChild(td);
- }
- tbody.appendChild(tr);
- }
- //依次填充结构
- table.appendChild(thead);
- table.appendChild(tbody);
- $('#exampleModal').modal('show')
- }
-
- </script>
- <!--版权信息-->
- <script src="../common/footer.js"></script>
- <script src="/Plugins/bootstrap-4.3.1/js/bootstrap.bundle.min.js"></script>
- <script src="/Plugins/bootstrap-select/js/bootstrap-select.min.js"></script>
- <script src="/Plugins/sweetalert/sweetalert.min.js"></script>
- <script src="/Plugins/xrequest/xrequest.min.js"></script>
- <script src="../Common/xuwell.js"></script>
- </body>
- </html>
|