wkjp-list-page 1.0.22 → 1.0.23

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
@@ -89,7 +89,7 @@ deviceListApi(params) {
89
89
  **情况:** 运营想自定义表头、列太多想藏起来。
90
90
  **默认:** **`columns` 达到 10 列及以上**(可用 **`column-config-auto-min`** 改阈值)时,表格最右侧自动出现 **表头设置** 齿轮;悬停齿轮显示 **「配置字段」** 提示(可用 **`column-config-tooltip`** 修改)。
91
91
  **可选:** `:enable-column-config="true"` 强制开启;`:enable-column-config="false"` 强制关闭。
92
- **作用:** 弹层内可 **搜索字段**、**显示/未显示** 分组、开关显隐、拖拽排序;**复选框列(`type: selection`)不出现在设置里**且表格始终保留;**固定列**左侧显示「固定」且不可拖不可关。点 **确认** 后才会作用到表格并触发 **`columns-change`**,点 **取消** / 关闭 / 再次点齿轮则放弃本次修改。
92
+ **作用:** 弹层内可 **搜索字段**、**显示/未显示** 分组、开关显隐、拖拽排序;**复选框列(`type: selection`)不出现在设置里**且表格始终保留;列上 **`showInColumnConfig: false`** 可排除在表头设置外(表格仍显示该列);**固定列**左侧显示「固定」且不可拖不可关。点 **确认** 后才会作用到表格并触发 **`columns-change`**,点 **取消** / 关闭 / 再次点齿轮则放弃本次修改。
93
93
 
94
94
  ### 2.2 不想要「查询」按钮,或想改按钮上的字
95
95
 
@@ -344,6 +344,8 @@ deviceListTransformList(list) {
344
344
  | `emptyText` / `defaultText` | 空值时显示文案;**`emptyText` 优先**;都不设则用 **`cell-empty-text`**(默认 `--`)。 |
345
345
  | `width` / `minWidth` | 显式指定后不再自动算宽;仍可配合上面的 tooltip 规则。 |
346
346
  | `showOverflowTooltip` | 显式 `true` / `false` 时优先于自动规则。 |
347
+ | `showInColumnConfig` | 是否出现在 **表头设置** 弹层,默认 **`true`**;为 **`false`** 时不出现在设置里(不可被用户隐藏),表格仍渲染。兼容 **`columnConfigShow`**。 |
348
+ | `configFixed` | 在表头设置中视为固定列,不可拖、不可关(常与 `fixed` 联用)。 |
347
349
 
348
350
  ---
349
351
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wkjp-list-page",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "Vue2 + ElementUI CommonListPage component",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -368,9 +368,14 @@ export default {
368
368
  showQueryButton: { type: Boolean, default: true },
369
369
  /** 主查询按钮文案 */
370
370
  queryButtonText: { type: String, default: "查询" },
371
- /** 是否显示「清除查询」按钮(在查询按钮右侧):将 `filters` 恢复为进入页面时的快照并重新查询 */
371
+ /** 是否显示「重置」按钮(在查询按钮右侧):将 `filters` 恢复为进入页面时的快照 */
372
372
  showClearQueryButton: { type: Boolean, default: true },
373
- clearQueryButtonText: { type: String, default: "清除查询" },
373
+ clearQueryButtonText: { type: String, default: "重置" },
374
+ /**
375
+ * 点击「重置」后是否自动 `fetchList`。默认 **true**:恢复查询条件后重新拉表。
376
+ * 带「请选择…再查询」等前置校验的页面请设为 **false**,仅重置条件不请求。
377
+ */
378
+ fetchOnClearQuery: { type: Boolean, default: true },
374
379
  /**
375
380
  * 搜索区折叠:显式 `true` / `false` 强制开/关;
376
381
  * 未传时 **`searchOption` 超过 `searchVisibleMax`(默认 6)** 自动显示「展开查询」。
@@ -440,7 +445,7 @@ export default {
440
445
  columnConfigPanelMaxHeight: null,
441
446
  configColumns: [],
442
447
  appliedColumns: [],
443
- /** 进入页时 filters 的快照,用于「清除查询」 */
448
+ /** 进入页时 filters 的快照,用于「重置」 */
444
449
  initialFiltersSnapshot: null,
445
450
  initialFiltersCaptured: false
446
451
  };
@@ -654,9 +659,12 @@ export default {
654
659
  isBuiltinCellColumn(col) {
655
660
  return col && ["selection", "index", "expand"].indexOf(col.type) !== -1;
656
661
  },
657
- /** 复选框列不参与表头设置 */
662
+ /** 复选框、展开列及 showInColumnConfig:false 不参与表头设置 */
658
663
  isConfigPanelColumn(col) {
659
- return col && col.type !== "selection";
664
+ if (!col) return false;
665
+ if (col.type === "selection" || col.type === "expand") return false;
666
+ if (col.showInColumnConfig === false) return false;
667
+ return true;
660
668
  },
661
669
  textDisplayLength(text) {
662
670
  return String(text == null ? "" : text).length;
@@ -732,7 +740,11 @@ export default {
732
740
  captureInitialFilters() {
733
741
  if (this.initialFiltersCaptured || !this.filters) return;
734
742
  try {
735
- this.initialFiltersSnapshot = JSON.parse(JSON.stringify(this.filters));
743
+ const snap = {};
744
+ Object.keys(this.filters).forEach((key) => {
745
+ snap[key] = this.cloneFilterValue(this.filters[key]);
746
+ });
747
+ this.initialFiltersSnapshot = snap;
736
748
  this.initialFiltersCaptured = true;
737
749
  } catch (e) {
738
750
  this.initialFiltersSnapshot = null;
@@ -751,14 +763,34 @@ export default {
751
763
  const snap = this.initialFiltersSnapshot;
752
764
  const f = this.filters;
753
765
  if (!snap || !f) return;
754
- Object.keys(snap).forEach((key) => {
755
- this.$set(f, key, this.cloneFilterValue(snap[key]));
766
+ Object.keys(f).forEach((key) => {
767
+ const val = Object.prototype.hasOwnProperty.call(snap, key)
768
+ ? snap[key]
769
+ : undefined;
770
+ this.$set(f, key, this.cloneFilterValue(val));
771
+ });
772
+ },
773
+ resetListWithoutFetch() {
774
+ this.innerPagination.page = 1;
775
+ this.innerTableData = [];
776
+ this.innerPagination.total = 0;
777
+ this.syncPaginationToFilters();
778
+ this.$emit("fetched", {
779
+ list: [],
780
+ total: 0,
781
+ page: this.innerPagination.page,
782
+ pageSize: this.innerPagination.pageSize,
783
+ raw: null,
756
784
  });
757
785
  },
758
786
  handleClearQueryClick() {
759
787
  this.applyInitialFiltersSnapshot();
760
- this.fetchList({ resetPage: true });
761
788
  this.$emit("clear-query");
789
+ if (this.fetchOnClearQuery) {
790
+ this.fetchList({ resetPage: true });
791
+ } else {
792
+ this.resetListWithoutFetch();
793
+ }
762
794
  },
763
795
  resolveValue(item) {
764
796
  if (Object.prototype.hasOwnProperty.call(item, "value")) return item.value;