[WIP] Добавил проверку на пустый поля, правка кода
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
.replace-photo.font-medium.text-base.cursor-pointer(
|
.replace-photo.font-medium.text-base.cursor-pointer(
|
||||||
v-if="isEdit",
|
v-if="isEdit",
|
||||||
@click="changeModal(insurance.insuranceKey)"
|
@click="changeModal(insurance.insuranceKey)"
|
||||||
) {{ basic[insurance.insuranceKey][field.key] ? "Заменить фото" : "Добавить фото" }}
|
) {{ basic[insurance.insuranceKey][field.key]?.photo ? "Заменить фото" : "Добавить фото" }}
|
||||||
base-modal(
|
base-modal(
|
||||||
v-if="insurance.insuranceKey === photoId"
|
v-if="insurance.insuranceKey === photoId"
|
||||||
v-model="showModal",
|
v-model="showModal",
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
span(
|
span(
|
||||||
:style="{color: 'var(--font-dark-blue-color)'}"
|
:style="{color: 'var(--font-dark-blue-color)'}"
|
||||||
) {{"\xa0" + basic?.benefit[insurance?.discount] + "%"}}
|
) {{"\xa0" + basic?.benefit[insurance?.discount] + "%"}}
|
||||||
.flex.flex-col.relative(v-else)
|
.input-container.flex.flex-col.relative(v-else)
|
||||||
base-input(
|
base-input(
|
||||||
v-model="basic[insurance.insuranceKey][field.key]",
|
v-model="basic[insurance.insuranceKey][field.key]",
|
||||||
@update:model-value="checkChangeInput",
|
@update:model-value="checkChangeInput",
|
||||||
@@ -76,10 +76,9 @@
|
|||||||
:standout="!isEdit",
|
:standout="!isEdit",
|
||||||
:outlined="isEdit",
|
:outlined="isEdit",
|
||||||
:type="field.type",
|
:type="field.type",
|
||||||
:width="278",
|
|
||||||
text-color="black"
|
text-color="black"
|
||||||
)
|
)
|
||||||
q-icon.my-auto.text-lg.label-field(
|
q-icon.my-auto.text-lg.label-field.cursor-pointer(
|
||||||
size="18px",
|
size="18px",
|
||||||
name="app:icon-copy",
|
name="app:icon-copy",
|
||||||
v-if="checkCopiedFields(field.key)",
|
v-if="checkCopiedFields(field.key)",
|
||||||
@@ -97,6 +96,8 @@ import BaseInput from "@/components/base/BaseInput.vue";
|
|||||||
import BaseModal from "@/components/base/BaseModal.vue";
|
import BaseModal from "@/components/base/BaseModal.vue";
|
||||||
import BaseUploadPhoto from "@/components/base/BaseUploadPhoto.vue";
|
import BaseUploadPhoto from "@/components/base/BaseUploadPhoto.vue";
|
||||||
import BaseCategorySelection from "@/components/base/BaseCategorySelection.vue";
|
import BaseCategorySelection from "@/components/base/BaseCategorySelection.vue";
|
||||||
|
import { checkChangeData } from "@/shared/utils/changesObjects";
|
||||||
|
import { addNotification } from "@/components/Notifications/notificationContext";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "InsuranceForm",
|
name: "InsuranceForm",
|
||||||
@@ -141,7 +142,6 @@ export default {
|
|||||||
localStorage.removeItem("searchBenefit", text);
|
localStorage.removeItem("searchBenefit", text);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
checkCopiedFields(key) {
|
checkCopiedFields(key) {
|
||||||
return !this.isEdit && this.copiedFields.some((elem) => elem === key);
|
return !this.isEdit && this.copiedFields.some((elem) => elem === key);
|
||||||
},
|
},
|
||||||
@@ -149,11 +149,8 @@ export default {
|
|||||||
navigator.clipboard.writeText(text);
|
navigator.clipboard.writeText(text);
|
||||||
},
|
},
|
||||||
selectCategory(str) {
|
selectCategory(str) {
|
||||||
return str && str.length > 30
|
if (str) return str.length > 30 ? str.substr(0, 30) + "..." : str;
|
||||||
? str.substr(0, 30) + "..."
|
return "Выберите категорию";
|
||||||
: !str
|
|
||||||
? "Выберите категорию"
|
|
||||||
: str;
|
|
||||||
},
|
},
|
||||||
saveCategories(obj) {
|
saveCategories(obj) {
|
||||||
this.showModalCategories = false;
|
this.showModalCategories = false;
|
||||||
@@ -225,10 +222,9 @@ export default {
|
|||||||
) {
|
) {
|
||||||
insuranceFormDataDMS.append("title", "DMS");
|
insuranceFormDataDMS.append("title", "DMS");
|
||||||
insuranceFormDataDMS.append("person", personal.id);
|
insuranceFormDataDMS.append("person", personal.id);
|
||||||
return fetchWrapper.post(
|
return this.sendData(
|
||||||
`general/insurance_policy/create/`,
|
`general/insurance_policy/create/`,
|
||||||
insuranceFormDataDMS,
|
insuranceFormDataDMS
|
||||||
"formData"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
@@ -239,41 +235,53 @@ export default {
|
|||||||
) {
|
) {
|
||||||
insuranceFormDataOMS.append("title", "OMS");
|
insuranceFormDataOMS.append("title", "OMS");
|
||||||
insuranceFormDataOMS.append("person", personal.id);
|
insuranceFormDataOMS.append("person", personal.id);
|
||||||
return fetchWrapper.post(
|
return this.sendData(
|
||||||
`general/insurance_policy/create/`,
|
`general/insurance_policy/create/`,
|
||||||
insuranceFormDataOMS,
|
insuranceFormDataOMS
|
||||||
"formData"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
checkChangeData(this.initDataBasic.insuranceDMS, insuranceDMS) &&
|
||||||
key === "insuranceDMS" &&
|
key === "insuranceDMS" &&
|
||||||
insuranceDMS.id &&
|
insuranceDMS.id
|
||||||
(insuranceDMS.number ||
|
|
||||||
insuranceDMS.series ||
|
|
||||||
insuranceDMS.photo.file)
|
|
||||||
) {
|
) {
|
||||||
insuranceFormDataDMS.append("title", "DMS");
|
insuranceFormDataDMS.append("title", "DMS");
|
||||||
return fetchWrapper.post(
|
return this.sendData(
|
||||||
`general/insurance_policy/${insuranceDMS.id}/update/`,
|
`general/insurance_policy/${insuranceDMS.id}/update/`,
|
||||||
insuranceFormDataDMS,
|
insuranceFormDataDMS
|
||||||
"formData"
|
);
|
||||||
|
} else if (
|
||||||
|
insuranceDMS.id &&
|
||||||
|
(!insuranceDMS.series || !insuranceDMS.number)
|
||||||
|
) {
|
||||||
|
this.addErrorNotification(
|
||||||
|
"Ошибка заполнения формы ДМС",
|
||||||
|
"Пожалуйста заполните все поля"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
checkChangeData(this.initDataBasic.insuranceOMS, insuranceOMS) &&
|
||||||
key === "insuranceOMS" &&
|
key === "insuranceOMS" &&
|
||||||
insuranceOMS.id &&
|
insuranceOMS.id
|
||||||
(insuranceOMS.number ||
|
|
||||||
insuranceOMS.series ||
|
|
||||||
insuranceOMS.photo.file)
|
|
||||||
) {
|
) {
|
||||||
insuranceFormDataOMS.append("title", "OMS");
|
insuranceFormDataOMS.append("title", "OMS");
|
||||||
return fetchWrapper.post(
|
return this.sendData(
|
||||||
`general/insurance_policy/${insuranceOMS.id}/update/`,
|
`general/insurance_policy/${insuranceOMS.id}/update/`,
|
||||||
insuranceFormDataOMS,
|
insuranceFormDataOMS
|
||||||
"formData"
|
);
|
||||||
|
} else if (
|
||||||
|
insuranceOMS.id &&
|
||||||
|
(!insuranceOMS.series || !insuranceOMS.number)
|
||||||
|
) {
|
||||||
|
this.addErrorNotification(
|
||||||
|
"Ошибка заполнения формы ОМС",
|
||||||
|
"Пожалуйста заполните все поля"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (key === "benefit" && benefit.id) {
|
if (
|
||||||
|
checkChangeData(this.initDataBasic.benefit, benefit) &&
|
||||||
|
key === "benefit"
|
||||||
|
) {
|
||||||
fetchWrapper.post(`general/person/${personal.id}/update/`, {
|
fetchWrapper.post(`general/person/${personal.id}/update/`, {
|
||||||
benefit: benefit.id,
|
benefit: benefit.id,
|
||||||
});
|
});
|
||||||
@@ -282,16 +290,22 @@ export default {
|
|||||||
benefit.photo.photo !== this.initDataBasic.benefit.photo.photo
|
benefit.photo.photo !== this.initDataBasic.benefit.photo.photo
|
||||||
) {
|
) {
|
||||||
benefitFormData.append("photo_benefit", benefit.photo.file[0]);
|
benefitFormData.append("photo_benefit", benefit.photo.file[0]);
|
||||||
return fetchWrapper.post(
|
return this.sendData(
|
||||||
`general/person/${personal.id}/update/`,
|
`general/person/${personal.id}/update/`,
|
||||||
benefitFormData,
|
benefitFormData
|
||||||
"formData"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return request;
|
return request;
|
||||||
},
|
},
|
||||||
|
addErrorNotification(title, message) {
|
||||||
|
addNotification(title + message, title, message, "error", 5000);
|
||||||
|
},
|
||||||
|
|
||||||
|
async sendData(url, body) {
|
||||||
|
return await fetchWrapper.post(url, body, "formData");
|
||||||
|
},
|
||||||
cancelEdit() {
|
cancelEdit() {
|
||||||
this.$store.dispatch("returnInitData");
|
this.$store.dispatch("returnInitData");
|
||||||
this.isEdit = false;
|
this.isEdit = false;
|
||||||
@@ -337,6 +351,9 @@ export default {
|
|||||||
.avatar
|
.avatar
|
||||||
height: 100%
|
height: 100%
|
||||||
|
|
||||||
|
.input-container
|
||||||
|
width: 302px
|
||||||
|
|
||||||
.replace-photo
|
.replace-photo
|
||||||
color: var(--btn-blue-color)
|
color: var(--btn-blue-color)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user