wkjp-list-page 1.0.29 → 1.0.30
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/package.json
CHANGED
|
@@ -343,6 +343,12 @@ export default {
|
|
|
343
343
|
},
|
|
344
344
|
props: {
|
|
345
345
|
filters: { type: Object, required: true },
|
|
346
|
+
/**
|
|
347
|
+
* 重置基准:首次传入的默认查询条件(深拷贝后冻结,后续查询怎么改都不影响「重置」)。
|
|
348
|
+
* 建议传入页面 `data` 里单独保存的一份默认值对象(勿与 `filters` 共用同一引用)。
|
|
349
|
+
* 未传时:在实例首次初始化时对当时的 `filters` 做一次快照(`v-if` 反复挂载时仍会按每次挂载时的 filters 快照,多 tab 请务必传本项)。
|
|
350
|
+
*/
|
|
351
|
+
initialFilters: { type: Object, default: null },
|
|
346
352
|
searchOption: { type: Array, default: () => [] },
|
|
347
353
|
columns: { type: Array, default: () => [] },
|
|
348
354
|
/**
|
|
@@ -402,7 +408,7 @@ export default {
|
|
|
402
408
|
showQueryButton: { type: Boolean, default: true },
|
|
403
409
|
/** 主查询按钮文案 */
|
|
404
410
|
queryButtonText: { type: String, default: "查询" },
|
|
405
|
-
/** 是否显示「重置」按钮(在查询按钮右侧):将 `filters`
|
|
411
|
+
/** 是否显示「重置」按钮(在查询按钮右侧):将 `filters` 恢复为 `initialFilters`(或首次快照) */
|
|
406
412
|
showClearQueryButton: { type: Boolean, default: true },
|
|
407
413
|
clearQueryButtonText: { type: String, default: "重置" },
|
|
408
414
|
/**
|
|
@@ -479,9 +485,9 @@ export default {
|
|
|
479
485
|
columnConfigPanelMaxHeight: null,
|
|
480
486
|
configColumns: [],
|
|
481
487
|
appliedColumns: [],
|
|
482
|
-
/**
|
|
488
|
+
/** 重置基准快照(深拷贝后冻结,仅初始化时写入一次) */
|
|
483
489
|
initialFiltersSnapshot: null,
|
|
484
|
-
|
|
490
|
+
resetBaselineLocked: false
|
|
485
491
|
};
|
|
486
492
|
},
|
|
487
493
|
computed: {
|
|
@@ -677,10 +683,25 @@ export default {
|
|
|
677
683
|
this.innerPagination = Object.assign({}, this.innerPagination, v);
|
|
678
684
|
}
|
|
679
685
|
}
|
|
686
|
+
},
|
|
687
|
+
initialFilters: {
|
|
688
|
+
immediate: true,
|
|
689
|
+
handler(val) {
|
|
690
|
+
if (this.resetBaselineLocked) return;
|
|
691
|
+
if (val && typeof val === "object") {
|
|
692
|
+
this.lockResetBaseline(val);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
680
695
|
}
|
|
681
696
|
},
|
|
682
697
|
created() {
|
|
683
|
-
this.
|
|
698
|
+
if (!this.resetBaselineLocked) {
|
|
699
|
+
const baseline =
|
|
700
|
+
this.initialFilters && typeof this.initialFilters === "object"
|
|
701
|
+
? this.initialFilters
|
|
702
|
+
: this.filters;
|
|
703
|
+
this.lockResetBaseline(baseline);
|
|
704
|
+
}
|
|
684
705
|
this.applyInnerPaginationConfig();
|
|
685
706
|
if (this.fetchOnCreated) {
|
|
686
707
|
this.fetchList();
|
|
@@ -803,19 +824,43 @@ export default {
|
|
|
803
824
|
handleQueryClick() {
|
|
804
825
|
this.fetchList({ resetPage: true });
|
|
805
826
|
},
|
|
806
|
-
|
|
807
|
-
|
|
827
|
+
/**
|
|
828
|
+
* 将 baseline 深拷贝为重置基准,仅首次调用生效;之后 filters 怎么变都不更新快照。
|
|
829
|
+
* @param {Object} baseline 优先使用 `initialFilters`,否则为首次 `filters`
|
|
830
|
+
*/
|
|
831
|
+
lockResetBaseline(baseline) {
|
|
832
|
+
if (this.resetBaselineLocked || !this.filters) return;
|
|
833
|
+
if (!baseline || typeof baseline !== "object") return;
|
|
808
834
|
try {
|
|
809
835
|
const snap = {};
|
|
810
|
-
|
|
811
|
-
|
|
836
|
+
const keys = {};
|
|
837
|
+
Object.keys(this.filters).forEach(function (k) {
|
|
838
|
+
keys[k] = true;
|
|
839
|
+
});
|
|
840
|
+
Object.keys(baseline).forEach(function (k) {
|
|
841
|
+
keys[k] = true;
|
|
842
|
+
});
|
|
843
|
+
Object.keys(keys).forEach((key) => {
|
|
844
|
+
const val = Object.prototype.hasOwnProperty.call(baseline, key)
|
|
845
|
+
? baseline[key]
|
|
846
|
+
: this.filters[key];
|
|
847
|
+
snap[key] = this.cloneFilterValue(val);
|
|
812
848
|
});
|
|
813
849
|
this.initialFiltersSnapshot = snap;
|
|
814
|
-
this.
|
|
850
|
+
this.resetBaselineLocked = true;
|
|
815
851
|
} catch (e) {
|
|
816
852
|
this.initialFiltersSnapshot = null;
|
|
817
853
|
}
|
|
818
854
|
},
|
|
855
|
+
/** @deprecated 请使用 lockResetBaseline */
|
|
856
|
+
captureInitialFilters() {
|
|
857
|
+
if (this.resetBaselineLocked) return;
|
|
858
|
+
const baseline =
|
|
859
|
+
this.initialFilters && typeof this.initialFilters === "object"
|
|
860
|
+
? this.initialFilters
|
|
861
|
+
: this.filters;
|
|
862
|
+
this.lockResetBaseline(baseline);
|
|
863
|
+
},
|
|
819
864
|
cloneFilterValue(val) {
|
|
820
865
|
if (val === null || val === undefined) return val;
|
|
821
866
|
if (typeof val !== "object") return val;
|