Merge branch 'ASTRA-48' into 'master'

Сделано удаление фото

See merge request andrusyakka/urban-couscous!336
This commit is contained in:
Daria Golova
2023-04-24 16:22:20 +00:00

View File

@@ -139,7 +139,7 @@ export default {
checkPassportFields(val, defaultRule) {
if (
this.passportFields.every((elem) => !this.docData.passport[elem]) &&
!this.initialDocData.passport.series
!this.initialDocData.passport?.id
) {
this.$refs.documentForm
.getValidationComponents()
@@ -200,11 +200,9 @@ export default {
let documentsFormData = new FormData();
form.getValidationComponents().forEach((elem) => {
if (!this.personDataField.includes(elem.name)) {
if (!this.approvedPassportData)
passportFormData.append(elem.name, elem.modelValue ?? "");
} else documentsFormData.append(elem.name, elem.modelValue ?? "");
});
if (!this.approvedPassportData)
this.checkChengePhoto("passport", "photo", passportFormData);
this.checkChengePhoto(
"insurance_number",
@@ -230,7 +228,13 @@ export default {
passportFormData
)
);
} else
} else {
if (this.checkPhotoDeletion("passport", "photo"))
request.push(
this.deletePhoto(
`general/identity_document/${this.initialDocData.passport?.id}/delete_photo/`
)
);
request.push(
this.sendData(
`general/identity_document/${this.initialDocData.passport?.id}/update/`,
@@ -238,6 +242,29 @@ export default {
)
);
}
}
if (
this.checkPhotoDeletion(
"insurance_number",
"photo_insurance_number"
)
)
request.push(
this.deletePhoto(
`general/person/${this.$store.state.medical?.basicData?.personalData?.id}/delete_photo_insurance_number/`
)
);
if (
this.checkPhotoDeletion(
"tax_identification_number",
"photo_tax_identification_number"
)
)
request.push(
this.deletePhoto(
`general/person/${this.$store.state.medical?.basicData?.personalData?.id}/delete_photo_tax_identification_number/`
)
);
request.push(
this.sendData(
`general/person/${this.$store.state.medical?.basicData?.personalData?.id}/update/`,
@@ -257,9 +284,18 @@ export default {
if (this.docData[updatedObjId][field]?.file)
formData.append(field, this.docData[updatedObjId][field]?.file[0]);
},
checkPhotoDeletion(updatedObjId, field) {
return (
!Object.keys(this.docData[updatedObjId][field]).length &&
this.initialDocData[updatedObjId][field]?.photo
);
},
async sendData(url, body) {
return await fetchWrapper.post(url, body, "formData");
},
async deletePhoto(url) {
return await fetchWrapper.del(url);
},
addErrorNotification(title, message) {
addNotification(title + message, title, message, "error", 5000);
},