You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

459 lines
12 KiB

3 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
2 months ago
3 months ago
  1. <script setup lang="ts">
  2. import { getContainerList } from 'apis/container'
  3. import logoutIcon from 'assets/images/logout.svg'
  4. import Check from 'components/check/index.vue'
  5. import Liquid from 'components/home/Liquid/index.vue'
  6. import Stop from 'components/Stop/index.vue'
  7. import { useActivateDebug } from 'hooks/useActivateDebug'
  8. import { useServerTime } from 'hooks/useServerTime'
  9. import { isClose } from 'libs/socket'
  10. import { authRoutes } from 'router/routes'
  11. import { useSystemStore } from 'stores/systemStore'
  12. import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
  13. import { useRouter } from 'vue-router'
  14. const { handleLogoClick } = useActivateDebug()
  15. const { currentTime } = useServerTime()
  16. const systemStore = useSystemStore()
  17. const router = useRouter()
  18. watch(() => currentTime.value, () => {
  19. systemStore.currentTime = currentTime.value
  20. })
  21. watch(() => systemStore.systemStatus, () => {
  22. if (!systemStore.systemStatus.currentUser) {
  23. router.push('/login')
  24. }
  25. if (!systemStore.systemStatus.selfTest && systemStore.systemStatus.currentUser && systemStore.systemStatus.currentUser?.username !== 'test') {
  26. isCheck.value = true
  27. }
  28. })
  29. onMounted(async () => {
  30. if (!systemStore.systemStatus.selfTest && systemStore.systemStatus.currentUser && systemStore.systemStatus.currentUser?.username !== 'test') {
  31. isCheck.value = true
  32. }
  33. if (!systemStore.systemStatus.currentUser) {
  34. console.log(11233)
  35. await router.push('/login')
  36. }
  37. })
  38. onUnmounted(() => {
  39. // clearInterval(timeInterval)
  40. })
  41. // meta的isDefault=true 并且 当isDebug=true时,把debug路由的页面也显示
  42. const menuList = computed(() => {
  43. return authRoutes.filter((item) => {
  44. if (item.meta?.isDefault) {
  45. return true
  46. }
  47. return (item.path === '/debug' && systemStore.isDebug)
  48. })
  49. })
  50. watch(() => systemStore.isDebug, () => {
  51. console.log('isDebug', systemStore.isDebug)
  52. if (!systemStore.isDebug && router.currentRoute.value.path === '/debug') {
  53. router.push('/')
  54. }
  55. })
  56. const isCheck = ref(false)
  57. const containerList = ref<Container.ContainerItem[]>()
  58. const getSolution = async () => {
  59. const res = await getContainerList()
  60. containerList.value = res.filter(item => item.type === 0)
  61. }
  62. const statusMap = {
  63. start: {
  64. type: 'primary',
  65. name: '指令开始执行',
  66. },
  67. success: {
  68. type: 'success',
  69. name: '指令执行成功',
  70. },
  71. fail: {
  72. type: 'danger',
  73. name: '指令执行异常',
  74. },
  75. }
  76. </script>
  77. <template>
  78. <el-container class="main">
  79. <el-header class="header">
  80. <div class="logo">
  81. <img src="../assets/images/logo.svg" alt="" @click="handleLogoClick">
  82. <span class="title" @click="handleLogoClick">长春黄金研究院有限公司</span>
  83. <img :class="systemStore.menuExpand ? 'expand-icon' : 'fold-icon'" src="../assets/images/expand.svg" alt="" @click="systemStore.updateMenuExpand()">
  84. </div>
  85. <div class="header-right">
  86. <el-dropdown class="wifi-dropdown" trigger="click">
  87. <div class="wifi-icon">
  88. <img v-if="isClose" src="../assets/images/wifi.svg" alt="">
  89. <img v-else src="../assets/images/wifi-active.svg" alt="">
  90. </div>
  91. <template #dropdown>
  92. <el-dropdown-menu>
  93. <el-dropdown-item @click="systemStore.logout()">
  94. <div class="logout">
  95. <span v-if="!isClose">已连接</span>
  96. <span v-else>已断开</span>
  97. </div>
  98. </el-dropdown-item>
  99. </el-dropdown-menu>
  100. </template>
  101. </el-dropdown>
  102. <div class="time">
  103. {{ systemStore.currentTime }}
  104. </div>
  105. <div class="user">
  106. <el-dropdown class="user-dropdown" trigger="click">
  107. <div class="user-dropdown-item">
  108. <img src="../assets/images/user.svg" alt="">
  109. <span>{{ systemStore.systemStatus.currentUser?.nickname || systemStore.systemStatus.currentUser?.username }}</span>
  110. </div>
  111. <template #dropdown>
  112. <el-dropdown-menu>
  113. <el-dropdown-item @click="systemStore.logout()">
  114. <div class="logout">
  115. <img :src="logoutIcon" alt="">
  116. <span>退出登录</span>
  117. </div>
  118. </el-dropdown-item>
  119. </el-dropdown-menu>
  120. </template>
  121. </el-dropdown>
  122. </div>
  123. </div>
  124. </el-header>
  125. <el-container class="container">
  126. <el-aside class="aside" :class="{ 'aside-off': !systemStore.menuExpand }">
  127. <div
  128. v-for="item in menuList"
  129. :key="item.path"
  130. class="aside-item"
  131. :class="{ 'aside-item-active': router.currentRoute.value.path.includes(item.path) }"
  132. @click="router.push(item.path)"
  133. >
  134. <img class="swing-icon" :src="((router.currentRoute.value.path.includes(item.path) ? item.meta!.activeIcon : item.meta!.icon) as string)" alt="">
  135. <span class="text">{{ item.meta!.title }}</span>
  136. </div>
  137. </el-aside>
  138. <el-main>
  139. <router-view v-slot="{ Component }" class="content">
  140. <transition name="el-fade-in-linear">
  141. <component :is="Component" />
  142. </transition>
  143. </router-view>
  144. </el-main>
  145. </el-container>
  146. <el-footer class="footer" :class="{ 'footer-expand': !systemStore.menuExpand }">
  147. <el-row>
  148. <el-col :span="16">
  149. <div class="footer-left">
  150. <img src="../assets/images/run.svg" alt="">
  151. <span v-if="!systemStore.systemLogList.length" class="text">设备运行状态</span>
  152. <el-popover v-else width="auto" trigger="click" placement="top">
  153. <template #reference>
  154. <el-tag style="width: 100%" :type="statusMap[systemStore.systemLogList[0]?.status as keyof typeof statusMap].type">
  155. {{ systemStore.systemLogList[0]?.cmdName }}: {{ statusMap[systemStore.systemLogList[0]?.status as keyof typeof statusMap].name }}
  156. {{ systemStore.systemLogList[0]?.time }}
  157. </el-tag>
  158. </template>
  159. <template #default>
  160. <div class="log-box">
  161. <el-tag
  162. v-for="(item, key) in systemStore.systemLogList"
  163. :key
  164. :type="statusMap[item?.status as keyof typeof statusMap].type"
  165. >
  166. {{ item.cmdName }}: {{ statusMap[item.status as keyof typeof statusMap].name }}
  167. {{ item.time }}
  168. </el-tag>
  169. </div>
  170. </template>
  171. </el-popover>
  172. </div>
  173. </el-col>
  174. <el-col :span="8">
  175. <el-popover
  176. placement="top-start"
  177. width="auto"
  178. trigger="click"
  179. @show="getSolution"
  180. >
  181. <template #reference>
  182. <div class="footer-right">
  183. <div class="status" />
  184. <span class="text">溶液容器余量正常</span>
  185. </div>
  186. </template>
  187. <template #default>
  188. <div class="container-box">
  189. <Liquid
  190. v-for="item in containerList"
  191. :key="item.id"
  192. :data="item"
  193. />
  194. </div>
  195. </template>
  196. </el-popover>
  197. </el-col>
  198. </el-row>
  199. </el-footer>
  200. <FtStream :visible="systemStore.streamVisible" />
  201. <Check v-if="isCheck" @close="isCheck = false" />
  202. <Stop v-if="systemStore.systemStatus.emergencyStop" />
  203. </el-container>
  204. </template>
  205. <style scoped lang="scss">
  206. .main {
  207. box-sizing: border-box;
  208. height: 100%;
  209. background: #F6F6F6;
  210. .header, .footer {
  211. height: 50px;
  212. width: 100%;
  213. display: flex;
  214. align-items: center;
  215. justify-content: space-between;
  216. padding: 10px 15px;
  217. }
  218. .header {
  219. color: #393F46;
  220. .logo {
  221. height: 100%;
  222. display: flex;
  223. align-items: center;
  224. .title {
  225. margin:0 10px;
  226. color: #8799AB;
  227. font-weight: 600;
  228. }
  229. img {
  230. height: 100%;
  231. }
  232. .expand-icon {
  233. height: 15px;
  234. transition: all 0.3s;
  235. }
  236. .fold-icon {
  237. height: 15px;
  238. transform: rotate(90deg);
  239. transition: all 0.3s;
  240. }
  241. }
  242. .header-right {
  243. display: flex;
  244. align-items: center;
  245. height: 100%;
  246. .wifi-dropdown {
  247. height: 100%;
  248. .wifi-icon {
  249. width: 40px;
  250. height: 100%;
  251. background: #fff;
  252. border-radius: 5px;
  253. display: flex;
  254. align-items: center;
  255. justify-content: center;
  256. img {
  257. height: 50%;
  258. }
  259. }
  260. }
  261. .time {
  262. margin:0 10px;
  263. height: 100%;
  264. padding: 0 10px;
  265. display: flex;
  266. align-items: center;
  267. background: #fff;
  268. border-radius: 5px;
  269. }
  270. }
  271. }
  272. .container {
  273. height: calc(100% - 100px);
  274. }
  275. }
  276. .aside {
  277. width: 170px;
  278. overflow: auto;
  279. padding-left: 10px;
  280. //transition: all 0.1s ease;
  281. .aside-item {
  282. width: 100%;
  283. height: 50px;
  284. border-radius: 10px;
  285. color: #1989FA;
  286. margin: 10px 0;
  287. padding: 0 10px;
  288. display: flex;
  289. align-items: center;
  290. overflow: hidden;
  291. img {
  292. height: 80%;
  293. margin-right: 20px;
  294. }
  295. .text {
  296. transition: opacity 0.3s ease;
  297. white-space: nowrap;
  298. }
  299. }
  300. .aside-item-active {
  301. background: #1989FA;
  302. color: #fff;
  303. }
  304. }
  305. .aside-off {
  306. width: 70px;
  307. //transition: all 0.1s ease;
  308. .aside-item {
  309. .text {
  310. opacity: 0
  311. }
  312. }
  313. .aside-item-active {
  314. background: rgba(0,0,0,0);
  315. color: #fff;
  316. }
  317. }
  318. .user-dropdown-item {
  319. display: flex;
  320. align-items: center;
  321. height: 100%;
  322. color: #393F46;
  323. font-weight: bold;
  324. img {
  325. height: 30px;
  326. margin-right: 10px;
  327. }
  328. }
  329. .el-main {
  330. padding: 0 15px;
  331. height: 100%;
  332. position: relative;
  333. }
  334. .content {
  335. width: 100%;
  336. height: 100%;
  337. background: #fff;
  338. border-radius: 10px;
  339. box-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
  340. padding: 10px;
  341. }
  342. .footer-expand {
  343. padding: 10px 15px 10px 85px !important;
  344. }
  345. .main .footer {
  346. padding: 10px 15px 10px 185px;
  347. .el-row {
  348. width: 100%;
  349. height: 100%;
  350. .el-col {
  351. height: 100%;
  352. }
  353. }
  354. .footer-left, .footer-right {
  355. width: 100%;
  356. height: 100%;
  357. background: #fff;
  358. border-radius: 5px;
  359. display: flex ;
  360. align-items: center;
  361. padding: 0 20px;
  362. }
  363. .footer-left {
  364. border-right: 5px solid #F6F6F6;
  365. display: flex;
  366. align-items: center;
  367. justify-content: space-between;
  368. img {
  369. height: 60%;
  370. margin-right: 20px;
  371. }
  372. .text {
  373. color: #1C1C1C ;
  374. font-size: 14px;
  375. }
  376. }
  377. .footer-right {
  378. border-left: 10px solid #F6F6F6;
  379. .status {
  380. width: 15px;
  381. height: 15px;
  382. border-radius: 50%;
  383. background: #4EE993;
  384. }
  385. .text {
  386. color: #1C1C1C ;
  387. margin-left: 10px;
  388. font-size: 14px;
  389. }
  390. }
  391. }
  392. .aside-item:hover {
  393. .swing-icon {
  394. animation: swing 1s ease-in-out;
  395. }
  396. }
  397. .logout {
  398. display: flex;
  399. img {
  400. width: 15px;
  401. margin-right: 10px;
  402. }
  403. }
  404. .container-box {
  405. width: 400px;
  406. display: grid;
  407. grid-template-columns: repeat(4, 1fr);
  408. grid-template-rows: repeat(2, 1fr);
  409. grid-gap: 10px;
  410. }
  411. .log-box {
  412. width: 500px;
  413. height: 400px;
  414. overflow: auto;
  415. .el-tag {
  416. margin: 5px 0;
  417. width: 100%;
  418. }
  419. }
  420. @keyframes swing {
  421. 0% {
  422. transform: rotate(0deg);
  423. }
  424. 25% {
  425. transform: rotate(-30deg);
  426. }
  427. 50% {
  428. transform: rotate(30deg);
  429. }
  430. 75% {
  431. transform: rotate(-15deg);
  432. }
  433. 100% {
  434. transform: rotate(0deg);
  435. }
  436. }
  437. </style>