wkjp-list-page 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -234,7 +234,8 @@ deviceListTransformList(list) {
234
234
 
235
235
  **情况:** 下拉只要 10、20、50,不要默认一长串。
236
236
  **加:** `:pagination="{ pSizes: [10, 20, 50] }"`
237
- **说明:** 这里的 **`pagination` 只用来合并进组件内部分页**(改 `pSizes` 等),不是让你自己维护当前第几页、总条数——那些仍是组件内部根据接口结果在管。
237
+ **说明:** 这里的 **`pagination` 只用来合并进组件内部分页**(改 `pSizes` 等),不是让你自己维护当前第几页、总条数——那些仍是组件内部根据接口结果在管。
238
+ **分页 `layout`:** 当 **`total` 不大于 `pSizes` 中的最小值**(例如共 3 条、最小每页 10 条)时,**不显示「每页条数」下拉与「前往页」**,只保留总数与翻页;数据超过一页时再显示完整分页控件。
238
239
 
239
240
  ---
240
241
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wkjp-list-page",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Vue2 + ElementUI CommonListPage component",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -143,9 +143,9 @@
143
143
  :current-page="innerPagination.page"
144
144
  :page-size="innerPagination.pageSize"
145
145
  :page-sizes="innerPagination.pSizes || [10, 50, 100, 200]"
146
+ :layout="paginationLayout"
146
147
  @size-change="handleSizeChange"
147
148
  @current-change="handlePageChange"
148
- layout="total, sizes, prev, pager, next, jumper"
149
149
  ></el-pagination>
150
150
 
151
151
  <el-dialog
@@ -338,6 +338,24 @@ export default {
338
338
  showExportWithApi() {
339
339
  return this.showExport === true && typeof this.exportApi === "function";
340
340
  },
341
+ /** `page-sizes` 中的最小值;与 `el-pagination` 的 `:page-sizes` 同源 */
342
+ paginationMinPageSize() {
343
+ const ip = this.innerPagination;
344
+ const fallback = [10, 50, 100, 200];
345
+ const sizes = ip && Array.isArray(ip.pSizes) && ip.pSizes.length ? ip.pSizes : fallback;
346
+ const nums = sizes.map((n) => Number(n)).filter((n) => Number.isFinite(n) && n > 0);
347
+ return nums.length ? Math.min.apply(null, nums) : 10;
348
+ },
349
+ /**
350
+ * 当 **`total` 不大于 `pSizes` 最小值**(单页即可装下)时,从 `layout` 去掉 **`sizes`**(每页条数)与 **`jumper`**(前往页),
351
+ * 仍保留 **总数、上一页、页码、下一页**;多页时再显示完整布局。
352
+ */
353
+ paginationLayout() {
354
+ if (!this.innerPagination) return "total, prev, pager, next";
355
+ const full = "total, sizes, prev, pager, next, jumper";
356
+ if (this.innerPagination.total > this.paginationMinPageSize) return full;
357
+ return "total, prev, pager, next";
358
+ },
341
359
  exportQuerys() {
342
360
  return this.filters && typeof this.filters === "object" ? this.filters : {};
343
361
  },