<template>
  <div class="SalesReportRejectedNew" v-loading="loading">
    <el-table :data="tableData" size="mini" border>
      <el-table-column label="部门" prop="name" />
      <el-table-column label="数量" prop="num" />
    </el-table>
  </div>
</template>

<script>
import asyncRequest from "@/api/newReport";
import setHeight from "@/mixins/index";
export default {
  name: "Consult",
  mixins: [setHeight],
  props: ['date'],
  watch: {
    date: function(val) {
      if (val && val.length === 2) {
        this.searchList();
      }
    }
  },
  data() {
    return {
     tableData:[],
     loading: false
    };
  },
  async created() {
    window.onresize = () => {
      this.getHeight();
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.getHeight();
    });
    this.searchList();
  },
  methods: {
    async searchList() {
      this.loading = true;
      this.tableData = [];
      const res = await asyncRequest.zxOrder({ start:this.date[0] || "", end:this.date[1] || "" });
      if (res.code === 0 && res.data && res.data.length > 0) {
        this.tableData = res.data
      } else {
        this.tableData = [];
      }
      this.getHeight();
      this.loading = false;
    }
  }
};
</script>
