water-ldht/src/views/analysis/dfunction/components/siteDay.vue

188 lines
4.6 KiB
Vue

<template>
<div class="manage-container">
<div class="manage-wrap">
<div class="manage-input">
<el-form ref="queryForm" :model="queryForm" label-width="80px">
<vab-query-form>
<el-form-item width="100" prop="month" label="站点名称">
<el-input
v-model="queryForm.deviceName"
size="small"
placeholder="请输入站点名称"
></el-input>
</el-form-item>
<el-form-item width="100" prop="month" label="时间">
<el-date-picker
v-model="queryForm.month"
size="small"
type="month"
placeholder="选择时间"
@change="standardToTime"
></el-date-picker>
</el-form-item>
</vab-query-form>
</el-form>
</div>
<div class="manage-button">
<el-button size="small" @click="resetForm()">重置</el-button>
<el-button type="primary" size="small" @click="search">查询</el-button>
</div>
</div>
<el-table
ref="multipleTable"
:data="reportData"
border
tooltip-effect="light"
>
<el-table-column
v-for="(key, index) in headerData"
:key="Math.random(index)"
:label="key"
:prop="key"
align="center"
width="150"
></el-table-column>
</el-table>
<vab-query-form>
<vab-query-form-right-panel>
<el-pagination
:background="background"
:current-page="queryForm.page"
:layout="layout"
:page-size="queryForm.size"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
></el-pagination>
</vab-query-form-right-panel>
</vab-query-form>
</div>
</template>
<script>
import { monthlyReport } from '@/api/analysis';
export default {
name: 'Index',
components: {},
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,
month: '',
projectId: '',
deviceName: '',
},
};
},
computed: {
height() {
return 500;
},
},
created() {
this.setDefaultTime();
this.queryForm.projectId = sessionStorage.getItem('projectId');
setTimeout(() => {
this.fetchData();
}, 1000);
},
methods: {
//获取当前时间
getDate(time = '') {
var now = new Date();
if (time != '') {
now = new Date(time);
}
const year = now.getFullYear(); //得到年份
let month = now.getMonth(); //得到月份
month = month + 1;
month = month.toString().padStart(2, '0');
return `${year}-${month}`;
},
//标准时间转yyyy-mm-dd
standardToTime() {
this.queryForm.month = this.getDate(this.queryForm.month);
},
setDefaultTime() {
this.queryForm.month = this.getDate();
},
//数据
async fetchData() {
this.listLoading = true;
const { data } = await monthlyReport(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>