NutzCN Logo
问答 nutzwk代码生成插件问题
发布于 2985天前 作者 Hamming 2008 次浏览 复制 上一个帖子 下一个帖子
标签:

index代码如下 用的是nutzwk框架生成代码

<%
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/app/t/goods/add" data-pjax><i class="ti-plus"></i> 新建Goods</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">
            <table class="table table-bordered table-striped mg-t datatable">
                <thead>
                    <tr>
                            <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">删除</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-12">
                        删除后无法恢复。<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/app/t/goods/data",
                "type": "post",
                "data": function (d) {
                    //d.unitid = $('#unitid').val();
                }
            },
            "order": [[0, "desc"]],
            "columns": [
            ],
            "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/app/t/goods/detail/' + row.id + '" data-toggle="modal" data-target="#dialogDetail">查看</a></li>' +
                                '<li><a href="${base}/private/app/t/goods/edit/' + row.id + '" data-pjax>修改</a></li>' +
                                '<li class="divider"></li>' +
                                '<li><a href="javascript:;" onclick="del(\'' + row.id + '\')">删除</a></li>' +
                                '</ul></div>';
                    },
                    "targets": 0
                }
            ]
        });
        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/app/t/goods/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/app/t/goods/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("请先选择要删除的项!");
        }
    }
    $(function () {
        initDatatable();
    });
</script>

<%}%>

实体类

package cn.wizzer.modules.app.models;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 通过 DBCodeCreateTool 代码自动生成
 * @time 2016-08-24 09:52:56
 */
@Table("t_goods")
public class Goods implements Serializable{
    private static final long serialVersionUID = 1L;
    /********** attribute ***********/
    /**
     * 商品状态-删除
     */
    public static final String STATE_RM = "0";

    /**
     * 商品状态-上架
     */
    public static final String STATE_ON = "1";

    /**
     * 商品状态-下架
     */
    public static final String STATE_OFF = "2";

    /**
     * 默认图片文件名
     */
    public static final String IMG_DFT = "goods_default.png";
    
    /****商品id ****/
    @Id
    @Column("good_id")
    private int good_id;
    /****商品名称 ****/

    @Name
    @Column("name")
    private String name;
    /****商品状态 ****/
    @Column("state")
    private String state;

    /****库存 ****/
    @Column("good_sku")
    private int good_sku;

    @Column("good_tenant_id")
    private int good_tenant_id;
    /****店铺ID ****/
    @Column("good_store_id")
    private int good_store_id;
    /****商品类别 ****/
    @Column("good_cate_id")
    private int good_cate_id;
    /****原价 ****/
    @Column("original_price")
    private java.math.BigDecimal original_price;
    /****优惠价 ****/
    @Column("prefere_price")
    private java.math.BigDecimal prefere_price;
    /****商品描述 ****/
    @Column("g_describe")
    private String g_describe;
    /****商品图片 ****/
    @Column("picture")
    private String picture;
    /****商品标签 ****/
    @Column("label")
    private String label;
    /****店铺名称 ****/
    @Column("good_store_name")
    private String good_store_name;
    /****首页商品标题 ****/
    @Column("good_title")
    private String good_title;

    @Column("sales_volume")
    private Long sales_volume;

    /****添加时间 ****/
    @Column("create_time")
    private Date create_time;
    /****更新时间 ****/
    @Column("update_time")
    private Date update_time;

    @Many(target = Sku.class, field = "sku_goods_id")
    private List<Sku> sku;

    @Many(target = Image.class, field = "img_goods_id")
    private List<Image> images;

    public Goods() {}
    public Goods(int good_id, String name, String state, int good_sku, int good_tenant_id, int good_store_id, int good_cate_id, java.math.BigDecimal original_price, java.math.BigDecimal prefere_price, String g_describe, String picture, String label, String good_store_name, String good_title, Date create_time, Date update_time) {
        this.good_id = good_id;
        this.name = name;
        this.state = state;
        this.good_sku = good_sku;
        this.good_tenant_id = good_tenant_id;
        this.good_store_id = good_store_id;
        this.good_cate_id = good_cate_id;
        this.original_price = original_price;
        this.prefere_price = prefere_price;
        this.g_describe = g_describe;
        this.picture = picture;
        this.label = label;
        this.good_store_name = good_store_name;
        this.good_title = good_title;
        this.create_time = create_time;
        this.update_time = update_time;
    }
    /********** get/set ***********/
    public int getGood_id() {
        return good_id;
    }
    public void setGood_id(int good_id) {
        this.good_id = good_id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    public int getGood_sku() {
        return good_sku;
    }
    public void setGood_sku(int good_sku) {
        this.good_sku = good_sku;
    }
    public int getGood_tenant_id() {
        return good_tenant_id;
    }
    public void setGood_tenant_id(int good_tenant_id) {
        this.good_tenant_id = good_tenant_id;
    }
    public int getGood_store_id() {
        return good_store_id;
    }
    public void setGood_store_id(int good_store_id) {
        this.good_store_id = good_store_id;
    }
    public int getGood_cate_id() {
        return good_cate_id;
    }
    public void setGood_cate_id(int good_cate_id) {
        this.good_cate_id = good_cate_id;
    }
    public java.math.BigDecimal getOriginal_price() {
        return original_price;
    }
    public void setOriginal_price(java.math.BigDecimal original_price) {
        this.original_price = original_price;
    }
    public java.math.BigDecimal getPrefere_price() {
        return prefere_price;
    }
    public void setPrefere_price(java.math.BigDecimal prefere_price) {
        this.prefere_price = prefere_price;
    }
    public String getG_describe() {
        return g_describe;
    }
    public void setG_describe(String g_describe) {
        this.g_describe = g_describe;
    }
    public String getPicture() {
        return picture;
    }
    public void setPicture(String picture) {
        this.picture = picture;
    }
    public String getLabel() {
        return label;
    }
    public void setLabel(String label) {
        this.label = label;
    }
    public String getGood_store_name() {
        return good_store_name;
    }
    public void setGood_store_name(String good_store_name) {
        this.good_store_name = good_store_name;
    }
    public String getGood_title() {
        return good_title;
    }
    public void setGood_title(String good_title) {
        this.good_title = good_title;
    }

    public Long getSales_volume() {
        return sales_volume;
    }

    public void setSales_volume(Long sales_volume) {
        this.sales_volume = sales_volume;
    }

    public Date getCreate_time() {
        return create_time;
    }
    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }
    public Date getUpdate_time() {
        return update_time;
    }
    public void setUpdate_time(Date update_time) {
        this.update_time = update_time;
    }

    public List<Sku> getSku() {
        return sku;
    }

    public void setSku(List<Sku> sku) {
        this.sku = sku;
    }

    public List<Image> getImages() {
        return images;
    }

    public void setImages(List<Image> images) {
        this.images = images;
    }
}

2 回复

so?

来自炫酷的 NutzCN

@wendal 出错了 内容

<thead>
                    <tr>
                            <th>操作</th>
                    </tr>
                </thead>

这个应该显示有值 但是 没有

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