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

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

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
				pagination: false,
				commonSearch: false,
				search: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'pid', title: __('Pid')},
                        {field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) {
                                return value.toString().replace(/(&|&)nbsp;/g, ' ');
                            }
                        },
                        {field: 'video', title: __('Video'), formatter: Table.api.formatter.url},
                        {field: 'play_num_virtual', title: __('Play_num_virtual')},
                        {field: 'play_num_real', title: __('Play_num_real')},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'weigh', title: __('Weigh')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, 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;
});