feature: schedule

This commit is contained in:
zhuyu 2025-05-11 21:57:03 +08:00
parent 947bb0a093
commit 2d3a85ca8c
6 changed files with 72 additions and 7 deletions

View File

@ -16,9 +16,12 @@ if ($("table.table").length > 0) {
require(['editable', 'table'], function (Editable, Table) {
$.fn.bootstrapTable.defaults.onEditableSave = function (field, row, oldValue, $el) {
var data = {};
data["row[" + field + "]"] = row[field];
data["row[field]"] = field;
for(var i in row){
data["row[" + i + "]"] = row[i];
}
Fast.api.ajax({
url: this.extend.edit_url + "/ids/" + row[this.pk],
url: this.extend.editable + "/idsssssssssss/" + row[this.pk],
data: data
});
};

View File

@ -109,6 +109,7 @@ class Schedule extends Backend
foreach ($adminIds as $adminId) {
$res[$adminId][$tmpDate] = '无';
$res[$adminId]['admin_id'] = $adminId;
$res[$adminId]['name'] = $adminNames[$adminId];
}
@ -251,8 +252,57 @@ class Schedule extends Backend
}
public function xtablesave()
public function editable()
{
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$date = $params['field'];
$adminId = $params['admin_id'];
$value = $params[$date] ?? '无';
$valueMap = [
'无' => 0,
'早班' => 1,
'中班' => 2,
'晚班' => 3,
'行政班' => 4,
];
if ($value == '无') {
$this->model->where('exec_admin_id', $adminId)->delete();
$this->success();
}
$dbValue = $valueMap[$value];
$data = $this->model
->where('date', '=', $date)
->where('exec_admin_id', '=', $adminId)
->find();
$nowTime = date('Y-m-d H:i:s');
if (!empty($data)) {
$data->save([
"date" => $date,
"exec_admin_id" => $adminId,
"type" => $dbValue,
"update_time" => $nowTime,
]);
}
$this->model->insert([
"date" => $date,
"exec_admin_id" => $adminId,
"type" => $dbValue,
"create_time" => $nowTime,
"update_time" => $nowTime,
]);
$this->success();
}
}

View File

@ -8,6 +8,7 @@ return [
'Type 1' => '早班',
'Type 2' => '中班',
'Type 3' => '晚班',
'Type 4' => '行政班',
'Date' => '日期',
'Create_time' => '创建时间',
'Update_time' => '编辑时间',

View File

@ -32,7 +32,7 @@ class Schedule extends Model
public function getTypeList()
{
return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4')];
}

View File

@ -330,9 +330,12 @@ if ($("table.table").length > 0) {
require(['editable', 'table'], function (Editable, Table) {
$.fn.bootstrapTable.defaults.onEditableSave = function (field, row, oldValue, $el) {
var data = {};
data["row[" + field + "]"] = row[field];
data["row[field]"] = field;
for(var i in row){
data["row[" + i + "]"] = row[i];
}
Fast.api.ajax({
url: this.extend.edit_url + "/ids/" + row[this.pk],
url: this.extend.editable + "/idsssssssssss/" + row[this.pk],
data: data
});
};

View File

@ -45,7 +45,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
extend: {
index_url: 'oa/schedule/custom_index' + location.search,
// add_url: 'oa/schedule/add',
// edit_url: 'oa/schedule/edit',
editable: 'oa/schedule/editable',
// del_url: 'oa/schedule/del',
// multi_url: 'oa/schedule/multi',
// import_url: 'oa/schedule/import',
@ -59,6 +59,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
defaultColumnArr.push({
"title":"用户名",
"field":"name",
},{
"title":"用户id",
"field":"admin_id",
"visible":false
});
const startDate = new Date(new Date().setDate(1));
@ -107,6 +111,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
changeColumn = [{
"title":"用户名",
"field":"name",
},{
"title":"用户id",
"field":"admin_id",
"visible":false
}];
const today = new Date();