Merge pull request #174 from dderbentsov/UC-98
WIP Исправила переключение страниц
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
clients-table-hat(
|
clients-table-hat(
|
||||||
:is-open-actions="marked.length",
|
:is-open-actions="marked.length",
|
||||||
:open-form="openForm",
|
:open-form="openForm",
|
||||||
|
:clearing-text-search="clearingTextSearch",
|
||||||
|
:change-clearing-text-search="changeClearingTextSearch",
|
||||||
@search="filterDataClients",
|
@search="filterDataClients",
|
||||||
)
|
)
|
||||||
.flex.flex-col.h-full.gap-y-2.table-container.w-full.mt-8.mb-3
|
.flex.flex-col.h-full.gap-y-2.table-container.w-full.mt-8.mb-3
|
||||||
@@ -75,7 +77,8 @@ export default {
|
|||||||
dataClients: [],
|
dataClients: [],
|
||||||
currentTablePage: 1,
|
currentTablePage: 1,
|
||||||
limit: 14,
|
limit: 14,
|
||||||
count: 0,
|
clientsCount: 0,
|
||||||
|
filteredClientsCount: 0,
|
||||||
textSearch: "",
|
textSearch: "",
|
||||||
paginationInfo: {
|
paginationInfo: {
|
||||||
currentPage: 0,
|
currentPage: 0,
|
||||||
@@ -84,15 +87,13 @@ export default {
|
|||||||
showModal: false,
|
showModal: false,
|
||||||
deletedClientId: "",
|
deletedClientId: "",
|
||||||
deletedRowId: "",
|
deletedRowId: "",
|
||||||
|
clearingTextSearch: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
pageCount() {
|
|
||||||
return Math.ceil(this.count / this.limit);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
updateDataClient() {
|
updateDataClient() {
|
||||||
|
if (this.textSearch) this.filteredClientsCount -= 1;
|
||||||
|
else this.clientsCount -= 1;
|
||||||
if (this.dataClients.find(({ id }) => id === this.deletedRowId)) {
|
if (this.dataClients.find(({ id }) => id === this.deletedRowId)) {
|
||||||
if (this.dataClients.length === 1) this.currentTablePage -= 1;
|
if (this.dataClients.length === 1) this.currentTablePage -= 1;
|
||||||
else this.fetchDataClients();
|
else this.fetchDataClients();
|
||||||
@@ -100,11 +101,18 @@ export default {
|
|||||||
},
|
},
|
||||||
saveDataClients(data) {
|
saveDataClients(data) {
|
||||||
this.dataClients = data.results;
|
this.dataClients = data.results;
|
||||||
this.count = data.count;
|
},
|
||||||
|
saveClientsCount(data) {
|
||||||
|
if (!this.clientsCount) this.clientsCount = data.count;
|
||||||
|
},
|
||||||
|
saveFilteredClientsCount(data) {
|
||||||
|
if (!this.filteredClientsCoun) this.filteredClientsCount = data.count;
|
||||||
},
|
},
|
||||||
filterDataClients(text) {
|
filterDataClients(text) {
|
||||||
if (text) this.textSearch = text;
|
if (text) {
|
||||||
else this.textSearch = "";
|
this.textSearch = text;
|
||||||
|
this.filteredClientsCount = 0;
|
||||||
|
} else this.textSearch = "";
|
||||||
if (this.currentTablePage !== 1) this.currentTablePage = 1;
|
if (this.currentTablePage !== 1) this.currentTablePage = 1;
|
||||||
else {
|
else {
|
||||||
this.fetchDataClients();
|
this.fetchDataClients();
|
||||||
@@ -118,18 +126,28 @@ export default {
|
|||||||
this.limit
|
this.limit
|
||||||
}&offset=${(this.currentTablePage - 1) * this.limit}`
|
}&offset=${(this.currentTablePage - 1) * this.limit}`
|
||||||
);
|
);
|
||||||
|
this.saveDataClients(response);
|
||||||
|
this.saveFilteredClientsCount(response);
|
||||||
|
this.paginationInfo = {
|
||||||
|
currentPage: this.currentTablePage,
|
||||||
|
length: this.calculatePageCount(this.filteredClientsCount),
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
response = await fetchWrapper.get(
|
response = await fetchWrapper.get(
|
||||||
`general/person/?limit=${this.limit}&offset=${
|
`general/person/?limit=${this.limit}&offset=${
|
||||||
(this.currentTablePage - 1) * this.limit
|
(this.currentTablePage - 1) * this.limit
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
|
this.saveDataClients(response);
|
||||||
|
this.saveClientsCount(response);
|
||||||
|
this.paginationInfo = {
|
||||||
|
currentPage: this.currentTablePage,
|
||||||
|
length: this.calculatePageCount(this.clientsCount),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
this.saveDataClients(response);
|
},
|
||||||
this.paginationInfo = {
|
calculatePageCount(count) {
|
||||||
currentPage: this.currentTablePage,
|
return Math.ceil(count / this.limit);
|
||||||
length: this.pageCount,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
selectedCheck(e) {
|
selectedCheck(e) {
|
||||||
if (e.target.id === "checkbox") {
|
if (e.target.id === "checkbox") {
|
||||||
@@ -178,14 +196,17 @@ export default {
|
|||||||
clearDeletedClientId() {
|
clearDeletedClientId() {
|
||||||
this.deletedClientId = "";
|
this.deletedClientId = "";
|
||||||
},
|
},
|
||||||
|
changeClearingTextSearch() {
|
||||||
|
this.clearingTextSearch = false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
updatedClients() {
|
updatedClients() {
|
||||||
if (this.updatedClients === true) {
|
if (this.updatedClients === true) {
|
||||||
this.textSearch = "";
|
this.textSearch = "";
|
||||||
this.fetchDataClients().then(
|
this.clearingTextSearch = true;
|
||||||
() => (this.currentTablePage = this.pageCount)
|
this.clientsCount += 1;
|
||||||
);
|
this.currentTablePage = this.calculatePageCount(this.clientsCount);
|
||||||
this.$emit("reset-updated-clients");
|
this.$emit("reset-updated-clients");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
openForm: Function,
|
openForm: Function,
|
||||||
isOpenActions: Number,
|
isOpenActions: Number,
|
||||||
|
clearingTextSearch: Boolean,
|
||||||
|
changeClearingTextSearch: Function,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -57,9 +59,15 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
searchClient() {
|
searchClient() {
|
||||||
if (!this.searchClient) {
|
if (!this.searchClient && !this.clearingTextSearch) {
|
||||||
this.$emit("search");
|
this.$emit("search");
|
||||||
}
|
}
|
||||||
|
if (this.clearingTextSearch) this.changeClearingTextSearch();
|
||||||
|
},
|
||||||
|
clearingTextSearch() {
|
||||||
|
if (this.clearingTextSearch) {
|
||||||
|
this.searchClient = "";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export default {
|
|||||||
this.timer = null;
|
this.timer = null;
|
||||||
},
|
},
|
||||||
startTimer() {
|
startTimer() {
|
||||||
this.countdown = 30;
|
this.countdown = 10;
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
this.changeCountdown();
|
this.changeCountdown();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|||||||
Reference in New Issue
Block a user