Yb-components Yb-components
首页
开发规范
yb-cli
  • 开发指南
  • 更新日志
  • 组件
关于
首页
开发规范
yb-cli
  • 开发指南
  • 更新日志
  • 组件
关于
  • 开发指南
  • 更新日志
  • 数据展示

    • YbTable 表格
    • YbCardList 卡片列表
    • YbTree 树
    • YbCascaderList 级联列表
    • YbSimpleTablePage 分页查询表格
    • YbSimpleCardPage 分页卡片列表
    • YbBasicProfile 基础详情数据展示
    • YbOutscrollLayout 固定在滚动区域外
    • YbOutscrollTree 固定在滚动区域外的Tree
    • YbInfoLayout 信息页布局
    • YbEditLayout 编辑页布局
  • 数据录入

    • YbRowsPopoverForm 浮层多行表单
    • YbFormily 配置式表单
    • YbForm 表单
    • YbRowsForm 多行表单
    • YbCollapseForm 折叠表单
    • YbQueryFilter 筛选表单
    • YbFilesSelect 文件选择器
    • YbRangeWrapper 范围结构
    • YbRangeDatepicker 日期范围
    • YbRange 范围
    • YbFormulaInput 简单运算公式输入
    • YbCron 表达式生成器
    • YbTreeSelect 树型选择器
    • YbInputgroupWrapper 复合组
    • YbThemeSelect 主题风格选择器
    • YbSelect 选择器
    • YbPaginationSelect 分页选择器
    • YbCodemirror 代码编辑器
    • YbCodemirrorSql SQL编辑器
    • YbCodemirrorJson JSON编辑器
    • YbCodemirrorXml XML编辑器
    • YbCombiDatepicker 组合时间
    • YbQuarterPicker 季度选择器
    • YbRangeQuarterPicker 季度范围选择器
    • YbConditionSelect 条件选择器
    • YbCheckboxGroup 多选框组
    • YbIconSelect 选择器
    • YbTagsInput 标签输入框
  • 其他组件

    • YbBallLoading 加载中
    • YbSymbolIcon 多色小图标
    • YbKeybuttonsPopover
    • YbPercentBattery 电池百分比
    • YbAffix 固钉
    • YbPagination 分页器
    • YbCollapse 折叠面板
    • YbScrollTool 滚动工具
  • 物料

    • YbMainSideMenu 侧栏菜单
    • YbLoadRemote 远程应用加载
    • YbLayoutPro 布局
    • YbMainPro 主页
    • YbAppMain 应用主页
    • YbAppLogin 普通登录页
    • YbAppPortal Portal登录页
  • 指令

    • v-fixed-in-scroller
  • Mixins

    • pageList_mixin
      • getScopedSlot_mixin
      • editFormPage_mixin
      • uploadProgressPage_mixin
      • rowActions_mixin
      • rowDeletes_mixin
      • drawerToRouterTab_mixin
    • 实验室

      • YbSwiper 轮播
    • 组件
    • Mixins
    zougt
    2021-10-23

    pageList_mixin

    提供分页查询的调用逻辑,YbSimpleTablePage 组件就是依赖此 mixin

    # 需独立引入

    import pageList_mixin from 'yb-components/packages/es/mixins/pageList_mixin';
    
    1

    # 基本使用

    需要在组件内引入 pageList_mixin

    需要提供 getListApi 方法,必需返回 Promise,resolve({total,tableData})

    <template>
        <div v-loading="pageLoading">
            <yb-form
                ref="form"
                :formItems="formItems"
                :model="formModel"
                :inline="true"
                style="width: 100%"
                @submit.native.prevent="searchList"
            >
                <template v-slot:formItems="formItem">
                    <el-input
                        v-model="formModel[formItem.prop]"
                        clearable
                    ></el-input>
                </template>
                <template v-slot:search-buttons>
                    <el-button type="primary" native-type="submit" size="small"
                        >查询</el-button
                    >
                </template>
            </yb-form>
            <el-card
                :body-style="{ padding: '0' }"
                style="border: 0"
                shadow="never"
            >
                <yb-table :columns="columns" :data="tableData">
                    <template v-slot:state="{ column, row }">
                        <el-tag
                            :type="tagTypes[row[column.property]]"
                            effect="plain"
                            >{{ row[column.property] }}</el-tag
                        >
                    </template>
                    <template v-slot:action-buttons="{ row }">
                        <el-button type="default" size="mini">查看</el-button>
                    </template>
                </yb-table>
            </el-card>
            <div style="margin-top: 10px; overflow: hidden">
                <el-pagination
                    background
                    layout="total,prev, pager, next"
                    :total="page.total"
                    :page-size="page.pageSize"
                    :current-page="page.currentPage"
                    style="float: right"
                    @size-change="onPageSizeChange"
                    @current-change="onCurrentPageChange"
                >
                </el-pagination>
            </div>
        </div>
    </template>
    
    <script>
        const tableData = JSON.parse(
            `[{"fieldName":"诊疗信息.组织机构代码","medicalRecordNumber":"BY04","patientName":"老王","projectTypeName":"诊疗信息"},{"fieldName":"诊疗信息.组织机构代码","medicalRecordNumber":"BY04","patientName":"老李","projectTypeName":"诊疗信息"},{"fieldName":"诊疗信息.组织机构代码","medicalRecordNumber":"BY04","patientName":"姓名","projectTypeName":"诊疗信息"},{"fieldName":"诊疗信息.组织机构代码","medicalRecordNumber":"BY04","patientName":"老王","projectTypeName":"诊疗信息"},{"fieldName":"诊疗信息.组织机构代码","medicalRecordNumber":"BY04","patientName":"老王","projectTypeName":"诊疗信息"},{"fieldName":"诊疗信息.组织机构代码","medicalRecordNumber":"BY04","patientName":"老王","projectTypeName":"诊疗信息"}]`
        ).map((item, i) => ({ ...item, id: i + 1 }));
    
        import pageListMixin from './pageListMixin';
    
        export default {
            mixins: [pageListMixin],
            data() {
                const formItems = [
                    {
                        label: '病案号',
                        prop: 'medicalRecordNumber',
                    },
                    {
                        label: '姓名',
                        prop: 'patientName',
                    },
                    {
                        label: '',
                        prop: 'search-buttons',
                    },
                ];
                const formModel = formItems.reduce((tol, item) => {
                    return { ...tol, [item.prop]: '' };
                }, {});
                return {
                    formItems,
                    formModel,
                    columns: [
                        {
                            label: '病案号',
                            prop: 'medicalRecordNumber',
                            'show-overflow-tooltip': true,
                            width: '120px',
                        },
                        {
                            label: '姓名',
                            prop: 'patientName',
                        },
                        {
                            label: '信息分类',
                            prop: 'projectTypeName',
    
                            'show-overflow-tooltip': true,
                        },
                        {
                            label: '操作',
                            prop: 'action-buttons',
                            width: '146px',
                        },
                    ],
                };
            },
            mounted() {
                this.searchList();
            },
            methods: {
                // 调用 this.searchLis() 会调用 getListApi
                getListApi(query) {
                    return Promise.resolve({
                        total: tableData.length,
                        tableData: tableData.slice(
                            (query.currentPage - 1) * query.pageSize,
                            query.currentPage * query.pageSize
                        ),
                    });
                },
            },
        };
    </script>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128

    # data

    参数 说明 类型 可选值 默认值
    pageLoading 调用 searchList 或 getList 会触发 pageLoading boolean - false
    page 分页的信息对象 object - -
    page.pageSize 一页显示条数 number - 10
    page.currentPage 当前页数 number - 1
    page.total 总数 number - 0
    tableData 由 getListApi 方法 resolve 回来的列表数据 object[] - []
    formModel 通常用于绑定查询表单的值,用于 getListApi 方法的参数 object - {}

    # methods

    方法名 说明 返回值 传参
    getList 获取列表数据,会调用 getListApi 方法 接受一个对象,会转发给 getListApi -
    searchList 会让分页器回到第一页,会调用 getList,可以理解为查询触发的方法 接受一个对象,会转发给 getListApi -
    searchList 会让分页器回到第一页,会调用 getList,可以理解为查询触发的方法 接受一个对象,会转发给 getListApi -
    onCurrentPageChange 当分页器的当前页改变时需调用 - currentPage
    onPageSizeChange 当分页器的一页条数改变时需调用 - pageSize
    上次更新: 2022/08/30, 17:30:42
    v-fixed-in-scroller
    getScopedSlot_mixin

    ← v-fixed-in-scroller getScopedSlot_mixin→

    Theme by Vdoing | Copyright © 2021-2025 YB-GZ | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式