Много всего
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<script setup>
|
||||
import { NModal, NDataTable, NSpace, NFlex, NButton, NForm, NFormItem, NInput, NDatePicker, NDivider, NSwitch, NTag } from 'naive-ui'
|
||||
import ArchiveHistoryMoveModal from '../ArchiveHistoryMoveModal/Index.vue'
|
||||
import {ref, watch} from "vue";
|
||||
import {computed, ref, watch} from "vue";
|
||||
import {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
|
||||
|
||||
const open = defineModel('open')
|
||||
const props = defineProps({
|
||||
@@ -10,10 +11,29 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const {filtersRef} = useMedicalHistoryFilter()
|
||||
const loading = ref(true)
|
||||
const patient = ref({})
|
||||
const showArchiveHistoryModal = ref(false)
|
||||
const selectedArchiveHistoryId = ref(null)
|
||||
const selectedArchiveHistoryType = ref(null)
|
||||
const isCreateNewArchiveHistoryModal = ref(false)
|
||||
const archiveInfo = ref({
|
||||
id: props.patientId,
|
||||
num: null,
|
||||
post_in: null,
|
||||
status: null
|
||||
})
|
||||
const emits = defineEmits(['historyUpdated'])
|
||||
|
||||
const onResetData = () => {
|
||||
archiveInfo.value = {
|
||||
id: props.patientId,
|
||||
num: null,
|
||||
post_in: null,
|
||||
status: null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const patientData = ref({
|
||||
@@ -25,9 +45,16 @@ const loadPatientData = async () => {
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
axios.get(`/api/si/patients/${props.patientId}`).then(res => {
|
||||
axios.get(`/api/si/patients/${props.patientId}?view_type=${filtersRef.value.view_type}`).then(res => {
|
||||
patient.value = res.data
|
||||
patientData.value = res.data.info
|
||||
archiveInfo.value = res.data.archiveInfo ?? {
|
||||
historyable_type: res.data.historyable_type,
|
||||
id: props.patientId,
|
||||
num: null,
|
||||
post_in: null,
|
||||
status: null,
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
// message.error('Ошибка при загрузке данных пациента')
|
||||
@@ -38,7 +65,14 @@ const loadPatientData = async () => {
|
||||
}
|
||||
|
||||
const onShowArchiveHistoryModal = (id) => {
|
||||
selectedArchiveHistoryId.value = id
|
||||
if (id === null) {
|
||||
isCreateNewArchiveHistoryModal.value = true
|
||||
selectedArchiveHistoryId.value = props.patientId
|
||||
} else {
|
||||
isCreateNewArchiveHistoryModal.value = false
|
||||
selectedArchiveHistoryId.value = id
|
||||
}
|
||||
selectedArchiveHistoryType.value = archiveInfo.value.historyable_type
|
||||
showArchiveHistoryModal.value = true
|
||||
}
|
||||
|
||||
@@ -75,6 +109,30 @@ const rowProps = (row) => ({
|
||||
}
|
||||
})
|
||||
|
||||
const onUpdateHistory = (updatedData) => {
|
||||
loadPatientData()
|
||||
}
|
||||
|
||||
const hasCreateNew = computed(() => archiveInfo.value === null)
|
||||
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
await axios.post(`/api/archive/histories/info/${props.patientId}`, archiveInfo.value).then(res => {
|
||||
// onCloseWithoutSave()
|
||||
emits('historyUpdated', {
|
||||
type: hasCreateNew.value ? 'created' : 'updated',
|
||||
data: res.data,
|
||||
patientId: props.patientId
|
||||
})
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Наблюдаем за изменением patientId
|
||||
watch(() => props.patientId, (newId) => {
|
||||
if (newId) {
|
||||
@@ -92,19 +150,19 @@ watch(() => props.patientId, (newId) => {
|
||||
<NFlex inline justify="space-between" align="center" :wrap="false">
|
||||
<NForm inline :show-feedback="false">
|
||||
<NFormItem label="Статус карты">
|
||||
<NTag :type="patient.archiveInfo?.status?.variant ?? 'error'" :bordered="false" round>
|
||||
{{ patient.archiveInfo?.status?.text ?? 'Нет в архиве' }}
|
||||
<NTag :type="archiveInfo.status?.variant ?? 'error'" :bordered="false" round>
|
||||
{{ archiveInfo.status?.text ?? 'Нет в архиве' }}
|
||||
</NTag>
|
||||
</NFormItem>
|
||||
<NFormItem label="№ в архиве">
|
||||
<NInput v-model:value="patientData.narhiv" />
|
||||
<NInput v-model:value="archiveInfo.num" />
|
||||
</NFormItem>
|
||||
<NFormItem label="Дата поступления карты в архив">
|
||||
<NDatePicker v-model:value="patientData.datearhiv" format="dd.MM.yyyy" />
|
||||
<NDatePicker v-model:value="archiveInfo.post_in" format="dd.MM.yyyy" />
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
</NFlex>
|
||||
<NButton @click="onShowArchiveHistoryModal(null)">
|
||||
<NButton @click="onShowArchiveHistoryModal(null)" :disabled="!patientData.can_be_issued">
|
||||
Добавить
|
||||
</NButton>
|
||||
<NDataTable :row-props="rowProps" min-height="420px" max-height="420px" :columns="columns" :data="patient?.journal" />
|
||||
@@ -116,14 +174,14 @@ watch(() => props.patientId, (newId) => {
|
||||
Закрыть без сохранения
|
||||
</NButton>
|
||||
<NDivider vertical />
|
||||
<NButton secondary type="primary">
|
||||
<NButton secondary type="primary" @click="onSubmit">
|
||||
Сохранить
|
||||
</NButton>
|
||||
</NSpace>
|
||||
</NFlex>
|
||||
</template>
|
||||
</NModal>
|
||||
<ArchiveHistoryMoveModal @close-without-save="selectedArchiveHistoryId = null" v-model:open="showArchiveHistoryModal" :archive-history-id="selectedArchiveHistoryId" />
|
||||
<ArchiveHistoryMoveModal @history-updated="onUpdateHistory" @close-without-save="selectedArchiveHistoryId = null" :is-create-new="isCreateNewArchiveHistoryModal" v-model:open="showArchiveHistoryModal" :active-history-type="selectedArchiveHistoryType" :archive-history-id="selectedArchiveHistoryId" />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user