yudao-dev/src/views/energy/monitoring/energyReport/index.vue

180 lines
4.3 KiB
Vue
Raw Normal View History

2023-08-25 16:27:46 +08:00
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick"
/>
<!-- 列表 -->
<base-table
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-props="tableProps"
:table-data="list"
:max-height="tableH"
/>
<pagination
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
:total="total"
@pagination="getList"
/>
</div>
</template>
<script>
2023-09-05 15:45:59 +08:00
import { energyReportPageAuto, energyReportPageExportAuto } from "@/api/monitoring/energyReport"
2023-08-25 16:27:46 +08:00
import { getEnergyTypeListAll } from "@/api/base/energyType";
import { publicFormatter } from '@/utils/dict'
2023-09-05 15:45:59 +08:00
import { parseTime } from '@/utils/ruoyi'
2023-08-25 16:27:46 +08:00
const tableProps = [
{
prop: 'statisticType',
label: '统计类型',
filter: publicFormatter('statistic_type')
},
{
prop: 'startTime',
label: '开始时间',
filter: parseTime,
minWidth: 150
},
{
prop: 'endTime',
label: '结束时间',
filter: parseTime,
minWidth: 150
},
{
prop: 'statisticName',
label: '统计方案'
},
{
prop: 'energyType',
label: '能源类型'
},
{
prop: 'startNum',
label: '抄表数(起始)'
},
{
prop: 'endNum',
label: '抄表数(结束)'
},
{
prop: 'useNum',
label: '消耗量'
}
]
export default {
2023-09-05 15:45:59 +08:00
name: "EnergyLimit",
2023-08-25 16:27:46 +08:00
data() {
return {
formConfig: [
{
type: 'select',
label: '能源类型',
selectOptions: [],
2023-09-05 15:45:59 +08:00
param: 'energyTypeId',
filterable: true
2023-08-25 16:27:46 +08:00
},
{
type: 'select',
label: '统计类型',
selectOptions: this.getDictDatas(this.DICT_TYPE.STATISTIC_TYPE),
labelField: 'label',
valueField: 'value',
param: 'statisticType'
},
{
type: 'datePicker',
label: '时间',
dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss',
2023-09-05 15:45:59 +08:00
valueFormat: "timestamp",
2023-08-25 16:27:46 +08:00
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
defaultSelect: [],
width: 350
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary'
},
{
type: 'separate'
},
{
2023-09-05 15:45:59 +08:00
type: this.$auth.hasPermi('monitoring:energy-report:export') ? 'button' : '',
2023-08-25 16:27:46 +08:00
btnName: '导出',
name: 'add',
color: 'primary',
plain: true
}
],
tableProps,
tableH: this.tableHeight(260),
// 总条数
total: 0,
// 班次基础信息列表
list: [],
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 20,
energyTypeId: null,
2023-09-05 15:45:59 +08:00
statisticType: null,
2023-08-25 16:27:46 +08:00
startTime: null,
2023-09-05 15:45:59 +08:00
endTime: null
}
2023-08-25 16:27:46 +08:00
};
},
created() {
window.addEventListener('resize', () => {
this.tableH = this.tableHeight(260)
})
2023-09-05 15:45:59 +08:00
this.getList()
2023-08-25 16:27:46 +08:00
this.getTypeList()
},
methods: {
getTypeList() {
getEnergyTypeListAll().then((res) => {
this.formConfig[0].selectOptions = res.data || []
// this.energyTypeList = res.data || []
})
},
buttonClick(val) {
switch (val.btnName) {
case 'search':
2023-09-05 15:45:59 +08:00
this.queryParams.pageNo = 1
2023-08-25 16:27:46 +08:00
this.queryParams.energyTypeId = val.energyTypeId
this.queryParams.statisticType = val.statisticType
2023-09-05 15:45:59 +08:00
this.queryParams.startTime = val.timeVal ? val.timeVal[0] : null
this.queryParams.endTime = val.timeVal ? val.timeVal[1] : null
2023-08-25 16:27:46 +08:00
this.getList()
break
default:
2023-09-05 15:45:59 +08:00
this.$modal.confirm('是否确认导出').then(() => {
return energyReportPageExportAuto({...this.queryParams});
}).then(response => {
this.$download.excel(response, '能源统计报表.xls');
}).catch(() => {})
2023-08-25 16:27:46 +08:00
}
},
/** 查询列表 */
getList() {
2023-09-05 15:45:59 +08:00
energyReportPageAuto(this.queryParams).then(response => {
this.list = response.data.list || [];
2023-08-25 16:27:46 +08:00
this.total = response.data.total;
});
}
}
};
</script>