Merge pull request #158 from dderbentsov/UC-64
WIP Настроила пагинацию с фильтрацией
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
:is-open-actions="marked.length",
|
:is-open-actions="marked.length",
|
||||||
:open-form="openForm",
|
:open-form="openForm",
|
||||||
@search="filterDataClients",
|
@search="filterDataClients",
|
||||||
@reset-search="fetchDataClients"
|
|
||||||
)
|
)
|
||||||
.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
|
||||||
clients-table-header(:check="selectedCheck" :is-check="selectAll")
|
clients-table-header(:check="selectedCheck" :is-check="selectAll")
|
||||||
@@ -62,6 +61,7 @@ export default {
|
|||||||
currentTablePage: 1,
|
currentTablePage: 1,
|
||||||
limit: 4,
|
limit: 4,
|
||||||
count: 0,
|
count: 0,
|
||||||
|
textSearch: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -75,20 +75,29 @@ export default {
|
|||||||
this.count = data.count;
|
this.count = data.count;
|
||||||
},
|
},
|
||||||
filterDataClients(text) {
|
filterDataClients(text) {
|
||||||
fetchWrapper
|
if (text) this.textSearch = text;
|
||||||
.get(
|
else this.textSearch = "";
|
||||||
`general/person/?last_name=${text}&?limit=${this.limit}&offset=${
|
if (this.currentTablePage !== 1) this.currentTablePage = 1;
|
||||||
(this.currentPage - 1) * this.limit
|
else {
|
||||||
}`
|
this.currentTablePage = 1;
|
||||||
)
|
this.fetchDataClients();
|
||||||
.then((data) => this.saveDataClients(data));
|
}
|
||||||
},
|
},
|
||||||
async fetchDataClients(currentPage) {
|
async fetchDataClients() {
|
||||||
let response = await fetchWrapper.get(
|
let response = {};
|
||||||
`general/person/?limit=${this.limit}&offset=${
|
if (this.textSearch) {
|
||||||
(currentPage - 1) * this.limit
|
response = await fetchWrapper.get(
|
||||||
}`
|
`general/person/?last_name=${this.textSearch}&limit=${
|
||||||
);
|
this.limit
|
||||||
|
}&offset=${(this.currentTablePage - 1) * this.limit}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
response = await fetchWrapper.get(
|
||||||
|
`general/person/?limit=${this.limit}&offset=${
|
||||||
|
(this.currentTablePage - 1) * this.limit
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
}
|
||||||
this.saveDataClients(response);
|
this.saveDataClients(response);
|
||||||
},
|
},
|
||||||
selectedCheck(e) {
|
selectedCheck(e) {
|
||||||
@@ -123,18 +132,19 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
updatedClients() {
|
updatedClients() {
|
||||||
if (this.updatedClients === true) {
|
if (this.updatedClients === true) {
|
||||||
this.fetchDataClients(this.currentTablePage).then(
|
this.textSearch = "";
|
||||||
|
this.fetchDataClients().then(
|
||||||
() => (this.currentTablePage = this.pageCount)
|
() => (this.currentTablePage = this.pageCount)
|
||||||
);
|
);
|
||||||
this.$emit("reset-updated-clients");
|
this.$emit("reset-updated-clients");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
currentTablePage() {
|
currentTablePage() {
|
||||||
this.fetchDataClients(this.currentTablePage);
|
this.fetchDataClients();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchDataClients(this.currentTablePage);
|
this.fetchDataClients();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
secondary,
|
secondary,
|
||||||
@click="resetLastName",
|
@click="resetLastName",
|
||||||
:size=40
|
:size=40
|
||||||
) Очистить
|
) Сбросить
|
||||||
clients-table-header-actions(v-if="!!isOpenActions", :is-selected-one="isOpenActions===1")
|
clients-table-header-actions(v-if="!!isOpenActions", :is-selected-one="isOpenActions===1")
|
||||||
.flex.w-fit.h-fit.gap-x-2
|
.flex.w-fit.h-fit.gap-x-2
|
||||||
base-button(left-icon="icon-download", :icon-left-size="16", :size="40", :outlined="true")
|
base-button(left-icon="icon-download", :icon-left-size="16", :size="40", :outlined="true")
|
||||||
@@ -53,10 +53,16 @@ export default {
|
|||||||
this.$emit("search", this.searchClient);
|
this.$emit("search", this.searchClient);
|
||||||
},
|
},
|
||||||
resetLastName() {
|
resetLastName() {
|
||||||
this.$emit("reset-search");
|
|
||||||
this.searchClient = "";
|
this.searchClient = "";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
searchClient() {
|
||||||
|
if (!this.searchClient) {
|
||||||
|
this.$emit("search");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user