WIP Изменила отправку документов
This commit is contained in:
@@ -75,21 +75,20 @@ export default {
|
||||
return {
|
||||
calendarVisibility: false,
|
||||
internalDate: null,
|
||||
//internalValue: null,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
this.changeInternalDate(
|
||||
moment(this.convertFormat(this.modelValue)).isValid()
|
||||
? moment(this.convertFormat(this.modelValue))
|
||||
moment(this.checkFormat(this.modelValue)).isValid()
|
||||
? moment(this.modelValue)
|
||||
: null
|
||||
);
|
||||
return this.modelValue;
|
||||
return this.convertISOFormat(this.modelValue);
|
||||
},
|
||||
set(value) {
|
||||
this.$emit("update:modelValue", value);
|
||||
this.$emit("update:modelValue", this.convertRUFormat(value));
|
||||
},
|
||||
},
|
||||
sizeVariable() {
|
||||
@@ -138,13 +137,17 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
convertFormat(date) {
|
||||
return date && date?.length === 10
|
||||
? date.split(".").reverse().join("-")
|
||||
: null;
|
||||
convertISOFormat(date) {
|
||||
return date?.split("-")?.reverse()?.join(".");
|
||||
},
|
||||
convertRUFormat(date) {
|
||||
return date?.split(".")?.reverse()?.join("-");
|
||||
},
|
||||
checkFormat(date) {
|
||||
return date && date?.length === 10 ? date : null;
|
||||
},
|
||||
defaultRule(val) {
|
||||
return !val || moment(this.convertFormat(val)).isValid();
|
||||
return !val || moment(this.convertRUFormat(val)).isValid();
|
||||
},
|
||||
closeCalendar() {
|
||||
this.calendarVisibility = false;
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
q-avatar(
|
||||
rounded,
|
||||
size="40px",
|
||||
v-if="docData[data.dataKey][field.key]?.photo"
|
||||
v-if="docData[data.dataKey]?.attachments?.photo"
|
||||
)
|
||||
img.h-10.w-10.object-cover(
|
||||
:src="docData[data.dataKey][field.key]?.photo",
|
||||
:src="docData[data.dataKey]?.attachments?.photo",
|
||||
:alt="docData[data.dataKey][field.label]"
|
||||
)
|
||||
q-badge.delete(
|
||||
@@ -114,6 +114,7 @@ export default {
|
||||
],
|
||||
initializationData: {
|
||||
passport: {
|
||||
category: "passport",
|
||||
id: null,
|
||||
series: null,
|
||||
number: null,
|
||||
@@ -124,11 +125,13 @@ export default {
|
||||
},
|
||||
insurance_number: {
|
||||
id: null,
|
||||
category: "insurance_number",
|
||||
number: null,
|
||||
attachments: null,
|
||||
},
|
||||
tax_identification_number: {
|
||||
id: null,
|
||||
category: "tax_identification_number",
|
||||
number: null,
|
||||
attachments: null,
|
||||
},
|
||||
@@ -143,7 +146,14 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
initialDocData() {
|
||||
return this.$store.state.medical?.documents;
|
||||
// const { passport, insurance_number, tax_identification_number } =
|
||||
// this.$store.state.medical.documents;
|
||||
// return {
|
||||
// passport: passport,
|
||||
// insurance_number: insurance_number,
|
||||
// tax_identification_number: tax_identification_number,
|
||||
// };
|
||||
return this.$store.state.medical.documents;
|
||||
},
|
||||
passportFields() {
|
||||
let excludedFields = ["attachments", "id", "category"];
|
||||
@@ -179,7 +189,15 @@ export default {
|
||||
return !this.isEdit && this.copiedFields.some((elem) => elem === key);
|
||||
},
|
||||
cancelEdit() {
|
||||
this.docData = JSON.parse(JSON.stringify(this.initialDocData));
|
||||
const { passport, insurance_number, tax_identification_number } =
|
||||
this.initialDocData;
|
||||
this.docData = {
|
||||
passport: JSON.parse(JSON.stringify(passport)),
|
||||
insurance_number: JSON.parse(JSON.stringify(insurance_number)),
|
||||
tax_identification_number: JSON.parse(
|
||||
JSON.stringify(tax_identification_number)
|
||||
),
|
||||
};
|
||||
this.isEdit = false;
|
||||
this.isCheckChange = false;
|
||||
this.$refs.documentForm.resetValidation();
|
||||
@@ -215,61 +233,34 @@ export default {
|
||||
} else {
|
||||
let request = [];
|
||||
Object.keys(this.docData).forEach((elem) => {
|
||||
let formData = new FormData();
|
||||
form
|
||||
.getValidationComponents()
|
||||
.filter(({ name }) => name?.split(":")?.[0] === elem)
|
||||
.forEach((el) => {
|
||||
const name = el?.name?.split(":")?.[1];
|
||||
if (name === "issued_at")
|
||||
formData.append(name, this.convertFormat(el.modelValue));
|
||||
else formData.append(name, el.modelValue ?? "");
|
||||
});
|
||||
this.checkChangePhoto(elem, "attachments", formData);
|
||||
if (formData.get("attachments")) {
|
||||
console.log(elem, "img", formData.get("attachments"));
|
||||
formData.delete("attachments");
|
||||
}
|
||||
if (formData.get("issued_by_org_code")) {
|
||||
this.checkChangePhoto(elem, "attachments");
|
||||
let newData = JSON.parse(JSON.stringify(this.docData[elem]));
|
||||
newData.attachments = {};
|
||||
if (!checkChangeData(this.initialDocData?.[elem], newData)) return;
|
||||
delete newData.id;
|
||||
if (newData?.issued_by_org_code) {
|
||||
console.log(
|
||||
"issued_by_org_code",
|
||||
formData.get("issued_by_org_code")
|
||||
"passport issued_by_org_code",
|
||||
newData.issued_by_org_code
|
||||
);
|
||||
formData.delete("issued_by_org_code");
|
||||
delete newData.issued_by_org_code;
|
||||
}
|
||||
if (
|
||||
!checkChangeData(
|
||||
this.initialDocData?.[elem],
|
||||
this.docData?.[elem]
|
||||
)
|
||||
)
|
||||
return;
|
||||
formData.append("category", elem);
|
||||
delete newData.attachments;
|
||||
if (!this.initialDocData?.[elem]?.id) {
|
||||
formData.append(
|
||||
"person_id",
|
||||
this.$store.state.medical?.basicData?.personalData?.id
|
||||
);
|
||||
// for (const key of formData.keys()) {
|
||||
// console.log(key, formData.get(key));
|
||||
// }
|
||||
request.push(this.createData("documents/", formData));
|
||||
} else {
|
||||
// for (const key of formData.keys()) {
|
||||
// console.log(key, formData.get(key));
|
||||
// }
|
||||
newData.person_id =
|
||||
this.$store.state.medical?.basicData?.personalData?.id;
|
||||
console.log("create", newData);
|
||||
request.push(this.createData("documents/", newData));
|
||||
} else console.log("create", newData);
|
||||
request.push(
|
||||
this.updateData(
|
||||
`documents/${this.initialDocData?.[elem]?.id}`,
|
||||
formData
|
||||
newData
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
Promise.allSettled(request).then(() => {
|
||||
this.getMedicalCardData({
|
||||
personId: this.$store.state.medical?.basicData?.personalData?.id,
|
||||
});
|
||||
this.getMedicalCardData(this.$route.params.id);
|
||||
this.isEdit = false;
|
||||
this.isCheckChange = false;
|
||||
this.$refs.form?.resetValidation();
|
||||
@@ -277,21 +268,19 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
checkChangePhoto(updatedObjId, field, formData) {
|
||||
checkChangePhoto(updatedObjId, field) {
|
||||
if (this.docData[updatedObjId][field]?.file)
|
||||
formData.append(field, this.docData[updatedObjId][field]?.file[0]);
|
||||
},
|
||||
checkPhotoDeletion(updatedObjId, field) {
|
||||
return (
|
||||
!Object.keys(this.docData[updatedObjId][field]).length &&
|
||||
this.initialDocData[updatedObjId][field]?.photo
|
||||
console.log(
|
||||
updatedObjId,
|
||||
field,
|
||||
this.docData[updatedObjId][field]?.file[0]
|
||||
);
|
||||
},
|
||||
async createData(url, body) {
|
||||
return await fetchWrapper.post(url, body, "formData");
|
||||
return await fetchWrapper.post(url, body);
|
||||
},
|
||||
async updateData(url, body) {
|
||||
return await fetchWrapper.patch(url, body, "formData");
|
||||
return await fetchWrapper.patch(url, body);
|
||||
},
|
||||
async deletePhoto(url) {
|
||||
return await fetchWrapper.del(url);
|
||||
@@ -303,7 +292,7 @@ export default {
|
||||
return date ? date.split(".").reverse().join("-") : "";
|
||||
},
|
||||
...mapActions({
|
||||
getMedicalCardData: "getMedicalCardDataByPersonId",
|
||||
getMedicalCardData: "getMedicalCardDataById",
|
||||
}),
|
||||
},
|
||||
watch: {
|
||||
@@ -312,7 +301,15 @@ export default {
|
||||
immediate: true,
|
||||
handler(value) {
|
||||
if (Object.keys(value).length) {
|
||||
this.docData = JSON.parse(JSON.stringify(value));
|
||||
const { passport, insurance_number, tax_identification_number } =
|
||||
value;
|
||||
this.docData = {
|
||||
passport: JSON.parse(JSON.stringify(passport)),
|
||||
insurance_number: JSON.parse(JSON.stringify(insurance_number)),
|
||||
tax_identification_number: JSON.parse(
|
||||
JSON.stringify(tax_identification_number)
|
||||
),
|
||||
};
|
||||
} else this.docData = this.initializationData;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
) {{"\xa0" + basic?.benefit[insurance?.discount] + "%"}}
|
||||
.input-container.flex.flex-col.relative(v-else)
|
||||
base-input(
|
||||
v-model="basic[insurance.insuranceKey][field.key]",
|
||||
v-model="insuranceData[insurance.insuranceKey][field.key]",
|
||||
@update:model-value="checkChangeInput",
|
||||
:mask="field?.inputMask",
|
||||
:readonly="!isEdit",
|
||||
@@ -125,18 +125,26 @@ export default {
|
||||
showModalCategories: false,
|
||||
photoId: "",
|
||||
copiedFields: ["series", "number"],
|
||||
insuranceData: {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
url: "getUrl",
|
||||
avatar: "getAvatar",
|
||||
initDataBasic: "getBasicData",
|
||||
//avatar: "getAvatar",
|
||||
//initDataBasic: "getBasicData",
|
||||
}),
|
||||
...mapState({
|
||||
basic: (state) => state.medical?.basicData,
|
||||
benefitData: (state) => state.medical?.benefitData,
|
||||
}),
|
||||
initialDocData() {
|
||||
const { OMS, DMS } = this.$store.state.medical.documents;
|
||||
return {
|
||||
OMS: OMS,
|
||||
DMS: DMS,
|
||||
};
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
filterDataBenefit(text) {
|
||||
@@ -170,23 +178,25 @@ export default {
|
||||
this.isCheckChange = true;
|
||||
},
|
||||
changeModal(id) {
|
||||
if (id === "benefit") return;
|
||||
this.photoId = id;
|
||||
this.showModal = true;
|
||||
},
|
||||
closeModalCategories() {
|
||||
this.showModalCategories = false;
|
||||
},
|
||||
openModalCategories() {
|
||||
//if (this.isEdit) this.showModalCategories = true;
|
||||
},
|
||||
checkChangeInput() {
|
||||
this.isCheckChange =
|
||||
JSON.stringify(this.initDataBasic) !== JSON.stringify(this.basic)
|
||||
? true
|
||||
: false;
|
||||
JSON.stringify(this.initialDocData) !==
|
||||
JSON.stringify(this.insuranceData);
|
||||
},
|
||||
confirmChangePhoto() {
|
||||
this.showModal = false;
|
||||
this.isCheckChange = true;
|
||||
},
|
||||
|
||||
updateBasicData() {
|
||||
let insuranceDMS = this.basic.insuranceDMS;
|
||||
let insuranceOMS = this.basic.insuranceOMS;
|
||||
@@ -360,6 +370,21 @@ export default {
|
||||
});
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
showModalCategories: {
|
||||
immediate: true,
|
||||
handler(newVal) {
|
||||
if (newVal) this.$store.dispatch("getBenefitData");
|
||||
},
|
||||
},
|
||||
initialDocData: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(newVal) {
|
||||
this.insuranceData = JSON.parse(JSON.stringify(newVal));
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
basic-data-form
|
||||
//contacts-form
|
||||
documents-form
|
||||
insurance-form
|
||||
//insurance-form
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -379,7 +379,7 @@ export const baseInfoMenu = [
|
||||
export const baseInsuranceForm = [
|
||||
{
|
||||
insuranceLabel: "ОМС",
|
||||
insuranceKey: "insuranceOMS",
|
||||
insuranceKey: "OMS",
|
||||
fields: [
|
||||
{
|
||||
key: "series",
|
||||
@@ -394,15 +394,15 @@ export const baseInsuranceForm = [
|
||||
inputMask: "####-####-####",
|
||||
},
|
||||
{
|
||||
key: "photo",
|
||||
key: "attachments",
|
||||
label: "Фото ОМС",
|
||||
type: "avatar",
|
||||
type: "photo",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
insuranceLabel: "ДМС",
|
||||
insuranceKey: "insuranceDMS",
|
||||
insuranceKey: "DMS",
|
||||
fields: [
|
||||
{
|
||||
key: "series",
|
||||
@@ -417,9 +417,9 @@ export const baseInsuranceForm = [
|
||||
inputMask: "####-####-####",
|
||||
},
|
||||
{
|
||||
key: "photo",
|
||||
key: "attachments",
|
||||
label: "Фото ДМС",
|
||||
type: "avatar",
|
||||
type: "photo",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -436,7 +436,7 @@ export const baseInsuranceForm = [
|
||||
{
|
||||
key: "photo",
|
||||
label: "Документы",
|
||||
type: "avatar",
|
||||
type: "photo",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -34,20 +34,20 @@ const state = () => ({
|
||||
house: null,
|
||||
flat: null,
|
||||
},
|
||||
insuranceDMS: {
|
||||
series: null,
|
||||
number: null,
|
||||
photo: null,
|
||||
id: null,
|
||||
organization: null,
|
||||
},
|
||||
insuranceOMS: {
|
||||
series: null,
|
||||
number: null,
|
||||
photo: null,
|
||||
id: null,
|
||||
organization: null,
|
||||
},
|
||||
// insuranceDMS: {
|
||||
// series: null,
|
||||
// number: null,
|
||||
// photo: null,
|
||||
// id: null,
|
||||
// organization: null,
|
||||
// },
|
||||
// insuranceOMS: {
|
||||
// series: null,
|
||||
// number: null,
|
||||
// photo: null,
|
||||
// id: null,
|
||||
// organization: null,
|
||||
// },
|
||||
benefit: {
|
||||
id: null,
|
||||
discount: null,
|
||||
@@ -142,8 +142,6 @@ const getters = {
|
||||
(el) => el.category === "CURRENT_ADDRESS"
|
||||
) || {};
|
||||
let person = state.medicalCard.person;
|
||||
let OMS = person?.insurance_policy?.find((e) => e.title === "OMS");
|
||||
let DMS = person?.insurance_policy?.find((e) => e.title === "DMS");
|
||||
return {
|
||||
personalData: {
|
||||
last_name: person?.last_name || "",
|
||||
@@ -176,30 +174,6 @@ const getters = {
|
||||
house: residenceAddress?.house || "",
|
||||
flat: residenceAddress?.flat || "",
|
||||
},
|
||||
insuranceDMS: {
|
||||
series: DMS?.series,
|
||||
number: DMS?.number,
|
||||
photo: DMS?.photo
|
||||
? {
|
||||
photo: rootState.getUrl + DMS?.photo,
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
id: DMS?.id,
|
||||
organization: DMS?.organization,
|
||||
},
|
||||
insuranceOMS: {
|
||||
series: OMS?.series,
|
||||
number: OMS?.number,
|
||||
photo: OMS?.photo
|
||||
? {
|
||||
photo: rootState.getUrl + OMS?.photo,
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
id: OMS?.id,
|
||||
organization: OMS?.organization,
|
||||
},
|
||||
benefit: {
|
||||
name: person?.benefit?.name,
|
||||
id: person?.benefit?.id,
|
||||
@@ -214,27 +188,25 @@ const getters = {
|
||||
};
|
||||
},
|
||||
getDocumentsData(state, rootState) {
|
||||
const person = state.medicalCard?.person,
|
||||
passport = person?.documents?.find(
|
||||
({ category }) => category === "passport"
|
||||
),
|
||||
insurance_number = person?.documents?.find(
|
||||
const documents = state.medicalCard?.person?.documents,
|
||||
passport = documents?.find(({ category }) => category === "passport"),
|
||||
insurance_number = documents?.find(
|
||||
({ category }) => category === "insurance_number"
|
||||
),
|
||||
tax_identification_number = person?.documents?.find(
|
||||
tax_identification_number = documents?.find(
|
||||
({ category }) => category === "tax_identification_number"
|
||||
);
|
||||
),
|
||||
OMS = documents?.find(({ category }) => category === "OMS"),
|
||||
DMS = documents?.find(({ category }) => category === "DMS");
|
||||
return {
|
||||
passport: {
|
||||
category: passport?.category || "",
|
||||
category: "passport",
|
||||
id: passport?.id || "",
|
||||
series: passport?.series || "",
|
||||
number: passport?.number || "",
|
||||
issued_by: passport?.issued_by || "",
|
||||
issued_by_org_code: passport?.issued_by_org_code || "",
|
||||
issued_at: passport?.issued_at
|
||||
? passport?.issued_at?.split("-")?.reverse()?.join(".")
|
||||
: "",
|
||||
issued_at: passport?.issued_at ? passport?.issued_at : "",
|
||||
attachments: passport?.attachments?.length
|
||||
? {
|
||||
photo: rootState.getUrl + passport?.attachments?.[0],
|
||||
@@ -243,7 +215,7 @@ const getters = {
|
||||
: {},
|
||||
},
|
||||
insurance_number: {
|
||||
category: insurance_number?.category || "",
|
||||
category: "insurance_number",
|
||||
id: insurance_number?.id || "",
|
||||
number: insurance_number?.number || "",
|
||||
attachments: insurance_number?.attachments?.length
|
||||
@@ -254,7 +226,7 @@ const getters = {
|
||||
: {},
|
||||
},
|
||||
tax_identification_number: {
|
||||
category: tax_identification_number?.category || "",
|
||||
category: "tax_identification_number",
|
||||
id: tax_identification_number?.id || "",
|
||||
number: tax_identification_number?.number || "",
|
||||
attachments: tax_identification_number?.attachments?.length
|
||||
@@ -265,6 +237,28 @@ const getters = {
|
||||
}
|
||||
: {},
|
||||
},
|
||||
OMS: {
|
||||
category: OMS?.category || "",
|
||||
id: OMS?.id || "",
|
||||
number: OMS?.number || "",
|
||||
attachments: OMS?.attachments?.length
|
||||
? {
|
||||
photo: rootState.getUrl + OMS?.attachments?.[0],
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
},
|
||||
DMS: {
|
||||
category: DMS?.category || "",
|
||||
id: DMS?.id || "",
|
||||
number: DMS?.number || "",
|
||||
attachments: OMS?.attachments?.length
|
||||
? {
|
||||
photo: rootState.getUrl + DMS?.attachments?.[0],
|
||||
file: null,
|
||||
}
|
||||
: {},
|
||||
},
|
||||
};
|
||||
},
|
||||
getContactsData(state) {
|
||||
|
||||
Reference in New Issue
Block a user