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