From 1c22b65361d81ef23bd76d0f76a3dce7ef72fd99 Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期二, 31 十月 2023 10:06:56 +0800 Subject: [PATCH] 拉代码 --- src/views/dashboard/components/ChannelCollapse.vue | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/views/dashboard/components/ChannelCollapse.vue b/src/views/dashboard/components/ChannelCollapse.vue index 693ab61..bde2dd9 100644 --- a/src/views/dashboard/components/ChannelCollapse.vue +++ b/src/views/dashboard/components/ChannelCollapse.vue @@ -2,35 +2,61 @@ <div class="channel-collapse"> <el-collapse v-model="activeChannel"> <el-collapse-item - v-for="(tasks, channelNumber) in channels" + v-for="(channel, channelNumber) in channels" :key="channelNumber" :title="CHANNEL_NAME_MAP[channelNumber] + ' 閫氶亾'" :name="String(channelNumber)" > - <TaskInfo v-for="task in tasks" :key="task.Procedure.ID" :task="task"></TaskInfo> + <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)" + ></TaskInfo> + + <div + v-show="channel.Tasks?.length && tasksStore.moreBtnStatus?.[channelNumber]" + class="btn more" + @click="tasksStore.moreChannelTasksBtn(channelNumber)" + > + 鏌ョ湅鏇村 + <el-icon style="margin-left: 6px"><ArrowDownBold /></el-icon> + </div> + + <div + v-show="channel.Tasks?.length && !tasksStore.moreBtnStatus?.[channelNumber]" + class="btn fold" + @click="tasksStore.foldChannelTasksBtn(channelNumber)" + > + 鏀惰捣 + <el-icon style="margin-left: 6px"><ArrowUpBold /></el-icon> + </div> </el-collapse-item> </el-collapse> </div> </template> <script setup lang="ts"> import { ref, watchEffect } from 'vue' -import type { Task } from '@/api/task' +import type { TasksGroupByChannel } from '@/api/task' import TaskInfo from './TaskInfo.vue' import { CHANNEL_NAME_MAP } from '@/common/constants' - -export interface Channel { - [channelNumber: number]: Task[] -} +import { useTasksStore } from '@/stores/tasks' +import { ArrowDownBold, ArrowUpBold } from '@element-plus/icons-vue' export interface ChannelCollapseProps { - channels: Channel + channels: TasksGroupByChannel } const props = defineProps<ChannelCollapseProps>() const activeChannel = ref<string[]>([]) +const tasksStore = useTasksStore() + watchEffect(() => { - const channelNumbers = Object.keys(props.channels).sort((a, b) => +a - +b) + // 閫氶亾鏁版嵁鍙樺寲鍚� + const channelNumbers = Object.keys(props?.channels ?? {}).sort((a, b) => +a - +b) activeChannel.value = [...channelNumbers] }) </script> @@ -66,4 +92,18 @@ font-size: 16px; font-weight: 600; } + +.btn { + width: 70%; + height: 50px; + margin: 0 auto; + display: flex; + align-items: center; + justify-content: center; + border-radius: 6px; + font-size: 18px; + font-weight: 600; + cursor: pointer; + background: linear-gradient(to right, rgb(29, 96, 212) 0%, rgb(47, 122, 251), rgb(29, 96, 212) 100%); +} </style> -- Gitblit v1.8.0