<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, null)" icon="md-add" type="primary" v-has="'create'">添加企业</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>

          <div class="handle-item">
            <Button @click="exportExcel" icon="md-download">导出</Button>
          </div>
        </li>
      </ul>

      <div class="search-wrap" v-show="search.show">
        <ul class="handle-wraper">
          <li class="handle-item w-250">
            <Input clearable placeholder="客户编号" v-model.trim="params.id"></Input>
          </li>

          <li class="handle-item w-250">
            <AutoComplete
              @on-search="handleCompleteCompanies"
              icon="ios-search"
              placeholder="企业名称"
              v-model.trim="params.company_name"
            >
              <Option
                :key="item.id"
                :value="item.name"
                v-for="item in completeHandledCompanies"
              >{{ item.name }}</Option>
            </AutoComplete>
          </li>

          <li class="handle-item w-250">
            <AutoComplete
              @on-search="handleCompletePackages(0, $event)"
              icon="ios-search"
              placeholder="套餐名称"
              v-model.trim="params.package_name"
            >
              <Option
                :key="item.id"
                :value="item.name"
                v-for="item in completeHandledPackages"
              >{{ item.name }}</Option>
            </AutoComplete>
          </li>

          <li class="handle-item w-250">
            <DatePicker
              :editable="false"
              placeholder="激活时间"
              placement="bottom-start"
              type="daterange"
              v-model.trim="params.activated_time"
              :options="datePickerOptionsMonth"
            ></DatePicker>
          </li>
        </ul>

        <ul class="handle-wraper">
          <li class="handle-item w-250">
            <Select clearable placeholder="运营商" v-model="params.carrier_operator">
              <Option :value="0">联通</Option>
              <Option :value="1">移动</Option>
              <Option :value="2">电信</Option>
            </Select>
          </li>

          <li class="handle-item w-250">
            <Select clearable placeholder="卡状态" v-model="params.card_status">
              <!-- <Option :value="0">测试期</Option> -->
              <Option :value="1">沉默期</Option>
              <Option :value="2">服务期</Option>
              <Option :value="3">服务到期</Option>
              <Option :value="4">已注销</Option>
            </Select>
          </li>

          <li class="handle-item w-250">
            <Input placeholder="SIM" type="textarea" v-model="params.sim"/>
          </li>

          <li class="handle-item w-250">
            <DatePicker
              :editable="false"
              placeholder="创建时间"
              placement="bottom-start"
              type="daterange"
              v-model.trim="params.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-detail :data="detailObj.data" :show.sync="detailObj.show"></ui-detail>
  </div>
</template>

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