src/stores/tasks.ts
@@ -1,8 +1,8 @@
import { computed, ref } from 'vue'
import { defineStore } from 'pinia'
import type { Task, TasksGroupByChannel, TasksResponse } from '@/api/task'
import type { TaskListParams } from '@/api'
import { getTaskList } from '@/api'
import type { TaskListParams, TaskInfoParams } from '@/api'
import { getTaskList, getTaskInfo } from '@/api'
import { isNumber } from 'lodash-es'
export interface ChannelMoreBtnStatus {
@@ -25,7 +25,8 @@
    const params: TaskListParams = {
      type,
      offset: 0,
      limit: 3
      limit: 3,
      deviceID: localStorage.getItem('currentDeviceID') || ''
    }
    return getTaskList(params)
      .then((res) => {
@@ -52,8 +53,20 @@
    if (firstNotEmptyChannel) {
      const channelNumber = +firstNotEmptyChannel[0]
      activeTask.value = channels[channelNumber].Tasks[0]
      setActiveChannel(channelNumber)
      // activeTask.value = channels[channelNumber].Tasks[0]
      console.log(channels[channelNumber].Tasks[0].Procedure.ID, '1111')
      const params: TaskInfoParams = {
        deviceID: localStorage.getItem('currentDeviceID') || '',
        procedureID: channels[channelNumber].Tasks[0].Procedure.ID
      }
      return getTaskInfo(params)
        .then((res) => {
          activeTask.value = res.data
        })
        .catch((err) => {
          console.error(err)
        })
        .finally(() => {})
    } else {
      // 如果没有任务就清空当前选中的任务
      activeTask.value = undefined
@@ -69,8 +82,19 @@
  function autoSelectTask(channel: number) {
    const currentChannelTaskList = channels.value[channel].Tasks
    if (currentChannelTaskList?.length) {
      activeTask.value = currentChannelTaskList[0]
      setActiveChannel(channel)
      // activeTask.value = currentChannelTaskList[0].Procedure.ID
      const params: TaskInfoParams = {
        deviceID: localStorage.getItem('currentDeviceID') || '',
        procedureID: currentChannelTaskList[0].Procedure.ID
      }
      return getTaskInfo(params)
        .then((res) => {
          activeTask.value = res.data
        })
        .catch((err) => {
          console.error(err)
        })
        .finally(() => {})
    } else {
      const firstNotEmptyChannel = Object.entries(channels.value).find((ele) => {
        const taskList = (ele[1] as TasksResponse)?.Tasks
@@ -105,7 +129,8 @@
      type: currentType.value,
      channel: channelNumber,
      offset: taskLength,
      limit: 10
      limit: 10,
      deviceID: localStorage.getItem('currentDeviceID') || ''
    }
    getTaskList(params)
      .then((res) => {