WIP Наладила get после post client

This commit is contained in:
Daria Golova
2022-12-01 19:03:56 +03:00
parent e3697d4416
commit 6837d9e498
5 changed files with 23 additions and 31 deletions

View File

@@ -4,7 +4,7 @@
:is-open-form="isOpenForm", :is-open-form="isOpenForm",
:close-form="closeForm", :close-form="closeForm",
:open-form="openForm", :open-form="openForm",
@update-client="setUpdatedClients" :set-updated-clients="setUpdatedClients",
) )
.flex.flex-auto .flex.flex-auto
the-sidebar the-sidebar

View File

@@ -3,7 +3,7 @@
base-client-form-create( base-client-form-create(
v-if="isOpenForm", v-if="isOpenForm",
:close-form="closeForm", :close-form="closeForm",
@update-client="transmitUpdateClient" :set-updated-clients="setUpdatedClients",
) )
.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")
@@ -42,6 +42,7 @@ export default {
openForm: Function, openForm: Function,
closeForm: Function, closeForm: Function,
isOpenForm: Boolean, isOpenForm: Boolean,
setUpdatedClients: Function,
}, },
data() { data() {
return { return {
@@ -57,9 +58,6 @@ export default {
localStorage.clear(); localStorage.clear();
this.$router.push("/login"); this.$router.push("/login");
}, },
transmitUpdateClient() {
this.$emit("update-client");
},
}, },
}; };
</script> </script>

View File

@@ -107,6 +107,7 @@ export default {
}, },
props: { props: {
closeForm: Function, closeForm: Function,
setUpdatedClients: Function,
}, },
data() { data() {
return { return {
@@ -300,9 +301,9 @@ export default {
this.createIdentityDocument(result.id); this.createIdentityDocument(result.id);
this.createAddress(result.id); this.createAddress(result.id);
this.createContacts(result.id); this.createContacts(result.id);
this.setUpdatedClients();
this.addSuccessNotification(); this.addSuccessNotification();
}); });
this.$emit("update-client");
}, },
filterDataEmptyProperty(data) { filterDataEmptyProperty(data) {
let postData = data; let postData = data;

View File

@@ -17,9 +17,9 @@
:check="selectedCheck", :check="selectedCheck",
:client="client", :client="client",
:row-overlay="deletedRowId === client.id", :row-overlay="deletedRowId === client.id",
:update-data-client="updateDataClient",
@delete-client="deleteClientHandler", @delete-client="deleteClientHandler",
@recover-client="clearDeletedRowId", @recover-client="clearDeletedRowId",
@update-clients="updateDataClient"
) )
client-table-pagination( client-table-pagination(
v-if="paginationInfo.length > 1" v-if="paginationInfo.length > 1"
@@ -181,11 +181,9 @@ export default {
updatedClients() { updatedClients() {
if (this.updatedClients === true) { if (this.updatedClients === true) {
this.textSearch = ""; this.textSearch = "";
setTimeout(() => {
this.fetchDataClients().then( this.fetchDataClients().then(
() => (this.currentTablePage = this.pageCount) () => (this.currentTablePage = this.pageCount)
); );
}, 100);
this.$emit("reset-updated-clients"); this.$emit("reset-updated-clients");
} }
}, },

View File

@@ -1,8 +1,7 @@
<template lang="pug"> <template lang="pug">
.wrapper.flex .wrapper.flex.relative
.row-overlay.flex.justify-center.items-center.gap-x-2.text-base( .row-overlay.flex.justify-center.items-center.gap-x-2.text-base(
v-if="rowOverlay", v-if="rowOverlay",
:style="rowSize"
) )
button.recover-btn(@click="stopTimer") Восстановить button.recover-btn(@click="stopTimer") Восстановить
.countdown 0:{{ countdown }} .countdown 0:{{ countdown }}
@@ -10,11 +9,10 @@
.row-body.flex.w-full.cursor-pointer( .row-body.flex.w-full.cursor-pointer(
:id="id", :id="id",
@click="(e) => openDetailInfo(e)", @click="(e) => openDetailInfo(e)",
:class="{'row-overlay-color': rowOverlay}", :class="{'row-overlay-color': rowOverlay}"
ref="rowBody"
) )
.check-box.flex.justify-center.items-center( .check-box.flex.justify-center.items-center(
:style="{'opacity': rowOverlay && '0.5'}" :class="{'row-opacity': rowOverlay}"
) )
clients-table-checkbox( clients-table-checkbox(
:id="id", :id="id",
@@ -22,7 +20,7 @@
:is-check="isCheck" :is-check="isCheck"
) )
table-cell-body-name( table-cell-body-name(
:style="{'opacity': rowOverlay && '0.5'}" :class="{'row-opacity': rowOverlay}"
:value="dataClient", :value="dataClient",
:avatar="dataClient.avatar", :avatar="dataClient.avatar",
:avatar-color="dataClient.color", :avatar-color="dataClient.color",
@@ -173,23 +171,15 @@ export default {
isCheck: Boolean, isCheck: Boolean,
client: Object, client: Object,
rowOverlay: Boolean, rowOverlay: Boolean,
updateDataClient: Function,
url: String, url: String,
}, },
computed: {
rowSize() {
let size = this.$refs["rowBody"].getBoundingClientRect();
return {
height: `${size.height}px`,
width: `${size.width}px`,
};
},
},
methods: { methods: {
stopTimer() { stopTimer() {
if (this.countdown !== 0) this.countdown = 0; if (this.countdown !== 0) this.countdown = 0;
this.$emit("recover-client");
clearInterval(this.timer); clearInterval(this.timer);
this.timer = null; this.timer = null;
this.$emit("recover-client");
}, },
startTimer() { startTimer() {
this.countdown = 30; this.countdown = 30;
@@ -199,7 +189,8 @@ export default {
}, },
changeCountdown() { changeCountdown() {
if (this.countdown === 0) { if (this.countdown === 0) {
this.deleteClient().then(() => this.stopTimer()); this.stopTimer();
this.deleteClient().then(() => this.updateDataClient());
} else { } else {
this.countdown -= 1; this.countdown -= 1;
} }
@@ -491,9 +482,9 @@ export default {
photo: this.client.photo, photo: this.client.photo,
}; };
}, },
beforeUnmount() { /*beforeUnmount() {
this.stopTimer(); this.stopTimer();
}, },*/
}; };
</script> </script>
@@ -518,10 +509,14 @@ export default {
&:hover &:hover
background-color: var(--btn-blue-color) background-color: var(--btn-blue-color)
color: var(--default-white) color: var(--default-white)
.row-opacity
opacity: 0.5
.row-overlay .row-overlay
background: transparent background: transparent
position: absolute position: absolute
z-index: 100 z-index: 100
width: 100%
height: 100%
.row-overlay-color .row-overlay-color
background: var(--row-overlay-color) background: var(--row-overlay-color)
.recover-btn .recover-btn