integral_goods.js 4.8 KB
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'integral_goods/index' + location.search,
                    add_url: 'integral_goods/add',
                    edit_url: 'integral_goods/edit',
                    del_url: 'integral_goods/del',
                    multi_url: 'integral_goods/multi',
                    table: 'integral_goods',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'country_id', title: __('Country_id'),visible:false},
                        {field: 'depot_id', title: __('Depot_id'),visible:false},
                        {field: 'ch_name', title: __('Ch_name')},
                        {field: 'en_name', title: __('En_name')},
                        {field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate:false},
                        {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images, operate:false},
                        {field: 'goods_no', title: __('Goods_no')},
                        {field: 'ch_specification', title: __('Ch_specification'),visible:false, operate:false},
                        {field: 'en_specification', title: __('En_specification'),visible:false, operate:false},
                        {field: 'ch_save_where', title: __('Ch_save_where'),visible:false, operate:false},
                        {field: 'en_save_where', title: __('En_save_where'),visible:false, operate:false},
                        {field: 'ch_period', title: __('Ch_period'),visible:false, operate:false},
                        {field: 'en_period', title: __('En_period'),visible:false, operate:false},
                        {field: 'stock_num', title: __('Stock_num'), operate:false},
                        {field: 'sales_initial', title: __('Sales_initial'), operate:false},
                        {field: 'sales_actual', title: __('Sales_actual'), operate:false},
                        {field: 'integral', title: __('Integral')},
                        {field: 'goods_price', title: __('Goods_price'), operate:false},
                        {field: 'original_price', title: __('Original_price'), operate:false},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.toggle,yes:1,no:2},
                        {field: 'weigh', title: __('Weigh')},
                        {field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'country.ch_name', title: __('Country.ch_name'), formatter: Table.api.formatter.label},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                            buttons: [
                                {
                                    name: 'depot', title: '仓库信息', icon: 'fa fa-bars',
                                    classname: 'btn btn-xs btn-warning  btn-dialog',
                                    url: 'depot/index/goods_id/{id}/type/2'
                                },
                                {
                                    name: 'evaluate', title: '评价信息', icon: 'fa fa-bars',
                                    classname: 'btn btn-xs btn-info btn-dialog',
                                    url: 'evaluate/index/goods_id/{id}/type/2',
                                    // extend: 'data-area=\'["1400px", "650px"]\''
                                }
                            ]}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});