<template>
  <el-select v-model="gridCatId" value-key="gridCatId" style="width: 100%" filterable placeholder="请选择区域分类">
    <el-option-group>
      <el-option
        v-for="item in dataList"
        :key="item.gridCatId"
        :label="item.gridCatTitle"
        :value="item.gridCatId"
      />
    </el-option-group>
  </el-select>
</template>
<script>
import { getGridCatByList } from '@/api/system/gridCatApi'

export default {
  name: 'GridCatSelector',
  components: { },
  props: {
    value: {
      type: Number,
      default: undefined
    }
  },
  data() {
    return {
      gridCatId: undefined,
      dataList: []
    }
  },
  watch: {
    value(val) {
      this.gridCatId = val
    },
    gridCatId(val) {
      this.$emit('input', val)
    }
  },
  created() {
    this.getData()
  },
  mounted() {},
  methods: {
    // 检查表清单
    getData() {
      getGridCatByList().then((resp) => {
        const { data } = resp
        this.dataList = data
      }).catch((error) => {
        console.log(error)
      })
    }
  }
}
</script>
