tree-nomal.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="tree-body">
  3. <view v-for="(item,index) in treeList" :key="item.value" class="tree">
  4. <view v-if="item.children">
  5. <view v-if="item.children.length > 0">
  6. <view class="head" @click="treeClick(item,index)">
  7. <image class="icon" :src="btn_unfold_normal_16" mode=""
  8. v-if="selectList.includes(item.value) && item.children"></image>
  9. <image class="icon" :src="btn_packup_normal_16" mode=""
  10. v-if="!selectList.includes(item.value) && item.children"></image>
  11. <view style="flex: 1;">{{ item.label }}</view>
  12. </view>
  13. <view v-if="selectList.includes(item.value) && item.children.length > 0" class="children">
  14. <TreeNomal :treeList="item.children" @detail="detail"></TreeNomal>
  15. </view>
  16. </view>
  17. <view class="data_item" v-else>
  18. <view>{{ item.label }}</view>
  19. <view class="btn-group">
  20. <view class="btn_orange btns" @click="detail(item)">详情</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="data_item" v-else>
  25. <view>{{ item.label }}</view>
  26. <view class="btn-group">
  27. <view class="btn_orange btns" @click="detail(item)">详情</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import TreeNomal from './tree-nomal.vue'
  35. export default {
  36. name: 'TreeNomal',
  37. props: {
  38. treeList: {
  39. type: Array,
  40. default: []
  41. }
  42. },
  43. components: {
  44. TreeNomal
  45. },
  46. data() {
  47. return {
  48. btn_packup_normal_16: require('./img/btn_packup_normal_16.svg'),
  49. btn_unfold_normal_16: require('./img/btn_unfold_normal_16.svg'),
  50. selectList: []
  51. }
  52. },
  53. methods: {
  54. detail(val) {
  55. this.$emit('detail', val)
  56. },
  57. yy(val) {
  58. this.$emit('yy', val)
  59. },
  60. sb(val) {
  61. this.$emit('sb', val)
  62. },
  63. treeClick(item, i) {
  64. console.log('treeClick', item)
  65. if (this.selectList.includes(item.value)) {
  66. for (let i = 0; i < this.selectList.length; i++) {
  67. if (this.selectList[i] == item.value) {
  68. this.selectList.splice(i, 1)
  69. }
  70. }
  71. } else {
  72. this.selectList.push(item.value)
  73. }
  74. // const parent = this.treeList
  75. // const index = i
  76. // this.nodeClick(item, parent, index)
  77. },
  78. nodeClick(item, parent, index) {
  79. this.$emit('node-click', item, parent, index)
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .tree-body {}
  86. .tree {
  87. font-family: PingFangSC, PingFang SC;
  88. color: rgba(4, 8, 20, 1);
  89. // font-size: 14px;
  90. // font-size: 56rpx;
  91. font-size: 28rpx;
  92. margin: 16rpx 0;
  93. background-color: rgba(255, 255, 255, 1);
  94. border-radius: 16rpx;
  95. padding: 16rpx;
  96. .head {
  97. display: flex;
  98. }
  99. .icon {
  100. width: 36rpx;
  101. height: 36rpx;
  102. // width: 60rpx;
  103. // height: 80rpx;
  104. }
  105. .children {
  106. margin-left: 40rpx;
  107. // margin-left: 60rpx;
  108. }
  109. .data_item {
  110. display: flex;
  111. justify-content: space-between;
  112. // min-height: 68rpx;
  113. margin: 16rpx 0 16rpx 40rpx;
  114. line-height: 48rpx;
  115. }
  116. .datas {
  117. padding: 8rpx;
  118. }
  119. .btn-group {
  120. width: 100rpx;
  121. display: flex;
  122. .btns {
  123. height: 48rpx;
  124. width: 96rpx;
  125. text-align: center;
  126. line-height: 46rpx;
  127. border-radius: 8rpx;
  128. margin-left: 24rpx;
  129. }
  130. .btn_orange {
  131. color: rgba(237, 123, 47, 1);
  132. border: 1rpx solid rgba(237, 123, 47, 1);
  133. }
  134. .btn_green {
  135. color: rgba(0, 168, 112, 1);
  136. border: 1rpx solid rgba(0, 168, 112, 1);
  137. }
  138. .btn_blue {
  139. color: rgba(16, 109, 255, 1);
  140. border: 1rpx solid rgba(16, 109, 255, 1);
  141. }
  142. }
  143. }
  144. </style>