Skip to content

二、框架核心组件

如无特殊说明,组件用法和PC端一致,只不过底层换成了vant组件实现

1. z-table 组件在移动端不可用

2. z-action 组件

2.1 mode 新增 popover

2.2 移动端新增属性

属性名说明类型默认值枚举值
position无线端属性,弹层位置(无线端)Stringrighttop/right/bottom/left

3. z-list 组件 (移动端特有)

组件属性:

属性名说明类型默认值枚举值
title内容标题String--
url表格数据接口地址String--
params接口参数配置Object--
condition搜索区域表单配置Field[]--
codetab 选项字典String--
tabNametab 条件的 nameString--
tabValuetab 的默认值String--
typetab 样式Enumlineline|card
tabs选项数据,建议使用字典 codeArray--
size分页大小Number10-
emptyText空数据文案String暂无相关数据
gutter删格间距Numbernull-

组件方法:

事件名说明
refresh()属性组件数据
jump(page)跳转到指定页数

组件事件:

事件名说明
finish表格接口数据返回完成

插槽:

插槽名说明
row没行数据插槽,返回当前行数据
default默认插槽

使用示例:

xml
<template>
    <van-nav-bar title="结算账户" fixed placeholder left-arrow @click-left="goBack">
    </van-nav-bar>
    <van-search v-model="search" placeholder="请输入结算账户名称" />
    <z-list url="/do/select/pay_account" :params="params" emptyText="暂无结算账户">
        <template #row="payAccount">
            <van-cell-group inset style="margin-top: 10px;">
                <van-cell :title="payAccount.title" :value="payAccount.status == 1 ? '已启用' : '禁用'">
                    <template #label>
                        <div>初始余额:<z-money :modelValue="payAccount.beginBalance" allowMinus/></div>
                        <div>总余额:<z-money :modelValue="payAccount.totalBalance || 0" allowMinus/></div>
                        <div>开账时间:<z-date :value="payAccount.createGmt" /></div>
                        <div>备注:{{ payAccount.extra }}</div>
                    </template>
                </van-cell>
                <van-cell>
                    <z-action label="明细" size="small" type="primary" >
                        <Detail :payAccount="payAccount" />
                    </z-action>
                    <z-action label="编辑" size="small" url="/api/common/patchPayAccount" type="primary"
                        :data="payAccount" :fields="fields" />
                    <z-action label="删除" size="small" url="/do/delete/pay_account" type="danger" mode="confirm"
                        :data="payAccount" />
                </van-cell>
            </van-cell-group>
        </template>
        <z-action label="新增" url="/do/put/pay_account" :fields="fields" size="small" type="bubble" :beforeSubmit="beforeSubmit" />
    </z-list>
</template>

<script>
import Detail from './blocks/detail.vue';
export default {
    components: {
        Detail
    },
    data() {
        return {
            search: '',
            fields: [
                { label: '账户名称', name: 'title' },
                { label: '初始余额', name: 'beginBalance', type: 'money' },
                { label: '备注', name: 'extra', type: 'textarea' },
            ],
        };
    },
    computed: {
        account() {
            return window.localStorage.getItem('_ac_');
        },
        params() {
            return { account: this.account, title: this.search };
        }
    },
    methods: {
        goBack() {
            this.$router.back();
        },
        beforeSubmit(formData) {
            formData.account = this.account;
            return formData;
        }
    }
};
</script>
<style scoped lang="scss">
.van-button--small {
    margin-right: 10px;

    &:last-child {
        margin-right: 0;
    }
}
</style>