<template>
  <SimpleList ref="list" v-bind="$attrs" :params="queryParams" :queryMethod="pageListCust()" @change="$emit('change', $event)">
    <template slot="header">
      <el-input
        v-model="queryParams.custName"
        style="margin-bottom: 10px;"
        placeholder="搜索客户名称"
        clearable
        @keyup.enter.native="handleSearch"
      >
        <el-button slot="append" icon="el-icon-search" @click="handleSearch" />
      </el-input>
    </template>
    <el-table-column label="客户名称" align="center" prop="custName" />
    <el-table-column label="客户类型" align="center" prop="custType" width="80">
      <template slot-scope="scope">
        <dict-tag :options="dict.type.customer_type" :value="scope.row.custType" />
      </template>
    </el-table-column>
  </SimpleList>
</template>

<script>
import { pageListCust } from '@/api/jxc/cust'
import SimpleList from '@/views/tm/components/SimpleList'

export default {
  name: 'CustList',
  dicts: ['customer_type'],
  components: { SimpleList },
  props: {
    custType: [String]
  },
  data() {
    return {
      queryParams: {
        custName: '',
        custType: '',
      }
    }
  },
  watch: {
    custType: {
      handler(val) {
        this.queryParams.custType = val;
      },
      immediate: true
    }
  },
  methods: {
    pageListCust() {
      return pageListCust
    },
    handleSearch(e) {
      this.$refs.list.handleSearch(e)
    },
    clearSelection() {
      this.$refs.list.clearSelection();
    }
  }
}
</script>
<style scoped lang="scss">
</style>
