<template>
  <div class="notice-page">
    <Card>
      <div class="search-con">
        <Select
          placeholder="请选择状态"
          class="search-input"
          v-model="searchContent.status"
          style="width:200px"
        >
          <Option value>全部</Option>
          <Option
            v-for="(item, index) of recordList"
            :value="item.label"
            :key="'series-option-' + index"
            >{{ item.label }}</Option
          >
        </Select>
        <DatePicker
          placeholder="开始时间至结束时间"
          v-model="createTime"
          type="daterange"
          placement="bottom-start"
          class="search-date"
          style="width:200px"
          @on-change="handleDateChange(createTime)"
          :editable="false"
          separator=" ~ "
        ></DatePicker>
        <ButtonGroup class="search-btngroup">
          <Button type="primary" style="margin-left: 20px" @click="handleSearch">查 找</Button>
          <Button type="primary" @click="handleRefresh">
            <Icon type="md-refresh" />
          </Button>
        </ButtonGroup>
      </div>
        <tables
        ref="tables"
        editable
        pagable
        v-model="tableData"
        :columns="columns"
        :currentPage="searchContent.pageNum"
        :pageSize="searchContent.pageSize"
        :totalSize="totalSize"
        :loading="loading"
        @on-change="handleCurrentChange"
      />
    </Card>
  </div>
</template>
<script>
import Tables from '_c/tables'
import { formatTime } from '@/libs/tools'
export default {
  inject: ['reload'],
  components: {
    Tables
  },
  data () {
    return {
      searchContent: {
        name: '',
        page: 1,
        pageSize: 10,
        addTimeHead: '',
        addTimeTail: ''
      },
      createTime: [],
      tableData: [],
      columns: [
        { title: '记录号', key: 'index', align: 'left', minWidth: 180 },
        { title: '订单号', key: 'index', align: 'left', minWidth: 180 },
        { title: '结算类型', key: 'index', align: 'center', minWidth: 120 },
        { title: '金额', key: 'index', align: 'center', minWidth: 120 },
        { title: '用户支付', key: 'index', align: 'center', minWidth: 120 },
        { title: '平台提成', key: 'index', align: 'center', minWidth: 120 },
        { title: '平台贴补', key: 'index', align: 'center', minWidth: 120 },
        { title: '状态', key: 'index', align: 'center', minWidth: 120 },
        { title: '记录时间', key: 'index', align: 'center', minWidth: 150 }
      ],
      recordList: [
        {
          label: '已结算',
          index: 1
        },
        {
          label: '待结算',
          index: 2
        }
      ],
      loading: false,
      totalSize: 0
    }
  },
  methods: {
    requestData () {

    },
    handleRefresh () {
      this.reload()
    },
    handleDateChange (createTime) {
      if (createTime && createTime.length == 2 && createTime[0] && createTime[1]) {
        this.searchContent.addTimeHead = new Date(createTime[0]).getTime()
        this.searchContent.addTimeTail =
          new Date(createTime[1]).getTime() + 24 * 60 * 60 * 1000 - 1
      } else {
        this.searchContent.addTimeHead = ''
        this.searchContent.addTimeTail = ''
      }
    },
    handleCurrentChange () {

    }
  },
  created () {
    this.requestData()
  }
}
</script>
<style scoped lang="less">
.notice-page .search-con {
  display: flex;
  padding: 10px 0;
  .search-input {
    width: 300px;
    margin-right: 10px;
  }
}
</style>
