[WIP] Добавил delete photo

This commit is contained in:
megavrilinvv
2023-04-25 14:57:44 +03:00
parent 506044b59a
commit 0a3028ecdc

View File

@@ -195,6 +195,7 @@ export default {
this.showModal = false;
this.isCheckChange = true;
},
updateBasicData() {
let insuranceDMS = this.basic.insuranceDMS;
let insuranceOMS = this.basic.insuranceOMS;
@@ -261,6 +262,12 @@ export default {
key === "insuranceDMS" &&
insuranceDMS.id
) {
this.checkedPhoto(
insuranceDMS.photo,
insuranceDMS.id,
"insurance_policy",
"delete_photo"
);
insuranceFormDataDMS.append("title", "DMS");
return this.sendData(
`general/insurance_policy/${insuranceDMS.id}/update/`,
@@ -280,6 +287,12 @@ export default {
key === "insuranceOMS" &&
insuranceOMS.id
) {
this.checkedPhoto(
insuranceOMS.photo,
insuranceOMS.id,
"insurance_policy",
"delete_photo"
);
insuranceFormDataOMS.append("title", "OMS");
return this.sendData(
`general/insurance_policy/${insuranceOMS.id}/update/`,
@@ -298,6 +311,12 @@ export default {
checkChangeData(this.initDataBasic.benefit, benefit) &&
key === "benefit"
) {
this.checkedPhoto(
benefit.photo,
personal.id,
"person",
"delete_photo_benefit"
);
fetchWrapper.post(`general/person/${personal.id}/update/`, {
benefit: benefit.id,
});
@@ -315,6 +334,11 @@ export default {
});
return request;
},
checkedPhoto(photo, id, key, title) {
if (!photo?.photo) {
return this.delPhoto(`general/${key}/${id}/${title}/`);
}
},
addErrorNotification(title, message) {
addNotification(title + message, title, message, "error", 5000);
},
@@ -322,6 +346,9 @@ export default {
async sendData(url, body) {
return await fetchWrapper.post(url, body, "formData");
},
async delPhoto(url) {
return await fetchWrapper.del(url);
},
cancelEdit() {
this.$store.dispatch("returnInitData");
this.isEdit = false;