<template>
  <div class="app-container">
    <div class="app-header-search">
      <el-form ref="dataSearch" :inline="true" :model="search" class="demo-form-inline">
        <el-form-item label="订单ID:">
          <el-input v-model="search.orderID" placeholder="请输入订单ID" maxlength="10" />
        </el-form-item>
        <el-form-item label="订单编号:">
          <el-input v-model="search.orderNumber" placeholder="请输入订单编号" maxlength="20" />
        </el-form-item>
        <el-form-item label="客户名称:">
          <el-input v-model="search.customer" placeholder="请输入客户名称" maxlength="15" />
        </el-form-item>
        <el-form-item label="创建时间:">
          <el-date-picker
            v-model="listQuery.startTime"
            type="date"
            placeholder="选择日期"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd"
          />
          至
          <el-date-picker
            v-model="listQuery.endTime"
            type="date"
            placeholder="选择日期"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="success" icon="el-icon-search" @click="onSubmit">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
      :header-cell-style="{background:'#eef1f6',color:'#606266'}"
    >
      <el-table-column align="center" label="序号" width="50">
        <template slot-scope="scope">
          {{ scope.$index+1 }}
        </template>
      </el-table-column>
      <el-table-column label="订单编码(ID)" align="center" prop="orderID" />
      <el-table-column label="下单时间" align="center" prop="createTime" />
      <el-table-column label="客户名称" align="center" prop="customer" />
      <el-table-column label="应收金额(元)" align="center" prop="money" />
      <el-table-column label="已收金额(元)" align="center" prop="money1" />
      <el-table-column label="未收金额(元)" align="center" prop="money2" />
      <el-table-column label="应付金额(元)" align="center" prop="money3" />
      <el-table-column label="已付金额(元)" align="center" prop="money4" />
      <el-table-column label="未付金额(元)" align="center" prop="money5" />
      <el-table-column label="佣金(元)" align="center" prop="money6" />
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" />
  </div>
</template>

<script>
import { getClubList } from '@/api/club'
import Pagination from '@/components/Pagination'

export default {
  components: { Pagination },
  filters: {
    statusFilter(status) {
      const statusMap = {
        1: 'success',
        0: 'gray'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null,
      listLoading: true,
      searchTimeVal: '',
      total: 100,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      search: {

      },
      form: {
        classifyName: '',
        telephone: '',
        contacts: '',
        businessNum: '',
        address: '',
        radio: 1,
        status: '请选择',
        imageUrl: '',
        doorwayImageUrl: ''
      },
      addPeople: {
        classifyName: '',
        telephone: ''
      },
      updateTatusId: '',
      updateTatusType: '',
      dialogVisible: false,
      dialogVisibleText: '',
      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: '添加运营人员',
        create: 'Create',
        titleText: '系统提示'
      },
      rules: {
        classifyName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
        telephone: [{ required: true, message: '手机号码不能为空', trigger: 'blur' }]
      }
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      getClubList().then(response => {
        this.list = response.data.items
        this.listLoading = false
      }).catch(() => {
        // 封装静态数据
        this.list = [
          {
            id: 1,
            orderID: 'XD956566565656',
            customer: '商城测试演示会所',
            createTime: '2020-01-01:20:30:56',
            money: 1200000,
            money1: 1200000,
            money2: 1200000,
            money3: 1200000,
            money4: 1200000,
            money5: 1200000,
            money6: 1200000
          },
          {
            id: 1,
            orderID: 'XD956566565656',
            customer: '商城测试演示会所',
            createTime: '2020-01-01:20:30:56',
            money: 1200000,
            money1: 1200000,
            money2: 1200000,
            money3: 1200000,
            money4: 1200000,
            money5: 1200000,
            money6: 1200000
          },
          {
            id: 1,
            orderID: 'XD956566565656',
            customer: '商城测试演示会所',
            createTime: '2020-01-01:20:30:56',
            money: 1200000,
            money1: 1200000,
            money2: 1200000,
            money3: 1200000,
            money4: 1200000,
            money5: 1200000,
            money6: 1200000
          },
          {
            id: 1,
            orderID: 'XD956566565656',
            customer: '商城测试演示会所',
            createTime: '2020-01-01:20:30:56',
            money: 1200000,
            money1: 1200000,
            money2: 1200000,
            money3: 1200000,
            money4: 1200000,
            money5: 1200000,
            money6: 1200000
          }
        ]
      })
      this.listLoading = false
    },
    onSubmit() {
      console.log('search')
    }
  }
}

</script>
