WIP Сделала валидацию на страховках
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
v-if="field.type === 'date'",
|
||||
v-model="docData[data.dataKey][field.key]",
|
||||
:name="data.dataKey + ':' + field.key",
|
||||
@update:model-value="checkChangeDocData",
|
||||
@update:model-value="checkChangeDocData(data.dataKey)",
|
||||
:readonly="!isEdit",
|
||||
:width="302",
|
||||
:mask="field?.inputMask",
|
||||
@@ -57,12 +57,12 @@
|
||||
v-if="field.type === 'text'",
|
||||
v-model="docData[data.dataKey][field.key]",
|
||||
:name="data.dataKey + ':' + field.key",
|
||||
@update:model-value="checkChangeDocData",
|
||||
@update:model-value="checkChangeDocData(data.dataKey)",
|
||||
:readonly="!isEdit",
|
||||
:type="field.type",
|
||||
:width="302",
|
||||
:mask="field?.inputMask",
|
||||
:rule="[(val) => !personDataField.includes(data.dataKey + ':' + field.key) ? checkPassportFields(val, field.rules) : field.rules(val)]",
|
||||
:rule="[(val) => !personDataField.includes(data.dataKey + ':' + field.key) ? checkPassportFields(val, field.rules) : field.rules(val, initialDocData?.[data.dataKey]?.id)]",
|
||||
size="M"
|
||||
)
|
||||
.icon-copy.my-auto.text-lg.label-field.cursor-pointer(
|
||||
@@ -146,13 +146,6 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
initialDocData() {
|
||||
// const { passport, insurance_number, tax_identification_number } =
|
||||
// this.$store.state.medical.documents;
|
||||
// return {
|
||||
// passport: passport,
|
||||
// insurance_number: insurance_number,
|
||||
// tax_identification_number: tax_identification_number,
|
||||
// };
|
||||
return this.$store.state.medical.documents;
|
||||
},
|
||||
passportFields() {
|
||||
@@ -205,8 +198,11 @@ export default {
|
||||
openEdit() {
|
||||
this.isEdit = true;
|
||||
},
|
||||
checkChangeDocData() {
|
||||
this.isCheckChange = checkChangeData(this.initialDocData, this.docData);
|
||||
checkChangeDocData(key) {
|
||||
this.isCheckChange = checkChangeData(
|
||||
this.initialDocData?.[key],
|
||||
this.docData?.[key]
|
||||
);
|
||||
},
|
||||
openModal(id) {
|
||||
this.photoId = id;
|
||||
@@ -235,6 +231,7 @@ export default {
|
||||
Object.keys(this.docData).forEach((elem) => {
|
||||
this.checkChangePhoto(elem, "attachments");
|
||||
let newData = JSON.parse(JSON.stringify(this.docData[elem]));
|
||||
console.log("prep", newData);
|
||||
newData.attachments = {};
|
||||
if (!checkChangeData(this.initialDocData?.[elem], newData)) return;
|
||||
delete newData.id;
|
||||
@@ -247,17 +244,20 @@ export default {
|
||||
}
|
||||
delete newData.attachments;
|
||||
if (!this.initialDocData?.[elem]?.id) {
|
||||
console.log("post", newData);
|
||||
newData.person_id =
|
||||
this.$store.state.medical?.basicData?.personalData?.id;
|
||||
console.log("create", newData);
|
||||
request.push(this.createData("documents/", newData));
|
||||
} else console.log("create", newData);
|
||||
request.push(
|
||||
this.updateData(
|
||||
`documents/${this.initialDocData?.[elem]?.id}`,
|
||||
newData
|
||||
)
|
||||
);
|
||||
//request.push(this.createData("documents/", newData));
|
||||
} else {
|
||||
console.log("create", newData);
|
||||
// request.push(
|
||||
// this.updateData(
|
||||
// `documents/${this.initialDocData?.[elem]?.id}`,
|
||||
// newData
|
||||
// )
|
||||
// );
|
||||
}
|
||||
});
|
||||
Promise.allSettled(request).then(() => {
|
||||
this.getMedicalCardData(this.$route.params.id);
|
||||
@@ -310,6 +310,7 @@ export default {
|
||||
JSON.stringify(tax_identification_number)
|
||||
),
|
||||
};
|
||||
console.log(this.docData);
|
||||
} else this.docData = this.initializationData;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
:save="saveChange",
|
||||
:cancel="cancelEdit"
|
||||
)
|
||||
.form-wrap.gap-24.w-full
|
||||
q-form.form-wrap.gap-24.w-full(ref="insuranceForm", :no-error-focus="true")
|
||||
.flex.flex-col.gap-4(v-for="insurance in insuranceConfig", :key="insurance.insuranceKey")
|
||||
.font-semibold.text-sm.whitespace-nowrap {{insurance.insuranceLabel}}
|
||||
.flex.w-full.justify-between.items-center.gap-4(
|
||||
@@ -17,10 +17,10 @@
|
||||
:style="{marginTop: field.label === 'Документы' ? '20px' : null}"
|
||||
)
|
||||
.label-field.font-sm.text-sm.whitespace-nowrap {{`${field.label} :`}}
|
||||
.avatar-field.flex.gap-3.items-center.h-10.w-10(v-if="field.type === 'avatar'")
|
||||
.flex.w-10.h-10.relative(v-if="basic[insurance.insuranceKey][field.key]?.photo")
|
||||
.avatar-field.flex.gap-3.items-center.h-10.w-10(v-if="field.type === 'attachments'")
|
||||
.flex.w-10.h-10.relative(v-if="insuranceData[insurance.insuranceKey][field.key]?.photo")
|
||||
img.rounded.avatar.object-cover(
|
||||
:src="basic[insurance.insuranceKey][field.key].photo",
|
||||
:src="insuranceData[insurance.insuranceKey][field.key]?.photo",
|
||||
alt="AV"
|
||||
)
|
||||
q-badge.delete(
|
||||
@@ -29,11 +29,11 @@
|
||||
@click="removeImage(insurance?.insuranceKey, field?.key)",
|
||||
rounded
|
||||
)
|
||||
q-icon.icon-cancel(name="app:cancel", size="8px")
|
||||
q-icon(name="app:icon-cancel", size="8px")
|
||||
.replace-photo.font-medium.text-base.cursor-pointer(
|
||||
v-if="isEdit",
|
||||
@click="changeModal(insurance.insuranceKey)"
|
||||
) {{ basic[insurance.insuranceKey][field.key]?.photo ? "Заменить фото" : "Добавить фото" }}
|
||||
) {{ insuranceData[insurance.insuranceKey][field.key]?.photo ? "Заменить фото" : "Добавить фото" }}
|
||||
base-modal(
|
||||
v-if="insurance.insuranceKey === photoId"
|
||||
v-model="showModal",
|
||||
@@ -41,7 +41,7 @@
|
||||
)
|
||||
base-upload-photo(
|
||||
:key="insurance.insuranceKey"
|
||||
v-model="basic[photoId][field.key]"
|
||||
v-model="insuranceData[photoId][field.key]"
|
||||
:confirm-upload="confirmChangePhoto"
|
||||
)
|
||||
.category.flex.h-10.relative.gap-x-2(v-else-if="field.type === 'select'")
|
||||
@@ -75,14 +75,16 @@
|
||||
span(
|
||||
:style="{color: 'var(--font-dark-blue-color)'}"
|
||||
) {{"\xa0" + basic?.benefit[insurance?.discount] + "%"}}
|
||||
.input-container.flex.flex-col.relative(v-else)
|
||||
.input-container.flex.flex-col.relative(v-if="field.type === 'text'")
|
||||
base-input(
|
||||
v-model="insuranceData[insurance.insuranceKey][field.key]",
|
||||
@update:model-value="checkChangeInput",
|
||||
@update:model-value="checkChangeInput(insurance.insuranceKey)",
|
||||
:mask="field?.inputMask",
|
||||
:readonly="!isEdit",
|
||||
:type="field.type",
|
||||
size="M"
|
||||
size="M",
|
||||
:name="insurance.insuranceKey + ':' + field.key",
|
||||
:rule="[(val) => checkFields(val, insurance.insuranceKey, field.key, field.rules)]"
|
||||
)
|
||||
q-icon.my-auto.text-lg.label-field.cursor-pointer.copy(
|
||||
size="18px",
|
||||
@@ -101,9 +103,12 @@ import { fetchWrapper } from "@/shared/fetchWrapper";
|
||||
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";
|
||||
import BaseInput from "@/components/base/BaseInput.vue";
|
||||
import {
|
||||
checkChangeData,
|
||||
getFieldsNameUnvalidated,
|
||||
} from "@/shared/utils/changesObjects.js";
|
||||
|
||||
export default {
|
||||
name: "InsuranceForm",
|
||||
@@ -139,14 +144,30 @@ export default {
|
||||
benefitData: (state) => state.medical?.benefitData,
|
||||
}),
|
||||
initialDocData() {
|
||||
const { OMS, DMS } = this.$store.state.medical.documents;
|
||||
return {
|
||||
OMS: OMS,
|
||||
DMS: DMS,
|
||||
};
|
||||
return this.$store.state.medical.documents;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
checkFields(val, insuranceKey, defaultRule) {
|
||||
const filteredFields = ["series", "number"];
|
||||
if (
|
||||
filteredFields?.every(
|
||||
(elem) => !this.insuranceData?.[insuranceKey]?.[elem]
|
||||
) &&
|
||||
!this.initialDocData?.[insuranceKey]?.id
|
||||
) {
|
||||
this.$refs.insuranceForm
|
||||
.getValidationComponents()
|
||||
.filter(
|
||||
(elem) =>
|
||||
elem.name === `${insuranceKey}:series` ||
|
||||
elem.name === `${insuranceKey}:number`
|
||||
)
|
||||
.forEach((elem) => elem.resetValidation());
|
||||
return true;
|
||||
}
|
||||
return defaultRule(val);
|
||||
},
|
||||
filterDataBenefit(text) {
|
||||
if (text.length > 1)
|
||||
return this.$store.dispatch("getBenefitDataSearch", text);
|
||||
@@ -188,187 +209,242 @@ export default {
|
||||
openModalCategories() {
|
||||
//if (this.isEdit) this.showModalCategories = true;
|
||||
},
|
||||
checkChangeInput() {
|
||||
checkChangeInput(key) {
|
||||
this.isCheckChange =
|
||||
JSON.stringify(this.initialDocData) !==
|
||||
JSON.stringify(this.insuranceData);
|
||||
JSON.stringify(this.initialDocData?.[key]) !==
|
||||
JSON.stringify(this.insuranceData?.[key]);
|
||||
},
|
||||
confirmChangePhoto() {
|
||||
this.showModal = false;
|
||||
this.isCheckChange = true;
|
||||
},
|
||||
updateBasicData() {
|
||||
let insuranceDMS = this.basic.insuranceDMS;
|
||||
let insuranceOMS = this.basic.insuranceOMS;
|
||||
let personal = this.basic.personalData;
|
||||
let benefit = this.basic.benefit;
|
||||
|
||||
const insuranceFormDataDMS = new FormData();
|
||||
const insuranceFormDataOMS = new FormData();
|
||||
const benefitFormData = new FormData();
|
||||
|
||||
if (insuranceDMS.series && insuranceDMS.number) {
|
||||
for (let key in insuranceDMS) {
|
||||
if (insuranceDMS[key] && key !== "photo" && key !== "id")
|
||||
insuranceFormDataDMS.append(key, insuranceDMS[key]);
|
||||
}
|
||||
}
|
||||
if (
|
||||
insuranceDMS.photo.file &&
|
||||
insuranceDMS.photo.photo !== this.initDataBasic.insuranceDMS.photo.photo
|
||||
)
|
||||
insuranceFormDataDMS.append("photo", insuranceDMS.photo.file[0]);
|
||||
|
||||
if (insuranceOMS.series && insuranceOMS.number) {
|
||||
for (let key in insuranceOMS) {
|
||||
if (insuranceOMS[key] && key !== "photo" && key !== "id")
|
||||
insuranceFormDataOMS.append(key, insuranceOMS[key]);
|
||||
}
|
||||
}
|
||||
if (
|
||||
insuranceOMS.photo.file &&
|
||||
insuranceOMS.photo.photo !== this.initDataBasic.insuranceOMS.photo.photo
|
||||
)
|
||||
insuranceFormDataOMS.append("photo", insuranceOMS.photo.file[0]);
|
||||
|
||||
const request = Object.keys(this.basic).map((key) => {
|
||||
if (
|
||||
key === "insuranceDMS" &&
|
||||
!insuranceDMS?.id &&
|
||||
insuranceDMS.series &&
|
||||
insuranceDMS.number
|
||||
) {
|
||||
insuranceFormDataDMS.append("title", "DMS");
|
||||
insuranceFormDataDMS.append("person", personal.id);
|
||||
return this.sendData(
|
||||
`general/insurance_policy/create/`,
|
||||
insuranceFormDataDMS
|
||||
);
|
||||
}
|
||||
if (
|
||||
key === "insuranceOMS" &&
|
||||
!insuranceOMS?.id &&
|
||||
insuranceOMS.series &&
|
||||
insuranceOMS.number
|
||||
) {
|
||||
insuranceFormDataOMS.append("title", "OMS");
|
||||
insuranceFormDataOMS.append("person", personal.id);
|
||||
return this.sendData(
|
||||
`general/insurance_policy/create/`,
|
||||
insuranceFormDataOMS
|
||||
);
|
||||
}
|
||||
if (
|
||||
checkChangeData(this.initDataBasic.insuranceDMS, insuranceDMS) &&
|
||||
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/`,
|
||||
insuranceFormDataDMS
|
||||
);
|
||||
} else if (
|
||||
insuranceDMS.id &&
|
||||
(!insuranceDMS.series || !insuranceDMS.number)
|
||||
) {
|
||||
this.addErrorNotification(
|
||||
"Ошибка заполнения формы ДМС",
|
||||
"Пожалуйста заполните все поля"
|
||||
);
|
||||
}
|
||||
if (
|
||||
checkChangeData(this.initDataBasic.insuranceOMS, insuranceOMS) &&
|
||||
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/`,
|
||||
insuranceFormDataOMS
|
||||
);
|
||||
} else if (
|
||||
insuranceOMS.id &&
|
||||
(!insuranceOMS.series || !insuranceOMS.number)
|
||||
) {
|
||||
this.addErrorNotification(
|
||||
"Ошибка заполнения формы ОМС",
|
||||
"Пожалуйста заполните все поля"
|
||||
);
|
||||
}
|
||||
if (
|
||||
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,
|
||||
saveChange() {
|
||||
const form = this.$refs.insuranceForm;
|
||||
form.validate().then((validate) => {
|
||||
if (!validate) {
|
||||
getFieldsNameUnvalidated(form).forEach((elem) => {
|
||||
let error = {};
|
||||
this.configData.forEach(({ dataKey, fields }) => {
|
||||
let findedElem = fields.find(
|
||||
(el) => dataKey + ":" + el.key === elem
|
||||
);
|
||||
if (findedElem) error = findedElem?.errorMessage;
|
||||
});
|
||||
this.addErrorNotification(error?.title, error?.message);
|
||||
});
|
||||
} else {
|
||||
let request = [];
|
||||
Object.keys(this.insuranceData).forEach((elem) => {
|
||||
this.checkChangePhoto(elem, "attachments");
|
||||
let newData = JSON.parse(JSON.stringify(this.insuranceData[elem]));
|
||||
console.log("prep", newData);
|
||||
newData.attachments = {};
|
||||
if (!checkChangeData(this.initialDocData?.[elem], newData)) return;
|
||||
delete newData.id;
|
||||
delete newData.attachments;
|
||||
if (!this.initialDocData?.[elem]?.id) {
|
||||
console.log("post", newData);
|
||||
newData.person_id =
|
||||
this.$store.state.medical?.basicData?.personalData?.id;
|
||||
console.log("create", newData);
|
||||
//request.push(this.createData("documents/", newData));
|
||||
} else {
|
||||
console.log("create", newData);
|
||||
// request.push(
|
||||
// this.updateData(
|
||||
// `documents/${this.initialDocData?.[elem]?.id}`,
|
||||
// newData
|
||||
// )
|
||||
// );
|
||||
}
|
||||
});
|
||||
Promise.allSettled(request).then(() => {
|
||||
this.getMedicalCardData(this.$route.params.id);
|
||||
this.isEdit = false;
|
||||
this.isCheckChange = false;
|
||||
this.$refs.form?.resetValidation();
|
||||
});
|
||||
if (
|
||||
benefit.photo.file &&
|
||||
benefit.photo.photo !== this.initDataBasic.benefit.photo.photo
|
||||
) {
|
||||
benefitFormData.append("photo_benefit", benefit.photo.file[0]);
|
||||
return this.sendData(
|
||||
`general/person/${personal.id}/update/`,
|
||||
benefitFormData
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
return request;
|
||||
|
||||
// let insuranceDMS = this.basic.insuranceDMS;
|
||||
// let insuranceOMS = this.basic.insuranceOMS;
|
||||
// let personal = this.basic.personalData;
|
||||
// let benefit = this.basic.benefit;
|
||||
|
||||
// const insuranceFormDataDMS = new FormData();
|
||||
// const insuranceFormDataOMS = new FormData();
|
||||
// const benefitFormData = new FormData();
|
||||
|
||||
// if (insuranceDMS.series && insuranceDMS.number) {
|
||||
// for (let key in insuranceDMS) {
|
||||
// if (insuranceDMS[key] && key !== "photo" && key !== "id")
|
||||
// insuranceFormDataDMS.append(key, insuranceDMS[key]);
|
||||
// }
|
||||
// }
|
||||
// if (
|
||||
// insuranceDMS.photo.file &&
|
||||
// insuranceDMS.photo.photo !== this.initDataBasic.insuranceDMS.photo.photo
|
||||
// )
|
||||
// insuranceFormDataDMS.append("photo", insuranceDMS.photo.file[0]);
|
||||
|
||||
// if (insuranceOMS.series && insuranceOMS.number) {
|
||||
// for (let key in insuranceOMS) {
|
||||
// if (insuranceOMS[key] && key !== "photo" && key !== "id")
|
||||
// insuranceFormDataOMS.append(key, insuranceOMS[key]);
|
||||
// }
|
||||
// }
|
||||
// if (
|
||||
// insuranceOMS.photo.file &&
|
||||
// insuranceOMS.photo.photo !== this.initDataBasic.insuranceOMS.photo.photo
|
||||
// )
|
||||
// insuranceFormDataOMS.append("photo", insuranceOMS.photo.file[0]);
|
||||
|
||||
// const request = Object.keys(this.basic).map((key) => {
|
||||
// if (
|
||||
// key === "insuranceDMS" &&
|
||||
// !insuranceDMS?.id &&
|
||||
// insuranceDMS.series &&
|
||||
// insuranceDMS.number
|
||||
// ) {
|
||||
// insuranceFormDataDMS.append("title", "DMS");
|
||||
// insuranceFormDataDMS.append("person", personal.id);
|
||||
// return this.sendData(
|
||||
// `general/insurance_policy/create/`,
|
||||
// insuranceFormDataDMS
|
||||
// );
|
||||
// }
|
||||
// if (
|
||||
// key === "insuranceOMS" &&
|
||||
// !insuranceOMS?.id &&
|
||||
// insuranceOMS.series &&
|
||||
// insuranceOMS.number
|
||||
// ) {
|
||||
// insuranceFormDataOMS.append("title", "OMS");
|
||||
// insuranceFormDataOMS.append("person", personal.id);
|
||||
// return this.sendData(
|
||||
// `general/insurance_policy/create/`,
|
||||
// insuranceFormDataOMS
|
||||
// );
|
||||
// }
|
||||
// if (
|
||||
// checkChangeData(this.initDataBasic.insuranceDMS, insuranceDMS) &&
|
||||
// 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/`,
|
||||
// insuranceFormDataDMS
|
||||
// );
|
||||
// } else if (
|
||||
// insuranceDMS.id &&
|
||||
// (!insuranceDMS.series || !insuranceDMS.number)
|
||||
// ) {
|
||||
// this.addErrorNotification(
|
||||
// "Ошибка заполнения формы ДМС",
|
||||
// "Пожалуйста заполните все поля"
|
||||
// );
|
||||
// }
|
||||
// if (
|
||||
// checkChangeData(this.initDataBasic.insuranceOMS, insuranceOMS) &&
|
||||
// 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/`,
|
||||
// insuranceFormDataOMS
|
||||
// );
|
||||
// } else if (
|
||||
// insuranceOMS.id &&
|
||||
// (!insuranceOMS.series || !insuranceOMS.number)
|
||||
// ) {
|
||||
// this.addErrorNotification(
|
||||
// "Ошибка заполнения формы ОМС",
|
||||
// "Пожалуйста заполните все поля"
|
||||
// );
|
||||
// }
|
||||
// if (
|
||||
// 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,
|
||||
// });
|
||||
// if (
|
||||
// benefit.photo.file &&
|
||||
// benefit.photo.photo !== this.initDataBasic.benefit.photo.photo
|
||||
// ) {
|
||||
// benefitFormData.append("photo_benefit", benefit.photo.file[0]);
|
||||
// return this.sendData(
|
||||
// `general/person/${personal.id}/update/`,
|
||||
// benefitFormData
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// return request;
|
||||
},
|
||||
checkedPhoto(photo, id, key, title) {
|
||||
if (!photo?.photo) {
|
||||
return this.delPhoto(`general/${key}/${id}/${title}/`);
|
||||
}
|
||||
|
||||
//todo удалить
|
||||
|
||||
checkChangePhoto(updatedObjId, field) {
|
||||
if (this.insuranceData[updatedObjId][field]?.file)
|
||||
console.log(
|
||||
updatedObjId,
|
||||
field,
|
||||
this.insuranceData[updatedObjId][field]?.file[0]
|
||||
);
|
||||
},
|
||||
addErrorNotification(title, message) {
|
||||
addNotification(title + message, title, message, "error", 5000);
|
||||
},
|
||||
|
||||
async sendData(url, body) {
|
||||
return await fetchWrapper.post(url, body, "formData");
|
||||
},
|
||||
async delPhoto(url) {
|
||||
return await fetchWrapper.del(url);
|
||||
},
|
||||
cancelEdit() {
|
||||
this.$store.dispatch("returnInitData");
|
||||
const { OMS, DMS } = JSON.parse(JSON.stringify(this.initialDocData));
|
||||
this.insuranceData = {
|
||||
OMS: OMS,
|
||||
DMS: DMS,
|
||||
};
|
||||
console.log("insuranceData cancel", this.insuranceData);
|
||||
this.isEdit = false;
|
||||
this.isCheckChange = false;
|
||||
},
|
||||
openEdit() {
|
||||
this.isEdit = true;
|
||||
},
|
||||
saveChange() {
|
||||
this.isLoadingData = true;
|
||||
let updateBasic = this.updateBasicData();
|
||||
Promise.allSettled(updateBasic)
|
||||
.then(() => this.$store.dispatch("getMedicalCardData"))
|
||||
.then(() => {
|
||||
this.isLoadingData = false;
|
||||
this.isEdit = false;
|
||||
this.isCheckChange = false;
|
||||
});
|
||||
},
|
||||
// saveChange() {
|
||||
// this.isLoadingData = true;
|
||||
// let updateBasic = this.updateInsurance();
|
||||
// Promise.allSettled(updateBasic)
|
||||
// .then(() => this.$store.dispatch("getMedicalCardData"))
|
||||
// .then(() => {
|
||||
// this.isLoadingData = false;
|
||||
// this.isEdit = false;
|
||||
// this.isCheckChange = false;
|
||||
// });
|
||||
// },
|
||||
},
|
||||
watch: {
|
||||
showModalCategories: {
|
||||
@@ -381,7 +457,12 @@ export default {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(newVal) {
|
||||
this.insuranceData = JSON.parse(JSON.stringify(newVal));
|
||||
const { OMS, DMS } = JSON.parse(JSON.stringify(newVal));
|
||||
this.insuranceData = {
|
||||
OMS: OMS,
|
||||
DMS: DMS,
|
||||
};
|
||||
console.log("insuranceData watch", this.insuranceData);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -385,13 +385,21 @@ export const baseInsuranceForm = [
|
||||
key: "series",
|
||||
label: "Серия",
|
||||
type: "text",
|
||||
inputMask: "####",
|
||||
rules: (val) => ruleNotValue(val),
|
||||
errorMessage: {
|
||||
title: "Ошибка валидации",
|
||||
message: "Серия полиса ОМС не заполнена",
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "number",
|
||||
label: "Номер",
|
||||
type: "text",
|
||||
inputMask: "####-####-####",
|
||||
rules: (val) => ruleNotValue(val),
|
||||
errorMessage: {
|
||||
title: "Ошибка валидации",
|
||||
message: "Номер полиса ДМС не заполнен",
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "attachments",
|
||||
@@ -408,13 +416,21 @@ export const baseInsuranceForm = [
|
||||
key: "series",
|
||||
label: "Серия",
|
||||
type: "text",
|
||||
inputMask: "####",
|
||||
rules: (val) => ruleNotValue(val),
|
||||
errorMessage: {
|
||||
title: "Ошибка валидации",
|
||||
message: "Серия полиса ДМС не заполнена",
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "number",
|
||||
label: "Номер",
|
||||
type: "text",
|
||||
inputMask: "####-####-####",
|
||||
rules: (val) => ruleNotValue(val),
|
||||
errorMessage: {
|
||||
title: "Ошибка валидации",
|
||||
message: "Номер полиса ДМС не заполнен",
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "attachments",
|
||||
@@ -525,7 +541,7 @@ export const documentForm = [
|
||||
title: "Ошибка валидации",
|
||||
message: "СНИЛС содержит менее 11 цифр",
|
||||
},
|
||||
rules: (val) => ruleOptionalFields(val, 14),
|
||||
rules: (val, id) => ruleOptionalFields(val, 14, id),
|
||||
},
|
||||
{
|
||||
key: "attachments",
|
||||
@@ -547,7 +563,7 @@ export const documentForm = [
|
||||
title: "Ошибка валидации",
|
||||
message: "ИНН содержит менее 12 цифр",
|
||||
},
|
||||
rules: (val) => ruleOptionalFields(val, 12),
|
||||
rules: (val, id) => ruleOptionalFields(val, 12, id),
|
||||
},
|
||||
{
|
||||
key: "attachments",
|
||||
|
||||
@@ -8,8 +8,8 @@ export function ruleLengthValue(val, minLength, text) {
|
||||
return (val && val.length === minLength) || text || false;
|
||||
}
|
||||
|
||||
export function ruleOptionalFields(val, minLength, text) {
|
||||
return !val || val.length === minLength || text || false;
|
||||
export function ruleOptionalFields(val, minLength, id, text) {
|
||||
return (!val && !id) || val.length === minLength || text || false;
|
||||
}
|
||||
|
||||
export function ruleEmailValue(val, text) {
|
||||
|
||||
@@ -188,78 +188,46 @@ const getters = {
|
||||
};
|
||||
},
|
||||
getDocumentsData(state, rootState) {
|
||||
const documents = state.medicalCard?.person?.documents,
|
||||
passport = documents?.find(({ category }) => category === "passport"),
|
||||
insurance_number = documents?.find(
|
||||
({ category }) => category === "insurance_number"
|
||||
),
|
||||
tax_identification_number = documents?.find(
|
||||
({ category }) => category === "tax_identification_number"
|
||||
),
|
||||
OMS = documents?.find(({ category }) => category === "OMS"),
|
||||
DMS = documents?.find(({ category }) => category === "DMS");
|
||||
return {
|
||||
passport: {
|
||||
category: "passport",
|
||||
id: passport?.id || "",
|
||||
series: passport?.series || "",
|
||||
number: passport?.number || "",
|
||||
issued_by: passport?.issued_by || "",
|
||||
issued_by_org_code: passport?.issued_by_org_code || "",
|
||||
issued_at: passport?.issued_at ? passport?.issued_at : "",
|
||||
attachments: passport?.attachments?.length
|
||||
const fields = [
|
||||
"passport",
|
||||
"insurance_number",
|
||||
"tax_identification_number",
|
||||
"OMS",
|
||||
"DMS",
|
||||
];
|
||||
let result = {};
|
||||
fields.forEach((elem) => {
|
||||
const document = state.medicalCard?.person?.documents?.find(
|
||||
({ category }) => category === elem
|
||||
);
|
||||
const isPassport = elem === "passport";
|
||||
const isPolicy = elem === "OMS" || elem === "DMS";
|
||||
result[elem] = {
|
||||
category: elem,
|
||||
id: document?.id || "",
|
||||
series: document?.series || (isPolicy || isPassport ? "" : "000"),
|
||||
number: document?.number || "",
|
||||
issued_by: document?.issued_by || (isPassport ? "" : "000"),
|
||||
issued_by_org_code: document?.issued_by_org_code || "",
|
||||
issued_at: document?.issued_at || "",
|
||||
attachments: document?.attachments?.length
|
||||
? {
|
||||
photo: rootState.getUrl + passport?.attachments?.[0],
|
||||
photo: rootState.getUrl + document?.attachments?.[0],
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
},
|
||||
insurance_number: {
|
||||
category: "insurance_number",
|
||||
id: insurance_number?.id || "",
|
||||
number: insurance_number?.number || "",
|
||||
attachments: insurance_number?.attachments?.length
|
||||
? {
|
||||
photo: rootState.getUrl + insurance_number.attachments?.[0],
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
},
|
||||
tax_identification_number: {
|
||||
category: "tax_identification_number",
|
||||
id: tax_identification_number?.id || "",
|
||||
number: tax_identification_number?.number || "",
|
||||
attachments: tax_identification_number?.attachments?.length
|
||||
? {
|
||||
photo:
|
||||
rootState.getUrl + tax_identification_number?.attachments?.[0],
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
},
|
||||
OMS: {
|
||||
category: OMS?.category || "",
|
||||
id: OMS?.id || "",
|
||||
number: OMS?.number || "",
|
||||
attachments: OMS?.attachments?.length
|
||||
? {
|
||||
photo: rootState.getUrl + OMS?.attachments?.[0],
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
},
|
||||
DMS: {
|
||||
category: DMS?.category || "",
|
||||
id: DMS?.id || "",
|
||||
number: DMS?.number || "",
|
||||
attachments: OMS?.attachments?.length
|
||||
? {
|
||||
photo: rootState.getUrl + DMS?.attachments?.[0],
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
},
|
||||
};
|
||||
};
|
||||
});
|
||||
// passport = documents?.find(({ category }) => category === "passport"),
|
||||
// insurance_number = documents?.find(
|
||||
// ({ category }) => category === "insurance_number"
|
||||
// ),
|
||||
// tax_identification_number = documents?.find(
|
||||
// ({ category }) => category === "tax_identification_number"
|
||||
// ),
|
||||
// OMS = documents?.find(({ category }) => category === "OMS"),
|
||||
// DMS = documents?.find(({ category }) => category === "DMS");
|
||||
return result;
|
||||
},
|
||||
getContactsData(state) {
|
||||
let phones =
|
||||
|
||||
Reference in New Issue
Block a user