WIP Паспортные данные отображаются при изменении
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
<template lang="pug">
|
||||
.base-select(@click="open = !open", :class="{'open': open && !disable, 'border-none': borderNone}")
|
||||
.placeholder.text-base(:class="{'value-color': value || placeholderOpacity}") {{ value || placeholder }}
|
||||
.base-select(@click="open = !open", :class="{'open': open, 'border-none': borderNone}")
|
||||
.placeholder(
|
||||
:class="{'value-color': value || placeholderOpacity, ...textClass}"
|
||||
) {{ value || placeholder }}
|
||||
.flex.items-center
|
||||
.select-form-separator.cursor-pointer.mr-4(v-if="separator")
|
||||
span.icon-down-arrow.open-icon(:class="{'open': open && !disable }")
|
||||
base-menu(v-if="open")
|
||||
.items-container(@click="open = false", v-click-outside="leaveSelect")
|
||||
.items-container(
|
||||
@click="open = false",
|
||||
v-click-outside="leaveSelect",
|
||||
:class="textClass"
|
||||
)
|
||||
.item(v-for="item in items", :key="item.id" @click="clickItem(item.label)") {{ item.label }}
|
||||
</template>
|
||||
|
||||
@@ -25,6 +31,7 @@ export default {
|
||||
separator: Boolean,
|
||||
placeholderOpacity: Boolean,
|
||||
disable: Boolean,
|
||||
textStyle: String,
|
||||
},
|
||||
emits: ["update:modelValue"],
|
||||
data() {
|
||||
@@ -41,6 +48,15 @@ export default {
|
||||
this.$emit("update:modelValue", value);
|
||||
},
|
||||
},
|
||||
textClass() {
|
||||
return this.textStyle
|
||||
? {
|
||||
[this.textStyle]: true,
|
||||
}
|
||||
: {
|
||||
"text-base": true,
|
||||
};
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
clickItem(id) {
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
span.title-section.font-semibold.text-xs(
|
||||
v-if="settings[section].options") {{settings[section].options[key]}}
|
||||
span.title-section.font-semibold.text-xs(v-if="item.header") {{item.header}}
|
||||
client-detail-input.text-sm.text-sm.w-max-fit(
|
||||
client-detail-input.text-sm.w-max-fit(
|
||||
v-if="section!=='docs' && isChange && settings[section].options[key] !== 'Дата выдачи'",
|
||||
:style="{fontWeight:key === 'numba'&&600, maxHeight: settings[section].options[key] !== 'Выдан' ? '40px' : ''}",
|
||||
v-model:value="sectionInfo[key]",
|
||||
@@ -70,7 +70,7 @@
|
||||
:placeholder="settings[section].placeholder[key]"
|
||||
:sharp="settings[section].sharps[key] && section === 'pass' ? settings[section].sharps[key] : ''"
|
||||
)
|
||||
base-input-date.input(
|
||||
base-input-date.input.text-sm(
|
||||
v-else-if="isChange && section !== 'docs'",
|
||||
v-model:value="sectionInfo.issued_by_date"
|
||||
)
|
||||
@@ -79,7 +79,7 @@
|
||||
@click="() => copyValue(item)"
|
||||
)
|
||||
.flex(v-if="settings[section].options && !isChange")
|
||||
span.text-sm.w-fit(:style="{fontWeight:key === 'numba'&&600}") {{item}}
|
||||
span.text-sm.w-fit(:style="{fontWeight:key === 'numba'&&600}") {{item === 'issued_by_date' ? formattedDate : item}}
|
||||
.copy.icon-copy.cursor-pointer.pl-4(
|
||||
v-if="key === 'numba'",
|
||||
@click="() => copyValue(item)"
|
||||
@@ -125,6 +125,7 @@ import { detail } from "@/pages/clients/utils/tableConfig";
|
||||
import pdfIcon from "@/assets/icons/pdf.svg";
|
||||
import wordIcon from "@/assets/icons/word.svg";
|
||||
import exelIcon from "@/assets/icons/exel.svg";
|
||||
import * as moment from "moment";
|
||||
export default {
|
||||
name: "ClientDetailInfoSection",
|
||||
components: {
|
||||
@@ -188,6 +189,11 @@ export default {
|
||||
? "var(--light-grey-bg-color)"
|
||||
: "var(--default-white)";
|
||||
},
|
||||
formattedDate() {
|
||||
return this.sectionInfo["issued_by_date"]
|
||||
? this.sectionInfo.issued_by_date.split("-").reverse().join(".")
|
||||
: "";
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openAddDoc() {
|
||||
@@ -220,13 +226,39 @@ export default {
|
||||
this.showModal = false;
|
||||
this.saveDocs();
|
||||
},
|
||||
checkDataPresence(data) {
|
||||
let postData = JSON.parse(JSON.stringify(data));
|
||||
let keys = Object.keys(postData);
|
||||
keys.forEach((key) => {
|
||||
if (!postData[key]) {
|
||||
delete postData[key];
|
||||
}
|
||||
});
|
||||
return postData;
|
||||
},
|
||||
changeDoc() {
|
||||
this.isChange = false;
|
||||
if (this.section === "pass") {
|
||||
this.docId ? this.updateDocument() : this.createDocument();
|
||||
if (!this.docId) {
|
||||
let changedData = Object.keys(
|
||||
this.checkDataPresence(this.sectionInfo)
|
||||
);
|
||||
if (
|
||||
changedData.length !== Object.keys(this.sectionInfo).length ||
|
||||
moment(this.sectionInfo.issued_by_date).isAfter(
|
||||
moment().format("YYYY-MM-DD")
|
||||
)
|
||||
) {
|
||||
this.isData = false;
|
||||
}
|
||||
this.createDocument();
|
||||
} else this.updateDocument();
|
||||
}
|
||||
if (this.section === "addresses") {
|
||||
this.addressId ? this.updateAddress() : this.createAddress();
|
||||
if (!this.addressId) {
|
||||
if (this.sectionInfo.join_adress === "") this.isAddress = false;
|
||||
this.createAddress();
|
||||
} else this.updateAddress();
|
||||
}
|
||||
},
|
||||
copyValue(text) {
|
||||
@@ -267,15 +299,18 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
lackData: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
if (this.isData !== newValue) {
|
||||
this.isData = newValue;
|
||||
}
|
||||
},
|
||||
},
|
||||
lackAddress: {
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
this.isAddress = newValue;
|
||||
if (this.isAddress !== newValue) this.isAddress = newValue;
|
||||
},
|
||||
},
|
||||
lackAttachments: {
|
||||
@@ -359,4 +394,5 @@ export default {
|
||||
|
||||
.input
|
||||
border: 1.5px solid var(--border-light-grey-color)
|
||||
height: 40px
|
||||
</style>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
.text-info.text-xxs.font-semibold Город
|
||||
base-select.cursor-grab(
|
||||
disable,
|
||||
textStyle="text-sm",
|
||||
placeholder="Введите город",
|
||||
v-model="dopeAddress.city",
|
||||
:style="{backgroundColor: 'var(--bg-disable-grey-color)'}"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
:client="client",
|
||||
:deleted-client-id="deletedRowId",
|
||||
:update-data-client="updateDataClient",
|
||||
:fetch-data-clients="fetchDataClients",
|
||||
@delete-client="deleteClientHandler",
|
||||
@recover-client="clearDeletedRowId",
|
||||
)
|
||||
|
||||
@@ -86,22 +86,22 @@
|
||||
)
|
||||
client-detail-info-wrapper.detail(
|
||||
v-if="isOpenDetailInfo",
|
||||
:data-address="dataAddress"
|
||||
:data-detail="dataDetail"
|
||||
:data-attachments="dataAttachments"
|
||||
:data-document="dataIdentityDocument"
|
||||
:save-new-doc="saveNewDoc"
|
||||
:delete-doc="deleteDoc"
|
||||
:update-document="postUpdateIdentityDocument"
|
||||
:update-address="postUpdateAddress"
|
||||
:lack-data="lackData"
|
||||
:lack-address="lackAddress"
|
||||
:dope-address="dopeAddress"
|
||||
:lack-attachments="lackAttachments"
|
||||
:create-address="postCreateAddress"
|
||||
:create-document="postCreateIdentityDocument"
|
||||
:address-id="addressId"
|
||||
:doc-id="docId"
|
||||
:data-address="dataAddress",
|
||||
:data-detail="dataDetail",
|
||||
:data-attachments="dataAttachments",
|
||||
:data-document="dataIdentityDocument",
|
||||
:save-new-doc="saveNewDoc",
|
||||
:delete-doc="deleteDoc",
|
||||
:update-document="postUpdateIdentityDocument",
|
||||
:update-address="postUpdateAddress",
|
||||
:lack-data="lackData",
|
||||
:lack-address="lackAddress",
|
||||
:dope-address="dopeAddress",
|
||||
:lack-attachments="lackAttachments",
|
||||
:create-address="postCreateAddress",
|
||||
:create-document="postCreateIdentityDocument",
|
||||
:address-id="addressId",
|
||||
:doc-id="docId",
|
||||
)
|
||||
</template>
|
||||
|
||||
@@ -178,6 +178,7 @@ export default {
|
||||
deletedClientId: String,
|
||||
updateDataClient: Function,
|
||||
url: String,
|
||||
fetchDataClients: Function,
|
||||
},
|
||||
computed: {
|
||||
rowOverlay() {
|
||||
@@ -223,6 +224,7 @@ export default {
|
||||
data.birth_date = this.dataClient.age;
|
||||
else if (!this.dataClient.age) {
|
||||
this.addErrorNotification(
|
||||
"Некорректная дата рождения",
|
||||
"Пожалуйста, введите дату рождения корректно"
|
||||
);
|
||||
this.dataClient.age = this.client.birth_date || "";
|
||||
@@ -233,12 +235,17 @@ export default {
|
||||
data.birth_date &&
|
||||
moment(data.birth_date).isAfter(moment().format("YYYY-MM-DD"))
|
||||
) {
|
||||
this.addErrorNotification("Дата рождения позже текущего дня");
|
||||
this.addErrorNotification(
|
||||
"Некорректная дата рождения",
|
||||
"Дата рождения позже текущего дня"
|
||||
);
|
||||
this.dataClient.age = this.client.birth_date || "";
|
||||
} else if (!Object.keys(data).length == 0)
|
||||
fetchWrapper.post(`general/person/${this.client.id}/update/`, {
|
||||
fetchWrapper
|
||||
.post(`general/person/${this.client.id}/update/`, {
|
||||
...data,
|
||||
});
|
||||
})
|
||||
.then(() => this.fetchDataClients());
|
||||
},
|
||||
postContactsClient() {
|
||||
let contacts = [...this.dataClient.contacts];
|
||||
@@ -334,26 +341,14 @@ export default {
|
||||
},
|
||||
async deleteClient() {
|
||||
await fetchWrapper.del(`general/person/${this.client.id}/delete/`);
|
||||
this.addSuccessNotification();
|
||||
this.addSuccessNotification("Клиент Успешно удален", "");
|
||||
this.handleUnFocusPopup();
|
||||
},
|
||||
addSuccessNotification() {
|
||||
addNotification(
|
||||
new Date().getTime(),
|
||||
"Клиент Успешно удален",
|
||||
"",
|
||||
"success",
|
||||
5000
|
||||
);
|
||||
addSuccessNotification(title, message) {
|
||||
addNotification(new Date().getTime(), title, message, "success", 5000);
|
||||
},
|
||||
addErrorNotification(message) {
|
||||
addNotification(
|
||||
"Некорректная дата рождения",
|
||||
"Некорректная дата рождения",
|
||||
message,
|
||||
"error",
|
||||
5000
|
||||
);
|
||||
addErrorNotification(title, message) {
|
||||
addNotification(title, title, message, "error", 5000);
|
||||
},
|
||||
fetchClientDetail(id) {
|
||||
fetchWrapper
|
||||
@@ -388,9 +383,7 @@ export default {
|
||||
issued_by_org_code: data.issued_by_org_code
|
||||
? data?.issued_by_org_code
|
||||
: "",
|
||||
issued_by_date: data.issued_by_date
|
||||
? data?.issued_by_date.split("-").reverse().join(".")
|
||||
: "",
|
||||
issued_by_date: data.issued_by_date ? data?.issued_by_date : "",
|
||||
};
|
||||
this.lackData = true;
|
||||
} else {
|
||||
@@ -410,12 +403,28 @@ export default {
|
||||
series_number: this.dataIdentityDocument.numba,
|
||||
issued_by_org: this.dataIdentityDocument.issued_by_org,
|
||||
issued_by_org_code: this.dataIdentityDocument.issued_by_org_code,
|
||||
issued_by_date: this.dataIdentityDocument.issued_by_date
|
||||
.split(".")
|
||||
.reverse()
|
||||
.join("-"),
|
||||
issued_by_date: this.dataIdentityDocument.issued_by_date,
|
||||
})
|
||||
.then(() => this.fetchClientDetail(this.id));
|
||||
.then((response) => {
|
||||
this.fetchClientDetail(this.id);
|
||||
if (response.type) {
|
||||
if (response.errors[0].code === "blank")
|
||||
this.addErrorNotification(
|
||||
"Ошибка создания ДУЛ",
|
||||
"Часть паспортных данных не заполнена"
|
||||
);
|
||||
if (response.errors[0].code === "Ошибка создания ДУЛ")
|
||||
this.addErrorNotification(
|
||||
response.errors[0].code,
|
||||
response.errors[0].detail
|
||||
);
|
||||
if (response?.errors[0].code === "invalid")
|
||||
this.addErrorNotification(
|
||||
"Ошибка создания ДУЛ",
|
||||
"Дата выдачи паспорта не заполнена"
|
||||
);
|
||||
} else this.addSuccessNotification("Изменения успешно сохранены", "");
|
||||
});
|
||||
},
|
||||
saveAddress(data) {
|
||||
this.addressId = data?.id;
|
||||
@@ -456,7 +465,15 @@ export default {
|
||||
.post(`general/address/${this.addressId}/update/`, {
|
||||
full_address: this.mergeFullAddress() || this.dataAddress.join_adress,
|
||||
})
|
||||
.then(() => this.fetchClientDetail(this.id));
|
||||
.then((response) => {
|
||||
this.fetchClientDetail(this.id);
|
||||
if (response.type && response.errors[0].code === "blank")
|
||||
this.addErrorNotification(
|
||||
"Ошибка именения адреса",
|
||||
"Полный адрес не заполнен"
|
||||
);
|
||||
else this.addSuccessNotification("Изменения успешно сохранены", "");
|
||||
});
|
||||
this.clearAddress();
|
||||
},
|
||||
openPopup(e) {
|
||||
@@ -494,7 +511,15 @@ export default {
|
||||
person_id: this.id,
|
||||
full_address: this.mergeFullAddress() || this.dataAddress.join_adress,
|
||||
})
|
||||
.then(() => this.fetchClientDetail(this.id));
|
||||
.then((response) => {
|
||||
this.fetchClientDetail(this.id);
|
||||
if (response.type && response.errors[0].code === "blank")
|
||||
this.addErrorNotification(
|
||||
"Ошибка создания адреса",
|
||||
"Полный адрес не заполнен"
|
||||
);
|
||||
else this.addSuccessNotification("Полный адрес успешно создан", "");
|
||||
});
|
||||
},
|
||||
postCreateIdentityDocument() {
|
||||
fetchWrapper
|
||||
@@ -504,12 +529,32 @@ export default {
|
||||
series_number: this.dataIdentityDocument.numba,
|
||||
issued_by_org: this.dataIdentityDocument.issued_by_org,
|
||||
issued_by_org_code: this.dataIdentityDocument.issued_by_org_code,
|
||||
issued_by_date: this.dataIdentityDocument.issued_by_date
|
||||
.split(".")
|
||||
.reverse()
|
||||
.join("-"),
|
||||
issued_by_date: this.dataIdentityDocument.issued_by_date,
|
||||
})
|
||||
.then(() => this.fetchClientDetail(this.id));
|
||||
.then((response) => {
|
||||
this.fetchClientDetail(this.id);
|
||||
if (response.type) {
|
||||
if (response.errors[0].code === "blank")
|
||||
this.addErrorNotification(
|
||||
"Ошибка создания ДУЛ",
|
||||
"Часть паспортных данных не заполнена"
|
||||
);
|
||||
if (response.errors[0].code === "Ошибка создания ДУЛ")
|
||||
this.addErrorNotification(
|
||||
response.errors[0].code,
|
||||
response.errors[0].detail
|
||||
);
|
||||
if (response.errors[0].code === "invalid")
|
||||
this.addErrorNotification(
|
||||
"Ошибка создания ДУЛ",
|
||||
"Дата выдачи паспорта не заполнена"
|
||||
);
|
||||
} else
|
||||
this.addSuccessNotification(
|
||||
"Паспортные данные успешно созданы",
|
||||
""
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
||||
Reference in New Issue
Block a user