From 6aa7db36cd059a43fced1a3cb8780f1cace2b936 Mon Sep 17 00:00:00 2001 From: zyx <zyx123456> Date: 星期一, 19 二月 2024 16:59:53 +0800 Subject: [PATCH] 增加 选中条数的合计功能以及筛选列记忆功能 --- src/main/webapp/static/js/pla/plaDetl.js | 65 ++++++++++++++++++++++++++++++-- 1 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/static/js/pla/plaDetl.js b/src/main/webapp/static/js/pla/plaDetl.js index a706e00..4a4f7aa 100644 --- a/src/main/webapp/static/js/pla/plaDetl.js +++ b/src/main/webapp/static/js/pla/plaDetl.js @@ -12,7 +12,7 @@ function getCol() { var cols = [ {field: 'id', title: 'id', align: 'center',hide:true} - ,{type: 'checkbox'} + ,{type: 'checkbox',totalRow:true} ,{field:'id', width:80, title: '', sort: true, totalRowText: '鍚堣锛�',hide: true} ,{field: 'pakinTime$', title: '鍏ュ簱鏃堕棿', align: 'center' , sort:true} ,{field: 'matnr', align: 'center',title: '瀛樿揣缂栫爜',hide:true,edit:true} @@ -20,7 +20,7 @@ ,{field: 'batch', align: 'center',title: '鎵瑰彿',edit:true, width: 150, sort:true} ,{field: 'packageNo', align: 'center',title: '鍖呰鍙�',edit:true, sort:true} ,{field: 'proDate', align: 'center',title: '鐢熶骇鏃ユ湡',edit:true, width: 100} - ,{field: 'weight', align: 'center',title: '閲嶉噺KG',edit:true} + ,{field: 'weight', align: 'center',title: '閲嶉噺KG',edit:true,totalRow:true} ,{field: 'packageType', align: 'center',title: '鍖呰绫诲瀷',edit:true} ,{field: 'zpalletType', align: 'center',title: '鎵樼洏绫诲瀷',edit:true} ,{field: 'filmWrap', align: 'center',title: '缂犺啘',edit:true,hide:true} @@ -124,7 +124,18 @@ even: true, toolbar: '#toolbar', cellMinWidth: 50, - cols: [getCol()], + cols: [function(){ + var arr = getCol(); + + // 鍒濆鍖栫瓫閫夌姸鎬� + var local = layui.data('table-filter-test'); // 鑾峰彇瀵瑰簲鐨勬湰鍦拌褰� + layui.each(arr, function(index, item){ + if(item.field in local){ + item.hide = local[item.field]; + } + }); + return arr; + }() ], request: { pageName: 'curr', pageSize: 'limit' @@ -142,6 +153,17 @@ statusCode: 200 }, done: function(res, curr, count) { + // 璁板綍绛涢�夌姸鎬� + var that = this; + that.elem.next().on('mousedown', 'input[lay-filter="LAY_TABLE_TOOL_COLS"]+', function(){ + var input = $(this).prev()[0]; + // 姝ゅ琛ㄥ悕鍙换鎰忓畾涔� + layui.data('table-filter-test', { + key: input.name + ,value: input.checked + }) + }); + //$(".lavui-table-grid-down").hide(); if (res.code === 403) { top.location.href = baseUrl+"/"; @@ -168,6 +190,33 @@ } }); } + }); + + // 澶嶉�夋浜嬩欢 + table.on('checkbox(plaDetl)', function(obj){ + // console.log(obj); // 鏌ョ湅瀵硅薄鎵�鏈夋垚鍛� + // console.log(obj.checked); // 褰撳墠鏄惁閫変腑鐘舵�� + // console.log(obj.data); // 閫変腑琛岀殑鐩稿叧鏁版嵁 + // console.log(obj.type); // 鑻ヨЕ鍙戠殑鏄叏閫夛紝鍒欎负锛歛ll锛涜嫢瑙﹀彂鐨勬槸鍗曢�夛紝鍒欎负锛歰ne + var checkStatus = table.checkStatus(obj.config.id) + var selectedNum = checkStatus.data.length; + var weightAll = 0; + var weightAnfmeAll = 0; + + for (var i in checkStatus.data){ + weightAll += checkStatus.data[i].weight; + weightAnfmeAll += checkStatus.data[i].weightAnfme; + } + + $('.layui-table-total').find('.laytable-cell-1-0-1').text(selectedNum); + $('.layui-table-total').find('.laytable-cell-1-0-9').text(weightAll); + $('.layui-table-total').find('.laytable-cell-1-0-41').text(weightAnfmeAll); + + }); + + // 琛屽崟鍑讳簨浠�( 鍙屽嚮浜嬩欢涓�: rowDouble ) + table.on('row(plaDetl)', function(obj){ + }); table.on('tool(plaDetl)', function (obj) { @@ -231,8 +280,8 @@ }); } }); - } + }) // 鐩戝惉澶村伐鍏锋爮浜嬩欢 @@ -516,6 +565,14 @@ }); } + $(document).on('click','#updateZpallet',function (){ + debugger; + }) + $("[name='layTableCheckbox']").click(function(){ // 閫氳繃name灞炴�ч�夊彇鍏冪礌锛屽苟娣诲姞鐐瑰嚮浜嬩欢 + alert("Hello World!"); // 鍦ㄦ帶鍒跺彴杈撳嚭鎻愮ず淇℃伅 + debugger + }); + $(document).on('click','#add', function () { -- Gitblit v1.9.1