<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  style="width: 100%" >
      <el-table-column type="index" label="广告时间" align="center"  width="80" />
      <el-table-column type="index" label="刊例名称" align="center"  width="80" />
      <el-table-column type="index" label="时长" align="center"  width="80" />
      <el-table-column type="index" label="位序" align="center"  width="80" />
      <el-table-column type="index" label="广告版本" align="center"  width="80" />
      <el-table-column prop="count" label="总计进线" align="center"  width="80" />
      <el-table-column prop="count" label="播放次数" align="center"  width="80" />
    </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/mediaCenter/mediaInformation";
import { pickerOptions, formatterContent } from "@/utils";
import Pagination from "@/components/Pagination"; // 对el-pagination 二次封装

export default {
  components: {
    Pagination
  },
  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>
