course.js
5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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_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},
{field: 'pay_num', title: __('Pay_num')},
//操作栏,默认有编辑、删除或排序按钮,可自定义配置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;
});