mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 20:12:48 +00:00
perf: 归档任务支持按标签搜索
This commit is contained in:
parent
5279d57018
commit
e52d066fb0
@ -941,7 +941,8 @@ class ProjectController extends AbstractController
|
|||||||
* @apiName task__lists
|
* @apiName task__lists
|
||||||
*
|
*
|
||||||
* @apiParam {Object} [keys] 搜索条件
|
* @apiParam {Object} [keys] 搜索条件
|
||||||
* - keys.name: ID、任务名称
|
* - keys.name: ID、任务名称、任务描述
|
||||||
|
* - keys.tag: 标签名称
|
||||||
*
|
*
|
||||||
* @apiParam {Number} [project_id] 项目ID
|
* @apiParam {Number} [project_id] 项目ID
|
||||||
* @apiParam {Number} [parent_id] 主任务ID(project_id && parent_id ≤ 0 时 仅查询自己参与的任务)
|
* @apiParam {Number} [parent_id] 主任务ID(project_id && parent_id ≤ 0 时 仅查询自己参与的任务)
|
||||||
@ -994,9 +995,17 @@ class ProjectController extends AbstractController
|
|||||||
if (Base::isNumber($keys['name'])) {
|
if (Base::isNumber($keys['name'])) {
|
||||||
$builder->where("project_tasks.id", intval($keys['name']));
|
$builder->where("project_tasks.id", intval($keys['name']));
|
||||||
} else {
|
} 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;
|
$scopeAll = false;
|
||||||
if ($parent_id > 0) {
|
if ($parent_id > 0) {
|
||||||
|
|||||||
@ -13,7 +13,22 @@
|
|||||||
{{$L("关键词")}}
|
{{$L("关键词")}}
|
||||||
</div>
|
</div>
|
||||||
<div class="search-content">
|
<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>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="search-button">
|
<li class="search-button">
|
||||||
@ -102,6 +117,23 @@ export default {
|
|||||||
}, row.name);
|
}, 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('完成时间'),
|
title: this.$L('完成时间'),
|
||||||
key: 'complete_at',
|
key: 'complete_at',
|
||||||
@ -139,7 +171,7 @@ export default {
|
|||||||
{
|
{
|
||||||
title: this.$L('操作'),
|
title: this.$L('操作'),
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 100,
|
width: 120,
|
||||||
render: (h, params) => {
|
render: (h, params) => {
|
||||||
if (this.cacheTasks.find(task => task.id == params.row.id && !task.archived_at)) {
|
if (this.cacheTasks.find(task => task.id == params.row.id && !task.archived_at)) {
|
||||||
return h('div', {
|
return h('div', {
|
||||||
@ -211,14 +243,14 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
params.row.__restorePoptipLoadIng ? h('Loading', {
|
params.row.__restorePoptipLoadIng ? h('Loading', {
|
||||||
style: {
|
style: {
|
||||||
width: '26px',
|
width: '26px',
|
||||||
height: '15px',
|
height: '15px',
|
||||||
},
|
},
|
||||||
}) : this.$L('还原')
|
}) : this.$L('还原')
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
h('Poptip', {
|
h('Poptip', {
|
||||||
@ -253,6 +285,8 @@ export default {
|
|||||||
],
|
],
|
||||||
list: [],
|
list: [],
|
||||||
|
|
||||||
|
tags: [],
|
||||||
|
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
total: 0,
|
total: 0,
|
||||||
@ -260,7 +294,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.loadTags()
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['cacheTasks'])
|
...mapState(['cacheTasks'])
|
||||||
@ -285,6 +319,23 @@ export default {
|
|||||||
this.getLists();
|
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() {
|
getLists() {
|
||||||
if (!this.projectId) {
|
if (!this.projectId) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user