<template>
  <div class="app-container">
    <div class="filter-container">
      <el-date-picker
        v-model="searchDate"
        :picker-options="pickerOptions"
        class="filter-item"
        type="daterange"
        format="yyyy年MM月dd日"
        value-format="yyyy-MM-dd"
        align="left"
        unlink-panels
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      />
      <span>接收号码:</span>
       <el-input v-model="receiveNumber" placeholder="请输入接收号码" class="filter-item"></el-input>
      <el-button type='primary'>搜索</el-button>
      <el-button type='primary'>导出</el-button>
    </div>
    <el-table v-loading="loading" :data="dataLists" border stripe >
      <el-table-column type="index" label="编号" align="center" fixed width="80" />
      <el-table-column label="接收号码" align="center" min-width="140">
      </el-table-column>
      <el-table-column prop="phone" label="短信内容" align="center" min-width="140" />
      <el-table-column prop="sourcename" label="发送方式" align="center" min-width />
      <el-table-column prop="typename" label="发送状态" align="center" min-width />
      <el-table-column prop="provincename" label="提交时间" align="center" />
      <el-table-column prop="cityname" label="实际发送时间" align="center" />
      <el-table-column prop="address" label="发送人" align="center" />
    </el-table>
    <pagination
      v-show="pageParams.total > 0"
      :total="pageParams.total"
      :pageindex.sync="pageParams.pageindex"
      :pagesize.sync="pageParams.pagesize"
      class="pagination"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getOrderLists } from "@/api/orderManagement/orderList";
import { pickerOptions, formatterContent } from "@/utils";
import Pagination from "@/components/Pagination"; // 对el-pagination 二次封装

export default {
  components: {
    Pagination
  },
  filters: {
    OrderTextFilter(status) {
      const statusMap = {
        0: "暂时",
        1: "永久",
        2: "已取消"
      };
      return statusMap[status];
    }
  },
  data() {
    return {
      loading: false,
      searchDate: "", // 日期
      pickerOptions, // 日期数据
      pageParams: {
        pageindex: 1, // 当前第几页
        pagesize: Number(this.$store.getters.serverConfig.PAGESIZE), // 每页几条数据
        total: 0 // 总共多少数据
      },
      dataLists: [], // 列表数据
      receiveNumber: '', // 接收号码
    };
  },
  created() {
    this.getList();
    document.onkeyup = e => {
      if (e.keyCode === 13) {
        this.getList();
      }
    };
  },
  methods: {
    getList() {
      this.loading = true;
      return new Promise(resolve => {
        const params = {
          pageindex: this.pageParams.pageindex, // int 第几页
          pagesize: this.pageParams.pagesize, // int 每页几条信息
          stime: this.searchDate && this.searchDate[0], // 开始时间
          etime: this.searchDate && this.searchDate[1], // 结束时间
        };
        getOrderLists(params).then(response => {
          this.loading = false;
          if (response.state.toLowerCase() === "success") {
            this.pageParams.total = response.data.total;
            this.dataLists = response.data.rows;
          }
        });
        resolve();
      });
    },
    btn_search() {
      this.pageParams.pageindex = 1;
      this.getList();
    },
    handleChange(value) {
      console.log(value);
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
span{
  font-size: 14px;
}

</style>
