<template>
  <div class="app-container">
    <!-- 用户select选项 -->
    <el-row :gutter="15" class="m-t-0">
      <el-col :span="4">
        <SelectionShopId class="w-100" v-model="form.shop_id" :allSel="true" />
      </el-col>
      <el-col :span="8">
        <DatePickerOrder class="w-100" />
      </el-col>
      <el-col :span="12">
        <el-input placeholder="请输入内容" v-model="input3" class="w-100">
          <el-select v-model="select" slot="prepend" placeholder="请选择" class="w-120px">
            <el-option label="餐厅名" value="1"></el-option>
            <el-option label="订单号" value="2"></el-option>
            <el-option label="用户电话" value="3"></el-option>
          </el-select>
          <el-button slot="append" icon="el-icon-search"></el-button>
        </el-input>
      </el-col>
    </el-row>
    <el-row :gutter="15">
      <el-col :span="14">
        <SelectionOrderStatus />
      </el-col>
      <el-col :span="10">
        <SelectionOrderBack />
      </el-col>
    </el-row>
    <!-- 订单列表 -->
    <el-table class="m-t-20 w-100" ref="myTable"
      :data="orderList.slice((currentPage - 1) * pageSize, currentPage * pageSize)" border tooltip-effect="dark">
      <el-table-column align="center" type="selection" width="40">
      </el-table-column>
      <el-table-column align="center" prop="id" label="id" width="50">
      </el-table-column>
      <el-table-column prop="order_sn" label="订单号" width="150" min-width="150">
      </el-table-column>
      <el-table-column prop="tel" label="客户电话" min-width="150">
      </el-table-column>
      <el-table-column label="下单时间" width="140" min-width="140">
        <template slot-scope="scope">
          {{ scope.row.addtime | parseTime('{y}-{m}-{d} {h}:{i}') }}
        </template>
      </el-table-column>
      <el-table-column prop="controler" label="操作" width="290" min-width="290">
        <template slot-scope="scope">
          <el-button-group>
            <el-button type="warning" icon="el-icon-edit">同意退款</el-button>
            <el-button type="danger" icon="el-icon-delete" @click="deleteAdmin([scope.row.id])">拒绝退款</el-button>
            <el-button type="primary" icon="el-icon-search"
              @click="$router.replace(`/order/show/${scope.row.id}`)">查看</el-button>
          </el-button-group>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination class="m-t-20" layout="prev, pager, next" :current-page.sync="currentPage" :page-size="pageSize"
      :total="orderList.length">
    </el-pagination>
  </div>
</template>

<script>

import { countSelIdArr, parseTime } from '@/utils'
import SelectionShopId from '@/components/SelectionShopId'
import SelectionOrderStatus from '@/components/SelectionOrderStatus'
import SelectionOrderBack from '@/components/SelectionOrderBack'
import DatePickerOrder from '@/components/DatePickerOrder'

export default {
  name: 'Order',
  data () {
    return {
      pageSize: 50, // 每页显示记录条数
      currentPage: 1, // 当前页
      form: {
        shop_id: ''
      }
    }
  },
  components: {
    SelectionShopId,
    SelectionOrderStatus,
    SelectionOrderBack,
    DatePickerOrder
  },
  computed: {
    // 获取订单列表
    orderList () {
      return this.$store.state.orderList
    }

  },
  methods: {
    countSelIdArr
  },
  watch: {
  },
  created () {
  },
  filters: {
    countSelIdArr,
    parseTime
  }
}
</script>

<style lang="scss" scoped>
@import "@/styles/theme.scss";

i {
  font-size: 18px !important;
  margin-right: 12px;
  vertical-align: middle;
}
</style>
