yudao-dev/src/views/core/analysis/balanceAnalysis/index.vue

263 lines
7.2 KiB
Vue
Raw Normal View History

2023-09-11 16:09:07 +08:00
<template>
2023-09-13 16:00:43 +08:00
<div class="app-container">
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
2023-10-16 15:47:31 +08:00
<div v-if="tableData.length">
<base-table v-loading="dataListLoading" :span-method="mergeColumnHandler" :table-props="tableProps" :table-data="tableData" />
<SearchBar :formConfigs="[{ label: '产线平衡分析图', type: 'title' }]" />
2023-11-11 20:49:31 +08:00
<BalanceChart ref="lineChart" />
2023-10-16 15:47:31 +08:00
</div>
<div v-else class="no-data-bg"></div>
2023-09-13 16:00:43 +08:00
<!-- <pagination
2023-09-11 16:09:07 +08:00
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
2023-09-13 16:00:43 +08:00
@pagination="getDataList" /> -->
</div>
2023-09-11 16:09:07 +08:00
</template>
<script>
2023-09-13 16:00:43 +08:00
// import basicPage from '../../mixins/basic-page';
2023-09-11 16:09:07 +08:00
import { parseTime } from '../../mixins/code-filter';
2023-09-13 16:00:43 +08:00
import { getCT } from '@/api/core/analysis/index';
2023-11-11 20:49:31 +08:00
import { getCorePLList } from '@/api/base/coreProductionLine';
2023-09-20 13:58:14 +08:00
import BalanceChart from '../balanceChart'
2023-09-16 17:51:09 +08:00
import { time } from 'echarts';
2023-09-13 16:00:43 +08:00
// import { getWorkshopSectionPage } from '@/api/core/base/workshopSection';
2023-09-11 16:09:07 +08:00
2023-09-13 16:00:43 +08:00
// const tableProps = [
// // {
// // prop: 'lineName',
// // label: '产线',
// // align: 'center',
// // },
// // {
// // prop: 'sum',
// // label: '合计',
// // align: 'center',
// // },
// // {
// // prop: 'dynamicValue',
// // label: 'dynamicName',
// // align: 'center',
// // children:[
// // ]
// // }
// ];
export default {
components: {
2023-09-20 13:58:14 +08:00
BalanceChart
2023-09-11 16:09:07 +08:00
},
2023-09-13 16:00:43 +08:00
// mixins: [basicPage],
data() {
return {
urlOptions: {
getDataListURL: getCT,
},
tableProps: [],
dataListLoading: false,
tableData: [],
listQuery: {
// time: ''
endTime: undefined,
lineId:undefined,
startTime:undefined
},
2023-09-16 17:51:09 +08:00
timeList: [],
spanArr: [],
2023-09-13 16:00:43 +08:00
xData: [],
yData: [],
2023-11-11 20:49:31 +08:00
optionArrUrl: [getCorePLList],
2023-09-13 16:00:43 +08:00
formConfig: [
{
type: 'select',
label: '产线',
selectOptions: [],
param: 'lineIds',
defaultSelect: '',
2023-09-16 17:51:09 +08:00
multiple: false,
2023-09-13 16:00:43 +08:00
filterable: true,
},
{
type: 'datePicker',
label: '时间',
2023-09-16 17:51:09 +08:00
dateType: 'datetimerange',
2023-09-13 16:00:43 +08:00
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
2023-09-16 17:51:09 +08:00
width: 350,
2023-09-13 16:00:43 +08:00
param: 'time',
},
{
type: 'button',
2023-10-16 15:47:31 +08:00
btnName: '查询',
2023-09-13 16:00:43 +08:00
name: 'search',
color: 'primary',
}
],
};
2023-09-11 16:09:07 +08:00
},
2023-09-13 16:00:43 +08:00
created() {
this.getArr();
2023-09-11 16:09:07 +08:00
},
2023-09-13 16:00:43 +08:00
methods: {
getArr() {
const params = {
page: 1,
2023-09-20 13:58:14 +08:00
limit: 500
}
2023-09-13 16:00:43 +08:00
this.optionArrUrl.forEach((item, index) => {
item(params).then((response) => {
2023-11-11 20:49:31 +08:00
this.formConfig[index].selectOptions = response.data
2023-09-13 16:00:43 +08:00
});
});
},
2023-09-16 17:51:09 +08:00
setRowSpan(arr) {
let count = 0
arr.forEach((item, index) => {
if(index === 0) {
this.spanArr.push(1)
} else {
if (item === arr[index - 1]) {
this.spanArr[count] += 1
this.spanArr.push(0)
} else {
count = index
this.spanArr.push(1)
}
}
})
},
/** 合并table列的规则 */
mergeColumnHandler({ row, column, rowIndex, columnIndex }) {
if (columnIndex == 0) {
if (this.spanArr[rowIndex]) {
return [
this.spanArr[rowIndex], // row span
1, // col span
];
} else {
return [0, 0];
}
}
},
2023-09-13 16:00:43 +08:00
getData() {
2023-09-16 17:51:09 +08:00
// this.listQuery.lineId = '1672847052717821953'
// this.listQuery.startTime = '1693497600000';
// this.listQuery.endTime = '1693843200000';
2023-09-13 16:00:43 +08:00
this.urlOptions.getDataListURL(this.listQuery).then(res => {
console.log(res)
let arr = [
{
prop: 'sectionName',
label: '工段',
align: 'center',
},
{
prop: 'equName',
label: '设备',
align: 'center',
2023-09-16 17:51:09 +08:00
}
2023-09-13 16:00:43 +08:00
]
2023-09-16 17:51:09 +08:00
let sectionArr= []
2023-09-13 16:00:43 +08:00
res.data.data.forEach((ele, index) => {
2023-09-16 17:51:09 +08:00
let tempData = []
2023-09-20 13:58:14 +08:00
let eqData = []
let plData = []
ele.data.forEach((item, index) => {
2023-09-16 17:51:09 +08:00
item.children.forEach(params => {
if (params.dynamicName === '设备CT') {
tempData[item.dynamicName + '_eq'] = params.dynamicValue
2023-09-20 13:58:14 +08:00
eqData[index] = params.dynamicValue
2023-09-16 17:51:09 +08:00
} else {
tempData[item.dynamicName + '_pl'] = params.dynamicValue
2023-09-20 13:58:14 +08:00
plData[index] = params.dynamicValue
2023-09-16 17:51:09 +08:00
}
})
})
2023-09-20 13:58:14 +08:00
const equipment = {
name: ele.equName,
eqData: eqData,
plData: plData
}
2023-09-16 17:51:09 +08:00
tempData['equName'] = ele.equName
tempData['sectionName'] = ele.sectionName
this.tableData.push(tempData)
const { sectionName } = tempData
sectionArr.push(sectionName)
2023-09-20 13:58:14 +08:00
this.yData.push(equipment)
console.log('看看equ', this.yData)
2023-09-13 16:00:43 +08:00
})
2023-09-16 17:51:09 +08:00
this.setRowSpan(sectionArr)
2023-09-13 16:00:43 +08:00
res.data.nameData.forEach(item => {
2023-09-16 17:51:09 +08:00
this.timeList.push(item.name)
})
const timeArray = Array.from(new Set(this.timeList))
for (const times of timeArray) {
if (times !== '设备CT' && times !== '产线CT') {
const subprop = {
label: times,
align: 'center',
children: [
{ prop: times + '_eq', label: '设备CT', align: 'center' },
{ prop: times + '_pl', label: '产线CT', align: 'center' }
]
2023-09-13 16:00:43 +08:00
}
2023-09-16 17:51:09 +08:00
arr.push(subprop)
2023-09-20 13:58:14 +08:00
this.xData.push(times)
2023-09-13 16:00:43 +08:00
}
}
this.tableProps = arr
2023-09-11 16:09:07 +08:00
2023-11-11 20:49:31 +08:00
console.log('表格横坐标', this.xData, this.yData)
this.$nextTick(() => {
this.$refs.lineChart.initChart(this.xData, this.yData)
})
2023-09-13 16:00:43 +08:00
// this.total = response.data.total;
// this.dataListLoading = false;
});
},
buttonClick(val) {
// console.log(val)
switch (val.btnName) {
case 'search':
// this.listQuery.pageNo = 1;
// this.listQuery.pageSize = 10;
2023-09-16 17:51:09 +08:00
this.listQuery.lineId = val.lineIds
this.listQuery.startTime = val.time ? String(new Date(val.time[0]).getTime()) : undefined;
this.listQuery.endTime = val.time ? String(new Date(val.time[1]).getTime()) : undefined;
2023-10-12 17:04:03 +08:00
if (val.time && val.lineIds) {
this.tableData = []
this.xData = []
this.yData = []
this.tableProps = []
this.spanArr = []
this.timeList = []
2023-10-08 16:59:09 +08:00
this.getData()
} else {
this.$message({
2023-10-12 17:04:03 +08:00
message: '请选择产线和时间',
2023-10-08 16:59:09 +08:00
type: 'warning'
});
}
2023-09-13 16:00:43 +08:00
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.listQuery = {
pageSize: 10,
pageNo: 1,
total: 1,
};
this.getDataList();
break;
default:
console.log(val);
}
},
},
2023-09-11 16:09:07 +08:00
};
</script>