index.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <el-select v-model="gridCatId" value-key="gridCatId" style="width: 100%" filterable placeholder="请选择区域分类">
  3. <el-option-group>
  4. <el-option
  5. v-for="item in dataList"
  6. :key="item.gridCatId"
  7. :label="item.gridCatTitle"
  8. :value="item.gridCatId"
  9. />
  10. </el-option-group>
  11. </el-select>
  12. </template>
  13. <script>
  14. import { getGridCatByList } from '@/api/system/gridCatApi'
  15. export default {
  16. name: 'GridCatSelector',
  17. components: { },
  18. props: {
  19. value: {
  20. type: Number,
  21. default: undefined
  22. }
  23. },
  24. data() {
  25. return {
  26. gridCatId: undefined,
  27. dataList: []
  28. }
  29. },
  30. watch: {
  31. value(val) {
  32. this.gridCatId = val
  33. },
  34. gridCatId(val) {
  35. this.$emit('input', val)
  36. }
  37. },
  38. created() {
  39. this.getData()
  40. },
  41. mounted() {},
  42. methods: {
  43. // 检查表清单
  44. getData() {
  45. getGridCatByList().then((resp) => {
  46. const { data } = resp
  47. this.dataList = data
  48. }).catch((error) => {
  49. console.log(error)
  50. })
  51. }
  52. }
  53. }
  54. </script>