123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template>
- <view class="tree-body">
- <view v-for="(item,index) in treeList" :key="item.value" class="tree">
- <view v-if="item.children">
- <view v-if="item.children.length > 0">
- <view class="head" @click="treeClick(item,index)">
- <image class="icon" :src="btn_unfold_normal_16" mode=""
- v-if="selectList.includes(item.value) && item.children"></image>
- <image class="icon" :src="btn_packup_normal_16" mode=""
- v-if="!selectList.includes(item.value) && item.children"></image>
- <view style="flex: 1;">{{ item.label }}</view>
- </view>
- <view v-if="selectList.includes(item.value) && item.children.length > 0" class="children">
- <TreeNomal :treeList="item.children" @detail="detail"></TreeNomal>
- </view>
- </view>
- <view class="data_item" v-else>
- <view>{{ item.label }}</view>
- <view class="btn-group">
- <view class="btn_orange btns" @click="detail(item)">详情</view>
- </view>
- </view>
- </view>
- <view class="data_item" v-else>
- <view>{{ item.label }}</view>
- <view class="btn-group">
- <view class="btn_orange btns" @click="detail(item)">详情</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import TreeNomal from './tree-nomal.vue'
- export default {
- name: 'TreeNomal',
- props: {
- treeList: {
- type: Array,
- default: []
- }
- },
- components: {
- TreeNomal
- },
- data() {
- return {
- btn_packup_normal_16: require('./img/btn_packup_normal_16.svg'),
- btn_unfold_normal_16: require('./img/btn_unfold_normal_16.svg'),
- selectList: []
- }
- },
- methods: {
- detail(val) {
- this.$emit('detail', val)
- },
- yy(val) {
- this.$emit('yy', val)
- },
- sb(val) {
- this.$emit('sb', val)
- },
- treeClick(item, i) {
- console.log('treeClick', item)
- if (this.selectList.includes(item.value)) {
- for (let i = 0; i < this.selectList.length; i++) {
- if (this.selectList[i] == item.value) {
- this.selectList.splice(i, 1)
- }
- }
- } else {
- this.selectList.push(item.value)
- }
- // const parent = this.treeList
- // const index = i
- // this.nodeClick(item, parent, index)
- },
- nodeClick(item, parent, index) {
- this.$emit('node-click', item, parent, index)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .tree-body {}
- .tree {
- font-family: PingFangSC, PingFang SC;
- color: rgba(4, 8, 20, 1);
- // font-size: 14px;
- // font-size: 56rpx;
- font-size: 28rpx;
- margin: 16rpx 0;
- background-color: rgba(255, 255, 255, 1);
- border-radius: 16rpx;
- padding: 16rpx;
- .head {
- display: flex;
- }
- .icon {
- width: 36rpx;
- height: 36rpx;
- // width: 60rpx;
- // height: 80rpx;
- }
- .children {
- margin-left: 40rpx;
- // margin-left: 60rpx;
- }
- .data_item {
- display: flex;
- justify-content: space-between;
- // min-height: 68rpx;
- margin: 16rpx 0 16rpx 40rpx;
- line-height: 48rpx;
- }
- .datas {
- padding: 8rpx;
- }
- .btn-group {
- width: 100rpx;
- display: flex;
- .btns {
- height: 48rpx;
- width: 96rpx;
- text-align: center;
- line-height: 46rpx;
- border-radius: 8rpx;
- margin-left: 24rpx;
- }
- .btn_orange {
- color: rgba(237, 123, 47, 1);
- border: 1rpx solid rgba(237, 123, 47, 1);
- }
- .btn_green {
- color: rgba(0, 168, 112, 1);
- border: 1rpx solid rgba(0, 168, 112, 1);
- }
- .btn_blue {
- color: rgba(16, 109, 255, 1);
- border: 1rpx solid rgba(16, 109, 255, 1);
- }
- }
- }
- </style>
|