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 = `