Merge branch 'ASTRA-48' into 'master'
WIP Подтянула данные из стора See merge request andrusyakka/urban-couscous!310
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
<template lang="pug">
|
||||
medical-form-wrapper(
|
||||
title="Документы"
|
||||
title="Документы",
|
||||
:is-check-change="isCheckChange",
|
||||
:is-edit="isEdit",
|
||||
:cancel="cancelEdit",
|
||||
:open-edit="openEdit",
|
||||
)
|
||||
.form-wrap.gap-24.w-full
|
||||
.data-section.flex.flex-col.gap-4(v-for="data in configData")
|
||||
@@ -8,24 +12,24 @@
|
||||
.flex.w-full.justify-between.items-center.gap-4(v-for="field in data.fields")
|
||||
.label-field.font-sm.text-sm.whitespace-nowrap {{`${field.label} :`}}
|
||||
.photo-field.flex.gap-3.items-center(v-if="field.type === 'photo'")
|
||||
base-avatar(
|
||||
v-if="photo",
|
||||
:size="40",
|
||||
img.photo.object-cover(
|
||||
v-if="docData[data.dataKey][field.key]",
|
||||
:src="docData[data.dataKey][field.key]",
|
||||
:alt="docData[data.dataKey][field.label]",
|
||||
)
|
||||
img.object-cover(
|
||||
:src="url + photo"
|
||||
alt="photo"
|
||||
)
|
||||
.replace-photo.font-medium.text-base.cursor-pointer(v-if="isEdit && photo") Заменить фото
|
||||
.replace-photo.font-medium.text-base.cursor-pointer(v-if="isEdit && !photo") Добавить фото
|
||||
.replace-photo.font-medium.text-base.cursor-pointer(
|
||||
v-if="isEdit"
|
||||
) {{ docData[data.dataKey][field.key] ? "Заменить фото" : "Добавить фото"}}
|
||||
base-input(
|
||||
v-else
|
||||
:disabled="!isEdit"
|
||||
:width="278"
|
||||
:standout="!isEdit"
|
||||
:outlined="isEdit"
|
||||
:rule="field.rules"
|
||||
text-color="black"
|
||||
v-else,
|
||||
v-model="docData[data.dataKey][field.key]",
|
||||
@update:model-value="checkChangeDocData"
|
||||
:disabled="!isEdit",
|
||||
:width="278",
|
||||
:standout="!isEdit",
|
||||
:outlined="isEdit",
|
||||
:rule="field.rules",
|
||||
text-color="black",
|
||||
)
|
||||
</template>
|
||||
|
||||
@@ -34,19 +38,65 @@ import MedicalFormWrapper from "@/pages/newMedicalCard/components/MedicalFormWra
|
||||
import { documentForm } from "@/pages/newMedicalCard/utils/medicalConfig";
|
||||
import BaseInput from "@/components/base/BaseInput.vue";
|
||||
import BaseAvatar from "@/components/base/BaseAvatar.vue";
|
||||
import BaseLoader from "@/components/Loader/BaseLoader.vue";
|
||||
export default {
|
||||
name: "DocumentsForm",
|
||||
components: { MedicalFormWrapper, BaseInput, BaseAvatar },
|
||||
components: { MedicalFormWrapper, BaseInput, BaseAvatar, BaseLoader },
|
||||
data() {
|
||||
return {
|
||||
configData: documentForm,
|
||||
isEdit: false,
|
||||
docData: null,
|
||||
isCheckChange: false,
|
||||
isLoadingData: true,
|
||||
initializationData: {
|
||||
passport: {
|
||||
id: null,
|
||||
series: null,
|
||||
number: null,
|
||||
issued_by_org: null,
|
||||
issued_by_org_code: null,
|
||||
issued_by_date: null,
|
||||
photo: null,
|
||||
},
|
||||
insurance_number: {
|
||||
insurance_number: null,
|
||||
photo_insurance_number: null,
|
||||
},
|
||||
tax_identification_number: {
|
||||
tax_identification_number: null,
|
||||
photo_tax_identification_number: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
url() {
|
||||
return this.$store.state.url;
|
||||
initialDocData() {
|
||||
return this.$store.state.medical?.documents;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
cancelEdit() {
|
||||
this.docData = JSON.parse(JSON.stringify(this.initialDocData));
|
||||
this.isEdit = false;
|
||||
},
|
||||
openEdit() {
|
||||
this.isEdit = true;
|
||||
},
|
||||
checkChangeDocData() {
|
||||
this.isCheckChange =
|
||||
JSON.stringify(this.docData) !== JSON.stringify(this.initialDocData);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
initialDocData: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(value) {
|
||||
if (Object.keys(value).length)
|
||||
this.docData = JSON.parse(JSON.stringify(this.initialDocData));
|
||||
else this.docData = this.initializationData;
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -68,4 +118,6 @@ export default {
|
||||
color: var(--btn-blue-color)
|
||||
.photo-field
|
||||
min-width: 302px
|
||||
.photo
|
||||
height: 100%
|
||||
</style>
|
||||
|
||||
@@ -299,7 +299,7 @@ export const documentForm = [
|
||||
},
|
||||
{
|
||||
dataLabel: "СНИЛС",
|
||||
dataKey: "insuranceNumber",
|
||||
dataKey: "insurance_number",
|
||||
fields: [
|
||||
{
|
||||
key: "insurance_number",
|
||||
@@ -315,7 +315,7 @@ export const documentForm = [
|
||||
},
|
||||
{
|
||||
dataLabel: "ИНН",
|
||||
dataKey: "taxIdentificationNumber",
|
||||
dataKey: "tax_identification_number",
|
||||
fields: [
|
||||
{
|
||||
key: "tax_identification_number",
|
||||
|
||||
@@ -23,9 +23,11 @@ export function getObjectChangeField(objInit, objUpdate) {
|
||||
export function checkChangeData(dataInit, dataChange) {
|
||||
let initData = JSON.stringify(dataInit);
|
||||
let changeData = JSON.stringify(dataChange);
|
||||
if (initData !== changeData) {
|
||||
return initData !== changeData;
|
||||
//Алексей, какого черта!?
|
||||
/*if (initData !== changeData) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -51,24 +51,7 @@ const state = () => ({
|
||||
photo: null,
|
||||
},
|
||||
},
|
||||
documents: {
|
||||
passport: {
|
||||
series: null,
|
||||
number: null,
|
||||
issued_by_org: null,
|
||||
issued_by_org_code: null,
|
||||
issued_by_date: null,
|
||||
photo: null,
|
||||
},
|
||||
insurance_number: {
|
||||
insurance_number: null,
|
||||
photo_insurance_number: null,
|
||||
},
|
||||
tax_identification_number: {
|
||||
tax_identification_number: null,
|
||||
photo_tax_identification_number: null,
|
||||
},
|
||||
},
|
||||
documents: {},
|
||||
avatar: "",
|
||||
});
|
||||
|
||||
@@ -80,6 +63,8 @@ const getters = {
|
||||
let residenceAddress =
|
||||
state?.medicalCard?.person?.address?.find((el) => el.residence_flg) || {};
|
||||
let person = state.medicalCard.person;
|
||||
let OMS = person?.insurance_policy?.find((e) => e.title === "OMS");
|
||||
let DMS = person?.insurance_policy?.find((e) => e.title === "DMS");
|
||||
return {
|
||||
personalData: {
|
||||
last_name: person?.last_name,
|
||||
@@ -116,36 +101,28 @@ const getters = {
|
||||
id: residenceAddress?.id,
|
||||
},
|
||||
insuranceDMS: {
|
||||
series: person?.insurance_policy?.find((e) => e.title === "DMS")
|
||||
?.series,
|
||||
number: person.insurance_policy.find((e) => e.title === "DMS")?.number,
|
||||
photo: person.insurance_policy.find((e) => e.title === "DMS")?.photo
|
||||
series: DMS?.series,
|
||||
number: DMS?.number,
|
||||
photo: DMS?.photo
|
||||
? {
|
||||
photo:
|
||||
rootState.getUrl +
|
||||
person.insurance_policy.find((e) => e.title === "DMS")?.photo,
|
||||
photo: rootState.getUrl + DMS?.photo,
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
id: person?.insurance_policy?.find((e) => e.title === "DMS")?.id,
|
||||
organization: person?.insurance_policy?.find((e) => e.title === "DMS")
|
||||
?.organization,
|
||||
id: DMS?.id,
|
||||
organization: DMS?.organization,
|
||||
},
|
||||
insuranceOMS: {
|
||||
series: person?.insurance_policy?.find((e) => e.title === "OMS")
|
||||
?.series,
|
||||
number: person.insurance_policy.find((e) => e.title === "OMS")?.number,
|
||||
photo: person.insurance_policy.find((e) => e.title === "OMS")?.photo
|
||||
series: OMS?.series,
|
||||
number: OMS?.number,
|
||||
photo: OMS?.photo
|
||||
? {
|
||||
photo:
|
||||
rootState.getUrl +
|
||||
person.insurance_policy.find((e) => e.title === "OMS")?.photo,
|
||||
photo: rootState.getUrl + OMS?.photo,
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
id: person?.insurance_policy?.find((e) => e.title === "OMS")?.id,
|
||||
organization: person?.insurance_policy?.find((e) => e.title === "OMS")
|
||||
?.organization,
|
||||
id: OMS?.id,
|
||||
organization: OMS?.organization,
|
||||
},
|
||||
benefit: {
|
||||
name: person?.benefit?.name,
|
||||
@@ -188,6 +165,7 @@ const actions = {
|
||||
commit("setMedicalCard", res);
|
||||
commit("setBasicData");
|
||||
commit("setContactsData");
|
||||
commit("setDocumentData", res.person);
|
||||
});
|
||||
},
|
||||
returnInitData({ commit }) {
|
||||
@@ -218,6 +196,34 @@ const mutations = {
|
||||
setContactsData(state) {
|
||||
state.contactsData = { ...this.getters.getContactsData };
|
||||
},
|
||||
setDocumentData(state, data, rootState) {
|
||||
const passport = data?.identity_document.find(
|
||||
(el) => el.kind === "PASSPORT"
|
||||
);
|
||||
state.documents = {
|
||||
passport: {
|
||||
id: passport?.id,
|
||||
series: passport?.series,
|
||||
number: passport?.number,
|
||||
issued_by_org: passport?.issued_by_org,
|
||||
issued_by_org_code: passport?.issued_by_org_code,
|
||||
issued_by_date: passport?.issued_by_date,
|
||||
photo: passport?.photo ? rootState.getUrl + passport.photo : "",
|
||||
},
|
||||
insurance_number: {
|
||||
insurance_number: data?.insurance_number,
|
||||
photo_insurance_number: data?.photo_insurance_number
|
||||
? rootState.getUrl + data.photo_insurance_number
|
||||
: "",
|
||||
},
|
||||
tax_identification_number: {
|
||||
tax_identification_number: data?.tax_identification_number,
|
||||
photo_tax_identification_number: data?.photo_tax_identification_number
|
||||
? rootState.getUrl + data?.photo_tax_identification_number
|
||||
: "",
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user