fix create form and fix origin

This commit is contained in:
kandrusyak
2023-09-04 20:57:34 +03:00
parent e7b9cce5a2
commit 66efe5bc95
6 changed files with 35 additions and 40 deletions

View File

@@ -15,9 +15,8 @@
:popup-content-style="{height: candidates?.length > 3 ? '216px' : ''}" :popup-content-style="{height: candidates?.length > 3 ? '216px' : ''}"
v-model="value" v-model="value"
ref="selectRef" ref="selectRef"
@blur="pasteFullName"
) )
//template(#selected)
// .text-dark.text-sm.font-medium(v-if="person") {{ person.last_name + ' ' + person.first_name + ' ' + person.patronymic }}
template(v-slot:iconLeft) template(v-slot:iconLeft)
q-icon.search-icon(name="app:search", size="20px") q-icon.search-icon(name="app:search", size="20px")
template(v-slot:customOption="{props, data}") template(v-slot:customOption="{props, data}")
@@ -60,6 +59,7 @@ export default {
}, },
computed: { computed: {
pickedFullName() { pickedFullName() {
if (!this.value.first_name) return "";
return ( return (
this.value.last_name + this.value.last_name +
" " + " " +
@@ -70,8 +70,8 @@ export default {
}, },
}, },
watch: { watch: {
pickedFullName(val) { pickedFullName() {
this.$refs?.selectRef?.updateInputValue(val, true); this.pasteFullName();
}, },
}, },
methods: { methods: {
@@ -87,8 +87,10 @@ export default {
}); });
}); });
}, },
test(slotProps) { pasteFullName() {
console.log(slotProps); this.$nextTick(() => {
this.$refs?.selectRef?.updateInputValue(this.pickedFullName, true);
});
}, },
}, },
}; };

View File

@@ -20,8 +20,9 @@
:placeholder="useInput && placeholder ? placeholder : ''", :placeholder="useInput && placeholder ? placeholder : ''",
@filter="filterFn", @filter="filterFn",
:popup-content-style="popupContentStyle" :popup-content-style="popupContentStyle"
@blur="$emit('blur')"
) )
template(v-slot:selected) template(#selected)
slot(name="selected") slot(name="selected")
template(v-slot:option="scope", v-if="!customOption") template(v-slot:option="scope", v-if="!customOption")
q-item(v-bind="scope.itemProps", style="justify-content: center", v-if="value?.icon") q-item(v-bind="scope.itemProps", style="justify-content: center", v-if="value?.icon")
@@ -79,7 +80,7 @@ export default {
filterFn: Function, filterFn: Function,
popupContentStyle: Object, popupContentStyle: Object,
}, },
emits: ["update:modelValue"], emits: ["update:modelValue", "blur"],
computed: { computed: {
value: { value: {
get() { get() {

View File

@@ -11,6 +11,7 @@
.wrapper-info.h-full .wrapper-info.h-full
.grid.grid-cols-2.gap-x-4.gap-y-6 .grid.grid-cols-2.gap-x-4.gap-y-6
base-input( base-input(
:disabled="!!patient.id"
v-model="phone", v-model="phone",
placeholder="+7 (915) 6449223", placeholder="+7 (915) 6449223",
mask="+7 (###) ###-##-##", mask="+7 (###) ###-##-##",
@@ -19,6 +20,7 @@
important important
) )
base-input-date( base-input-date(
:disabled="!!patient.id"
v-model="birth_date", v-model="birth_date",
size="M", size="M",
important, important,
@@ -63,6 +65,11 @@ export default {
currentStatus: patientData.statuses.find((e) => e.name === "Не принят"), currentStatus: patientData.statuses.find((e) => e.name === "Не принят"),
}; };
}, },
computed: {
primaryNumber() {
return this.patient?.contacts?.find((e) => e.category === "PHONE")?.value;
},
},
methods: { methods: {
...mapActions({ ...mapActions({
getEvents: "getEvents", getEvents: "getEvents",
@@ -90,6 +97,16 @@ export default {
}, },
}, },
mounted() {}, mounted() {},
watch: {
patient(val) {
if (val.birth_date) {
this.birth_date = val.birth_date;
}
if (this.primaryNumber) {
this.phone = this.primaryNumber;
}
},
},
}; };
</script> </script>

View File

@@ -1,6 +1,11 @@
const getOrigin = () =>
process.env.NODE_ENV === "development"
? "https://astra-dev.dopcore.com"
: window.origin;
function prepareUrl(url) { function prepareUrl(url) {
if (url.startsWith("http")) return url; if (url.startsWith("http")) return url;
return `https://astra-dev.dopcore.com/api/${url}`; return `${getOrigin}/api/${url}`;
} }
function handleRequest(method, url, headers, attempts, body, type) { function handleRequest(method, url, headers, attempts, body, type) {

View File

@@ -20,10 +20,6 @@ export function getObjectChangeField(objInit, objUpdate) {
return resultObj; return resultObj;
} }
export function checkTypeofObject(obj) {
return typeof obj === "object" && obj !== "null";
}
export function checkChangeData(dataInit, dataChange) { export function checkChangeData(dataInit, dataChange) {
return JSON.stringify(dataInit) !== JSON.stringify(dataChange); return JSON.stringify(dataInit) !== JSON.stringify(dataChange);
} }

View File

@@ -1,31 +1,5 @@
import { fetchWrapper } from "../fetchWrapper"; import { fetchWrapper } from "../fetchWrapper";
import { removeEmptyFields, checkChangeData } from "./changesObjects"; import { checkChangeData } from "./changesObjects";
export function getRequestChangeData(
createData,
updateData,
initData,
key,
id
) {
let isInitDataEmpty = [...Object.keys(removeEmptyFields(initData))].length;
if (Object.keys(removeEmptyFields(updateData)).length) {
if (!isInitDataEmpty) {
return fetchWrapper.post(
`general/${key}/create/`,
removeEmptyFields(createData)
);
}
if (JSON.stringify(updateData) !== JSON.stringify(initData)) {
return fetchWrapper.post(
`general/${key}/${id}/update/`,
removeEmptyFields(updateData)
);
}
return Promise.resolve();
}
return Promise.resolve();
}
export function getRequestArrayData( export function getRequestArrayData(
initData, initData,