feature: schedule
This commit is contained in:
parent
947bb0a093
commit
2d3a85ca8c
7
addons/editable/bootstrap.js
vendored
7
addons/editable/bootstrap.js
vendored
|
|
@ -16,9 +16,12 @@ if ($("table.table").length > 0) {
|
||||||
require(['editable', 'table'], function (Editable, Table) {
|
require(['editable', 'table'], function (Editable, Table) {
|
||||||
$.fn.bootstrapTable.defaults.onEditableSave = function (field, row, oldValue, $el) {
|
$.fn.bootstrapTable.defaults.onEditableSave = function (field, row, oldValue, $el) {
|
||||||
var data = {};
|
var data = {};
|
||||||
data["row[" + field + "]"] = row[field];
|
data["row[field]"] = field;
|
||||||
|
for(var i in row){
|
||||||
|
data["row[" + i + "]"] = row[i];
|
||||||
|
}
|
||||||
Fast.api.ajax({
|
Fast.api.ajax({
|
||||||
url: this.extend.edit_url + "/ids/" + row[this.pk],
|
url: this.extend.editable + "/idsssssssssss/" + row[this.pk],
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ class Schedule extends Backend
|
||||||
|
|
||||||
foreach ($adminIds as $adminId) {
|
foreach ($adminIds as $adminId) {
|
||||||
$res[$adminId][$tmpDate] = '无';
|
$res[$adminId][$tmpDate] = '无';
|
||||||
|
$res[$adminId]['admin_id'] = $adminId;
|
||||||
$res[$adminId]['name'] = $adminNames[$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();
|
$this->success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ return [
|
||||||
'Type 1' => '早班',
|
'Type 1' => '早班',
|
||||||
'Type 2' => '中班',
|
'Type 2' => '中班',
|
||||||
'Type 3' => '晚班',
|
'Type 3' => '晚班',
|
||||||
|
'Type 4' => '行政班',
|
||||||
'Date' => '日期',
|
'Date' => '日期',
|
||||||
'Create_time' => '创建时间',
|
'Create_time' => '创建时间',
|
||||||
'Update_time' => '编辑时间',
|
'Update_time' => '编辑时间',
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class Schedule extends Model
|
||||||
|
|
||||||
public function getTypeList()
|
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')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -330,9 +330,12 @@ if ($("table.table").length > 0) {
|
||||||
require(['editable', 'table'], function (Editable, Table) {
|
require(['editable', 'table'], function (Editable, Table) {
|
||||||
$.fn.bootstrapTable.defaults.onEditableSave = function (field, row, oldValue, $el) {
|
$.fn.bootstrapTable.defaults.onEditableSave = function (field, row, oldValue, $el) {
|
||||||
var data = {};
|
var data = {};
|
||||||
data["row[" + field + "]"] = row[field];
|
data["row[field]"] = field;
|
||||||
|
for(var i in row){
|
||||||
|
data["row[" + i + "]"] = row[i];
|
||||||
|
}
|
||||||
Fast.api.ajax({
|
Fast.api.ajax({
|
||||||
url: this.extend.edit_url + "/ids/" + row[this.pk],
|
url: this.extend.editable + "/idsssssssssss/" + row[this.pk],
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
|
||||||
extend: {
|
extend: {
|
||||||
index_url: 'oa/schedule/custom_index' + location.search,
|
index_url: 'oa/schedule/custom_index' + location.search,
|
||||||
// add_url: 'oa/schedule/add',
|
// add_url: 'oa/schedule/add',
|
||||||
// edit_url: 'oa/schedule/edit',
|
editable: 'oa/schedule/editable',
|
||||||
// del_url: 'oa/schedule/del',
|
// del_url: 'oa/schedule/del',
|
||||||
// multi_url: 'oa/schedule/multi',
|
// multi_url: 'oa/schedule/multi',
|
||||||
// import_url: 'oa/schedule/import',
|
// import_url: 'oa/schedule/import',
|
||||||
|
|
@ -59,6 +59,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
|
||||||
defaultColumnArr.push({
|
defaultColumnArr.push({
|
||||||
"title":"用户名",
|
"title":"用户名",
|
||||||
"field":"name",
|
"field":"name",
|
||||||
|
},{
|
||||||
|
"title":"用户id",
|
||||||
|
"field":"admin_id",
|
||||||
|
"visible":false
|
||||||
});
|
});
|
||||||
|
|
||||||
const startDate = new Date(new Date().setDate(1));
|
const startDate = new Date(new Date().setDate(1));
|
||||||
|
|
@ -107,6 +111,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
|
||||||
changeColumn = [{
|
changeColumn = [{
|
||||||
"title":"用户名",
|
"title":"用户名",
|
||||||
"field":"name",
|
"field":"name",
|
||||||
|
},{
|
||||||
|
"title":"用户id",
|
||||||
|
"field":"admin_id",
|
||||||
|
"visible":false
|
||||||
}];
|
}];
|
||||||
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user