<template>
  <div class="stock">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item label="名称">
        <el-input v-model="dataForm.customerName" placeholder="客户名称" clearable/>
      </el-form-item>
      <el-form-item label="客户级别">
        <el-select
          v-model="value"
          remote
          :remote-method="selectCusLevel"
          placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
<!--        <el-input v-model="dataForm.level" placeholder="客户级别" clearable/>-->
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <el-button type="primary" @click="test()">新增客户</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        label="序号"
        type="index"
        width="50"
        align="center">
      </el-table-column>
      <el-table-column
        prop="-"
        header-align="center"
        align="center"
        label="编码">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button v-if="isAuth('wh:stock-mg-ctl:info')" type="text" size="small" @click="details(scope.row.customerId)">查看</el-button>
          <el-button v-if="isAuth('wh:stock-mg-ctl:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.customerId)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <stock-details v-if="detailVisible" ref="details"/>
    <stock-add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"/>
  </div>
</template>

<script>
  export default {
    name: 'customer'
  }
</script>

<style scoped>

</style>
