<template>
  <SimpleList ref="list" v-bind="$attrs" :params="queryParams" :queryMethod="pageListVehicle()" @change="$emit('change', $event)">
    <template slot="header">
      <el-input v-model="queryParams.vehicleNumber" 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="vehicleNumber"  />
    <el-table-column label="品牌" align="center" prop="vehicleBrand"  />
    <el-table-column label="载重" align="center" prop="vehicleLoad" />
  </SimpleList>
</template>

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

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