room_order.js
12.6 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, undefined, Backend, Table, Form,Layer) {
var Controller = {
index: function() {
// 初始化表格参数配置
Table.api.init();
//绑定事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var panel = $($(this).attr("href"));
if (panel.size() > 0) {
Controller.table[panel.attr("id")].call(this);
$(this).on('click', function (e) {
$($(this).attr("href")).find(".btn-refresh").trigger("click");
});
}
//移除绑定的事件
$(this).unbind('shown.bs.tab');
});
//必须默认触发shown.bs.tab事件
$('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
},
table: {
first: function () {
// 表格1
var table1 = $("#table1");
table1.bootstrapTable({
url: 'project_appointment/room_order/index' + location.search,
toolbar: '#toolbar1',
sortName: 'id',
search: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'),operate: false},
{field: 'username', title: __('申请人'),operate: 'LIKE'},
{field: 'room_name', title: __('房间名称'),operate: 'LIKE'},
{field: 'apply_date', title: __('预约日期'),operate: false},
{field: 'start_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'end_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'use_count', title: __('使用人数'),operate: false},
{field: 'apply_desc', title: __('预约说明'),operate: false},
{field: 'status_text', title: __('审核状态'),operate: false},
{field: 'createtime', title: __('创建时间'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field: 'operate',
title: __('Operate'),
table: table1,
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons:[
{
name: 'btn',
text: '审核',
title: '审核',
classname: 'btn btn-xs btn-success btn-click',
click: function (val, row) {
var id = row.id;
var row_index = val.rowIndex;
layer.confirm('您想?', {
btn: ['通过审核','驳回审核'] //按钮
}, function(){
$.ajax({
type:'post',
url:'project_appointment/room_order/verify',
data:{id:id,status:2},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('.btn-refresh').click();
}
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
}, function(){
$.ajax({
type:'post',
url:'project_appointment/room_order/verify',
data:{id:id,status:3},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('.btn-refresh').click();
}
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
});
},
visible: function (val) {
if(val.status == 1) {
return true;
}
}
},
]
},
]
],
});
// 为表格1绑定事件
Table.api.bindevent(table1);
},
second: function () {
// 表格2
var table2 = $("#table2");
table2.bootstrapTable({
url: 'station_appointment/index' + location.search,
toolbar: '#toolbar2',
sortName: 'id',
search: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'),operate: false},
{field: 'username', title: __('申请人'),operate: 'LIKE'},
{field: 'station_name', title: __('工位名称'),operate: 'LIKE'},
{field: 'station_date', title: __('预约日期'),operate: false},
{field: 'station_start_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'station_end_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'station_user_count', title: __('使用人数'),operate: false},
{field: 'station_desc', title: __('预约说明'),operate: false},
{field: 'status_text', title: __('审核状态'),operate: false},
{field: 'createtime', title: __('创建时间'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field: 'operate',
title: __('Operate'),
table: table2,
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons:[
{
name: 'btn',
text: '审核',
title: '审核',
classname: 'btn btn-xs btn-success btn-click',
click: function (val, row) {
var id = row.id;
layer.confirm('您想?', {
btn: ['通过审核','驳回审核'] //按钮
}, function(){
$.ajax({
type:'post',
url:'station_appointment/verify',
data:{id:id,status:1},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('.btn-refresh').click();
}
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
}, function(){
$.ajax({
type:'post',
url:'station_appointment/verify',
data:{id:id,status:2},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('.btn-refresh').click();
}
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
});
},
visible: function (val) {
if(val.status == 0) {
return true;
}
}
},
]
},
]
],
});
// 为表格2绑定事件
Table.api.bindevent(table2);
}
},
add: function () {
Controller.api.bindevent();
Controller.api.linkage();
},
edit: function () {
Controller.api.bindevent();
//绑定事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { // 为tab按钮绑定事件
var panel = $($(this).attr("href"));
if (panel.size() > 0) {
Controller.tabbar[panel.attr("id")].call(this);
}
//移除绑定的事件
$(this).unbind('shown.bs.tab');
});
//必须默认触发shown.bs.tab事件
$('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
Controller.api.linkage();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});