change disabled method

This commit is contained in:
kandrusyak
2023-08-16 20:19:21 +03:00
parent 4dda501a3e
commit e59624e263
2 changed files with 8 additions and 72 deletions

View File

@@ -25,7 +25,7 @@
base-modal(v-model="showModal" title="Загрузить изображение") base-modal(v-model="showModal" title="Загрузить изображение")
base-upload-photo( base-upload-photo(
v-model="basic[data.dataKey][field.key]" v-model="basic[data.dataKey][field.key]"
:confirm-upload="confirmCahngeAvatar" :confirm-upload="confirmChangeAvatar"
) )
.select(v-else-if="field.type === 'select'") .select(v-else-if="field.type === 'select'")
base-select( base-select(
@@ -49,7 +49,7 @@
) )
base-input( base-input(
v-else, v-else,
:readonly="checkRow(data.dataLabel)" :readonly="field.disabled || !this.isEdit"
v-model="basic[data.dataKey][field.key]" v-model="basic[data.dataKey][field.key]"
@update:model-value="checkChangeInput" @update:model-value="checkChangeInput"
:type="field.type" :type="field.type"
@@ -69,10 +69,7 @@ import MedicalFormWrapper from "@/pages/newMedicalCard/components/MedicalFormWra
import TheNotificationProvider from "@/components/Notifications/TheNotificationProvider.vue"; import TheNotificationProvider from "@/components/Notifications/TheNotificationProvider.vue";
import { getFieldsNameUnvalidated } from "@/shared/utils/changesObjects"; import { getFieldsNameUnvalidated } from "@/shared/utils/changesObjects";
import { addNotification } from "@/components/Notifications/notificationContext"; import { addNotification } from "@/components/Notifications/notificationContext";
import { getRequestChangeData } from "@/shared/utils/wrapperRequestChangeData";
import { checkChangeData } from "@/shared/utils/changesObjects"; import { checkChangeData } from "@/shared/utils/changesObjects";
import { fetchWrapper } from "@/shared/fetchWrapper";
import moment from "moment";
import { import {
baseDataForm, baseDataForm,
genderOptions, genderOptions,
@@ -168,13 +165,10 @@ export default {
}); });
} }
}, },
checkRow(label) {
return label === "Личные данные" ? true : !this.isEdit;
},
checkChangeInput() { checkChangeInput() {
this.isCheckChange = checkChangeData(this.initDataBasic, this.basic); this.isCheckChange = checkChangeData(this.initDataBasic, this.basic);
}, },
confirmCahngeAvatar() { confirmChangeAvatar() {
this.showModal = false; this.showModal = false;
this.isCheckChange = true; this.isCheckChange = true;
}, },
@@ -183,69 +177,6 @@ export default {
this.isEdit = false; this.isEdit = false;
this.isCheckChange = false; this.isCheckChange = false;
}, },
oldUpdateBasicData() {
let registration = this.basic.registrationAddress;
let residence = this.basic.residenceAddress;
let personal = this.basic.personalData;
const personalFormData = new FormData();
personalFormData.append(
"full_name",
`${personal.last_name} ${personal.first_name} ${personal.patronymic}`
);
if (personal.birth_date) {
personalFormData.append(
"birth_date",
moment(personal.birth_date).format("YYYY-MM-DD")
);
}
if (personal.gender) {
personalFormData.append("gender", personal.gender?.id);
}
if (
personal.photo.file &&
personal.photo.photo !== this.initDataBasic.personalData.photo.photo
) {
personalFormData.append("photo", personal.photo.file[0]);
}
const request = Object.keys(this.basic).map((key) => {
if (key === "personalData") {
return fetchWrapper.post(
`general/person/${personal.id}/update/`,
personalFormData,
"formData"
);
}
if (key === "registrationAddress") {
let createRegistration = {
person: personal.id,
registration_flg: true,
...registration,
};
return getRequestChangeData(
createRegistration,
registration,
this.initDataBasic[key],
"address",
registration.id
);
}
if (key === "residenceAddress") {
let createResidence = {
person: personal.id,
residence_flg: true,
...residence,
};
return getRequestChangeData(
createResidence,
residence,
this.initDataBasic[key],
"address",
residence.id
);
}
});
return request;
},
saveChange() { saveChange() {
const form = this.$refs.formBasicData; const form = this.$refs.formBasicData;
form.validate().then((validate) => { form.validate().then((validate) => {

View File

@@ -19,26 +19,31 @@ export const baseDataForm = [
key: "last_name", key: "last_name",
label: "Фамилия", label: "Фамилия",
type: "text", type: "text",
disabled: true,
}, },
{ {
key: "first_name", key: "first_name",
label: "Имя", label: "Имя",
type: "text", type: "text",
disabled: true,
}, },
{ {
key: "patronymic", key: "patronymic",
label: "Отчество", label: "Отчество",
type: "text", type: "text",
disabled: true,
}, },
{ {
key: "gender", key: "gender",
label: "Пол", label: "Пол",
type: "select", type: "select",
disabled: true,
}, },
{ {
key: "birth_date", key: "birth_date",
label: "Дата рождения", label: "Дата рождения",
type: "date", type: "date",
disabled: true,
}, },
{ {
key: "photo", key: "photo",