<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.bar_name"
            placeholder="请输入门店名称"
            clearable></el-input>
        </el-form-item>
        <el-form-item label="酒吧状态:">
          <el-select clearable v-model="searchForm.bar_status">
            <el-option label="有效" :value="1"></el-option>
            <el-option label="无效" :value="0"></el-option>
          </el-select>
        </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-item class="ml-10">
          <el-button icon="el-icon-plus"
                     type="primary"
                     v-permission="'outlet_list_add_0'"
                     @click="add">新增
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="tableData"
              v-loading="tableLoading"
              fit
              class="marginT-10 order-table"
              :max-height="vheight">
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left"
                   inline
                   class="demo-table-expand"
                   label-width="160px">
            <el-form-item label="编号">
              <span>{{ props.row.id }}</span>
            </el-form-item>
            <el-form-item label="酒吧名称">
              <span>{{ props.row.bar_name }}</span>
            </el-form-item>
            <el-form-item label="门店地址">
              <span>{{ props.row.bar_address }}</span>
            </el-form-item>
            <el-form-item label="酒吧状态">
              <span>{{ ['无效', '有效'][props.row.bar_status] }}</span>
            </el-form-item>
            <el-form-item label="点歌开始时间">
              <span>{{ props.row.bar_song_start_time }}</span>
            </el-form-item>
            <el-form-item label="点歌结束时间">
              <span>{{ props.row.bar_song_end_time }}</span>
            </el-form-item>
            <el-form-item label="酒吧座位预定开始时间">
              <span>{{ props.row.bar_place_reserve_start_time }}</span>
            </el-form-item>
            <el-form-item label="酒吧座位预定结束时间">
              <span>{{ props.row.bar_place_reserve_end_time }}</span>
            </el-form-item>
            <el-form-item label="门店图片">
              <el-image style="width: 100px; height: 100px"
                        :src="props.row.bar_img_url[0]"
                        :preview-src-list="props.row.bar_img_url">
              </el-image>
            </el-form-item>
            <el-form-item label="创建时间">
              <span>{{ props.row.created_at }}</span>
            </el-form-item>
            <el-form-item label="更新时间">
              <span>{{ props.row.updated_at }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column label="编号" prop="id" width="160"></el-table-column>
      <el-table-column label="酒吧名称" prop="bar_name"></el-table-column>
      <el-table-column label="门店地址" prop="bar_address"></el-table-column>
      <el-table-column label="酒吧状态" sortable :sort-method="() => {}" width="100">
        <template slot-scope="scope">
          <p>{{ ['无效', '有效'][scope.row.bar_status] }}</p>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" v-permission="'outlet_list_edit_0'" @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/bar/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>
.demo-table-expand {
  .el-form-item {
    width: 50%;
    margin-right: 0;
    margin-bottom: 0;

    ::v-deep &__label {
      color: #99a9bf;
    }
  }
}
</style>
