yangfeng
2023-12-12 1519870c0e18171ced014a840e86a459dc6b00f1
src/views/dashboard/index.vue
@@ -58,7 +58,7 @@
    <template #middleBlock3>
      <SubTitle>任务详情</SubTitle>
      <div class="task-detail">
        <TaskControl :task="activeTask" @should-reload="reloadChannel"></TaskControl>
        <TaskControl :task="activeTask" :workers="currentWorkers" @should-reload="reloadChannel"></TaskControl>
      </div>
      <ColorInfo :type="1"></ColorInfo>
      <ColorInfo :type="2"></ColorInfo>
@@ -96,7 +96,7 @@
import { computed, ref } from 'vue'
import ChannelCollapse from '@/views/dashboard/components/ChannelCollapse.vue'
import type { Worker, Order, Task, Material } from '@/api/task'
import type { Task, Material } from '@/api/task'
import type { CraftModel } from '@/api/craftModel'
import PersonInfo from '@/views/dashboard/components/PersonInfo.vue'
import ProcessInfo from '@/views/dashboard/components/ProcessInfo.vue'
@@ -124,6 +124,7 @@
import { updateCraftParams } from '@/api'
import { Loading } from '@element-plus/icons-vue'
import { isNumber } from 'lodash-es'
defineOptions({
  name: 'DashboardView'
@@ -154,7 +155,7 @@
const tasksStore = useTasksStore()
const { activeTask, channels } = storeToRefs(tasksStore)
tasksStore.getChannels(1)
tasksStore.getChannels(1, true)
function changeTab(tab: LabelValue) {
  tasksStore.getChannels(tab.value)
@@ -165,11 +166,14 @@
 * @param task
 */
function reloadChannel(task: Task) {
  tasksStore.reloadChannel(task.Channel)
  tasksStore.reloadChannel(task.Channel).then(() => {
    plcStore.startPollingPLC()
  })
}
function reloadAllData() {
  tasksStore.reloadAllData()
  location.reload()
}
// 启动plc 轮询
const plcStore = usePLCStore()
@@ -235,6 +239,15 @@
  currentMaterialInfo.value = material
  showMaterialDetail.value = true
}
const currentWorkers = computed(() => {
  const channel = activeTask.value?.Channel
  if (isNumber(channel)) {
    return channels.value[channel].workers ?? []
  } else {
    return []
  }
})
</script>
<style scoped lang="scss">