charles
2024-04-29 b95cf940af8e01e4eca30b2599b029c2f645bd1e
src/views/dashboard/components/ChannelCollapse.vue
@@ -45,6 +45,9 @@
import { useTasksStore } from '@/stores/tasks'
import { ArrowDownBold, ArrowUpBold } from '@element-plus/icons-vue'
import { isNumber } from 'lodash-es'
import { getTaskInfo } from '@/api'
import type { TaskInfoParams } from '@/api'
import { storeToRefs } from 'pinia'
export interface ChannelCollapseProps {
  channels: TasksGroupByChannel
@@ -54,6 +57,7 @@
const activeChannel = ref<string[]>([])
const tasksStore = useTasksStore()
const { activeTask } = storeToRefs(tasksStore)
watchEffect(() => {
  // 通道数据变化后
@@ -67,11 +71,26 @@
}
function selectTask(task: Task | undefined) {
  tasksStore.setActiveTask(task)
  let channel = tasksStore?.activeTask?.Channel
  if (isNumber(channel)) {
    tasksStore.setActiveChannel(channel)
  console.log(task, 'iiiiiii')
  const params: TaskInfoParams = {
    deviceID: localStorage.getItem('currentDeviceID') || '',
    procedureID: Number(task?.Procedure.ID)
  }
  return getTaskInfo(params)
    .then((res) => {
      tasksStore.setActiveTask(res.data)
      let channel = tasksStore?.activeTask?.Channel
      if (isNumber(channel)) {
        tasksStore.setActiveChannel(channel)
      }
      // taskStore.activeTask?.value = res.data
    })
    .catch((err) => {
      console.error(err)
    })
    .finally(() => {})
  // tasksStore.setActiveTask(task)
}
</script>