@monoui/vuejs 1.1.18 → 1.1.21
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 +91 -43
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,33 @@ export default {
|
|
|
567
565
|
itemPerPage
|
|
568
566
|
);
|
|
569
567
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
568
|
+
if (addHistory) {
|
|
569
|
+
let state = null;
|
|
570
|
+
|
|
571
|
+
// clear all first
|
|
572
|
+
this.clearHistoryParameters("f-");
|
|
573
|
+
this.clearHistoryParameters("s-");
|
|
574
|
+
|
|
575
|
+
for (const filter of this.filters) {
|
|
576
|
+
state = this.addHistoryParameter(
|
|
577
|
+
`f-${filter.Column}`,
|
|
578
|
+
filter.Value,
|
|
579
|
+
this.storage,
|
|
580
|
+
state,
|
|
581
|
+
false
|
|
582
|
+
);
|
|
583
|
+
}
|
|
574
584
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
585
|
+
for (const sort of this.sorting) {
|
|
586
|
+
state = this.addHistoryParameter(
|
|
587
|
+
`s-${sort.Column}`,
|
|
588
|
+
sort.Asc ? 1 : 0,
|
|
589
|
+
this.storage,
|
|
590
|
+
state,
|
|
591
|
+
false
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
this.replaceHistory(state);
|
|
578
595
|
}
|
|
579
596
|
|
|
580
597
|
if (!result || result.status !== 200) {
|
|
@@ -623,12 +640,12 @@ export default {
|
|
|
623
640
|
changePage(page) {
|
|
624
641
|
this.settings.currentPage = page;
|
|
625
642
|
this.addHistoryParameter("page", page);
|
|
626
|
-
this.getValues();
|
|
643
|
+
this.getValues(false);
|
|
627
644
|
},
|
|
628
645
|
changeItemPerPage(value) {
|
|
629
646
|
this.settings.itemPerPage = value;
|
|
630
647
|
this.addHistoryParameter("limit", value);
|
|
631
|
-
this.getValues();
|
|
648
|
+
this.getValues(false);
|
|
632
649
|
},
|
|
633
650
|
isLessThanTotalItemCount(val) {
|
|
634
651
|
return this.settings.totalItemCount > val;
|
|
@@ -659,12 +676,14 @@ export default {
|
|
|
659
676
|
return;
|
|
660
677
|
}
|
|
661
678
|
|
|
662
|
-
if (filter)
|
|
663
|
-
|
|
679
|
+
if (filter) {
|
|
680
|
+
filter.Value = value;
|
|
681
|
+
} else {
|
|
664
682
|
this.filters.push({
|
|
665
683
|
Column: column,
|
|
666
684
|
Value: value
|
|
667
685
|
});
|
|
686
|
+
}
|
|
668
687
|
this.getValues();
|
|
669
688
|
},
|
|
670
689
|
inLimit() {
|
|
@@ -680,7 +699,6 @@ export default {
|
|
|
680
699
|
storage = this.historyStorage
|
|
681
700
|
) {
|
|
682
701
|
if (!startsWith || !storage) return;
|
|
683
|
-
|
|
684
702
|
try {
|
|
685
703
|
const startsWithName = this.getHistoryName(startsWith);
|
|
686
704
|
|
|
@@ -828,42 +846,72 @@ export default {
|
|
|
828
846
|
|
|
829
847
|
if (filter && !value) {
|
|
830
848
|
this.filters.splice(this.filters.indexOf(filter), 1);
|
|
831
|
-
} else if (
|
|
832
|
-
filter
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
849
|
+
} else if (value) {
|
|
850
|
+
if (filter) {
|
|
851
|
+
filter.Value = value;
|
|
852
|
+
} else {
|
|
853
|
+
this.filters.push({
|
|
854
|
+
Column: column,
|
|
855
|
+
Value: value
|
|
856
|
+
});
|
|
857
|
+
}
|
|
838
858
|
}
|
|
839
859
|
}
|
|
840
860
|
},
|
|
841
861
|
loadHistorySorting() {
|
|
862
|
+
const latestSorting = [...this.initialSorting];
|
|
842
863
|
const parameters = this.getHistoryParameters("s-");
|
|
843
864
|
const trimName = this.getHistoryName("s-");
|
|
844
865
|
const names = Object.keys(parameters);
|
|
845
866
|
for (const paramName of names) {
|
|
846
|
-
|
|
867
|
+
var paramValue = parameters[paramName];
|
|
868
|
+
let value = undefined;
|
|
869
|
+
if (paramValue && paramValue === "1") value = true;
|
|
870
|
+
else if (paramValue && paramValue === "0") value = false;
|
|
847
871
|
const column = paramName.replace(trimName, "");
|
|
848
872
|
|
|
849
|
-
let sort =
|
|
873
|
+
let sort = latestSorting.find(x => x.Column === column);
|
|
850
874
|
|
|
851
|
-
if (
|
|
852
|
-
sort
|
|
853
|
-
|
|
854
|
-
|
|
875
|
+
if (value !== undefined) {
|
|
876
|
+
if (sort) {
|
|
877
|
+
sort.Value = value;
|
|
878
|
+
} else {
|
|
879
|
+
latestSorting.push({ Column: column, Asc: value });
|
|
880
|
+
}
|
|
855
881
|
}
|
|
856
882
|
}
|
|
883
|
+
this.sorting.length = 0;
|
|
884
|
+
for (const sort of latestSorting) {
|
|
885
|
+
this.sorting.push(sort);
|
|
886
|
+
}
|
|
857
887
|
},
|
|
858
|
-
|
|
888
|
+
replaceHistory(state, storage = this.historyStorage) {
|
|
889
|
+
if (!state) return;
|
|
890
|
+
if (storage === "query") {
|
|
891
|
+
window.history.pushState({ url: state.href }, "", state);
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
addHistoryParameter(
|
|
896
|
+
name,
|
|
897
|
+
value,
|
|
898
|
+
storage = this.historyStorage,
|
|
899
|
+
state = null,
|
|
900
|
+
replace = true
|
|
901
|
+
) {
|
|
859
902
|
if (!this.history || !name || !storage) return;
|
|
860
|
-
// console.log("addHistoryParameter", name, value, storage);
|
|
861
903
|
try {
|
|
862
904
|
if (storage === "query") {
|
|
863
|
-
|
|
905
|
+
let url;
|
|
906
|
+
if (state) url = state;
|
|
907
|
+
else url = new URL(window.location);
|
|
864
908
|
const historyName = this.getHistoryName(name);
|
|
865
909
|
url.searchParams.set(historyName, value);
|
|
866
|
-
|
|
910
|
+
if (!replace) {
|
|
911
|
+
state = url;
|
|
912
|
+
return state;
|
|
913
|
+
}
|
|
914
|
+
window.history.pushState({ url: url.href }, "", url.href);
|
|
867
915
|
return;
|
|
868
916
|
}
|
|
869
917
|
|