RuoYi 两个table公用一个 form 表格增加合计行

在这里插入图片描述

<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('行车炉次加料记录列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>车间:</label>
                            <select name="factoryCode" th:with="type=${@dict.getType('sys_workshop_name')}">
                                <option th:selected="${session.deptId} == ${dict.dictValue}" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
 
                        <li style="height: 25px;">
                            <div class="form-group form-inline">
                                <label class="font-noraml">日期:</label>
                                <div class="input-group date form-inline">
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                    <input type="text" class="form-control" th:value="${rq}" id="laydate-demo-3" name="rq" placeholder="请选择日期">
                                </div>
                            </div>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="ff()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
 
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="batchExport()" shiro:hasPermission="mes:record:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <h3 style="text-align: center">行车炉次加料记录</h3>
            <table id="bootstrap-table1"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('mes:record:edit')}]];
    var removeFlag = [[${@permission.hasPermi('mes:record:remove')}]];
    var prefix = ctx + "mes/DrivingRecord";
  
    function ff(){
        $.table.search('formId', 'bootstrap-table');
        $.table.search('formId', 'bootstrap-table1')
    }
    function fffff(lh,rq){
        $.modal.open("添加其他价格",ctx + 'mes/jlqt/add?lh='+lh+'&rq=' + rq);
    }
 
    $(function() {
        var options = {
            url: prefix + "/listTJ",
            exportUrl: prefix + "/export",
            modalName: "行车炉次加料记录",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            showFooter: true,
            headerStyle: headerStyle,
            footerStyle: footerStyle,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '业务主键ID',
                    visible: false
                },
                {
                    field: 'lh',
                    title: '炉号',
                    align: 'center'  ,
                    footerFormatter:function () {
                        return "合计";
                    }
                },
                {
                    field: 'rq',
                    title: '日期',
                    align: 'center'
                },
                {
                    field: 'fg',
                    title: '废钢()',
                    align: 'center' ,
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].fg);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'hll',
                    title: '回炉料()',
                    align: 'center' ,
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].hll);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'glts',
                    title: '高炉铁水()',
                    align: 'center' ,
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].glts);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'qt',
                    title: '其他()',
                    align: 'center' ,
                    formatter:function(value, row, index){
                        var lh ="'"+ row.lh + "'";
                        var rq ="'"+ row.rq + "'";
                        if(!value){
                            return '<a onclick="fffff('+ lh + ',' + rq +')" style="color: red">未录入,请录入其他材料</a>';
                        }else{
                            return value;
                        }
                    },
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].qt);
                        }
                        return count;
                    }
                },
                ]
        };
 
 
        $.table.init(options);
        // $.table.search(options1);
        var options1 = {
            id: "bootstrap-table1",
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "行车炉次加料记录",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            showFooter: true,
            headerStyle: headerStyle,
            footerStyle: footerStyle,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '业务主键ID',
                    visible: false
                },
                {
                    field: 'heatNumber',
                    title: '炉号',
                    align: 'center',
                    footerFormatter:function () {
                        return "合计";
                    }
                },
                {
                    field: 'meltNumber',
                    title: '炉次号',
                    align: 'center'
                },
                {
                    field: 'createTime',
                    title: '加料记录时间',
                    align: 'center'
                },
                {
                    field: 'materialsOneWeight',
                    title: '回炉料重量(kg)',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].materialsOneWeight);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'materialsOnePlanWeight',
                    title: '回炉料计划量(kg)',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].materialsOnePlanWeight);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'materialsTwoWeight',
                    title: '废钢重量(kg)',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].materialsTwoWeight);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'materialsTwoPlanWeight',
                    title: '废钢计划量(kg)',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].materialsTwoPlanWeight);
                        }
                        return Math.round(count*100)/100;
                    }
 
                },
                {
                    field: 'materialsThreeWeight',
                    title: '高炉铁水重量(kg)',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].materialsThreeWeight);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'materialsThreePlanWeight',
                    title: '高炉铁水计划量(kg)',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].materialsThreePlanWeight);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'lctszjrWeight',
                    title: '炉次累计固体加料重量(kg)',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].lctszjrWeight);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                // {
                //     field: 'gltszjrWeight',
                //     title: '高炉铁水总加入重量(kg)',
                //     align: 'center',
                //     footerFormatter:function (value, row, index) {
                //         var count = 0;
                //         for (var i in value) {
                //             count += Number(value[i].gltszjrWeight);
                //         }
                //         return count;
                //     }
                // },
                {
                    field: 'lczjrWeight',
                    title: '炉次总加入量',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].lczjrWeight);
                        }
                        return Math.round(count*100)/100;
                    }
                },
                {
                    field: 'gtljllCost',
                    title: '固体料加料量费用()',
                    align: 'center',
                    footerFormatter:function (value, row, index) {
                        var count = 0;
                        for (var i in value) {
                            count += Number(value[i].gtljllCost);
                        }
                        return Math.round(count*100)/100;
                    }
                },
            ]
        };
        $.table.init(options1);
 
    });
    function headerStyle(column) {
        return {
            createTime: {
                css: { color: 'red' }
            }
        } [column.field]
    }
    function footerStyle(column) {
        return {
            qt: {
                css: {color: 'orange', 'font-weight': 'normal'}
            },
            fg: {
                css: {color: 'orange', 'font-weight': 'normal'}
            },
            hll: {
                css: {color: 'orange', 'font-weight': 'normal'}
            },
            lh: {
                css: {color: 'orange', 'font-weight': 'normal'}
            }
        }[column.field]
    }
 
</script>
 
</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ruoyi框架中,在表格的每一后面添加一个按钮并在点击按钮时弹出一个弹窗,您可以按照以下步骤进: 1. 在您的Controller中定义一个@RequestMapping注解的方法,该方法返回您想要显示的弹窗页面。 2. 在您的html页面中,使用th:attr指令为每个按钮添加一个data-url属性,该属性的值为您在第1步中定义的方法的URL路径,并使用th:each指令遍历每一数据。 3. 在您的html页面中,使用jQuery或JavaScript等技术为每个按钮添加一个点击事件,该事件获取按钮的data-url属性并使用layer.open方法打开弹窗。 下面是一个简单的示例代码,仅供参考: 在Controller中定义方法: ``` @GetMapping("/showDialog") public String showDialog() { return "yourDialogPageName"; } ``` 在html页面中添加表格和按钮: ``` <table> <thead> <tr> <th>列1</th> <th>列2</th> <th>操作</th> </tr> </thead> <tbody> <tr th:each="item : ${list}"> <td th:text="${item.col1}"></td> <td th:text="${item.col2}"></td> <td> <button th:attr="data-url=@{/showDialog}" class="btn-dialog">弹窗</button> </td> </tr> </tbody> </table> ``` 在html页面中添加JavaScript代码: ``` <script> $(function() { $('.btn-dialog').click(function() { var url = $(this).data('url'); layer.open({ type: 2, title: '弹窗标题', area: ['800px', '600px'], content: url }); }); }); </script> ``` 请注意将“yourDialogPageName”替换为您要显示的弹窗页面的名称,以及根据实际情况修改弹窗的标题和大小。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值