WIP Добавил валидации на формах мед карты и отправку данных с формы

This commit is contained in:
DwCay
2023-02-28 19:33:07 +03:00
parent 8f07d76fa2
commit 08a6cf59c1
6 changed files with 214 additions and 48 deletions

View File

@@ -13,6 +13,7 @@
v-for="field in configData.identity_document.fields"
:field="field"
:data="medicalDataInit.identity_document"
:mask="field.mask"
)
.flex.flex-col.gap-30px
base-detail-info(
@@ -45,6 +46,7 @@
v-for="field in configData.snils.fields"
:field="field"
:data="medicalDataInit.snils"
:mask="field.mask"
)
base-detail-info(
:title="configData.policy.title"
@@ -55,6 +57,7 @@
v-for="field in configData.policy.fields"
:field="field"
:data="medicalDataInit.policy"
:mask="field.mask"
)
base-detail-info(
:title="configData.policy_organization.title"
@@ -76,10 +79,12 @@
v-for="field in configData.additional.fields"
:field="field"
:data="medicalDataInit.additional"
:mask="field.mask"
)
base-detail-info(
:title="configData.agreement_form.title"
:height="configData.agreement_form.height"
:data="medicalDataInit.agreement_form"
direction-row
)
base-detail-input(
@@ -92,9 +97,10 @@
.flex.flex-col.gap-y-2(v-for="(key, index) in Object.keys(dentalIndications)")
span.font-bold.text-xsx {{`${index+1}. ${configData.dental_indications[key]}`}}
medical-dental-formula(v-if="key === 'dental_formula'" :formula-data="dentalIndications[key]")
base-input(v-model="dentalIndications[key]", outlined, v-else)
base-input(v-model="dentalIndications[key]" outlined v-else)
.flex.justify-center
q-btn(
@click="validateFormCard",
color="primary",
label="Сохранить",
padding="8px 24px",
@@ -109,6 +115,8 @@ import BaseDetailInput from "@/components/base/BaseDetailInput.vue";
import BaseDetailInfo from "@/components/base/BaseDetailInfo.vue";
import { formulaDataMap } from "@/pages/medicalCard/utils/medicalConfig";
import { medicalDetailConfig } from "@/pages/medicalCard/utils/medicalConfig";
import { mobilityMap } from "@/pages/medicalCard/utils/medicalConfig";
import { createEntryMedicalCard } from "@/pages/medicalCard/utils/wrapperMedicalCard";
import { fetchWrapper } from "@/shared/fetchWrapper";
import BaseInput from "@/components/base/BaseInput.vue";
import ClientDetailInput from "@/pages/clients/components/ClientDetailInput.vue";
@@ -124,6 +132,7 @@ export default {
},
data() {
return {
medicalCardData: undefined,
numberCard: "",
configData: medicalDetailConfig,
medicalDataInit: {
@@ -152,8 +161,6 @@ export default {
additional: {
name_confidant: null,
phone_confidant: null,
},
benefit_code: {
benefit_code: null,
},
agreement_form: {
@@ -186,8 +193,31 @@ export default {
};
},
methods: {
validateFormCard() {
Object.keys(this.dentalIndications).forEach((key) => {
if (key === "dental_formula") {
const notEmptyEntries =
this.dentalIndications.dental_formula[0].columns
.concat(this.dentalIndications.dental_formula[1].columns)
.filter((el) => el.dental_condition && el.tooth_mobility);
createEntryMedicalCard(
notEmptyEntries,
key,
localStorage.getItem("medicalId")
);
}
if (this.dentalIndications[key] && !this.medicalCardData[key].length) {
createEntryMedicalCard(
this.dentalIndications[key],
key,
localStorage.getItem("medicalId")
);
}
});
},
saveDataMedical(data) {
this.numberCard = data?.number && data.number;
this.medicalCardData = data;
this.numberCard = data?.number;
const confidant = data ? data["confidant"] : undefined;
const pass = data
? data?.person?.identity_document?.find((el) => el.kind === "PASSPORT")
@@ -210,12 +240,14 @@ export default {
)?.join_adress,
},
snils: {
...data?.person["insurance_number"],
insurance_number: data?.person["insurance_number"],
},
policy: {
...this.medicalDataInit.policy,
...data?.person["insurance_policy"][0],
},
policy_organization: {
...this.medicalDataInit.policy_organization,
...data?.person["insurance_policy"][0],
},
additional: {
@@ -225,8 +257,6 @@ export default {
phone_confidant: confidant?.contacts?.find(
(el) => el?.kind === "PHONE"
)?.username,
},
benefit_code: {
benefit_code: data?.benefit_code,
},
agreement_form: {
@@ -234,6 +264,59 @@ export default {
agreement_date: null,
},
};
Object.keys(this.dentalIndications).forEach((key) => {
if (key === "dental_formula" && data[key].length) {
data[key].forEach((tooth) => {
if (tooth.dental_condition && tooth.tooth_mobility) {
if (17 < tooth.tooth_number < 29) {
this.dentalIndications.dental_formula[0] = {
...this.dentalIndications.dental_formula[0],
columns: this.dentalIndications.dental_formula[0].columns.map(
(el) => {
if (el.tooth_number === tooth.tooth_number) {
return {
...tooth,
tooth_mobility: mobilityMap.find(
(el) => el.label === tooth.tooth_mobility
),
};
}
return el;
}
),
};
}
if (37 < tooth.tooth_number < 49) {
this.dentalIndications.dental_formula[1] = {
...this.dentalIndications.dental_formula[1],
columns: this.dentalIndications.dental_formula[1].columns.map(
(el) => {
if (el.tooth_number === tooth.tooth_number) {
return {
...tooth,
tooth_mobility: mobilityMap.find(
(el) => el.label === tooth.tooth_mobility
),
};
}
return el;
}
),
};
}
}
});
} else {
this.dentalIndications[key] = data[key]?.length
? data[key]
.map((el) => {
let value = el.title || el["index_calculation"];
return value || "";
})
.join("")
: this.dentalIndications[key];
}
});
},
async fetchDataMedicalCard() {
await fetchWrapper