category.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div>
  3. <el-cascader
  4. :clearable="true"
  5. v-model="select_val"
  6. placeholder="请选择分类"
  7. :options="options"
  8. @change="handleChange"
  9. />
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. value: {
  16. },
  17. type: {
  18. type: Number,
  19. default: 0
  20. },
  21. category_change:{
  22. type: Function,
  23. }
  24. },
  25. data() {
  26. return {
  27. type_val: 0,
  28. select_val: [],
  29. options: []
  30. }
  31. },
  32. watch:{
  33. type:function (newVal,oldVal) {
  34. this.type_val = newVal
  35. this.getCateGory()
  36. }
  37. },
  38. mounted() {
  39. this.type_val = this.type
  40. this.getCateGory()
  41. },
  42. methods: {
  43. handleChange(value) {
  44. this.$emit('input', value);
  45. if(typeof(this.category_change)=="function")
  46. {
  47. this.category_change(this.select_val[1]);
  48. }
  49. },
  50. async getCateGory() {
  51. const res =await this.$post('/uapi/pub/list/admin/category/get_cate_ab', { type: this.type_val })
  52. this.options = res.data
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .screenfull-svg {
  59. display: inline-block;
  60. cursor: pointer;
  61. fill: #5a5e66;;
  62. width: 20px;
  63. height: 20px;
  64. vertical-align: 10px;
  65. }
  66. </style>