Files
jczxw-java/src/views/water/river/statistic/avg-standard.vue
2022-01-10 09:56:26 +08:00

257 lines
7.9 KiB
Vue

<!-- 江河水查看数据页面-->
<template>
<div class="ele-body">
<!-- 搜索表单 -->
<a-form :model="where" :label-col="{ md: { span: 8 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 16 }, sm: { span: 24 } }">
<a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="断面名称">
<a-select allow-clear mode="multiple" placeholder="请选择断面名称" v-model:value="where.name">
<a-select-option v-for="item in sectionInfo" :key="item.sectionName" :value="item.sectionName">
{{ item.sectionName }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="河段名称">
<a-select v-model:value="where.riverLakeLibrary" placeholder="请选择河段名称" allowClear showSearch>
<a-select-option v-for="item in waterSystemList" :key="item">{{ item }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="水系名称">
<a-select v-model:value="where.importWaterBody" placeholder="请选择水系名称" allowClear showSearch>
<a-select-option v-for="item in waterBodyList" :key="item">{{ item }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="指标名称">
<a-select allow-clear mode="multiple" placeholder="请选择指标名称" v-model:value="where.targetName">
<a-select-option v-for="item in targetInfoList" :key="item" :value="item">
{{ item }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="开始时间:">
<a-month-picker valueFormat="YYYY-MM" v-model:value="where.startTime" :disabled-date="disabledDate" />
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="结束时间:">
<a-month-picker valueFormat="YYYY-MM" v-model:value="where.endTime" :disabled-date="disabledDate" />
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item class="ele-text-right" :wrapper-col="{ span: 24 }">
<a-space>
<a-button type="primary" @click="reload">查询</a-button>
<a-button @click="reset">重置</a-button>
<a-button @click="exportFile">导出Excel</a-button>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
<!-- 表格 -->
<a-spin :spinning="loading">
<ele-pro-table ref="table" :datasource="momData" :columns="columns" :where="where"
:scroll="{ x: 'max-content' }" @done="(d) => (data = d.data)">
</ele-pro-table>
</a-spin>
</div>
<!-- 编辑弹窗 -->
</template>
<script>
import {
listAvgWaterQualitySandard,
listTargetInfo,
} from "@/api/ecology/river-statis";
import {
listInfo
} from "@/api/ecology/water/river-plcae";
import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
import XLSX from "xlsx";
export default {
name: "RiverCollectWater",
components: {},
props:{
// 表格搜索条件
searchForm:{
typeof:Object,
default: function () {
return {}
},
},
visiable:{
typeof:Boolean
}
},
data() {
return {
data: [],
momData: [],
datasource: {},
columns: [{
title: '断面类型',
dataIndex: 'sectionType',
key: 'sectionType',
},
{
title: '断面名称',
dataIndex: 'sectionName',
key: 'sectionName',
},
{
title: '考核城市',
dataIndex: 'city',
key: 'city',
},
{
title: '水质考核目标',
dataIndex: 'waterTarget',
key: 'waterTarget',
},
{
title: '平均水质类别',
dataIndex: 'waterQualityCategoryAvg',
key: 'waterQualityCategoryAvg',
},
{
title: '水质评价',
dataIndex: 'waterQualityEvaluate',
key: 'waterQualityEvaluate',
},
{
title: '超标项目',
dataIndex: 'transnormalItem',
key: 'transnormalItem',
},
{
title: '去年同期水质类别',
dataIndex: 'waterQualityCategoryYoy',
key: 'waterQualityCategoryYoy',
},
],
locale,
bill: {},
selection: [],
where: {},
sectionInfo: {},
loading: false,
rules: {},
waterBodyList: [],
waterSystemList: [],
targetInfo:{},
targetInfoList:[],
};
},
watch: {
searchForm(newV) {
this.where = newV;
},
// 监听组件显示
visiable(val){
console.log('change',val)
if(val && this.where.startTime && this.where.endTime){
this.reload()
}
}
},
created() {
// 回显并搜素
this.where = this.searchForm;
if(this.where.startTime && this.where.endTime){
this.reload()
}
listInfo().then((res) => {
if (res.data.code == 0) {
console.log(res.data.data)
this.sectionInfo = res.data.data
res.data.data.forEach((m) => {
this.waterSystemList.push(m.waterBody);
this.waterBodyList.push(m.importWaterBody);
})
this.waterSystemList = [...new Set(this.waterSystemList)];
this.waterBodyList = [...new Set(this.waterBodyList)];
} else {
this.$message.error(res.data.msg);
}
}),
listTargetInfo().then((res) => {
if (res.data.code == 0) {
console.log(res.data.data)
this.targetInfo = res.data.data
res.data.data.forEach((m) => {
this.targetInfoList.push(m.indicatorName);
})
this.targetInfoList = [...new Set(this.targetInfoList)];
} else {
this.$message.error(res.data.msg);
}
})
},
methods: {
/* 刷新表格 */
reload() {
// 上传搜索条件给父级
this.$emit("search", this.where);
this.loading = true;
listAvgWaterQualitySandard(this.where).then((res) => {
console.log(res.data.data);
this.momData = [];
if (res.data.code == 0) {
this.$message.success(res.data.msg);
res.data.data.forEach((m) => {
if(m.transnormalItem==""){
m.transnormalItem = "--"
}
this.momData.push(m);
})
} else {
this.$message.error(res.data.msg);
}
this.loading = false;
});
},
/* 重置搜索 */
reset() {
this.where = {};
this.reload();
},
/* 导出 */
exportFile() {
const columns = this.columns.filter(item => item.dataIndex);
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
this.data.forEach((d) => {
const td = columns.map((item) => d[item.dataIndex]);
arr.push(td);
});
let sheet = XLSX.utils.aoa_to_sheet(arr);
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
}
},
};
</script>
<style scoped lang="less">
.ant-calendar-picker{
width: 100%;
}
</style>