perf: 归档任务支持按标签搜索

This commit is contained in:
kuaifan 2025-02-28 21:04:34 +08:00
parent 5279d57018
commit e52d066fb0
2 changed files with 68 additions and 8 deletions

View File

@ -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] 主任务IDproject_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) {

View File

@ -13,7 +13,22 @@
{{$L("关键词")}}
</div>
<div class="search-content">
<Input v-model="keys.name" :placeholder="$L('ID、任务名...')" clearable/>
<Input v-model="keys.name" :placeholder="$L('ID、名称、描述...')" clearable/>
</div>
</li>
<li v-if="tags.length > 0">
<div class="search-label">
{{$L("任务标签")}}
</div>
<div class="search-content">
<Select v-model="keys.tag" :placeholder="$L('全部')">
<Option value="">{{$L('全部')}}</Option>
<Option v-for="tag in tags" :key="tag.id" :value="tag.name" :label="tag.name">
<div class="tag-dot" :style="{'--bg-color': tag.color}">
{{tag.name}}
</div>
</Option>
</Select>
</div>
</li>
<li class="search-button">
@ -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;