WIP Изменены уведомления
This commit is contained in:
@@ -30,18 +30,20 @@ export default {
|
||||
type: Number,
|
||||
default: 7,
|
||||
},
|
||||
paginationInfo: Object,
|
||||
},
|
||||
computed: {
|
||||
pageCount() {
|
||||
let countArray = [];
|
||||
for (let i = 1; i <= this.length; i++) {
|
||||
for (let i = 1; i <= this.paginationInfo.length; i++) {
|
||||
countArray.push(i);
|
||||
}
|
||||
if (this.length <= this.totalVisible) return countArray;
|
||||
if (this.paginationInfo.length <= this.totalVisible) return countArray;
|
||||
let incompleteCountArray = [];
|
||||
if (
|
||||
this.currentPage <= 2 ||
|
||||
this.currentPage >= countArray[this.length - 2]
|
||||
this.paginationInfo.currentPage <= 2 ||
|
||||
this.paginationInfo.currentPage >=
|
||||
countArray[this.paginationInfo.length - 2]
|
||||
) {
|
||||
countArray.forEach((elem, index, arr) => {
|
||||
if (index <= 2 || index >= arr.length - 3)
|
||||
@@ -51,7 +53,7 @@ export default {
|
||||
});
|
||||
return incompleteCountArray;
|
||||
}
|
||||
if (this.currentPage <= 4) {
|
||||
if (this.paginationInfo.currentPage <= 4) {
|
||||
countArray.forEach((elem, index, arr) => {
|
||||
if (index <= 4 || index === arr.length - 1)
|
||||
incompleteCountArray.push(elem);
|
||||
@@ -60,7 +62,10 @@ export default {
|
||||
});
|
||||
return incompleteCountArray;
|
||||
}
|
||||
if (this.currentPage >= countArray[this.length - 4]) {
|
||||
if (
|
||||
this.paginationInfo.currentPage >=
|
||||
countArray[this.paginationInfo.length - 4]
|
||||
) {
|
||||
countArray.forEach((elem, index, arr) => {
|
||||
if (index === 0 || index >= arr.length - 5)
|
||||
incompleteCountArray.push(elem);
|
||||
@@ -71,22 +76,25 @@ export default {
|
||||
}
|
||||
countArray.forEach((elem, index, arr) => {
|
||||
if (index === 0) incompleteCountArray.push(elem, "...");
|
||||
if (index >= this.currentPage - 2 && index <= this.currentPage)
|
||||
if (
|
||||
index >= this.paginationInfo.currentPage - 2 &&
|
||||
index <= this.paginationInfo.currentPage
|
||||
)
|
||||
incompleteCountArray.push(elem);
|
||||
if (index === arr.length - 1) incompleteCountArray.push("...", elem);
|
||||
});
|
||||
return incompleteCountArray;
|
||||
},
|
||||
disabledNextButton() {
|
||||
return this.currentPage === this.length;
|
||||
return this.paginationInfo.currentPage === this.paginationInfo.length;
|
||||
},
|
||||
disabledPreviousButton() {
|
||||
return this.currentPage === 1;
|
||||
return this.paginationInfo.currentPage === 1;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
currentPageStyle(number) {
|
||||
if (number === this.currentPage)
|
||||
if (number === this.paginationInfo.currentPage)
|
||||
return {
|
||||
"active-theme": true,
|
||||
};
|
||||
@@ -95,10 +103,11 @@ export default {
|
||||
};
|
||||
},
|
||||
previousHandler() {
|
||||
if (this.currentPage !== 1) this.$emit("previous-page");
|
||||
if (this.paginationInfo.currentPage !== 1) this.$emit("previous-page");
|
||||
},
|
||||
nextHandler() {
|
||||
if (this.currentPage !== this.length) this.$emit("next-page");
|
||||
if (this.paginationInfo.currentPage !== this.paginationInfo.length)
|
||||
this.$emit("next-page");
|
||||
},
|
||||
changeCurrentPage(e) {
|
||||
this.$emit("set-current-page", parseInt(e.target.id));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
.button.keep-redaction.flex.gap-x-3
|
||||
.icon-star-off.icon
|
||||
span На ведение
|
||||
.button.delete.flex.gap-x-3
|
||||
.button.delete.flex.gap-x-3(@click="deleteClient")
|
||||
.icon-basket.icon-delete
|
||||
span Удалить
|
||||
</template>
|
||||
@@ -18,6 +18,7 @@ export default {
|
||||
name: "ClientsActionPopup",
|
||||
props: {
|
||||
openChangeData: Function,
|
||||
deleteClient: Function,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
:check="selectedCheck",
|
||||
:client="client",
|
||||
:fetch-data-clients="fetchDataClients",
|
||||
:current-year="currentYear"
|
||||
:current-year="currentYear",
|
||||
@update-clients="updateDataClient"
|
||||
)
|
||||
client-table-pagination(
|
||||
v-if="pageCount > 1"
|
||||
:length="pageCount",
|
||||
:current-page="currentTablePage",
|
||||
v-if="paginationInfo.length > 1"
|
||||
:pagination-info="paginationInfo"
|
||||
@previous-page="switchPreviousPage",
|
||||
@next-page="switchNextPage",
|
||||
@set-current-page="changeCurrentTablePage"
|
||||
@@ -62,6 +62,10 @@ export default {
|
||||
limit: 4,
|
||||
count: 0,
|
||||
textSearch: "",
|
||||
paginationInfo: {
|
||||
currentPage: 0,
|
||||
length: 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -70,6 +74,10 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
updateDataClient() {
|
||||
if (this.dataClients.length === 1) this.currentTablePage -= 1;
|
||||
else this.fetchDataClients();
|
||||
},
|
||||
saveDataClients(data) {
|
||||
this.dataClients = data.results;
|
||||
this.count = data.count;
|
||||
@@ -98,6 +106,10 @@ export default {
|
||||
);
|
||||
}
|
||||
this.saveDataClients(response);
|
||||
this.paginationInfo = {
|
||||
currentPage: this.currentTablePage,
|
||||
length: this.pageCount,
|
||||
};
|
||||
},
|
||||
selectedCheck(e) {
|
||||
if (e.target.id === "checkbox") {
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
clients-action-popup(
|
||||
v-if="isOpenPopup",
|
||||
:open-change-data="openChangeData"
|
||||
:delete-client="deleteClient"
|
||||
)
|
||||
client-detail-info-wrapper(
|
||||
v-if="isOpenDetailInfo"
|
||||
@@ -270,6 +271,11 @@ export default {
|
||||
openChangeData() {
|
||||
this.isOpenChange = true;
|
||||
},
|
||||
async deleteClient() {
|
||||
await fetchWrapper.del(`general/person/${this.dataClient.id}/delete/`);
|
||||
this.handleUnFocusPopup();
|
||||
this.$emit("update-clients");
|
||||
},
|
||||
fetchClientDetail(id) {
|
||||
fetchWrapper
|
||||
.get(`general/person/${id}/detail/`)
|
||||
|
||||
Reference in New Issue
Block a user