From 04a7e586466a9c00f20d5e4fb1caca71048ac73f Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Wed, 24 Jul 2024 14:26:13 +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/testManagementList.js | 60 +++++++++++++++++++ .../js/basis/tools/child/addTestStandards.js | 7 ++- .../js/basis/tools/testStandardsList.js | 4 +- .../basic/standard/testManagementList.html | 7 +-- .../basic/tools/child/addTestStandards.html | 24 ++++---- .../basic/tools/child/checkTestStandards.html | 15 +++-- 6 files changed, 92 insertions(+), 25 deletions(-) diff --git a/src/main/resources/static/js/basis/standard/testManagementList.js b/src/main/resources/static/js/basis/standard/testManagementList.js index 40e03f4..35600ca 100644 --- a/src/main/resources/static/js/basis/standard/testManagementList.js +++ b/src/main/resources/static/js/basis/standard/testManagementList.js @@ -1,5 +1,6 @@ let form, layer, table, tableIns; let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 +let selectedIds = []; // 存储选中项的ID layui.use(['form', 'layer', 'table', 'laydate'], function () { form = layui.form; layer = layui.layer; @@ -63,6 +64,7 @@ function initTable(dataList, limit, page) { limit: limit, cols: [ [ + {type: 'checkbox', fixed: 'left'}, //表头 {title: "序号", width: 80, unresize: true, align: "center", templet: function (d) { @@ -115,8 +117,43 @@ function initTable(dataList, limit, page) { 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); + } + });*/ }, }); + + // 监听单个复选框的选中和取消事件 + 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); + } + } + }); + // 获取头部复选框元素 + 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 = []; + } + }); } @@ -198,4 +235,27 @@ function setSelectValue(list, selectName) { }) $('#' + selectName).empty().append(html); layui.form.render(); +} + +function commitCheckTestData(){ + console.log(selectedIds); + let url = dataUrl + '/experimental/commitCheckTestData'; + let obj = { + 'ids':selectedIds + } + 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/js/basis/tools/child/addTestStandards.js b/src/main/resources/static/js/basis/tools/child/addTestStandards.js index b0f1ada..2f7f902 100644 --- a/src/main/resources/static/js/basis/tools/child/addTestStandards.js +++ b/src/main/resources/static/js/basis/tools/child/addTestStandards.js @@ -137,13 +137,13 @@ function titleAdd() { newDiv.style.border='1px solid #ccc'; newDiv.innerHTML = `
- - + +
- +
`; // 将新div插入到现有'dev'元素之后 @@ -193,6 +193,7 @@ function itemNameAdd(num) { newInput.placeholder = '请输入名称'; newInput.id = 'itemName-'+num+'-' + (maxId + 1); newInput.name = 'itemName-'+num+'-' + (maxId + 1); + newInput.maxLength='30'; // 将新的 input 元素追加到 div 中 divElement.appendChild(newInput); diff --git a/src/main/resources/static/js/basis/tools/testStandardsList.js b/src/main/resources/static/js/basis/tools/testStandardsList.js index 2a8b2ba..2873aa7 100644 --- a/src/main/resources/static/js/basis/tools/testStandardsList.js +++ b/src/main/resources/static/js/basis/tools/testStandardsList.js @@ -130,7 +130,7 @@ function addData(id) { let param = { 'id': id } - openIframeMax("addOrEditTestStandards", title, "child/addTestStandards.html", '1000px', '625px', param); + openIframeMax("addOrEditTestStandards", title, "child/addTestStandards.html", '80%', '80%', param); } // 查看试验标准 @@ -138,7 +138,7 @@ function checkData(id) { let param = { 'id': id } - openIframeMax("addOrEditTestStandards", "查看试验标准", "child/checkTestStandards.html", '1000px', '625px', param); + openIframeMax("addOrEditTestStandards", "查看试验标准", "child/checkTestStandards.html", '80%', '80%', param); } /*删除用户*/ diff --git a/src/main/resources/static/pages/basic/standard/testManagementList.html b/src/main/resources/static/pages/basic/standard/testManagementList.html index b2fa6f9..e336f34 100644 --- a/src/main/resources/static/pages/basic/standard/testManagementList.html +++ b/src/main/resources/static/pages/basic/standard/testManagementList.html @@ -44,10 +44,9 @@ diff --git a/src/main/resources/static/pages/basic/tools/child/addTestStandards.html b/src/main/resources/static/pages/basic/tools/child/addTestStandards.html index c9a1e32..20381d0 100644 --- a/src/main/resources/static/pages/basic/tools/child/addTestStandards.html +++ b/src/main/resources/static/pages/basic/tools/child/addTestStandards.html @@ -61,7 +61,7 @@
- +
@@ -106,7 +106,7 @@
- +
@@ -116,14 +116,14 @@
- +
- +
@@ -141,19 +141,23 @@ -
-
+
+

主设备

+
+ +
+
-
+
-
+
-
- +
+
diff --git a/src/main/resources/static/pages/basic/tools/child/checkTestStandards.html b/src/main/resources/static/pages/basic/tools/child/checkTestStandards.html index b3618ee..c7cd452 100644 --- a/src/main/resources/static/pages/basic/tools/child/checkTestStandards.html +++ b/src/main/resources/static/pages/basic/tools/child/checkTestStandards.html @@ -141,19 +141,22 @@
-
-
+
+

试验项

+
+
+
-
+
-
+
-
- +
+