WIP Доделал форму Контактов
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
--bg-btn-icons-color: rgba(215, 217, 255, 0.6)
|
--bg-btn-icons-color: rgba(215, 217, 255, 0.6)
|
||||||
--font-grey-color: #9294a7
|
--font-grey-color: #9294a7
|
||||||
--font-grey-color-0: #85858b
|
--font-grey-color-0: #85858b
|
||||||
|
--border-grey-color: #c2c2c2
|
||||||
--border-light-grey-color: #d3d4dc
|
--border-light-grey-color: #d3d4dc
|
||||||
--bg-light-grey: #eff1f4
|
--bg-light-grey: #eff1f4
|
||||||
--row-overlay-color: #f5f6ff
|
--row-overlay-color: #f5f6ff
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
--bg-hover-row-table: rgba(215, 217, 255, 0.25)
|
--bg-hover-row-table: rgba(215, 217, 255, 0.25)
|
||||||
--default-white: #fff
|
--default-white: #fff
|
||||||
--btn-red-color: #ff6f6f
|
--btn-red-color: #ff6f6f
|
||||||
|
--icon-violet-color: #791984
|
||||||
--font-obligatory-color: #ff0000
|
--font-obligatory-color: #ff0000
|
||||||
--bg-event-box-color: rgba(37, 40, 80, 0.1)
|
--bg-event-box-color: rgba(37, 40, 80, 0.1)
|
||||||
--bg-event-green-color: #24d07d
|
--bg-event-green-color: #24d07d
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
@click="changeSelect",
|
@click="changeSelect",
|
||||||
v-click-outside="closeSelect",
|
v-click-outside="closeSelect",
|
||||||
:class="{border: styleBorder}"
|
:class="{border: styleBorder}"
|
||||||
|
:style="{width: sizeInput + 'px'}"
|
||||||
)
|
)
|
||||||
.flex.select.cursor-pointer.w-full.text-xl.items-center.networks(:class="optionData, 'px-2.5'")
|
.flex.select.cursor-pointer.w-full.text-xl.items-center.networks(:class="'px-2.5'")
|
||||||
|
q-icon(:name="listData.find((el) => el.network === optionData)?.icon || placeholder")
|
||||||
.absolute.options.top-11.left-0(
|
.absolute.options.top-11.left-0(
|
||||||
v-show="isSelectOpen",
|
v-show="isSelectOpen",
|
||||||
:id="id"
|
:id="id"
|
||||||
@@ -14,8 +16,8 @@
|
|||||||
@click="(e) => chooseOption(e)",
|
@click="(e) => chooseOption(e)",
|
||||||
:key="data.network",
|
:key="data.network",
|
||||||
:id="data.network",
|
:id="data.network",
|
||||||
:class="data.icon"
|
|
||||||
)
|
)
|
||||||
|
q-icon(:name="data.icon")
|
||||||
.select-form-separator.cursor-pointer.mr-6px(v-if="separator")
|
.select-form-separator.cursor-pointer.mr-6px(v-if="separator")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ export default {
|
|||||||
background-color: var(--default-white)
|
background-color: var(--default-white)
|
||||||
&.border
|
&.border
|
||||||
background-color: var(--default-white)
|
background-color: var(--default-white)
|
||||||
border: 2px solid var(--border-light-grey-color)
|
border: 1.5px solid var(--border-grey-color)
|
||||||
.select
|
.select
|
||||||
appearance: none
|
appearance: none
|
||||||
border: none
|
border: none
|
||||||
|
|||||||
@@ -9,26 +9,31 @@
|
|||||||
:open-edit="openEdit"
|
:open-edit="openEdit"
|
||||||
)
|
)
|
||||||
.form-wrap.gap-24.w-full
|
.form-wrap.gap-24.w-full
|
||||||
.flex.flex-col.gap-4(v-for="(data, key) in contacts")
|
.flex.flex-col.gap-4(v-for="(contact, key) in contacts")
|
||||||
.font-semibold.text-sm.whitespace-nowrap {{configData[key].title}}
|
.font-semibold.text-sm.whitespace-nowrap {{configData[key].title}}
|
||||||
.flex.w-full.justify-between.items-center.gap-4(v-for="(value, index) in data")
|
.flex.w-full.justify-between.items-center.gap-4(v-for="(data, index) in contact")
|
||||||
.label-field.font-sm.text-sm.whitespace-nowrap {{`${configData[key].fieldName} ${index+1} :`}}
|
.label-field.font-sm.text-sm.whitespace-nowrap {{`${configData[key].fieldName} ${index+1} :`}}
|
||||||
.input-wrapper.items-center.flex.h-10.gap-10px
|
.input-wrapper.items-center.flex.h-10.gap-10px
|
||||||
.flex(v-if="key === 'networks'")
|
.flex(v-if="key === 'networks'")
|
||||||
.flex.rounded-full.cursor-pointer.items-center.gap-10px.py-1.pl-1.pr-2(
|
.flex.rounded-full.cursor-pointer.items-center.gap-10px.py-1.pl-1.pr-2(
|
||||||
v-if="value.kind"
|
v-if="data.id || data.filled"
|
||||||
@click="() => copyLinkNetwork(value.username)"
|
@click="() => copyLinkNetwork(data.username)"
|
||||||
style="background-color: var(--bg-light-grey)"
|
style="background-color: var(--bg-light-grey)"
|
||||||
)
|
)
|
||||||
q-icon(:name="mapNetworks[value.kind].icon" style="color: var(--btn-blue-color)")
|
q-icon.icon(:name="mapNetworks[data.kind].icon" :class="{old: data.id, new: data.filled}")
|
||||||
span.text-sm.font-medium {{ mapNetworks[value.kind].title || value.username }}
|
span.text-sm.font-medium {{ mapNetworks[data.kind].title || data.username }}
|
||||||
|
.flex.gap-10px(v-else v-click-outside="() => checkNetworksField(index)")
|
||||||
|
base-select-networks(
|
||||||
|
:list-data="Object.values(mapNetworks)"
|
||||||
|
:option-data="data.kind"
|
||||||
|
:choose-option="(e) => chooseNetwork(e, index)"
|
||||||
|
:style-border="true"
|
||||||
|
:size-input="50"
|
||||||
|
)
|
||||||
base-input.w-full(
|
base-input.w-full(
|
||||||
v-else
|
|
||||||
:disabled="!isEdit"
|
:disabled="!isEdit"
|
||||||
v-model="value.username"
|
v-model="data.username"
|
||||||
:mask="configData[key].inputMask"
|
:mask="configData[key].inputMask"
|
||||||
@keyup.enter="(e) => defineNetworkByValue(e, index)",
|
|
||||||
@update:model-value="checkChangeInput"
|
|
||||||
type="text"
|
type="text"
|
||||||
:standout="!isEdit"
|
:standout="!isEdit"
|
||||||
:outlined="isEdit"
|
:outlined="isEdit"
|
||||||
@@ -37,7 +42,7 @@
|
|||||||
base-input.w-full(
|
base-input.w-full(
|
||||||
v-else
|
v-else
|
||||||
:disabled="!isEdit"
|
:disabled="!isEdit"
|
||||||
v-model="value.username"
|
v-model="data.username"
|
||||||
:mask="configData[key].inputMask"
|
:mask="configData[key].inputMask"
|
||||||
@update:model-value="checkChangeInput"
|
@update:model-value="checkChangeInput"
|
||||||
type="text"
|
type="text"
|
||||||
@@ -60,6 +65,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import MedicalFormWrapper from "@/pages/newMedicalCard/components/MedicalFormWrapper.vue";
|
import MedicalFormWrapper from "@/pages/newMedicalCard/components/MedicalFormWrapper.vue";
|
||||||
import BaseInput from "@/components/base/BaseInput.vue";
|
import BaseInput from "@/components/base/BaseInput.vue";
|
||||||
|
import BaseSelectNetworks from "@/components/base/BaseSelectNetworks.vue";
|
||||||
import { mapNetworks } from "@/pages/newMedicalCard/utils/medicalConfig";
|
import { mapNetworks } from "@/pages/newMedicalCard/utils/medicalConfig";
|
||||||
import { checkChangeData } from "@/shared/utils/changesObjects";
|
import { checkChangeData } from "@/shared/utils/changesObjects";
|
||||||
import { contactsDataForm } from "@/pages/newMedicalCard/utils/medicalConfig";
|
import { contactsDataForm } from "@/pages/newMedicalCard/utils/medicalConfig";
|
||||||
@@ -67,7 +73,7 @@ import { mapState, mapGetters } from "vuex";
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ContactsForm",
|
name: "ContactsForm",
|
||||||
components: { MedicalFormWrapper, BaseInput },
|
components: { MedicalFormWrapper, BaseInput, BaseSelectNetworks },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
@@ -87,6 +93,14 @@ export default {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
checkNetworksField(index) {
|
||||||
|
if (
|
||||||
|
this.contacts.networks[index].kind &&
|
||||||
|
this.contacts.networks[index].username
|
||||||
|
) {
|
||||||
|
this.contacts.networks[index].filled = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
openEdit() {
|
openEdit() {
|
||||||
this.isEdit = true;
|
this.isEdit = true;
|
||||||
},
|
},
|
||||||
@@ -108,19 +122,22 @@ export default {
|
|||||||
this.contacts
|
this.contacts
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
defineNetworkByValue(e, index) {
|
chooseNetwork(e, index) {
|
||||||
const arrNetworkMap = Object.values(this.mapNetworks);
|
this.contacts.networks[index].kind = e.currentTarget.id;
|
||||||
const value = e.target.value;
|
|
||||||
let newKind = arrNetworkMap.find((el) =>
|
|
||||||
value.includes(el.markerLink)
|
|
||||||
)?.kind;
|
|
||||||
this.contacts.networks[index].kind = newKind;
|
|
||||||
},
|
},
|
||||||
addNewContact(key) {
|
addNewContact(key) {
|
||||||
|
if (key === "networks") {
|
||||||
|
this.contacts[key].push({
|
||||||
|
filled: false,
|
||||||
|
kind: null,
|
||||||
|
username: null,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
this.contacts[key].push({
|
this.contacts[key].push({
|
||||||
kind: this.configData[key].kind,
|
kind: this.configData[key].kind,
|
||||||
username: null,
|
username: null,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
this.checkChangeInput();
|
this.checkChangeInput();
|
||||||
},
|
},
|
||||||
deleteContact(key, index) {
|
deleteContact(key, index) {
|
||||||
@@ -135,6 +152,11 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
|
.icon
|
||||||
|
&.old
|
||||||
|
color: var(--btn-blue-color)
|
||||||
|
&.new
|
||||||
|
color: var(--icon-violet-color)
|
||||||
.input-wrapper
|
.input-wrapper
|
||||||
width: 324px
|
width: 324px
|
||||||
.form-wrap
|
.form-wrap
|
||||||
|
|||||||
@@ -107,44 +107,38 @@ export const mapNetworks = {
|
|||||||
VK: {
|
VK: {
|
||||||
title: "VK",
|
title: "VK",
|
||||||
icon: "app:icon-vk",
|
icon: "app:icon-vk",
|
||||||
kind: "VK",
|
network: "VK",
|
||||||
markerLink: "vk",
|
|
||||||
},
|
},
|
||||||
TELEGRAM: {
|
TELEGRAM: {
|
||||||
title: "Telegram",
|
title: "Telegram",
|
||||||
icon: "app:icon-tg",
|
icon: "app:icon-tg",
|
||||||
kind: "TELEGRAM",
|
network: "TELEGRAM",
|
||||||
markerLink: "t.me",
|
|
||||||
},
|
},
|
||||||
GMAIL: {
|
GMAIL: {
|
||||||
title: "Gmail",
|
title: "Gmail",
|
||||||
icon: "app:icon-google",
|
icon: "app:icon-google",
|
||||||
kind: "GMAIL",
|
network: "GMAIL",
|
||||||
markerLink: "gmail",
|
|
||||||
},
|
},
|
||||||
SLACK: {
|
SLACK: {
|
||||||
title: "Slack",
|
title: "Slack",
|
||||||
icon: "app:icon-slack",
|
icon: "app:icon-slack",
|
||||||
kind: "SLACK",
|
network: "SLACK",
|
||||||
markerLink: "slack",
|
markerLink: "slack",
|
||||||
},
|
},
|
||||||
DISCORD: {
|
DISCORD: {
|
||||||
title: "Discord",
|
title: "Discord",
|
||||||
icon: "app:icon-discord",
|
icon: "app:icon-discord",
|
||||||
kind: "DISCORD",
|
network: "DISCORD",
|
||||||
markerLink: "discord",
|
|
||||||
},
|
},
|
||||||
VIBER: {
|
VIBER: {
|
||||||
title: "Viber",
|
title: "Viber",
|
||||||
icon: "wifi_calling_3",
|
icon: "wifi_calling_3",
|
||||||
kind: "VIBER",
|
network: "VIBER",
|
||||||
markerLink: "viber",
|
|
||||||
},
|
},
|
||||||
WHATS_APP: {
|
WHATS_APP: {
|
||||||
title: "WhatsApp",
|
title: "WhatsApp",
|
||||||
icon: "call",
|
icon: "call",
|
||||||
kind: "WHATS_APP",
|
network: "WHATS_APP",
|
||||||
markerLink: "wa.me",
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -245,19 +245,24 @@ const actions = {
|
|||||||
.filter((el) => !allNewContacts.find((newNet) => newNet.id === el.id))
|
.filter((el) => !allNewContacts.find((newNet) => newNet.id === el.id))
|
||||||
.map((el) => fetchWrapper.del(`general/contact/${el.id}/delete/`));
|
.map((el) => fetchWrapper.del(`general/contact/${el.id}/delete/`));
|
||||||
const request = allNewContacts
|
const request = allNewContacts
|
||||||
.map((network) => {
|
.map((contact) => {
|
||||||
let initNetwork = initContacts.find((el) => el.id === network.id);
|
let initNetwork = initContacts.find((el) => el.id === contact.id);
|
||||||
if (!network.id) {
|
if (!contact.id && contact.username && contact.kind) {
|
||||||
return fetchWrapper.post(`general/contact/create/`, {
|
return fetchWrapper.post(`general/contact/create/`, {
|
||||||
person: personId,
|
person: personId,
|
||||||
...network,
|
username: contact.username,
|
||||||
|
kind: contact.kind,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (network.id && network.username !== initNetwork.username) {
|
if (
|
||||||
return fetchWrapper.post(`general/contact/${network.id}/update/`, {
|
contact.id &&
|
||||||
|
contact.username &&
|
||||||
|
contact.username !== initNetwork.username
|
||||||
|
) {
|
||||||
|
return fetchWrapper.post(`general/contact/${contact.id}/update/`, {
|
||||||
person: personId,
|
person: personId,
|
||||||
username: network.username,
|
username: contact.username,
|
||||||
kind: network.kind,
|
kind: contact.kind,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|||||||
Reference in New Issue
Block a user