From 8174d4b6b32249232e5ac964a98631d8e569626a Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 15 Jun 2021 18:21:21 +0800 Subject: [PATCH] no message --- .../Controllers/Api/ProjectController.php | 41 ++++++ app/Models/ProjectLog.php | 30 +++++ .../js/pages/manage/components/ProjectLog.vue | 126 ++++++++++++++++++ .../js/pages/manage/components/TaskDetail.vue | 30 +++-- resources/assets/js/store/actions.js | 4 +- resources/assets/sass/pages/components/_.scss | 1 + .../sass/pages/components/dialog-wrapper.scss | 3 +- .../sass/pages/components/project-log.scss | 79 +++++++++++ .../sass/pages/components/task-detail.scss | 32 ++++- 9 files changed, 328 insertions(+), 18 deletions(-) create mode 100644 resources/assets/js/pages/manage/components/ProjectLog.vue create mode 100644 resources/assets/sass/pages/components/project-log.scss diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php index 7c20c9cd..2e88cb46 100755 --- a/app/Http/Controllers/Api/ProjectController.php +++ b/app/Http/Controllers/Api/ProjectController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api; use App\Models\AbstractModel; use App\Models\Project; use App\Models\ProjectColumn; +use App\Models\ProjectLog; use App\Models\ProjectTask; use App\Models\ProjectTaskFile; use App\Models\ProjectUser; @@ -798,4 +799,44 @@ class ProjectController extends AbstractController // return $task->deleteTask(); } + + /** + * 获取项目、任务日志 + * + * @apiParam {Number} project_id 项目ID + * @apiParam {Number} task_id 任务ID(与 项目ID 二选一,任务ID优先) + * + * @apiParam {Number} [page] 当前页,默认:1 + * @apiParam {Number} [pagesize] 每页显示数量,默认:20,最大:100 + */ + public function log__lists() + { + user::auth(); + // + $project_id = intval(Request::input('project_id')); + $task_id = intval(Request::input('task_id')); + // + $builder = ProjectLog::with(['user']); + if ($task_id > 0) { + $task = ProjectTask::userTask($task_id); + $builder->whereTaskId($task->id); + } else { + $project = Project::userProject($project_id); + $builder->whereTaskId($project->id); + } + // + $list = $builder->orderByDesc('created_at')->paginate(Base::getPaginate(100, 20)); + $list->transform(function (ProjectLog $log) { + $timestamp = Carbon::parse($log->created_at)->timestamp; + $log->time = [ + 'ymd' => date(date("Y", $timestamp) == date("Y", Base::time()) ? "m-d" : "Y-m-d", $timestamp), + 'hi' => date("h:i", $timestamp) , + 'week' => "周" . Base::getTimeWeek($timestamp), + 'segment' => Base::getTimeDayeSegment($timestamp), + ]; + return $log; + }); + // + return Base::retSuccess('success', $list); + } } diff --git a/app/Models/ProjectLog.php b/app/Models/ProjectLog.php index 96b6b449..d0047f67 100644 --- a/app/Models/ProjectLog.php +++ b/app/Models/ProjectLog.php @@ -4,9 +4,39 @@ namespace App\Models; /** * Class ProjectLog + * * @package App\Models + * @property int $id + * @property int|null $project_id 项目ID + * @property int|null $column_id 列表ID + * @property int|null $task_id 项目ID + * @property int|null $userid 会员ID + * @property string|null $detail 详细信息 + * @property \Illuminate\Support\Carbon|null $created_at + * @property \Illuminate\Support\Carbon|null $updated_at + * @property-read \App\Models\User|null $user + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog newModelQuery() + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog newQuery() + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog query() + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog whereColumnId($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog whereCreatedAt($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog whereDetail($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog whereId($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog whereProjectId($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog whereTaskId($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog whereUpdatedAt($value) + * @method static \Illuminate\Database\Eloquent\Builder|ProjectLog whereUserid($value) + * @mixin \Eloquent */ class ProjectLog extends AbstractModel { + /** + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function user(): \Illuminate\Database\Eloquent\Relations\HasOne + { + return $this->hasOne(User::class, 'userid', 'userid'); + } + } diff --git a/resources/assets/js/pages/manage/components/ProjectLog.vue b/resources/assets/js/pages/manage/components/ProjectLog.vue new file mode 100644 index 00000000..b9023b52 --- /dev/null +++ b/resources/assets/js/pages/manage/components/ProjectLog.vue @@ -0,0 +1,126 @@ + + + diff --git a/resources/assets/js/pages/manage/components/TaskDetail.vue b/resources/assets/js/pages/manage/components/TaskDetail.vue index a7a5f779..8fc2d31a 100644 --- a/resources/assets/js/pages/manage/components/TaskDetail.vue +++ b/resources/assets/js/pages/manage/components/TaskDetail.vue @@ -330,24 +330,28 @@
- -
- -