[WIP] Исправил отправку основных данных

This commit is contained in:
megavrilinvv
2023-08-16 17:59:26 +03:00
parent b7af4b15ca
commit 15cb788fcc
2 changed files with 32 additions and 15 deletions

View File

@@ -121,7 +121,8 @@ export default {
}, },
methods: { methods: {
...mapActions({ ...mapActions({
postAddress: "postAddress", createAddress: "postCreateAddress",
updateAddress: "postUpdateAddress",
}), }),
updateBasicData() { updateBasicData() {
const photoFormData = new FormData(); const photoFormData = new FormData();
@@ -137,25 +138,35 @@ export default {
if (key === "registrationAddress") if (key === "registrationAddress")
this.getRequestChangeData( this.getRequestChangeData(
this.basic.registrationAddress, this.basic.registrationAddress,
this.initDataBasic[key] this.initDataBasic[key],
"Адрес регистрации"
); );
if (key === "residenceAddress") if (key === "residenceAddress")
this.getRequestChangeData( this.getRequestChangeData(
this.basic.residenceAddress, this.basic.residenceAddress,
this.initDataBasic[key] this.initDataBasic[key],
"Адрес проживания"
); );
}); });
this.isEdit = false; this.isEdit = false;
}, },
getRequestChangeData(updateData, initData) { getRequestChangeData(updateData, initData, key) {
if ( let isInitDataEmpty = [...Object.keys(removeEmptyFields(initData))]
Object.keys(removeEmptyFields(updateData)).length && .length;
JSON.stringify(updateData) !== JSON.stringify(initData) if (Object.keys(removeEmptyFields(updateData)).length) {
) if (!isInitDataEmpty)
return this.postAddress({ return this.createAddress({
id: this.basic.personalData.id, id: this.basic.personalData.id,
address: updateData, address: updateData,
category: key,
}); });
if (JSON.stringify(updateData) !== JSON.stringify(initData))
return this.updateAddress({
id: this.basic.personalData.id,
address: updateData,
category: key,
});
}
}, },
checkRow(label) { checkRow(label) {
return label === "Личные данные" ? true : !this.isEdit; return label === "Личные данные" ? true : !this.isEdit;

View File

@@ -165,7 +165,6 @@ const getters = {
street: registrationAddress?.street || "", street: registrationAddress?.street || "",
house: registrationAddress?.house || "", house: registrationAddress?.house || "",
flat: registrationAddress?.flat || "", flat: registrationAddress?.flat || "",
category: "Адрес регистрации",
}, },
residenceAddress: { residenceAddress: {
region: residenceAddress?.region || "", region: residenceAddress?.region || "",
@@ -173,7 +172,6 @@ const getters = {
street: residenceAddress?.street || "", street: residenceAddress?.street || "",
house: residenceAddress?.house || "", house: residenceAddress?.house || "",
flat: residenceAddress?.flat || "", flat: residenceAddress?.flat || "",
category: "Адрес проживания",
}, },
insuranceDMS: { insuranceDMS: {
series: DMS?.series, series: DMS?.series,
@@ -429,9 +427,17 @@ const getters = {
}; };
const actions = { const actions = {
postAddress(context, { id, address }) { postCreateAddress(context, { id, address, category }) {
fetchWrapper.post(`address`, {
person_id: id,
...address,
category: category,
});
},
postUpdateAddress(context, { id, address, category }) {
fetchWrapper.post(`address/${id}`, { fetchWrapper.post(`address/${id}`, {
...address, ...address,
category: category,
}); });
}, },
deleteItemData({ commit }, props) { deleteItemData({ commit }, props) {