weex 折叠列表组件

weex实现折叠列表(人员组织的样式),有light组件库供参考(https://document.lightyy.com/light_ui_ref/index.html),但是(因为个人公司UI源码,所以自己手码了一个供参考)

参考:https://www.cnblogs.com/crazycode2/p/7919256.html

要实现的效果图:

codinate

源码:(提供了源码,功能不够用,可以自己扩展)

accordion.vue:
<!-- 折叠列表 组件 -->
<template>
    <div class="accordion_main_css">

        <div class="firstCellCss" @click="toggleList">
            //一级列表内容坑位
            <slot name="firstContent" :row="firstItem" ></slot>
            <image class="arrowRightImageCss" v-if="!isFirstDisplay" src="mipmap://cell_right_arrow.png"/>
            <image class="arrowDownImageCss" v-else src="mipmap://cell_down_arrow.png"/>
        </div>

        <div class="secondCellCss" v-if="isFirstDisplay">
            <div style="flex-direction: column;" v-for="(item,index) in  firstItem.children" @click="toggleSecondList(item)">
                <div  style="height: 1px;background-color: #eee"></div>
                <div style="justify-content: space-between;align-items: center;flex-direction: row;height: 88px">
                    //二级列表内容坑位
                    <slot name="secondContent" :row="item" ></slot>
                    <image class="arrowRightImageCss" v-if="!isSecondDisplay" src="mipmap://cell_right_arrow.png"/>
                    <image class="arrowDownImageCss" v-else src="mipmap://cell_down_arrow.png"/>
                </div>
            </div>
        </div>

    </div>
</template>

<script>
    export default {
        data() {
            return {
                isFirstDisplay: false,//一級列表icon是否展示,是否有字列表
                isSecondDisplay: false//二級列表icon是否展示,是否有字列表
            }
        },
        props: {
            //content ,使用的话用slot重写content view
            firstItem: {
                type: Object,
                default() {
                    return {}
                }
            },
        },
        methods: {
            toggleList() {
                if(this.firstItem.children.length>0){
                    this.isFirstDisplay = !this.isFirstDisplay;
                }else{
                    console.log('没有子集')
                }
            },
            toggleSecondList(item) {
                //this.isSecondDisplay = !this.isSecondDisplay
                this.$emit('childItem', item);
            }
        }
    }
</script>

<style scoped>
    .accordion_main_css {
        width: 750px;
        display: flex;
        flex-direction: column;
        background-color: white;
    }

    .firstCellCss {
        flex-direction: row;
        justify-content: space-between;
        background-color: white;
        align-items: center;
        height: 88px;
        line-height: 88px;
    }

    .secondCellCss {
        flex-direction: column;
        background-color: white;
    }

    .arrowRightImageCss{
        width:14px;
        height: 24px;
        margin-right: 24px;
        align-items: right;
    }
    .arrowDownImageCss{
        width:24px;
        height: 14px;
        align-items: right;
        margin-right: 24px;
    }
</style>

控件使用:在自己的vue里使用

<!-- 列表 -->
<scroller  style="align-items:center">
    <div v-for="(item,index) in organizationList">
        //展示分割线
        <div style="height: 1px;background-color: #eee"></div>
        //列表的cell  (firstItem一级列表的item  ;  childItem二级列表item的点击返回)
        <accordion  :firstItem="item" :childItem="childItemClick">

               //一级内容坑位展示
               <div slot="firstContent" slot-scope="props" style="flex-direction: row;align-items: center;margin-left:24px">
                    <image  style="width: 34px;height:34px" src="mipmap://department_icon.png"></image>
                    <text style="font-size: 30px;color: #333;margin-left:10px;"> {{ props.row.name }}({{ item.children.length }}人)</text>
               </div>

               //二级内容坑位展示
               <div slot="secondContent" slot-scope="props" style="flex-direction: row;align-items: center;margin-left: 44px">
                  <image  style="width: 23px;height:23px" src="mipmap://depart_org_icon.png"></image>
                  <text style="margin-left:10px; font-size: 28px;color: #333;"> {{ props.row.name }} </text>
               </div>

        </accordion>

    </div>
</scroller >
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

漠天515

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值