yudao-dev/src/views/report/glass/month.vue

197 lines
6.0 KiB
Vue
Raw Normal View History

2023-12-14 14:01:19 +08:00
<template>
2024-03-07 16:28:23 +08:00
<div class="app-container">
<div>
<el-form :model="listQuery" :inline="true" ref="dataForm" class="blueTip">
<el-form-item label="月" prop="reportTime">
<el-date-picker v-model="reportTime" type="month" size="small" @change="changeTime" placeholder="选择月">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button v-if="this.$auth.hasPermi('report:glass-month:query')" type="primary" size="small"
@click="getDataList">查询</el-button>
<el-button v-if="this.$auth.hasPermi('report:glass-month:export')" type="primary" size="small" plain
@click="handleExport">导出</el-button>
</el-form-item>
</el-form>
</div>
<inputTable :date="date" :data="tableData" :time="[startTimeStamp, endTimeStamp]" :sum="all"
:type="listQuery.reportType" @refreshDataList="getDataList" />
<!-- <pagination
2023-12-14 14:01:19 +08:00
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" /> -->
2024-03-07 16:28:23 +08:00
</div>
2023-12-14 14:01:19 +08:00
</template>
<script>
import { parseTime } from '../../core/mixins/code-filter';
import { getGlassPage, exportGlasscExcel } from '@/api/report/glass';
import inputTable from './inputTable.vue';
import { getCorePLList } from '@/api/base/coreProductionLine';
export default {
components: { inputTable },
data() {
return {
urlOptions: {
getDataListURL: getGlassPage,
exportURL: exportGlasscExcel
},
listQuery: {
pageSize: 10,
pageNo: 1,
total: 0,
reportType: 4,
reportTime: []
2024-03-07 16:28:23 +08:00
},
date: '许昌安彩月原片生产汇总',
2023-12-14 14:01:19 +08:00
reportTime: '',
startTimeStamp: '',
endTimeStamp: '',
tableData: [],
proLineList: [],
all: {}
};
},
2024-03-05 09:48:16 +08:00
created() {
this.getCurrentMonthFirst()
2024-03-08 16:20:03 +08:00
this.getDict()
this.getDataList()
2023-12-14 14:01:19 +08:00
},
methods: {
async getDict() {
// 产线列表
const res = await getCorePLList();
this.proLineList = res.data;
2024-03-05 09:48:16 +08:00
},
getCurrentMonthFirst() {
const date = new Date();
date.setDate(1);
this.reportTime = date
// console.log(date)
this.changeTime(date)
// console.log(date.valueOf());
},
2023-12-14 14:01:19 +08:00
// 获取数据列表
async getDataList() {
this.dataListLoading = true;
await this.urlOptions.getDataListURL(this.listQuery).then(response => {
this.tableData = response.data.filter(item => {
this.proLineList.forEach(it => {
if (item.lineId === it.id) {
2024-03-08 16:20:03 +08:00
item.lineName = it.name
2024-03-11 17:06:38 +08:00
item.originalGlassStatisticsTrend = item.originalGlassStatisticsTrend ? item.originalGlassStatisticsTrend + '%' : null
item.actualProductTrend = item.actualProductTrend ? item.actualProductTrend + '%' : null
item.originalGlassPassTrend = item.originalGlassPassTrend ? item.originalGlassPassTrend * 100 + '%' : null
2023-12-14 14:01:19 +08:00
}
})
if (item.det === false) {
this.all = {
id: item.id,
remark: item.remark
}
}
return item.det === true
});
this.listQuery.total = response.data.length;
this.dataListLoading = false;
});
},
2024-03-05 09:48:16 +08:00
changeTime(val) {
console.log(val)
2023-12-14 14:01:19 +08:00
if(val) {
const timeStamp = val.getMonth(); //标准时间转为时间戳,毫秒级别
const fullyear = val.getFullYear()
let days = 0
switch (timeStamp) {
2024-03-05 09:48:16 +08:00
case 0:
case 2:
case 4:
case 6:
case 7:
case 9:
case 11:
2023-12-14 14:01:19 +08:00
days = 31
break
2024-03-05 09:48:16 +08:00
case 3:
case 4:
case 8:
case 10:
2023-12-14 14:01:19 +08:00
days = 30
break
case 1:
2024-03-05 09:48:16 +08:00
if ((fullyear % 400 === 0) || (fullyear % 4 === 0 && fullyear % 100 !== 0)) {
2023-12-14 14:01:19 +08:00
days = 29
} else {
days = 28
2024-03-05 09:48:16 +08:00
}
break
2023-12-14 14:01:19 +08:00
}
2024-03-11 15:47:46 +08:00
this.startTimeStamp = this.timeFun(new Date(fullyear, timeStamp, 1, 7, 0, 1).getTime()); //开始时间
this.endTimeStamp = this.timeFun(new Date(fullyear, timeStamp, days, 7, 0, 0).getTime()); //结束时间
2023-12-14 14:01:19 +08:00
console.log(this.startTimeStamp, this.endTimeStamp)
2024-03-11 15:47:46 +08:00
this.listQuery.reportTime[0] = parseTime(new Date(fullyear, timeStamp, 1, 7, 0, 1).getTime()) //+ ' 00:00:00' //new Date(this.startTimeStamp + ' 00:00:00').getTime() / 1000
this.listQuery.reportTime[1] = parseTime(new Date(fullyear, timeStamp, days, 7, 0, 0).getTime()) //+ ' 23:59:59' //new Date(this.endTimeStamp + ' 23:59:59').getTime() / 1000
2023-12-14 14:01:19 +08:00
} else {
this.listQuery.reportTime = []
}
},
//时间戳转为yy-mm-dd hh:mm:ss
timeFun(unixtimestamp) {
var unixtimestamp = new Date(unixtimestamp);
var year = 1900 + unixtimestamp.getYear();
var month = "0" + (unixtimestamp.getMonth() + 1);
var date = "0" + unixtimestamp.getDate();
return year + "-" + month.substring(month.length - 2, month.length) + "-" + date.substring(date.length - 2, date.length)
},
buttonClick(val) {
this.listQuery.reportTime = val.reportTime ? val.reportTime : undefined;
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.getDataList();
break;
case 'export':
this.handleExport();
break;
default:
console.log(val);
}
},
/** 导出按钮操作 */
handleExport() {
// 处理查询参数
let params = { ...this.listQuery };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出所有数据项?').then(() => {
this.exportLoading = true;
return this.urlOptions.exportURL(params);
}).then(response => {
this.$download.excel(response, '原片生产周报.xls');
this.exportLoading = false;
}).catch(() => { });
}
},
};
</script>
<style scoped>
/* .blueTip { */
/* padding-bottom: 10px; */
/* } */
.blueTip::before{
display: inline-block;
content: '';
width: 4px;
height: 18px;
background: #0B58FF;
border-radius: 1px;
margin-right: 8PX;
margin-top: 8px;
}
</style>