<template>
    <div>
        <el-row :gutter="10" style="margin-bottom: 0px;">
            <el-col :span="24">
                <basic-container>
                    <avue-form :option="searchOption" v-model="searchForm" @submit="handleImportSubmit">
                    </avue-form>
                </basic-container>
            </el-col>
        </el-row>
        <el-row :gutter="10" style="margin-bottom: 0px;">
            <el-col :span="24">
                <basic-container>

                </basic-container>
            </el-col>
        </el-row>
        <el-row :gutter="10" style="margin-bottom: 0px;">
            <el-col :span="24">
                <basic-container>
                    <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form"
                        :permission="permissionList" @search-change="searchChange" @search-reset="searchReset"
                        @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
                        @refresh-change="refreshChange" @on-load="onLoad">
                    </avue-crud>
                </basic-container>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import { getMonitorSiteCountPage } from "@/api/business/count/count";
import { mapGetters } from "vuex";

export default {
    data() {
        return {
            form: {},
            selectionList: [],
            query: {},
            loading: true,
            searchForm: {
                countTime: '',
            },
            searchOption: {
                // submitBtn: false,
                // emptyBtn: false,
                submitText: '查询',
                column: [
                    {
                        label: "统计年月",
                        prop: "countTime",
                        type: "date",
                        span: 6,
                        format: 'yyyy年MM月',
                        valueFormat: 'yyyy-MM-dd HH:mm:ss',
                    }
                ]
            },

            option: {
                height: 'auto',
                calcHeight: 30,
                tip: false,
                searchShow: true,
                searchMenuSpan: 6,
                border: true,
                index: true,
                selection: true,
                viewBtn: false,
                dialogClickModal: false,
                menu: false,
                column: [
                    {
                        label: "ID",
                        prop: "deptId",
                        hide: true,
                    },
                    {
                        label: "行政区",
                        prop: "adCity",
                    }, {
                        label: "取用水户数量",
                        prop: "waterUseConsumer",
                    }, {
                        label: "监测站数量",
                        prop: "monitorSite",
                    }, {
                        label: "监测点数量",
                        prop: "monitorPoint",
                    }
                ]
            },
            data: []
        };
    },
    computed: {
        ...mapGetters(["userInfo", "permission"]),
        permissionList() {
            return {
                addBtn: false,
                viewBtn: false,
                delBtn: false,
                editBtn: false
            };
        },
        ids() {
            let ids = [];
            this.selectionList.forEach(ele => {
                ids.push(ele.id);
            });
            return ids.join(",");
        }
    },
    mounted() {
        this.searchForm.countTime = new Date();
        
    },
    methods: {
        init() {

        },
        searchReset() {
            this.query = {};
            this.onLoad(this.page);
        },
        searchChange(params, done) {
            this.query = params;
            this.page.currentPage = 1;
            this.onLoad(this.page, params);
            done();
        },
        selectionChange(list) {
            this.selectionList = list;
        },
        selectionClear() {
            this.selectionList = [];
            this.$refs.crud.toggleSelection();
        },
        currentChange(currentPage) {
            this.page.currentPage = currentPage;
        },
        sizeChange(pageSize) {
            this.page.pageSize = pageSize;
        },
        refreshChange() {
            this.onLoad(this.page, this.query);
        },

        onLoad(page, params = {}) {
            this.loading = true;
            getMonitorSiteCountPage(Object.assign(params, this.query)).then(res => {
                this.data = res.data.data;

                this.loading = false;
                this.selectionClear();
            });
        }
    }
};
</script>

<style></style>
