From 1b1953b435e3187243102c794d29b56acb0dba5a Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期五, 03 十一月 2023 16:44:22 +0800 Subject: [PATCH] Merge branch 'dev' of http://192.168.5.5:10010/r/web/bulletin-board-style1 into wn --- src/views/dashboard/components/DeviceStatusInfo.vue | 25 +++++++++++- src/stores/craftModel.ts | 16 ++++++- src/views/dashboard/index.vue | 19 ++++----- src/api/index.ts | 1 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 84fceb8..6b41213 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -112,7 +112,6 @@ procedureId: number page: number pageSize: number - number: string } /** diff --git a/src/stores/craftModel.ts b/src/stores/craftModel.ts index 7f7c5f3..9b8afbd 100644 --- a/src/stores/craftModel.ts +++ b/src/stores/craftModel.ts @@ -1,8 +1,10 @@ -import { ref, computed } from 'vue' +import { ref, watch } from 'vue' import { defineStore } from 'pinia' import type { CraftModel } from '@/api/craftModel' import { apiGetCraftModelList } from '@/api' import { useTasksStore } from '@/stores/tasks' + +const watcher = ref() export const useCraftModelStore = defineStore('craftModel', () => { const craftModelList = ref<CraftModel[]>() @@ -12,13 +14,21 @@ apiGetCraftModelList({ procedureId: taskStore.activeTask?.Procedure.ID, page: 1, - pageSize: 999, - number: taskStore.activeTask?.Procedure?.processModelNumber + pageSize: 999 }).then((res) => { craftModelList.value = res.data ?? [] }) } } + if (!watcher.value) { + watch( + () => taskStore.activeTask, + () => { + getCraftModelList() + } + ) + } + return { craftModelList, getCraftModelList } }) diff --git a/src/views/dashboard/components/DeviceStatusInfo.vue b/src/views/dashboard/components/DeviceStatusInfo.vue index 0730135..de86706 100644 --- a/src/views/dashboard/components/DeviceStatusInfo.vue +++ b/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> diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 4f255f6..d006860 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -15,12 +15,14 @@ <ProcessingInfo style="margin-top: 6px" :task="activeTask"></ProcessingInfo> </el-tab-pane> <el-tab-pane label="宸ヨ壓淇℃伅" name="宸ヨ壓淇℃伅"> - <ProcessInfo - v-for="item in craftModelStore.craftModelList" - :key="item.ID" - :craft-model="item" - @detail="openCraftModelDetailModal" - ></ProcessInfo> + <el-scrollbar always> + <ProcessInfo + v-for="item in craftModelStore.craftModelList" + :key="item.ID" + :craft-model="item" + @detail="openCraftModelDetailModal" + ></ProcessInfo> + </el-scrollbar> </el-tab-pane> <el-tab-pane label="鐗╂枡娓呭崟" name="鐗╂枡娓呭崟"> <InputMaterialsList @@ -152,13 +154,10 @@ // 鍒囨崲浠诲姟鏃惰幏鍙栧搴斾换鍔$殑宸ヨ壓妯″瀷淇℃伅 const craftModelStore = useCraftModelStore() -watch(activeTask, () => { - craftModelStore.getCraftModelList() -}) +craftModelStore.getCraftModelList() const showCraftModelDetail = ref(false) function openCraftModelDetailModal() { - console.log(1) showCraftModelDetail.value = true } -- Gitblit v1.8.0