From 2453a589a623b2448a8cc940d8dce3da6698c50c Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期一, 05 二月 2024 14:15:49 +0800
Subject: [PATCH] 获取设备列表、切换设备列表、开始生产接口和逻辑修改、结束任务联调、工艺信息联调、切换任务联调

---
 src/stores/tasks.ts |   41 +++++++++++++++++++++++++++++++++--------
 1 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts
index 33df9a7..794268c 100644
--- a/src/stores/tasks.ts
+++ b/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) => {

--
Gitblit v1.8.0