Привязка таблицы к смене статуса из модальных окон

This commit is contained in:
brusnitsyn
2025-12-19 00:36:13 +09:00
parent fdcfaec862
commit 76d1df235d
3 changed files with 41 additions and 11 deletions

View File

@@ -45,7 +45,7 @@ const loadPatientData = async () => {
loading.value = true
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
patientData.value = res.data.info
archiveInfo.value = res.data.archiveInfo ?? {
@@ -109,8 +109,15 @@ const rowProps = (row) => ({
}
})
const onUpdateHistory = (updatedData) => {
loadPatientData()
const onUpdateHistory = async ({data}) => {
await loadPatientData()
const updatedData = {
status: archiveInfo.value.status,
}
emits('historyUpdated', {
data: updatedData,
patientId: props.patientId
})
}
const hasCreateNew = computed(() => archiveInfo.value === null)
@@ -119,11 +126,14 @@ const onSubmit = async () => {
try {
await axios.post(`/api/archive/histories/info/${props.patientId}`, archiveInfo.value).then(res => {
// onCloseWithoutSave()
const updatedData = {
status: archiveInfo.value.status,
}
emits('historyUpdated', {
type: hasCreateNew.value ? 'created' : 'updated',
data: res.data,
data: updatedData,
patientId: props.patientId
})
open.value = false
})
} catch (error) {
@@ -134,9 +144,9 @@ const onSubmit = async () => {
}
// Наблюдаем за изменением patientId
watch(() => props.patientId, (newId) => {
watch(() => props.patientId, async (newId) => {
if (newId) {
loadPatientData()
await loadPatientData()
}
}, { immediate: true })
</script>