<template>
    <div class="block">
      <el-cascader
        placeholder="车辆品牌型号"
        :options="options"
        v-model="selectedValues"
        filterable
        :props="{checkStrictly:true}"
        />
    </div>

  </template>
  <script>
  import * as CarBrandSelectorApi from '@/layout/components/CarBrandSelector/Api';

  export default {
    name: 'CarBrandSelector',

    props: {
      //v-model绑定的值
      value: {
        type: Array,
        default: () => [],
      },
    },

    data() {
      return {
        //子组件赋值
        selectedValues:this.value,
        options: [], //选项集合
      };
    },

    watch: {
      value: {
        immediate: true,
        handler(newVal) {
          this.selectedValues = newVal;
        }
      },
      selectedValues(newVal) {
        this.$emit('input', newVal);
      }
    },

    created() {
      this.getData();
    },
    methods: {

      getData(keyword) {
        // this.reset()
        let param = {
          modelName: keyword,
        }
        CarBrandSelectorApi.searchBrand(param).then(res => {
          this.options = res.data
        });
      },
    },


  };
  </script>
