songshankun
2023-11-03 102002f53d93c88cdd85b23a4e070ab39539f633
feat: 工序运行时间使用当前选中任务所在通道的正处于运行中的任务来展示
3个文件已修改
30 ■■■■ 已修改文件
src/api/index.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/craftModel.ts 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dashboard/components/DeviceStatusInfo.vue 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/index.ts
@@ -112,7 +112,6 @@
  procedureId: number
  page: number
  pageSize: number
  number: string
}
/**
src/stores/craftModel.ts
@@ -1,4 +1,4 @@
import { onUnmounted, ref, watch } from 'vue'
import { ref, watch } from 'vue'
import { defineStore } from 'pinia'
import type { CraftModel } from '@/api/craftModel'
import { apiGetCraftModelList } from '@/api'
@@ -11,13 +11,11 @@
  const taskStore = useTasksStore()
  function getCraftModelList() {
    if (taskStore.activeTask?.Procedure.ID) {
      console.log(122)
      apiGetCraftModelList({
        procedureId: taskStore.activeTask?.Procedure.ID,
        page: 1,
        pageSize: 999
      }).then((res) => {
        console.log()
        craftModelList.value = res.data ?? []
      })
    }
src/views/dashboard/components/DeviceStatusInfo.vue
@@ -73,6 +73,7 @@
import type { PLCResponse } from '@/api/plc'
import { useTasksStore } from '@/stores/tasks'
import { storeToRefs } from 'pinia'
import type { TasksGroupByChannel } from '@/api/task'
export interface DeviceStatusInfoProps {
  plc?: PLCResponse
@@ -143,11 +144,31 @@
  return `${days}天${hours}时${m}分`
}
/**
 * 获取某任务所在通道的运行中的任务
 * @param channelMap
 * @param channelNumber
 */
function getChannelRunningTask(channelMap?: TasksGroupByChannel, channelNumber?: number) {
  if (!channelMap || !channelNumber) {
    return
  }
  const channel = channelMap[channelNumber]
  if (channel) {
    const taskList = channel?.Tasks ?? []
    return taskList.find((ele) => ele.Procedure.Status === 2)
  }
}
// 工序运行时间
const taskStore = useTasksStore()
const { activeTask } = storeToRefs(taskStore)
const { activeTask, channels } = storeToRefs(taskStore)
// 工序运行时间: 使用当前选中任务所在通道的正处于运行中的任务来展示
const runningTime = computed(() => {
  return getTaskRunningTime(activeTask?.value?.Procedure?.realStartTime, activeTask?.value?.Procedure?.realEndTime)
  const runningTask = getChannelRunningTask(channels?.value, activeTask?.value?.Channel)
  return getTaskRunningTime(runningTask?.Procedure?.realStartTime, runningTask?.Procedure?.realEndTime)
})
</script>