绍兴网站推广优化,浙江建设信息港网站考试成绩查询,seo网站优化工具,建站服务器记录#xff1a;
TP5 动态渲染多个Layui表格每个表格设置有2行表头#xff0c;并且第一行表头在页面完成后动态渲染显示内容每个表格下面显示统计信息可点击字段排序一次打印页面上的所有表格打印页面上多个table时,让每个table单独一页
后端代码示例#xff1a; /*** Nod…记录
TP5 动态渲染多个Layui表格每个表格设置有2行表头并且第一行表头在页面完成后动态渲染显示内容每个表格下面显示统计信息可点击字段排序一次打印页面上的所有表格打印页面上多个table时,让每个table单独一页
后端代码示例 /*** NodeAnotation(title批量打印)*/public function mergePrint($id){ $rlist $this-model-where([[id,in,$id]])-select();$tablesData [];foreach($rlist as $k$row){ //拣货商品明细$goodsList $row-boutboundPickGoods; // 排序首先拣货位正序、其次商品ID正序、最后批次倒序 array_multisort(array_column($goodsList, jianhuo_location), SORT_ASC, array_column($goodsList, id), SORT_ASC, array_column($goodsList, pici), SORT_DESC, $goodsList);$row[goodsList] $goodsList;$row[create_time_text] date(Y-m-d,$row[create_time]);$tablesData[] $row-toArray();}$this-assign(tablesData, $tablesData);return $this-fetch();}html代码示例
stylefieldset {padding: 0;border: none;border-top: 1px dashed #eee;}fieldset legend {margin-left: 30px;padding: 0 10px;font-size: 16px;font-weight: 500;}
/style
div classlayuimini-containerform idapp-form classlayui-form layuimini-formfieldsetlegenda nameother拣货商品详情/abutton typebutton classlayui-btn layui-btn-normal layui-btn-sm print_apple lay-eventaddi classfa fa-print/i 批量打印/button/legend/fieldset!-- 要拣货的商品 --div classprintContentdiv classtablestylestyle .layui-table td, .layui-table th{font-size: 12px;color: #000;padding: 5px;}.printMain{font-size: 12px;color: #000;}.title{background-color: #fff;text-align: left;}/* layui 打印页面上多个table时,让每个table单独一页 */media print {.layui-card {page-break-after: always;}.layui-card:last-child {page-break-after: auto;}table{width: 100%; border-collapse: collapse; border-spacing: 0;}}/style/divdiv classprintMain{volist nametablesData keyindex idrow}div classlayui-cardtable classlayui-table layui-table-main idtable-{$row[id]} stylemargin: 0;/tablediv styleline-height:40px;总合计 出库单数量{:floatval($row.yck_number)} nbsp;nbsp;nbsp;品种数{:floatval($row.pre_goods_number)} nbsp;nbsp;nbsp;总重量(kg){:floatval($row.pre_goods_weight_number)} nbsp;nbsp;nbsp;总体积(m3){:floatval($row.pre_goods_volumn_number)} nbsp;nbsp;nbsp;总数量{:floatval($row.pre_goods_account)} nbsp;nbsp;nbsp;总件数{:floatval($row.pre_goods_jian_number)}/divdiv styleheight: 30px;div stylefloat: left;margin-right:120px制单人/divdiv stylefloat: left;margin-right:120px拣货人/div/div/div{/volist}/div/div/form
/divscript src__STATIC__/jquery.min.js?v{$version} charsetutf-8/scriptscript//JavaScript代码区域layui.use([element, table, form], function () {var element layui.element,table layui.table, form layui.form,laydate layui.laydate;var tablesData {:json_encode($tablesData)};// 循环渲染每个表格tablesData.forEach(function(tableInfo) {// 初始化表格table.render({elem: #table- tableInfo.id,toolbar: #toolbar,defaultToolbar: [filter], //开启右边按钮cols: [// 第一行表头[{field: fdsf, title: 标题tableInfo.id, colspan:14},],// 第二行表头[{field: id, width: 90, title: 商品ID, sort: true},{field: xuhao, width: 80, title: 序号, sort: true},{field: title_en, minWidth: 120, title: 英文简称, sort: true},{field: title, minWidth: 120, title: 商品名称, sort: true},{field: tuo_guige, minWidth: 100, title: 码托件数, sort: true},{field: ji_guige, minWidth: 110, title: 件计量规格, sort: true},{field: ware_location, minWidth: 100, title: 库位, sort: true},{field: is_jianhuo_location, minWidth: 110, title: 是否拣货位, sort: true,templet: function (d) {if(d.is_jianhuo_location 1){return span stylecolor:#1e9fff;是/span;}else{return span 否/span;}}},{field: is_zhengban, minWidth: 100, title: 整板, sort: true,templet: function (d) {if(d.is_zhengban 1){return span stylecolor:#1e9fff;是/span;}else{return span 否/span;}}},{field: pici, minWidth: 100, title: 批次号, sort: true},{field: actual_number, minWidth: 100, title: 数量, sort: true},{field: jian_number, minWidth: 100, title: 件数, sort: true},{field: jianhuo_location, minWidth: 100, title: 拣货位, sort: true},{field: jianhuo_area, minWidth: 110, title: 拣货位库区, sort: true},]],data:tableInfo.goodsList,page: false, // 如果需要分页 limit: Number.MAX_VALUE,done: function (res, curr, count) {// 组合第一行表头显示的内容var htmltext 拣货单号 tableInfo.jh_order nbsp;nbsp;nbsp; 拣货单日期 tableInfo.create_time_text nbsp;nbsp;nbsp; 收货单位(人) tableInfo.delivery_people nbsp;nbsp;nbsp; 送货地址 tableInfo.provice nbsp;nbsp;nbsp; tableInfo.city nbsp;nbsp;nbsp; tableInfo.area nbsp;nbsp;nbsp; tableInfo.delivery_address;// 赋值第一行表头显示的内容$([lay-id\table- tableInfo.id \] .layui-table-box .layui-table-header tr:first-child).find(th).html(htmltext);// 更换第一行表头样式$([lay-id\table- tableInfo.id \] .layui-table-box .layui-table-header tr:first-child).css({background-color:#fff,});$([lay-id\table- tableInfo.id \] .layui-table-box .layui-table-header tr:first-child).find(th).css({text-align:left,});// 设置tool的层级不被下面的table遮盖注意上面的table的层级要高于下面table的层级$([lay-id\table- tableInfo.id \] .layui-table-tool).css({position:relative,z-index:9999-tableInfo.id,width:100%,min-height:50px,line-height:30px,padding:10px 15px,border-width:0,border-bottom-width:1px,});},});})// 打印页面上所有表格table$(.print_apple).click(function(){// 定义一个DIV存放打印的内容let v document.createElement(div);// 为DIV定义一个class名字v.className printMain;// 向DIV中增加样式内容打印页面上多个table时,让每个table单独一页$(v).append($(.tablestyle).html());// 循环每个表格tablesData.forEach(function(tableInfo) {// 组合一个表格要打印的内容var tablelayid table- tableInfo.id;var card document.createElement(div);card.className layui-card;$(card).append($([lay-id\ tablelayid \] .layui-table-box).find(.layui-table-header).html());$(card).find(thead).after($([lay-id\ tablelayid \] .layui-table-body.layui-table-main table).html()); $(card).find(th.layui-table-patch).remove();$(card).find(.layui-table-col-special).remove();$(card).append($([lay-id\ tablelayid \]).next().html()$([lay-id\ tablelayid \]).next().next().html());// 向打印DIV中增加打印表格内容$(v).append(card);}); // 页眉let f [head,style, body{font-size: 12px; color: #000;}, table{width: 100%; border-collapse: collapse; border-spacing: 0;},th,td{line-height: 18px; padding: 5px 5px; border: 1px solid #ccc; text-align: center;},a{color: #666; text-decoration:none;}, *.layui-hide{display: none},/style, /head].join();//页脚展示let footer [footer/footer ].join();// 打印let h window.open(打印窗口, _blank);h.document.write(f $(v).prop(outerHTML) footer);h.document.close();h.print();h.close();});})
/script页面效果图示 文章转载自: http://www.morning.fqyqm.cn.gov.cn.fqyqm.cn http://www.morning.flxgx.cn.gov.cn.flxgx.cn http://www.morning.bhjyh.cn.gov.cn.bhjyh.cn http://www.morning.dzdtj.cn.gov.cn.dzdtj.cn http://www.morning.youprogrammer.cn.gov.cn.youprogrammer.cn http://www.morning.lpcpb.cn.gov.cn.lpcpb.cn http://www.morning.frpm.cn.gov.cn.frpm.cn http://www.morning.rlqqy.cn.gov.cn.rlqqy.cn http://www.morning.zyffq.cn.gov.cn.zyffq.cn http://www.morning.jiuyungps.com.gov.cn.jiuyungps.com http://www.morning.glnxd.cn.gov.cn.glnxd.cn http://www.morning.hnk25076he.cn.gov.cn.hnk25076he.cn http://www.morning.dyfmh.cn.gov.cn.dyfmh.cn http://www.morning.fbqr.cn.gov.cn.fbqr.cn http://www.morning.wtdhm.cn.gov.cn.wtdhm.cn http://www.morning.npkrm.cn.gov.cn.npkrm.cn http://www.morning.xcfmh.cn.gov.cn.xcfmh.cn http://www.morning.bbyqz.cn.gov.cn.bbyqz.cn http://www.morning.lrgfd.cn.gov.cn.lrgfd.cn http://www.morning.lhztj.cn.gov.cn.lhztj.cn http://www.morning.lwnwl.cn.gov.cn.lwnwl.cn http://www.morning.lptjt.cn.gov.cn.lptjt.cn http://www.morning.kntbk.cn.gov.cn.kntbk.cn http://www.morning.qljxm.cn.gov.cn.qljxm.cn http://www.morning.ttdbr.cn.gov.cn.ttdbr.cn http://www.morning.qxlgt.cn.gov.cn.qxlgt.cn http://www.morning.nkjxn.cn.gov.cn.nkjxn.cn http://www.morning.svrud.cn.gov.cn.svrud.cn http://www.morning.cjqqj.cn.gov.cn.cjqqj.cn http://www.morning.xdlwm.cn.gov.cn.xdlwm.cn http://www.morning.cbvlus.cn.gov.cn.cbvlus.cn http://www.morning.thbkc.cn.gov.cn.thbkc.cn http://www.morning.psqs.cn.gov.cn.psqs.cn http://www.morning.yqmmh.cn.gov.cn.yqmmh.cn http://www.morning.bryyb.cn.gov.cn.bryyb.cn http://www.morning.ymtbr.cn.gov.cn.ymtbr.cn http://www.morning.zdydj.cn.gov.cn.zdydj.cn http://www.morning.twgzq.cn.gov.cn.twgzq.cn http://www.morning.hjjhjhj.com.gov.cn.hjjhjhj.com http://www.morning.pfjbn.cn.gov.cn.pfjbn.cn http://www.morning.wzwpz.cn.gov.cn.wzwpz.cn http://www.morning.yzxhk.cn.gov.cn.yzxhk.cn http://www.morning.qzsmz.cn.gov.cn.qzsmz.cn http://www.morning.lpsjs.com.gov.cn.lpsjs.com http://www.morning.rcmwl.cn.gov.cn.rcmwl.cn http://www.morning.fwrr.cn.gov.cn.fwrr.cn http://www.morning.dmzqd.cn.gov.cn.dmzqd.cn http://www.morning.hsrpr.cn.gov.cn.hsrpr.cn http://www.morning.hsksm.cn.gov.cn.hsksm.cn http://www.morning.jpfpc.cn.gov.cn.jpfpc.cn http://www.morning.ntgsg.cn.gov.cn.ntgsg.cn http://www.morning.wlddq.cn.gov.cn.wlddq.cn http://www.morning.mnbcj.cn.gov.cn.mnbcj.cn http://www.morning.tfrlj.cn.gov.cn.tfrlj.cn http://www.morning.wjwfj.cn.gov.cn.wjwfj.cn http://www.morning.qwmsq.cn.gov.cn.qwmsq.cn http://www.morning.etsaf.com.gov.cn.etsaf.com http://www.morning.hongjp.com.gov.cn.hongjp.com http://www.morning.rwjtf.cn.gov.cn.rwjtf.cn http://www.morning.ggfdq.cn.gov.cn.ggfdq.cn http://www.morning.skbbt.cn.gov.cn.skbbt.cn http://www.morning.ylljn.cn.gov.cn.ylljn.cn http://www.morning.lqjlg.cn.gov.cn.lqjlg.cn http://www.morning.brlcj.cn.gov.cn.brlcj.cn http://www.morning.thbkc.cn.gov.cn.thbkc.cn http://www.morning.hlshn.cn.gov.cn.hlshn.cn http://www.morning.yzygj.cn.gov.cn.yzygj.cn http://www.morning.dfojgo.cn.gov.cn.dfojgo.cn http://www.morning.gftnx.cn.gov.cn.gftnx.cn http://www.morning.wdlg.cn.gov.cn.wdlg.cn http://www.morning.lxcwh.cn.gov.cn.lxcwh.cn http://www.morning.wwnb.cn.gov.cn.wwnb.cn http://www.morning.cbvlus.cn.gov.cn.cbvlus.cn http://www.morning.ylqpp.cn.gov.cn.ylqpp.cn http://www.morning.kfysh.com.gov.cn.kfysh.com http://www.morning.zphlb.cn.gov.cn.zphlb.cn http://www.morning.yfnhg.cn.gov.cn.yfnhg.cn http://www.morning.lwmxk.cn.gov.cn.lwmxk.cn http://www.morning.xqgtd.cn.gov.cn.xqgtd.cn http://www.morning.fyglr.cn.gov.cn.fyglr.cn