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

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

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                /*        {field: 'course_sign_id', title: __('Course_sign_id')},*/
                        {field: 'course_star', title: __('Course_star'), operate:'BETWEEN'},
                        {field: 'teacher_star', title: __('Teacher_star'), operate:'BETWEEN'},
                        {field: 'service_star', title: __('Service_star'), operate:'BETWEEN'},
                        {field: 'content', title: __('Content')},
                        {field: 'pic', title: __('Pic'), formatter: function (value) {
                                var arr = value.split(',');
                                var html = '';
                                for(var i = 0; i < arr.length; i++) {
                                    html += '<a href="javascript:"><img class="img-sm img-center" src="'+Fast.api.cdnurl(arr[i])+'"></a>'
                                }
                                return html;
                            },events: Table.api.events.image},
                        {field: 'username', title: __('名字')},
                        {field: 'weChat_pic', title: __('头像'), formatter: function (value) {
                                var arr = value.split(',');
                                var html = '';
                                for(var i = 0; i < arr.length; i++) {
                                    html += '<a href="javascript:"><img class="img-sm img-center" src="'+Fast.api.cdnurl(arr[i])+'"></a>'
                                }
                                return html;
                            },events: Table.api.events.image},
                        {field: 'course.name', title: __('Course_id')},
                        {field: 'store.name', title: __('Store_id')},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'status', title: __('是否显示'),formatter: function (value, row, index) {
                                return '<a class="btn-change text-success" data-url="course_sign_start_set/change" data-id="' + row.id + '"><i class="fa ' + (row.status === 'true' ?'fa-toggle-on fa-flip-horizontal' : 'fa-toggle-off fa-flip-horizontal text-gray' ) + ' fa-2x"></i></a>';
                            }
                        },
                        {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;
});