category_parent.vue 1.2 KB

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