add create medical card
This commit is contained in:
@@ -10,9 +10,11 @@
|
|||||||
)
|
)
|
||||||
template(#iconLeft)
|
template(#iconLeft)
|
||||||
q-icon.search-icon(name="app:search", size="20px")
|
q-icon.search-icon(name="app:search", size="20px")
|
||||||
base-button(width="216px", @click="openCreateMedcardPage")
|
base-button(width="216px", @click="showCreateModal = true")
|
||||||
q-icon.plus.mr-2(name="app:plus", size="24px")
|
q-icon.plus.mr-2(name="app:plus", size="24px")
|
||||||
span Создать медкарту
|
span Создать медкарту
|
||||||
|
base-modal(v-model="showCreateModal", title="Создать медицинскую карту", modal-padding)
|
||||||
|
patient-creation-form(@close="handleClosePatientForm")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -21,19 +23,37 @@ import BaseSelect from "@/components/base/BaseSelect.vue";
|
|||||||
import BaseButton from "@/components/base/BaseButton.vue";
|
import BaseButton from "@/components/base/BaseButton.vue";
|
||||||
|
|
||||||
import debounce from "lodash/debounce";
|
import debounce from "lodash/debounce";
|
||||||
|
import BaseModal from "@/components/base/BaseModal.vue";
|
||||||
|
import PatientCreationForm from "@/components/PatientCreationForm.vue";
|
||||||
|
import { mapActions } from "vuex";
|
||||||
export default {
|
export default {
|
||||||
name: "MedicalCardSearchHeader",
|
name: "MedicalCardSearchHeader",
|
||||||
components: { BaseInput, BaseSelect, BaseButton },
|
components: {
|
||||||
|
PatientCreationForm,
|
||||||
|
BaseModal,
|
||||||
|
BaseInput,
|
||||||
|
BaseSelect,
|
||||||
|
BaseButton,
|
||||||
|
},
|
||||||
emits: ["search"],
|
emits: ["search"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
filterString: "",
|
filterString: "",
|
||||||
|
showCreateModal: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openCreateMedcardPage() {
|
handleClosePatientForm(val) {
|
||||||
alert("Создать медкарту с ФИО: " + this.filterString);
|
this.showCreateModal = false;
|
||||||
|
if (!val) return;
|
||||||
|
this.getMedicalCardData({
|
||||||
|
personId: val.id,
|
||||||
|
successCallback: (id) => this.$router.push("medical-card/" + id),
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
...mapActions({
|
||||||
|
getMedicalCardData: "getMedicalCardDataByPersonId",
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
filterString: debounce(function (value) {
|
filterString: debounce(function (value) {
|
||||||
|
|||||||
@@ -425,17 +425,26 @@ const actions = {
|
|||||||
commit("setBenefitData", res.results);
|
commit("setBenefitData", res.results);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
createMedicalCard(ctx, id) {
|
createMedicalCard(ctx, { personId, successCallback }) {
|
||||||
fetchWrapper.post("medical_cards", {
|
fetchWrapper
|
||||||
person_id: id,
|
.post("medical_cards", {
|
||||||
number: String(Math.floor(1 + Math.random() * (100000000 + 1 - 1))),
|
person_id: personId,
|
||||||
});
|
number: String(Math.floor(1 + Math.random() * (100000000 + 1 - 1))),
|
||||||
return this.getMedicalCardDataByPersonId(ctx, id);
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.dispatch("getMedicalCardDataByPersonId", {
|
||||||
|
personId,
|
||||||
|
successCallback,
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
getMedicalCardDataByPersonId({ commit }, { personId, successCallback }) {
|
getMedicalCardDataByPersonId({ commit }, { personId, successCallback }) {
|
||||||
fetchWrapper.get(`medical_cards/person/${personId}`).then((data) => {
|
fetchWrapper.get(`medical_cards/person/${personId}`).then((data) => {
|
||||||
if (!data) {
|
if (!data || data?.detail) {
|
||||||
return this.createMedicalCard({ commit }, personId);
|
return this.dispatch("createMedicalCard", {
|
||||||
|
personId,
|
||||||
|
successCallback,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
commit("setMedicalCard", data);
|
commit("setMedicalCard", data);
|
||||||
commit("setBasicData");
|
commit("setBasicData");
|
||||||
|
|||||||
Reference in New Issue
Block a user