water-ldht/src/views/analysis/mfunction/components/waterMonth.vue

205 lines
5.2 KiB
Vue
Raw Normal View History

2024-09-26 14:04:18 +08:00
<template>
<div class="manage-container">
<div class="manage-wrap">
<div class="manage-input">
<el-form ref="form" :model="queryForm" label-width="80px">
<vab-query-form>
2024-10-10 08:18:58 +08:00
<el-form-item
width="100"
prop="deviceName"
:label="$t('dfunction.xzsj')"
>
2024-09-26 14:04:18 +08:00
<el-input
v-model="queryForm.deviceName"
size="small"
2024-10-10 08:18:58 +08:00
:placeholder="$t('dataEnquiry.qsrzdmc')"
2024-09-26 14:04:18 +08:00
></el-input>
</el-form-item>
2024-10-10 08:18:58 +08:00
<el-form-item width="100" prop="year" :label="$t('defalult.sj')">
2024-09-26 14:04:18 +08:00
<el-date-picker
v-model="queryForm.year"
size="small"
type="year"
2024-10-10 08:18:58 +08:00
:placeholder="$t('dfunction.xzsj')"
2024-09-26 14:04:18 +08:00
@change="standardToTime"
></el-date-picker>
</el-form-item>
</vab-query-form>
</el-form>
</div>
<div class="manage-button">
2024-10-10 08:18:58 +08:00
<el-button size="small" @click="resetForm()">
{{ $t('defalult.chongz') }}
</el-button>
<el-button type="primary" size="small" @click="search">
{{ $t('defalult.cx') }}
</el-button>
2024-09-26 14:04:18 +08:00
<el-button type="primary" size="small" @click="exportData">
2024-10-10 08:18:58 +08:00
{{ $t('defalult.dc') }}
2024-09-26 14:04:18 +08:00
</el-button>
</div>
</div>
<el-table
ref="multipleTable"
v-loading="listLoading"
:data="reportData"
border
tooltip-effect="light"
style="width: 100%"
>
<el-table-column
v-for="(key, index) in headerData"
:key="index"
:label="key"
:prop="key"
:fixed="key == '站点名称' ? true : false"
align="center"
width="150"
></el-table-column>
2024-10-10 08:18:58 +08:00
<el-table-column fixed="right" :label="$t('defalult.cz')" align="center">
2024-09-26 14:04:18 +08:00
<template #default="{ row }">
2024-10-10 08:18:58 +08:00
<el-button type="text" @click="graph(row)">
{{ $t('dfunction.qxt') }}
</el-button>
2024-09-26 14:04:18 +08:00
</template>
</el-table-column>
</el-table>
<el-pagination
:background="background"
:current-page="queryForm.page"
:layout="layout"
:page-size="queryForm.size"
:total="total"
style="text-align: right"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
></el-pagination>
<water-graph ref="water"></water-graph>
</div>
</template>
<script>
import { waterMonth, waterMonthExport } from '@/api/analysis';
import ajax from '@/api/download';
import { getDate2 } from '@/common/times';
import waterGraph from '@/views/analysis/dfunction/components/watergraph';
export default {
name: 'Index',
components: {
waterGraph,
},
data() {
return {
reportData: [],
headerData: {},
lazy: true,
activeName: 'first',
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
input: '',
textarea: '',
background: true,
listLoading: true,
elementLoadingText: '正在加载...',
queryForm: {
page: 1,
size: 20,
year: '',
projectId: '',
deviceName: '',
},
};
},
computed: {
height() {
return 500;
},
},
created() {},
methods: {
// 曲线图
graph(row) {
this.$refs['water'].showData(row);
},
//标准时间转yyyy-mm-dd
standardToTime() {
this.queryForm.year = getDate2(this.queryForm.year);
console.log(this.queryForm.year);
},
setDefaultTime() {
this.queryForm.year = getDate2();
console.log(this.queryForm.year);
},
//导出
async exportData() {
const url = await waterMonthExport(this.queryForm);
ajax.downloadFile(url, { fileName: '水量月报.xls' });
},
//数据
async fetchData() {
this.listLoading = true;
const { data } = await waterMonth(this.queryForm);
const reportData1 = data.items;
var list = [];
for (var i = 0; i < reportData1.length; i++) {
list.push(reportData1[i]);
}
this.reportData = data.items;
this.headerData = Object.keys(list[0]);
this.total = data.total;
setTimeout(() => {
this.listLoading = false;
}, 500);
},
showData() {
this.setDefaultTime();
this.queryForm.projectId = sessionStorage.getItem('projectId');
setTimeout(() => {
this.fetchData();
}, 1000);
},
search() {
this.fetchData();
},
resetForm() {
this.$refs.queryForm.resetFields();
},
handleAdd() {
this.$refs['edit'].showEdit();
},
handleEdit(row) {
this.$refs['edit'].showEdit(row);
},
handleQuery() {
this.queryForm.page = 1;
this.fetchData();
},
handleSizeChange(val) {
this.queryForm.size = val;
this.fetchData();
},
handleCurrentChange(val) {
this.queryForm.page = val;
this.fetchData();
},
},
};
</script>
<style lang="scss" scoped>
.manage-wrap {
display: flex;
justify-content: space-between;
align-items: flex-start;
.el-input {
width: 200px !important;
}
.el-select {
width: 200px !important;
}
.manage-button {
padding-left: 12px;
margin-bottom: 30px;
}
}
</style>