diff --git a/pages/index/index.vue b/pages/index/index.vue index c74b99616f826a068005d1847592501c02f8b81a..ced4ae76b11138d12476a6f2e23d3a064372cba7 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -2,11 +2,12 @@ color 不生效 [2022年4月1日] +2. 新增分页功能,详细请看文档相关配置 [2022年4月1日] + ## 1.0.2(2022-04-01) 1. add: 新增 columns 配置: customName , 别名;如果 customName 存在 则优先显示,否则显示 title 2. fix: 修复表格名称居中显示实际没有居中的问题 diff --git a/uni_modules/n-table/components/n-table/config.js b/uni_modules/n-table/components/n-table/config.js index 5b30b23dabab4cb3cf1f1770a209b23374e032d7..2339302bcc91e35d56c0e5c6e6c0021f764a5520 100644 --- a/uni_modules/n-table/components/n-table/config.js +++ b/uni_modules/n-table/components/n-table/config.js @@ -53,3 +53,11 @@ export const defaultTableOpt = { // sumPlace String | 合计行位置 top / bottom, 仅 isShowSum = true 生效 sumPlace: 'bottom' } + + +export const defaultPagerOpt = { + // show Boolean | 是否启用分页功能 + show: false, + // pageSize Number | 每页条数 + pageSize: 10 +} \ No newline at end of file diff --git a/uni_modules/n-table/components/n-table/n-table.vue b/uni_modules/n-table/components/n-table/n-table.vue index e15bf43dd75389a5c6903e28c8d234752d03286e..da7e61a8a437aa1554415b262da77d9971be6c46 100644 --- a/uni_modules/n-table/components/n-table/n-table.vue +++ b/uni_modules/n-table/components/n-table/n-table.vue @@ -43,6 +43,7 @@ + @@ -51,20 +52,23 @@ import tableHeader from "./table-header.vue" import tableBody from "./table-body.vue" import tableName from "./table-name.vue" - import { defaultTableOpt, defaultNameOpt } from "./config.js" + import pager from "./pager.vue" + import { defaultTableOpt, defaultNameOpt, defaultPagerOpt } from "./config.js" import { sortList } from "./utils.js" export default { - components: { tableHeader, tableBody, tableName }, + components: { tableHeader, tableBody, tableName, pager }, data() { return { nowSortKey: '', sortType: 'desc', // asc/desc 升序/降序 - tableLoaded: false, - dataList: [], // 处理后的数据列表 + dataList: [], // 遍历显示的数据列表 + saveDataList: [], // 处理后的数据列表 - 用以备份 : 当分页形式无需重新计算 dataIndexs: [], // isTree: false, // 是否树形数据 isOpenAll: false, // 是否展开全部 + curPage: 1, // 当前页码 + totalPage: 0, // 总页数 } }, props: { @@ -85,6 +89,13 @@ type: Object, default: () => {} }, + // 分页配置 + pagerOpt: { + type: Object, + default: () => { + return {} + } + }, // 数据源唯一key字段名 idKey: { type: String, default: 'id' }, // columns中对应列表数据的 字段名 @@ -93,11 +104,6 @@ tableData: { type: [Array, Boolean], default () { return false } }, columns: { - /* - * - * [{title: xxx, key: 当前列展示对象名, width: 列宽, render: