<template>
  <div class="padding-20">
    <div class="search-box">
      <el-form
        ref="form"
        :inline="true"
        :model="searchForm"
        clearable
        class="mt-10">
        <el-form-item label="座位模版名称:">
          <el-input v-model="searchForm.place_template_name" placeholder="请输入座位模版名称" clearable></el-input>
        </el-form-item>
        <el-form-item label="预定人手机号:">
          <el-input v-model="searchForm.order_user_phone" placeholder="请输入预定人手机号" clearable></el-input>
        </el-form-item>
        <el-form-item label="签到状态:">
          <el-select
            v-model="searchForm.order_sign_status"
            clearable
            placeholder="请选择签到状态">
            <el-option
              v-for="item in [{label: '未签到', value: 0}, {label: '已签到', value: 1}]"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="预定时间:">
          <el-date-picker
            v-model="searchForm.order_pre_time"
            type="datetime"
            placeholder="选择预定时间"
            value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
        </el-form-item>
        <el-form-item class="ml-10">
          <el-button
            icon="el-icon-search"
            type="primary"
            @click="searchSubmit">查询
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="tableData"
              stripe
              v-loading="tableLoading"
              fit
              class="marginT-10 order-table"
              border
              :max-height="vheight">
      <el-table-column label="订单ID" prop="id" width="80"></el-table-column>
      <el-table-column label="预定时间" prop="order_pre_time"></el-table-column>
      <el-table-column label="预订人" prop="order_user_name"></el-table-column>
      <el-table-column label="手机号" prop="order_user_phone" width="120"></el-table-column>
      <el-table-column label="预定人数" prop="order_user_num" width="60"></el-table-column>
      <el-table-column label="座位名称" prop="place_name"></el-table-column>
      <el-table-column label="最晚到场时间" prop="order_latest_time"></el-table-column>
      <el-table-column label="签到状态" width="80">
        <template slot-scope="scope">
          <p>{{ ['未签到', '已签到'][scope.row.order_sign_status] }}</p>
        </template>
      </el-table-column>
      <el-table-column label="签到时间" prop="order_sign_date" width="160"></el-table-column>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button type="text"
                     v-permission="'business_place_reserve_sign'"
                     @click="edit(scope.row)">签到
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="marginT-20"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :hide-on-single-page="true"
      :current-page="page"
      :page-size="page_size"
      :page-sizes="[10, 20, 100, 200, 300, 400]"
      background
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalCount"/>
    <detail v-if="detailsDialog.show"
            v-model="detailsDialog.show"
            :exData="detailsDialog.exData"
            @success="init"></detail>
  </div>
</template>

<script>
import page from '@/mixin/page'
import detail from './details'

export default {
  mixins: [page],
  components: {
    detail,
  },
  data () {
    return {
      detailsDialog: {
        show: false,
        exData: {}
      },
      searchForm: {},
      tableData: [],
      tableUrl: '/v1/prepare/order/list'
    }
  },
  methods: {
    add () {
      this.detailsDialog.exData = {}
      this.detailsDialog.show = true
    },
    edit (row) {
      this.detailsDialog.exData = row
      this.detailsDialog.show = true
    }
  },
  mounted () {
    this.init()
  },
}
</script>

<style lang="scss" scoped>
</style>
