yangfeng
2024-02-06 7edf66cafb871c5fb28911dfb02611ef5c9910b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<template>
  <div class="dashboard-title">
    <div class="title-text-box">
      <div class="title-text">
        <span> 智能工作台 —</span>
        <el-popover placement="bottom" :width="180" trigger="click" :content="currentDeviceName">
          <template #reference>
            <el-text truncated class="device-name">{{ currentDeviceName }}</el-text>
          </template>
        </el-popover>
        <el-icon class="text-icon" color="#0db7f5" @click="openDevicesModal">
          <IconSlider></IconSlider>
        </el-icon>
      </div>
    </div>
    <div class="title-status">
      <div class="connection-info" @click="openProblemsModal">
        <el-icon class="size_26" :color="problemsIconStatus ? '#00ff00' : '#ff0000'">
          <AlertLightIcon></AlertLightIcon>
        </el-icon>
      </div>
      <div class="cloud-connection-status">
        <el-icon v-if="cloudConnectionIconStatus" class="size_36" color="#00ff00">
          <IconCloudDone></IconCloudDone>
        </el-icon>
 
        <el-icon v-else class="size_36" color="#ff0000">
          <IconCloudOff></IconCloudOff>
        </el-icon>
      </div>
 
      <div class="reporting-record">
        <el-icon
          class="size_26"
          :color="taskStore.activeTask ? '#0db7f5' : '#c0c0c0'"
          :style="{ 'margin-right': '10px', cursor: taskStore.activeTask ? 'pointer' : 'not-allowed' }"
          @click="openReportingRecord"
        >
          <IconRecords></IconRecords>
        </el-icon>
      </div>
 
      <div class="params-config" @click="openConfigModal">
        <el-icon class="size_28"><Setting /></el-icon>
      </div>
    </div>
  </div>
  <DeviceCheckList v-model="showDevicesModal" @should-reload="emits('shouldReload')"></DeviceCheckList>
  <TroubleTrackerModal v-model="showProblemsModal" :problems="problemList"></TroubleTrackerModal>
  <DeliverParamsConfigModal v-model="showConfigModal"></DeliverParamsConfigModal>
  <ReportingRecordModal v-model="showReportingRecordModal"></ReportingRecordModal>
</template>
<script setup lang="ts">
import AlertLightIcon from '@/components/icons/AlertLightIcon.vue'
import IconRecords from '~icons/vaadin/records'
import { computed, onUnmounted, ref } from 'vue'
import { useDevicesStore } from '@/stores/devices'
import TroubleTrackerModal from '@/views/dashboard/components/TroubleTrackerModal.vue'
import DeviceCheckList from '@/views/dashboard/components/DeviceCheckList.vue'
import IconCloudDone from '~icons/material-symbols-light/cloud-done-outline'
import IconCloudOff from '~icons/material-symbols-light/cloud-off-outline'
import IconSlider from '~icons/bx/slider'
import { useRequest } from 'vue-hooks-plus'
// import { apiGetProblemList } from '@/api'
import { PROBLEMS_POLLING_DURATION } from '@/common/constants'
import { Setting } from '@element-plus/icons-vue'
import DeliverParamsConfigModal from '@/views/dashboard/components/DeliverParamsConfigModal.vue'
import ReportingRecordModal from '@/views/dashboard/components/ReportingRecordModal.vue'
import { useTasksStore } from '@/stores/tasks'
 
const emits = defineEmits<{
  shouldReload: []
}>()
 
// 是否显示问题诊断modal
const showProblemsModal = ref(false)
/**
 * 打开问题诊断modal
 */
function openProblemsModal() {
  showProblemsModal.value = true
}
 
// 是否显示设备切换modal
const showDevicesModal = ref(false)
/**
 * 打开设备切换modal
 */
function openDevicesModal() {
  showDevicesModal.value = true
}
 
// 获取当前设备名
const deviceStore = useDevicesStore()
const currentDeviceName = computed(() => {
  return (
    deviceStore?.deviceInfo?.deviceList?.find((ele) => ele?.deviceID === deviceStore?.deviceInfo?.currentDeviceID)
      ?.deviceName ?? ''
  )
})
 
// 问题诊断列表
const problemList = computed(() => {
  // return problemsRes?.value?.data ?? []
  return []
})
// 问题诊断icon状态, 问题列表中有一条异常即为红灯 否则是绿灯  true绿灯
const problemsIconStatus = computed(() => {
  if (!problemList.value || !problemList.value?.length) {
    // 默认绿灯, 拿到一次数据后才以接口为准
    return true
  }
  // return !problemList.value.some((ele) => !ele.CheckResult)
  return false
})
// 云端连接icon状态, 问题列表中有一条代表云端链接的, 异常即为红色云icon 否则是绿色  true绿云
const cloudConnectionIconStatus = computed(() => {
  if (!problemList.value || !problemList.value?.length) {
    // 默认绿灯, 拿到一次数据后才以接口为准
    return true
  }
  // 没数据就当是链接正常
  // const cloudConnection = problemList.value.find((ele) => ele.ItemCode === 'cloud')
  // return cloudConnection ? cloudConnection?.CheckResult : true
  return false
})
 
// 配置下发参数弹窗
const showConfigModal = ref(false)
function openConfigModal() {
  showConfigModal.value = true
}
function closeConfigModal() {
  showConfigModal.value = false
}
/**
 * 轮询问题诊断
 */
// const {
//   data: problemsRes,
//   run: startProblemsPolling,
//   cancel: cancelProblemsPolling
// } = useRequest(apiGetProblemList, {
//   manual: true,
//   pollingInterval: PROBLEMS_POLLING_DURATION,
//   pollingWhenHidden: false
// })
// startProblemsPolling()
// onUnmounted(() => {
//   cancelProblemsPolling()
// })
 
const taskStore = useTasksStore()
 
// 是否显示报工记录
const showReportingRecordModal = ref(false)
function openReportingRecord() {
  if (!taskStore.activeTask) {
    ElMessage.error('请先选择任务')
    return
  }
  showReportingRecordModal.value = true
}
</script>
 
<style scoped lang="scss">
.dashboard-title {
  position: relative;
  height: 100%;
}
.el-icon.size_28 {
  font-size: 28px;
}
.size_26 {
  font-size: 26px;
}
.size_36 {
  font-size: 36px;
}
.title-text-box {
  width: calc(100% - 150px);
  height: 100%;
 
  .title-text {
    // display: flex;
    width: 450px;
    height: 100%;
    margin: 0 auto;
    margin-left: 24%;
    align-items: center;
    line-height: 68px;
    // justify-content: center;
    font-size: 34px;
    font-weight: 700;
    span {
      float: left;
    }
    .text-icon {
      font-size: 40px;
      margin-left: 4px;
      cursor: pointer;
    }
  }
}
 
.title-status {
  height: 100%;
  display: flex;
  vertical-align: middle;
  align-items: center;
  position: absolute;
  top: 0px;
  right: 6px;
  div {
    vertical-align: middle;
    display: inline-block;
    margin-top: 7px;
  }
  .cloud-connection-status {
    // margin-top: 5px;
  }
}
.connection-info {
  margin-right: 10px;
  cursor: pointer;
}
.device-name {
  max-width: 180px;
  font-size: 40px;
  color: #fff;
}
.cloud-connection-status {
  margin-right: 10px;
}
.params-config {
  cursor: pointer;
}
</style>