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

<script>
import { pageListDriver } from "@/api/tm/driver";
import SimpleList from "@/views/tm/components/SimpleList";

export default {
  name: "DriverList",
  dicts: ['license_type'],
  components: {
    SimpleList,
  },
  props: {
    custId: {
      type: [String, Number],
      default: null,
    }
  },
  data() {
    return {
      queryParams: {
        driverName: '',
        custId: this.custId
      }
    };
  },
  watch: {
    custId: {
      handler(val) {
        this.queryParams.custId = val;
        this.$nextTick(() => {
          this.handleSearch();
        });
      },
    }
  },
  methods: {
    pageListDriver() {
      return pageListDriver;
    },
    handleSearch(e) {
      this.$refs.list.handleSearch(e);
    },
    clearSelection() {
      this.$refs.list.clearSelection();
    }
  }
};
</script>
