Реализация смены статуса

Добавлен move метод
Правка в поиске
This commit is contained in:
brusnitsyn
2025-12-07 22:33:19 +09:00
parent 2e1b5a3d0e
commit 945b53c578
10 changed files with 142 additions and 17 deletions

View File

@@ -92,8 +92,8 @@ watch(() => props.patientId, (newId) => {
<NFlex inline justify="space-between" align="center" :wrap="false">
<NForm inline :show-feedback="false">
<NFormItem label="Статус карты">
<NTag type="default" :bordered="false" round>
Не определен
<NTag :type="patient.archiveInfo?.status?.variant ?? 'error'" :bordered="false" round>
{{ patient.archiveInfo?.status?.text ?? 'Нет в архиве' }}
</NTag>
</NFormItem>
<NFormItem label="№ в архиве">

View File

@@ -11,6 +11,7 @@ const emits = defineEmits(['closeWithoutSave'])
const loading = ref(false)
const archiveHistory = ref({
historyable_id: props.archiveHistoryId,
issue_at: null,
org_id: null,
return_at: null,
@@ -23,6 +24,7 @@ const orgs = ref([])
const onResetData = () => {
archiveHistory.value = {
historyable_id: props.archiveHistoryId,
issue_at: null,
org_id: null,
return_at: null,
@@ -39,13 +41,13 @@ const onCloseWithoutSave = () => {
const loadArchiveHistoryData = async () => {
try {
axios.get('/api/orgs').then(res => {
await axios.get('/api/orgs').then(res => {
orgs.value = res.data
})
if (!props.archiveHistoryId) return
axios.get(`/api/archive/histories/${props.archiveHistoryId}`).then(res => {
await axios.get(`/api/archive/histories/${props.archiveHistoryId}`).then(res => {
archiveHistory.value = res.data
})
} catch (error) {
@@ -55,10 +57,22 @@ const loadArchiveHistoryData = async () => {
}
}
const submit = () => {
try {
axios.post('/api/archive/histories/move', archiveHistory.value).then(res => {
onCloseWithoutSave()
})
} catch (error) {
console.error(error)
} finally {
loading.value = false
}
}
// Наблюдаем за изменением archiveHistoryId
watch(() => props.archiveHistoryId, (newId) => {
watch(() => props.archiveHistoryId, async (newId) => {
if (newId) {
loadArchiveHistoryData()
await loadArchiveHistoryData()
} else {
onResetData()
}
@@ -101,7 +115,7 @@ watch(() => props.archiveHistoryId, (newId) => {
Закрыть без сохранения
</NButton>
<NDivider vertical />
<NButton secondary type="primary">
<NButton secondary type="primary" @click="submit">
Сохранить
</NButton>
</NSpace>

View File

@@ -1,5 +1,5 @@
<script setup>
import {NDataTable, NEllipsis} from "naive-ui"
import {NDataTable, NEllipsis, NTag} from "naive-ui"
import {computed, h, reactive, ref} from "vue"
import {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
import ArchiveHistoryModal from '../ArchiveHistoryModal/Index.vue'
@@ -25,6 +25,19 @@ const props = defineProps({
const { isLoading, handlePageChange, handlePageSizeChange, meta } = useMedicalHistoryFilter(props.filters)
const archiveStatusColumn = (status) => {
const tagType = status?.variant ?? 'error'
const tagText = status?.text ?? 'Нет в архиве'
console.log(tagType)
return h(
NEllipsis,
null,
{
default: () => h(NTag, {type: tagType, round: true, size: 'small'}, tagText)
})
}
const columns = ref([
{
title: '№ карты',
@@ -58,9 +71,9 @@ const columns = ref([
},
{
title: '№ архива',
key: 'narhiv',
key: 'card_num',
width: 120,
render: (row) => h(NEllipsis, null, { default: () => row.narhiv || '-' })
render: (row) => h(NEllipsis, null, { default: () => row.card_num || '-' })
},
{
title: 'Дата архива',
@@ -72,7 +85,7 @@ const columns = ref([
title: 'Статус',
key: 'status',
width: 100,
render: (row) => h(NEllipsis, null, { default: () => row.status || '-' })
render: (row) => archiveStatusColumn(row.status)
}
])
const showArchiveHistoryModal = ref(false)