update 设备实时

This commit is contained in:
g7hoo 2022-08-23 14:00:45 +08:00
parent 6bbc0d3d08
commit 70485d293c

View File

@ -8,7 +8,6 @@
<template> <template>
<div> <div>
<div class="app-container"> <div class="app-container">
<!-- <small-title :size="'md'">{{ $t('module.factory.realtime.equipment.name') }}</small-title> -->
<small-title :size="'md'">设备生产实时数据</small-title> <small-title :size="'md'">设备生产实时数据</small-title>
<base-table v-if="loadTable" :table-head-configs="tableProps" :data="tableData.length ? tableData : []" :span-method="spanMethod" /> <base-table v-if="loadTable" :table-head-configs="tableProps" :data="tableData.length ? tableData : []" :span-method="spanMethod" />
</div> </div>
@ -19,9 +18,6 @@
import BaseTable from '@/components/base-table' import BaseTable from '@/components/base-table'
import SmallTitle from '@/components/small-title' import SmallTitle from '@/components/small-title'
import moment from 'moment' import moment from 'moment'
// import fetchList from '@/api/factory-manage/realtimeData'
const fetchList = () => {}
export default { export default {
name: 'RealtimeDataOfEquipment', name: 'RealtimeDataOfEquipment',
@ -46,21 +42,19 @@ export default {
this.testData = res.data.filter(item => !!item.equDet) this.testData = res.data.filter(item => !!item.equDet)
this.handleData() this.handleData()
}) })
// this.loadTable = true this.intervalId = setInterval(() => {
// this.intervalId = setInterval(() => { this.$message({
// this.$message({ type: 'warning',
// // message: this.$t('module.factory.realtime.equipment.refresh'), duration: 1500,
// type: 'warning', onClose: () => {
// duration: 1500, this.clearData()
// onClose: () => { fetchList('equipment').then(({ data: res }) => {
// this.clearData() this.testData = res.data.filter(item => !!item.equDet)
// fetchList('equipment').then(res => { this.handleData()
// this.testData = res })
// this.handleData() }
// }) })
// } }, 1000 * 60 * 5)
// })
// }, 1000 * 60 * 5)
}, },
beforeDestroy() { beforeDestroy() {
if (this.intervalId) clearInterval(this.intervalId) if (this.intervalId) clearInterval(this.intervalId)
@ -81,7 +75,6 @@ export default {
handleData() { handleData() {
this.expandDataStepOne() this.expandDataStepOne()
this.expandDataStepTwo() this.expandDataStepTwo()
// console.log('span data: ', this.equipmentCount)
this.loadTable = true this.loadTable = true
}, },
@ -93,68 +86,52 @@ export default {
}) })
}, },
testSpan({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 1 && rowIndex % 2 === 0) {
return [2, 1]
}
if (columnIndex === 1 && rowIndex % 2 !== 0) {
return [0, 0]
}
},
expandDataStepOne() { expandDataStepOne() {
console.log('testdata: ', this.testData) console.log('testdata: ', this.testData)
// this.stepOneArray = this.testData.data this.stepOneArray = this.testData.map(item => {
// .filter(item => item.equDet) if (item.equDet) {
// .map(item => { item.equDet.forEach((equipment, index) => {
// if (item.equDet) { equipment.lineName = item.lineName
// item.equDet.forEach((equipment, index) => { })
// equipment.lineName = item.lineName }
// }) return item.equDet
// } })
// return item.equDet
// })
}, },
expandDataStepTwo() { expandDataStepTwo() {
// //
console.log('before step two: ', this.stepOneArray)
this.rowNum = 0 this.rowNum = 0
this.stepOneArray.forEach(arrayItem => { this.stepOneArray.forEach(line => {
let count = 0 let avaliableEquipmentCount = 0
arrayItem.forEach(item => { line.forEach(equipment => {
// console.log('========= ', item.equName, ' ==========')
const newItem = { const newItem = {
equId: item.equId, equId: equipment.equId,
lineName: item.lineName, lineName: equipment.lineName,
equName: item.equName, equName: equipment.equName,
productSize: item.productSize, externalCode: equipment.externalCode,
orderName: item.orderName, totalProduction: equipment.totalProduction ?? '-'
externalCode: item.externalCode,
totalProduction: item.totalProduction ?? '-'
} }
if (item.det) {
count += 1 if (equipment.det) {
item.det.forEach(obj => { avaliableEquipmentCount += 1
// Step2: props equipment.det.forEach(obj => {
if (!this.dynamicPropSet) { if (!this.dynamicPropSet) {
if (obj.recordTime) {
// obj.recordTime
this.tableProps.push({ this.tableProps.push({
label: moment(obj.recordTime).format('YYYY-MM-DD HH:mm:ss'), label: moment(obj.recordTime).format('YYYY-MM-DD HH:mm:ss'),
children: [ children: [
// { prop: obj.recordTime + '-inputNum', label: i18n.t('module.factory.realtime.equipment.input') }, { prop: obj.recordTime + '-inputNum', label: '进数据' },
// { prop: obj.recordTime + '-outputNum', label: i18n.t('module.factory.realtime.equipment.output') }, { prop: obj.recordTime + '-outputNum', label: '出数据' },
// { prop: obj.recordTime + '-scrapNum', label: i18n.t('module.factory.realtime.equipment.scrapNum') }, { prop: obj.recordTime + '-scrapNum', label: '报废数据' },
// { { prop: obj.recordTime + '-scrapRate', label: '报废比例' }
// prop: obj.recordTime + '-scrapRate',
// label: i18n.t('module.factory.realtime.equipment.scrapRate')
// }
] ]
}) })
} }
}
// console.log('==> ',obj.recordTime, obj.inputNum, obj.outputNum, obj.scrapNum, obj.scrapRate)
Object.defineProperty(newItem, obj.recordTime + '-inputNum', { Object.defineProperty(newItem, obj.recordTime + '-inputNum', {
value: obj.inputNum ?? '-', value: obj.inputNum ?? '-',
enumerable: true, enumerable: true,
@ -186,28 +163,24 @@ export default {
this.tableData.push(newItem) this.tableData.push(newItem)
} }
}) })
this.$set(this.equipmentCount, [this.rowNum], avaliableEquipmentCount)
this.$set(this.equipmentCount, [this.rowNum], count) this.rowNum += avaliableEquipmentCount
this.rowNum += count
}) })
}, },
setStaticTableProps() { setStaticTableProps() {
// Step1: table props // Step1: table props
const staticTableProps = [ const staticTableProps = [
// { prop: 'lineName', label: i18n.t('module.factory.realtime.equipment.pl'), fixed: true }, { prop: 'lineName', label: '产线', fixed: true },
// { prop: 'orderName', label: i18n.t('module.factory.realtime.equipment.currOrder'), fixed: true }, { prop: 'equName', label: '设备', fixed: true },
// { prop: 'productSize', label: i18n.t('module.factory.realtime.equipment.pSpecs'), fixed: true }, { prop: 'totalProduction', label: '总产量', fixed: true }
// { prop: 'equName', label: i18n.t('module.factory.realtime.equipment.eqName'), fixed: true },
// { prop: 'totalProduction', label: i18n.t('module.factory.realtime.equipment.produceTotal'), fixed: true }
] ]
this.tableProps = staticTableProps this.tableProps = staticTableProps
}, },
spanMethod({ row, column, rowIndex, columnIndex }) { spanMethod({ row, column, rowIndex, columnIndex }) {
// //
if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2) { if (columnIndex === 0) {
// 3
if (this.equipmentCount[rowIndex]) { if (this.equipmentCount[rowIndex]) {
// //
return { return {