сервис уведомлений
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
import {h} from "vue";
|
||||||
|
import {NCode, NLog} from "naive-ui"
|
||||||
|
|
||||||
export function useNotification() {
|
export function useNotification() {
|
||||||
const showNotification = (options) => {
|
const showNotification = (options) => {
|
||||||
if (window.$notification) {
|
if (window.$notification) {
|
||||||
@@ -11,12 +14,20 @@ export function useNotification() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const errorApi = (content = '', options = {}) => {
|
const errorApi = (data, content = '', options = {}) => {
|
||||||
return showNotification(
|
return showNotification(
|
||||||
{
|
{
|
||||||
title: 'Произошла ошибка',
|
title: 'Произошла ошибка',
|
||||||
description: 'При обращении к API серверу',
|
description: `Код: ${data.code}\nURL: ${data.response.config.url}\nМетод: ${data.response.config.method.toUpperCase()}`,
|
||||||
content,
|
content: () => {
|
||||||
|
return h(
|
||||||
|
NLog,
|
||||||
|
{
|
||||||
|
rows: 4,
|
||||||
|
log: data.response.config.data,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
meta: options.meta || new Date().toLocaleDateString(),
|
meta: options.meta || new Date().toLocaleDateString(),
|
||||||
...options,
|
...options,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { NModal, NDataTable, NSpace, NFlex, NButton, NForm, NFormItem, NInput, N
|
|||||||
import ArchiveHistoryMoveModal from '../ArchiveHistoryMoveModal/Index.vue'
|
import ArchiveHistoryMoveModal from '../ArchiveHistoryMoveModal/Index.vue'
|
||||||
import {computed, ref, watch} from "vue";
|
import {computed, ref, watch} from "vue";
|
||||||
import {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
|
import {useMedicalHistoryFilter} from "../../../Composables/useMedicalHistoryFilter.js";
|
||||||
|
import {useNotification} from "../../../Composables/useNotification.js";
|
||||||
|
|
||||||
const open = defineModel('open')
|
const open = defineModel('open')
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -12,6 +13,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const {filtersRef} = useMedicalHistoryFilter()
|
const {filtersRef} = useMedicalHistoryFilter()
|
||||||
|
const {errorApi} = useNotification()
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const patient = ref({})
|
const patient = ref({})
|
||||||
const showArchiveHistoryModal = ref(false)
|
const showArchiveHistoryModal = ref(false)
|
||||||
@@ -61,7 +63,7 @@ const loadPatientData = async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// message.error('Ошибка при загрузке данных пациента')
|
errorApi(error)
|
||||||
console.error(error)
|
console.error(error)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@@ -141,6 +143,7 @@ const onSubmit = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
errorApi(error)
|
||||||
console.error(error)
|
console.error(error)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|||||||
Reference in New Issue
Block a user