<!--
 * @Title: 
 * @Description: 测站RTU更换列表
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
    <div>
        <basic-container>
            <avue-crud :option="option" :table-loading="loading" :page.sync="page" :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>
    </div>
</template>

<script>

import { getHistoryPage } from "@/api/business/monitor/waterflowrate.js";

export default {
    components: {

    },
    name: 'waterflowratehistorylist',
    data() {
        return {
            drawer: false,
            form: {},
            selectionList: [],
            query: {},
            loading: true,
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            option: {
                labelWidth: 120,
                viewLabelWidth: 100,
                searchlabelWidth: 100,
                height: "auto",
                calcHeight: 80,
                align: "center",
                headerAlign: "center",
                tip: false,
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                menu: false,
                border: true,
                index: true,
                editBtn: false,
                delBtn: false,
                addBtn: false,
                viewBtn: false,
                viewBtnText: "历史信息",
                dialogType: "drawer",
                dialogClickModal: false,
                columnBtn: false,
                column: [
                    {
                        label: "测站编码",
                        prop: "mpcd",
                        span: 24,
                    },
                    {
                        label: "报文时间",
                        prop: "tm",
                        span: 24,
                    },
                    {
                        label: "瞬时流量",
                        prop: "mpq",
                        span: 24,
                    },
                    {
                        label: "累计流量",
                        prop: "accw",
                        span: 24,
                    },
                    {
                        label: "水位",
                        prop: "waterLevel",
                        span: 24,

                    },
                    {
                        label: "流速",
                        prop: "flowSpeed",
                        span: 24,

                    },
                ],
            },
            data: [],

        };
    },
    props: {
        mpcd: {
            type: [String],
            required: true
        },
    },
    created() {
        this.init();
    },
    methods: {
        init() {
            this.onLoad(this.page);
        },
        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;
            params['mpcd'] = this.mpcd;
            getHistoryPage(
                page.currentPage,
                page.pageSize,
                Object.assign(params, this.query)
            ).then((res) => {
                const data = res.data.data;
                console.log(JSON.stringify(data))
                this.page.total = data.total;
                this.data = data.records;
                this.loading = false;
                this.selectionClear();
            });
        },
    },
};
</script>
