Привязка таблицы к смене статуса из модальных окон
This commit is contained in:
@@ -45,7 +45,7 @@ const loadPatientData = async () => {
|
|||||||
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
axios.get(`/api/si/patients/${props.patientId}?view_type=${filtersRef.value.view_type}`).then(res => {
|
await axios.get(`/api/si/patients/${props.patientId}?view_type=${filtersRef.value.view_type}`).then(res => {
|
||||||
patient.value = res.data
|
patient.value = res.data
|
||||||
patientData.value = res.data.info
|
patientData.value = res.data.info
|
||||||
archiveInfo.value = res.data.archiveInfo ?? {
|
archiveInfo.value = res.data.archiveInfo ?? {
|
||||||
@@ -109,8 +109,15 @@ const rowProps = (row) => ({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onUpdateHistory = (updatedData) => {
|
const onUpdateHistory = async ({data}) => {
|
||||||
loadPatientData()
|
await loadPatientData()
|
||||||
|
const updatedData = {
|
||||||
|
status: archiveInfo.value.status,
|
||||||
|
}
|
||||||
|
emits('historyUpdated', {
|
||||||
|
data: updatedData,
|
||||||
|
patientId: props.patientId
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasCreateNew = computed(() => archiveInfo.value === null)
|
const hasCreateNew = computed(() => archiveInfo.value === null)
|
||||||
@@ -119,11 +126,14 @@ const onSubmit = async () => {
|
|||||||
try {
|
try {
|
||||||
await axios.post(`/api/archive/histories/info/${props.patientId}`, archiveInfo.value).then(res => {
|
await axios.post(`/api/archive/histories/info/${props.patientId}`, archiveInfo.value).then(res => {
|
||||||
// onCloseWithoutSave()
|
// onCloseWithoutSave()
|
||||||
|
const updatedData = {
|
||||||
|
status: archiveInfo.value.status,
|
||||||
|
}
|
||||||
emits('historyUpdated', {
|
emits('historyUpdated', {
|
||||||
type: hasCreateNew.value ? 'created' : 'updated',
|
data: updatedData,
|
||||||
data: res.data,
|
|
||||||
patientId: props.patientId
|
patientId: props.patientId
|
||||||
})
|
})
|
||||||
|
open.value = false
|
||||||
})
|
})
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -134,9 +144,9 @@ const onSubmit = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Наблюдаем за изменением patientId
|
// Наблюдаем за изменением patientId
|
||||||
watch(() => props.patientId, (newId) => {
|
watch(() => props.patientId, async (newId) => {
|
||||||
if (newId) {
|
if (newId) {
|
||||||
loadPatientData()
|
await loadPatientData()
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -73,12 +73,12 @@ const submit = () => {
|
|||||||
: `/api/archive/histories/move/${archiveHistory.value.id}`
|
: `/api/archive/histories/move/${archiveHistory.value.id}`
|
||||||
|
|
||||||
axios.post(url, archiveHistory.value).then(res => {
|
axios.post(url, archiveHistory.value).then(res => {
|
||||||
onCloseWithoutSave()
|
|
||||||
emits('historyUpdated', {
|
emits('historyUpdated', {
|
||||||
type: props.isCreateNew ? 'created' : 'updated',
|
type: props.isCreateNew ? 'created' : 'updated',
|
||||||
data: res.data,
|
data: res.data,
|
||||||
historyId: archiveHistory.value.id
|
historyId: archiveHistory.value.id
|
||||||
})
|
})
|
||||||
|
onCloseWithoutSave()
|
||||||
})
|
})
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {NDataTable, NEllipsis, NTag} from "naive-ui"
|
import {NDataTable, NEllipsis, NTag} from "naive-ui"
|
||||||
import {computed, h, reactive, ref} from "vue"
|
import {computed, h, reactive, ref, watch} from "vue"
|
||||||
import {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
|
import {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
|
||||||
import ArchiveHistoryModal from '../ArchiveHistoryModal/Index.vue'
|
import ArchiveHistoryModal from '../ArchiveHistoryModal/Index.vue'
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const { isLoading, handlePageChange, handlePageSizeChange, meta, filtersRef } = useMedicalHistoryFilter(props.filters)
|
const { isLoading, handlePageChange, handlePageSizeChange, meta, filtersRef } = useMedicalHistoryFilter(props.filters)
|
||||||
|
const dataTable = ref(props.data ?? [])
|
||||||
|
|
||||||
const archiveStatusColumn = (status) => {
|
const archiveStatusColumn = (status) => {
|
||||||
const tagType = status?.variant ?? 'error'
|
const tagType = status?.variant ?? 'error'
|
||||||
@@ -132,11 +133,30 @@ const pagination = computed(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const onCloseWithoutSave = () => {
|
||||||
|
selectedPatientId.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
const onUpdateHistory = ({data, patientId}) => {
|
||||||
|
console.log(data)
|
||||||
|
if (dataTable.value.length > 0) {
|
||||||
|
let needUpdateItem = dataTable.value.findIndex(itm => itm.id === patientId)
|
||||||
|
dataTable.value[needUpdateItem] = {
|
||||||
|
...dataTable.value[needUpdateItem],
|
||||||
|
status: data.status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => props.data, (newData) => {
|
||||||
|
dataTable.value = newData
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NDataTable remote striped :loading="isLoading" :row-props="rowProps" :columns="columns" :pagination="pagination" :max-height="maxHeight" size="small" :min-height="minHeight" :data="data" />
|
<NDataTable remote striped :loading="isLoading" :row-props="rowProps" :columns="columns" :pagination="pagination" :max-height="maxHeight" size="small" :min-height="minHeight" :data="dataTable" />
|
||||||
<ArchiveHistoryModal v-model:open="showArchiveHistoryModal" :patient-id="selectedPatientId" />
|
<ArchiveHistoryModal v-model:open="showArchiveHistoryModal" :patient-id="selectedPatientId" @history-updated="onUpdateHistory" @close-without-save="onCloseWithoutSave" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user