* добавил удаление карты, если она была добавлена не из МИС
* добавил диалог при удалении карты * добавил сохранение движения * добавил вывод сохраненного отчета * изменил логику сохранения отчета
This commit is contained in:
53
resources/js/Components/AppDialog.vue
Normal file
53
resources/js/Components/AppDialog.vue
Normal file
@@ -0,0 +1,53 @@
|
||||
<script setup>
|
||||
import { NModal, NSpace, NButton, NText, NFlex, NSpin } from 'naive-ui'
|
||||
|
||||
const props = defineProps({
|
||||
show: Boolean,
|
||||
loading: Boolean,
|
||||
title: String,
|
||||
content: String,
|
||||
positiveText: { type: String, default: 'Подтвердить' },
|
||||
negativeText: { type: String, default: 'Отмена' },
|
||||
maskClosable: { type: Boolean, default: false },
|
||||
positiveProps: { type: Object, default: { type: 'error', secondary: true } },
|
||||
negativeProps: { type: Object, default: { type: 'primary', secondary: true } }
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:show', 'confirm', 'cancel'])
|
||||
|
||||
const handleAction = (type) => {
|
||||
emit(type)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal
|
||||
:show="show"
|
||||
:mask-closable="maskClosable"
|
||||
@update:show="(val) => emit('update:show', val)"
|
||||
@after-leave="emit('after-leave')"
|
||||
preset="card"
|
||||
class="max-w-sm relative overflow-clip"
|
||||
:title="title"
|
||||
>
|
||||
<NFlex vertical size="large">
|
||||
<NSpace vertical :size="0">
|
||||
<NText v-if="content" tag="p">{{ content }}</NText>
|
||||
</NSpace>
|
||||
|
||||
<NSpace vertical size="small">
|
||||
<NButton v-if="negativeText" block v-bind="negativeProps" @click="handleAction('cancel')">
|
||||
{{ negativeText }}
|
||||
</NButton>
|
||||
<NButton v-if="positiveText" block v-bind="positiveProps" @click="handleAction('confirm')">
|
||||
{{ positiveText }}
|
||||
</NButton>
|
||||
</NSpace>
|
||||
</NFlex>
|
||||
<div v-if="loading" class="absolute inset-0" style="background-color: color-mix(in srgb, var(--n-color-embedded-modal), transparent 50%);">
|
||||
<div class="flex flex-col items-center justify-center h-full">
|
||||
<NSpin description="Загрузка" />
|
||||
</div>
|
||||
</div>
|
||||
</NModal>
|
||||
</template>
|
||||
40
resources/js/Components/AppDialogManager.vue
Normal file
40
resources/js/Components/AppDialogManager.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<script setup>
|
||||
import {dialogQueue, closeDialog, cleanupDialog} from '../Composables/useAppDialog'
|
||||
import AppDialog from './AppDialog.vue'
|
||||
|
||||
const handleConfirm = async (dialog) => {
|
||||
dialog.loading = true
|
||||
try {
|
||||
// Ждём выполнения вашего запроса
|
||||
if (typeof dialog.onConfirm === 'function') {
|
||||
await dialog.onConfirm()
|
||||
}
|
||||
closeDialog(dialog.id, true)
|
||||
} catch (error) {
|
||||
console.error('Ошибка при подтверждении:', error)
|
||||
dialog.loading = false // Оставляем диалог открытым при ошибке
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<AppDialog
|
||||
v-for="dialog in dialogQueue"
|
||||
:key="dialog.id"
|
||||
:show="dialog.show"
|
||||
:loading="dialog.loading"
|
||||
:title="dialog.title"
|
||||
:content="dialog.content"
|
||||
:positive-text="dialog.positiveText"
|
||||
:negative-text="dialog.negativeText"
|
||||
:positive-props="dialog.positiveProps"
|
||||
:negative-props="dialog.negativeProps"
|
||||
:mask-closable="dialog.maskClosable"
|
||||
@confirm="handleConfirm(dialog)"
|
||||
@cancel="closeDialog(dialog.id, false)"
|
||||
@update:show="(val) => !val && dialog.show && !dialog.loading && closeDialog(dialog.id, false)"
|
||||
@after-leave="cleanupDialog(dialog.id)"
|
||||
/>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -120,37 +120,52 @@ const modelComputed = computed({
|
||||
const formattedValue = computed(() => {
|
||||
const value = reportStore.timestampCurrentRange
|
||||
|
||||
if (authStore.isHeadOfDepartment || authStore.isAdmin) {
|
||||
if (props.isOneDay) {
|
||||
const dateToFormat = Array.isArray(value) ? value[1] : value
|
||||
return formatRussianDate(dateToFormat)
|
||||
} else if (Array.isArray(value) && value.length >= 2 && value[0] && value[1]) { // Для админа - диапазон дат
|
||||
return formatRussianDateRange(value)
|
||||
}
|
||||
|
||||
// Если что-то пошло не так, форматируем как одиночную дату
|
||||
if (value) {
|
||||
const dateToFormat = Array.isArray(value) ? value[0] : value
|
||||
return formatRussianDate(dateToFormat)
|
||||
}
|
||||
|
||||
return ''
|
||||
} else {
|
||||
// Для врача - одиночная дата
|
||||
let dateToFormat
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
dateToFormat = value[1] || value[0]
|
||||
} else {
|
||||
dateToFormat = value
|
||||
}
|
||||
|
||||
// Если выбрана сегодняшняя дата - показываем текущее время
|
||||
if (dateToFormat) {
|
||||
return formatRussianDate(dateToFormat)
|
||||
}
|
||||
return ''
|
||||
if (props.isOneDay) {
|
||||
const dateToFormat = Array.isArray(value) ? value[1] : value
|
||||
return formatRussianDate(dateToFormat)
|
||||
} else if (Array.isArray(value) && value.length >= 2 && value[0] && value[1]) { // Для админа - диапазон дат
|
||||
return formatRussianDateRange(value)
|
||||
}
|
||||
|
||||
// Если что-то пошло не так, форматируем как одиночную дату
|
||||
if (value) {
|
||||
const dateToFormat = Array.isArray(value) ? value[0] : value
|
||||
return formatRussianDate(dateToFormat)
|
||||
}
|
||||
|
||||
return ''
|
||||
|
||||
// if (authStore.isHeadOfDepartment || authStore.isAdmin) {
|
||||
// if (props.isOneDay) {
|
||||
// const dateToFormat = Array.isArray(value) ? value[1] : value
|
||||
// return formatRussianDate(dateToFormat)
|
||||
// } else if (Array.isArray(value) && value.length >= 2 && value[0] && value[1]) { // Для админа - диапазон дат
|
||||
// return formatRussianDateRange(value)
|
||||
// }
|
||||
//
|
||||
// // Если что-то пошло не так, форматируем как одиночную дату
|
||||
// if (value) {
|
||||
// const dateToFormat = Array.isArray(value) ? value[0] : value
|
||||
// return formatRussianDate(dateToFormat)
|
||||
// }
|
||||
//
|
||||
// return ''
|
||||
// } else {
|
||||
// // Для врача - одиночная дата
|
||||
// let dateToFormat
|
||||
//
|
||||
// if (Array.isArray(value)) {
|
||||
// dateToFormat = value[1] || value[0]
|
||||
// } else {
|
||||
// dateToFormat = value
|
||||
// }
|
||||
//
|
||||
// // Если выбрана сегодняшняя дата - показываем текущее время
|
||||
// if (dateToFormat) {
|
||||
// return formatRussianDate(dateToFormat)
|
||||
// }
|
||||
// return ''
|
||||
// }
|
||||
})
|
||||
|
||||
const classComputed = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user