index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div>
  3. <el-popover ref="popover" :placement="placement" trigger="click">
  4. <el-tree
  5. :data="data"
  6. :props="props"
  7. node-key="nodeKey"
  8. ref="popupTree"
  9. @current-change="currentChangeHandle"
  10. :default-expand-all="defaultExpandAll"
  11. :highlight-current="true"
  12. :expand-on-click-node="true">
  13. </el-tree>
  14. </el-popover>
  15. <el-input v-model="prop" v-popover:popover :readonly="true" :placeholder="placeholder" style="cursor:pointer;"></el-input>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. name: 'PopupTreeInput',
  21. props: {
  22. data: {
  23. type: Array,
  24. default: []
  25. },
  26. props: {
  27. type: Object,
  28. default: {}
  29. },
  30. prop: {
  31. type: String,
  32. default: ''
  33. },
  34. nodeKey: {
  35. type: String,
  36. default: ''
  37. },
  38. placeholder: {
  39. type: String,
  40. default: '点击选择内容'
  41. },
  42. placement: {
  43. type: String,
  44. default: 'right-start'
  45. },
  46. defaultExpandAll: {
  47. type: Boolean,
  48. default: false
  49. },
  50. currentChangeHandle: {
  51. type: Function,
  52. default: null
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. </style>