allocatr/public/assets/js/backend/oa/schedule.js
2025-03-24 18:09:16 +08:00

114 lines
5.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'oa/schedule/index' + location.search,
add_url: 'oa/schedule/add',
edit_url: 'oa/schedule/edit',
del_url: 'oa/schedule/del',
multi_url: 'oa/schedule/multi',
import_url: 'oa/schedule/import',
table: 'schedule',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'admin_id', title: __('Admin_id')},
{field: 'exec_admin_id', title: __('Exec_admin_id')},
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
{field: 'date', title: __('Date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'admin.id', title: __('Admin.id')},
{field: 'admin.username', title: __('Admin.username'), operate: 'LIKE'},
{field: 'admin.nickname', title: __('Admin.nickname'), operate: 'LIKE'},
{field: 'admin.password', title: __('Admin.password'), operate: 'LIKE'},
{field: 'admin.salt', title: __('Admin.salt'), operate: 'LIKE'},
{field: 'admin.avatar', title: __('Admin.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'admin.email', title: __('Admin.email'), operate: 'LIKE'},
{field: 'admin.mobile', title: __('Admin.mobile'), operate: 'LIKE'},
{field: 'admin.loginfailure', title: __('Admin.loginfailure')},
{field: 'admin.logintime', title: __('Admin.logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.loginip', title: __('Admin.loginip'), operate: 'LIKE'},
{field: 'admin.createtime', title: __('Admin.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.updatetime', title: __('Admin.updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.token', title: __('Admin.token'), operate: 'LIKE'},
{field: 'admin.status', title: __('Admin.status'), operate: 'LIKE', formatter: Table.api.formatter.status},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
custom_index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'oa/schedule/custom_index' + location.search,
// add_url: 'oa/schedule/add',
// edit_url: 'oa/schedule/edit',
// del_url: 'oa/schedule/del',
// multi_url: 'oa/schedule/multi',
// import_url: 'oa/schedule/import',
table: 'schedule',
}
});
var table = $("#table");
var columnArr = [];
columnArr.push({
"title":"username",
"field":"name",
});
const startDate = new Date("2025-02-22");
const endDate = new Date("2025-03-22");
for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) {
let tmpDate = d.toISOString().split('T')[0]; // 使用 d而不是 date
columnArr.push({
"title": tmpDate,
"field": tmpDate,
});
}
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
columns: columnArr
});
// 为表格绑定事件
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;
});