perform.js
6.5 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'perform/index',
add_url: 'perform/add',
edit_url: 'perform/edit',
del_url: 'perform/del',
multi_url: 'perform/multi',
table: 'perform',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'),operate:false},
{field: 'title', title: __('Title')},
{field: 'images', title: __('Images'), formatter: Table.api.formatter.images},
{field: 'showtime', title: __('Showtime'), operate:'RANGE', addclass:'datetimerange'},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
{field: 'label_name', title: __('Label_name')},
{field: 'user_id', title: __('User_id')},
{field: 'username', title: __('User_name')},
{field: 'usereditor', title: __('User_editor')},
{
field: 'operate',
width: "120px",
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'up',
title: __('发布'),
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
icon: 'fa fa-magic',
url: 'perform/statusS/status/1',
success: function (data, ret) {
// Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
location.href= location.href;
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
return false;
}
},
{
name: 'down',
title: __('取消发布'),
classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
icon: 'fa fa-magic',
url: 'perform/statusS/status/0',
success: function (data, ret) {
// Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
//如果需要阻止成功提示,则必须使用return false;
//return false;
location.href= location.href;
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
return false;
}
},
{
name: 'down',
title: __('引用'),
classname: 'btn btn-xs btn-danger btn-magic btn-addtabs',
icon: 'fa fa-edit',
url: 'quote/index?controller='+Config.controller,
}
],
formatter: Table.api.formatter.operate
},
]
],
search:false,
});
// 为表格绑定事件
Table.api.bindevent(table);
$(document).on("click", ".btn-up", function () {
//在table外不可以使用添加.btn-change的方法
//只能自己调用Table.api.multi实现
//如果操作全部则ids可以置为空
var ids = Table.api.selectedids(table);
$.ajax({
"url":"perform/statusS/status/1/ids/"+ids,
"type":"get",
success:function ($res) {
location.href= location.href;
},
error:function(){
location.href= location.href;
}
})
});
//取消发布
$(document).on("click", ".btn-down", function () {
//在table外不可以使用添加.btn-change的方法
//只能自己调用Table.api.multi实现
//如果操作全部则ids可以置为空
var ids = Table.api.selectedids(table);
$.ajax({
"url":"perform/statusS/status/0/ids/"+ids,
"type":"get",
success:function ($res) {
location.href= location.href;
},
error:function(){
location.href= location.href;
}
})
});
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});