From 6266614b48ec552917912f1956a6529be812e13c Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Wed, 24 Jul 2024 20:23:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E9=AA=8C=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/basis/standard/child/testForm.js | 79 ++++--- .../js/basis/standard/child/testList.js | 62 +++++- .../js/basis/standard/child/testUpdateForm.js | 8 +- .../js/basis/standard/testManagementList.js | 195 ++++++++++------ .../pages/basic/standard/child/testCheck.html | 208 ++++++++++-------- .../pages/basic/standard/child/testForm.html | 200 ++++++++++------- .../basic/standard/testManagementList.html | 6 +- 7 files changed, 477 insertions(+), 281 deletions(-) diff --git a/src/main/resources/static/js/basis/standard/child/testForm.js b/src/main/resources/static/js/basis/standard/child/testForm.js index 490ada6..7358222 100644 --- a/src/main/resources/static/js/basis/standard/child/testForm.js +++ b/src/main/resources/static/js/basis/standard/child/testForm.js @@ -63,18 +63,9 @@ function setParams(params) { } }); - if(experIdParam == null || experIdParam == "null"){ - //调用试验模板数据接口 - getTestById(); - }else{ - //调用试验详情数据接口 - getTestViewById(); - } - - //设备类别 // getDicts("dev_code",'devTypeName',"","设备类别",30); - getDevCode() + // getDevCode() //试验地点 getDicts("sy_local",'experLocal',"","试验地点",30); @@ -88,6 +79,16 @@ function setParams(params) { //试验依据 getDicts("sy_basis",'basisName-1',"","试验依据",30); + if(experIdParam == null || experIdParam == "null"){ + console.log("调用试验模板数据接口") + //调用试验模板数据接口 + getTestById(); + }else{ + console.log("调用试验详情数据接口") + //调用试验详情数据接口 + getTestViewById(); + } + form.on('submit(formData)', function (data) { saveData(data); }); @@ -354,12 +355,15 @@ function saveData(data) { var items = convertToItems(data.field); // 获取select元素 - var selectElement = document.getElementById('devCode'); - // 获取选中的option - var selectedOption = selectElement.options[selectElement.selectedIndex]; - // 读取option的value和text - var value = selectedOption.value; - var text = selectedOption.text; + // var selectElement = document.getElementById('devCode'); + // // 获取选中的option + // var selectedOption = selectElement.options[selectElement.selectedIndex]; + // // 读取option的value和text + // var value = selectedOption.value; + // var text = selectedOption.text; + + var value = $("#devTypeCode").val(); + var text = $("#devTypeName").val(); let paramsData = { 'yjList':yjList, @@ -406,8 +410,11 @@ function saveData(data) { }, function (result) { layer.close(loadingMsg); // 关闭提示层 if (result.code === 200) { - closePage(1); - parent.layer.msg(result.msg, {icon: 1}); + // closePage(1); + // parent.layer.msg(result.msg, {icon: 1}); + parent.layer.msg(result.msg, {icon: 1},function (index){ + closePage(1); + }) } else { layer.alert(result.msg, {icon: 2}) $('.save').removeClass("layui-btn-disabled").attr("disabled", false); @@ -462,7 +469,7 @@ function convertToExperDevList(originalData){ const manufactureDateKey = `manufactureDate-${deviceId}`; const devModuleKey = `devModule-${deviceId}`; const devStatusKey = `devStatus-${deviceId}`; - const amountKey = `amount-${deviceId}`; + const amountKey = `amounts-${deviceId}`; const remarksKey = `remarks-${deviceId}`; // 构建devData数组 @@ -553,7 +560,7 @@ function getTestById() { params={ encryptedData:encryptCBC(JSON.stringify(params)) } - ajaxRequest(url, "POST", params, true, function () { + ajaxRequest(url, "POST", params, false, function () { }, function (result) { layer.close(loadingMsg); // 关闭提示层 if (result.code === 200) { @@ -578,7 +585,12 @@ function setFormData(data) { $('#customId').val(data.customId); //设备类别 // getDicts("dev_code",'devTypeName',data.devTypeName,"设备类别",30); - $('#devCode option[value=' + data.devTypeCode + ']').attr('selected', true); + //设备类别 + $('#devTypeCode').val(data.devTypeCode); + //设备类别 + $('#devTypeName').val(data.devTypeName); + + // $('#devCode option[value=' + data.devTypeCode + ']').attr('selected', true); //设备规格 $('#devModule').val(data.devModule); @@ -670,9 +682,9 @@ function generateHeaders(data) { firstLevelHeader.colSpan = item.itemList.length; firstLevelHeader.classList.add('center-aligned'); // firstLevelHeader.textContent = `${item.experTypeName} - ${item.amount}`; - firstLevelHeader.innerHTML=`
- - + firstLevelHeader.innerHTML=`
+ +
`; thead.rows[0].appendChild(firstLevelHeader); @@ -681,7 +693,7 @@ function generateHeaders(data) { const secondLevelHeader = document.createElement('th'); secondLevelHeader.classList.add('center-aligned'); secondLevelHeader.innerHTML=`
- +
` // secondLevelHeader.textContent = subItem.itemName; @@ -710,18 +722,19 @@ function generateRows(data,sampleDeviceVos){ const row = document.createElement('tr'); row.innerHTML = ` - ${idCounter} - - - - - - - + ${idCounter} + + + + + + + `; // 遍历itemList的长度,而不是itemList本身,以匹配表头的列数 for (let i = 0; i < columns; i++) { const td = document.createElement('td'); + td.style.width = '340px'; const input = document.createElement('input'); input.type = 'text'; input.id = `devData-${idCounter}-${i + 1}`; diff --git a/src/main/resources/static/js/basis/standard/child/testList.js b/src/main/resources/static/js/basis/standard/child/testList.js index 1a2ca58..64026f2 100644 --- a/src/main/resources/static/js/basis/standard/child/testList.js +++ b/src/main/resources/static/js/basis/standard/child/testList.js @@ -72,8 +72,66 @@ function initTable(dataList, limit, page) { }, {field: "devTypeName", title: "样品类型", unresize: true, align: "center"}, {field: "devModule", title: "规格型号", unresize: true, align: "center"}, - {field: "sampleQuantity", title: "样品数量", unresize: true, align: "center"}, - {field: "", title: "状态", unresize: true, align: "center"}, + {field: "", title: "样品数量", unresize: true, align: "center", + templet: function (d) { + var testResult=""; + var html = ''; + for (let i = 0; i < d.sampleList.length; i++) { + if (d.sampleList[i].testResult == "合格") { + + }else{ + testResult = d.sampleList[i].testResult + } + } + if(testResult=="不合格"){ + // 添加包裹元素并应用类 + html += "" + + "" + // 注意这里是字符串形式 + d.sampleQuantity + + ""; + }else{ + // 添加包裹元素并应用类 + html += "" + + "" + // 注意这里是字符串形式 + d.sampleQuantity + + ""; + + } + return html; + } + }, + {field: "", title: "状态", unresize: true, align: "center", + templet: function (d) { + if (d.status == "待试验") { + var html = " 待试验"; + return html; + } else if (d.status == "待提交") { + var html = " 待提交"; + return html; + } else if (d.status == "待审阅") { + var html = " 待审阅"; + return html; + }else if (d.status == "审阅不通过") { + var html = " 审阅不通过"; + return html; + }else if (d.status == "待审核") { + var html = " 待审核"; + return html; + }else if (d.status == "审核不通过") { + var html = " 审核不通过"; + return html; + }else if (d.status == "待审批") { + var html = " 待审批"; + return html; + }else if (d.status == "审批不通过") { + var html = " 审批不通过"; + return html; + }else if (d.status == "试验完成") { + var html = " 试验完成"; + return html; + } + } + }, {field: "causeOfRejection", title: "驳回原因", unresize: true, align: "center"}, {title: "原始记录", unresize: true, width: 300, align: "center", templet: function (d) { diff --git a/src/main/resources/static/js/basis/standard/child/testUpdateForm.js b/src/main/resources/static/js/basis/standard/child/testUpdateForm.js index e2914b1..64b98cb 100644 --- a/src/main/resources/static/js/basis/standard/child/testUpdateForm.js +++ b/src/main/resources/static/js/basis/standard/child/testUpdateForm.js @@ -31,9 +31,11 @@ function setFormUpadteData(data) { $('#id').val(data.id); $('#sampleId').val(data.sampleId); $('#customId').val(data.customId); - //设备类别 // getDicts("dev_code",'devTypeName',data.devTypeName,"设备类别",30); - $('#devCode option[value=' + data.devTypeCode + ']').attr('selected', true); + //设备类别 + $('#devTypeCode').val(data.devTypeCode); + //设备类别 + $('#devTypeName').val(data.devTypeName); //设备规格 $('#devModule').val(data.devModule); @@ -124,7 +126,7 @@ function setTableData(data){ $(`#manufactureDate-${rowNumber}`).val(item.manufactureDate); $(`#devModule-${rowNumber}`).val(item.devModule); $(`#devStatus-${rowNumber}`).val(item.devStatus); - $(`#amount-${rowNumber}`).val(item.amount); + $(`#amounts-${rowNumber}`).val(item.amount); $(`#remarks-${rowNumber}`).val(item.remarks); // devData 是一个字符串,需要解析为数组 const devDataArray = JSON.parse(item.devData); diff --git a/src/main/resources/static/js/basis/standard/testManagementList.js b/src/main/resources/static/js/basis/standard/testManagementList.js index 35600ca..d434919 100644 --- a/src/main/resources/static/js/basis/standard/testManagementList.js +++ b/src/main/resources/static/js/basis/standard/testManagementList.js @@ -1,6 +1,8 @@ let form, layer, table, tableIns; let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 -let selectedIds = []; // 存储选中项的ID + +let temp_table_list = []; // 临时保存每页的所有数据 +let temp_all_list = []; // 临时保存所有选中的数据 layui.use(['form', 'layer', 'table', 'laydate'], function () { form = layui.form; layer = layui.layer; @@ -79,24 +81,42 @@ function initTable(dataList, limit, page) { {field: "sampleDate", title: "收样时间", unresize: true, align: "center"}, {field: "dispatchUserName", title: "派工人", unresize: true, align: "center"}, {field: "teamName", title: "试验班组", unresize: true, align: "center"}, - {field: "audtiStatus", title: "状态", unresize: true, align: "center", - // templet: function (d) { - // if (d.audtiStatus == "0") { - // return "待试验"; - // } else if (d.audtiStatus == "1") { - // return "待审阅"; - // } else if (d.audtiStatus == "2") { - // return "待审核"; - // }else if (d.audtiStatus == "3") { - // return "待审批"; - // }else if (d.audtiStatus == "4") { - // return "试验结束"; - // }else if (d.audtiStatus == "5") { - // return "待重新审阅"; - // } - // } + {field: "", title: "状态", unresize: true, align: "center", + templet: function (d) { + if (d.audtiStatus == "待试验") { + var html = " 待试验"; + return html; + } else if (d.audtiStatus == "待提交") { + var html = " 待提交"; + return html; + } else if (d.audtiStatus == "待审阅") { + var html = " 待审阅"; + return html; + }else if (d.audtiStatus == "审阅不通过") { + var html = " 审阅不通过"; + return html; + }else if (d.audtiStatus == "待审核") { + var html = " 待审核"; + return html; + }else if (d.audtiStatus == "审核不通过") { + var html = " 审核不通过"; + return html; + }else if (d.audtiStatus == "待审批") { + var html = " 待审批"; + return html; + }else if (d.audtiStatus == "审批不通过") { + var html = " 审批不通过"; + return html; + }else if (d.audtiStatus == "试验结束") { + var html = " 试验结束"; + return html; + }else if (d.audtiStatus == "试验完成") { + var html = " 试验完成"; + return html; + } + } }, - {field: "remarks", title: "备注", unresize: true, align: "center", + /*{field: "remarks", title: "备注", unresize: true, align: "center", templet: function (d) { if (d.remarks) { return d.remarks; @@ -104,7 +124,7 @@ function initTable(dataList, limit, page) { return ""; } } - }, + },*/ {title: "操作", unresize: true, width: 300, align: "center", templet: function (d) { return '试验'; @@ -114,49 +134,79 @@ function initTable(dataList, limit, page) { ], done: function (res, curr, count) { layer.close(loadingMsg); - table.resize("table_data"); count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block"); count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto"); - // 每次分页完成后,根据selectedIds选中复选框 - /*$.each(res.data, function(i, item){ - if($.inArray(item.id, selectedIds) !== -1){ - table.checkRow(item); + temp_table_list = res.data; + temp_table_list.forEach(function (o, i) { + for (let j = 0; j < temp_all_list.length; j++) { + if (temp_all_list[j].id === o.id) { + // 这里才是真正的有效勾选 + o["LAY_CHECKED"] = 'true'; + // 找到对应数据改变勾选样式,呈现出选中效果 + let index = o['LAY_INDEX']; + $('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true); + $('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked'); + } } - });*/ + }) + // 设置全选checkbox的选中状态,只有改变LAY_CHECKED的值, table.checkStatus才能抓取到选中的状态 + let checkStatus = table.checkStatus('table_data'); + if (checkStatus.isAll) {// 是否全选 + // layTableAllChoose + $('.layui-table th[data-field="0"] input[type="checkbox"]').prop('checked', true);//data-field值默认为0,如果在分页部分自定义了属性名,则需要改成对应的属性名 + $('.layui-table th[data-field="0"] input[type="checkbox"]').next().addClass('layui-form-checked');//data-field值默认为0,如果在分页部分自定义了属性名,则需要改成对应的属性名 + } }, }); // 监听单个复选框的选中和取消事件 table.on('checkbox(table_data)', function (obj) { - if (obj.checked) { - selectedIds.push(obj.data.id); - } else { - var index = selectedIds.indexOf(obj.data.id); - if (index > -1) { - selectedIds.splice(index, 1); + if (obj.checked == true) { + if (obj.type == 'one') { + let index = checkAllList(temp_all_list, obj.data); + if (index == -1) { + temp_all_list.push(obj.data); + } + } else { + temp_table_list.forEach(function (o, i) { + let index = checkAllList(temp_all_list, o); + if (index == -1) { + temp_all_list.push(o); + } + }) } - } - }); - // 获取头部复选框元素 - var headerCheckbox = $('input[name="layTableCheckbox"]'); - - // 监听头部复选框的change事件 - headerCheckbox.on('change', function() { - if ($(this).is(':checked')) { - // 全选操作 - table.checkAll('table_data'); - selectedIds = table.cache.table_data.map(function(item) { - return item.id; - }); } else { - // 全不选操作 - table.uncheckAll('table_data'); - selectedIds = []; + let all_list = []; // 使用临时数组,防止删除临时选中所有的数组错乱 + if (obj.type == 'one') { + temp_all_list.forEach(function (o, i) { + if (o.id != obj.data.id) { + all_list.push(o); + } + }) + } else { + temp_all_list.forEach(function (o, i) { + let index = checkAllList(temp_table_list, o); + if (index == -1) { + all_list.push(o); + } + }) + } + temp_all_list = all_list; } }); } - +/** + * 判断数组重复 + */ +function checkAllList(list, obj) { + for (let j = 0; j < list.length; j++) { + if (list[j].id == obj.id) { + return j; + } + } + return -1; +} // 获取参数 function getReqParams(page, limit, type) { let obj = {}; @@ -172,7 +222,7 @@ function getReqParams(page, limit, type) { } else { obj = { page: '1', - limit: '10', + limit: '2', devTypeCode: '', keyWord: '', sampleUserName: '', @@ -238,24 +288,35 @@ function setSelectValue(list, selectName) { } function commitCheckTestData(){ - console.log(selectedIds); - let url = dataUrl + '/experimental/commitCheckTestData'; - let obj = { - 'ids':selectedIds - } - let params = { - encryptedData: encryptCBC(JSON.stringify(obj)) - } + var selectedIds = []; + $.each(temp_all_list, function (index, item) { + selectedIds.push(item.id) + }) - ajaxRequest(url, "POST", params, true, function () { - }, function (result) { - if (result.code === 200) { - console.log("数据",result.data) - // return result.data - } else { - layer.alert(result.msg, {icon: 2}) + let index = layer.confirm('批量审查确认前,请仔细检查数据?', { + title: '操作提示', + icon: 7, + move: false + }, function () { + layer.close(index); + let url = dataUrl + '/experimental/commitCheckTestData'; + let obj = { + 'ids':selectedIds } - }, function (xhr) { - error(xhr) - }); + let params = { + encryptedData: encryptCBC(JSON.stringify(obj)) + } + + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + if (result.code === 200) { + console.log("数据",result.data) + // return result.data + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); + }) } \ No newline at end of file diff --git a/src/main/resources/static/pages/basic/standard/child/testCheck.html b/src/main/resources/static/pages/basic/standard/child/testCheck.html index 911752b..a5f6705 100644 --- a/src/main/resources/static/pages/basic/standard/child/testCheck.html +++ b/src/main/resources/static/pages/basic/standard/child/testCheck.html @@ -32,10 +32,17 @@ letter-spacing: 1px; } + .layui-form-item .layui-input-inline{ + width: 340px; + } + .center-aligned { text-align: center !important; } + .table-cell-wide { + width: 340px !important; + } @@ -44,52 +51,78 @@ -
- -
- + +
+

基础数据

+
+ +
+
+ +
+ + + +
+
+ +
+ +
+ +
-
- -
- +
+

试验数据

+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
-
- -
- +
+
+ +
+ +
+
+ +
+ +
+ +
-
- -
- +
+
+ +
+
-
-
- -
- -
-
+
+ +
-
- -
- -
-
- -
- -
+
@@ -105,63 +138,81 @@
--> -
- -
+
+
+ +
+ +
+
+
+ +
+ +
-
- -
- +
+
+ +
+ +
+
+
+ +
+ +
-
- -
- +
+
+ +
+ +
+
+ +
+ +
+ +
-
- -
- -
-
- -
- - - - +
+ + +
-
- +
+
- - - - - - + + + + + + - - - + + + @@ -171,27 +222,6 @@
编号客户自编号样品信息外观状态金额备注编号客户自编号样品信息外观状态金额备注
生产厂家生产日期规格型号生产厂家生产日期规格型号
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- diff --git a/src/main/resources/static/pages/basic/standard/child/testForm.html b/src/main/resources/static/pages/basic/standard/child/testForm.html index 01b120a..c76c3e2 100644 --- a/src/main/resources/static/pages/basic/standard/child/testForm.html +++ b/src/main/resources/static/pages/basic/standard/child/testForm.html @@ -32,10 +32,17 @@ letter-spacing: 1px; } + .layui-form-item .layui-input-inline{ + width: 340px; + } + .center-aligned { text-align: center !important; } + .table-cell-wide { + width: 340px !important; + } @@ -44,52 +51,78 @@ -
- -
- + +
+

基础数据

+
+ +
+
+ +
+ + + +
+
+ +
+ +
+ +
-
- -
- +
+

试验数据

+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
-
- -
- +
+
+ +
+ +
+
+ +
+ +
+ +
-
- -
- +
+
+ +
+
-
-
- -
- -
-
+
+ +
-
- -
- -
-
- -
- -
+
@@ -105,35 +138,53 @@
--> -
- -
+
+
+ +
+ +
+
+
+ +
+ +
-
- -
- +
+
+ +
+ +
+
+
+ +
+ +
-
- -
- +
+
+ +
+ +
+
+ +
+ +
+ +
-
- -
- -
-
- -
@@ -146,22 +197,22 @@
-
- +
+
- - - - - - + + + + + + - - - + + + @@ -171,27 +222,6 @@
编号客户自编号样品信息外观状态金额备注编号客户自编号样品信息外观状态金额备注
生产厂家生产日期规格型号生产厂家生产日期规格型号
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- diff --git a/src/main/resources/static/pages/basic/standard/testManagementList.html b/src/main/resources/static/pages/basic/standard/testManagementList.html index e336f34..460a1e5 100644 --- a/src/main/resources/static/pages/basic/standard/testManagementList.html +++ b/src/main/resources/static/pages/basic/standard/testManagementList.html @@ -2,10 +2,12 @@ - + + - + +