screenFront/src/views/MicroExhibition/index.vue

450 lines
12 KiB
Vue
Raw Normal View History

2023-12-05 09:01:51 +00:00
<!--
* @Author: hzz hzz
2023-12-07 08:49:09 +00:00
* @Date: 2023-12-06 15:21:39
2023-12-05 09:01:51 +00:00
* @LastEditors: hzz hzz
2023-12-07 08:49:09 +00:00
* @LastEditTime: 2023-12-06 16:40:32
2023-12-05 09:01:51 +00:00
* @FilePath: \screenFront\src\views\MicroExhibition\index.vue
* @Description:
*
* Copyright (c) 2023 by ${hzz}, All Rights Reserved.
-->
2023-08-23 10:06:47 +00:00
<template>
<div class="container">
<div class="header">
<div class="title">
<Header :title="t('MicroExhibition.富怡服装微工厂物联管理平台')" :wh="{ width: '100%', height: '100px' }"></Header>
2023-08-23 10:06:47 +00:00
</div>
</div>
<div class="content">
<div class="left">
2023-12-05 09:01:51 +00:00
<div class="ltop">
<BoardVue :title="t('MicroExhibition.裁剪设备')" class="ltborder">
2023-12-07 08:49:09 +00:00
<div class="lttop">
<ScrollBoard :data="cjdata"></ScrollBoard>
</div>
<div class="ltbottom">
<BarChart :xData="xData" style="width: 100%;height: 100%;" :seriesData="seriesData"></BarChart>
</div>
</BoardVue>
2023-08-23 10:06:47 +00:00
</div>
2023-12-05 09:01:51 +00:00
<div class="lbottom">
<BoardVue :title="t('MicroExhibition.缝前设备')">
2023-12-06 07:18:31 +00:00
<ScrollBoard :data="fqdata"></ScrollBoard>
</BoardVue>
2023-08-23 10:06:47 +00:00
</div>
</div>
2023-12-05 09:01:51 +00:00
<div class="right">
<div class="rtop">
<div class="rtleft">
2023-12-06 07:18:31 +00:00
<div class="rtltop">
2023-12-07 08:49:09 +00:00
<StepItem v-for="i in stepList" :data="i"></StepItem>
2023-12-06 07:18:31 +00:00
</div>
<div class="rtlbottom">
2023-12-07 08:49:09 +00:00
<video controls loop autoplay="true" ref="videoElement" width="777">
<source :src="videoUrl" type="video/mp4" />
2023-12-06 07:18:31 +00:00
</video>
</div>
2023-08-23 10:06:47 +00:00
</div>
2023-12-05 09:01:51 +00:00
<div class="rtright">
<BoardVue :title="t('MicroExhibition.缝中设备')">
2023-12-06 07:18:31 +00:00
<ScrollBoard :data="fzdata"></ScrollBoard>
</BoardVue>
2023-08-23 10:06:47 +00:00
</div>
</div>
2023-12-05 09:01:51 +00:00
<div class="rbottom">
2023-12-07 08:49:09 +00:00
<BottomBorder :data="hzdata"></BottomBorder>
2023-08-24 10:10:09 +00:00
</div>
2023-08-23 10:06:47 +00:00
</div>
</div>
2023-12-06 07:18:31 +00:00
2023-08-23 10:06:47 +00:00
</div>
</template>
<script setup lang='ts'>
2023-12-05 09:01:51 +00:00
import Header from './component/Header.vue'
import BoardVue from './component/Border.vue'
2023-12-06 07:18:31 +00:00
import StepItem from './component/StepItem.vue'
import BottomBorder from './component/BottomBorder.vue'
import ScrollBoard from './component/ScrollBoard.vue'
2023-12-07 08:49:09 +00:00
import BarChart from './component/BarChart.vue'
2023-12-05 09:01:51 +00:00
2023-12-07 08:49:09 +00:00
import { getmDeviceList, getmDeviceProduction } from '@/http/MicroExhibition'
2023-12-06 07:18:31 +00:00
import { ref, onMounted, onUnmounted, getCurrentInstance, watch, onUpdated, computed, reactive } from 'vue'
import { useMicroExhibitionStore } from '@/store/module/MicroExhibition'
2023-09-11 08:46:02 +00:00
import { connectWebsocket, closeWebsocket } from "@/utils/websocket"
import { getStoredLanguage, saveStoredLanguage,languageHash } from "@/utils/languageStorage";
import { useRoute } from 'vue-router'
2023-08-23 10:06:47 +00:00
import { useI18n } from 'vue-i18n'
let { t } = useI18n();
let route = useRoute()
const store = useMicroExhibitionStore()
let lang = route.query.lang as string
2023-12-13 07:33:10 +00:00
let videoUrl = ref('https://d.tufting222.cn/video/yzy/a.mp4')
2023-12-07 08:49:09 +00:00
const videoElement = ref(null)
2023-12-13 07:33:10 +00:00
let timer = null
let thisLang = getStoredLanguage();
2023-12-06 07:18:31 +00:00
let fqdata = ref({
list: [],
rowNum: 3,
})
let fzdata = ref({
list: [],
rowNum: 10,
})
2023-12-07 08:49:09 +00:00
let cjdata = ref({
list: [],
rowNum: 4,
})
let stepList = reactive([
{
name: t("MicroExhibition.裁剪设备"),
2023-12-07 08:49:09 +00:00
total: 0,
online: 0,
},
{
name: t("MicroExhibition.缝前设备"),
2023-12-07 08:49:09 +00:00
total: 0,
online: 0,
},
{
name: t("MicroExhibition.缝中设备"),
2023-12-07 08:49:09 +00:00
total: 0,
online: 0,
},
{
name: t("MicroExhibition.后整设备"),
2023-12-07 08:49:09 +00:00
total: 0,
online: 0,
},
])
let hzdata = ref([])
2023-12-07 08:58:49 +00:00
let xData = ref([])
2023-12-07 08:49:09 +00:00
let seriesData = ref([
])
2023-09-12 10:11:14 +00:00
2023-12-13 07:33:10 +00:00
//获取echarts数据
2023-12-07 08:58:49 +00:00
function getDeviceProduction() {
getmDeviceProduction().then((res: any) => {
if (res.code == 200) {
let data = res.data
2023-12-13 07:33:10 +00:00
seriesData.value = data.series.map(item => {
2023-12-07 08:58:49 +00:00
return {
name: item.name == '计划完成' ? t('default.计划产量') : t('default.实际产量'),
2023-12-07 08:58:49 +00:00
type: 'bar',
data: item.data
}
})
let xDataArr = thisLang == "简体中文"?data.xData:data.exData
xData.value = xDataArr
2023-12-07 08:58:49 +00:00
}
})
}
2023-09-09 04:01:37 +00:00
2023-12-07 08:58:49 +00:00
//获取设备列表
2023-12-07 08:49:09 +00:00
function getmDevList() {
getmDeviceList().then((res: any) => {
if (res.code == 200) {
let data = res.data
for (let key in data) {
const devObj = {
2023-12-13 07:33:10 +00:00
'裁剪设备': cjdata.value,
'缝前设备': fqdata.value,
'缝中设备': fzdata.value,
2023-12-07 08:49:09 +00:00
}
const statusObj = {
2023-12-13 07:33:10 +00:00
'裁剪设备': 0,
'缝前设备': 1,
'缝中设备': 2,
2023-12-07 08:49:09 +00:00
}
if (devObj.hasOwnProperty(key)) {
let online = 0;
devObj[key].list = data[key].map((item: any, i: number) => {
2023-12-14 08:48:15 +00:00
if (item.status != 'false' && item.status != '0') {
2023-12-07 08:49:09 +00:00
online++
}
let temp = item.status
if (item.status == "true") {
temp = '2'
} else if (item.status == "false") {
temp = '0'
}
let devname = thisLang == "简体中文"?item.name:item.ename
return [i + 1, devname, item.num, temp, item.ratio, item.workTime]
2023-12-07 08:49:09 +00:00
})
stepList[statusObj[key]].online = online;
stepList[statusObj[key]].total = devObj[key].list.length;
}
if (key == '后整设备') {
let online = 0;
hzdata.value = data[key].map((item: any, i: number) => {
2023-12-14 08:48:15 +00:00
if (item.status != 'false' && item.status != '0') {
2023-12-07 08:49:09 +00:00
online++
}
let temp = item.status
if (item.status == "true") {
temp = '2'
} else if (item.status == "false") {
temp = '0'
}
let devname = thisLang == "简体中文"?item.name:item.ename
2023-12-07 08:49:09 +00:00
return {
name: devname,
2023-12-07 08:49:09 +00:00
num: item.num,
status: temp,
ratio: item.ratio,
rationum: parseInt(item.ratio.split('%')[0]),
workTime: item.workTime,
}
})
stepList[3].online = online;
stepList[3].total = hzdata.value.length;
}
}
}
})
}
2023-12-13 07:33:10 +00:00
/*
改变设备状态
{
step:'裁剪设备',
num:1,
status:0
}
*/
function changestatus(val) {
const devObj = {
'裁剪设备': cjdata.value,
'缝前设备': fqdata.value,
'缝中设备': fzdata.value,
}
const statusObj = {
'裁剪设备': 0,
'缝前设备': 1,
'缝中设备': 2,
}
if (val.step == "后整设备") {
2023-12-15 09:05:58 +00:00
let hzdataIndex = hzdata.value.findIndex((item, index) => {
2023-12-13 07:33:10 +00:00
return item.num == val.num
})
2023-12-15 09:05:58 +00:00
2023-12-13 07:33:10 +00:00
if (hzdataIndex !== -1 && hzdata.value[hzdataIndex].status != val.status) {
2023-12-14 08:48:15 +00:00
if (hzdata.value[hzdataIndex].status != 0 && val.status == '0') {
2023-12-13 07:33:10 +00:00
stepList[3].online -= 1
2023-12-14 08:48:15 +00:00
} else if (hzdata.value[hzdataIndex].status == 0 && val.status != '0') {
2023-12-13 07:33:10 +00:00
stepList[3].online += 1
}
2023-12-14 08:48:15 +00:00
hzdata.value[hzdataIndex].status = val.status
2023-12-13 07:33:10 +00:00
}
} else {
let dataIndex = devObj[val.step].list.findIndex((item, index) => {
return item[2] == val.num
})
if (dataIndex !== -1 && devObj[val.step].list[dataIndex][3] != val.status) {
2023-12-14 08:48:15 +00:00
if (devObj[val.step].list[dataIndex][3] != 0 && val.status == '0') {
2023-12-13 07:33:10 +00:00
stepList[statusObj[val.step]].online -= 1
2023-12-14 08:48:15 +00:00
} else if (devObj[val.step].list[dataIndex][3] == 0 && val.status != '0') {
2023-12-13 07:33:10 +00:00
stepList[statusObj[val.step]].online += 1
}
2023-12-14 08:48:15 +00:00
devObj[val.step].list[dataIndex][3] = val.status
2023-12-13 07:33:10 +00:00
}
}
}
2023-09-09 04:01:37 +00:00
2023-09-11 08:46:02 +00:00
function getWebsocket(val) {
try {
let data = JSON.parse(val)
2023-12-19 00:20:23 +00:00
if (data.type == 'mDeviceStatus') {
changestatus(data.msg)
}
2023-12-05 09:01:51 +00:00
// if (data.type == 'WorkingState') {
// store.changestatus(data.msg)
// }
2023-09-11 08:46:02 +00:00
} catch (err) {
console.log(err);
2023-09-09 04:01:37 +00:00
}
2023-09-11 08:46:02 +00:00
}
function errWebsocket(val) {
2023-09-09 04:01:37 +00:00
// console.log(val);
}
2023-12-07 08:49:09 +00:00
2023-09-08 08:03:33 +00:00
onMounted(() => {
2023-12-14 08:48:15 +00:00
2023-12-07 08:58:49 +00:00
getDeviceProduction()
2023-12-07 08:49:09 +00:00
getmDevList()
2023-12-13 07:33:10 +00:00
timer = setInterval(() => {
getDeviceProduction()
getmDevList()
2023-12-14 08:48:15 +00:00
}, 60 * 1000)
// setInterval(() => {
// let status = Math.round(Math.random() * 3)
// let val = {
2023-12-15 09:05:58 +00:00
// step: '后整设备',
// num: 24,
2023-12-14 08:48:15 +00:00
// status: status
// }
// changestatus(val)
// }, 5000)
2023-09-11 08:46:02 +00:00
connectWebsocket(null, null, getWebsocket, errWebsocket)
2023-12-05 09:01:51 +00:00
document.getElementById('app').style.backgroundColor = 'rgba(0, 11, 18, 1)'
2023-09-08 08:03:33 +00:00
})
onUnmounted(() => {
2023-09-12 10:11:14 +00:00
closeWebsocket()
2023-12-13 07:33:10 +00:00
clearInterval(timer)
document.getElementById('app').style.backgroundColor = '#100c2a'
2023-09-08 08:03:33 +00:00
})
2023-08-23 10:06:47 +00:00
</script>
2023-09-08 08:03:33 +00:00
2023-08-23 10:06:47 +00:00
<style scoped>
.container {
height: 1080px;
width: 1920px;
2023-09-06 10:05:57 +00:00
color: #FFFFFF;
2023-12-05 09:01:51 +00:00
background-color: rgba(0, 11, 18, 1);
2023-09-08 08:03:33 +00:00
position: relative;
2023-09-06 10:05:57 +00:00
2023-08-23 10:06:47 +00:00
}
.header {
2023-09-06 10:05:57 +00:00
height: 100px;
2023-08-23 10:06:47 +00:00
width: 1920px;
}
.content {
2023-09-06 10:05:57 +00:00
height: 980px;
2023-08-23 10:06:47 +00:00
width: 1920px;
display: flex;
flex-direction: row;
justify-content: space-between;
2023-09-06 10:05:57 +00:00
padding: 0 5px;
box-sizing: border-box;
2023-08-23 10:06:47 +00:00
}
2023-12-05 09:01:51 +00:00
.left {
width: 540px;
height: 100%;
margin-left: 13px;
2023-08-23 10:06:47 +00:00
display: flex;
flex-direction: column;
justify-content: space-between;
2023-12-05 09:01:51 +00:00
align-items: center;
2023-08-23 10:06:47 +00:00
}
2023-12-06 07:18:31 +00:00
2023-12-05 09:01:51 +00:00
.ltop {
2023-09-06 10:05:57 +00:00
width: 100%;
2023-12-05 09:01:51 +00:00
height: 630px;
2023-09-06 10:05:57 +00:00
}
2023-09-08 08:03:33 +00:00
2023-12-07 08:49:09 +00:00
.ltborder {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.lttop {
width: 100%;
height: 240px;
}
.ltbottom {
flex: 1;
width: 100%;
height: 270px;
}
2023-12-05 09:01:51 +00:00
.lbottom {
2023-09-06 10:05:57 +00:00
width: 100%;
2023-12-05 09:01:51 +00:00
height: 335px;
2023-09-06 10:05:57 +00:00
}
2023-08-24 10:10:09 +00:00
2023-12-05 09:01:51 +00:00
.right {
width: 1330px;
2023-08-24 10:10:09 +00:00
height: 100%;
2023-12-05 09:01:51 +00:00
margin-right: 13px;
2023-08-24 10:10:09 +00:00
display: flex;
2023-12-05 09:01:51 +00:00
flex-direction: column;
justify-content: space-between;
2023-08-24 10:10:09 +00:00
align-items: center;
2023-08-23 10:06:47 +00:00
}
2023-08-24 10:10:09 +00:00
2023-12-05 09:01:51 +00:00
.rtop {
width: 100%;
height: 715px;
2023-09-08 08:03:33 +00:00
display: flex;
2023-12-05 09:01:51 +00:00
flex-direction: row;
2023-09-08 08:03:33 +00:00
justify-content: space-between;
align-items: center;
}
2023-09-08 10:02:15 +00:00
2023-12-05 09:01:51 +00:00
.rbottom {
width: 100%;
height: 250px;
}
.rtleft {
width: 777px;
2023-09-08 08:03:33 +00:00
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
2023-09-08 10:02:15 +00:00
2023-12-05 09:01:51 +00:00
.rtltop {
width: 100%;
height: 120px;
2023-12-06 07:18:31 +00:00
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
2023-09-08 08:03:33 +00:00
}
2023-12-06 07:18:31 +00:00
2023-12-05 09:01:51 +00:00
.rtlbottom {
width: 100%;
height: 580px;
2023-12-06 07:18:31 +00:00
display: flex;
justify-content: center;
align-items: center;
/* background-image: url('./images/border.png');
background-repeat: no-repeat;
background-size: 100% 100%;
box-sizing: border-box;
padding: 10px; */
}
.rtlbottom .video {
width: 100%;
height: 100%;
object-fit: fill;
2023-09-08 08:03:33 +00:00
}
2023-09-08 10:02:15 +00:00
2023-12-05 09:01:51 +00:00
.rtright {
width: 540px;
2023-09-08 08:03:33 +00:00
height: 100%;
}
2023-09-11 08:46:02 +00:00
</style>