NutzCN Logo
问答 idea代码生成器 字段多的话排序错乱
发布于 293天前 作者 qq_fca05dd3 450 次浏览 复制 上一个帖子 下一个帖子
标签:

<%
layout("/layouts/private.html"){
%>



新建 busOrder
删除选中








商品主图
营销单号
商品名称
商品Id
商品链接
优惠券链接
渠道
业务员
订单状态
订单状态
订单状态
订单状态
订单状态
订单状态
操作










×
删除busOrder




busOrder删除后无法恢复。
确定删除吗?




取 消
确 定











var datatable;
function initDatatable() {
datatable = $('.datatable').DataTable({
"dom": '<"toolbar">frtip',
"searching":false,
"processing": false,
"serverSide": true,
"select": true,
"ordering": true,
"language": {
"url": "${base}/assets/plugins/datatables/cn.json"
},
"preDrawCallback": function () {
sublime.showLoadingbar($(".main-content"));
},
"drawCallback": function () {
sublime.closeLoadingbar($(".main-content"));
},
"ajax": {
"url": "${base}/private/business/bus_orders/data",
"type": "post",
"data": function (d) {
d.unitid = $('#unitid').val();
}
},
// "order": [[0, "desc"]],
"columns": [
{"data": "goodsPicMain", "bSortable": true},
{"data": "marketingNum", "bSortable": true},
{"data": "goodsName", "bSortable": true},
{"data": "goodsId", "bSortable": true},
{"data": "goodsUrl", "bSortable": true},
{"data": "couponUrl", "bSortable": true},
{"data": "channel", "bSortable": true},
{"data": "salesman", "bSortable": true},
{"data": "busOrderStatus", "bSortable": true},
{"data": "busOrderStatus_1", "bSortable": true},
{"data": "busOrderStatus_2", "bSortable": true},
{"data": "busOrderStatus_3", "bSortable": true},
{"data": "busOrderStatus_4", "bSortable": true},
{"data": "busOrderStatus_5", "bSortable": true},
],
"columnDefs": [
{
"render": function (data, type, row) {
return '' +
' ' +
'查看信息' +
'修改信息' +
'' +
'删除' +
'';
},
"targets": 14
}
]
});
datatable.on('click', 'tr', function () {
$(this).toggleClass('selected');
});
$("#searchBtn").on('click', function () {
datatable.ajax.reload();
});
}
function del(id) {
var dialog = $("#dialogDelete");
dialog.modal("show");
dialog.find("#okDel").unbind("click");
dialog.find("#okDel").bind("click", function (event) {
var btn = $(this);
btn.button("loading");
$.post("${base}/private/business/bus_orders/delete/" + id, {}, function (data) {
if (data.code == 0) {
datatable.ajax.reload(null,false);
} else {
Toast.error(data.msg);
}
//重置按钮状态,关闭提示框
btn.button("reset");
dialog.modal("hide");
}, "json");
});
}
function delCheck() {
var chks = datatable.rows('.selected').data();
if (chks.length > 0) {
var ids = [];
$.each(datatable.rows('.selected').data(), function (i, n) {
ids.push(n.id);
});
var dialog = $("#dialogDelete");
dialog.modal("show");
dialog.find("#okDel").unbind("click");
dialog.find("#okDel").bind("click", function (event) {
var btn = $(this);
btn.button("loading");
$.post("${base}/private/business/bus_orders/delete", {ids: ids.toString()}, function (data) {
if (data.code == 0) {
datatable.ajax.reload(null,false);
} else {
Toast.error(data.msg);
}
btn.button("reset");
dialog.modal("hide");
}, "json");
});
} else {
Toast.warning("请先选择要删除的busOrder!");
}
}
$(function () {
initDatatable();
});

<%}%>

29 回复

这就是直接贴代码的悲剧,编辑菜单里面有代码按钮啊,图片按钮的右边

来自炫酷的 NutzCN

<%
layout("/layouts/private.html"){
%>
<section class="content-wrap bg-white">
    <header class="header navbar bg-white shadow">
        <div class="btn-group tool-button">
            <a id="add" class="btn btn-primary navbar-btn" href="${base}/private/business/bus_orders/add" data-pjax><i class="ti-plus"></i> 新建 busOrder</a>
            <button class="btn btn-danger navbar-btn" onclick="delCheck()"><i class="ti-close"></i> 删除选中</button>
        </div>
    </header>
    <div class=panel-body style="padding-top: 50px;">
        <div class="table-responsive no-border">
            <input id="unitid" type="hidden">
            <table class="table table-bordered table-striped mg-t datatable">
                <thead>
                    <tr>
                            <th>商品主图</th>
                            <th>营销单号</th>
                            <th>商品名称</th>
                            <th>商品Id</th>
                            <th>商品链接</th>
                            <th>优惠券链接</th>
                            <th>渠道</th>
                            <th>业务员</th>
                            <th>订单状态</th>
                            <th>订单状态</th>
                            <th>订单状态</th>
                            <th>订单状态</th>
                            <th>订单状态</th>
                            <th>订单状态</th>
                            <th>操作</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</section>
<div id="dialogDelete" class="modal fade bs-modal-sm" tabindex="-2" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">删除busOrder</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-12">
                        busOrder删除后无法恢复。<br/>
                        <br/>确定删除吗?
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取  消</button>
                <button id="okDel" type="button" class="btn btn-primary" data-loading-text="正在删除...">确  定</button>
            </div>
        </div>
    </div>
</div>
<div id="dialogDetail" class="modal fade bs-modal-sm" tabindex="-3" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
    </div>
</div>
<script language="JavaScript">
    var datatable;
    function initDatatable() {
        datatable = $('.datatable').DataTable({
            "dom": '<"toolbar">frtip',
            "searching":false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "ordering": true,
            "language": {
                "url": "${base}/assets/plugins/datatables/cn.json"
            },
            "preDrawCallback": function () {
                sublime.showLoadingbar($(".main-content"));
            },
            "drawCallback": function () {
                sublime.closeLoadingbar($(".main-content"));
            },
            "ajax": {
                "url": "${base}/private/business/bus_orders/data",
                "type": "post",
                "data": function (d) {
                    d.unitid = $('#unitid').val();
                }
            },
//            "order": [[0, "desc"]],
            "columns": [
                    {"data": "goodsPicMain", "bSortable": true},
                    {"data": "marketingNum", "bSortable": true},
                    {"data": "goodsName", "bSortable": true},
                    {"data": "goodsId", "bSortable": true},
                    {"data": "goodsUrl", "bSortable": true},
                    {"data": "couponUrl", "bSortable": true},
                    {"data": "channel", "bSortable": true},
                    {"data": "salesman", "bSortable": true},
                    {"data": "busOrderStatus", "bSortable": true},
                    {"data": "busOrderStatus_1", "bSortable": true},
                    {"data": "busOrderStatus_2", "bSortable": true},
                    {"data": "busOrderStatus_3", "bSortable": true},
                    {"data": "busOrderStatus_4", "bSortable": true},
                    {"data": "busOrderStatus_5", "bSortable": true},
            ],
            "columnDefs": [
                {
                    "render": function (data, type, row) {
                        return '<div class="btn-group"><button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">' +
                                ' <i class="ti-settings"></i> <span class="ti-angle-down"></span></button><ul class="dropdown-menu" role="menu">' +
                                '<li><a href="${base}/private/business/bus_orders/detail/' + row.id + '" data-toggle="modal" data-target="#dialogDetail">查看信息</a></li>' +
                                '<li><a href="${base}/private/business/bus_orders/edit/' + row.id + '" data-pjax>修改信息</a></li>' +
                                '<li class="divider"></li>' +
                                '<li><a href="javascript:;" onclick="del(\'' + row.id + '\')">删除</a></li>' +
                                '</ul></div>';
                    },
                    "targets": 14
                }
            ]
        });
        datatable.on('click', 'tr', function () {
            $(this).toggleClass('selected');
        });
        $("#searchBtn").on('click', function () {
            datatable.ajax.reload();
        });
    }
    function del(id) {
        var dialog = $("#dialogDelete");
        dialog.modal("show");
        dialog.find("#okDel").unbind("click");
        dialog.find("#okDel").bind("click", function (event) {
            var btn = $(this);
            btn.button("loading");
            $.post("${base}/private/business/bus_orders/delete/" + id, {}, function (data) {
                if (data.code == 0) {
                    datatable.ajax.reload(null,false);
                } else {
                    Toast.error(data.msg);
                }
                //重置按钮状态,关闭提示框
                btn.button("reset");
                dialog.modal("hide");
            }, "json");
        });
    }
    function delCheck() {
        var chks = datatable.rows('.selected').data();
        if (chks.length > 0) {
            var ids = [];
            $.each(datatable.rows('.selected').data(), function (i, n) {
                ids.push(n.id);
            });
            var dialog = $("#dialogDelete");
            dialog.modal("show");
            dialog.find("#okDel").unbind("click");
            dialog.find("#okDel").bind("click", function (event) {
                var btn = $(this);
                btn.button("loading");
                $.post("${base}/private/business/bus_orders/delete", {ids: ids.toString()}, function (data) {
                    if (data.code == 0) {
                        datatable.ajax.reload(null,false);
                    } else {
                        Toast.error(data.msg);
                    }
                    btn.button("reset");
                    dialog.modal("hide");
                }, "json");
            });
        } else {
            Toast.warning("请先选择要删除的busOrder!");
        }
    }
    $(function () {
        initDatatable();
    });
</script>

<%}%>

@qq_fca05dd3 根据实体生成出来的代码么?把java实体也贴出来

@enilu

package cn.wizzer.modules.back.business.models;

import cn.wizzer.common.base.Model;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;

/**
 * 描述:
 * 作者:啊平
 * 版本:1.0
 * 时间:2016/8/3 0003
 */
@Table("bus_order")
public class busOrder extends Model implements Serializable {
    private static final long serialVersionUID = 1L;

    @Name
    @Column
    @Prev(els = {@EL("uuid()")})
    private String id;

    @Column
    @Comment("商品主图")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String goodsPicMain;
    @Column
    @Comment("营销单号")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String marketingNum;
    @Column
    @Comment("商品名称")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String goodsName;
    @Column
    @Comment("商品Id")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String goodsId;
    @Column
    @Comment("商品链接")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String goodsUrl;
    @Column
    @Comment("优惠券链接")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String couponUrl;
    @Column
    @Comment("渠道")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String channel;
    @Column
    @Comment("业务员")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String salesman;
    @Column
    @Comment("订单状态")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String busOrderStatus;

    @Column
    @Comment("订单状态")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String busOrderStatus_1;

    @Column
    @Comment("订单状态")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String busOrderStatus_2;

    @Column
    @Comment("订单状态")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String busOrderStatus_3;

    @Column
    @Comment("订单状态")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String busOrderStatus_4;

    @Column
    @Comment("订单状态")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String busOrderStatus_5;

    public String getBusOrderStatus_3() {
        return busOrderStatus_3;
    }

    public void setBusOrderStatus_3(String busOrderStatus_3) {
        this.busOrderStatus_3 = busOrderStatus_3;
    }

    public String getBusOrderStatus_4() {
        return busOrderStatus_4;
    }

    public void setBusOrderStatus_4(String busOrderStatus_4) {
        this.busOrderStatus_4 = busOrderStatus_4;
    }

    public String getBusOrderStatus_5() {
        return busOrderStatus_5;
    }

    public void setBusOrderStatus_5(String busOrderStatus_5) {
        this.busOrderStatus_5 = busOrderStatus_5;
    }

    public String getBusOrderStatus_2() {
        return busOrderStatus_2;
    }

    public void setBusOrderStatus_2(String busOrderStatus_2) {
        this.busOrderStatus_2 = busOrderStatus_2;
    }

    public String getBusOrderStatus_1() {
        return busOrderStatus_1;
    }

    public void setBusOrderStatus_1(String busOrderStatus_1) {
        this.busOrderStatus_1 = busOrderStatus_1;
    }

//    public String getBusOrderStatus_2() {
//        return busOrderStatus_2;
//    }
//
//    public void setBusOrderStatus_2(String busOrderStatus_2) {
//        this.busOrderStatus_2 = busOrderStatus_2;
//    }
//
//    public String getBusOrderStatus_3() {
//        return busOrderStatus_3;
//    }
//
//    public void setBusOrderStatus_3(String busOrderStatus_3) {
//        this.busOrderStatus_3 = busOrderStatus_3;
//    }
//
//    public String getBusOrderStatus_4() {
//        return busOrderStatus_4;
//    }
//
//    public void setBusOrderStatus_4(String busOrderStatus_4) {
//        this.busOrderStatus_4 = busOrderStatus_4;
//    }
//
//    public String getBusOrderStatus_5() {
//        return busOrderStatus_5;
//    }
//
//    public void setBusOrderStatus_5(String busOrderStatus_5) {
//        this.busOrderStatus_5 = busOrderStatus_5;
//    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getGoodsPicMain() {
        return goodsPicMain;
    }

    public void setGoodsPicMain(String goodsPicMain) {
        this.goodsPicMain = goodsPicMain;
    }

    public String getMarketingNum() {
        return marketingNum;
    }

    public void setMarketingNum(String marketingNum) {
        this.marketingNum = marketingNum;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsUrl() {
        return goodsUrl;
    }

    public void setGoodsUrl(String goodsUrl) {
        this.goodsUrl = goodsUrl;
    }

    public String getCouponUrl() {
        return couponUrl;
    }

    public void setCouponUrl(String couponUrl) {
        this.couponUrl = couponUrl;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String getSalesman() {
        return salesman;
    }

    public void setSalesman(String salesman) {
        this.salesman = salesman;
    }

    public String getBusOrderStatus() {
        return busOrderStatus;
    }

    public void setBusOrderStatus(String busOrderStatus) {
        this.busOrderStatus = busOrderStatus;
    }
}

你后面那几个字段都叫做订单状态啊,生成出来肯定是这样了

@enilu 名字一样就不行? 名字不一样好像也不行啊

@qq_fca05dd3 好吧,又看了下你qq里的问题,是排序问题,对吧,以后请直接把问题和代码一起贴出来。只贴个代码,都不知道你问题是什么。

请问,你qq里说,排序乱了,怎么个乱法

@enilu 339Q_13SE99FIA_JI_1IODT_png 比如我点了这个排序 后台打印的sql是 B7S_VQ__Z__%K`4~IKXFP_5_png 这个字段是不对的

@qq_fca05dd3 排序那里生成的代码不完善,你需要把代码

 //"order": [[0, "desc"]],

注释去掉,更改为:

  "order": [[2, "desc"]],

@enilu 嗯嗯 能随便说下为啥是2

@qq_fca05dd3

"order": [[2, "desc"]],
这里的2表示以第三个字段排序,顺序从0开始。

你具体看你要根据哪个字段排序,写上字段的序号就行

@enilu 那为啥字段多了 才会这样

不是字段多了才那样,是排序哪里,代码没有生成完毕,需要你根据实际情况调整

@enilu 可能你误会我的意思了 order": [[2, "desc"]],这个应该是默认按照哪个字段排序 我描述的是字段多了 不管点哪个字段排序 传到后台都不是对应的字段 比如我点了商品主图 可以后台生成的sql确实按照订单状态排序

比如,你的表格列为:
商品主图,营销单号,商品名称,
那么 order": [[2, "desc"]], 表示,按商品名称排序

@enilu 这个我知道 但是这个不是问题 问题是你明明是按照商品名称排序 sql确是按照其他字段排序

@enilu 你可以用我的实体类生成代码尝试一下

@qq_fca05dd3
不好意思,纠正一下, "order": [[0, "desc"]], 这行的代码的意思是,进入该列表页面的时候,默认以第几列的字段排序。这个我之前理解错了,不好意思。

另外,关于排序哪里无论如何都是以订单状态排序的问题,你可以在debug一下这个方法:

public Object data(@Param("length") int length, @Param("start") int start, @Param("draw") int draw, @Param("::order") List<DataTableOrder> order, @Param("::columns") List<DataTableColumn> columns) {

看看接收到的参数columns 到底是什么样的

@enilu 不是都以订单状态排序 是都不对应 比如你点图片主图 可能按订单状态 再点其他的是按其他字段排序 但不对应 debug过了 html传进来的值有问题

@qq_fca05dd3 你在把你的页面代码发出来,我试试,

来自炫酷的 NutzCN

@enilu 往上拉有页面代码还有实体类

@Wizzercn 鲨鱼看下,感觉是个bug。
前台界面列顺序是这样

                   {"data": "goodsPicMain", "bSortable": true},
                    {"data": "marketingNum", "bSortable": true},
                    {"data": "goodsName", "bSortable": true},
                    {"data": "goodsId", "bSortable": true},
                    {"data": "goodsUrl", "bSortable": true},
                    {"data": "couponUrl", "bSortable": true},
                    {"data": "channel", "bSortable": true},
                    {"data": "salesman", "bSortable": true},
                    {"data": "busOrderStatus", "bSortable": true},
                    {"data": "busOrderStatus_1", "bSortable": true},
                    {"data": "busOrderStatus_2", "bSortable": true},
                    {"data": "busOrderStatus_3", "bSortable": true},
                    {"data": "busOrderStatus_4", "bSortable": true},
                    {"data": "busOrderStatus_5", "bSortable": true},

后台controller的data方法中接收到的@Param("::columns") List columns 参数,顺序和这个是不一致的

导致service中的data方法中下述代码:

        if (orders != null && orders.size() > 0) {
            for (DataTableOrder order : orders) {
              **  DataTableColumn col = columns.get(order.getColumn());**
                cnd.orderBy(Sqls.escapeSqlFieldValue(col.getData()).toString(), order.getDir());
            }
        }

拿到的排序字段不是前台点击的那个字段

@Wizzercn
前台提交到后台的参数是:

draw:4
columns[0][data]:goodsPicMain
columns[0][name]:
columns[0][searchable]:true
columns[0][orderable]:true
columns[0][search][value]:
columns[0][search][regex]:false
columns[1][data]:marketingNum
columns[1][name]:
columns[1][searchable]:true
columns[1][orderable]:true
columns[1][search][value]:
columns[1][search][regex]:false
columns[2][data]:goodsName
columns[2][name]:
columns[2][searchable]:true
columns[2][orderable]:true
columns[2][search][value]:
columns[2][search][regex]:false
columns[3][data]:goodsId
columns[3][name]:
columns[3][searchable]:true
columns[3][orderable]:true
columns[3][search][value]:
columns[3][search][regex]:false
columns[4][data]:goodsUrl
columns[4][name]:
columns[4][searchable]:true
columns[4][orderable]:true
columns[4][search][value]:
columns[4][search][regex]:false
columns[5][data]:couponUrl
columns[5][name]:
columns[5][searchable]:true
columns[5][orderable]:true
columns[5][search][value]:
columns[5][search][regex]:false
columns[6][data]:channel
columns[6][name]:
columns[6][searchable]:true
columns[6][orderable]:true
columns[6][search][value]:
columns[6][search][regex]:false
columns[7][data]:salesman
columns[7][name]:
columns[7][searchable]:true
columns[7][orderable]:true
columns[7][search][value]:
columns[7][search][regex]:false
columns[8][data]:busOrderStatus
columns[8][name]:
columns[8][searchable]:true
columns[8][orderable]:true
columns[8][search][value]:
columns[8][search][regex]:false
columns[9][data]:busOrderStatus_1
columns[9][name]:
columns[9][searchable]:true
columns[9][orderable]:true
columns[9][search][value]:
columns[9][search][regex]:false
columns[10][data]:busOrderStatus_2
columns[10][name]:
columns[10][searchable]:true
columns[10][orderable]:true
columns[10][search][value]:
columns[10][search][regex]:false
columns[11][data]:busOrderStatus_3
columns[11][name]:
columns[11][searchable]:true
columns[11][orderable]:true
columns[11][search][value]:
columns[11][search][regex]:false
columns[12][data]:busOrderStatus_4
columns[12][name]:
columns[12][searchable]:true
columns[12][orderable]:true
columns[12][search][value]:
columns[12][search][regex]:false
columns[13][data]:busOrderStatus_5
columns[13][name]:
columns[13][searchable]:true
columns[13][orderable]:true
columns[13][search][value]:
columns[13][search][regex]:false
columns[14][data]:14
columns[14][name]:
columns[14][searchable]:true
columns[14][orderable]:true
columns[14][search][value]:
columns[14][search][regex]:false
order[0][column]:3
order[0][dir]:asc
start:0
length:10
search[value]:
search[regex]:false
unitid:

后台接收到的是这样:

[{
   "data" :"busOrderStatus_3",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"busOrderStatus_4",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"busOrderStatus_5",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"14",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"goodsPicMain",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"marketingNum",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"goodsName",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"goodsId",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"goodsUrl",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"couponUrl",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"channel",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"salesman",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"busOrderStatus",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"busOrderStatus_1",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}, {
   "data" :"busOrderStatus_2",
   "name" :"",
   "searchable" :true,
   "orderable" :true
}]

赤果果的顺序变了

给出对应的html代码

我的测试表单(含乱序)

    <form action="${base}/demo/param/list" method="post" enctype="application/x-www-form-urlencoded">
		
		<input name="user[0].name" value="ABC_Name_0"></br>
		<input name="user[0].id" value="0"></br>
		
		<input name="user[1].name" value="ABC_Name_1"></br>
		<input name="user[1].id" value="1"></br>
		
		<input name="user[2].name" value="ABC_Name_2"></br>
		<input name="user[2].id" value="2"></br>
		
		<input name="user[4].name" value="ABC_Name_4"></br>
		<input name="user[4].id" value="4"></br>
		
		<input name="user[3].name" value="ABC_Name_3"></br>
		<input name="user[3].id" value="3"></br>

		<input name="user[3].roles[0].name" value="ABC_ROLE_3"></br>
		<input name="user[3].roles[0].id" value="303"></br>
		
		<input type="submit">
	</form>

接收代码

    @At("/param/list")
    @Ok("json:forlook")
    public Object paramList(@Param("::user")List<User> users) {
        return users;
    }

页面输出

[{
   id :0,
   name :"ABC_Name_0",
   locked :false
}, {
   id :1,
   name :"ABC_Name_1",
   locked :false
}, {
   id :2,
   name :"ABC_Name_2",
   locked :false
}, {
   id :3,
   name :"ABC_Name_3",
   locked :false,
   roles :[{
      id :303,
      name :"ABC_ROLE_3"
   }]
}, {
   id :4,
   name :"ABC_Name_4",
   locked :false
}]

@wendal

<%
layout("/layouts/private.html"){
%>
<section class="content-wrap bg-white">
    <header class="header navbar bg-white shadow">
        <div class="btn-group tool-button">
            <a id="add" class="btn btn-primary navbar-btn" href="${base}/private/business/bus_orders/add" data-pjax><i class="ti-plus"></i> 新建 busOrder</a>
            <button class="btn btn-danger navbar-btn" onclick="delCheck()"><i class="ti-close"></i> 删除选中</button>
        </div>
    </header>
    <div class=panel-body style="padding-top: 50px;">
        <div class="table-responsive no-border">
            <input id="unitid" type="hidden">
            <table class="table table-bordered table-striped mg-t datatable">
                <thead>
                    <tr>
                            <th>商品主图</th>
                            <th>营销单号</th>
                            <th>商品名称</th>
                            <th>商品Id</th>
                            <th>商品链接</th>
                            <th>优惠券链接</th>
                            <th>渠道</th>
                            <th>业务员</th>
                            <th>ffffff</th>
                            <th>eeeee</th>
                            <th>ddddd</th>
                            <th>ccccc</th>
                            <th>bbbbb</th>
                            <th>aaaaaa</th>
                            <th>操作</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</section>
<div id="dialogDelete" class="modal fade bs-modal-sm" tabindex="-2" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">删除busOrder</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-12">
                        busOrder删除后无法恢复。<br/>
                        <br/>确定删除吗?
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取  消</button>
                <button id="okDel" type="button" class="btn btn-primary" data-loading-text="正在删除...">确  定</button>
            </div>
        </div>
    </div>
</div>
<div id="dialogDetail" class="modal fade bs-modal-sm" tabindex="-3" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
    </div>
</div>
<script language="JavaScript">
    var datatable;
    function initDatatable() {
        datatable = $('.datatable').DataTable({
            "dom": '<"toolbar">frtip',
            "searching":false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "ordering": true,
            "language": {
                "url": "${base}/assets/plugins/datatables/cn.json"
            },
            "preDrawCallback": function () {
                sublime.showLoadingbar($(".main-content"));
            },
            "drawCallback": function () {
                sublime.closeLoadingbar($(".main-content"));
            },
            "ajax": {
                "url": "${base}/private/business/bus_orders/data",
                "type": "post",
                "data": function (d) {
                    d.unitid = $('#unitid').val();
                }
            },
//            "order": [[0, "desc"]],
            "columns": [
                    {"data": "goodsPicMain", "bSortable": true},
                    {"data": "marketingNum", "bSortable": true},
                    {"data": "goodsName", "bSortable": true},
                    {"data": "goodsId", "bSortable": true},
                    {"data": "goodsUrl", "bSortable": true},
                    {"data": "couponUrl", "bSortable": true},
                    {"data": "channel", "bSortable": true},
                    {"data": "salesman", "bSortable": true},
                    {"data": "ffffff", "bSortable": true},
                    {"data": "eeeee", "bSortable": true},
                    {"data": "ddddd", "bSortable": true},
                    {"data": "ccccc", "bSortable": true},
                    {"data": "bbbbb", "bSortable": true},
                    {"data": "aaaaaa", "bSortable": true},
            ],
            "columnDefs": [
                {
                    "render": function (data, type, row) {
                        return '<div class="btn-group"><button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">' +
                                ' <i class="ti-settings"></i> <span class="ti-angle-down"></span></button><ul class="dropdown-menu" role="menu">' +
                                '<li><a href="${base}/private/business/bus_orders/detail/' + row.id + '" data-toggle="modal" data-target="#dialogDetail">查看信息</a></li>' +
                                '<li><a href="${base}/private/business/bus_orders/edit/' + row.id + '" data-pjax>修改信息</a></li>' +
                                '<li class="divider"></li>' +
                                '<li><a href="javascript:;" onclick="del(\'' + row.id + '\')">删除</a></li>' +
                                '</ul></div>';
                    },
                    "targets": 14
                }
            ]
        });
        datatable.on('click', 'tr', function () {
            $(this).toggleClass('selected');
        });
        $("#searchBtn").on('click', function () {
            datatable.ajax.reload();
        });
    }
    function del(id) {
        var dialog = $("#dialogDelete");
        dialog.modal("show");
        dialog.find("#okDel").unbind("click");
        dialog.find("#okDel").bind("click", function (event) {
            var btn = $(this);
            btn.button("loading");
            $.post("${base}/private/business/bus_orders/delete/" + id, {}, function (data) {
                if (data.code == 0) {
                    datatable.ajax.reload(null,false);
                } else {
                    Toast.error(data.msg);
                }
                //重置按钮状态,关闭提示框
                btn.button("reset");
                dialog.modal("hide");
            }, "json");
        });
    }
    function delCheck() {
        var chks = datatable.rows('.selected').data();
        if (chks.length > 0) {
            var ids = [];
            $.each(datatable.rows('.selected').data(), function (i, n) {
                ids.push(n.id);
            });
            var dialog = $("#dialogDelete");
            dialog.modal("show");
            dialog.find("#okDel").unbind("click");
            dialog.find("#okDel").bind("click", function (event) {
                var btn = $(this);
                btn.button("loading");
                $.post("${base}/private/business/bus_orders/delete", {ids: ids.toString()}, function (data) {
                    if (data.code == 0) {
                        datatable.ajax.reload(null,false);
                    } else {
                        Toast.error(data.msg);
                    }
                    btn.button("reset");
                    dialog.modal("hide");
                }, "json");
            });
        } else {
            Toast.warning("请先选择要删除的busOrder!");
        }
    }
    $(function () {
        initDatatable();
    });
</script>

<%}%>

@wendal 要字段多才会出现这种情况

添加回复
请先登陆
回到顶部