From 3a3cc473c33cb4a97399ace76a1b35e9ffd68525 Mon Sep 17 00:00:00 2001 From: songshankun <songshankun@foxmail.com> Date: 星期一, 20 十一月 2023 16:45:17 +0800 Subject: [PATCH] feat: 无任务选中通道时从p[lc读取统计 --- src/views/dashboard/components/ChannelCollapse.vue | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/views/dashboard/components/ChannelCollapse.vue b/src/views/dashboard/components/ChannelCollapse.vue index 1f483b7..8dda63a 100644 --- a/src/views/dashboard/components/ChannelCollapse.vue +++ b/src/views/dashboard/components/ChannelCollapse.vue @@ -1,19 +1,19 @@ <template> <div class="channel-collapse"> <el-collapse v-model="activeChannel"> - <el-collapse-item - v-for="(channel, channelNumber) in channels" - :key="channelNumber" - :title="CHANNEL_NAME_MAP[channelNumber] + ' 閫氶亾' + ' (' + (channel?.TaskCount ?? 0) + ')'" - :name="String(channelNumber)" - > + <el-collapse-item v-for="(channel, channelNumber) in channels" :key="channelNumber" :name="String(channelNumber)"> + <template #title> + <div style="width: 100%; text-align: left" @click="selectChannel(channelNumber)"> + {{ CHANNEL_NAME_MAP[channelNumber] + ' 閫氶亾' + ' (' + (channel?.TaskCount ?? 0) + ')' }} + </div> + </template> <TaskInfo v-for="task in channel.Tasks" :key="task.Procedure.ID" :active="task.Procedure.ID === tasksStore.activeTask?.Procedure.ID" :task="task" style="margin-bottom: 16px" - @click="tasksStore.setActiveTask(task)" + @click="selectTask(task)" ></TaskInfo> <div @@ -39,11 +39,12 @@ </template> <script setup lang="ts"> import { ref, watchEffect } from 'vue' -import type { TasksGroupByChannel } from '@/api/task' +import type { Task, TasksGroupByChannel } from '@/api/task' import TaskInfo from './TaskInfo.vue' import { CHANNEL_NAME_MAP } from '@/common/constants' import { useTasksStore } from '@/stores/tasks' import { ArrowDownBold, ArrowUpBold } from '@element-plus/icons-vue' +import { isNumber } from 'lodash-es' export interface ChannelCollapseProps { channels: TasksGroupByChannel @@ -59,6 +60,19 @@ const channelNumbers = Object.keys(props?.channels ?? {}).sort((a, b) => +a - +b) activeChannel.value = [...channelNumbers] }) + +function selectChannel(channelNumber: number) { + tasksStore.setActiveTask(undefined) + tasksStore.setActiveChannel(+channelNumber) +} + +function selectTask(task: Task | undefined) { + tasksStore.setActiveTask(task) + let channel = tasksStore?.activeTask?.Channel + if (isNumber(channel)) { + tasksStore.setActiveChannel(channel) + } +} </script> <style scoped lang="scss"> -- Gitblit v1.8.0