增加工时
Signed-off-by: vilson <545522390@qq.com>
This commit is contained in:
parent
013ea28608
commit
2a1a3865dc
@ -124,6 +124,9 @@ class Task extends CommonModel
|
|||||||
$type = 'clearEndTime';
|
$type = 'clearEndTime';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($data['work_time'])) {
|
||||||
|
$type = 'setWorkTime';
|
||||||
|
}
|
||||||
$type && self::taskHook($member['code'], $code, $type);
|
$type && self::taskHook($member['code'], $code, $type);
|
||||||
//TODO 任务动态
|
//TODO 任务动态
|
||||||
return $result;
|
return $result;
|
||||||
|
62
application/common/Model/TaskWorkTime.php
Normal file
62
application/common/Model/TaskWorkTime.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\Model;
|
||||||
|
|
||||||
|
use think\db\exception\DataNotFoundException;
|
||||||
|
use think\db\exception\ModelNotFoundException;
|
||||||
|
use think\exception\DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务工时
|
||||||
|
* Class TaskLike
|
||||||
|
* @package app\common\Model
|
||||||
|
*/
|
||||||
|
class TaskWorkTime extends CommonModel
|
||||||
|
{
|
||||||
|
protected $append = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建工时
|
||||||
|
* @param $taskCode
|
||||||
|
* @param $memberCode
|
||||||
|
* @param $num
|
||||||
|
* @param $beginTime
|
||||||
|
* @param string $content
|
||||||
|
* @return array
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
*/
|
||||||
|
public static function createData($taskCode, $memberCode, $num, $beginTime, $content = '')
|
||||||
|
{
|
||||||
|
if (!$taskCode) {
|
||||||
|
return error(1, '请选择任务');
|
||||||
|
}
|
||||||
|
$task = Task::where(['code' => $taskCode, 'deleted' => 0])->field('id')->find();
|
||||||
|
if (!$task) {
|
||||||
|
return error(2, '该任务已失效');
|
||||||
|
}
|
||||||
|
if (!$memberCode) {
|
||||||
|
return error(3, '请指定成员');
|
||||||
|
}
|
||||||
|
if (!$beginTime) {
|
||||||
|
return error(4, '请选择开始时间');
|
||||||
|
}
|
||||||
|
if (!$num || !is_numeric($num)) {
|
||||||
|
return error(5, '请输入有效工时');
|
||||||
|
}
|
||||||
|
$data = [
|
||||||
|
'create_time' => nowTime(),
|
||||||
|
'code' => createUniqueCode('TaskWorkTime'),
|
||||||
|
'task_code' => $taskCode,
|
||||||
|
'num' => $num,
|
||||||
|
'content' => $content,
|
||||||
|
'begin_time' => $beginTime,
|
||||||
|
'member_code' => $memberCode,
|
||||||
|
];
|
||||||
|
$result = self::create($data)->toArray();
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -156,6 +156,10 @@ class Task
|
|||||||
$icon = 'undo';
|
$icon = 'undo';
|
||||||
$remark = '恢复了任务 ';
|
$remark = '恢复了任务 ';
|
||||||
break;
|
break;
|
||||||
|
case 'setWorkTime':
|
||||||
|
$icon = 'clock-circle';
|
||||||
|
$remark = '更新预估工时为 ' .$task['work_time'];
|
||||||
|
break;
|
||||||
case 'linkFile':
|
case 'linkFile':
|
||||||
$icon = 'link';
|
$icon = 'link';
|
||||||
$remark = '关联了文件 ';
|
$remark = '关联了文件 ';
|
||||||
|
@ -7,6 +7,7 @@ use app\common\Model\Member;
|
|||||||
use app\common\Model\MemberAccount;
|
use app\common\Model\MemberAccount;
|
||||||
use app\common\Model\Notify;
|
use app\common\Model\Notify;
|
||||||
use app\common\Model\ProjectCollection;
|
use app\common\Model\ProjectCollection;
|
||||||
|
use app\common\Model\ProjectLog;
|
||||||
use app\common\Model\ProjectMember;
|
use app\common\Model\ProjectMember;
|
||||||
use app\common\Model\SystemConfig;
|
use app\common\Model\SystemConfig;
|
||||||
use controller\BasicApi;
|
use controller\BasicApi;
|
||||||
@ -212,7 +213,7 @@ class Project extends BasicApi
|
|||||||
*/
|
*/
|
||||||
public function edit(Request $request)
|
public function edit(Request $request)
|
||||||
{
|
{
|
||||||
$data = $request::only('name,description,cover,private,prefix,open_prefix,schedule,open_begin_time,open_task_private,task_board_theme');
|
$data = $request::only('name,description,cover,private,prefix,open_prefix,schedule,open_begin_time,open_task_private,task_board_theme,begin_time,end_time');
|
||||||
$code = $request::param('projectCode');
|
$code = $request::param('projectCode');
|
||||||
try {
|
try {
|
||||||
$result = $this->model->edit($code, $data);
|
$result = $this->model->edit($code, $data);
|
||||||
@ -286,6 +287,60 @@ class Project extends BasicApi
|
|||||||
$this->success('', $list);
|
$this->success('', $list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 概览报表
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function _projectStats()
|
||||||
|
{
|
||||||
|
$projectCode = Request::param('projectCode');
|
||||||
|
if (!$projectCode) {
|
||||||
|
$this->error('项目已失效');
|
||||||
|
}
|
||||||
|
$project = \app\common\Model\Project::where(['code' => $projectCode])->find();
|
||||||
|
if (!$project) {
|
||||||
|
$this->error('项目已失效');
|
||||||
|
}
|
||||||
|
$taskStats = [
|
||||||
|
'total' => 0,
|
||||||
|
'unDone' => 0,
|
||||||
|
'done' => 0,
|
||||||
|
'overdue' => 0,
|
||||||
|
'toBeAssign' => 0,
|
||||||
|
'expireToday' => 0,
|
||||||
|
'doneOverdue' => 0,
|
||||||
|
];
|
||||||
|
$taskList = \app\common\Model\Task::where(['project_code' => $projectCode, 'deleted' => 0])->select()->toArray();
|
||||||
|
$taskStats['total'] = count($taskList);
|
||||||
|
if ($taskList) {
|
||||||
|
$today = date('Y-m-d 00:00', time());
|
||||||
|
$tomorrow = date('Y-m-d 00:00', strtotime($today) + 3600 * 24);
|
||||||
|
foreach ($taskList as $item) {
|
||||||
|
!$item['assign_to'] && $taskStats['toBeAssign']++;
|
||||||
|
$item['done'] && $taskStats['done']++;
|
||||||
|
!$item['done'] && $taskStats['unDone']++;
|
||||||
|
if ($item['end_time']) {
|
||||||
|
if (!$item['done']) {
|
||||||
|
$item['end_time'] < nowTime() && $taskStats['overdue']++;
|
||||||
|
if ($item['end_time'] >= $today && $item['end_time'] < $tomorrow) {
|
||||||
|
$taskStats['doneOverdue']++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$log = ProjectLog::where(['action_type' => 'task', 'source_code' => $item['code'], 'type' => 'done'])->order('id desc')->find();
|
||||||
|
if ($log && $log['create_time'] > $item['end_time']) {
|
||||||
|
$taskStats['doneOverdue']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->success('', $taskStats);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传封面
|
* 上传封面
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,7 @@ use app\common\Model\Member;
|
|||||||
use app\common\Model\ProjectLog;
|
use app\common\Model\ProjectLog;
|
||||||
use app\common\Model\TaskTag;
|
use app\common\Model\TaskTag;
|
||||||
use app\common\Model\TaskToTag;
|
use app\common\Model\TaskToTag;
|
||||||
|
use app\common\Model\TaskWorkTime;
|
||||||
use controller\BasicApi;
|
use controller\BasicApi;
|
||||||
use Exception;
|
use Exception;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
@ -287,7 +288,7 @@ class Task extends BasicApi
|
|||||||
*/
|
*/
|
||||||
public function edit(Request $request)
|
public function edit(Request $request)
|
||||||
{
|
{
|
||||||
$data = $request::only('name,sort,end_time,begin_time,pri,description');
|
$data = $request::only('name,sort,end_time,begin_time,pri,description,work_time');
|
||||||
$code = $request::post('taskCode');
|
$code = $request::post('taskCode');
|
||||||
if (!$code) {
|
if (!$code) {
|
||||||
$this->error("请选择一个任务");
|
$this->error("请选择一个任务");
|
||||||
@ -463,6 +464,60 @@ class Task extends BasicApi
|
|||||||
$this->success('', $list);
|
$this->success('', $list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function _taskWorkTimeList()
|
||||||
|
{
|
||||||
|
$taskCode = Request::param('taskCode');
|
||||||
|
$workTimeList = TaskWorkTime::where(['task_code' => $taskCode])->select()->toArray();
|
||||||
|
if ($workTimeList) {
|
||||||
|
foreach ($workTimeList as &$workTime) {
|
||||||
|
$member = Member::where(['code' => $workTime['member_code']])->field('avatar,name')->find();
|
||||||
|
$workTime['member'] = $member;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->success('', $workTimeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveTaskWorkTime()
|
||||||
|
{
|
||||||
|
$param = Request::only('beginTime,num,content,taskCode');
|
||||||
|
$result = TaskWorkTime::createData($param['taskCode'], getCurrentMember()['code'], $param['num'], $param['beginTime'], $param['content']);
|
||||||
|
if (isError($result)) {
|
||||||
|
$this->error($result['msg'], $result['errno']);
|
||||||
|
}
|
||||||
|
$this->success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editTaskWorkTime()
|
||||||
|
{
|
||||||
|
$param = Request::only('beginTime,num,content');
|
||||||
|
$code = Request::param('code');
|
||||||
|
if ($code) {
|
||||||
|
$workTime = TaskWorkTime::where(['code' => $code])->find();
|
||||||
|
if (!$workTime) {
|
||||||
|
return error(1, '该记录已失效');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($param['beginTime'])) {
|
||||||
|
$param['begin_time'] = $param['beginTime'];
|
||||||
|
unset($param['beginTime']);
|
||||||
|
}
|
||||||
|
$result = TaskWorkTime::update($param, ['code' => $code]);
|
||||||
|
$this->success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delTaskWorkTime()
|
||||||
|
{
|
||||||
|
$code = Request::param('code');
|
||||||
|
if ($code) {
|
||||||
|
$workTime = TaskWorkTime::where(['code' => $code])->find();
|
||||||
|
if (!$workTime) {
|
||||||
|
return error(1, '该记录已失效');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$result = TaskWorkTime::destroy(['code' => $code]);
|
||||||
|
$this->success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载导入任务模板
|
* 下载导入任务模板
|
||||||
@ -478,7 +533,7 @@ class Task extends BasicApi
|
|||||||
public function uploadFile()
|
public function uploadFile()
|
||||||
{
|
{
|
||||||
$projectCode = Request::param('projectCode');
|
$projectCode = Request::param('projectCode');
|
||||||
$count = $this->model->uploadFile(Request::file('file'), $projectCode,getCurrentMember()['code']);
|
$count = $this->model->uploadFile(Request::file('file'), $projectCode, getCurrentMember()['code']);
|
||||||
if (isError($count)) {
|
if (isError($count)) {
|
||||||
$this->error($count['msg']);
|
$this->error($count['msg']);
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use think\facade\Route;
|
|
||||||
/* 演示环境禁止操作路由 */
|
|
||||||
Route::post('project/menu/menuForbid', function () {
|
|
||||||
return json(['code' => 404, 'msg' => '演示环境禁修改菜单权限!']);
|
|
||||||
});
|
|
||||||
Route::post('project/menu/menuEdit', function () {
|
|
||||||
return json(['code' => 404, 'msg' => '演示环境禁修改菜单权限!']);
|
|
||||||
});
|
|
||||||
Route::post('project/menu/menuDel', function () {
|
|
||||||
return json(['code' => 404, 'msg' => '演示环境禁修改菜单权限!']);
|
|
||||||
});
|
|
||||||
Route::post('project/index/editPassword', function () {
|
|
||||||
return json(['code' => 404, 'msg' => '演示环境禁修改密码!']);
|
|
||||||
});
|
|
||||||
//Route::post('project/account/del', function () {
|
|
||||||
// return json(['code' => 404, 'msg' => '演示环境禁修改账号!']);
|
|
||||||
//});
|
|
||||||
return [];
|
|
Loading…
x
Reference in New Issue
Block a user