Accept Merge Request #45: (feature/zy -> develop)

Merge Request: feature: schedule

Created By: @zhuyu
Accepted By: @zhuyu
URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/45
This commit is contained in:
zhuyu 2025-05-11 22:01:40 +08:00 committed by Coding
commit 5ed36e678a
11 changed files with 134 additions and 11 deletions

View File

@ -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
}); });
}; };

View File

@ -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];
} }
@ -250,4 +251,58 @@ class Schedule extends Backend
$this->success(); $this->success();
} }
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

@ -24,6 +24,10 @@ class Task extends Backend
protected $dataLimit = 'personal'; protected $dataLimit = 'personal';
protected $dataLimitField = 'exec_admin_id';
protected $dataLimitFieldAutoFill = false;
public function _initialize() public function _initialize()
{ {
parent::_initialize(); parent::_initialize();
@ -101,7 +105,7 @@ class Task extends Backend
} }
} }
$list[$k]['refuse_reason'] = $list['refuse_reason'] ?? ''; $list[$k]['refuse_reason'] = $row['refuse_reason'] ?? '';
} }
$result = array("total" => $list->total(), "rows" => $list->items()); $result = array("total" => $list->total(), "rows" => $list->items());
@ -113,6 +117,26 @@ class Task extends Backend
return $this->view->fetch(); return $this->view->fetch();
} }
public function complete($ids)
{
if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
if (empty($ids)) {
$this->error(__('Parameter %s can not be empty', 'id'));
}
$task = $this->model->where('id', '=', $ids)->where('status', 1)->find();
if (!$task) {
$this->error('任务状态已变更,请刷新后操作');
}
$task->save(['status' => 3]);
$this->success();
}
public function review($ids) public function review($ids)
{ {
if (false === $this->request->isPost()) { if (false === $this->request->isPost()) {
@ -177,6 +201,7 @@ class Task extends Backend
$params['create_time'] = date('Y-m-d H:i:s'); $params['create_time'] = date('Y-m-d H:i:s');
$params['update_time'] = date('Y-m-d H:i:s'); $params['update_time'] = date('Y-m-d H:i:s');
$params['admin_id'] = $this->auth->id;
$result = $this->model->allowField(true)->save($params); $result = $this->model->allowField(true)->save($params);

View File

@ -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' => '编辑时间',

View File

@ -3,7 +3,7 @@
return [ return [
'Id' => 'ID', 'Id' => 'ID',
'Admin_id' => '创建人id', 'Admin_id' => '创建人id',
'Review_admin_id' => '审核人id', 'Exec_admin_id' => '执行人ID',
'Type' => '任务类型', 'Type' => '任务类型',
'Type 1' => '每日任务', 'Type 1' => '每日任务',
'Type 2' => '每周任务', 'Type 2' => '每周任务',

View File

@ -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')];
} }

View File

@ -62,6 +62,6 @@ class Task extends Model
public function admin() public function admin()
{ {
return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0); return $this->belongsTo('app\admin\model\Admin', 'exec_admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
} }
} }

View File

@ -41,7 +41,7 @@
<label class="control-label"></label> <label class="control-label"></label>
<div class="row"> <div class="row">
<div class="col-xs-6"> <div class="col-xs-6">
<input type="submit" class="btn btn-success btn-block" value="提交"/> <input type="submit" class="btn btn-success btn-block" value="查询"/>
</div> </div>
</div> </div>
</div> </div>

View File

@ -23,6 +23,12 @@
<input id="c-desc" class="form-control" name="row[desc]" type="text" value=""> <input id="c-desc" class="form-control" name="row[desc]" type="text" value="">
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Exec_admin_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-exec_admin_id" data-rule="required" data-source="auth/admin/selectpage" data-field="nickname" class="form-control selectpage" name="row[exec_admin_id]" type="text" value="">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Expire_start_time')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Expire_start_time')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -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
}); });
}; };

View File

@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form) {
var Controller = { var Controller = {
index: function () { index: function () {
@ -45,7 +45,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
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'], function ($, undefin
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));
@ -73,6 +77,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
defaultColumnArr.push({ defaultColumnArr.push({
"title": tmpDate, "title": tmpDate,
"field": tmpDate, "field": tmpDate,
"editable" :{
type: 'select',
pk: 1,
source: [
{value: '无', text: '无'},
{value: '早班', text: '早班'},
{value: '中班', text: '中班'},
{value: '晚班', text: '晚班'},
{value: '行政班', text: '行政班'},
]
}
}); });
} }
@ -96,6 +111,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
changeColumn = [{ changeColumn = [{
"title":"用户名", "title":"用户名",
"field":"name", "field":"name",
},{
"title":"用户id",
"field":"admin_id",
"visible":false
}]; }];
const today = new Date(); const today = new Date();
@ -107,6 +126,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
changeColumn.push({ changeColumn.push({
"title": tmpDate, "title": tmpDate,
"field": tmpDate, "field": tmpDate,
"editable" :{
type: 'select',
pk: 1,
source: [
{value: '无', text: '无'},
{value: '早班', text: '早班'},
{value: '中班', text: '中班'},
{value: '晚班', text: '晚班'},
{value: '行政班', text: '行政班'},
]
}
}); });
} }