category-select.vue 987 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <el-cascader style="width: 100%"
  3. ref="cascader"
  4. :options="categoryList"
  5. :props="{ checkStrictly: true,label: 'categoryName',value: 'id',children: 'childs' }"
  6. clearable></el-cascader>
  7. </template>
  8. <script>
  9. import api from '@@/components/canvasShow/config/api'
  10. import {sendReqMixin} from '@@/components/canvasShow/config/mixin'
  11. import {checkEmptyChild} from '@@/config/common'
  12. export default {
  13. name: 'category-select',
  14. mixins: [sendReqMixin],
  15. data () {
  16. return {
  17. categoryList: []
  18. }
  19. },
  20. mounted () {
  21. this.getCategory()
  22. },
  23. methods: {
  24. // 获取类别
  25. getCategory () {
  26. var _this = this
  27. let params = {
  28. url: api.getClassify,
  29. method: 'GET'
  30. }
  31. this.sendReq(params, (res) => {
  32. _this.categoryList = res.data
  33. checkEmptyChild(_this.categoryList)
  34. })
  35. }
  36. }
  37. }
  38. </script>