index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. show: {
  24. type: Boolean,
  25. default: false
  26. },
  27. treeData: Array,
  28. mode: {
  29. type: String,
  30. default: 'top'
  31. },
  32. height: {
  33. type: String,
  34. default: '600rpx'
  35. },
  36. width: {
  37. type: String,
  38. default: '400rpx'
  39. }
  40. },
  41. data() {
  42. return {
  43. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  44. showApply: false,
  45. isReady: false,
  46. prop: {
  47. label: 'fullName',
  48. isLeaf: 'isLeaf',
  49. value: "id",
  50. icon: 'avatar'
  51. },
  52. customStyle: {
  53. // #ifdef MP
  54. 'margin-top': '160rpx'
  55. // #endif
  56. // #ifndef MP
  57. 'margin-top': '80rpx'
  58. // #endif
  59. }
  60. }
  61. },
  62. watch: {
  63. show: {
  64. handler(val) {
  65. this.showApply = val
  66. },
  67. immediate: true,
  68. },
  69. },
  70. created() {
  71. _self = this
  72. this.isReady = true;
  73. },
  74. computed: {
  75. baseURL() {
  76. return this.define.baseURL
  77. }
  78. },
  79. methods: {
  80. handleNodeClick(obj) {
  81. if (obj.data.type != 1) this.$emit('change', obj.data)
  82. },
  83. close() {
  84. this.$emit('close')
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. page {
  91. padding-top: 80rpx;
  92. }
  93. .u-drawer {
  94. margin-top: 0 !important;
  95. }
  96. .ly-tree {
  97. /* padding: 20rpx !important; */
  98. }
  99. </style>