WIP Подключила пагинацию на клиентов
This commit is contained in:
@@ -4,14 +4,17 @@
|
|||||||
:is-open-form="isOpenForm",
|
:is-open-form="isOpenForm",
|
||||||
:close-form="closeForm",
|
:close-form="closeForm",
|
||||||
:open-form="openForm",
|
:open-form="openForm",
|
||||||
:current-year="currentYear"
|
:current-year="currentYear",
|
||||||
|
@update-client="setUpdatedClients"
|
||||||
)
|
)
|
||||||
.flex.flex-auto
|
.flex.flex-auto
|
||||||
the-sidebar
|
the-sidebar
|
||||||
router-view(
|
router-view(
|
||||||
:open-form="openForm",
|
:open-form="openForm",
|
||||||
:is-open-form="isOpenForm",
|
:is-open-form="isOpenForm",
|
||||||
:current-year="currentYear"
|
:current-year="currentYear",
|
||||||
|
:updated-clients="updatedClients",
|
||||||
|
@reset-updated-clients="resetUpdatedClients"
|
||||||
)
|
)
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -26,6 +29,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
isOpenForm: false,
|
isOpenForm: false,
|
||||||
currentYear: null,
|
currentYear: null,
|
||||||
|
updatedClients: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -38,6 +42,12 @@ export default {
|
|||||||
printCurrentYear() {
|
printCurrentYear() {
|
||||||
return new Date().getFullYear();
|
return new Date().getFullYear();
|
||||||
},
|
},
|
||||||
|
setUpdatedClients() {
|
||||||
|
this.updatedClients = true;
|
||||||
|
},
|
||||||
|
resetUpdatedClients() {
|
||||||
|
this.updatedClients = false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
this.currentYear = this.printCurrentYear();
|
this.currentYear = this.printCurrentYear();
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
base-client-form-create(
|
base-client-form-create(
|
||||||
v-if="isOpenForm",
|
v-if="isOpenForm",
|
||||||
:close-form="closeForm",
|
:close-form="closeForm",
|
||||||
:current-year="currentYear"
|
:current-year="currentYear",
|
||||||
|
@update-client="transmitUpdateClient"
|
||||||
)
|
)
|
||||||
.flex.items-center.box-border.cursor-pointer.mr-auto
|
.flex.items-center.box-border.cursor-pointer.mr-auto
|
||||||
img.logo-img.mr-29_25px(src="@/assets/images/logo.svg", alt="Logo")
|
img.logo-img.mr-29_25px(src="@/assets/images/logo.svg", alt="Logo")
|
||||||
@@ -58,6 +59,9 @@ export default {
|
|||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
this.$router.push("/login");
|
this.$router.push("/login");
|
||||||
},
|
},
|
||||||
|
transmitUpdateClient() {
|
||||||
|
this.$emit("update-client");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ export default {
|
|||||||
this.createIdentityDocument(result.id);
|
this.createIdentityDocument(result.id);
|
||||||
this.createAddress(result.id);
|
this.createAddress(result.id);
|
||||||
});
|
});
|
||||||
|
this.$emit("update-client");
|
||||||
},
|
},
|
||||||
filterDataEmptyProperty(data) {
|
filterDataEmptyProperty(data) {
|
||||||
let postData = data;
|
let postData = data;
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
clients-wrapper(
|
clients-wrapper(
|
||||||
:open-form="openForm",
|
:open-form="openForm",
|
||||||
:is-open-form="isOpenForm",
|
:is-open-form="isOpenForm",
|
||||||
:current-year="currentYear"
|
:current-year="currentYear",
|
||||||
|
:updated-clients="updatedClients",
|
||||||
|
@reset-updated-clients="transmitReset"
|
||||||
)
|
)
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -15,6 +17,12 @@ export default {
|
|||||||
openForm: Function,
|
openForm: Function,
|
||||||
currentYear: Number,
|
currentYear: Number,
|
||||||
isOpenForm: Boolean,
|
isOpenForm: Boolean,
|
||||||
|
updatedClients: Boolean,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
transmitReset() {
|
||||||
|
this.$emit("reset-updated-clients");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
:current-year="currentYear"
|
:current-year="currentYear"
|
||||||
)
|
)
|
||||||
client-table-pagination(
|
client-table-pagination(
|
||||||
:length=6,
|
v-if="pageCount > 1"
|
||||||
|
:length="pageCount",
|
||||||
:current-page="currentTablePage",
|
:current-page="currentTablePage",
|
||||||
@previous-page="switchPreviousPage",
|
@previous-page="switchPreviousPage",
|
||||||
@next-page="switchNextPage",
|
@next-page="switchNextPage",
|
||||||
@@ -50,6 +51,7 @@ export default {
|
|||||||
openForm: Function,
|
openForm: Function,
|
||||||
currentYear: Number,
|
currentYear: Number,
|
||||||
isOpenForm: Boolean,
|
isOpenForm: Boolean,
|
||||||
|
updatedClients: Boolean,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@@ -58,21 +60,36 @@ export default {
|
|||||||
marked: [],
|
marked: [],
|
||||||
dataClients: [],
|
dataClients: [],
|
||||||
currentTablePage: 1,
|
currentTablePage: 1,
|
||||||
|
limit: 4,
|
||||||
|
count: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
pageCount() {
|
||||||
|
return Math.ceil(this.count / this.limit);
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
saveDataClients(data) {
|
saveDataClients(data) {
|
||||||
this.dataClients = data.results;
|
this.dataClients = data.results;
|
||||||
|
this.count = data.count;
|
||||||
},
|
},
|
||||||
filterDataClients(text) {
|
filterDataClients(text) {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
.get(`general/person/?last_name=${text}`)
|
.get(
|
||||||
|
`general/person/?last_name=${text}&?limit=${this.limit}&offset=${
|
||||||
|
(this.currentPage - 1) * this.limit
|
||||||
|
}`
|
||||||
|
)
|
||||||
.then((data) => this.saveDataClients(data));
|
.then((data) => this.saveDataClients(data));
|
||||||
},
|
},
|
||||||
fetchDataClients() {
|
async fetchDataClients(currentPage) {
|
||||||
fetchWrapper
|
let response = await fetchWrapper.get(
|
||||||
.get("general/person/")
|
`general/person/?limit=${this.limit}&offset=${
|
||||||
.then((data) => this.saveDataClients(data));
|
(currentPage - 1) * this.limit
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
this.saveDataClients(response);
|
||||||
},
|
},
|
||||||
selectedCheck(e) {
|
selectedCheck(e) {
|
||||||
if (e.target.id === "checkbox") {
|
if (e.target.id === "checkbox") {
|
||||||
@@ -104,17 +121,20 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
isOpenForm: {
|
updatedClients() {
|
||||||
immediate: true,
|
if (this.updatedClients === true) {
|
||||||
handler(newValue) {
|
this.fetchDataClients(this.currentTablePage).then(
|
||||||
if (newValue === false) {
|
() => (this.currentTablePage = this.pageCount)
|
||||||
this.fetchDataClients();
|
);
|
||||||
}
|
this.$emit("reset-updated-clients");
|
||||||
},
|
}
|
||||||
|
},
|
||||||
|
currentTablePage() {
|
||||||
|
this.fetchDataClients(this.currentTablePage);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchDataClients();
|
this.fetchDataClients(this.currentTablePage);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export default {
|
|||||||
this.$emit("search", this.searchClient);
|
this.$emit("search", this.searchClient);
|
||||||
},
|
},
|
||||||
resetLastName() {
|
resetLastName() {
|
||||||
this.$emit("reset-search", this.searchClient);
|
this.$emit("reset-search");
|
||||||
this.searchClient = "";
|
this.searchClient = "";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
.wrapper.flex.w-full.relative.mx-2
|
.wrapper.flex.w-full.relative.mx-2
|
||||||
clients-table(
|
clients-table(
|
||||||
:open-form="openForm",
|
:open-form="openForm",
|
||||||
:is-open-form="isOpenForm"
|
:is-open-form="isOpenForm",
|
||||||
:current-year="currentYear"
|
:current-year="currentYear",
|
||||||
|
:updated-clients="updatedClients",
|
||||||
|
@reset-updated-clients="transmitReset"
|
||||||
)
|
)
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -16,6 +18,12 @@ export default {
|
|||||||
openForm: Function,
|
openForm: Function,
|
||||||
currentYear: Number,
|
currentYear: Number,
|
||||||
isOpenForm: Boolean,
|
isOpenForm: Boolean,
|
||||||
|
updatedClients: Boolean,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
transmitReset() {
|
||||||
|
this.$emit("reset-updated-clients");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user