* закончил окно редактирования карты с назначением номера в архиве

* добавил окно для редактирования выдачи / возврата карты
* раздробил логику хранения карты
This commit is contained in:
brusnitsyn
2025-12-05 18:04:02 +09:00
parent 2dfa45707c
commit 2e1b5a3d0e
17 changed files with 431 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
<script setup>
import { NModal, NDataTable } from 'naive-ui'
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";
const open = defineModel('open')
@@ -11,6 +12,13 @@ const props = defineProps({
const loading = ref(true)
const patient = ref({})
const showArchiveHistoryModal = ref(false)
const selectedArchiveHistoryId = ref(null)
const patientData = ref({
...patient.value.info
})
const loadPatientData = async () => {
if (!props.patientId) return
@@ -19,6 +27,7 @@ const loadPatientData = async () => {
try {
axios.get(`/api/si/patients/${props.patientId}`).then(res => {
patient.value = res.data
patientData.value = res.data.info
})
} catch (error) {
// message.error('Ошибка при загрузке данных пациента')
@@ -28,28 +37,43 @@ const loadPatientData = async () => {
}
}
const onShowArchiveHistoryModal = (id) => {
selectedArchiveHistoryId.value = id
showArchiveHistoryModal.value = true
}
const columns = [
{
title: 'Выдача',
key: 'issue_at'
key: 'issue_at',
width: 100
},
{
title: 'Возврат',
key: 'return_at'
key: 'return_at',
width: 100
},
{
title: 'Организация',
key: 'org_id'
key: 'org',
width: 220
},
{
title: 'ФИО',
key: 'employee_name'
key: 'employee_name',
width: 180
},
{
title: 'Должность',
key: 'employee_post'
key: 'employee_post',
width: 120
},
]
const rowProps = (row) => ({
onDblclick: () => {
onShowArchiveHistoryModal(row.id)
}
})
// Наблюдаем за изменением patientId
watch(() => props.patientId, (newId) => {
@@ -64,8 +88,42 @@ watch(() => props.patientId, (newId) => {
<template #header>
{{ patient.info?.medcardnum }} {{ patient.info?.family }} {{ patient.info?.name }} {{ patient.info?.ot }}
</template>
<NDataTable :columns="columns" :data="patient?.journal" />
<NSpace vertical>
<NFlex inline justify="space-between" align="center" :wrap="false">
<NForm inline :show-feedback="false">
<NFormItem label="Статус карты">
<NTag type="default" :bordered="false" round>
Не определен
</NTag>
</NFormItem>
<NFormItem label="№ в архиве">
<NInput v-model:value="patientData.narhiv" />
</NFormItem>
<NFormItem label="Дата поступления карты в архив">
<NDatePicker v-model:value="patientData.datearhiv" format="dd.MM.yyyy" />
</NFormItem>
</NForm>
</NFlex>
<NButton @click="onShowArchiveHistoryModal(null)">
Добавить
</NButton>
<NDataTable :row-props="rowProps" min-height="420px" max-height="420px" :columns="columns" :data="patient?.journal" />
</NSpace>
<template #action>
<NFlex justify="end" align="center">
<NSpace align="center" :size="0">
<NButton secondary>
Закрыть без сохранения
</NButton>
<NDivider vertical />
<NButton secondary type="primary">
Сохранить
</NButton>
</NSpace>
</NFlex>
</template>
</NModal>
<ArchiveHistoryMoveModal @close-without-save="selectedArchiveHistoryId = null" v-model:open="showArchiveHistoryModal" :archive-history-id="selectedArchiveHistoryId" />
</template>
<style scoped>

View File

@@ -0,0 +1,115 @@
<script setup>
import {NButton, NDatePicker, NDivider, NFlex, NForm, NFormItem, NInput, NModal, NSpace, NSwitch, NSelect} from "naive-ui";
import {ref, watch} from "vue";
const open = defineModel('open')
const props = defineProps({
archiveHistoryId: {
type: Number
}
})
const emits = defineEmits(['closeWithoutSave'])
const loading = ref(false)
const archiveHistory = ref({
issue_at: null,
org_id: null,
return_at: null,
employee_name: null,
employee_post: null,
comment: null,
has_lost: false,
})
const orgs = ref([])
const onResetData = () => {
archiveHistory.value = {
issue_at: null,
org_id: null,
return_at: null,
employee_name: null,
employee_post: null,
comment: null,
has_lost: false,
}
}
const onCloseWithoutSave = () => {
emits('closeWithoutSave')
open.value = false
}
const loadArchiveHistoryData = async () => {
try {
axios.get('/api/orgs').then(res => {
orgs.value = res.data
})
if (!props.archiveHistoryId) return
axios.get(`/api/archive/histories/${props.archiveHistoryId}`).then(res => {
archiveHistory.value = res.data
})
} catch (error) {
console.error(error)
} finally {
loading.value = false
}
}
// Наблюдаем за изменением archiveHistoryId
watch(() => props.archiveHistoryId, (newId) => {
if (newId) {
loadArchiveHistoryData()
} else {
onResetData()
}
}, { immediate: true })
</script>
<template>
<NModal v-model:show="open" preset="card" class="max-w-2xl" closable @close="open = false">
<template #header>
{{ archiveHistoryId === null ? 'Добавить' : 'Редактировать' }} запись выдачи
</template>
<NForm>
<NFormItem label="Дата выдачи">
<NDatePicker v-model:value="archiveHistory.issue_at" format="dd.MM.yyyy" />
</NFormItem>
<NFormItem label="Дата возврата">
<NDatePicker v-model:value="archiveHistory.return_at" format="dd.MM.yyyy" />
</NFormItem>
<NFormItem label="Организация">
<NSelect v-model:value="archiveHistory.org_id" :options="orgs" label-field="name" value-field="id" filterable />
</NFormItem>
<NFormItem label="Имя сотрудника">
<NInput v-model:value="archiveHistory.employee_name" />
</NFormItem>
<NFormItem label="Должность">
<NInput v-model:value="archiveHistory.employee_post" />
</NFormItem>
<NFormItem label="Примечание">
<NInput v-model:value="archiveHistory.comment" type="textarea" rows="3" :resizable="false" />
</NFormItem>
</NForm>
<template #action>
<NFlex justify="space-between" align="center">
<NFormItem :show-feedback="false" label-placement="left" label="Карта утеряна">
<NSwitch v-model:value="archiveHistory.has_lost" />
</NFormItem>
<NSpace align="center" :size="0">
<NButton secondary @click="onCloseWithoutSave">
Закрыть без сохранения
</NButton>
<NDivider vertical />
<NButton secondary type="primary">
Сохранить
</NButton>
</NSpace>
</NFlex>
</template>
</NModal>
</template>
<style scoped>
</style>