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

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

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'title', title: __('Title')},
                        {field: 'current_price', title: __('Current_price'), operate:'BETWEEN'},
                        {field: 'original_price', title: __('Original_price'), operate:'BETWEEN'},
                        {field: 'do_num_virtual', title: __('Do_num_virtual')},
                        {field: 'do_num_real', title: __('Do_num_real')},
                        {field: 'pay_num', title: __('Pay_num')},
                        //操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    text: '题目管理',
                                    title: '题目管理',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'mobile/simulation_question?target_id={id}&target_type=5',
                                },
								{
								    text: '规格管理',
								    title: '规格管理',
								    classname: 'btn btn-xs btn-primary btn-dialog',
								    icon: 'fa fa-list',
								    url: 'mobile/secret_spec?secret_id={id}',
								}
                            ],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            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;
});