diff --git a/src/components/HeaderInputs.vue b/src/components/HeaderInputs.vue index bd379c1..ffa62a0 100644 --- a/src/components/HeaderInputs.vue +++ b/src/components/HeaderInputs.vue @@ -13,10 +13,10 @@ .icon-wrapper.mr-2.flex.justify-center .icon-ok.text-xs.flex.justify-center.items-center(v-if="filter === selectedFilter") .flex.items-center {{ filter }} - base-input.p-4( + q-input.px-4( type="text", placeholder="Искать ...", - text-color="var(--btn-blue-color)", + :input-style="{color: 'var(--btn-blue-color)'}", borderless, square ) @@ -109,4 +109,7 @@ export default { .icon-down-arrow width: 16px height: 16px + +.input-height + height: 38px diff --git a/src/components/base/BaseAddingNetwork.vue b/src/components/base/BaseAddingNetwork.vue index dd9056c..56e0ca9 100644 --- a/src/components/base/BaseAddingNetwork.vue +++ b/src/components/base/BaseAddingNetwork.vue @@ -1,25 +1,34 @@ diff --git a/src/components/base/BaseClientFormCreate.vue b/src/components/base/BaseClientFormCreate.vue index 70383e7..f4c515f 100644 --- a/src/components/base/BaseClientFormCreate.vue +++ b/src/components/base/BaseClientFormCreate.vue @@ -76,14 +76,12 @@ :basic-info="infoClient.basic", :phone="infoClient.phone", :email="infoClient.email", - :save-network-id="saveNetworkId", :add-network="addNewNetwork", - :choose-option="chooseOptionNetworks", - :choose-priority="choosePriority", :priority-list="priorityList", :identity-document="infoClient.identity_document", :addresses="infoClient.addresses", :save-file="saveDocFile", + :networks-list="getNetworksList", ) q-btn( label="Создать клиента", @@ -129,7 +127,7 @@ export default { mixins: [v_model], data() { return { - networksSettings: column.find((el) => el.name === "networks"), + networksSettings: column.find((el) => el.name === "networks")?.settings, prioritySettings: column.find((el) => el.name === "priority"), networkId: "", infoClient: { @@ -142,10 +140,11 @@ export default { }, contacts: [ { - id: "network", - kind: "TELEGRAM", + kind: { + id: "TELEGRAM", + icon: "app:icon-tg", + }, username: "", - icon: "icon-tg", }, ], }, @@ -240,6 +239,16 @@ export default { return { label: el.text, id: el.id }; }); }, + getNetworksList() { + let contacts = []; + this.infoClient.basic.contacts.forEach((elem) => + contacts.push(elem.kind.id) + ); + let filteredNetworks = this.networksSettings.filter( + ({ id }) => !contacts.includes(id) + ); + return filteredNetworks; + }, }, methods: { previewImage(event) { @@ -258,10 +267,11 @@ export default { closePopup() { this.showPopup = false; }, - closeModal() { + /*closeModal() { !this.showModal ? this.closeForm() : null; - }, - createIdentityDocument(id) { + },*/ + async createIdentityDocument(id) { + let doc = null; let filteredData = Object.keys( this.filterDataEmptyProperty(this.infoClient.identity_document.pass) ); @@ -281,7 +291,7 @@ export default { "Паспортные данные не будут записаны в профиль клиента" ); } else - fetchWrapper.post("general/identity_document/create/", { + doc = await fetchWrapper.post("general/identity_document/create/", { series_number: this.infoClient.identity_document.pass.series_number, issued_by_org: this.infoClient.identity_document.pass.issued_by_org, issued_by_date: moment( @@ -292,35 +302,47 @@ export default { person: id, kind: "Паспорт", }); + return Promise.resolve(doc); } }, createAddress(id) { + let address = null; Object.keys(this.filterDataEmptyProperty(this.infoClient.addresses)) .length > 0 && - fetchWrapper.post("general/address/create/", { - ...this.filterDataEmptyProperty(this.infoClient.addresses), - person: id, - }); + fetchWrapper + .post("general/address/create/", { + ...this.filterDataEmptyProperty(this.infoClient.addresses), + person: id, + }) + .then((res) => (address = res)); + return Promise.resolve(address); }, - createContacts(id) { + async createContacts(id) { + let phone = null, + email = null, + contacts = []; if (this.infoClient.phone.username) - fetchWrapper.post("general/contact/create/", { + phone = await fetchWrapper.post("general/contact/create/", { ...this.filterDataEmptyProperty(this.infoClient.phone), person: id, }); if (this.infoClient.email.username) - fetchWrapper.post("general/contact/create/", { + email = await fetchWrapper.post("general/contact/create/", { ...this.filterDataEmptyProperty(this.infoClient.email), person: id, }); - this.infoClient.basic.contacts.forEach((el) => { - if (el.username) - fetchWrapper.post("general/contact/create/", { - kind: el.kind, - username: el.username, - person: id, - }); - }); + for (const network of this.infoClient.basic.contacts) { + if (network.username) { + contacts.push( + await fetchWrapper.post("general/contact/create/", { + kind: network.kind.id, + username: network.username, + person: id, + }) + ); + } + } + return Promise.allSettled([phone, email, contacts]); }, postNewClient() { const formData = new FormData(); @@ -340,12 +362,15 @@ export default { .post("general/person/create/", formData, "formData") .then((result) => { if (result.id) { - this.createIdentityDocument(result.id); - this.createAddress(result.id); - this.createContacts(result.id); - this.writeCreatedClientId(result.id); - this.setUpdatedClients(); - this.addSuccessNotification(); + Promise.allSettled([ + this.createIdentityDocument(result.id), + this.createAddress(result.id), + this.createContacts(result.id), + ]).then(() => { + this.writeCreatedClientId(result.id); + this.setUpdatedClients(); + this.addSuccessNotification(); + }); } else { this.addErrorNotification( "Клиент не создан", @@ -364,26 +389,13 @@ export default { }); return postData; }, - saveNetworkId(e) { - this.networkId = e.currentTarget.id; - }, choosePriority(e) { this.infoClient.basic.priority = e.target.id; }, - chooseOptionNetworks(e) { - let index = this.infoClient.basic.contacts.findIndex( - (el) => el.id === this.networkId - ); - let icon = this.networksSettings.settings.find( - (el) => el.network === e.target.id - ).icon; - this.infoClient.basic.contacts[index].kind = e.target.id; - this.infoClient.basic.contacts[index].icon = icon; - }, saveClient() { if (this.checkFormFullness()) { this.postNewClient(); - this.closeForm(); + //this.closeForm(); } }, changeOpenModal() { @@ -407,14 +419,15 @@ export default { }); }, addNewNetwork() { - this.infoClient.basic.contacts.push({ - id: - this.infoClient.basic.contacts[0].id + - this.infoClient.basic.contacts.length, - kind: "TELEGRAM", - username: "", - icon: "icon-tg", - }); + const newNetwork = this.getNetworksList; + if (newNetwork[0]) + this.infoClient.basic.contacts.push({ + kind: { + id: newNetwork[0].id, + icon: newNetwork[0].icon, + }, + username: "", + }); }, selectForm(componentName) { this.currentForm = this.forms.find( diff --git a/src/components/base/BaseInput.vue b/src/components/base/BaseInput.vue index 5707185..27db359 100644 --- a/src/components/base/BaseInput.vue +++ b/src/components/base/BaseInput.vue @@ -10,7 +10,7 @@ :dense="dense", :type="type", :filled="filled", - :bg-color="!filled && 'white'", + :bg-color="filled ? '' : 'white'", :disable="disabled", :rules="rule", :mask="mask", diff --git a/src/components/base/BaseModal.vue b/src/components/base/BaseModal.vue index 5bbc342..c908672 100644 --- a/src/components/base/BaseModal.vue +++ b/src/components/base/BaseModal.vue @@ -106,7 +106,6 @@ export default { backdropEl.style.background = "rgba(37, 40, 80, 0.2)"; backdropEl.style.backdropFilter = "blur(4px)"; } else backdropEl.style.background = "rgba(0,0,0,0)"; - console.log("123"); }, watch: { value(val) { diff --git a/src/components/base/BaseSelect.vue b/src/components/base/BaseSelect.vue index 757a38e..fc4310d 100644 --- a/src/components/base/BaseSelect.vue +++ b/src/components/base/BaseSelect.vue @@ -13,7 +13,19 @@ map-options ) template(v-slot:selected) - span {{ textSelect }} + span(v-if="!value.icon") {{ textSelect }} + q-icon( + v-else, + :name="iconSelect", + size="20px" + ) + template( + v-slot:option="scope", + v-if="value.icon" + ) + q-item(v-bind="scope.itemProps", style="justify-content: center") + q-item-section(avatar, style="padding: 0px; min-width: 0px") + q-icon(:name="scope.opt.icon", size="20px") diff --git a/src/pages/clients/components/ClientsTableRow.vue b/src/pages/clients/components/ClientsTableRow.vue index 21d9572..1b9b2c8 100644 --- a/src/pages/clients/components/ClientsTableRow.vue +++ b/src/pages/clients/components/ClientsTableRow.vue @@ -381,11 +381,14 @@ export default { }); }, addNetwork(network) { - this.dataClient.contacts.push(network); + this.dataClient.contacts.push({ + kind: network.kind?.id, + username: network.username, + }); }, deleteNetwork(e) { this.dataClient.contacts = this.dataClient.contacts.filter( - (el) => el.kind !== e.target.id + (el) => el.kind !== e.currentTarget.id ); }, choosePriority(e) { diff --git a/src/pages/clients/components/FormCreateBasicInfo.vue b/src/pages/clients/components/FormCreateBasicInfo.vue index 12efb74..92afdc2 100644 --- a/src/pages/clients/components/FormCreateBasicInfo.vue +++ b/src/pages/clients/components/FormCreateBasicInfo.vue @@ -28,16 +28,13 @@ ) .flex.flex-col.col-start-1.col-end-3.w-100(class="gap-y-1.5") span.text-sm.font-semibold.opacity-40.input-info Ссылки на соцсети - .flex(class="gap-x-1.5" v-for="network in basicInfo.contacts" :key="network.id") + .flex(class="gap-x-1.5" v-for="network in basicInfo.contacts" :key="network.kind.id") base-adding-network( - :list-adding-networks="networks.settings", - :selected-option="network.icon", - :value="network", - :choose-network="chooseOption", - :save-network-id="saveNetworkId" + :items="networksList", + :network="network", ) span.add-network.cursor-pointer( - v-show="networks.settings.length !== basicInfo.contacts.length", + v-show="networksList.length !== 0", @click="addNetwork" ) Добавить соцсеть @@ -45,7 +42,6 @@ diff --git a/src/pages/clients/components/cells/TableCellBodyNetworks.vue b/src/pages/clients/components/cells/TableCellBodyNetworks.vue index 4000b54..151f4a1 100644 --- a/src/pages/clients/components/cells/TableCellBodyNetworks.vue +++ b/src/pages/clients/components/cells/TableCellBodyNetworks.vue @@ -1,40 +1,43 @@