From e52d066fb06e4f9418a3b0d47f4d966b692cf13d Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 28 Feb 2025 21:04:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=BD=92=E6=A1=A3=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=89=E6=A0=87=E7=AD=BE=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/ProjectController.php | 13 +++- .../pages/manage/components/TaskArchived.vue | 63 +++++++++++++++++-- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php index 58510c51b..14fca7408 100755 --- a/app/Http/Controllers/Api/ProjectController.php +++ b/app/Http/Controllers/Api/ProjectController.php @@ -941,7 +941,8 @@ class ProjectController extends AbstractController * @apiName task__lists * * @apiParam {Object} [keys] 搜索条件 - * - keys.name: ID、任务名称 + * - keys.name: ID、任务名称、任务描述 + * - keys.tag: 标签名称 * * @apiParam {Number} [project_id] 项目ID * @apiParam {Number} [parent_id] 主任务ID(project_id && parent_id ≤ 0 时 仅查询自己参与的任务) @@ -994,9 +995,17 @@ class ProjectController extends AbstractController if (Base::isNumber($keys['name'])) { $builder->where("project_tasks.id", intval($keys['name'])); } else { - $builder->where("project_tasks.name", "like", "%{$keys['name']}%"); + $builder->where(function ($query) use ($keys) { + $query->where("project_tasks.name", "like", "%{$keys['name']}%"); + $query->orWhere("project_tasks.desc", "like", "%{$keys['name']}%"); + }); } } + if ($keys['tag']) { + $builder->whereHas('taskTag', function ($query) use ($keys) { + $query->where('project_task_tags.name', $keys['tag']); + }); + } // $scopeAll = false; if ($parent_id > 0) { diff --git a/resources/assets/js/pages/manage/components/TaskArchived.vue b/resources/assets/js/pages/manage/components/TaskArchived.vue index 910bcbaea..4b29a3f0b 100644 --- a/resources/assets/js/pages/manage/components/TaskArchived.vue +++ b/resources/assets/js/pages/manage/components/TaskArchived.vue @@ -13,7 +13,22 @@ {{$L("关键词")}}
- + +
+ +
  • +
    + {{$L("任务标签")}} +
    +
    +
  • @@ -102,6 +117,23 @@ export default { }, row.name); } }, + { + title: this.$L('任务标签'), + key: 'tags', + minWidth: 100, + render: (h, {row}) => { + if (row.task_tag.length == 0) { + return h('div', '-'); + } + return h('AutoTip', { + on: { + 'on-click': () => { + this.$store.dispatch("openTask", row); + } + } + }, row.task_tag.map(({name}) => name).join('、')); + } + }, { title: this.$L('完成时间'), key: 'complete_at', @@ -139,7 +171,7 @@ export default { { title: this.$L('操作'), align: 'center', - width: 100, + width: 120, render: (h, params) => { if (this.cacheTasks.find(task => task.id == params.row.id && !task.archived_at)) { return h('div', { @@ -211,14 +243,14 @@ export default { }) } }, - }, - [ + }, + [ params.row.__restorePoptipLoadIng ? h('Loading', { style: { width: '26px', height: '15px', }, - }) : this.$L('还原') + }) : this.$L('还原') ]) ]), h('Poptip', { @@ -253,6 +285,8 @@ export default { ], list: [], + tags: [], + page: 1, pageSize: 20, total: 0, @@ -260,7 +294,7 @@ export default { } }, mounted() { - + this.loadTags() }, computed: { ...mapState(['cacheTasks']) @@ -285,6 +319,23 @@ export default { this.getLists(); }, + async loadTags() { + let tags = []; + const project_id = this.projectId + try { + const {data} = await this.$store.dispatch("call", { + url: 'project/tag/list', + data: {project_id}, + }) + tags = data || [] + } catch (e) { + tags = []; + } + if (project_id === this.projectId) { + this.tags = tags + } + }, + getLists() { if (!this.projectId) { return;