Убрал localStorage с medicalId и заменил на route

This commit is contained in:
megavrilinvv
2023-08-16 10:09:22 +03:00
parent f67c9be11f
commit cdf9754a36
6 changed files with 25 additions and 50 deletions

View File

@@ -140,13 +140,9 @@ export default {
}, },
methods: { methods: {
filterDataBenefit(text) { filterDataBenefit(text) {
if (text.length > 1) { if (text.length > 1)
localStorage.setItem("searchBenefit", text); return this.$store.dispatch("getBenefitDataSearch", text);
this.$store.dispatch("getBenefitDataSearch"); this.$store.dispatch("getBenefitData", text);
} else {
this.$store.dispatch("getBenefitData");
localStorage.removeItem("searchBenefit", text);
}
}, },
removeImage(docKey, field) { removeImage(docKey, field) {
this.basic[docKey][field] = {}; this.basic[docKey][field] = {};

View File

@@ -191,8 +191,7 @@ export default {
checkChangeInput(val, key) { checkChangeInput(val, key) {
if (key === "last_name") { if (key === "last_name") {
if (val.length > 0) { if (val.length > 0) {
localStorage.setItem("searchConfidant", val); this.$store.dispatch("getPersonsFiltredList", val).then((res) => {
this.$store.dispatch("getPersonsFiltredList").then((res) => {
if (res.length > 0) { if (res.length > 0) {
this.listPersons = res; this.listPersons = res;
this.isOpenListConfidant = true; this.isOpenListConfidant = true;
@@ -225,7 +224,8 @@ export default {
getRequestConfidant( getRequestConfidant(
this.confidant, this.confidant,
initConfidantData, initConfidantData,
this.initPerson this.initPerson,
this.$route.params.id
).then(() => { ).then(() => {
this.$store.dispatch("getMedicalCardData"); this.$store.dispatch("getMedicalCardData");
this.isLoadingData = false; this.isLoadingData = false;
@@ -259,9 +259,7 @@ export default {
if (this.confidant.id) { if (this.confidant.id) {
fetchWrapper fetchWrapper
.del( .del(
`medical_card/medical_history/${localStorage.getItem( `medical_card/medical_history/${this.$route.params.id}/delete_confidant/`,
"medicalId"
)}/delete_confidant/`,
{ {
confidants: [ confidants: [
{ {

View File

@@ -30,7 +30,7 @@ export default {
methods: { methods: {
removeMedicalCard() { removeMedicalCard() {
this.changeShownRemoveModal(false); this.changeShownRemoveModal(false);
this.$store.dispatch("removeMedicalCardData"); this.$store.dispatch("removeMedicalCardData", this.$route.params.id);
}, },
}, },
}; };

View File

@@ -249,11 +249,7 @@ export default {
!!tooth.tooth_mobility && !!tooth.tooth_mobility &&
!!tooth.dental_condition; !!tooth.dental_condition;
if (isCreate) { if (isCreate) {
requestCreateMedicalCard( requestCreateMedicalCard(tooth, key, this.$route.params.id);
tooth,
key,
localStorage.getItem("medicalId")
);
} }
if ( if (
toothResponse && toothResponse &&
@@ -273,7 +269,7 @@ export default {
requestCreateMedicalCard( requestCreateMedicalCard(
this.dentalIndications[key], this.dentalIndications[key],
key, key,
localStorage.getItem("medicalId") this.$route.params.id
); );
} }
if ( if (
@@ -385,11 +381,7 @@ export default {
}, },
async fetchDataMedicalCard() { async fetchDataMedicalCard() {
await fetchWrapper await fetchWrapper
.get( .get(`medical_card/medical_history/${this.$route.params.id}/detail/`)
`medical_card/medical_history/${localStorage.getItem(
"medicalId"
)}/detail/`
)
.then((res) => this.saveDataMedical(res)); .then((res) => this.saveDataMedical(res));
}, },
}, },

View File

@@ -89,8 +89,8 @@ export function getRequestNote(note, initNote, personId) {
return Promise.resolve(); return Promise.resolve();
} }
export function getRequestConfidant(confidant, initConfidant, initPerson) { export function getRequestConfidant(confidant, initConfidant, initPerson, id) {
const medicalId = localStorage.getItem("medicalId"); const medicalId = id;
const fullName = `${confidant.last_name.value} ${confidant.first_name.value} ${confidant.patronymic.value}`; const fullName = `${confidant.last_name.value} ${confidant.first_name.value} ${confidant.patronymic.value}`;
let contacts = []; let contacts = [];
const phone = confidant.phone.value const phone = confidant.phone.value

View File

@@ -259,7 +259,7 @@ const getters = {
state.medicalCard?.person?.contacts state.medicalCard?.person?.contacts
?.filter((el) => el.category === "PHONE") ?.filter((el) => el.category === "PHONE")
?.map((el) => { ?.map((el) => {
el.value = el.value.slice(1); el.value = el.value.length > 10 ? el.value.slice(1) : el.value;
return { ...el }; return { ...el };
}) || []; }) || [];
let emails = let emails =
@@ -443,10 +443,8 @@ const actions = {
commit("setBenefitData", res.results); commit("setBenefitData", res.results);
}); });
}, },
getBenefitDataSearch({ commit }) { getBenefitDataSearch({ commit }, text) {
fetchWrapper fetchWrapper.get(`general/benefit/?name=${text}`).then((res) => {
.get(`general/benefit/?name=${localStorage.getItem("searchBenefit")}`)
.then((res) => {
commit("setBenefitData", res.results); commit("setBenefitData", res.results);
}); });
}, },
@@ -489,11 +487,9 @@ const actions = {
commit("setEventsPersonData", data?.person?.id); commit("setEventsPersonData", data?.person?.id);
}); });
}, },
getPersonsFiltredList() { getPersonsFiltredList(value) {
return fetchWrapper return fetchWrapper
.get( .get(`general/person/?last_name=${value}`)
`general/person/?last_name=${localStorage.getItem("searchConfidant")}`
)
.then((res) => res.results); .then((res) => res.results);
}, },
returnInitData({ commit }) { returnInitData({ commit }) {
@@ -502,17 +498,10 @@ const actions = {
commit("setAllergiesData"); commit("setAllergiesData");
commit("setConfidantData"); commit("setConfidantData");
}, },
removeMedicalCardData({ commit, rootState }) { removeMedicalCardData({ commit, rootState }, id) {
fetchWrapper fetchWrapper.del(`medical_card/medical_history/${id}/delete/`).then(() => {
.del(
`medical_card/medical_history/${localStorage.getItem(
"medicalId"
)}/delete/`
)
.then(() => {
rootState.routingHistory.back(); rootState.routingHistory.back();
commit("setMedicalCard", {}); commit("setMedicalCard", {});
localStorage.removeItem("medicalId");
}); });
}, },
createProtocol({ commit, rootGetters, state }, data) { createProtocol({ commit, rootGetters, state }, data) {