statisc.js
6.61 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
define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init();
//绑定事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var panel = $($(this).attr("href"));
if (panel.length > 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");
$(document).on("click", ".btn-export", function () {
var time = $('#c_time2').val()
var staff_id = $('#c_staff').val()
$.post('antis/attendance/Statisc/export', {time:time,staff_id:staff_id}, function (res) {
Layer.alert(res.msg);
if(res.code == 1){
window.location.href = res.data.filePath;
Layer.close(index);
}
table.bootstrapTable('refresh');
}, 'json');
return false;
});
$(document).on("click", ".btn-export_detail", function () {
var time = $('#c_time2').val()
var staff_id = $('#c_staff').val()
$.post('antis/attendance/Statisc/exportDetaile', {time:time,staff_id:staff_id}, function (res) {
Layer.alert(res.msg);
if(res.code == 1){
window.location.href = res.data.filePath;
Layer.close(index);
}
table.bootstrapTable('refresh');
}, 'json');
return false;
})
},
tableinfo:{
url : '',
toolbar: '',
pk : 'id',
sortName : 'id',
fixedColumns : true,
fixedNumber : 2,
fixedRightNumber : 1,
columns: [
[
{field: 'state', checkbox: true},
{field: 'month', title: '月份', operate: false},
{field: 'staff', title: '姓名', operate: false},
{field: 'normal', title: __('正常天数'), operate: false},
{field: 'error', title: __('异常天数'), operate: false},
{field: 'late', title:'迟到', operate: false},
{field: 'leave', title: '早退', operate: false},
{field: 'work', title: __('旷工'), operate: false},
{field: 'card', title: __('缺卡'), operate: false},
{field: 'other', title: __('外勤'), operate: false},
{field: 'overtime', title: __('加班时长'), operate: false},
// {field : 'staff_id', title : '姓名',operate:false},
{field : 'staff_id', title : '姓名', visible: false, addClass: "selectpage", extend: "data-source='antis/department/staff/index' data-field='name'"},
]
],
pagination : true,
search : false,
commonSearch : true,
searchFormVisible : true,
searchFormTemplate: 'customformtpl',
//显示导出按钮
showExport: true,
onLoadSuccess:function(){
// 这里就是数据渲染结束后的回调函数
$(".btn-add").data("area",["80%","80%"]);
$(".btn-edit").data("area",["80%","80%"]);
}
},
table: {
first: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'antis/attendance/statisc/index',
table: 'statisc'
}
});
var table = $("#table");
Controller.tableinfo.url=location.href+'&type=0';
Controller.tableinfo.toolbar='#toolbar';
Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
// 初始化表格
table.bootstrapTable(Controller.tableinfo);
// 为表格绑定事件
Table.api.bindevent(table);
},
second: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'antis/attendance/statisc/index',
table: 'statisc'
}
});
var table = $("#table1");
Controller.tableinfo.url=location.href+'&type=1';
Controller.tableinfo.toolbar='#toolbar1';
Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
// 初始化表格
table.bootstrapTable(Controller.tableinfo);
// 为表格绑定事件
Table.api.bindevent(table);
},
third: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'antis/attendance/statisc/index',
table: 'statisc'
}
});
var table = $("#table2");
Controller.tableinfo.url=location.href+'&type=2';
Controller.tableinfo.toolbar='#toolbar2 ';
Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
// 初始化表格
table.bootstrapTable(Controller.tableinfo);
// 为表格绑定事件
Table.api.bindevent(table);
},
},
add: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
},
}
};
return Controller;
});