zzz-pc-view 0.0.164 → 0.0.166
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 +1 -1
- package/src/decorators/CurdKey/index.d.ts +8 -0
- package/src/index.es.js +63 -25
- package/src/index.umd.js +2 -2
- package/src/utils/reduce/sort.d.ts +8 -0
- package/src/zzz-frame.css +1 -1
package/package.json
CHANGED
|
@@ -450,6 +450,14 @@ export declare abstract class CurdHandler<T extends object = object, P extends P
|
|
|
450
450
|
* 最后,它会将解析后的对象绑定到 FilterTarget 上,并将结果赋值给 searchQueryRef。
|
|
451
451
|
*/
|
|
452
452
|
protected setSearchQuery(): void;
|
|
453
|
+
protected readonly sortInfoRef: import('vue').ShallowRef<{
|
|
454
|
+
prop: keyof T;
|
|
455
|
+
order: 1 | -1;
|
|
456
|
+
} | undefined, {
|
|
457
|
+
prop: keyof T;
|
|
458
|
+
order: 1 | -1;
|
|
459
|
+
} | undefined>;
|
|
460
|
+
setSortInfo(prop: keyof T, order: 1 | -1): void;
|
|
453
461
|
/**
|
|
454
462
|
* 创建一个浅引用,用于存储列表数据。
|
|
455
463
|
* 这个引用将用于在组件中存储和更新列表数据。
|
package/src/index.es.js
CHANGED
|
@@ -1544,6 +1544,26 @@ const sort = (list2, sortKey) => {
|
|
|
1544
1544
|
return 0;
|
|
1545
1545
|
});
|
|
1546
1546
|
};
|
|
1547
|
+
const sortByField = (arr, field, order = 1, nullLast = true) => {
|
|
1548
|
+
const list2 = [...arr];
|
|
1549
|
+
list2.sort((a, b) => {
|
|
1550
|
+
const valA = a[field];
|
|
1551
|
+
const valB = b[field];
|
|
1552
|
+
const isANull = valA === null || valA === void 0;
|
|
1553
|
+
const isBNull = valB === null || valB === void 0;
|
|
1554
|
+
if (isANull && isBNull) return 0;
|
|
1555
|
+
if (isANull) return nullLast ? 1 : -1;
|
|
1556
|
+
if (isBNull) return nullLast ? -1 : 1;
|
|
1557
|
+
if (typeof valA === "number" && typeof valB === "number") {
|
|
1558
|
+
return order * (valA - valB);
|
|
1559
|
+
}
|
|
1560
|
+
const strA = String(valA).trim();
|
|
1561
|
+
const strB = String(valB).trim();
|
|
1562
|
+
const compareRes = strA.localeCompare(strB, void 0, { numeric: true });
|
|
1563
|
+
return order * compareRes;
|
|
1564
|
+
});
|
|
1565
|
+
return list2;
|
|
1566
|
+
};
|
|
1547
1567
|
const create$1 = (option) => {
|
|
1548
1568
|
const rootNodes = [];
|
|
1549
1569
|
const buildMap = {};
|
|
@@ -1720,6 +1740,7 @@ const index$g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
1720
1740
|
ratioByHorizontal,
|
|
1721
1741
|
ratioByVertical,
|
|
1722
1742
|
sort,
|
|
1743
|
+
sortByField,
|
|
1723
1744
|
sumGroupByHorizontal,
|
|
1724
1745
|
sumGroupByVertical,
|
|
1725
1746
|
toKeyValue,
|
|
@@ -5639,6 +5660,7 @@ class CurdHandler extends FilterHandler {
|
|
|
5639
5660
|
* @description 这对于性能优化很重要,因为它避免了不必要的更新。
|
|
5640
5661
|
*/
|
|
5641
5662
|
__publicField(this, "searchQueryRef", shallowRef());
|
|
5663
|
+
__publicField(this, "sortInfoRef", shallowRef());
|
|
5642
5664
|
/**
|
|
5643
5665
|
* 创建一个浅引用,用于存储列表数据。
|
|
5644
5666
|
* 这个引用将用于在组件中存储和更新列表数据。
|
|
@@ -5657,6 +5679,10 @@ class CurdHandler extends FilterHandler {
|
|
|
5657
5679
|
*/
|
|
5658
5680
|
__publicField(this, "displayListComputed", computed(() => {
|
|
5659
5681
|
let displayList = this.listRef.value;
|
|
5682
|
+
const sortInfo = this.sortInfoRef.value;
|
|
5683
|
+
if (sortInfo) {
|
|
5684
|
+
displayList = sortByField([...displayList], sortInfo.prop, sortInfo.order);
|
|
5685
|
+
}
|
|
5660
5686
|
const { pagination } = this;
|
|
5661
5687
|
if (!this.api.hasServerPagination && pagination) {
|
|
5662
5688
|
const { currentPage, pageSize } = pagination;
|
|
@@ -5964,6 +5990,9 @@ class CurdHandler extends FilterHandler {
|
|
|
5964
5990
|
}
|
|
5965
5991
|
this.searchQueryRef.value = searchQuery;
|
|
5966
5992
|
}
|
|
5993
|
+
setSortInfo(prop, order) {
|
|
5994
|
+
this.sortInfoRef.value = { prop, order };
|
|
5995
|
+
}
|
|
5967
5996
|
/**
|
|
5968
5997
|
* 获取当前显示的列表数据。
|
|
5969
5998
|
* 这个方法返回 displayListComputed 计算属性的值,它表示当前显示的列表数据。
|
|
@@ -12335,8 +12364,9 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
12335
12364
|
}
|
|
12336
12365
|
});
|
|
12337
12366
|
const _hoisted_1$a = { class: "flex column wrapper data-wrapper" };
|
|
12338
|
-
const _hoisted_2$7 = { class: "
|
|
12339
|
-
const _hoisted_3$5 = { class: "flex gap-10 data-wrapper-
|
|
12367
|
+
const _hoisted_2$7 = { class: "data-wrapper-header" };
|
|
12368
|
+
const _hoisted_3$5 = { class: "flex flex-wrap gap-10 data-wrapper-header-inner" };
|
|
12369
|
+
const _hoisted_4$5 = { class: "flex gap-10 data-wrapper-footer" };
|
|
12340
12370
|
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
12341
12371
|
__name: "DataWrapperView",
|
|
12342
12372
|
props: {
|
|
@@ -12347,7 +12377,9 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
12347
12377
|
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
12348
12378
|
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
12349
12379
|
createElementVNode("div", _hoisted_2$7, [
|
|
12350
|
-
|
|
12380
|
+
createElementVNode("div", _hoisted_3$5, [
|
|
12381
|
+
renderSlot(_ctx.$slots, "header")
|
|
12382
|
+
])
|
|
12351
12383
|
]),
|
|
12352
12384
|
createVNode(_component_el_scrollbar, {
|
|
12353
12385
|
"view-class": _ctx.bodyViewClass || "wrapper data-wrapper-body",
|
|
@@ -12358,7 +12390,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
12358
12390
|
]),
|
|
12359
12391
|
_: 3
|
|
12360
12392
|
}, 8, ["view-class"]),
|
|
12361
|
-
createElementVNode("div",
|
|
12393
|
+
createElementVNode("div", _hoisted_4$5, [
|
|
12362
12394
|
renderSlot(_ctx.$slots, "footer")
|
|
12363
12395
|
]),
|
|
12364
12396
|
renderSlot(_ctx.$slots, "extra")
|
|
@@ -12554,8 +12586,13 @@ const _hoisted_2$6 = {
|
|
|
12554
12586
|
key: 0,
|
|
12555
12587
|
class: "curd-list-aside"
|
|
12556
12588
|
};
|
|
12557
|
-
const _hoisted_3$4 = { class: "flex-1 fit-size
|
|
12558
|
-
const _hoisted_4$4 = {
|
|
12589
|
+
const _hoisted_3$4 = { class: "flex column flex-1 fit-size" };
|
|
12590
|
+
const _hoisted_4$4 = { class: "flex-1 fit-size curd-list-content" };
|
|
12591
|
+
const _hoisted_5$3 = {
|
|
12592
|
+
key: 0,
|
|
12593
|
+
class: "curd-list-pagination"
|
|
12594
|
+
};
|
|
12595
|
+
const _hoisted_6$2 = {
|
|
12559
12596
|
key: 1,
|
|
12560
12597
|
class: "curd-list-aside"
|
|
12561
12598
|
};
|
|
@@ -12568,8 +12605,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
12568
12605
|
const props = __props;
|
|
12569
12606
|
const { pagination } = props.viewHandler;
|
|
12570
12607
|
return (_ctx, _cache) => {
|
|
12571
|
-
const _component_el_card = resolveComponent("el-card");
|
|
12572
12608
|
const _component_el_pagination = resolveComponent("el-pagination");
|
|
12609
|
+
const _component_el_card = resolveComponent("el-card");
|
|
12573
12610
|
const _directive_loading = resolveDirective("loading");
|
|
12574
12611
|
return openBlock(), createBlock(_sfc_main$l, null, {
|
|
12575
12612
|
header: withCtx(() => [
|
|
@@ -12600,7 +12637,24 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
12600
12637
|
}, {
|
|
12601
12638
|
default: withCtx(() => [
|
|
12602
12639
|
createElementVNode("div", _hoisted_3$4, [
|
|
12603
|
-
|
|
12640
|
+
createElementVNode("div", _hoisted_4$4, [
|
|
12641
|
+
createVNode(_sfc_main$i, { "view-handler": _ctx.viewHandler }, null, 8, ["view-handler"])
|
|
12642
|
+
]),
|
|
12643
|
+
unref(pagination) ? (openBlock(), createElementBlock("div", _hoisted_5$3, [
|
|
12644
|
+
createVNode(_component_el_pagination, {
|
|
12645
|
+
"current-page": unref(pagination).currentPage,
|
|
12646
|
+
"onUpdate:currentPage": _cache[0] || (_cache[0] = ($event) => unref(pagination).currentPage = $event),
|
|
12647
|
+
"page-size": unref(pagination).pageSize,
|
|
12648
|
+
"onUpdate:pageSize": _cache[1] || (_cache[1] = ($event) => unref(pagination).pageSize = $event),
|
|
12649
|
+
"page-sizes": [10, 20, 30, 40, 50, 100],
|
|
12650
|
+
total: _ctx.viewHandler.total,
|
|
12651
|
+
disabled: _ctx.viewHandler.listLoadStatus,
|
|
12652
|
+
layout: "total, sizes, prev, pager, next",
|
|
12653
|
+
background: "",
|
|
12654
|
+
onCurrentChange: _ctx.viewHandler.onCurrentPageChange,
|
|
12655
|
+
onSizeChange: _ctx.viewHandler.onPageSizeChange
|
|
12656
|
+
}, null, 8, ["current-page", "page-size", "total", "disabled", "onCurrentChange", "onSizeChange"])
|
|
12657
|
+
])) : createCommentVNode("", true)
|
|
12604
12658
|
])
|
|
12605
12659
|
]),
|
|
12606
12660
|
_: 1
|
|
@@ -12608,7 +12662,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
12608
12662
|
[_directive_loading, _ctx.viewHandler.listLoadStatus]
|
|
12609
12663
|
])
|
|
12610
12664
|
]),
|
|
12611
|
-
_ctx.viewHandler.displayFilterConfigMap[unref(ZDecorators).FilterKey.PositionEnum.RIGHT] ? (openBlock(), createElementBlock("div",
|
|
12665
|
+
_ctx.viewHandler.displayFilterConfigMap[unref(ZDecorators).FilterKey.PositionEnum.RIGHT] ? (openBlock(), createElementBlock("div", _hoisted_6$2, [
|
|
12612
12666
|
createVNode(_sfc_main$m, {
|
|
12613
12667
|
"view-handler": _ctx.viewHandler,
|
|
12614
12668
|
position: unref(ZDecorators).FilterKey.PositionEnum.RIGHT,
|
|
@@ -12617,22 +12671,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
12617
12671
|
])) : createCommentVNode("", true)
|
|
12618
12672
|
])
|
|
12619
12673
|
]),
|
|
12620
|
-
footer: withCtx(() => [
|
|
12621
|
-
unref(pagination) ? (openBlock(), createBlock(_component_el_pagination, {
|
|
12622
|
-
key: 0,
|
|
12623
|
-
"current-page": unref(pagination).currentPage,
|
|
12624
|
-
"onUpdate:currentPage": _cache[0] || (_cache[0] = ($event) => unref(pagination).currentPage = $event),
|
|
12625
|
-
"page-size": unref(pagination).pageSize,
|
|
12626
|
-
"onUpdate:pageSize": _cache[1] || (_cache[1] = ($event) => unref(pagination).pageSize = $event),
|
|
12627
|
-
"page-sizes": [10, 20, 30, 40, 50, 100],
|
|
12628
|
-
total: _ctx.viewHandler.total,
|
|
12629
|
-
disabled: _ctx.viewHandler.listLoadStatus,
|
|
12630
|
-
layout: "total, sizes, prev, pager, next",
|
|
12631
|
-
background: "",
|
|
12632
|
-
onCurrentChange: _ctx.viewHandler.onCurrentPageChange,
|
|
12633
|
-
onSizeChange: _ctx.viewHandler.onPageSizeChange
|
|
12634
|
-
}, null, 8, ["current-page", "page-size", "total", "disabled", "onCurrentChange", "onSizeChange"])) : createCommentVNode("", true)
|
|
12635
|
-
]),
|
|
12636
12674
|
extra: withCtx(() => [
|
|
12637
12675
|
renderSlot(_ctx.$slots, "editor"),
|
|
12638
12676
|
renderSlot(_ctx.$slots, "extra")
|