Accept Merge Request #186: (feature/zy -> develop)
Merge Request: feature: 排班 Created By: @zhuyu Accepted By: @zhuyu URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/186
This commit is contained in:
commit
6400ab5515
|
|
@ -152,35 +152,57 @@ class CustomSchedule extends Backend
|
||||||
if (empty($params)) {
|
if (empty($params)) {
|
||||||
$this->error(__('Parameter %s can not be empty', ''));
|
$this->error(__('Parameter %s can not be empty', ''));
|
||||||
}
|
}
|
||||||
$params = $this->preExcludeFields($params);
|
|
||||||
|
|
||||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
|
||||||
$params[$this->dataLimitField] = $this->auth->id;
|
|
||||||
}
|
|
||||||
$result = false;
|
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
//是否采用模型验证
|
|
||||||
if ($this->modelValidate) {
|
$dates = [];
|
||||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
||||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
if ($params['period'] == 'month') {
|
||||||
$this->model->validateFailException()->validate($validate);
|
$daysInMonth = date('t'); // 本月天数
|
||||||
|
$month = date('Y-m'); // 当前年月
|
||||||
|
for ($i = 1; $i <= $daysInMonth; $i++) {
|
||||||
|
$dates[] = $month . '-' . str_pad($i, 2, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
} elseif ($params['period'] == 'week') {
|
||||||
|
$start = strtotime('monday this week');
|
||||||
|
for ($i = 0; $i < 7; $i++) {
|
||||||
|
$dates[] = date('Y-m-d', strtotime("+$i day", $start));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$dates = [date('Y-m-d')];
|
||||||
|
}
|
||||||
|
$type = $params['type'];
|
||||||
|
$execAdminIds = explode(',', $params['exec_admin_id']);
|
||||||
|
|
||||||
|
$schedules = [];
|
||||||
|
$nowTime = date('Y-m-d H:i:s');
|
||||||
|
foreach ($execAdminIds as $execAdminId) {
|
||||||
|
foreach ($dates as $date) {
|
||||||
|
$schedules[] = [
|
||||||
|
'admin_id' => $this->auth->id,
|
||||||
|
'exec_admin_id' => $execAdminId,
|
||||||
|
'date' => $date,
|
||||||
|
'type' => $type,
|
||||||
|
"create_time" => $nowTime,
|
||||||
|
"update_time" => $nowTime,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Db::name('schedule')
|
||||||
|
->whereIn('exec_admin_id', $execAdminIds)
|
||||||
|
->whereIn('date', $dates)
|
||||||
|
->delete();
|
||||||
|
|
||||||
$params['create_time'] = date('Y-m-d H:i:s');
|
Db::name('schedule')
|
||||||
$params['update_time'] = date('Y-m-d H:i:s');
|
->insertAll($schedules);
|
||||||
|
|
||||||
|
|
||||||
$result = $this->model->allowField(true)->save($params);
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (ValidateException|PDOException|Exception $e) {
|
} catch (ValidateException|PDOException|Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
$this->error($e->getMessage());
|
$this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($result === false) {
|
|
||||||
$this->error(__('No rows were inserted'));
|
|
||||||
}
|
|
||||||
$this->success();
|
$this->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -273,6 +295,7 @@ class CustomSchedule extends Backend
|
||||||
$nowTime = date('Y-m-d H:i:s');
|
$nowTime = date('Y-m-d H:i:s');
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
$data->save([
|
$data->save([
|
||||||
|
'admin_id' => $this->auth->id,
|
||||||
"date" => $date,
|
"date" => $date,
|
||||||
"exec_admin_id" => $adminId,
|
"exec_admin_id" => $adminId,
|
||||||
"type" => $dbValue,
|
"type" => $dbValue,
|
||||||
|
|
@ -281,6 +304,7 @@ class CustomSchedule extends Backend
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->insert([
|
$this->model->insert([
|
||||||
|
'admin_id' => $this->auth->id,
|
||||||
"date" => $date,
|
"date" => $date,
|
||||||
"exec_admin_id" => $adminId,
|
"exec_admin_id" => $adminId,
|
||||||
"type" => $dbValue,
|
"type" => $dbValue,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,17 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Exec_admin_id')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">{:__('Exec_admin_id')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
<input id="c-exec_admin_id" data-rule="required" data-source="auth/admin/norightselectpage" data-field="nickname" class="form-control selectpage" name="row[exec_admin_id]" type="text" value="">
|
<input id="c-exec_admin_id" data-rule="required" data-multiple="multiple" data-source="auth/admin/norightselectpage" data-field="nickname" class="form-control selectpage" name="row[exec_admin_id]" type="text" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2">周期</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<select id="c-period" data-rule="required" class="form-control selectpicker" name="row[period]">
|
||||||
|
<option value="day">当天</option>
|
||||||
|
<option value="week">本周</option>
|
||||||
|
<option value="month">本月</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -18,12 +28,6 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Date')}:</label>
|
|
||||||
<div class="col-xs-12 col-sm-8">
|
|
||||||
<input id="c-date" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[date]" type="text" value="{:date('Y-m-d')}">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group layer-footer">
|
<div class="form-group layer-footer">
|
||||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,12 @@
|
||||||
<div class="tab-pane fade active in" id="one">
|
<div class="tab-pane fade active in" id="one">
|
||||||
<div class="widget-body no-padding">
|
<div class="widget-body no-padding">
|
||||||
<div id="toolbar" class="toolbar">
|
<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/custom_schedule/edit')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
|
||||||
Table.api.init({
|
Table.api.init({
|
||||||
extend: {
|
extend: {
|
||||||
index_url: 'oa/custom_schedule/index' + location.search,
|
index_url: 'oa/custom_schedule/index' + location.search,
|
||||||
// add_url: 'oa/schedule/add',
|
add_url: 'oa/custom_schedule/add',
|
||||||
editable: 'oa/custom_schedule/editable',
|
editable: 'oa/custom_schedule/editable',
|
||||||
// del_url: 'oa/schedule/del',
|
// del_url: 'oa/schedule/del',
|
||||||
// multi_url: 'oa/schedule/multi',
|
// multi_url: 'oa/schedule/multi',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user