Merge pull request #149 from dderbentsov/UC-41

[WIP] Добавил иконки документов и возможность их удаления
This commit is contained in:
frontgavrilin
2022-11-22 17:57:48 +03:00
committed by GitHub
3 changed files with 24 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14.9268 2.52721C14.5893 2.18964 14.1314 2 13.654 2V8.14561C13.654 8.69789 14.1017 9.14561 14.654 9.14561H20.3996C20.3996 8.66822 20.21 8.21038 19.8724 7.87282L14.9268 2.52721Z" fill="#FFA0A0"/> <path d="M14.9272 2.52721C14.5896 2.18964 14.1318 2 13.6544 2V8.14561C13.6544 8.69789 14.1021 9.14561 14.6544 9.14561H20.4C20.4 8.66822 20.2104 8.21038 19.8728 7.87282L14.9272 2.52721Z" fill="#FFA0A0"/>
<path d="M13.654 2H5.39961H4.59961C4.04732 2 3.59961 2.44772 3.59961 3V20.2V21C3.59961 21.5523 4.04732 22 4.59961 22H5.39961H18.5996H19.3996C19.9519 22 20.3996 21.5523 20.3996 21V20.2V9.14561H14.654C14.1017 9.14561 13.654 8.69789 13.654 8.14561V2Z" fill="#FF6969"/> <path d="M13.6544 2H5.40001H4.60001C4.04772 2 3.60001 2.44772 3.60001 3V20.2V21C3.60001 21.5523 4.04772 22 4.60001 22H5.40001H18.6H19.4C19.9523 22 20.4 21.5523 20.4 21V20.2V9.14561H14.6544C14.1021 9.14561 13.6544 8.69789 13.6544 8.14561V2Z" fill="#FF6969"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 573 B

After

Width:  |  Height:  |  Size: 564 B

View File

@@ -85,15 +85,16 @@
) )
.flex(v-if="item.name && !isChange") .flex(v-if="item.name && !isChange")
span.text-sm.w-fit {{item.title}} span.text-sm.w-fit {{item.title}}
.flex.items-center .flex.items-center(v-if="item.title")
.icon-cancel.cancel.cursor-pointer.pr-3.text-xsm( .icon-cancel.cancel.cursor-pointer.pr-3.text-xsm(
v-if="isChange", v-if="isChange",
:id="item.id", :id="item.id",
@click="deleteDoc(item.id)" @click="deleteDoc(item.id)"
) )
img(:src="iconDictionary[item?.document?.split('.')[1]]") .flex.gap-x-2.items-center
span.text-sm {{item.title}} img(:src="iconDictionary[item?.document?.substr(item.document.lastIndexOf('.') + 1)]")
span.text-sm(v-if="item.document") {{`. ${item?.document?.split(".")[1]}`}} span.text-sm {{item.title}}
span.text-sm(v-if="item.document") {{`. ${item?.document?.substr(item.document.lastIndexOf(".") + 1)}`}}
.section-add-doc.flex.justify-center.items-center.cursor-pointer( .section-add-doc.flex.justify-center.items-center.cursor-pointer(
v-else, v-else,
@click="openAddDoc" @click="openAddDoc"

View File

@@ -276,6 +276,7 @@ export default {
fetchWrapper fetchWrapper
.get(`general/person/${id}/detail/`) .get(`general/person/${id}/detail/`)
.then((data) => this.saveClientDetail(data)); .then((data) => this.saveClientDetail(data));
this.fetchAttachment();
}, },
saveClientDetail(data) { saveClientDetail(data) {
this.saveIdentityDocument( this.saveIdentityDocument(
@@ -284,7 +285,20 @@ export default {
) )
); );
this.saveAddress(data.address[0]); this.saveAddress(data.address[0]);
this.saveAttachments([...data.attachments]); },
fetchAttachment() {
fetchWrapper
.get("general/attachment/")
.then((data) => this.saveAttachment(data.results));
},
saveAttachment(data) {
this.dataAttachments = data.filter((e) => e.person_id.id === this.id);
if (this.dataAttachments[0]?.id) {
this.lackAttachments = true;
this.attachmentId = this.dataAttachments.id;
} else {
this.lackAttachments = false;
}
}, },
saveIdentityDocument(data) { saveIdentityDocument(data) {
if (data?.id) { if (data?.id) {
@@ -366,16 +380,6 @@ export default {
.then(() => this.fetchClientDetail(this.id)); .then(() => this.fetchClientDetail(this.id));
this.clearAddress(); this.clearAddress();
}, },
saveAttachments(data) {
this.dataAttachments = [""];
if (data.find((e) => e.id)) {
this.dataAttachments = [...data];
this.lackAttachments = true;
this.attachmentId = this.dataAttachments[0].id;
} else {
this.lackAttachments = false;
}
},
openPopup(e) { openPopup(e) {
e.target.focus(); e.target.focus();
e.stopPropagation(); e.stopPropagation();
@@ -391,9 +395,9 @@ export default {
saveNewDoc(data) { saveNewDoc(data) {
this.dataAttachments = [...this.dataDetail, ...data]; this.dataAttachments = [...this.dataDetail, ...data];
}, },
deleteDoc(id) { deleteDoc(attachmentId) {
fetchWrapper fetchWrapper
.del(`general/attachment/${id}/delete/`) .del(`general/attachment/${attachmentId}/delete/`)
.then(() => this.fetchClientDetail(this.id)); .then(() => this.fetchClientDetail(this.id));
}, },
postCreateAddress() { postCreateAddress() {