[WIP] Фикс запросов на основыне данные, добавил запросы для контактов

This commit is contained in:
megavrilinvv
2023-08-17 16:31:22 +03:00
parent 15cb788fcc
commit e3ad1396b6
4 changed files with 82 additions and 110 deletions

View File

@@ -134,10 +134,13 @@ const state = () => ({
const getters = {
getBasicData(state, rootState) {
let registrationAddress =
state.medicalCard?.person?.address?.find((el) => el.registration_flg) ||
{};
state.medicalCard?.person?.addresses?.find(
(el) => el.category === "REGISTRATION_ADDRESS"
) || {};
let residenceAddress =
state?.medicalCard?.person?.address?.find((el) => el.residence_flg) || {};
state?.medicalCard?.person?.addresses?.find(
(el) => el.category === "CURRENT_ADDRESS"
) || {};
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");
@@ -257,7 +260,6 @@ const getters = {
state.medicalCard?.person?.contacts
?.filter((el) => el.category === "PHONE")
?.map((el) => {
el.value = el.value.length > 10 ? el.value.slice(1) : el.value;
return { ...el };
}) || [];
let emails =
@@ -440,6 +442,23 @@ const actions = {
category: category,
});
},
deleteAddress(context, { id }) {
fetchWrapper.del(`address/${id}`);
},
postCreateContact(context, { obj, id }) {
fetchWrapper.post("contacts", {
person_id: id,
...obj,
});
},
postUpdateContact(context, { obj, id }) {
fetchWrapper.post(`contacts/${id}`, {
...obj,
});
},
deleteContact(context, { id }) {
fetchWrapper.del(`contacts/${id}`);
},
deleteItemData({ commit }, props) {
commit("setDataWithouDeleted", props);
},