define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'mobile/course/course/index' + location.search, add_url: 'mobile/course/course/add', edit_url: 'mobile/course/course/edit', del_url: 'mobile/course/course/del', multi_url: 'mobile/course/course/multi', table: 'mobile_course', } }); 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: 'cover', title: __('Cover'), events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'current_price', title: __('Current_price'), operate:'BETWEEN'}, {field: 'original_price', title: __('Original_price'), operate:'BETWEEN'}, {field: 'study_num_rate', title: __('Study_num_rate')}, {field: 'study_num_virtual', title: __('Study_num_virtual')}, {field: 'study_num_real', title: __('Study_num_real')}, {field: 'teacher_avatar', title: __('Teacher_avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'teacher_name', title: __('Teacher_name')}, {field: 'teacher_desc', title: __('Teacher_desc')}, // {field: 'is_top', title: __('Is_top'), searchList: {"0":__('Is_top 0'),"1":__('Is_top 1')}, formatter: Table.api.formatter.toggle}, //操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮 { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: [ { name: 'top', text: '置顶', title: '置顶', classname: 'btn btn-xs btn-primary btn-ajax', icon: 'fa fa-long-arrow-up', url: 'mobile/course/course/top?course_id={id}&is_top=1', visible: function (row) { if(row.is_top == '0'){ return true; } }, success: function (data) { table.bootstrapTable('refresh'); } }, { name: 'top', text: '取消置顶', title: '取消置顶', classname: 'btn btn-xs btn-danger btn-ajax', icon: 'fa fa-long-arrow-down', url: 'mobile/course/course/top?course_id={id}&is_top=0', visible: function (row) { if(row.is_top == '1'){ return true; } }, success: function (data) { table.bootstrapTable('refresh'); } }, { name: 'catalog', text: '目录管理', title: '目录管理', classname: 'btn btn-xs btn-primary btn-dialog', icon: 'fa fa-list', url: 'mobile/course/course_catalog?course_id={id}', }, { name: 'spec', text: '规格管理', title: '规格管理', classname: 'btn btn-xs btn-primary btn-dialog', icon: 'fa fa-list', url: 'mobile/course/course_spec?course_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; });