Files
onboard/resources/js/Components/AppPanel.vue
brusnitsyn 6cf1ffbb2b Добавил реанимацию
Правки окна операций
2026-05-07 22:37:07 +09:00

83 lines
2.2 KiB
Vue

<script setup>
import { NFormItem, NCard, NScrollbar } from 'naive-ui'
import {computed, ref, watch} from "vue";
const props = defineProps({
header: {
type: String,
default: ''
},
headerIncludeBody: {
type: Boolean,
default: false
},
feedback: {
type: String,
default: ''
},
minH: {
type: [String, Number],
default: null
},
maxH: {
type: [String, Number],
default: null
},
noPadding: {
type: Boolean,
default: false
}
})
const hasHeader = computed(() => props.header.trim().length > 0)
const hasHeaderInOutside = computed(() => hasHeader.value && !props.headerIncludeBody)
const hasFeedback = computed(() => props.feedback.trim().length > 0)
const hasMinH = computed(() => props.minH.trim().length > 0 || Number.isInteger(props.minH))
const hasMaxH = computed(() => props.maxH.trim().length > 0 || Number.isInteger(props.maxH))
const styles = ref([])
watch(() => [props.minH, props.maxH], ([minH, maxH]) => {
const sizeStyles = []
if (minH === null) return
if (minH.trim().length > 0) {
sizeStyles.push(`min-height: ${minH};`)
} else if (Number.isInteger(minH)) {
sizeStyles.push(`min-height: ${minH}px;`)
}
if (maxH === null) return
if (maxH.trim().length > 0) {
sizeStyles.push(`max-height: ${maxH};`)
} else if (Number.isInteger(maxH)) {
sizeStyles.push(`max-height: ${maxH}px;`)
}
styles.value = styles.value.concat(sizeStyles)
}, {
immediate: true
})
</script>
<template>
<NFormItem :show-label="hasHeaderInOutside" :label="header" :show-feedback="hasFeedback" :feedback="feedback">
<NCard v-bind="$attrs" :class="noPadding ? 'no-padding h-full' : 'h-full'">
<template v-if="!hasHeaderInOutside && header" #header>
{{ header }}
</template>
<template #header-extra>
<slot name="header-extra" />
</template>
<NScrollbar :style="styles">
<slot />
</NScrollbar>
</NCard>
</NFormItem>
</template>
<style scoped>
.no-padding :deep(.n-card-content) {
padding: 0 !important;
}
</style>