@monoui/vuejs 1.1.19 → 1.1.20
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/dist/main.js +8 -8
- package/package.json +1 -1
- package/src/components/Table/Table.vue +69 -31
package/package.json
CHANGED
|
@@ -417,6 +417,11 @@ export default {
|
|
|
417
417
|
type: String,
|
|
418
418
|
required: false,
|
|
419
419
|
default: ""
|
|
420
|
+
},
|
|
421
|
+
perPage: {
|
|
422
|
+
type: Number,
|
|
423
|
+
required: false,
|
|
424
|
+
default: 10
|
|
420
425
|
}
|
|
421
426
|
},
|
|
422
427
|
watch: {
|
|
@@ -426,12 +431,6 @@ export default {
|
|
|
426
431
|
},
|
|
427
432
|
data() {
|
|
428
433
|
return {
|
|
429
|
-
defaultSettings: {
|
|
430
|
-
currentPage: 1,
|
|
431
|
-
pageCount: 0,
|
|
432
|
-
itemPerPage: 10,
|
|
433
|
-
totalItemCount: 0
|
|
434
|
-
},
|
|
435
434
|
settings: {
|
|
436
435
|
currentPage: 1,
|
|
437
436
|
pageCount: 0,
|
|
@@ -443,7 +442,8 @@ export default {
|
|
|
443
442
|
isDataEmpty: false,
|
|
444
443
|
isLoading: false,
|
|
445
444
|
limit: 250,
|
|
446
|
-
searchDebounceTimeout: null
|
|
445
|
+
searchDebounceTimeout: null,
|
|
446
|
+
initialSorting: []
|
|
447
447
|
};
|
|
448
448
|
},
|
|
449
449
|
computed: {
|
|
@@ -470,6 +470,7 @@ export default {
|
|
|
470
470
|
this.addPopStateListener();
|
|
471
471
|
},
|
|
472
472
|
async mounted() {
|
|
473
|
+
this.initialSorting = [...this.sorting];
|
|
473
474
|
this.loadHistory();
|
|
474
475
|
if (this.autoLoad) await this.getValues();
|
|
475
476
|
},
|
|
@@ -487,23 +488,20 @@ export default {
|
|
|
487
488
|
loadHistory() {
|
|
488
489
|
this.settings.currentPage = this.getHistoryParameter(
|
|
489
490
|
"page",
|
|
490
|
-
this.
|
|
491
|
+
this.settings.currentPage
|
|
491
492
|
);
|
|
492
493
|
this.settings.itemPerPage = this.getHistoryParameter(
|
|
493
494
|
"limit",
|
|
494
|
-
this.
|
|
495
|
+
this.perPage || this.settings.itemPerPage
|
|
495
496
|
);
|
|
496
497
|
if (this.searchColumn) {
|
|
497
498
|
this.searchWord = this.getHistoryParameter(
|
|
498
499
|
`f-${this.searchColumn}`,
|
|
499
|
-
|
|
500
|
+
""
|
|
500
501
|
);
|
|
501
502
|
}
|
|
502
503
|
this.loadHistoryFilters();
|
|
503
504
|
this.loadHistorySorting();
|
|
504
|
-
// console.log("loadHistory:settings", this.settings);
|
|
505
|
-
// console.log("loadHistory:filters", this.filters);
|
|
506
|
-
// console.log("loadHistory:sorting", this.sorting);
|
|
507
505
|
},
|
|
508
506
|
sortableIcon(column) {
|
|
509
507
|
const currentSort = this.sorting.find(x => x.Column === column);
|
|
@@ -555,7 +553,7 @@ export default {
|
|
|
555
553
|
row
|
|
556
554
|
);
|
|
557
555
|
},
|
|
558
|
-
async getValues() {
|
|
556
|
+
async getValues(addHistory = true) {
|
|
559
557
|
this.isLoading = true;
|
|
560
558
|
this.$emit("loading", this.isLoading);
|
|
561
559
|
const { currentPage, itemPerPage } = this.settings;
|
|
@@ -567,14 +565,30 @@ export default {
|
|
|
567
565
|
itemPerPage
|
|
568
566
|
);
|
|
569
567
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
this.
|
|
573
|
-
|
|
568
|
+
if (addHistory) {
|
|
569
|
+
let state = null;
|
|
570
|
+
this.clearHistoryParameters("f-");
|
|
571
|
+
for (const filter of this.filters) {
|
|
572
|
+
state = this.addHistoryParameter(
|
|
573
|
+
`f-${filter.Column}`,
|
|
574
|
+
filter.Value,
|
|
575
|
+
this.storage,
|
|
576
|
+
state,
|
|
577
|
+
false
|
|
578
|
+
);
|
|
579
|
+
}
|
|
574
580
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
581
|
+
this.clearHistoryParameters("s-");
|
|
582
|
+
for (const sort of this.sorting) {
|
|
583
|
+
state = this.addHistoryParameter(
|
|
584
|
+
`s-${sort.Column}`,
|
|
585
|
+
sort.Asc ? 1 : 0,
|
|
586
|
+
this.storage,
|
|
587
|
+
state,
|
|
588
|
+
false
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
this.replaceHistory(state);
|
|
578
592
|
}
|
|
579
593
|
|
|
580
594
|
if (!result || result.status !== 200) {
|
|
@@ -623,7 +637,7 @@ export default {
|
|
|
623
637
|
changePage(page) {
|
|
624
638
|
this.settings.currentPage = page;
|
|
625
639
|
this.addHistoryParameter("page", page);
|
|
626
|
-
this.getValues();
|
|
640
|
+
this.getValues(false);
|
|
627
641
|
},
|
|
628
642
|
changeItemPerPage(value) {
|
|
629
643
|
this.settings.itemPerPage = value;
|
|
@@ -659,12 +673,14 @@ export default {
|
|
|
659
673
|
return;
|
|
660
674
|
}
|
|
661
675
|
|
|
662
|
-
if (filter)
|
|
663
|
-
|
|
676
|
+
if (filter) {
|
|
677
|
+
filter.Value = value;
|
|
678
|
+
} else {
|
|
664
679
|
this.filters.push({
|
|
665
680
|
Column: column,
|
|
666
681
|
Value: value
|
|
667
682
|
});
|
|
683
|
+
}
|
|
668
684
|
this.getValues();
|
|
669
685
|
},
|
|
670
686
|
inLimit() {
|
|
@@ -680,7 +696,6 @@ export default {
|
|
|
680
696
|
storage = this.historyStorage
|
|
681
697
|
) {
|
|
682
698
|
if (!startsWith || !storage) return;
|
|
683
|
-
|
|
684
699
|
try {
|
|
685
700
|
const startsWithName = this.getHistoryName(startsWith);
|
|
686
701
|
|
|
@@ -841,6 +856,7 @@ export default {
|
|
|
841
856
|
}
|
|
842
857
|
},
|
|
843
858
|
loadHistorySorting() {
|
|
859
|
+
const latestSorting = [...this.initialSorting];
|
|
844
860
|
const parameters = this.getHistoryParameters("s-");
|
|
845
861
|
const trimName = this.getHistoryName("s-");
|
|
846
862
|
const names = Object.keys(parameters);
|
|
@@ -851,26 +867,48 @@ export default {
|
|
|
851
867
|
else if (paramValue && paramValue === "0") value = false;
|
|
852
868
|
const column = paramName.replace(trimName, "");
|
|
853
869
|
|
|
854
|
-
let sort =
|
|
870
|
+
let sort = latestSorting.find(x => x.Column === column);
|
|
855
871
|
|
|
856
872
|
if (value !== undefined) {
|
|
857
873
|
if (sort) {
|
|
858
874
|
sort.Value = value;
|
|
859
875
|
} else {
|
|
860
|
-
|
|
876
|
+
latestSorting.push({ Column: column, Asc: value });
|
|
861
877
|
}
|
|
862
878
|
}
|
|
863
879
|
}
|
|
880
|
+
this.sorting.length = 0;
|
|
881
|
+
for (const sort of latestSorting) {
|
|
882
|
+
this.sorting.push(sort);
|
|
883
|
+
}
|
|
864
884
|
},
|
|
865
|
-
|
|
885
|
+
replaceHistory(state, storage = this.historyStorage) {
|
|
886
|
+
if (!state) return;
|
|
887
|
+
if (storage === "query") {
|
|
888
|
+
window.history.pushState({ url: state.href }, "", state);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
addHistoryParameter(
|
|
893
|
+
name,
|
|
894
|
+
value,
|
|
895
|
+
storage = this.historyStorage,
|
|
896
|
+
state = null,
|
|
897
|
+
replace = true
|
|
898
|
+
) {
|
|
866
899
|
if (!this.history || !name || !storage) return;
|
|
867
|
-
// console.log("addHistoryParameter", name, value, storage);
|
|
868
900
|
try {
|
|
869
901
|
if (storage === "query") {
|
|
870
|
-
|
|
902
|
+
let url;
|
|
903
|
+
if (state) url = state;
|
|
904
|
+
else url = new URL(window.location);
|
|
871
905
|
const historyName = this.getHistoryName(name);
|
|
872
906
|
url.searchParams.set(historyName, value);
|
|
873
|
-
|
|
907
|
+
if (!replace) {
|
|
908
|
+
state = url;
|
|
909
|
+
return state;
|
|
910
|
+
}
|
|
911
|
+
window.history.pushState({ url: url.href }, "", url.href);
|
|
874
912
|
return;
|
|
875
913
|
}
|
|
876
914
|
|