You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
5.9 KiB
143 lines
5.9 KiB
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");
|
|
|
|
},
|
|
tableinfo:{
|
|
url : '',
|
|
toolbar: '',
|
|
pk : 'id',
|
|
sortName : 'id',
|
|
fixedColumns : true,
|
|
fixedNumber : 2,
|
|
fixedRightNumber : 1,
|
|
columns: [
|
|
[
|
|
{field: 'state', checkbox: true},
|
|
{field: 'staff.name', title: '姓名', operate: false},
|
|
{field: 'address', title: __('打卡位置'), operate: false},
|
|
{field: 'type_name', title: __('打卡类型'), formatter: Table.api.formatter.status, searchList: {0: '上班',1:'下班'}},
|
|
{
|
|
field: 'type_status', title: '打卡状态', operate: false, formatter: function (value, row) {
|
|
|
|
if (row.type_name == 0 && row.late_time == 0) {
|
|
return '<span style="color: #18bc9c">正常打卡</span>';
|
|
}
|
|
if (row.type_name == 0 && row.late_time > 0) {
|
|
return '<span style="color: red">迟到' + row.late_time + '分</span>';
|
|
}
|
|
if (row.type_name == 1 && row.leaver_time == 0) {
|
|
return '<span style="color: #18bc9c">正常打卡</span>';
|
|
}
|
|
if (row.type_name == 1 && row.leaver_time > 0) {
|
|
return '<span style="color: red">早退' + row.leaver_time + '分</span>';
|
|
}
|
|
}
|
|
},
|
|
{field: 'remarks', title: __('备注'), operate: false},
|
|
{field: 'files', title: __('附件'), events: Table.api.events.image, formatter: Table.api.formatter.images, operate: false},
|
|
|
|
{field: 'createtime', title: '打卡时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
|
|
|
|
]
|
|
],
|
|
pagination : true,
|
|
search : false,
|
|
commonSearch : true,
|
|
searchFormVisible : true,
|
|
//显示导出按钮
|
|
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: 'qingdong/attendance/attendance/index',
|
|
table: 'attendance'
|
|
}
|
|
});
|
|
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: 'qingdong/attendance/attendance/index',
|
|
table: 'attendance'
|
|
}
|
|
});
|
|
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: 'qingdong/attendance/attendance/index',
|
|
table: 'attendance'
|
|
}
|
|
});
|
|
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;
|
|
});
|