diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php index 38773b888..e6e12d9c5 100755 --- a/app/Http/Controllers/Api/ProjectController.php +++ b/app/Http/Controllers/Api/ProjectController.php @@ -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] 主任务ID(project_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) { diff --git a/resources/assets/js/pages/manage/components/TaskArchived.vue b/resources/assets/js/pages/manage/components/TaskArchived.vue index 4b29a3f0b..41764e65d 100644 --- a/resources/assets/js/pages/manage/components/TaskArchived.vue +++ b/resources/assets/js/pages/manage/components/TaskArchived.vue @@ -16,7 +16,20 @@ -
  • +
  • +
    + {{$L("任务状态")}} +
    +
    + +
    +
  • +
  • {{$L("任务标签")}}
    @@ -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 { diff --git a/resources/assets/js/pages/manage/components/TaskDeleted.vue b/resources/assets/js/pages/manage/components/TaskDeleted.vue index 209f4a114..95bd1098e 100644 --- a/resources/assets/js/pages/manage/components/TaskDeleted.vue +++ b/resources/assets/js/pages/manage/components/TaskDeleted.vue @@ -16,7 +16,20 @@
  • -
  • +
  • +
    + {{$L("任务状态")}} +
    +
    + +
    +
  • +
  • {{$L("任务标签")}}
    @@ -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 {