Browse Source

组件重写

main
likunming 1 year ago
parent
commit
d57b364ef7
  1. 76
      io.sc.platform.core.frontend/src/platform/components/dialog/WDialog.vue

76
io.sc.platform.core.frontend/src/platform/components/dialog/WDialog.vue

@ -1,10 +1,16 @@
<template>
<q-dialog v-model="isShowRef" allow-focus-outside v-bind="attrs">
<!-- 组件默认带上的官方属性说明
allow-focus-outside: 允许对话框外的元素可聚焦不设置该值会导致luckysheet在窗口中无法编辑
no-esc-dismiss: 用户不能按 ESC 键关闭对话框如果还设置了 'persistent' 属性则无需设置它
no-backdrop-dismiss: 用户不能通过单击对话框外部来关闭对话框如果还设置了 'persistent' 属性则无需设置它
no-refocus: 当对话框被隐藏时不要重新聚焦以前有聚焦过的 DOM 元素
-->
<q-dialog v-model="dialog.show" :maximized="dialog.maximized" allow-focus-outside no-esc-dismiss no-backdrop-dismiss no-refocus v-bind="attrs">
<q-card
:style="{
width: maximizedRef ? '100vw' : props.width,
width: dialog.maximized ? '100vw' : props.width,
'max-width': '100vw',
height: maximizedRef ? '100vh' : props.height,
height: dialog.maximized ? '100vh' : props.height,
'max-height': '100vh',
}"
>
@ -14,22 +20,17 @@
<div class="flex justify-between">
<div class="text-h6">{{ title }}</div>
<div class="flex justify-end gap-4">
<template v-for="(btn, index) in actions as any" :key="index">
<q-btn
v-if="typeof btn === 'object'"
:loading="btn.loading ? btn.loading : false"
:label="btn.label"
:icon="btn.icon"
color="primary"
@click="btn.click()"
>
</q-btn>
<template v-if="buttons && buttons.length > 0">
<template v-for="(btn, index) in buttons as any" :key="index">
<q-btn v-if="typeof btn === 'object'" :loading="false" :color="'primary'" v-bind="btn" @click="btn.click ? btn.click() : () => {}"> </q-btn>
</template>
</template>
<q-btn v-if="canMaximize" dense flat :icon="!maximizedRef ? PlatformIconEnum.全屏 : PlatformIconEnum.退出全屏" @click="maximizeBtnClick">
<q-tooltip v-if="!maximizedRef">全屏</q-tooltip>
<q-tooltip v-else-if="maximizedRef">退出全屏</q-tooltip>
<slot name="buttons"></slot>
<q-btn v-if="canMaximize" dense flat :icon="!dialog.maximized ? IconEnum.全屏 : IconEnum.退出全屏" @click="maximizeBtnClick">
<q-tooltip v-if="!dialog.maximized">全屏</q-tooltip>
<q-tooltip v-else-if="dialog.maximized">退出全屏</q-tooltip>
</q-btn>
<q-btn v-close-popup dense flat :icon="PlatformIconEnum.关闭">
<q-btn v-close-popup dense flat :icon="IconEnum.关闭">
<q-tooltip>关闭</q-tooltip>
</q-btn>
</div>
@ -38,17 +39,9 @@
<q-separator />
</div>
<div style="height: calc(100% - 69px)">
<q-card-section v-if="!splitter" style="height: 100%" class="scroll">
<slot name="content"></slot>
<q-card-section style="height: 100%; padding: 0px" class="scroll">
<slot></slot>
</q-card-section>
<q-splitter v-else style="height: 100%" v-bind="props.splitter">
<template #before>
<slot name="splitterBefore"></slot>
</template>
<template #after>
<slot name="splitterAfter"></slot>
</template>
</q-splitter>
</div>
</div>
</q-card>
@ -56,42 +49,39 @@
</template>
<script setup lang="ts">
import { ref, reactive, computed, useAttrs } from 'vue';
import { PlatformIconEnum } from '@/platform/components/utils';
import '@/css/tailwind.css';
import { reactive, useAttrs } from 'vue';
import { IconEnum } from '@/platform/enums';
const attrs = useAttrs();
const props = defineProps({
canMaximize: { type: Boolean, default: true },
title: { type: String, default: '' },
width: { type: String, default: '70%' },
height: { type: String, default: '70%' },
actions: { type: Array, default: () => [] },
splitter: { type: Object, default: undefined },
canMaximize: { type: Boolean, default: true },
buttons: { type: Array, default: () => [] },
});
const emit = defineEmits<{
(
e: 'maximize', //
e: 'maximized', //
maximized: boolean, // true:,false:退
): void;
}>();
const isShowRef = ref<boolean>(false);
const maximizedRef = ref<boolean>(attrs.maximized);
const dialog = reactive({
show: false,
maximized: attrs.maximized || false,
});
const maximizeBtnClick = () => {
maximizedRef.value = !maximizedRef.value;
emit('maximize', attrs.maximized);
dialog.maximized = !dialog.maximized;
emit('maximized', dialog.maximized);
};
const show = () => {
isShowRef.value = true;
dialog.show = true;
};
const hide = () => {
isShowRef.value = false;
dialog.show = false;
};
defineExpose({

Loading…
Cancel
Save