diff --git a/src/components/base/BaseInputWithSearch.vue b/src/components/base/BaseInputWithSearch.vue index df5607b..b2c3469 100644 --- a/src/components/base/BaseInputWithSearch.vue +++ b/src/components/base/BaseInputWithSearch.vue @@ -15,9 +15,8 @@ :popup-content-style="{height: candidates?.length > 3 ? '216px' : ''}" v-model="value" 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) q-icon.search-icon(name="app:search", size="20px") template(v-slot:customOption="{props, data}") @@ -60,6 +59,7 @@ export default { }, computed: { pickedFullName() { + if (!this.value.first_name) return ""; return ( this.value.last_name + " " + @@ -70,8 +70,8 @@ export default { }, }, watch: { - pickedFullName(val) { - this.$refs?.selectRef?.updateInputValue(val, true); + pickedFullName() { + this.pasteFullName(); }, }, methods: { @@ -87,8 +87,10 @@ export default { }); }); }, - test(slotProps) { - console.log(slotProps); + pasteFullName() { + this.$nextTick(() => { + this.$refs?.selectRef?.updateInputValue(this.pickedFullName, true); + }); }, }, }; diff --git a/src/components/base/BaseSelect.vue b/src/components/base/BaseSelect.vue index 3300900..ddc6970 100644 --- a/src/components/base/BaseSelect.vue +++ b/src/components/base/BaseSelect.vue @@ -20,8 +20,9 @@ :placeholder="useInput && placeholder ? placeholder : ''", @filter="filterFn", :popup-content-style="popupContentStyle" + @blur="$emit('blur')" ) - template(v-slot:selected) + template(#selected) slot(name="selected") template(v-slot:option="scope", v-if="!customOption") q-item(v-bind="scope.itemProps", style="justify-content: center", v-if="value?.icon") @@ -79,7 +80,7 @@ export default { filterFn: Function, popupContentStyle: Object, }, - emits: ["update:modelValue"], + emits: ["update:modelValue", "blur"], computed: { value: { get() { diff --git a/src/pages/newCalendar/components/CreateEventForm.vue b/src/pages/newCalendar/components/CreateEventForm.vue index 9921e06..27da256 100644 --- a/src/pages/newCalendar/components/CreateEventForm.vue +++ b/src/pages/newCalendar/components/CreateEventForm.vue @@ -11,6 +11,7 @@ .wrapper-info.h-full .grid.grid-cols-2.gap-x-4.gap-y-6 base-input( + :disabled="!!patient.id" v-model="phone", placeholder="+7 (915) 644–92–23", mask="+7 (###) ###-##-##", @@ -19,6 +20,7 @@ important ) base-input-date( + :disabled="!!patient.id" v-model="birth_date", size="M", important, @@ -63,6 +65,11 @@ export default { currentStatus: patientData.statuses.find((e) => e.name === "Не принят"), }; }, + computed: { + primaryNumber() { + return this.patient?.contacts?.find((e) => e.category === "PHONE")?.value; + }, + }, methods: { ...mapActions({ getEvents: "getEvents", @@ -90,6 +97,16 @@ export default { }, }, mounted() {}, + watch: { + patient(val) { + if (val.birth_date) { + this.birth_date = val.birth_date; + } + if (this.primaryNumber) { + this.phone = this.primaryNumber; + } + }, + }, }; diff --git a/src/shared/fetchWrapper.js b/src/shared/fetchWrapper.js index c42c3b9..94923e7 100644 --- a/src/shared/fetchWrapper.js +++ b/src/shared/fetchWrapper.js @@ -1,6 +1,11 @@ +const getOrigin = () => + process.env.NODE_ENV === "development" + ? "https://astra-dev.dopcore.com" + : window.origin; + function prepareUrl(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) { diff --git a/src/shared/utils/changesObjects.js b/src/shared/utils/changesObjects.js index 87f234d..a01b67c 100644 --- a/src/shared/utils/changesObjects.js +++ b/src/shared/utils/changesObjects.js @@ -20,10 +20,6 @@ export function getObjectChangeField(objInit, objUpdate) { return resultObj; } -export function checkTypeofObject(obj) { - return typeof obj === "object" && obj !== "null"; -} - export function checkChangeData(dataInit, dataChange) { return JSON.stringify(dataInit) !== JSON.stringify(dataChange); } diff --git a/src/shared/utils/wrapperRequestChangeData.js b/src/shared/utils/wrapperRequestChangeData.js index 180e277..c25e2c3 100644 --- a/src/shared/utils/wrapperRequestChangeData.js +++ b/src/shared/utils/wrapperRequestChangeData.js @@ -1,31 +1,5 @@ import { fetchWrapper } from "../fetchWrapper"; -import { removeEmptyFields, 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(); -} +import { checkChangeData } from "./changesObjects"; export function getRequestArrayData( initData,