forked from mt-fe-group/mt-yd-ui
update 设备实时
This commit is contained in:
parent
6bbc0d3d08
commit
70485d293c
@ -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',
|
||||||
@ -42,25 +38,23 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.clearData()
|
this.clearData()
|
||||||
this.fetchList('equipment').then(({data: res}) => {
|
this.fetchList('equipment').then(({ data: res }) => {
|
||||||
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) {
|
||||||
this.tableProps.push({
|
if (obj.recordTime) {
|
||||||
label: moment(obj.recordTime).format('YYYY-MM-DD HH:mm:ss'),
|
// 如果 obj.recordTime 是有效的
|
||||||
children: [
|
this.tableProps.push({
|
||||||
// { prop: obj.recordTime + '-inputNum', label: i18n.t('module.factory.realtime.equipment.input') },
|
label: moment(obj.recordTime).format('YYYY-MM-DD HH:mm:ss'),
|
||||||
// { prop: obj.recordTime + '-outputNum', label: i18n.t('module.factory.realtime.equipment.output') },
|
children: [
|
||||||
// { prop: obj.recordTime + '-scrapNum', label: i18n.t('module.factory.realtime.equipment.scrapNum') },
|
{ prop: obj.recordTime + '-inputNum', label: '进数据' },
|
||||||
// {
|
{ prop: obj.recordTime + '-outputNum', label: '出数据' },
|
||||||
// prop: obj.recordTime + '-scrapRate',
|
{ prop: obj.recordTime + '-scrapNum', label: '报废数据' },
|
||||||
// label: i18n.t('module.factory.realtime.equipment.scrapRate')
|
{ prop: obj.recordTime + '-scrapRate', label: '报废比例' }
|
||||||
// }
|
]
|
||||||
]
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user