perf: 已归档/已删除任务列表支持按状态检索

This commit is contained in:
kuaifan 2025-03-18 12:02:17 +08:00
parent ff2461d89d
commit 7217bd7d1a
3 changed files with 177 additions and 22 deletions

View File

@ -943,6 +943,7 @@ class ProjectController extends AbstractController
* @apiParam {Object} [keys] 搜索条件
* - keys.name: ID、任务名称、任务描述
* - keys.tag: 标签名称
* - keys.status: 任务状态 (completed: 已完成、uncompleted: 未完成、flow-xx: 流程状态ID)
*
* @apiParam {Number} [project_id] 项目ID
* @apiParam {Number} [parent_id] 主任务IDproject_id && parent_id 0 仅查询自己参与的任务)
@ -1006,6 +1007,20 @@ class ProjectController extends AbstractController
$query->where('project_task_tags.name', $keys['tag']);
});
}
if ($keys['status']) {
if ($keys['status'] == 'completed') {
$builder->whereNotNull('project_tasks.complete_at');
} elseif ($keys['status'] == 'uncompleted') {
$builder->whereNull('project_tasks.complete_at');
} elseif (str_starts_with($keys['status'], 'flow-')) {
$flow = str_replace('flow-', '', $keys['status']);
if (Base::isNumber($flow)) {
$builder->where('project_tasks.flow_item_id', intval($flow));
} elseif ($flow) {
$builder->where('project_tasks.flow_item_name', 'like', "%{$flow}%");
}
}
}
//
$scopeAll = false;
if ($parent_id > 0) {

View File

@ -16,7 +16,20 @@
<Input v-model="keys.name" :placeholder="$L('ID、名称、描述...')" clearable/>
</div>
</li>
<li v-if="tags.length > 0">
<li>
<div class="search-label">
{{$L("任务状态")}}
</div>
<div class="search-content">
<Select v-model="keys.status" :placeholder="$L('全部')">
<Option value="">{{$L('全部')}}</Option>
<Option v-for="flow in flows" :key="flow.id" :value="flow.id" :label="flow.name">
<div class="tag-dot" :class="flow.status">{{flow.name}}</div>
</Option>
</Select>
</div>
</li>
<li>
<div class="search-label">
{{$L("任务标签")}}
</div>
@ -117,6 +130,22 @@ export default {
}, row.name);
}
},
{
title: this.$L('任务状态'),
key: 'status',
minWidth: 100,
render: (h, {row}) => {
let flow_item_name = row.flow_item_name;
if (flow_item_name && flow_item_name.indexOf("|") !== -1) {
[, flow_item_name] = flow_item_name.split("|")
} else if (row.complete_at) {
flow_item_name = this.$L('已完成');
} else {
flow_item_name = this.$L('未完成');
}
return h('AutoTip', flow_item_name);
}
},
{
title: this.$L('任务标签'),
key: 'tags',
@ -125,13 +154,7 @@ export default {
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('、'));
return h('AutoTip', row.task_tag.map(({name}) => name).join('、'));
}
},
{
@ -285,6 +308,7 @@ export default {
],
list: [],
flowList: [],
tags: [],
page: 1,
@ -294,10 +318,39 @@ export default {
}
},
mounted() {
this.loadTags()
this.getFlowData()
this.getTagData()
},
computed: {
...mapState(['cacheTasks'])
...mapState(['cacheTasks']),
flows({flowList}) {
const list = [
{
id: 'completed',
name: this.$L('已完成'),
status: 'completed',
label: this.$L('已完成'),
},
{
id: 'uncompleted',
name: this.$L('未完成'),
status: 'uncompleted',
label: this.$L('未完成'),
}
];
flowList.forEach(item1 => {
item1.project_flow_item.forEach(item2 => {
const label = flowList.length > 1 ? item1.name + ' - ' + item2.name : item2.name;
list.push({
...item2,
id: 'flow-' + item2.id,
label,
})
})
});
return list;
}
},
watch: {
projectId: {
@ -319,7 +372,24 @@ export default {
this.getLists();
},
async loadTags() {
async getFlowData() {
let flowList = [];
const project_id = this.projectId
try {
const {data} = await this.$store.dispatch("call", {
url: 'project/flow/list',
data: {project_id},
})
flowList = data || []
} catch (e) {
flowList = [];
}
if (project_id === this.projectId) {
this.flowList = flowList
}
},
async getTagData() {
let tags = [];
const project_id = this.projectId
try {

View File

@ -16,7 +16,20 @@
<Input v-model="keys.name" :placeholder="$L('ID、名称、描述...')" clearable/>
</div>
</li>
<li v-if="tags.length > 0">
<li>
<div class="search-label">
{{$L("任务状态")}}
</div>
<div class="search-content">
<Select v-model="keys.status" :placeholder="$L('全部')">
<Option value="">{{$L('全部')}}</Option>
<Option v-for="flow in flows" :key="flow.id" :value="flow.id" :label="flow.name">
<div class="tag-dot" :class="flow.status">{{flow.name}}</div>
</Option>
</Select>
</div>
</li>
<li>
<div class="search-label">
{{$L("任务标签")}}
</div>
@ -111,6 +124,22 @@ export default {
return h('AutoTip', row.name);
}
},
{
title: this.$L('任务状态'),
key: 'status',
minWidth: 100,
render: (h, {row}) => {
let flow_item_name = row.flow_item_name;
if (flow_item_name && flow_item_name.indexOf("|") !== -1) {
[, flow_item_name] = flow_item_name.split("|")
} else if (row.complete_at) {
flow_item_name = this.$L('已完成');
} else {
flow_item_name = this.$L('未完成');
}
return h('AutoTip', flow_item_name);
}
},
{
title: this.$L('任务标签'),
key: 'tags',
@ -119,13 +148,7 @@ export default {
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('、'));
return h('AutoTip', row.task_tag.map(({name}) => name).join('、'));
}
},
{
@ -192,6 +215,7 @@ export default {
],
list: [],
flowList: [],
tags: [],
page: 1,
@ -201,10 +225,39 @@ export default {
}
},
mounted() {
this.loadTags()
this.getFlowData()
this.getTagData()
},
computed: {
...mapState(['cacheTasks'])
...mapState(['cacheTasks']),
flows({flowList}) {
const list = [
{
id: 'completed',
name: this.$L('已完成'),
status: 'completed',
label: this.$L('已完成'),
},
{
id: 'uncompleted',
name: this.$L('未完成'),
status: 'uncompleted',
label: this.$L('未完成'),
}
];
flowList.forEach(item1 => {
item1.project_flow_item.forEach(item2 => {
const label = flowList.length > 1 ? item1.name + ' - ' + item2.name : item2.name;
list.push({
...item2,
id: 'flow-' + item2.id,
label,
})
})
});
return list;
}
},
watch: {
projectId: {
@ -226,7 +279,24 @@ export default {
this.getLists();
},
async loadTags() {
async getFlowData() {
let flowList = [];
const project_id = this.projectId
try {
const {data} = await this.$store.dispatch("call", {
url: 'project/flow/list',
data: {project_id},
})
flowList = data || []
} catch (e) {
flowList = [];
}
if (project_id === this.projectId) {
this.flowList = flowList
}
},
async getTagData() {
let tags = [];
const project_id = this.projectId
try {