[WIP] Добавил возможность сохранения аватара клиента
This commit is contained in:
@@ -4,8 +4,16 @@
|
|||||||
span.title.text-xl.font-bold.px-4 Создание клиента
|
span.title.text-xl.font-bold.px-4 Создание клиента
|
||||||
.flex.gap-x-4.h-fit.px-4
|
.flex.gap-x-4.h-fit.px-4
|
||||||
.flex.gap-x-3.w-full
|
.flex.gap-x-3.w-full
|
||||||
base-button.relative(:rounded="true", :secondary="true", :size="40", @click="changeOpenPopup")
|
base-button.relative(
|
||||||
.icon-download.text-xl
|
:rounded="true",
|
||||||
|
:secondary="true",
|
||||||
|
:size="40",
|
||||||
|
@click="changeOpenPopup",
|
||||||
|
v-for="img in image"
|
||||||
|
)
|
||||||
|
.icon-download.text-xl(v-if="img === defaultIcon")
|
||||||
|
.flex.w-10.h-10(v-else)
|
||||||
|
img.current-avatar(:src="img")
|
||||||
base-popup.right-5.top-7(v-if="showPopup", :width="230")
|
base-popup.right-5.top-7(v-if="showPopup", :width="230")
|
||||||
.flex.items-center.gap-x-2
|
.flex.items-center.gap-x-2
|
||||||
img(src="@/assets/icons/computer.svg")
|
img(src="@/assets/icons/computer.svg")
|
||||||
@@ -13,18 +21,20 @@
|
|||||||
.flex.items-center.gap-x-2
|
.flex.items-center.gap-x-2
|
||||||
img(src="@/assets/icons/camera.svg")
|
img(src="@/assets/icons/camera.svg")
|
||||||
span.text-smm Сделать фото
|
span.text-smm Сделать фото
|
||||||
base-modal(v-model="showModal", title="Загрузить изображение мидла")
|
base-modal(v-model="showModal", title="Загрузить изображение")
|
||||||
.form-avatar.flex.flex-col.items-center.justify-center
|
.flex.flex-col.items-center.justify-center(
|
||||||
.avatar-block.flex.relative.flex-row
|
:style="{padding: '153px 370px'}"
|
||||||
|
)
|
||||||
|
.avatar-wrapper.flex.relative
|
||||||
input.input(
|
input.input(
|
||||||
type="file",
|
type="file",
|
||||||
id="image-upload",
|
id="image-upload",
|
||||||
accept="image/*",
|
accept="image/*",
|
||||||
@change="(e) => previewImages(e)"
|
@change="(e) => previewImages(e)"
|
||||||
)
|
)
|
||||||
.avatar.absolute(v-for="img in image")
|
.avatar.flex.absolute.items-center.gap-x-6(v-for="img in image")
|
||||||
img.avatar(for="image-upload", :src="img", v-if="img")
|
img.avatar(for="image-upload", :src="img", v-if="img")
|
||||||
base-button(:rounded="true", :secondary="true", :size="48", @click="closeModal")
|
base-button(:rounded="true", :size="48", @click="closeModal")
|
||||||
.icon-ok
|
.icon-ok
|
||||||
base-input.w-full(v-model:value="infoClient.basic.full_name" placeholder="ФИО*")
|
base-input.w-full(v-model:value="infoClient.basic.full_name" placeholder="ФИО*")
|
||||||
.flex.flex-col.flex-auto.l.gap-y-8
|
.flex.flex-col.flex-auto.l.gap-y-8
|
||||||
@@ -197,9 +207,11 @@ export default {
|
|||||||
label: "-",
|
label: "-",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
defaultIcon: addImageIcon,
|
||||||
showModal: false,
|
showModal: false,
|
||||||
showPopup: false,
|
showPopup: false,
|
||||||
image: [addImageIcon],
|
image: [addImageIcon],
|
||||||
|
imageData: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -213,7 +225,6 @@ export default {
|
|||||||
closeModal() {
|
closeModal() {
|
||||||
this.showModal = false;
|
this.showModal = false;
|
||||||
this.showPopup = false;
|
this.showPopup = false;
|
||||||
this.image = [addImageIcon];
|
|
||||||
},
|
},
|
||||||
previewImages(event) {
|
previewImages(event) {
|
||||||
this.image = [];
|
this.image = [];
|
||||||
@@ -225,6 +236,7 @@ export default {
|
|||||||
};
|
};
|
||||||
reader.readAsDataURL(pictures[i]);
|
reader.readAsDataURL(pictures[i]);
|
||||||
}
|
}
|
||||||
|
this.imageData = [...this.imageData, ...event.target.files];
|
||||||
},
|
},
|
||||||
createIdentityDocument(id) {
|
createIdentityDocument(id) {
|
||||||
Object.keys(
|
Object.keys(
|
||||||
@@ -247,16 +259,21 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
postNewClient() {
|
postNewClient() {
|
||||||
let sentData = {
|
const formData = new FormData();
|
||||||
full_name: this.infoClient.basic.full_name,
|
this.imageData.forEach((e) => {
|
||||||
};
|
formData.append("photo", e);
|
||||||
|
formData.append("full_name", this.infoClient.basic.full_name);
|
||||||
|
});
|
||||||
if (this.infoClient.basic.birth_date)
|
if (this.infoClient.basic.birth_date)
|
||||||
sentData.birth_date = this.infoClient.basic.birth_date;
|
formData.append("birth_date", this.infoClient.basic.birth_date);
|
||||||
|
|
||||||
let foundElement = this.prioritySettings.settings.find(
|
let foundElement = this.prioritySettings.settings.find(
|
||||||
(el) => el.text === this.infoClient.basic.priority
|
(el) => el.text === this.infoClient.basic.priority
|
||||||
);
|
);
|
||||||
if (foundElement) sentData.priority = foundElement.priority;
|
if (foundElement) formData.append("priority", foundElement.priority);
|
||||||
fetchWrapper.post("general/person/create/", sentData).then((result) => {
|
fetchWrapper
|
||||||
|
.post("general/person/create/", formData, "formData")
|
||||||
|
.then((result) => {
|
||||||
this.createIdentityDocument(result.id);
|
this.createIdentityDocument(result.id);
|
||||||
this.createAddress(result.id);
|
this.createAddress(result.id);
|
||||||
});
|
});
|
||||||
@@ -297,6 +314,7 @@ export default {
|
|||||||
changeOpenModal() {
|
changeOpenModal() {
|
||||||
this.showModal = true;
|
this.showModal = true;
|
||||||
this.showPopup = false;
|
this.showPopup = false;
|
||||||
|
this.image = [addImageIcon];
|
||||||
},
|
},
|
||||||
changeOpenPopup() {
|
changeOpenPopup() {
|
||||||
this.showPopup = true;
|
this.showPopup = true;
|
||||||
@@ -345,15 +363,14 @@ export default {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
check() {
|
|
||||||
this.showPopup = false;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
showModal: function () {
|
showModal: function () {
|
||||||
if (this.showModal === false) {
|
if (this.showModal === false) {
|
||||||
this.check();
|
this.closeModal();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -365,8 +382,10 @@ export default {
|
|||||||
width: 634px
|
width: 634px
|
||||||
min-height: 700px
|
min-height: 700px
|
||||||
box-shadow: var(--default-shadow)
|
box-shadow: var(--default-shadow)
|
||||||
|
|
||||||
.title
|
.title
|
||||||
color: var(--font-dark-blue-color)
|
color: var(--font-dark-blue-color)
|
||||||
|
|
||||||
.export-avatar
|
.export-avatar
|
||||||
min-width: 40px
|
min-width: 40px
|
||||||
height: 40px
|
height: 40px
|
||||||
@@ -376,6 +395,7 @@ export default {
|
|||||||
&:hover
|
&:hover
|
||||||
color: var(--default-white)
|
color: var(--default-white)
|
||||||
background-color: var(--btn-blue-color)
|
background-color: var(--btn-blue-color)
|
||||||
|
|
||||||
.title-info
|
.title-info
|
||||||
color: var(--font-grey-color)
|
color: var(--font-grey-color)
|
||||||
border-bottom: 1.5px solid var(--font-grey-color)
|
border-bottom: 1.5px solid var(--font-grey-color)
|
||||||
@@ -385,27 +405,28 @@ export default {
|
|||||||
&.active
|
&.active
|
||||||
color: var(--btn-blue-color)
|
color: var(--btn-blue-color)
|
||||||
border-bottom: 1.5px solid var(--btn-blue-color)
|
border-bottom: 1.5px solid var(--btn-blue-color)
|
||||||
.form-avatar
|
|
||||||
width: 1221px
|
.avatar-wrapper
|
||||||
height: 793px
|
|
||||||
.avatar-block
|
|
||||||
width: 400px
|
width: 400px
|
||||||
height: 400px
|
height: 400px
|
||||||
border-radius: 50%
|
border-radius: 50%
|
||||||
|
|
||||||
.input
|
.input
|
||||||
width: 100%
|
width: 100%
|
||||||
height: 100%
|
height: 100%
|
||||||
border-radius: 50%
|
border-radius: 50%
|
||||||
overflow: hidden
|
|
||||||
z-index: 5
|
z-index: 5
|
||||||
opacity: 0
|
opacity: 0
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
|
|
||||||
.avatar
|
.avatar
|
||||||
cursor: pointer
|
|
||||||
width: 100%
|
|
||||||
height: 100%
|
height: 100%
|
||||||
border-radius: 50%
|
border-radius: 50%
|
||||||
// background-image: url("../../assets/icons/photo.svg")
|
|
||||||
|
.current-avatar
|
||||||
|
cursor: pointer
|
||||||
|
height: 100%
|
||||||
|
border-radius: 50%
|
||||||
background-size: cover
|
background-size: cover
|
||||||
background-repeat: no-repeat
|
background-repeat: no-repeat
|
||||||
background-position: center
|
background-position: center
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.section-wrapper.flex.flex-col.h-fit.cursor-pointer(
|
.section-wrapper.flex.flex-col.h-fit.cursor-pointer(
|
||||||
@click="changeOpenCard",
|
|
||||||
v-click-outside="clickOutside"
|
|
||||||
:style="{flexDirection:settings[section].rowFlex && 'row', width: settings[section].width + 'px', height: settings[section].height + 'px', background: changeBackground}"
|
:style="{flexDirection:settings[section].rowFlex && 'row', width: settings[section].width + 'px', height: settings[section].height + 'px', background: changeBackground}"
|
||||||
)
|
)
|
||||||
.section-header.flex.items-center.justify-between.pl-4.pr-3(:class="{small:settings[section].rowFlex}")
|
.section-header.flex.items-center.justify-between.pl-4.pr-3(:class="{small:settings[section].rowFlex}")
|
||||||
@@ -17,12 +15,12 @@
|
|||||||
)
|
)
|
||||||
.icon-ok.text-xsm(class="pt-[3px]")
|
.icon-ok.text-xsm(class="pt-[3px]")
|
||||||
.edit.icon-edit.cursor-pointer.text-sm(
|
.edit.icon-edit.cursor-pointer.text-sm(
|
||||||
v-if="openCard && !isChange",
|
v-if="!isChange",
|
||||||
@click="changeClientData"
|
@click="changeClientData"
|
||||||
)
|
)
|
||||||
.flex.relative
|
.flex.relative
|
||||||
base-button(
|
base-button(
|
||||||
v-if="settings[section].addFile && openCard",
|
v-if="settings[section].addFile",
|
||||||
@click="openAddingWrap",
|
@click="openAddingWrap",
|
||||||
:rounded="true",
|
:rounded="true",
|
||||||
:outlined="true",
|
:outlined="true",
|
||||||
@@ -193,12 +191,11 @@ export default {
|
|||||||
isOpenPackage: false,
|
isOpenPackage: false,
|
||||||
isOpenAddDoc: false,
|
isOpenAddDoc: false,
|
||||||
showModal: false,
|
showModal: false,
|
||||||
openCard: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
changeBackground() {
|
changeBackground() {
|
||||||
return this.openCard || this.isChange
|
return this.isChange
|
||||||
? "var(--light-grey-bg-color)"
|
? "var(--light-grey-bg-color)"
|
||||||
: "var(--default-white)";
|
: "var(--default-white)";
|
||||||
},
|
},
|
||||||
@@ -234,15 +231,8 @@ export default {
|
|||||||
this.showModal = false;
|
this.showModal = false;
|
||||||
this.saveDocs();
|
this.saveDocs();
|
||||||
},
|
},
|
||||||
changeOpenCard() {
|
|
||||||
this.openCard = true;
|
|
||||||
},
|
|
||||||
clickOutside() {
|
|
||||||
this.openCard = false;
|
|
||||||
},
|
|
||||||
changeDoc() {
|
changeDoc() {
|
||||||
this.isChange = false;
|
this.isChange = false;
|
||||||
this.openCard = false;
|
|
||||||
if (this.section === "pass") {
|
if (this.section === "pass") {
|
||||||
this.docId ? this.updateDocument() : this.createDocument();
|
this.docId ? this.updateDocument() : this.createDocument();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
:value="dataClient",
|
:value="dataClient",
|
||||||
:avatar="dataClient.avatar",
|
:avatar="dataClient.avatar",
|
||||||
:avatar-color="dataClient.color",
|
:avatar-color="dataClient.color",
|
||||||
|
:photo="dataClient.photo"
|
||||||
:is-open-change="isOpenChange",
|
:is-open-change="isOpenChange",
|
||||||
:width="columnBody.find(el => el.name === 'fullName').width"
|
:width="columnBody.find(el => el.name === 'fullName').width"
|
||||||
)
|
)
|
||||||
@@ -180,6 +181,7 @@ export default {
|
|||||||
contacts: [...this.client.contacts],
|
contacts: [...this.client.contacts],
|
||||||
avatar: `${this.client.last_name[0]}${this.client.first_name[0]}`,
|
avatar: `${this.client.last_name[0]}${this.client.first_name[0]}`,
|
||||||
color: this.client.color,
|
color: this.client.color,
|
||||||
|
photo: this.client.photo,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.flex.box-border.px-4.items-center.gap-x-3.w-full.text-sm(:style="{ minWidth : width + 'px' }")
|
.flex.box-border.px-4.items-center.gap-x-3.w-full.text-sm(:style="{ minWidth : width + 'px' }")
|
||||||
BaseAvatar(:size="36", :color="avatarColor") {{avatar}}
|
base-avatar(:size="36", :color="avatarColor", v-if="!photo") {{avatar}}
|
||||||
|
base-avatar(:size="36", v-else)
|
||||||
|
img.h-full(:src="url + photo")
|
||||||
span.font-semibold(v-if="!isOpenChange") {{value.fullName}}
|
span.font-semibold(v-if="!isOpenChange") {{value.fullName}}
|
||||||
base-input(v-if="isOpenChange" type="text" v-model:value="value.fullName" :width-input="300")
|
base-input(v-if="isOpenChange" type="text" v-model:value="value.fullName" :width-input="300")
|
||||||
</template>
|
</template>
|
||||||
@@ -14,11 +16,17 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
value: Object,
|
value: Object,
|
||||||
avatar: String,
|
avatar: String,
|
||||||
|
photo: String,
|
||||||
width: Number,
|
width: Number,
|
||||||
imgUrl: String,
|
imgUrl: String,
|
||||||
isOpenChange: Boolean,
|
isOpenChange: Boolean,
|
||||||
avatarColor: String,
|
avatarColor: String,
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
url: "http://45.84.227.122:8080",
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user