Files
charge-pile-system/src/views/reports/yunying_reports.vue

198 lines
4.3 KiB
Vue
Raw Normal View History

2025-11-10 16:14:42 +08:00
<template>
<div class="container">
<div class="search-area">
<Form ref="formInline" inline :label-width="120" :model="formInline" :rules="ruleInline">
<FormItem prop="user" label="站点">
<Input type="text" v-model="formInline.user" placeholder="" />
</FormItem>
<FormItem prop="user" label="充电桩">
<Input type="text" v-model="formInline.user" placeholder="" />
</FormItem>
<FormItem prop="user" label="起止时间">
<Input type="text" v-model="formInline.user" placeholder="" />
</FormItem>
<FormItem>
<Button type="primary" @click="handleSubmit('formInline')">搜索</Button>
</FormItem>
</Form>
</div>
<div class="table-container">
<Table border :columns="columns" stripe :height="tableHeight" :data="data">
<template #action="{ row, index }">
<!-- <Button type="primary" size="small" style="margin-right: 5px" @click="show(index)">详情</Button> -->
</template>
</Table>
<Page :total="total" show-total show-sizer class="page" @on-change="onChangePage"
@on-page-size-change="onChangePageSize" />
</div>
</div>
</template>
<script>
import { getYunYingData } from '@/api'
export default {
name: 'charging_station',
data() {
return {
show_modal: false,
page: 1,
pageSize: 10,
total: 100,
tableHeight: 500,
formInline: {
user: '',
password: '',
},
ruleInline: {},
columns: [{
title: '充电站名称',
2025-11-20 18:08:12 +08:00
key: 'charge_station_name',
2025-11-10 16:14:42 +08:00
},
{
title: '桩类型',
2025-11-20 18:08:12 +08:00
key: 'type',
2025-11-10 16:14:42 +08:00
},
{
title: '桩数量',
2025-11-20 18:08:12 +08:00
key: 'pile_num_2',
2025-11-10 16:14:42 +08:00
},
{
title: '枪数量',
2025-11-20 18:08:12 +08:00
key: 'pile_num',
2025-11-10 16:14:42 +08:00
},
{
2025-11-20 18:08:12 +08:00
title: '充电次数(次)',
key: 'order_num',
2025-11-10 16:14:42 +08:00
},
{
title: '充电电量(度)',
2025-11-20 18:08:12 +08:00
key: 'power',
2025-11-10 16:14:42 +08:00
},
{
title: '充电金额(元)',
2025-11-20 18:08:12 +08:00
key: 'money',
2025-11-10 16:14:42 +08:00
},
{
2025-11-20 18:08:12 +08:00
title: '电费(元)',
key: 'elec',
2025-11-10 16:14:42 +08:00
},
{
2025-11-20 18:08:12 +08:00
title: '服务费(元)',
key: 'sevice',
2025-11-10 16:14:42 +08:00
},
{
2025-11-20 18:08:12 +08:00
title: '总时长(小时)',
key: 'length',
2025-11-10 16:14:42 +08:00
},
{
title: '操作',
slot: 'action',
width: 150,
align: 'center',
},
],
data: [],
}
},
mounted() {
this.getList()
this.calculateTableHeight()
window.addEventListener('resize', this.calculateTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.calculateTableHeight)
},
methods: {
calculateTableHeight() {
// 计算表格高度 = 窗口高度 - 搜索区域高度 - 分页高度 - 其他间距
const searchHeight = document.querySelector('.search-area').offsetHeight
const pageHeight = 32 // 分页组件大约高度
const margins = 40 // 上下边距总和
this.tableHeight = window.innerHeight - searchHeight - pageHeight - margins - 130
},
async getList() {
await getYunYingData({
page: this.page,
pageSize: this.pageSize,
}).then((res) => {
2025-11-20 18:08:12 +08:00
this.total = res.data.total
this.data = res.data.data
2025-11-10 16:14:42 +08:00
})
},
handleSubmit(name) {
this.$refs[name].validate((valid) => {
if (valid) {
this.$Message.success('Success!')
} else {
this.$Message.error('Fail!')
}
})
},
handleReset(name) {
this.$refs[name].resetFields()
},
show(index) {
this.$Modal.info({
title: 'User Info',
content: `Name${this.data[index].name}<br>Age${this.data[index].age}<br>Address${this.data[index].address}`,
})
},
onChangePage(e) {
if (this.page != e) {
this.page = e
this.getList()
}
},
onChangePageSize(e) {
if (this.pageSize != e) {
this.page = 1
this.pageSize = e
this.getList()
}
},
},
}
</script>
<style scoped>
.container {
display: flex;
flex-direction: column;
height: 100vh;
padding: 20px;
box-sizing: border-box;
}
.action-btn {
margin: 20px 0;
background-color: white;
padding: 20px;
border: 1px solid #F3F7FD;
border-radius: 15px;
display: flex;
align-items: center;
button {
margin-right: 20px;
}
}
.table-container {
flex: 1;
display: flex;
flex-direction: column;
}
.page {
margin-top: 10px;
text-align: right;
}
.search-area {
background-color: white;
padding-top: 20px;
border: 1px solid #F3F7FD;
border-radius: 15px;
}
</style>