<template>
  <div>
    <el-table v-loading="loading" :data="list" border>
      <el-table-column label="时间" prop="time" />
      <el-table-column label="水位" prop="avgWaterlevel" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="pagination.page"
      :limit.sync="pagination.size"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listWaterLevel } from '@/api/analysis/achievement'

export default {
  props: {
    queryParams: Object,
  },
  data() {
    return {
      total: 0,
      list: [],
      loading: false,
      pagination: {
        page: 1,
        size: 10,
      },
    }
  },
  mounted() {
    this.getList();
  },
  watch: {
    queryParams: {
      handler() {
        this.getList();
      },
      deep: true,
    },
  },
  methods: {
    getList() {
      const { queryParams } = this;
      if (!queryParams.siteId) return;
      const params = {
        ...this.queryParams,
        ...this.pagination,
      };
      this.loading = true;
      listWaterLevel(params).then(response => {
          this.list = response.data.records;
          this.total = response.data.total;
          this.loading = false;
        }
      );
    },
  }
}
</script>

<style scoped>

</style>
