139 lines
2.6 KiB
Vue
139 lines
2.6 KiB
Vue
<script setup>
|
|
import { ArrowLeftOutlined } from '@ant-design/icons-vue'
|
|
import LayoutHeader from './LayoutHeader.vue'
|
|
|
|
defineOptions({ name: 'FormLayout' })
|
|
|
|
// Props
|
|
const props = defineProps({
|
|
title: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
showBack: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
submitText: {
|
|
type: String,
|
|
default: '提交'
|
|
},
|
|
cancelText: {
|
|
type: String,
|
|
default: '取消'
|
|
},
|
|
showCancel: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
submitLoading: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
showFooter: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
})
|
|
|
|
// Emits
|
|
const emit = defineEmits(['submit', 'cancel', 'back'])
|
|
|
|
// Methods
|
|
const handleSubmit = () => {
|
|
emit('submit')
|
|
}
|
|
|
|
const handleCancel = () => {
|
|
emit('cancel')
|
|
}
|
|
|
|
const handleBack = () => {
|
|
emit('back')
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="form-layout">
|
|
<LayoutHeader
|
|
:title="title"
|
|
:show-back="showBack"
|
|
@back="handleBack"
|
|
>
|
|
<template #extra>
|
|
<slot name="extra"></slot>
|
|
</template>
|
|
</LayoutHeader>
|
|
|
|
<!-- 表单内容 -->
|
|
<div class="form-layout__content">
|
|
<div class="form-container">
|
|
<slot></slot>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 底部操作栏 -->
|
|
<div v-if="showFooter" class="form-layout__footer">
|
|
<div class="footer-content">
|
|
<a-space :size="12">
|
|
<a-button v-if="showCancel" @click="handleCancel">
|
|
{{ cancelText }}
|
|
</a-button>
|
|
<a-button
|
|
type="primary"
|
|
:loading="submitLoading"
|
|
@click="handleSubmit"
|
|
>
|
|
{{ submitText }}
|
|
</a-button>
|
|
</a-space>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped lang="less">
|
|
.form-layout {
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
background: var(--bg-primary);
|
|
border: 1px solid var(--border-light);
|
|
border-radius: var(--radius-md);
|
|
}
|
|
|
|
.form-layout__content {
|
|
flex: 1;
|
|
overflow: auto;
|
|
padding: var(--space-md);
|
|
background: var(--bg-secondary);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.form-container {
|
|
width: 100%;
|
|
max-width: 600px;
|
|
background: var(--bg-primary);
|
|
border: 1px solid var(--border-light);
|
|
border-radius: var(--radius-md);
|
|
padding: var(--space-2xl);
|
|
}
|
|
|
|
.form-layout__footer {
|
|
padding: var(--space-md) var(--space-lg);
|
|
border-top: 1px solid var(--border-light);
|
|
background: var(--bg-primary);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.footer-content {
|
|
max-width: 600px;
|
|
margin: 0 auto;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
}
|
|
</style>
|