<template>
  <div class="page-wrap">
    <ui-loading :show="page_loading.show"></ui-loading>

    <div class="page-handle-wrap">
      <ul class="handle-wraper bd-b">
        <li class="f-l">
          <div class="text-exp">
            <b>全部信息</b>
          </div>
        </li>
        <li class="f-r">
          <div class="handle-item">
            <Button @click="openEdit(true)" icon="md-add" type="primary">执行同步</Button>
          </div>

          <div class="handle-item">
            <Button @click="openRefund(true)" icon="md-arrow-dropleft" type="primary">退货同步</Button>
          </div>

          <div class="handle-item">
            <Button @click="openCancelled(true)" icon="md-close" type="primary">注销同步</Button>
          </div>

          <div class="handle-item">
            <Button @click="search.show=!search.show" ghost icon="ios-search" type="primary">搜索</Button>
          </div>

          <div class="handle-item">
            <Button @click="index(1)" icon="md-refresh">刷新</Button>
          </div>
        </li>
      </ul>

      <div class="search-wrap" v-show="search.show">
        <ul class="handle-wraper">
          <li class="handle-item w-250">
            <Select clearable placeholder="命令类型" v-model="options.command">
              <Option :value="index" v-for="(name, index) in commands" :key="index">{{name}}</Option>
            </Select>
          </li>

          <li class="handle-item w-250">
            <DatePicker
              :editable="false"
              placeholder="请选择时间"
              placement="bottom-start"
              type="daterange"
              v-model.trim="options.time"
              :options="datePickerOptionsMonth"
            ></DatePicker>
          </li>

          <li class="f-r">
            <div class="handle-item">
              <Button @click="index(1)" ghost type="primary">立即搜索</Button>
            </div>
            <div class="handle-item">
              <Button @click="resetSearch" ghost type="warning">重置搜索</Button>
            </div>
          </li>
        </ul>
      </div>
    </div>

    <div class="page-list-wrap">
      <Table :columns="table_titles" :data="list_data ? list_data.data : []"></Table>
    </div>

    <div class="page-turn-wrap" v-if="list_data">
      <Page
        :current="Number(list_data.current_page)"
        :page-size="Number(list_data.per_page)"
        :total="Number(list_data.total)"
        @on-change="index"
        show-elevator
        show-total
      ></Page>
    </div>

    <ui-edit
      :show.sync="editObj.show"
      @add-success="index"
      @update-success="index(list_data.current_page)"
    ></ui-edit>

    <ui-refund
      :show.sync="refundObj.show"
      @add-success="index"
      @update-success="index(list_data.current_page)"
    ></ui-refund>

    <ui-cancelled
      :show.sync="cancelledObj.show"
      @add-success="index"
      @update-success="index(list_data.current_page)"
    ></ui-cancelled>
  </div>
</template>

<script src="./js/index.js"></script>
