<template>
  <el-select v-model="equipCatId" value-key="EquipmentCatId" style="width: 100%" filterable placeholder="请选择设备类别">
    <el-option-group>
      <el-option
        v-for="item in dataList"
        :key="item.equipCatId"
        :label="item.equipCatTitle"
        :value="item.equipCatId"
      />
    </el-option-group>
  </el-select>
</template>
<script>
import { getEquipmentCatByList } from '@/api/aqpt/equipmentCatApi'

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