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