index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <u-popup v-model="showApply" :mode="mode" :height="height" @close="close" :width="width"
  3. :custom-style="customStyle">
  4. <slot></slot>
  5. <view class="tree-main">
  6. <ly-tree :props="prop" :node-key="prop.value" :tree-data="treeData" show-node-icon :defaultExpandAll='true'
  7. ref="tree" @node-click="handleNodeClick" :highlight-current="true" />
  8. </view>
  9. </u-popup>
  10. </template>
  11. <script>
  12. import LyTree from './ly-tree.vue'
  13. let _self;
  14. export default {
  15. components: {
  16. LyTree
  17. },
  18. props: {
  19. type: {
  20. type: String,
  21. default: ''
  22. },
  23. statusBarHeight: {
  24. type: Number,
  25. default: 196
  26. },
  27. show: {
  28. type: Boolean,
  29. default: false
  30. },
  31. treeData: Array,
  32. mode: {
  33. type: String,
  34. default: 'top'
  35. },
  36. height: {
  37. type: String,
  38. default: '600rpx'
  39. },
  40. width: {
  41. type: String,
  42. default: '400rpx'
  43. }
  44. },
  45. data() {
  46. return {
  47. showApply: false,
  48. isReady: false,
  49. prop: {
  50. label: 'fullName',
  51. isLeaf: 'isLeaf',
  52. value: "id",
  53. icon: 'avatar'
  54. },
  55. customStyle: {
  56. // #ifdef MP
  57. 'margin-top': '160rpx'
  58. // #endif
  59. // #ifndef MP
  60. 'margin-top': '80rpx'
  61. // #endif
  62. }
  63. }
  64. },
  65. watch: {
  66. show: {
  67. handler(val) {
  68. this.showApply = val
  69. },
  70. immediate: true,
  71. },
  72. },
  73. created() {
  74. _self = this
  75. this.isReady = true;
  76. },
  77. computed: {
  78. baseURL() {
  79. return this.define.baseURL
  80. }
  81. },
  82. methods: {
  83. handleNodeClick(obj) {
  84. if (obj.data.type != 1) this.$emit('change', obj.data)
  85. },
  86. close() {
  87. this.$emit('close')
  88. }
  89. }
  90. }
  91. </script>
  92. <style>
  93. page {
  94. padding-top: 80rpx;
  95. }
  96. .ly-tree {
  97. /* padding: 20rpx !important; */
  98. }
  99. </style>