songshankun
2023-11-02 15f938d1756a9da8bd1323edda92bd0f52537bb4
src/views/dashboard/index.vue
@@ -6,7 +6,9 @@
    <template #leftBlock2>
      <ChannelCollapse :channels="channels"></ChannelCollapse>
    </template>
    <template #middleBlock1>标题</template>
    <template #middleBlock1>
      <DashboardTitle></DashboardTitle>
    </template>
    <template #middleBlock2>
      <el-tabs v-model="activeMainTabName" class="main-info-tabs">
        <el-tab-pane label="加工信息" name="加工信息">
@@ -21,14 +23,14 @@
    <template #middleBlock3>
      <SubTitle>任务详情</SubTitle>
      <div class="task-detail">
        <TaskControl :task="activeTask"></TaskControl>
        <TaskControl :task="activeTask" @should-reload="reloadAllData"></TaskControl>
      </div>
      <ColorInfo :order="order" :type="1"></ColorInfo>
      <ColorInfo :order="order" :type="2"></ColorInfo>
    </template>
    <template #middleBlock4>
      <SubTitle>人员信息</SubTitle>
      <PersonInfo :person="person"></PersonInfo>
      <PersonInfo v-for="worker in workers" :key="worker.workerId" :person="worker"></PersonInfo>
    </template>
    <template #rightBlock1>
      <div class="date-time">
@@ -36,8 +38,8 @@
      </div>
    </template>
    <template #rightBlock2>
      <DeviceStatusInfo :device="device" :type="1"></DeviceStatusInfo>
      <DeviceStatusInfo :device="device" :type="2"></DeviceStatusInfo>
      <DeviceStatusInfo :plc="plcStore.plcInfo" :type="1"></DeviceStatusInfo>
      <DeviceStatusInfo :device="deviceStore.deviceInfo" :type="2"></DeviceStatusInfo>
      <DeviceNumberInfo></DeviceNumberInfo>
    </template>
    <template #rightBlock3>
@@ -48,9 +50,9 @@
  </DashboardLayout>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, ref, watch, onUnmounted } from 'vue'
import ChannelCollapse from '@/views/dashboard/components/ChannelCollapse.vue'
import type { Worker, Order } from '@/api/task'
import type { Worker, Order, Task } from '@/api/task'
import type { PLCResponse } from '@/api/plc'
import PersonInfo from '@/views/dashboard/components/PersonInfo.vue'
import ProcessInfo from '@/views/dashboard/components/ProcessInfo.vue'
@@ -67,19 +69,22 @@
import ProcessingInfo from '@/views/dashboard/components/ProcessingInfo.vue'
import TaskControl from '@/views/dashboard/components/TaskControl.vue'
import SubTitle from '@/views/dashboard/components/SubTitle.vue'
import DashboardTitle from '@/views/dashboard/components/DashboardTitle.vue'
import { usePLCStore } from '@/stores/plc'
import { useDevicesStore } from '@/stores/devices'
defineOptions({
  name: 'DashboardView'
})
const person = computed(() => {
  return {
    workerName: '姓名',
    phone: '111'
  } as unknown as Worker
// 获取当前高亮任务的值班人信息
const taskStore = useTasksStore()
const workers = computed(() => {
  return taskStore.activeTask?.Procedure?.procedure?.workers ?? []
})
const process = computed(() => {
  return { product: '产品名称', number: '111', procedure: '工艺名称', isUpdate: true }
  return { product: '产品名称', number: '111', procedure: '工艺名称', isUpdate: true } as any
})
const order = computed(() => {
@@ -119,6 +124,17 @@
function changeTab(tab: LabelValue) {
  tasksStore.getChannels(tab.value)
}
function reloadAllData(task: Task) {
  tasksStore.reload(task.Channel)
}
const plcStore = usePLCStore()
// 启动plc 轮询
plcStore.startPollingPLC()
const deviceStore = useDevicesStore()
deviceStore.startPollingDevice()
</script>
<style scoped lang="scss">