borgTree.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="treetable">
  3. <view style="display:table-caption !important;text-align:center !important;" >
  4. <view class="kuang" @click.native.stop="selectedClick(treedata)">{{treedata.name}}{{treedata.userCount}}人</view>
  5. <br/>
  6. <span style="border-left:1px solid;height:10upx;"></span>
  7. </view>
  8. <view v-if="treedata.children && treedata.children.length > 1">
  9. <view v-for=" index of treedata.children.length" :key="index">
  10. <view class="treetable">
  11. <view>
  12. <view v-for="index2 of 2" :key="index2">
  13. <view v-if="((index+1)*2-(index2+1)%2 -1) == 0">
  14. <text style="visibility: hidden;">
  15. 1
  16. </text>
  17. </view>
  18. <!-- [注意]index+1 是v-for 的 of in与Vue和Uniapp是不是一样?遍历下标是从0还是1开始 -->
  19. <view v-else-if="((index+1)*2-(index2+1)%2 -1) == 1" :style="lefttoplinestyle">
  20. <text style="visibility: hidden;">
  21. 1
  22. </text>
  23. </view>
  24. <view v-else-if="((index+1)*2-(index2+1)%2 -1) == treedata.children.length * 2 - 2" :style="righttoplinestyle">
  25. <text style="visibility: hidden;">
  26. 1
  27. </text>
  28. </view>
  29. <view v-else-if="((index+1)*2-(index2+1)%2 -1) == treedata.children.length * 2 - 1">
  30. <text style="visibility: hidden;">
  31. 1
  32. </text>
  33. </view>
  34. <view v-else-if="((index+1)*2-(index2+1)%2 -1) % 2 == 1" :style="lefttoplinestyle">
  35. <text style="visibility: hidden;">
  36. 1
  37. </text>
  38. </view>
  39. <view v-else-if="((index+1)*2-(index2+1)%2 -1) % 2 == 0" :style="toplinestyle">
  40. <text style="visibility: hidden;">
  41. 1
  42. </text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view>
  50. <view v-for=" (children,index) in treedata.children" :key="index" style="vertical-align:top;text-align: center;">
  51. <view v-if="!children.children || children.children.length == 0" class="kuang" @click.native.stop="selectedClick(children)">
  52. {{children.name}}{{children.userCount}}人
  53. </view>
  54. <borgTree ref="btree" v-else :treedata="children" @clickNode="selectedClick"></borgTree>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. // import borgTree from '@/components/gld-tree/borg-tree-div.vue';
  61. export default {
  62. // components: {
  63. // borgTree
  64. // },
  65. name: "grp",
  66. props: {
  67. treedata: Object,
  68. },
  69. data() {
  70. return {
  71. lefttoplinestyle: "border-top:1px solid;border-left:1px solid;",
  72. toplinestyle: "border-top:1px solid;",
  73. righttoplinestyle: "border-top:1px solid;border-right:1px solid;"
  74. }
  75. },
  76. created() {
  77. },
  78. methods: {
  79. selectedClick(node) {
  80. this.$emit("clickNode", node)
  81. }
  82. }
  83. };
  84. </script>
  85. <style>
  86. .kuang {
  87. border-radius: 5px !important;
  88. word-wrap: break-word;
  89. display: inline-block !important;
  90. padding: 10upx !important;
  91. font-size: 28upx !important;
  92. border: 1px solid #333333 !important;
  93. margin: 0upx 8upx !important;
  94. width: 1em;
  95. /* min- 200upx !important; */
  96. }
  97. .treetable {
  98. width: 100% ;
  99. display: table;
  100. }
  101. .treetable > view {
  102. display: table-row ;
  103. }
  104. .treetable > view > view {
  105. display: table-cell ;
  106. vertical-align: middle ;
  107. text-align: center ;
  108. }
  109. </style>