<template>
  <div class="app-container">

    <div class="filter-container">
      <el-date-picker
        class="filter-item"
        v-model="listQuery.times"
        type="datetimerange"
        :default-time="['00:00:00', '23:59:59']"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
      </el-date-picker>
      <el-select v-model="listQuery.os" filterable placeholder="请选择" class="filter-item" >
        <el-option
          key=""
          label="请选择"
          value="">
        </el-option>
        <el-option
          v-for="(v,k) in oss"
          :key="k"
          :label="v"
          :value="k">
        </el-option>
      </el-select>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="getList">
        搜索
      </el-button>
    </div>

    <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">

      <el-table-column align="center" fixed label="姓名" width="120" prop="admin.name" />

      <el-table-column align="center" label="订单数" width="120" prop="orders" />

      <el-table-column align="center" label="订单总金额">
        <template slot-scope="scope">
          {{ scope.row.total_price/100 }}
        </template>
      </el-table-column>

      <el-table-column align="center" label="核销数" width="120" prop="assets" />

      <el-table-column align="center" label="核销金额">
        <template slot-scope="scope">
          {{ scope.row.asset_price/100 }}
        </template>
      </el-table-column>

      <el-table-column align="center" label="未付款订单" width="120" prop="nopays" />

      <el-table-column align="center" label="未付款金额">
        <template slot-scope="scope">
          {{ scope.row.nopay_price/100 }}
        </template>
      </el-table-column>

    </el-table>

  </div>
</template>

<script>

export default {
  name: 'Datalist',
  data() {
    return {
      oss: null,
      list: [],
      listLoading: true,
      listQuery:{}
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.$axios.get('/admin/data/index', { params: this.listQuery }).then(response => {
        this.list = response.data
        this.oss = response.ext.oss
        this.listLoading = false
      })
    }
  }
}
</script>
