screenFront/src/views/MicroExhibition/index.vue

456 lines
13 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">
2023-12-06 07:18:31 +00:00
<Header :title="'富怡服装微工厂物联管理平台'" :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">
2023-12-07 08:49:09 +00:00
<BoardVue :title="'裁剪设备'" class="ltborder">
<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">
2023-12-06 07:18:31 +00:00
<BoardVue :title="'缝前设备'">
<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">
2023-12-06 07:18:31 +00:00
<BoardVue :title="'缝中设备'">
<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"
2023-08-23 10:06:47 +00:00
import { useI18n } from 'vue-i18n'
let { t } = useI18n();
const store = useMicroExhibitionStore()
2023-12-07 08:49:09 +00:00
let videoUrl = ref('http://tjgoa.oss-cn-beijing.aliyuncs.com/202309141%E5%BE%AE%E5%B7%A5%E5%8E%82%E5%AE%A3%E4%BC%A0%E8%A7%86%E9%A2%91%E4%BA%8E%E6%89%BF%E5%BF%97.mp4')
const videoElement = ref(null)
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: '裁剪',
total: 0,
online: 0,
},
{
name: '缝前',
total: 0,
online: 0,
},
{
name: '缝中',
total: 0,
online: 0,
},
{
name: '后整',
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-12-06 07:18:31 +00:00
let list = [
[1, '自动缝纫机', 29, 1, '95%', '12min'],
[1, '自动缝纫机', 29, 1, '95%', '12min'],
[1, '自动缝纫机', 29, 1, '95%', '12min'],
[1, '自动缝纫机', 29, 1, '95%', '12min'],
[1, '自动缝纫机', 29, 1, '95%', '12min'],]
2023-09-12 10:11:14 +00:00
2023-12-07 08:58:49 +00:00
//获取echarts数据
function getDeviceProduction() {
getmDeviceProduction().then((res: any) => {
if (res.code == 200) {
let data = res.data
console.log(data.series, 'data.series');
seriesData.value = data.series.map(item=>{
return {
name: item.name == '计划完成' ? '计划产量' : '实际产量',
type: 'bar',
data: item.data
}
})
xData.value = data.xData
}
})
}
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
console.log(data, 'data');
for (let key in data) {
const devObj = {
'裁剪设备':cjdata.value,
'缝前设备':fqdata.value,
'缝中设备':fzdata.value,
}
const statusObj = {
'裁剪设备':0,
'缝前设备':1,
'缝中设备':2,
}
if (devObj.hasOwnProperty(key)) {
let online = 0;
devObj[key].list = data[key].map((item: any, i: number) => {
if (item.status == 'true' || item.status == '2') {
online++
}
let temp = item.status
if (item.status == "true") {
temp = '2'
} else if (item.status == "false") {
temp = '0'
}
return [i + 1, item.name, item.num, temp, item.ratio, item.workTime]
})
stepList[statusObj[key]].online = online;
stepList[statusObj[key]].total = devObj[key].list.length;
}
// if (key == '裁剪设备') {
// let online = 0;
// cjdata.value.list = data[key].map((item: any, i: number) => {
// if (item.status == 'true' || item.status == '2') {
// online++
// }
// return [i + 1, item.name, item.num, item.status, item.ratio, item.workTime]
// })
// stepList[0].online = online;
// stepList[0].total = cjdata.value.list.length;
// }
// if (key == '缝前设备') {
// let online = 0;
// fqdata.value.list = data[key].map((item: any, i: number) => {
// if (item.status == 'true' || item.status == '2') {
// online++
// }
// return [i + 1, item.name, item.num, item.status, item.ratio, item.workTime]
// })
// stepList[1].online = online;
// stepList[1].total = fqdata.value.list.length;
// }
// if (key == '缝中设备') {
// let online = 0;
// fzdata.value.list = data[key].map((item: any, i: number) => {
// if (item.status == 'true' || item.status == '2') {
// online++
// }
// return [i + 1, item.name, item.num, item.status, item.ratio, item.workTime]
// })
// stepList[2].online = online;
// stepList[2].total = fzdata.value.list.length;
// }
if (key == '后整设备') {
let online = 0;
hzdata.value = data[key].map((item: any, i: number) => {
if (item.status == 'true' || item.status == '2') {
online++
}
let temp = item.status
if (item.status == "true") {
temp = '2'
} else if (item.status == "false") {
temp = '0'
}
return {
name: item.name,
num: item.num,
status: temp,
ratio: item.ratio,
rationum: parseInt(item.ratio.split('%')[0]),
workTime: item.workTime,
}
})
console.log(hzdata.value, 'hzdata.value');
stepList[3].online = online;
stepList[3].total = hzdata.value.length;
}
}
}
})
}
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-05 09:01:51 +00:00
// if (data.type == 'StateChart') {
// store.setDevnum(data.msg)
// }
// 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
// function videoToBase64(file) {
// return new Promise((resolve, reject) => {
// let reader:any = new FileReader();
// reader.readAsDataURL(file);
// reader.onload = () => {
// let base64 = reader.result.split(',')[1];
// resolve(base64);
// };
// reader.onerror = error => reject(error);
// });
// }
// async function loadeddataFun() {
// if (localStorage.getItem('videoUrl')) {
// return
// }
// const response:any = await fetch(videoWebUrl);
// const blob = await response.blob();
// const fileReader:any = new FileReader();
// console.log(response,'21313');
// fileReader.readAsDataURL(response);
// fileReader.onloadend = function () {
// const file = new File([fileReader.result], 'video.mp4', { type: 'video/mp4' });
// videoUrl.value = URL.createObjectURL(file);
// let base64 = fileReader.result.split(',')[1];
// localStorage.setItem('videoUrl', base64 )
// };
// fileReader.readAsArrayBuffer(blob);
// }
2023-09-08 08:03:33 +00:00
onMounted(() => {
2023-12-07 08:58:49 +00:00
getDeviceProduction()
2023-12-07 08:49:09 +00:00
getmDevList()
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-05 09:01:51 +00:00
document.getElementById('app').style.backgroundColor = 'rgba(0, 11, 18, 1)'
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>