feature: task
This commit is contained in:
parent
1c76cdf45e
commit
50e27370dd
|
|
@ -76,80 +76,63 @@ class Schedule extends Backend
|
|||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if ($this->request->isAjax()) {
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$list = $this->model
|
||||
->with(['admin'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
foreach ($list as $row) {
|
||||
|
||||
|
||||
$startDate = '2025-02-22';
|
||||
$endDate = '2025-03-22';
|
||||
|
||||
$res = [];
|
||||
$admins = Db::name('admin')->field('id,nickname')->select();
|
||||
$admins = array_column($admins, NULL, 'id');
|
||||
$adminIds = array_keys($admins);
|
||||
|
||||
$adminNames = array_column($admins, 'nickname', 'id');
|
||||
|
||||
$tmpDate = $startDate;
|
||||
$dates = [];
|
||||
while(true) {
|
||||
|
||||
if ($tmpDate > $endDate) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($adminIds as $adminId) {
|
||||
$res[$adminId][$tmpDate] = '无';
|
||||
$res[$adminId]['name'] = $adminNames[$adminId];
|
||||
}
|
||||
|
||||
$dates[] = $tmpDate;
|
||||
$tmpDate = date('Y-m-d', strtotime($tmpDate) + 86400);
|
||||
}
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
$queryData = $this->model
|
||||
->with([
|
||||
'admin'
|
||||
])
|
||||
->where('date', '>=', $startDate)
|
||||
->where('date', '<=', $endDate)
|
||||
->select();
|
||||
foreach ($queryData as $queryDatum) {
|
||||
$queryDatum = $queryDatum->toArray();
|
||||
|
||||
$adminId = $queryDatum['admin']['id'];
|
||||
$date = $queryDatum['date'];
|
||||
$type = $queryDatum['type'];
|
||||
|
||||
if (isset($res[$adminId][$date])) {
|
||||
$res[$adminId][$date] = $this->model->getTypeList()[$type];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$res = array_values($res);
|
||||
|
||||
|
||||
$result = array("total" => count($res), "rows" => $res);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
|
||||
$startDate = '2025-02-22';
|
||||
$endDate = '2025-03-22';
|
||||
|
||||
$res = [];
|
||||
$admins = Db::name('admin')->field('id,nickname')->select();
|
||||
$admins = array_column($admins, NULL, 'id');
|
||||
$adminIds = array_keys($admins);
|
||||
|
||||
$adminNames = array_column($admins, 'nickname', 'id');
|
||||
|
||||
$tmpDate = $startDate;
|
||||
$dates = [];
|
||||
while(true) {
|
||||
|
||||
if ($tmpDate > $endDate) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($adminIds as $adminId) {
|
||||
$res[$adminId][$tmpDate] = '无';
|
||||
}
|
||||
|
||||
$dates[] = $tmpDate;
|
||||
$tmpDate = date('Y-m-d', strtotime($tmpDate) + 86400);
|
||||
}
|
||||
|
||||
$queryData = $this->model
|
||||
->with([
|
||||
'admin'
|
||||
])
|
||||
->where('date', '>=', $startDate)
|
||||
->where('date', '<=', $endDate)
|
||||
->select();
|
||||
foreach ($queryData as $queryDatum) {
|
||||
$queryDatum = $queryDatum->toArray();
|
||||
|
||||
$adminId = $queryDatum['admin']['id'];
|
||||
$date = $queryDatum['date'];
|
||||
$type = $queryDatum['type'];
|
||||
|
||||
if (isset($res[$adminId][$date])) {
|
||||
$res[$adminId][$date] = $this->model->getTypeList()[$type];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->assign('adminNames', $adminNames);
|
||||
$this->assign('res', $res);
|
||||
$this->assign('dates', $dates);
|
||||
$this->assign('types', $this->model->getTypeList());
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,31 +6,10 @@
|
|||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('oa/schedule/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('oa/schedule/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('oa/schedule/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>用户\日期</th>
|
||||
{foreach $dates as $date}
|
||||
<th>{$date}</th>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{foreach $res as $adminId => $item}
|
||||
<tr>
|
||||
<td>{$adminNames[$adminId]}</td>
|
||||
{foreach $item as $typeId}
|
||||
<td>{$typeId}</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/foreach}
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -55,6 +55,48 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
// 为表格绑定事件
|
||||
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();
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user