@aoao-y33/ui 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -11
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -5
- package/package.json +9 -3
- package/dist/global.d.ts +0 -33
- package/dist/global.d.ts.map +0 -1
- package/src/button/components/button/button.vue +0 -64
- package/src/button/components/button/index.ts +0 -2
- package/src/button/components/button/props.ts +0 -75
- package/src/button/components/fields/index.ts +0 -6
- package/src/button/hoc/index.ts +0 -1
- package/src/button/hoc/useButton.ts +0 -27
- package/src/button/index.ts +0 -4
- package/src/button/utils/index.ts +0 -32
- package/src/common/index.ts +0 -1
- package/src/common/utils/iconUtils.ts +0 -21
- package/src/common/utils/index.ts +0 -1
- package/src/form/components/fields/index.ts +0 -35
- package/src/form/components/form/form.vue +0 -130
- package/src/form/components/form/index.ts +0 -6
- package/src/form/components/form/props.ts +0 -73
- package/src/form/components/form-item/form-item.vue +0 -90
- package/src/form/components/form-item/index.ts +0 -6
- package/src/form/components/form-item/props.ts +0 -50
- package/src/form/hoc/index.ts +0 -3
- package/src/form/hoc/useForm.ts +0 -106
- package/src/form/hoc/useFormExpose.ts +0 -97
- package/src/form/hoc/useFormFetch.ts +0 -103
- package/src/form/index.ts +0 -5
- package/src/form/utils/index.ts +0 -149
- package/src/global.ts +0 -40
- package/src/index.ts +0 -37
- package/src/layout/components/fields/basic/basic.vue +0 -18
- package/src/layout/components/fields/index.ts +0 -10
- package/src/layout/components/fields/side/side.vue +0 -26
- package/src/layout/components/fields/top/top.vue +0 -13
- package/src/layout/components/layout/index.ts +0 -6
- package/src/layout/components/layout/layout.vue +0 -19
- package/src/layout/components/layout/props.ts +0 -3
- package/src/layout/hoc/index.ts +0 -1
- package/src/layout/hoc/useLayout.ts +0 -32
- package/src/layout/index.ts +0 -4
- package/src/layout/utils/index.ts +0 -31
- package/src/modal/components/form-modal/form-modal.vue +0 -158
- package/src/modal/components/form-modal/index.ts +0 -5
- package/src/modal/components/form-modal/props.ts +0 -61
- package/src/modal/components/modal/index.ts +0 -6
- package/src/modal/components/modal/modal.vue +0 -127
- package/src/modal/components/modal/props.ts +0 -78
- package/src/modal/hoc/index.ts +0 -3
- package/src/modal/hoc/useFormModal.ts +0 -140
- package/src/modal/hoc/useModal.ts +0 -151
- package/src/modal/hoc/useModalExpose.ts +0 -52
- package/src/modal/index.ts +0 -3
- package/src/style/index.css +0 -21
- package/src/table/components/fields/action-column/action-column.vue +0 -34
- package/src/table/components/fields/action-column/props.ts +0 -8
- package/src/table/components/fields/index.ts +0 -6
- package/src/table/components/table/index.ts +0 -6
- package/src/table/components/table/props.ts +0 -148
- package/src/table/components/table/table.vue +0 -77
- package/src/table/components/table-column/index.ts +0 -6
- package/src/table/components/table-column/props.ts +0 -26
- package/src/table/components/table-column/table-column.vue +0 -31
- package/src/table/components/table-page/index.ts +0 -6
- package/src/table/components/table-page/props.ts +0 -48
- package/src/table/components/table-page/table-page.vue +0 -51
- package/src/table/components/table-select/index.ts +0 -6
- package/src/table/components/table-select/props.ts +0 -79
- package/src/table/components/table-select/table-select.vue +0 -70
- package/src/table/hoc/index.ts +0 -2
- package/src/table/hoc/useTable.ts +0 -206
- package/src/table/hoc/useTableExpose.ts +0 -46
- package/src/table/index.ts +0 -7
- package/src/table/utils/index.ts +0 -37
- package/tsconfig.json +0 -30
- package/vite.config.ts +0 -49
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="w-full h-full flex flex-col overflow-hidden">
|
|
3
|
-
<header class="w-full">
|
|
4
|
-
<slot name="header"></slot>
|
|
5
|
-
</header>
|
|
6
|
-
<main class="flex flex-1 overflow-hidden h-full">
|
|
7
|
-
<aside class="h-full overflow-hidden">
|
|
8
|
-
<slot name="aside"></slot>
|
|
9
|
-
</aside>
|
|
10
|
-
<main class="flex-1 flex overflow-hidden h-full">
|
|
11
|
-
<slot name="main"></slot>
|
|
12
|
-
</main>
|
|
13
|
-
</main>
|
|
14
|
-
<footer class="w-full">
|
|
15
|
-
<slot name="footer"></slot>
|
|
16
|
-
</footer>
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import basic from './basic/basic.vue';
|
|
2
|
-
import side from './side/side.vue';
|
|
3
|
-
import top from './top/top.vue';
|
|
4
|
-
import {addLayoutField} from "@/layout";
|
|
5
|
-
|
|
6
|
-
export const initLayoutFields = () => {
|
|
7
|
-
addLayoutField('basic', basic);
|
|
8
|
-
addLayoutField('side', side);
|
|
9
|
-
addLayoutField('top', top);
|
|
10
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="w-full h-full flex overflow-hidden">
|
|
3
|
-
<aside class="h-full overflow-hidden">
|
|
4
|
-
<slot name="aside"></slot>
|
|
5
|
-
</aside>
|
|
6
|
-
<main class="h-full flex-1 flex flex-col overflow-hidden">
|
|
7
|
-
<header class="w-full">
|
|
8
|
-
<slot name="header"></slot>
|
|
9
|
-
</header>
|
|
10
|
-
<main class="flex-1 w-full overflow-hidden">
|
|
11
|
-
<slot name="main"></slot>
|
|
12
|
-
</main>
|
|
13
|
-
<footer class="w-full">
|
|
14
|
-
<slot name="footer"></slot>
|
|
15
|
-
</footer>
|
|
16
|
-
</main>
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<script setup lang="ts">
|
|
21
|
-
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<style scoped>
|
|
25
|
-
|
|
26
|
-
</style>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex flex-col w-full h-full">
|
|
3
|
-
<header class="w-full">
|
|
4
|
-
<slot name="header"></slot>
|
|
5
|
-
</header>
|
|
6
|
-
<main class="flex-1 w-full flex overflow-hidden">
|
|
7
|
-
<slot name="main"></slot>
|
|
8
|
-
</main>
|
|
9
|
-
<footer class="w-full">
|
|
10
|
-
<slot name="footer"></slot>
|
|
11
|
-
</footer>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Layout>
|
|
3
|
-
<template v-for="slot in Object.keys(slots)" #[slot]>
|
|
4
|
-
<slot :name="slot"></slot>
|
|
5
|
-
</template>
|
|
6
|
-
</Layout>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import {type AxLayoutProps} from "./props";
|
|
11
|
-
import {computed, useSlots} from "vue";
|
|
12
|
-
import {layoutFields} from "@/layout";
|
|
13
|
-
|
|
14
|
-
const {type = 'basic'} = defineProps<AxLayoutProps>();
|
|
15
|
-
const slots = useSlots();
|
|
16
|
-
const Layout = computed(()=>{
|
|
17
|
-
return layoutFields[type]
|
|
18
|
-
})
|
|
19
|
-
</script>
|
package/src/layout/hoc/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useLayout';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {type Component, defineComponent, h, shallowRef} from "vue";
|
|
2
|
-
import {AxLayout} from "@/layout";
|
|
3
|
-
import {mergeDeep} from "@aoao-y33/utils";
|
|
4
|
-
|
|
5
|
-
export interface AxLayoutOptions {
|
|
6
|
-
type?: string;
|
|
7
|
-
header?:Component;
|
|
8
|
-
footer?:Component ;
|
|
9
|
-
main?:Component ;
|
|
10
|
-
aside?:Component ;
|
|
11
|
-
}
|
|
12
|
-
export function useLayout(options:AxLayoutOptions={}){
|
|
13
|
-
const props = shallowRef(options);
|
|
14
|
-
const setLayout=(options:AxLayoutOptions)=>{
|
|
15
|
-
props.value = mergeDeep(props.value,options);
|
|
16
|
-
}
|
|
17
|
-
const Layout = defineComponent({
|
|
18
|
-
setup(){
|
|
19
|
-
const slots:Record<string, Component> = {};
|
|
20
|
-
const keys = ['header','footer','main','aside'];
|
|
21
|
-
|
|
22
|
-
keys.forEach(key=>{
|
|
23
|
-
if(props.value?.[key as keyof typeof props.value]){
|
|
24
|
-
slots[key] = ()=>h(props.value[key as keyof typeof props.value] as Component)
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
return ()=>h(AxLayout as any,{type:props.value?.type},slots);
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return [Layout,setLayout] as const;
|
|
32
|
-
}
|
package/src/layout/index.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type {Component} from "vue";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 布局组件注册表
|
|
5
|
-
* 存储布局类型与对应 Vue 组件的映射关系
|
|
6
|
-
* @example
|
|
7
|
-
* // 注册自定义布局组件
|
|
8
|
-
* addLayoutField('sidebar', SidebarLayoutComponent)
|
|
9
|
-
*/
|
|
10
|
-
export const layoutFields:Record<string, Component> = {};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 注册新的布局类型组件
|
|
14
|
-
* 将自定义布局组件添加到布局类型注册表中
|
|
15
|
-
*
|
|
16
|
-
* @param type - 布局类型标识符(唯一)
|
|
17
|
-
* @param component - 对应的 Vue 组件
|
|
18
|
-
*
|
|
19
|
-
* @warning 如果类型已存在,会输出警告信息并阻止重复注册
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* import CustomLayout from './CustomLayout.vue'
|
|
23
|
-
* addLayoutField('custom-layout', CustomLayout)
|
|
24
|
-
*/
|
|
25
|
-
export const addLayoutField = (type: string, component: Component) => {
|
|
26
|
-
if (type in layoutFields) {
|
|
27
|
-
console.warn(`[AxLayout] Layout type ${type} already exists`)
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
layoutFields[type] = component;
|
|
31
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Modal v-bind="{...modalProps,...attrs}" v-model="_open"
|
|
3
|
-
:header-class="'ax-form-modal-header'+' '+headerClass"
|
|
4
|
-
:footer-class="'ax-form-modal-footer'+' '+footerClass"
|
|
5
|
-
:body-class="'ax-form-modal-body'+' '+bodyClass"
|
|
6
|
-
:close-icon
|
|
7
|
-
:class="['ax-form-modal',className]"
|
|
8
|
-
ref="modalRef"
|
|
9
|
-
:show-close="false">
|
|
10
|
-
<template #header v-if="title||showClose">
|
|
11
|
-
<div class="flex justify-between items-center overflow-hidden gap-1">
|
|
12
|
-
<div :title="title" class="flex-1 whitespace-nowrap text-ellipsis overflow-hidden">{{ title }}</div>
|
|
13
|
-
<ElIcon @click="close">
|
|
14
|
-
<Close/>
|
|
15
|
-
</ElIcon>
|
|
16
|
-
</div>
|
|
17
|
-
</template>
|
|
18
|
-
<template #default>
|
|
19
|
-
<AxForm v-loading="_loading" v-bind="{...modalProps,...attrs} as AxFormProps" :is-default="false" ref="formRef">
|
|
20
|
-
<slot></slot>
|
|
21
|
-
</AxForm>
|
|
22
|
-
</template>
|
|
23
|
-
<template #footer v-if="slots.button||isDefault">
|
|
24
|
-
<template v-if="isDefault">
|
|
25
|
-
<ax-button v-bind="_confirmButton" @click="onConfirm"></ax-button>
|
|
26
|
-
<ax-button v-bind="_cancelButton" @click="close"></ax-button>
|
|
27
|
-
</template>
|
|
28
|
-
<slot name="button"></slot>
|
|
29
|
-
</template>
|
|
30
|
-
</Modal>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<script setup lang="ts">
|
|
34
|
-
import type {AxFormModalProps, AxFormModalEmits} from "./props";
|
|
35
|
-
import {useDefineProps, useFetch} from "@aoao-y33/hooks";
|
|
36
|
-
import {computed, type Ref, ref, useAttrs, useSlots} from "vue";
|
|
37
|
-
import {type DrawerInstance, ElDialog, ElDrawer, ElIcon,vLoading} from "element-plus";
|
|
38
|
-
import {AxButton, type AxButtonProps} from "@/button";
|
|
39
|
-
import {Close} from "@element-plus/icons-vue";
|
|
40
|
-
import {AxForm, type AxFormInstance, type AxFormProps, useFormExpose} from "@/form";
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
type = 'dialog',
|
|
44
|
-
showClose = true,
|
|
45
|
-
open = false,
|
|
46
|
-
title = '',
|
|
47
|
-
isDefault = true,
|
|
48
|
-
confirmButton = {},
|
|
49
|
-
cancelButton = {},
|
|
50
|
-
className = "md:w-[30%]! w-[100%]!",
|
|
51
|
-
api = null,
|
|
52
|
-
apiConfig = {},
|
|
53
|
-
loading=false,
|
|
54
|
-
...props
|
|
55
|
-
} = defineProps<AxFormModalProps>();
|
|
56
|
-
|
|
57
|
-
const emits = defineEmits<AxFormModalEmits>();
|
|
58
|
-
|
|
59
|
-
const _confirmButton = useDefineProps<AxButtonProps>(confirmButton, {
|
|
60
|
-
text: '确定',
|
|
61
|
-
icon: 'CircleCheckFilled',
|
|
62
|
-
componentProps: {
|
|
63
|
-
type: 'primary',
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
const _cancelButton = useDefineProps<AxButtonProps>(cancelButton, {
|
|
68
|
-
text: '取消',
|
|
69
|
-
icon: 'CircleCloseFilled',
|
|
70
|
-
componentProps: {
|
|
71
|
-
type: 'default',
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const slots = useSlots();
|
|
76
|
-
|
|
77
|
-
const attrs = useAttrs();
|
|
78
|
-
|
|
79
|
-
const [,requestApi] = useFetch(api, apiConfig);
|
|
80
|
-
|
|
81
|
-
const modalProps = useDefineProps(props);
|
|
82
|
-
|
|
83
|
-
const _open = computed({
|
|
84
|
-
get() {
|
|
85
|
-
return open;
|
|
86
|
-
},
|
|
87
|
-
set(value) {
|
|
88
|
-
emits('update:open', value);
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
const _loading = computed(()=>{
|
|
93
|
-
return Boolean(loading||requestApi.getConfig().loading);
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const modalRef = ref<DrawerInstance>();
|
|
98
|
-
|
|
99
|
-
const formRef = ref<AxFormInstance>() as Ref<AxFormInstance>;
|
|
100
|
-
|
|
101
|
-
const formApi = useFormExpose(formRef);
|
|
102
|
-
|
|
103
|
-
const Modal = computed(() => {
|
|
104
|
-
return type === 'dialog' ? ElDialog : ElDrawer;
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
const close = () => {
|
|
108
|
-
modalRef.value?.handleClose();
|
|
109
|
-
emits("cancel");
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const onConfirm = () => {
|
|
113
|
-
const data = formApi.getValues();
|
|
114
|
-
formApi.getElForm().validate((res) => {
|
|
115
|
-
if(res){
|
|
116
|
-
if(requestApi.getReady()){
|
|
117
|
-
requestApi.load(data);
|
|
118
|
-
}
|
|
119
|
-
emits("confirm",data);
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const getModal = () => {
|
|
126
|
-
return modalRef.value;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
defineExpose({
|
|
130
|
-
getModal,
|
|
131
|
-
close,
|
|
132
|
-
...formApi,
|
|
133
|
-
...requestApi,
|
|
134
|
-
})
|
|
135
|
-
</script>
|
|
136
|
-
|
|
137
|
-
<style lang="scss">
|
|
138
|
-
.ax-form-modal {
|
|
139
|
-
padding: 0 !important;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.ax-form-modal-header {
|
|
143
|
-
padding: 8px 12px;
|
|
144
|
-
border-bottom: 1px solid var(--el-border-color);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.ax-form-modal-body {
|
|
148
|
-
flex: 1;
|
|
149
|
-
width: 100%;
|
|
150
|
-
height: 100%;
|
|
151
|
-
padding: 8px 12px;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.ax-form-modal-footer {
|
|
155
|
-
padding: 8px 12px;
|
|
156
|
-
border-top: 1px solid var(--el-border-color);
|
|
157
|
-
}
|
|
158
|
-
</style>
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type {AxModalProps} from "@/modal";
|
|
2
|
-
import type {AxFormItemOptions, AxFormProps} from "@/form";
|
|
3
|
-
import type {EmitsToEventProps} from "@aoao-y33/utils";
|
|
4
|
-
import type {FieldsConfig} from "@aoao-y33/hooks";
|
|
5
|
-
import type {AxButtonOptions} from "@/button";
|
|
6
|
-
import type {EmitsToProps} from "vue";
|
|
7
|
-
import type {DrawerEmits} from "element-plus";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* AxFormModal 表单弹窗组件属性接口
|
|
11
|
-
* 继承自 AxModalProps(弹窗属性)和 AxFormProps(表单属性),组合了弹窗和表单的双重功能
|
|
12
|
-
* @template T - 表单数据类型,必须是对象类型
|
|
13
|
-
*/
|
|
14
|
-
export interface AxFormModalProps<T extends Record<string, any> = any> extends AxModalProps, Omit<AxFormProps<T>, 'size'> {
|
|
15
|
-
// 继承了弹窗的所有属性和表单的大部分属性(排除了 size,避免与弹窗尺寸冲突)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* AxFormModal 表单弹窗组件事件发射接口
|
|
20
|
-
* @template T - 表单数据类型
|
|
21
|
-
*/
|
|
22
|
-
export interface AxFormModalEmits<T extends Record<string, any> = any> {
|
|
23
|
-
/**
|
|
24
|
-
* 弹窗显示状态变化事件(用于 v-model:open 双向绑定)
|
|
25
|
-
* @param data - 新的显示状态(true/false)
|
|
26
|
-
*/
|
|
27
|
-
'update:open': [data: boolean]
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 确认按钮点击事件,触发表单验证和提交
|
|
31
|
-
* @param data - 验证通过后的表单数据
|
|
32
|
-
*/
|
|
33
|
-
'confirm': [data: T]
|
|
34
|
-
|
|
35
|
-
/** 取消按钮点击事件或关闭弹窗时触发 */
|
|
36
|
-
'cancel': []
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* AxFormModal 表单弹窗配置选项接口
|
|
41
|
-
* 整合了弹窗属性、表单属性、事件处理和字段配置
|
|
42
|
-
* @template T - 表单数据类型
|
|
43
|
-
*/
|
|
44
|
-
export interface AxFormModalOptions<T extends Record<string, any> = any>
|
|
45
|
-
extends Omit<AxFormModalProps<T>, 'open'>, // 排除 open 属性(由内部状态管理)
|
|
46
|
-
EmitsToProps<DrawerEmits>, // 合并 Element Plus Drawer 的事件属性
|
|
47
|
-
EmitsToEventProps<AxFormModalEmits<T>> { // 合并自定义事件处理函数
|
|
48
|
-
/**
|
|
49
|
-
* 按钮配置映射表,用于配置弹窗中的操作按钮(确认、取消等)
|
|
50
|
-
* @see FieldsConfig - 字段配置类型
|
|
51
|
-
* @see AxButtonOptions - 按钮选项类型
|
|
52
|
-
*/
|
|
53
|
-
buttonConfig?: FieldsConfig<AxButtonOptions>
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 表单项配置映射表,用于配置弹窗内表单的各个字段
|
|
57
|
-
* @see FieldsConfig - 字段配置类型
|
|
58
|
-
* @see AxFormItemOptions - 表单项选项类型
|
|
59
|
-
*/
|
|
60
|
-
fieldConfig?: FieldsConfig<AxFormItemOptions>
|
|
61
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Modal v-bind="{...modalProps,...attrs}" v-model="_open"
|
|
3
|
-
:header-class="'ax-modal-header'+' '+headerClass"
|
|
4
|
-
:footer-class="'ax-modal-footer'+' '+footerClass"
|
|
5
|
-
:body-class="'ax-modal-body'+' '+bodyClass"
|
|
6
|
-
:close-icon
|
|
7
|
-
:class="['ax-modal',className]"
|
|
8
|
-
ref="modalRef"
|
|
9
|
-
:show-close="false" >
|
|
10
|
-
<template #header v-if="title||showClose">
|
|
11
|
-
<div class="flex justify-between items-center overflow-hidden gap-1">
|
|
12
|
-
<div :title="title" class="flex-1 whitespace-nowrap text-ellipsis overflow-hidden">{{title}}</div>
|
|
13
|
-
<ElIcon @click="close">
|
|
14
|
-
<Close/>
|
|
15
|
-
</ElIcon>
|
|
16
|
-
</div>
|
|
17
|
-
</template>
|
|
18
|
-
<template #default>
|
|
19
|
-
<slot></slot>
|
|
20
|
-
</template>
|
|
21
|
-
<template #footer v-if="slots.button||isDefault">
|
|
22
|
-
<template v-if="isDefault">
|
|
23
|
-
<ax-button v-bind="_confirmButton" @click="onConfirm"></ax-button>
|
|
24
|
-
<ax-button v-bind="_cancelButton" @click="close"></ax-button>
|
|
25
|
-
</template>
|
|
26
|
-
<slot name="button"></slot>
|
|
27
|
-
</template>
|
|
28
|
-
</Modal>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<script setup lang="ts">
|
|
32
|
-
import type {AxModalProps, AxModalEmits} from "./props";
|
|
33
|
-
import {useDefineProps} from "@aoao-y33/hooks";
|
|
34
|
-
import {computed, ref, useAttrs, useSlots} from "vue";
|
|
35
|
-
import {type DrawerInstance, ElDialog, ElDrawer,ElIcon} from "element-plus";
|
|
36
|
-
import {AxButton, type AxButtonProps} from "@/button";
|
|
37
|
-
import {Close} from "@element-plus/icons-vue";
|
|
38
|
-
|
|
39
|
-
const {
|
|
40
|
-
type = 'dialog',
|
|
41
|
-
showClose = true,
|
|
42
|
-
open = false,
|
|
43
|
-
title = '',
|
|
44
|
-
isDefault = true,
|
|
45
|
-
confirmButton = {},
|
|
46
|
-
cancelButton = {},
|
|
47
|
-
className = "md:w-[30%]! w-[100%]!",
|
|
48
|
-
...props
|
|
49
|
-
} = defineProps<AxModalProps>();
|
|
50
|
-
|
|
51
|
-
const emits = defineEmits<AxModalEmits>();
|
|
52
|
-
|
|
53
|
-
const _confirmButton = useDefineProps<AxButtonProps>(confirmButton, {
|
|
54
|
-
text: '确定',
|
|
55
|
-
icon: 'CircleCheckFilled',
|
|
56
|
-
componentProps: {
|
|
57
|
-
type: 'primary',
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
const _cancelButton = useDefineProps<AxButtonProps>(cancelButton, {
|
|
62
|
-
text: '取消',
|
|
63
|
-
icon: 'CircleCloseFilled',
|
|
64
|
-
componentProps: {
|
|
65
|
-
type: 'default',
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
const slots = useSlots();
|
|
70
|
-
|
|
71
|
-
const attrs = useAttrs();
|
|
72
|
-
|
|
73
|
-
const modalProps = useDefineProps(props);
|
|
74
|
-
|
|
75
|
-
const _open = computed({
|
|
76
|
-
get() {
|
|
77
|
-
return open;
|
|
78
|
-
},
|
|
79
|
-
set(value) {
|
|
80
|
-
emits('update:open', value);
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
const modalRef = ref<DrawerInstance>();
|
|
85
|
-
|
|
86
|
-
const Modal = computed(() => {
|
|
87
|
-
return type === 'dialog' ? ElDialog : ElDrawer;
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
const close = ()=>{
|
|
91
|
-
modalRef.value?.handleClose();
|
|
92
|
-
emits("cancel");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const onConfirm=()=>{
|
|
96
|
-
emits("confirm");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const getModal =()=>{
|
|
100
|
-
return modalRef.value;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
defineExpose({
|
|
104
|
-
getModal,
|
|
105
|
-
close
|
|
106
|
-
})
|
|
107
|
-
</script>
|
|
108
|
-
|
|
109
|
-
<style lang="scss">
|
|
110
|
-
.ax-modal{
|
|
111
|
-
padding: 0 !important;
|
|
112
|
-
}
|
|
113
|
-
.ax-modal-header{
|
|
114
|
-
padding: 8px 12px;
|
|
115
|
-
border-bottom: 1px solid var(--el-border-color);
|
|
116
|
-
}
|
|
117
|
-
.ax-modal-body{
|
|
118
|
-
flex:1;
|
|
119
|
-
width: 100%;
|
|
120
|
-
height: 100%;
|
|
121
|
-
padding: 8px 12px;
|
|
122
|
-
}
|
|
123
|
-
.ax-modal-footer{
|
|
124
|
-
padding: 8px 12px;
|
|
125
|
-
border-top: 1px solid var(--el-border-color);
|
|
126
|
-
}
|
|
127
|
-
</style>
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type {DrawerProps,DrawerEmits} from "element-plus";
|
|
2
|
-
import type {AxButtonOptions, AxButtonProps} from "@/button";
|
|
3
|
-
import type {EmitsToEventProps} from "@aoao-y33/utils";
|
|
4
|
-
import type {Component, EmitsToProps} from "vue";
|
|
5
|
-
import type {FieldsConfig} from "@aoao-y33/hooks";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* AxModal 弹窗组件属性接口
|
|
9
|
-
* 继承自 Element Plus DrawerProps,扩展了通用弹窗功能
|
|
10
|
-
* 支持 Drawer(抽屉)和 Dialog(对话框)两种展示模式
|
|
11
|
-
*/
|
|
12
|
-
export interface AxModalProps extends DrawerProps{
|
|
13
|
-
/**
|
|
14
|
-
* 弹窗类型,决定使用哪种展示形式
|
|
15
|
-
* - 'drawer': 抽屉式弹窗,从屏幕边缘滑出
|
|
16
|
-
* - 'dialog': 对话框式弹窗,居中显示
|
|
17
|
-
* @default 'drawer'
|
|
18
|
-
*/
|
|
19
|
-
type?:'drawer'|'dialog',
|
|
20
|
-
|
|
21
|
-
/** 弹窗标题,显示在弹窗顶部 */
|
|
22
|
-
title?:string
|
|
23
|
-
|
|
24
|
-
/** 弹窗的显示/隐藏状态,用于外部控制 */
|
|
25
|
-
open?:boolean
|
|
26
|
-
|
|
27
|
-
/** 自定义 CSS 类名,用于样式定制 */
|
|
28
|
-
className?:string
|
|
29
|
-
|
|
30
|
-
/** 确认按钮的配置项,用于自定义确认按钮的外观和行为 */
|
|
31
|
-
confirmButton?:AxButtonProps
|
|
32
|
-
|
|
33
|
-
/** 取消按钮的配置项,用于自定义取消按钮的外观和行为 */
|
|
34
|
-
cancelButton?:AxButtonProps
|
|
35
|
-
|
|
36
|
-
/** 是否使用默认配置,启用后将自动应用预设的弹窗样式和按钮 */
|
|
37
|
-
isDefault?:boolean
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* AxModal 弹窗组件事件发射接口
|
|
42
|
-
*/
|
|
43
|
-
export interface AxModalEmits{
|
|
44
|
-
/**
|
|
45
|
-
* 弹窗显示状态变化事件(用于 v-model:open 双向绑定)
|
|
46
|
-
* @param data - 新的显示状态(true/false)
|
|
47
|
-
*/
|
|
48
|
-
'update:open':[data:boolean],
|
|
49
|
-
|
|
50
|
-
/** 取消按钮点击或关闭弹窗时触发 */
|
|
51
|
-
'cancel':[]
|
|
52
|
-
|
|
53
|
-
/** 确认按钮点击时触发 */
|
|
54
|
-
'confirm':[]
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* AxModal 弹窗配置选项接口
|
|
59
|
-
* 整合了弹窗属性、事件处理和动态内容配置
|
|
60
|
-
*/
|
|
61
|
-
export interface AxModalOptions
|
|
62
|
-
extends Omit<AxModalProps, 'open'>, // 排除 open 属性(由内部状态管理)
|
|
63
|
-
EmitsToEventProps<AxModalEmits>, // 合并自定义事件处理函数
|
|
64
|
-
EmitsToProps<DrawerEmits>{ // 合并 Element Plus Drawer 的事件属性
|
|
65
|
-
/**
|
|
66
|
-
* 动态渲染的组件,用于在弹窗内容区域显示自定义组件
|
|
67
|
-
* @example
|
|
68
|
-
* component: UserFormComponent
|
|
69
|
-
*/
|
|
70
|
-
component?:Component,
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 按钮配置映射表,用于配置弹窗中的各种操作按钮
|
|
74
|
-
* @see FieldsConfig - 字段配置类型
|
|
75
|
-
* @see AxButtonOptions - 按钮选项类型
|
|
76
|
-
*/
|
|
77
|
-
buttonConfig?:FieldsConfig<AxButtonOptions>
|
|
78
|
-
}
|
package/src/modal/hoc/index.ts
DELETED