<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-select v-model="mediaSourcesId" placeholder="请选择投放媒体">
          <el-option
          v-for="item in mediaSources"
          :key="item.id"
          :label="item.name"
          :value="item.id">
          </el-option>
      </el-select>
      <span>投放产品:</span>
       <el-select v-model="launchProductsId" placeholder="请选择投放产品">
          <el-option
          v-for="item in launchProducts"
          :key="item.id"
          :label="item.name"
          :value="item.id">
          </el-option>
      </el-select>
      <span>组别：</span>
      <el-cascader
      v-model="group"
      :options="groupItem"
      @change="handleChange"></el-cascader>
    </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-column label="唯一进线" align="center">
      </el-table-column>
      <el-table-column prop="name" label="有效进线" align="center" />
      <el-table-column prop="phone" label="新增进线" align="center" />
      <el-table-column prop="sex" label="下单数" align="center" />
      <el-table-column prop="createuser" label="下单金额" align="center" />
      <el-table-column prop="createuser" label="进线下单率" align="center"/>
      <el-table-column prop="createuser" label="有效下单率" align="center"/>
      <el-table-column prop="createuser" label="新增下单率" align="center"/>
      <el-table-column prop="createuser" label="下单单线金额" align="center"/>
      <el-table-column prop="createuser" label="审核通过单数" align="center"/>
      <el-table-column prop="createuser" label="审核通过金额" align="center"/>
      <el-table-column prop="createuser" label="审核通过率" align="center"/>
      <el-table-column prop="createuser" 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, // 日期数据
      mediaSourcesId:'',// 投放媒体id
      mediaSources:[
        {
          name:'腾讯',
          id:0
        },
        {
          name:'百度',
          id:1
        }
      ],//投放媒体
      launchProductsId:'',//投放产品id
      launchProducts:[
        {
          name:'秦时',
          id:0
        },
        {
          name:'天九',
          id:1
        },
        {
          name:'玄机',
          id:2
        }
      ],//投放产品
      group:[],//组别
       groupItem: [{
          value: 'zhinan',
          label: '指南',
          children: [{
            value: 'shejiyuanze',
            label: '设计原则',
            children: [{
              value: 'yizhi',
              label: '一致'
            }, {
              value: 'fankui',
              label: '反馈'
            }, {
              value: 'xiaolv',
              label: '效率'
            }, {
              value: 'kekong',
              label: '可控'
            }]
          }]
       }],
      pageParams: {
        pageindex: 1, // 当前第几页
        pagesize: Number(this.$store.getters.serverConfig.PAGESIZE), // 每页几条数据
        total: 0 // 总共多少数据
      },
      dataLists: [] // 列表数据
    };
  },
  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>
