[WIP] Добавил переход на медкарту, возможность редактирования основных данных
This commit is contained in:
@@ -33,14 +33,14 @@
|
||||
size="M"
|
||||
)
|
||||
base-input(
|
||||
v-model="addresses.house_number",
|
||||
v-model="addresses.house",
|
||||
label="Дом",
|
||||
placeholder="Номер дома",
|
||||
disabled,
|
||||
size="M"
|
||||
)
|
||||
base-input(
|
||||
v-model="addresses.apartment_number",
|
||||
v-model="addresses.flat",
|
||||
label="Квартира",
|
||||
placeholder="Номер квартиры",
|
||||
disabled,
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
.thumb.h-full.rounded(:style="thumbStyle")
|
||||
span.grey-color {{ medcardInfo?.filling_percentage || 0 }}%
|
||||
.field(:style="{...headerStyle(headerConfig[6])}")
|
||||
q-icon.medcard.cursor-pointer(name="app:medcard", size="20px")
|
||||
q-icon.medcard.cursor-pointer(name="app:medcard", size="20px", @click="openMedicalCard")
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -36,6 +36,7 @@ import * as moment from "moment/moment";
|
||||
import TheNotificationProvider from "@/components/Notifications/TheNotificationProvider";
|
||||
import { addNotification } from "@/components/Notifications/notificationContext";
|
||||
import avatar from "@/assets/images/person.png";
|
||||
import { mapActions } from "vuex";
|
||||
export default {
|
||||
name: "MedicalCardSearchRow",
|
||||
components: { TheNotificationProvider },
|
||||
@@ -72,6 +73,15 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
getMedicalCardData: "getMedicalCardDataByPersonId",
|
||||
}),
|
||||
openMedicalCard() {
|
||||
this.getMedicalCardData({
|
||||
personId: this.medcardInfo.person_id,
|
||||
successCallback: (id) => this.$router.push("medical-card/" + id),
|
||||
});
|
||||
},
|
||||
convertDate(date) {
|
||||
return moment(date)?.format("DD MMMM YYYY");
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
:is-check-change="isCheckChange"
|
||||
:is-loading-data="isLoadingData"
|
||||
:is-edit="isEdit"
|
||||
:save="saveChange"
|
||||
:save="updateBasicData"
|
||||
:cancel="cancelEdit"
|
||||
:open-edit="openEdit"
|
||||
)
|
||||
@@ -29,7 +29,7 @@
|
||||
)
|
||||
.select(v-else-if="field.type === 'select'")
|
||||
base-select(
|
||||
:readonly="!isEdit"
|
||||
readonly,
|
||||
v-model="basic[data.dataKey][field.key]"
|
||||
@update:model-value="checkChangeInput"
|
||||
:hide-dropdown-icon="!isEdit"
|
||||
@@ -43,13 +43,13 @@
|
||||
v-else-if="field.type === 'date'",
|
||||
v-model="basic[data.dataKey][field.key]",
|
||||
size="M",
|
||||
:readonly="!isEdit",
|
||||
readonly
|
||||
@update:model-value="checkChangeInput",
|
||||
:width="302"
|
||||
)
|
||||
base-input(
|
||||
v-else,
|
||||
:readonly="!isEdit"
|
||||
:readonly="checkRow(data.dataLabel)"
|
||||
v-model="basic[data.dataKey][field.key]"
|
||||
@update:model-value="checkChangeInput"
|
||||
:type="field.type"
|
||||
@@ -81,6 +81,8 @@ import {
|
||||
import { mapGetters, mapState } from "vuex";
|
||||
import BaseInput from "@/components/base/BaseInput.vue";
|
||||
import BaseInputDate from "@/components/base/BaseInputDate.vue";
|
||||
import { mapActions } from "vuex";
|
||||
import { removeEmptyFields } from "@/shared/utils/changesObjects";
|
||||
|
||||
export default {
|
||||
name: "BasicDataForm",
|
||||
@@ -118,6 +120,46 @@ export default {
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
postAddress: "postAddress",
|
||||
}),
|
||||
updateBasicData() {
|
||||
const photoFormData = new FormData();
|
||||
if (
|
||||
this.basic.personalData.photo.file &&
|
||||
this.basic.personalData.photo.photo !==
|
||||
this.initDataBasic.personalData.photo.photo
|
||||
) {
|
||||
photoFormData.append("photo", this.basic.personalData?.photo?.file[0]);
|
||||
console.log("photo_update");
|
||||
}
|
||||
Object.keys(this.basic).map((key) => {
|
||||
if (key === "registrationAddress")
|
||||
this.getRequestChangeData(
|
||||
this.basic.registrationAddress,
|
||||
this.initDataBasic[key]
|
||||
);
|
||||
if (key === "residenceAddress")
|
||||
this.getRequestChangeData(
|
||||
this.basic.residenceAddress,
|
||||
this.initDataBasic[key]
|
||||
);
|
||||
});
|
||||
this.isEdit = false;
|
||||
},
|
||||
getRequestChangeData(updateData, initData) {
|
||||
if (
|
||||
Object.keys(removeEmptyFields(updateData)).length &&
|
||||
JSON.stringify(updateData) !== JSON.stringify(initData)
|
||||
)
|
||||
return this.postAddress({
|
||||
id: this.basic.personalData.id,
|
||||
address: updateData,
|
||||
});
|
||||
},
|
||||
checkRow(label) {
|
||||
return label === "Личные данные" ? true : !this.isEdit;
|
||||
},
|
||||
checkChangeInput() {
|
||||
this.isCheckChange = checkChangeData(this.initDataBasic, this.basic);
|
||||
},
|
||||
@@ -130,7 +172,7 @@ export default {
|
||||
this.isEdit = false;
|
||||
this.isCheckChange = false;
|
||||
},
|
||||
updateBasicData() {
|
||||
oldUpdateBasicData() {
|
||||
let registration = this.basic.registrationAddress;
|
||||
let residence = this.basic.residenceAddress;
|
||||
let personal = this.basic.personalData;
|
||||
|
||||
@@ -67,7 +67,7 @@ export const baseDataForm = [
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
key: "house_number",
|
||||
key: "house",
|
||||
label: "Дом",
|
||||
type: "text",
|
||||
rules: [(val) => !/^[\W0]/.test(val)],
|
||||
@@ -75,7 +75,7 @@ export const baseDataForm = [
|
||||
"Номер дома должен начинатся не с нуля и только с цифробуквенного символа",
|
||||
},
|
||||
{
|
||||
key: "apartment_number",
|
||||
key: "flat",
|
||||
label: "Квартира",
|
||||
type: "text",
|
||||
rules: [(val) => !/^[\W0]/.test(val)],
|
||||
@@ -104,7 +104,7 @@ export const baseDataForm = [
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
key: "house_number",
|
||||
key: "house",
|
||||
label: "Дом",
|
||||
type: "text",
|
||||
rules: [(val) => !/^[\W0]/.test(val)],
|
||||
@@ -112,7 +112,7 @@ export const baseDataForm = [
|
||||
"Номер дома должен начинатся не с нуля и только с цифробуквенного символа",
|
||||
},
|
||||
{
|
||||
key: "apartment_number",
|
||||
key: "flat",
|
||||
label: "Квартира",
|
||||
type: "text",
|
||||
rules: [(val) => !/^[\W0]/.test(val)],
|
||||
@@ -124,12 +124,12 @@ export const baseDataForm = [
|
||||
];
|
||||
|
||||
export const errorMap = {
|
||||
house_number: {
|
||||
house: {
|
||||
title: "Дом",
|
||||
error:
|
||||
"Номер дома должен начинатся не с нуля и только с цифробуквенного символа",
|
||||
},
|
||||
apartment_number: {
|
||||
flat: {
|
||||
title: "Квартира",
|
||||
error:
|
||||
"Номер квартиры должен начинатся не с нуля и только с цифробуквенного символа",
|
||||
|
||||
@@ -24,15 +24,15 @@ const state = () => ({
|
||||
region: null,
|
||||
city: null,
|
||||
street: null,
|
||||
house_number: null,
|
||||
apartment_number: null,
|
||||
house: null,
|
||||
flat: null,
|
||||
},
|
||||
residenceAddress: {
|
||||
region: null,
|
||||
city: null,
|
||||
street: null,
|
||||
house_number: null,
|
||||
apartment_number: null,
|
||||
house: null,
|
||||
flat: null,
|
||||
},
|
||||
insuranceDMS: {
|
||||
series: null,
|
||||
@@ -163,17 +163,17 @@ const getters = {
|
||||
region: registrationAddress?.region || "",
|
||||
city: registrationAddress?.city || "",
|
||||
street: registrationAddress?.street || "",
|
||||
house_number: registrationAddress?.house_number || "",
|
||||
apartment_number: registrationAddress?.apartment_number || "",
|
||||
id: registrationAddress?.id || "",
|
||||
house: registrationAddress?.house || "",
|
||||
flat: registrationAddress?.flat || "",
|
||||
category: "Адрес регистрации",
|
||||
},
|
||||
residenceAddress: {
|
||||
region: residenceAddress?.region || "",
|
||||
city: residenceAddress?.city || "",
|
||||
street: residenceAddress?.street || "",
|
||||
house_number: residenceAddress?.house_number || "",
|
||||
apartment_number: residenceAddress?.apartment_number || "",
|
||||
id: residenceAddress?.id || "",
|
||||
house: residenceAddress?.house || "",
|
||||
flat: residenceAddress?.flat || "",
|
||||
category: "Адрес проживания",
|
||||
},
|
||||
insuranceDMS: {
|
||||
series: DMS?.series,
|
||||
@@ -429,6 +429,11 @@ const getters = {
|
||||
};
|
||||
|
||||
const actions = {
|
||||
postAddress(context, { id, address }) {
|
||||
fetchWrapper.post(`address/${id}`, {
|
||||
...address,
|
||||
});
|
||||
},
|
||||
deleteItemData({ commit }, props) {
|
||||
commit("setDataWithouDeleted", props);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user