2023-08-30 10:27:49 +08:00
|
|
|
<!--
|
|
|
|
filename: index.vue
|
|
|
|
author: liubin
|
|
|
|
date: 2023-08-04 14:44:58
|
2023-08-30 14:32:05 +08:00
|
|
|
description: 设备24小时生产记录
|
2023-08-30 10:27:49 +08:00
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="app-container">
|
|
|
|
<SearchBar
|
2023-08-30 14:32:05 +08:00
|
|
|
:formConfigs="[{ label: '设备近24小时生产记录', type: 'title' }]"
|
2023-08-30 10:27:49 +08:00
|
|
|
ref="search-bar" />
|
|
|
|
<el-skeleton v-if="initing" :rows="6" animated />
|
2023-09-18 15:05:06 +08:00
|
|
|
<div v-else :class="{ 'no-data-bg': !list || list.length == 0 }">
|
2023-09-13 17:06:02 +08:00
|
|
|
<base-table
|
2023-09-18 15:05:06 +08:00
|
|
|
v-if="list && list.length > 0"
|
2023-09-13 17:06:02 +08:00
|
|
|
:span-method="mergeColumnHandler"
|
|
|
|
:table-props="tableProps"
|
|
|
|
:table-data="list"
|
|
|
|
@emitFun="handleEmitFun"></base-table>
|
|
|
|
<!-- :page="queryParams.pageNo"
|
|
|
|
:limit="queryParams.pageSize" -->
|
|
|
|
</div>
|
2023-08-30 10:27:49 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-09-25 15:47:39 +08:00
|
|
|
import moment from 'moment';
|
|
|
|
|
2023-08-30 10:27:49 +08:00
|
|
|
export default {
|
|
|
|
name: 'QualityRecentHours',
|
|
|
|
components: {},
|
|
|
|
props: {},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
initing: false,
|
|
|
|
queryParams: {
|
|
|
|
pageNo: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
},
|
2023-08-30 14:32:05 +08:00
|
|
|
list: [],
|
|
|
|
tableProps: [],
|
2023-08-30 10:27:49 +08:00
|
|
|
spanInfo: {},
|
2023-09-13 17:06:02 +08:00
|
|
|
noData: true,
|
2023-08-30 10:27:49 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {},
|
|
|
|
mounted() {
|
|
|
|
this.getList();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
/** 构建tableProps - 依据第一个元素所提供的信息 */
|
|
|
|
buildProps(item) {
|
2023-08-30 11:37:11 +08:00
|
|
|
const {
|
|
|
|
data: [{ hourData }],
|
|
|
|
} = item;
|
|
|
|
|
|
|
|
const props = [
|
2023-09-15 14:30:19 +08:00
|
|
|
{ prop: 'productLine', label: '产线' },
|
|
|
|
{ prop: 'specification', label: '规格' },
|
|
|
|
{ prop: 'equipmentName', label: '设备' },
|
|
|
|
{ prop: 'totalQuantity', label: '生产总数' },
|
2023-08-30 11:37:11 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
for (const key of Object.keys(hourData).sort()) {
|
|
|
|
const subprop = {
|
2023-09-25 15:47:39 +08:00
|
|
|
// label: 'key',
|
|
|
|
label: moment(key).format('YYYY-MM-DD HH:mm:ss'),
|
2023-08-30 11:37:11 +08:00
|
|
|
children: [
|
2023-09-15 14:30:19 +08:00
|
|
|
{ prop: key + '__in', label: '进数据' },
|
|
|
|
{ prop: key + '__out', label: '出数据' },
|
|
|
|
{ prop: key + '__nok', label: '报废数据' },
|
2023-08-30 14:30:08 +08:00
|
|
|
{
|
|
|
|
prop: key + '__ratio',
|
|
|
|
label: '报废率',
|
|
|
|
filter: (val) => (val != null ? val + ' %' : '-'),
|
|
|
|
},
|
2023-08-30 11:37:11 +08:00
|
|
|
],
|
|
|
|
};
|
|
|
|
props.push(subprop);
|
|
|
|
}
|
2023-08-30 10:27:49 +08:00
|
|
|
|
|
|
|
this.tableProps = props;
|
|
|
|
},
|
|
|
|
|
|
|
|
/** 把 list 里的数据转换成 tableProps 对应的格式 */
|
2023-08-30 11:37:11 +08:00
|
|
|
convertList(list) {
|
|
|
|
this.list.splice(0);
|
|
|
|
let rowIndex = 0;
|
|
|
|
for (const line of list) {
|
2023-09-25 15:47:39 +08:00
|
|
|
const {
|
|
|
|
productLine,
|
|
|
|
specification = [],
|
|
|
|
data,
|
|
|
|
} = line;
|
2023-08-30 11:37:11 +08:00
|
|
|
|
|
|
|
// 设置span的行数
|
|
|
|
this.spanInfo[rowIndex] = data.length;
|
|
|
|
for (const equipment of data) {
|
2023-08-30 14:30:08 +08:00
|
|
|
const { equipmentName, totalQuantity } = equipment;
|
|
|
|
let row = {
|
|
|
|
productLine,
|
|
|
|
specification: specification.join('、'),
|
|
|
|
equipmentName,
|
|
|
|
totalQuantity,
|
|
|
|
};
|
2023-08-30 14:11:24 +08:00
|
|
|
rowIndex += 1;
|
2023-08-30 11:37:11 +08:00
|
|
|
for (const [key, hourData] of Object.entries(equipment.hourData)) {
|
|
|
|
const { inQuantity, outQuantity, nokQuantity, scrapRatio } =
|
|
|
|
hourData;
|
|
|
|
row[key + '__in'] = inQuantity;
|
|
|
|
row[key + '__out'] = outQuantity;
|
|
|
|
row[key + '__nok'] = nokQuantity;
|
|
|
|
row[key + '__ratio'] = scrapRatio;
|
|
|
|
}
|
2023-08-30 14:30:08 +08:00
|
|
|
this.list.push(row);
|
2023-08-30 11:37:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
buildData(data) {
|
|
|
|
this.convertList(data);
|
2023-08-30 10:27:49 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/** 合并table列的规则 */
|
|
|
|
mergeColumnHandler({ row, column, rowIndex, columnIndex }) {
|
2023-08-30 14:30:08 +08:00
|
|
|
if (columnIndex == 0 || columnIndex == 1) {
|
|
|
|
if (this.spanInfo[rowIndex]) {
|
2023-08-30 11:37:11 +08:00
|
|
|
return [
|
2023-08-30 14:30:08 +08:00
|
|
|
this.spanInfo[rowIndex], // row span
|
2023-08-30 11:37:11 +08:00
|
|
|
1, // col span
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
return [0, 0];
|
|
|
|
}
|
2023-08-30 10:27:49 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
async getList() {
|
2023-08-30 14:30:08 +08:00
|
|
|
const { data } = await this.$axios({
|
|
|
|
url: '/monitoring/equipment-monitor/recent-24-hours',
|
|
|
|
method: 'get',
|
|
|
|
});
|
|
|
|
|
|
|
|
// const data = this.res.data;
|
|
|
|
// console.log('recent-24', data);
|
2023-08-30 10:27:49 +08:00
|
|
|
|
2023-08-30 14:30:08 +08:00
|
|
|
this.initing = true;
|
2023-09-13 17:06:02 +08:00
|
|
|
|
|
|
|
if (!data || !data.length) {
|
|
|
|
this.initing = false;
|
|
|
|
this.noData = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.noData = false;
|
2023-08-30 11:37:11 +08:00
|
|
|
this.buildProps(data[0]);
|
|
|
|
this.buildData(data);
|
2023-08-30 14:30:08 +08:00
|
|
|
this.queryParams.pageSize = this.list.length;
|
2023-08-30 10:27:49 +08:00
|
|
|
|
2023-08-30 14:30:08 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
this.initing = false;
|
|
|
|
}, 1000);
|
2023-08-30 10:27:49 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
handleEmitFun(payload) {
|
|
|
|
console.log('payload', payload);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
::-webkit-scrollbar {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
pre {
|
|
|
|
margin: 10px;
|
|
|
|
background: #f6f8faf6;
|
|
|
|
border: 1px solid #e1e4e8;
|
|
|
|
padding: 12px;
|
|
|
|
border-radius: 12px;
|
|
|
|
position: fixed;
|
|
|
|
// top: 15vh;
|
|
|
|
top: 10vh;
|
|
|
|
left: 0;
|
|
|
|
max-height: 80vh;
|
|
|
|
overflow-y: auto;
|
|
|
|
z-index: 100000;
|
|
|
|
box-shadow: 0 0 32px 12px #0001;
|
|
|
|
}
|
|
|
|
|
|
|
|
code {
|
|
|
|
font-family: 'IntelOne Mono', 'Ubuntu', 'Courier New', Courier, monospace;
|
|
|
|
}
|
|
|
|
</style>
|