WIP Переключение на клиента после создания
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
:clearing-text-search="clearingTextSearch",
|
||||
:change-clearing-text-search="changeClearingTextSearch",
|
||||
@search="filterDataClients",
|
||||
:created-client-name="createdClientName",
|
||||
)
|
||||
.flex.flex-col.h-full.table-container.w-full.mt-8.mb-3
|
||||
base-modal(v-model="showMedicalCard")
|
||||
@@ -30,7 +31,9 @@
|
||||
:deleted-client-id="deletedRowId",
|
||||
:update-data-client="updateDataClient",
|
||||
:fetch-data-clients="fetchDataClients",
|
||||
:fetch-created-client-data="fetchCreatedClientData",
|
||||
:create-medical-card="createMedicalCard",
|
||||
:created-client-name="createdClientName",
|
||||
@delete-client="deleteClientHandler",
|
||||
@recover-client="clearDeletedRowId",
|
||||
)
|
||||
@@ -83,6 +86,7 @@ export default {
|
||||
isOpenForm: Boolean,
|
||||
updatedClients: Boolean,
|
||||
url: String,
|
||||
createdClientId: String,
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -108,6 +112,7 @@ export default {
|
||||
deletedRowId: "",
|
||||
clearingTextSearch: false,
|
||||
showMedicalCard: false,
|
||||
createdClientName: "",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -117,6 +122,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
updateDataClient() {
|
||||
this.clearCreatedClientName();
|
||||
if (this.textSearch) this.filteredClientsCount -= 1;
|
||||
else this.clientsCount -= 1;
|
||||
if (this.dataClients.find(({ id }) => id === this.deletedRowId)) {
|
||||
@@ -134,6 +140,7 @@ export default {
|
||||
if (!this.filteredClientsCoun) this.filteredClientsCount = data.count;
|
||||
},
|
||||
filterDataClients(text) {
|
||||
this.clearCreatedClientName();
|
||||
if (text) {
|
||||
this.textSearch = text;
|
||||
this.filteredClientsCount = 0;
|
||||
@@ -171,6 +178,18 @@ export default {
|
||||
};
|
||||
}
|
||||
},
|
||||
async fetchCreatedClientData() {
|
||||
fetchWrapper
|
||||
.get(`general/person/${this.createdClientId}/detail/`)
|
||||
.then((response) => {
|
||||
this.dataClients = [response];
|
||||
this.createdClientName = `${response.last_name} ${response.first_name} ${response.patronymic}`;
|
||||
this.paginationInfo = {
|
||||
currentPage: 0,
|
||||
length: 0,
|
||||
};
|
||||
});
|
||||
},
|
||||
calculatePageCount(count) {
|
||||
return Math.ceil(count / this.limit);
|
||||
},
|
||||
@@ -226,19 +245,18 @@ export default {
|
||||
},
|
||||
changeClearingTextSearch() {
|
||||
this.clearingTextSearch = false;
|
||||
this.clearCreatedClientName();
|
||||
},
|
||||
clearCreatedClientName() {
|
||||
this.createdClientName = "";
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
updatedClients() {
|
||||
if (this.updatedClients === true) {
|
||||
this.textSearch = "";
|
||||
this.clearingTextSearch = true;
|
||||
this.clientsCount += 1;
|
||||
if (
|
||||
this.currentTablePage !== this.calculatePageCount(this.clientsCount)
|
||||
)
|
||||
this.currentTablePage = this.calculatePageCount(this.clientsCount);
|
||||
else this.fetchDataClients();
|
||||
this.fetchCreatedClientData();
|
||||
this.$emit("reset-updated-clients");
|
||||
}
|
||||
},
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
)
|
||||
.icon-search
|
||||
base-button.font-semibold(
|
||||
v-if="createdClientName === ''",
|
||||
@click="searchLastName",
|
||||
:size=40
|
||||
) Поиск
|
||||
@@ -43,6 +44,7 @@ export default {
|
||||
isOpenActions: Number,
|
||||
clearingTextSearch: Boolean,
|
||||
changeClearingTextSearch: Function,
|
||||
createdClientName: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -51,7 +53,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
searchLastName() {
|
||||
if (this.searchClient.length >= 3)
|
||||
if (this.searchClient.length >= 3 && !this.createdClientName)
|
||||
this.$emit("search", this.searchClient);
|
||||
},
|
||||
resetLastName() {
|
||||
@@ -59,6 +61,9 @@ export default {
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
createdClientName() {
|
||||
if (this.createdClientName) this.searchClient = this.createdClientName;
|
||||
},
|
||||
searchClient() {
|
||||
if (!this.searchClient && !this.clearingTextSearch) {
|
||||
this.$emit("search");
|
||||
@@ -76,5 +81,5 @@ export default {
|
||||
|
||||
<style lang="sass" scoped>
|
||||
.input
|
||||
width: 280px
|
||||
min-width: 280px
|
||||
</style>
|
||||
|
||||
@@ -188,6 +188,8 @@ export default {
|
||||
url: String,
|
||||
fetchDataClients: Function,
|
||||
createMedicalCard: Function,
|
||||
fetchCreatedClientData: Function,
|
||||
createdClientName: String,
|
||||
},
|
||||
computed: {
|
||||
rowOverlay() {
|
||||
@@ -207,7 +209,7 @@ export default {
|
||||
this.timer = null;
|
||||
},
|
||||
startTimer() {
|
||||
this.countdown = 30;
|
||||
this.countdown = 600;
|
||||
this.timer = setInterval(() => {
|
||||
this.changeCountdown();
|
||||
}, 1000);
|
||||
@@ -260,7 +262,10 @@ export default {
|
||||
.post(`general/person/${this.client.id}/update/`, {
|
||||
...data,
|
||||
})
|
||||
.then(() => this.fetchDataClients());
|
||||
.then(() => {
|
||||
if (this.createdClientName) this.fetchCreatedClientData;
|
||||
else this.fetchDataClients();
|
||||
});
|
||||
},
|
||||
postContactsClient() {
|
||||
let contacts = [...this.dataClient.contacts];
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
:is-open-form="isOpenForm",
|
||||
:updated-clients="updatedClients",
|
||||
@reset-updated-clients="transmitReset",
|
||||
:url="url"
|
||||
:url="url",
|
||||
:created-client-id="createdClientId"
|
||||
)
|
||||
</template>
|
||||
|
||||
@@ -19,6 +20,7 @@ export default {
|
||||
isOpenForm: Boolean,
|
||||
updatedClients: Boolean,
|
||||
url: String,
|
||||
createdClientId: String,
|
||||
},
|
||||
methods: {
|
||||
transmitReset() {
|
||||
|
||||
Reference in New Issue
Block a user