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

244 lines
6.5 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" :table-props="tableProps" :table-data="tableData" />
<SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
<line-chart ref="lineChart" />
</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 { getYieldAnalysisPageData } from '@/api/core/analysis/index';
2023-11-07 15:53:01 +08:00
// import { getProductionLinePage } from '@/api/core/base/productionLine';
2023-09-13 16:00:43 +08:00
import lineChart from '../LineChart'
2023-11-11 20:49:31 +08:00
import moment from 'moment';
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:[
// // ]
// // }
// ];
2023-09-11 16:09:07 +08:00
export default {
2023-09-13 16:00:43 +08:00
components: {
lineChart,
},
// mixins: [basicPage],
2023-09-11 16:09:07 +08:00
data() {
return {
urlOptions: {
2023-09-13 16:00:43 +08:00
getDataListURL: getYieldAnalysisPageData,
2023-09-11 16:09:07 +08:00
},
2023-09-13 16:00:43 +08:00
tableProps:[],
dataListLoading:false,
tableData: [],
listQuery: {
2023-11-07 15:53:01 +08:00
// lineIds: [],
recordTime: []
2023-09-13 16:00:43 +08:00
},
2023-10-08 16:59:09 +08:00
dateLabelList: [],
2023-11-11 20:49:31 +08:00
tempTtime: '',
day: 0,
xData: [],
2023-09-11 16:09:07 +08:00
formConfig: [
2023-11-07 15:53:01 +08:00
// {
// type: 'select',
// label: '产线',
// selectOptions: [],
// param: 'lineIds',
// defaultSelect: '',
// multiple:true,
// filterable: true,
// },
2023-09-11 16:09:07 +08:00
{
type: 'datePicker',
label: '时间',
2023-10-12 17:04:03 +08:00
dateType: 'month',
2023-09-11 16:09:07 +08:00
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
2023-09-13 16:00:43 +08:00
param: 'time',
2023-09-11 16:09:07 +08:00
},
{
type: 'button',
2023-10-16 15:47:31 +08:00
btnName: '查询',
2023-09-11 16:09:07 +08:00
name: 'search',
color: 'primary',
2023-09-13 16:00:43 +08:00
}
2023-09-11 16:09:07 +08:00
],
};
},
created() {
2023-11-07 15:53:01 +08:00
// this.getArr();
2023-09-11 16:09:07 +08:00
},
methods: {
2023-11-07 15:53:01 +08:00
// getArr() {
// const params = {
// page: 1,
// limit: 500,
// };
// this.optionArrUrl.forEach((item, index) => {
// item(params).then((response) => {
// this.formConfig[index].selectOptions = response.data.list
// // this.formConfig[0].defaultSelect = response.data.list[0].id
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id)
// });
// });
// },
2023-11-11 20:49:31 +08:00
// 设置表头和横坐标
setHeader() {
const month = this.tempTtime.getMonth() + 1
let arr = [
{
prop: 'proName',
label: '产品名称',
fixed: 'left'
},
{
prop: 'specifications',
label: '产品规格',
fixed: 'left'
},
{
prop: 'sum',
label: '合计',
fixed: 'left'
},
{
label: this.tempTtime.getFullYear() + '年' + month + '月',
align: 'center',
children: []
}
]
for (let d = 1; d <= this.day; d ++) {
arr[3].children.push({
prop: 'value' + d, label: month + '-' + d
})
// 横坐标
this.xData.push(month + '-' + d)
}
this.tableProps = arr
},
2023-09-13 16:00:43 +08:00
getData() {
this.urlOptions.getDataListURL(this.listQuery).then(res => {
2023-11-11 20:49:31 +08:00
//构造数据
2023-10-08 16:59:09 +08:00
if (res.data) {
2023-11-11 20:49:31 +08:00
this.setHeader()
res.data.forEach(item => {
console.log('111', item.recordTime, moment(item.recordTime).format('DD'))
this.tableData.push({
proName: item.proName,
specifications: item.specifications
2023-09-13 16:00:43 +08:00
})
2023-11-11 20:49:31 +08:00
})
2023-10-08 16:59:09 +08:00
}
2023-11-11 20:49:31 +08:00
console.log('饿', this.tableData)
// res.data.data.forEach(item => {
// let yData = []
// lineName.push(item.lineName)
// // let obj = {}
// // obj.lineName = item.lineName,
// // obj.sum = item.sum,
// item.data.forEach((ele, index) => {
// // console.log(ele)
// ele.children.forEach((e) => {
// // let yData = []
// yData.push(e.dynamicValue)
// })
// })
// yAllData.push(yData)
// });
// console.log(lineName)
// } else {
// this.tableProps = arr
// this.tableData = []
// xData = []
// yAllData = []
// lineName = []
// }
2023-09-13 16:00:43 +08:00
// res.data.data[0].data[0].children.forEach((item, index) => {
// // console.log(item)
// yData.push(item.dynamicValue)
// // let data = 'data' + Number(index+1)
// // obj['' + item.dynamicName + ''] = item.dynamicValue
// })
// console.log(this.yData)
2023-11-11 20:49:31 +08:00
// this.$refs.lineChart.initChart(this.xData, yAllData, lineName)
2023-09-13 16:00:43 +08:00
// this.total = response.data.total;
// this.dataListLoading = false;
});
},
buttonClick(val) {
2023-09-11 16:09:07 +08:00
switch (val.btnName) {
2023-09-13 16:00:43 +08:00
case 'search':
2023-11-07 15:53:01 +08:00
// this.listQuery.recordTime = val.time ? new Date(val.time).getTime() : undefined
2023-10-08 16:59:09 +08:00
if (val.time) {
2023-11-11 20:49:31 +08:00
this.tempTtime = new Date(val.time)
switch (this.tempTtime.getMonth() + 1) {
2023-11-07 15:53:01 +08:00
case 1, 3, 5, 7, 8, 10, 12:
2023-11-11 20:49:31 +08:00
this.day = 31;
2023-11-07 15:53:01 +08:00
break;
case 2:
2023-11-11 20:49:31 +08:00
this.day = 28;
2023-11-07 15:53:01 +08:00
break;
case 4, 6, 9, 11:
2023-11-11 20:49:31 +08:00
this.day = 30;
2023-11-07 15:53:01 +08:00
break;
}
this.listQuery.recordTime = [
val.time,
2023-11-11 20:49:31 +08:00
parseTime(new Date(this.tempTtime.getFullYear(), this.tempTtime.getMonth(), this.day, 23, 59, 59))
2023-11-07 15:53:01 +08:00
]
2023-10-08 16:59:09 +08:00
this.getData()
} else {
this.$message({
message: '请选择时间',
type: 'warning'
});
}
2023-09-11 16:09:07 +08:00
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.listQuery = {
pageSize: 10,
pageNo: 1,
total: 1,
};
this.getDataList();
break;
default:
console.log(val);
}
},
},
};
</script>