Исправила отображение контактов на записи
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
v-if="field.type === 'date'",
|
||||
v-model="docData[data.dataKey][field.key]",
|
||||
:name="data.dataKey + ':' + field.key",
|
||||
@update:model-value="checkChangeDocData(data.dataKey)",
|
||||
@update:model-value="checkChangeDocData",
|
||||
:readonly="!isEdit",
|
||||
:width="302",
|
||||
:mask="field?.inputMask",
|
||||
@@ -57,7 +57,7 @@
|
||||
v-if="field.type === 'text'",
|
||||
v-model="docData[data.dataKey][field.key]",
|
||||
:name="data.dataKey + ':' + field.key",
|
||||
@update:model-value="checkChangeDocData(data.dataKey)",
|
||||
@update:model-value="checkChangeDocData",
|
||||
:readonly="!isEdit",
|
||||
:type="field.type",
|
||||
:width="302",
|
||||
@@ -105,7 +105,6 @@ export default {
|
||||
docData: null,
|
||||
isCheckChange: false,
|
||||
isLoadingData: true,
|
||||
approvedPassportData: false,
|
||||
copiedFields: [
|
||||
"series",
|
||||
"number",
|
||||
@@ -165,15 +164,13 @@ export default {
|
||||
.getValidationComponents()
|
||||
.filter((elem) => !this.personDataField.includes(elem.name))
|
||||
.forEach((elem) => elem.resetValidation());
|
||||
this.approvedPassportData = true;
|
||||
return true;
|
||||
}
|
||||
this.approvedPassportData = false;
|
||||
return defaultRule(val);
|
||||
},
|
||||
removeImage(docKey, field) {
|
||||
this.docData[docKey][field] = {};
|
||||
this.isCheckChange = true;
|
||||
this.checkChangeDocData();
|
||||
},
|
||||
copyValue(text) {
|
||||
navigator.clipboard.writeText(text);
|
||||
@@ -182,15 +179,7 @@ export default {
|
||||
return !this.isEdit && this.copiedFields.some((elem) => elem === key);
|
||||
},
|
||||
cancelEdit() {
|
||||
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.docData = this.destruct(this.initialDocData);
|
||||
this.isEdit = false;
|
||||
this.isCheckChange = false;
|
||||
this.$refs.documentForm.resetValidation();
|
||||
@@ -198,10 +187,10 @@ export default {
|
||||
openEdit() {
|
||||
this.isEdit = true;
|
||||
},
|
||||
checkChangeDocData(key) {
|
||||
checkChangeDocData() {
|
||||
this.isCheckChange = checkChangeData(
|
||||
this.initialDocData?.[key],
|
||||
this.docData?.[key]
|
||||
this.destruct(this.initialDocData),
|
||||
this.docData
|
||||
);
|
||||
},
|
||||
openModal(id) {
|
||||
@@ -231,7 +220,6 @@ export default {
|
||||
Object.keys(this.docData).forEach((elem) => {
|
||||
this.checkChangePhoto(elem, "attachments");
|
||||
let newData = JSON.parse(JSON.stringify(this.docData[elem]));
|
||||
console.log("prep", newData);
|
||||
newData.attachments = {};
|
||||
if (!checkChangeData(this.initialDocData?.[elem], newData)) return;
|
||||
delete newData.id;
|
||||
@@ -243,24 +231,24 @@ export default {
|
||||
delete newData.issued_by_org_code;
|
||||
}
|
||||
delete newData.attachments;
|
||||
Object.keys(this.docData[elem])?.forEach((key) => {
|
||||
if (!this.docData[elem]?.[key]) delete newData?.[key];
|
||||
});
|
||||
if (!this.initialDocData?.[elem]?.id) {
|
||||
console.log("post", newData);
|
||||
newData.person_id =
|
||||
this.$store.state.medical?.basicData?.personalData?.id;
|
||||
console.log("create", newData);
|
||||
//request.push(this.createData("documents/", newData));
|
||||
request.push(this.createData("documents/", newData));
|
||||
} else {
|
||||
console.log("create", newData);
|
||||
// request.push(
|
||||
// this.updateData(
|
||||
// `documents/${this.initialDocData?.[elem]?.id}`,
|
||||
// newData
|
||||
// )
|
||||
// );
|
||||
request.push(
|
||||
this.updateData(
|
||||
`documents/${this.initialDocData?.[elem]?.id}`,
|
||||
newData
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
Promise.allSettled(request).then(() => {
|
||||
this.getMedicalCardData(this.$route.params.id);
|
||||
this.getMedicalDataById(this.$route.params.id);
|
||||
this.isEdit = false;
|
||||
this.isCheckChange = false;
|
||||
this.$refs.form?.resetValidation();
|
||||
@@ -292,26 +280,25 @@ export default {
|
||||
return date ? date.split(".").reverse().join("-") : "";
|
||||
},
|
||||
...mapActions({
|
||||
getMedicalCardData: "getMedicalCardDataById",
|
||||
getMedicalDataById: "getMedicalDataById",
|
||||
}),
|
||||
destruct(data) {
|
||||
const { passport, insurance_number, tax_identification_number } =
|
||||
JSON.parse(JSON.stringify(data));
|
||||
return {
|
||||
passport: passport,
|
||||
insurance_number: insurance_number,
|
||||
tax_identification_number: tax_identification_number,
|
||||
};
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
initialDocData: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(value) {
|
||||
if (Object.keys(value).length) {
|
||||
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)
|
||||
),
|
||||
};
|
||||
console.log(this.docData);
|
||||
} else this.docData = this.initializationData;
|
||||
if (Object.keys(value).length) this.docData = this.destruct(value);
|
||||
else this.docData = this.initializationData;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user