Обновление 1.0
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
<script setup>
|
||||
import { NModal, NSelect, NSpace, NFlex, NButton, NForm, NFormItem, NInput, NDatePicker, NDivider, NSpin, NTag } from 'naive-ui'
|
||||
import ArchiveHistoryMoveModal from '../ArchiveHistoryMoveModal/Index.vue'
|
||||
import {computed, ref, watch} from "vue";
|
||||
import {computed, h, ref, watch} from "vue";
|
||||
import {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
|
||||
import {useNotification} from "../../../Composables/useNotification.js";
|
||||
import {useDebounceFn} from "@vueuse/core";
|
||||
import {useArchiveCard} from "../../../Stores/ArchiveCard.js";
|
||||
|
||||
const open = defineModel('open')
|
||||
|
||||
const {errorApi} = useNotification()
|
||||
const loading = ref(false)
|
||||
const loadingFilterPatients = ref(false)
|
||||
const formRef = ref(null)
|
||||
const archiveCardStore = useArchiveCard()
|
||||
const isCardInArchive = computed(() => archiveCardStore.preOpenCard !== null)
|
||||
const emits = defineEmits(['historyUpdated', 'closeWithoutSave', 'openArchiveCard'])
|
||||
const archiveInfo = ref({
|
||||
id: null,
|
||||
num: null,
|
||||
@@ -20,16 +26,43 @@ const archiveInfoRules = {
|
||||
{
|
||||
required: true,
|
||||
validator(rule, value) {
|
||||
console.log(value)
|
||||
if (isCardInArchive.value) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
return new Error('Это поле необходимо заполнить')
|
||||
return false
|
||||
}
|
||||
else if (!Number(value)) {
|
||||
return new Error('Ошибка при получении ID')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
trigger: ['input', 'blur']
|
||||
renderMessage: () => {
|
||||
if (isCardInArchive.value) {
|
||||
return h(
|
||||
'div',
|
||||
[
|
||||
'Карта уже находится в архиве. ',
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
text: true,
|
||||
onClick: (e) => {
|
||||
e.preventDefault()
|
||||
archiveCardStore.isOpenArchiveCard = true
|
||||
onCloseWithoutSave()
|
||||
}
|
||||
},
|
||||
'Перейти к карте'
|
||||
)
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
return 'Это поле необходимо заполнить'
|
||||
},
|
||||
trigger: ['change', 'blur']
|
||||
}
|
||||
],
|
||||
num: [
|
||||
@@ -47,17 +80,26 @@ const archiveInfoRules = {
|
||||
}
|
||||
]
|
||||
}
|
||||
const loadingFilterPatients = ref(false)
|
||||
const formRef = ref(null)
|
||||
|
||||
const emits = defineEmits(['historyUpdated', 'closeWithoutSave'])
|
||||
const onResetArchiveInfo = (only) => {
|
||||
if (only && Object.keys(only).length > 0) {
|
||||
archiveInfo.value = {
|
||||
...archiveInfo.value,
|
||||
...only
|
||||
}
|
||||
} else {
|
||||
archiveInfo.value = {
|
||||
id: null,
|
||||
num: null,
|
||||
post_in: null,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onResetData = () => {
|
||||
archiveInfo.value = {
|
||||
id: null,
|
||||
num: null,
|
||||
post_in: null,
|
||||
}
|
||||
onResetArchiveInfo()
|
||||
filteredPatients.value = []
|
||||
setTimeout(() => archiveCardStore.resetPreOpenCard(), 100)
|
||||
}
|
||||
|
||||
const onCloseWithoutSave = () => {
|
||||
@@ -106,6 +148,27 @@ const onSubmit = async (e) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const updateValueSearch = async (value) => {
|
||||
archiveCardStore.setPreOpenCard(null)
|
||||
await axios.post('/api/archive/check', {
|
||||
id: value
|
||||
}).then(res => {
|
||||
archiveCardStore.setPreOpenCard(res.data)
|
||||
}).catch(err => {
|
||||
if (err.code === 404) {
|
||||
archiveCardStore.resetPreOpenCard()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
watch(() => isCardInArchive.value, (val) => {
|
||||
if (val)
|
||||
onResetArchiveInfo({
|
||||
num: null,
|
||||
post_in: null
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -126,17 +189,20 @@ const onSubmit = async (e) => {
|
||||
:loading="loadingFilterPatients"
|
||||
:options="filteredPatients"
|
||||
v-model:value="archiveInfo.id"
|
||||
@update:value="(val) => updateValueSearch(val)"
|
||||
@search="handleSearchCard"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem size="large" label="Дата поступления карты в архив" path="post_in">
|
||||
<NDatePicker class="w-full"
|
||||
v-model:value="archiveInfo.post_in"
|
||||
:disabled="archiveCardStore.isSetPreOpenCard"
|
||||
format="dd.MM.yyyy"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem size="large" label="№ в архиве" path="num">
|
||||
<NInput v-model:value="archiveInfo.num" />
|
||||
<NInput v-model:value="archiveInfo.num"
|
||||
:disabled="archiveCardStore.isSetPreOpenCard"/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
</NFlex>
|
||||
@@ -147,6 +213,7 @@ const onSubmit = async (e) => {
|
||||
type="primary"
|
||||
attr-type="submit"
|
||||
form="formAddToArchive"
|
||||
:disabled="archiveCardStore.isSetPreOpenCard"
|
||||
@click="onSubmit">
|
||||
Добавить карту
|
||||
</NButton>
|
||||
|
||||
Reference in New Issue
Block a user