@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,140 +0,0 @@
|
|
|
1
|
-
import {type AxFormModalOptions, AxFormModal, useModalExpose, type ModalApi} from "@/modal";
|
|
2
|
-
import {type FieldsApi, type StateApi, useComponentPool, useState} from "@aoao-y33/hooks";
|
|
3
|
-
import {omit} from "lodash";
|
|
4
|
-
import {AxButton, type AxButtonOptions} from "@/button";
|
|
5
|
-
import {AxFormItem, type AxFormItemOptions, type FormApi, type FormFetchApi, useFormExpose, useFormFetch} from "@/form";
|
|
6
|
-
import {type Component, defineComponent, h, ref} from "vue";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* UseFormModal Hook 返回的 API 接口
|
|
10
|
-
* 整合了弹窗控制、表单操作和请求管理的完整功能集
|
|
11
|
-
* @template T - 表单数据类型
|
|
12
|
-
*/
|
|
13
|
-
export interface UseFormModalApi<T extends Record<string, any>> extends ModalApi, FormApi<T>, FormFetchApi<T> {
|
|
14
|
-
/**
|
|
15
|
-
* 打开弹窗的方法
|
|
16
|
-
* 调用后将显示表单弹窗
|
|
17
|
-
*/
|
|
18
|
-
readonly open: () => void;
|
|
19
|
-
|
|
20
|
-
/** 按钮组件池 API,用于管理弹窗中的操作按钮(确认、取消等) */
|
|
21
|
-
readonly buttonsApi: FieldsApi<AxButtonOptions>
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 弹窗属性状态管理器
|
|
25
|
-
* 用于动态更新弹窗配置(不包含 buttonConfig 和 fieldConfig)
|
|
26
|
-
*/
|
|
27
|
-
readonly setModal: StateApi<Omit<AxFormModalOptions, 'buttonConfig' | 'fieldConfig'>>
|
|
28
|
-
|
|
29
|
-
/** 表单项组件池 API,用于管理弹窗内表单的各个字段配置 */
|
|
30
|
-
readonly fieldsApi: FieldsApi<AxFormItemOptions>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 表单弹窗 Hook,用于创建集成了表单功能的弹窗组件
|
|
35
|
-
*
|
|
36
|
-
* 该 Hook 封装了弹窗和表单的组合逻辑,包括:
|
|
37
|
-
* - 弹窗显示/隐藏控制
|
|
38
|
-
* - 表单字段动态配置
|
|
39
|
-
* - 按钮动态配置
|
|
40
|
-
* - 表单验证和提交
|
|
41
|
-
* - 数据双向绑定
|
|
42
|
-
*
|
|
43
|
-
* @param options - 表单弹窗初始配置选项
|
|
44
|
-
* @returns [Modal 组件, FormModal API] 元组
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const [FormModal, modalApi] = useFormModal({
|
|
48
|
-
* title: '编辑用户',
|
|
49
|
-
* api: submitUserData,
|
|
50
|
-
* fieldConfig: {
|
|
51
|
-
* username: { label: '用户名', type: 'input', vtypes: ['required'] },
|
|
52
|
-
* email: { label: '邮箱', type: 'input', vtypes: ['required', 'mail'] }
|
|
53
|
-
* },
|
|
54
|
-
* buttonConfig: {
|
|
55
|
-
* confirm: { text: '保存' },
|
|
56
|
-
* cancel: { text: '取消' }
|
|
57
|
-
* }
|
|
58
|
-
* })
|
|
59
|
-
*
|
|
60
|
-
* // 在模板中使用
|
|
61
|
-
* <FormModal />
|
|
62
|
-
*
|
|
63
|
-
* // 通过 API 控制弹窗
|
|
64
|
-
* modalApi.open() // 打开弹窗
|
|
65
|
-
* modalApi.fieldsApi.addField('phone', { label: '电话', type: 'input' })
|
|
66
|
-
* modalApi.requestApi.submit()
|
|
67
|
-
*/
|
|
68
|
-
export function useFormModal<T extends Record<string, any> = any>(options: AxFormModalOptions<T> = {}): [Component, UseFormModalApi<T>] {
|
|
69
|
-
// 创建弹窗属性状态,排除 buttonConfig 和 fieldConfig(它们由独立的组件池管理)
|
|
70
|
-
const [props, setModal] = useState(omit(options, ['buttonConfig', 'fieldConfig']))
|
|
71
|
-
|
|
72
|
-
// 创建按钮组件池,用于管理和渲染弹窗中的操作按钮
|
|
73
|
-
const [Buttons, buttonsApi] = useComponentPool<AxButtonOptions>(AxButton, options.buttonConfig);
|
|
74
|
-
|
|
75
|
-
// 创建表单项组件池,用于管理和渲染弹窗内的表单字段
|
|
76
|
-
const [Fields, fieldsApi] = useComponentPool<AxFormItemOptions>(AxFormItem, options.fieldConfig);
|
|
77
|
-
|
|
78
|
-
// 创建弹窗引用,用于访问弹窗实例的方法
|
|
79
|
-
const modalRef = ref();
|
|
80
|
-
|
|
81
|
-
// 获取弹窗暴露的 API(关闭、销毁等方法)
|
|
82
|
-
const modalApi = useModalExpose(modalRef);
|
|
83
|
-
|
|
84
|
-
// 获取表单暴露的 API(验证、重置、获取数据等方法)
|
|
85
|
-
const formApi = useFormExpose<T>(modalRef);
|
|
86
|
-
|
|
87
|
-
// 获取表单请求 API(提交、数据获取等异步操作)
|
|
88
|
-
const requestApi = useFormFetch<T>(modalRef);
|
|
89
|
-
|
|
90
|
-
// 创建内部可见性状态,用于控制弹窗显示/隐藏
|
|
91
|
-
const [visible, setVisible] = useState(false);
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 打开弹窗方法
|
|
95
|
-
* 设置内部可见性状态为 true
|
|
96
|
-
*/
|
|
97
|
-
const open = () => {
|
|
98
|
-
setVisible(true);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// 定义表单弹窗渲染组件
|
|
102
|
-
const Modal = defineComponent({
|
|
103
|
-
setup() {
|
|
104
|
-
const slots: Record<string, Component> = {};
|
|
105
|
-
|
|
106
|
-
// 如果存在字段配置,创建默认插槽(表单项列表)
|
|
107
|
-
if (fieldsApi.getList().length) {
|
|
108
|
-
slots.default = () => h(Fields);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// 如果存在按钮配置,创建按钮插槽
|
|
112
|
-
if (buttonsApi.getList().length) {
|
|
113
|
-
slots.button = () => h(Buttons);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// 渲染 AxFormModal 组件,传入 ref、属性和事件处理
|
|
117
|
-
return () => h(AxFormModal, {
|
|
118
|
-
ref: modalRef,
|
|
119
|
-
...props.value,
|
|
120
|
-
// 监听弹窗显示状态变化,同步到内部状态
|
|
121
|
-
"onUpdate:open": (val: boolean) => {
|
|
122
|
-
setVisible(val);
|
|
123
|
-
},
|
|
124
|
-
// 绑定内部可见性状态到弹窗
|
|
125
|
-
open: visible.value,
|
|
126
|
-
}, slots);
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
// 返回弹窗组件和完整的 API 集合(合并弹窗、表单、请求 API)
|
|
131
|
-
return [Modal, {
|
|
132
|
-
...modalApi,
|
|
133
|
-
...formApi,
|
|
134
|
-
...requestApi,
|
|
135
|
-
buttonsApi,
|
|
136
|
-
fieldsApi,
|
|
137
|
-
open,
|
|
138
|
-
setModal
|
|
139
|
-
}] as const;
|
|
140
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import {AxModal, type AxModalOptions, type ModalApi} from "@/modal";
|
|
2
|
-
import {type FieldsApi, type StateApi, useComponentPool, useState} from "@aoao-y33/hooks";
|
|
3
|
-
import {type Component, defineComponent, h, ref, shallowRef} from "vue";
|
|
4
|
-
import {omit} from "lodash";
|
|
5
|
-
import {AxButton, type AxButtonOptions} from "@/button";
|
|
6
|
-
import {useModalExpose} from "@/modal";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* UseModal Hook 返回的 API 接口
|
|
10
|
-
* 提供完整的弹窗控制和内容管理能力
|
|
11
|
-
*/
|
|
12
|
-
export interface UseModalApi extends ModalApi {
|
|
13
|
-
/**
|
|
14
|
-
* 打开弹窗的方法
|
|
15
|
-
* 调用后将显示弹窗
|
|
16
|
-
*/
|
|
17
|
-
readonly open: () => void;
|
|
18
|
-
|
|
19
|
-
/** 按钮组件池 API,用于管理弹窗中的操作按钮(确认、取消等) */
|
|
20
|
-
readonly buttonsApi: FieldsApi<AxButtonOptions>
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 弹窗属性状态管理器
|
|
24
|
-
* 用于动态更新弹窗配置(不包含 buttonConfig 和 component)
|
|
25
|
-
*/
|
|
26
|
-
readonly setModal: StateApi<Omit<AxModalOptions, 'buttonConfig' | 'component'>>
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 获取弹窗内动态组件实例的方法
|
|
30
|
-
* @returns 组件实例引用,可用于访问子组件的方法和属性
|
|
31
|
-
*/
|
|
32
|
-
readonly getComponent: () => any
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 通用弹窗 Hook,用于创建可配置的弹窗组件
|
|
37
|
-
*
|
|
38
|
-
* 该 Hook 封装了弹窗的核心逻辑,包括:
|
|
39
|
-
* - 弹窗显示/隐藏控制
|
|
40
|
-
* - 动态组件渲染(支持自定义内容组件)
|
|
41
|
-
* - 按钮动态配置
|
|
42
|
-
* - 弹窗状态管理
|
|
43
|
-
* - 组件实例访问
|
|
44
|
-
*
|
|
45
|
-
* @param options - 弹窗初始配置选项
|
|
46
|
-
* @returns [Modal 组件, Modal API] 元组
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* // 基础用法
|
|
50
|
-
* const [Modal, modalApi] = useModal({
|
|
51
|
-
* title: '提示',
|
|
52
|
-
* type: 'dialog'
|
|
53
|
-
* })
|
|
54
|
-
*
|
|
55
|
-
* // 带自定义组件的用法
|
|
56
|
-
* import UserDetail from './UserDetail.vue'
|
|
57
|
-
* const [Modal, modalApi] = useModal({
|
|
58
|
-
* title: '用户详情',
|
|
59
|
-
* component: UserDetail,
|
|
60
|
-
* buttonConfig: {
|
|
61
|
-
* confirm: { text: '关闭' }
|
|
62
|
-
* }
|
|
63
|
-
* })
|
|
64
|
-
*
|
|
65
|
-
* // 在模板中使用
|
|
66
|
-
* <Modal />
|
|
67
|
-
*
|
|
68
|
-
* // 通过 API 控制弹窗
|
|
69
|
-
* modalApi.open() // 打开弹窗
|
|
70
|
-
* modalApi.getComponent() // 获取内部组件实例
|
|
71
|
-
* modalApi.setModal({ title: '新标题' }) // 动态修改弹窗属性
|
|
72
|
-
*/
|
|
73
|
-
export function useModal(options: AxModalOptions = {}): [Component, UseModalApi] {
|
|
74
|
-
|
|
75
|
-
// 创建弹窗属性状态,排除 component 和 buttonConfig(它们由独立方式管理)
|
|
76
|
-
const [props, setModal] = useState(omit(options, ['component', 'buttonConfig']));
|
|
77
|
-
|
|
78
|
-
// 使用 shallowRef 存储动态组件,避免深层响应式开销
|
|
79
|
-
const component = shallowRef(options.component);
|
|
80
|
-
|
|
81
|
-
// 创建按钮组件池,用于管理和渲染弹窗中的操作按钮
|
|
82
|
-
const [Buttons, buttonsApi] = useComponentPool<AxButtonOptions>(AxButton, options.buttonConfig);
|
|
83
|
-
|
|
84
|
-
// 创建内部可见性状态,用于控制弹窗显示/隐藏
|
|
85
|
-
const [visible, setVisible] = useState(false);
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 打开弹窗方法
|
|
89
|
-
* 设置内部可见性状态为 true
|
|
90
|
-
*/
|
|
91
|
-
const open = () => {
|
|
92
|
-
setVisible(true);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 创建组件引用,用于访问弹窗内动态组件的实例
|
|
96
|
-
const componentRef = ref();
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 获取动态组件实例的方法
|
|
100
|
-
* @returns 组件实例引用
|
|
101
|
-
*/
|
|
102
|
-
const getComponent = () => {
|
|
103
|
-
return componentRef.value;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// 创建弹窗引用,用于访问弹窗实例的方法
|
|
107
|
-
const modalRef = ref();
|
|
108
|
-
|
|
109
|
-
// 获取弹窗暴露的 API(关闭、销毁等方法)
|
|
110
|
-
const modalApi = useModalExpose(modalRef);
|
|
111
|
-
|
|
112
|
-
// 定义弹窗渲染组件
|
|
113
|
-
const Modal = defineComponent({
|
|
114
|
-
setup() {
|
|
115
|
-
const slots: Record<string, Component> = {};
|
|
116
|
-
|
|
117
|
-
// 如果配置了动态组件,创建默认插槽并传入组件引用
|
|
118
|
-
if (component.value) {
|
|
119
|
-
slots.default = () => h(component.value, {ref: componentRef});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 如果存在按钮配置,创建按钮插槽
|
|
123
|
-
if (buttonsApi.getList().length) {
|
|
124
|
-
slots.button = () => h(Buttons);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// 渲染 AxModal 组件,传入 ref、属性和事件处理
|
|
128
|
-
return () => h(AxModal, {
|
|
129
|
-
ref: modalRef,
|
|
130
|
-
...props.value,
|
|
131
|
-
// 监听弹窗显示状态变化,同步到内部状态
|
|
132
|
-
"onUpdate:open": (val: boolean) => {
|
|
133
|
-
setVisible(val);
|
|
134
|
-
},
|
|
135
|
-
// 绑定内部可见性状态到弹窗
|
|
136
|
-
open: visible.value,
|
|
137
|
-
}, slots);
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
// 返回弹窗组件和完整的 API 集合(合并按钮管理、状态管理、打开方法和弹窗 API)
|
|
142
|
-
return [Modal,
|
|
143
|
-
{
|
|
144
|
-
buttonsApi,
|
|
145
|
-
setModal,
|
|
146
|
-
open,
|
|
147
|
-
...modalApi,
|
|
148
|
-
getComponent
|
|
149
|
-
}] as const;
|
|
150
|
-
|
|
151
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type {Ref} from "vue";
|
|
2
|
-
import type {AxModalInstance} from "@/modal";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* ModalApi 类型定义
|
|
6
|
-
* 由 useModalExpose 函数返回的 API 对象类型
|
|
7
|
-
*/
|
|
8
|
-
export type ModalApi = ReturnType<typeof useModalExpose>;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 弹窗暴露 API Hook,用于获取和控制弹窗实例的方法
|
|
12
|
-
*
|
|
13
|
-
* 该 Hook 提供了访问底层弹窗实例的能力,包括:
|
|
14
|
-
* - 关闭弹窗
|
|
15
|
-
* - 获取原生弹窗组件实例
|
|
16
|
-
*
|
|
17
|
-
* @param modal - 弹窗组件的 Ref 引用,指向 AxModalInstance 实例
|
|
18
|
-
* @returns 包含弹窗控制方法的 API 对象
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const modalRef = ref<AxModalInstance>();
|
|
22
|
-
* const modalApi = useModalExpose(modalRef);
|
|
23
|
-
*
|
|
24
|
-
* // 关闭弹窗
|
|
25
|
-
* modalApi.close()
|
|
26
|
-
*
|
|
27
|
-
* // 获取原生弹窗实例(如 Element Plus 的 Drawer/Dialog 实例)
|
|
28
|
-
* const instance = modalApi.getModal()
|
|
29
|
-
*/
|
|
30
|
-
export function useModalExpose(modal:Ref<AxModalInstance>){
|
|
31
|
-
/**
|
|
32
|
-
* 关闭弹窗方法
|
|
33
|
-
* 调用底层弹窗实例的 close 方法
|
|
34
|
-
*/
|
|
35
|
-
const close = ()=>{
|
|
36
|
-
modal.value.close();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 获取原生弹窗组件实例
|
|
41
|
-
* 可用于访问 Element Plus 弹窗组件的原生方法和属性
|
|
42
|
-
* @returns 原生弹窗实例(Drawer 或 Dialog 实例)
|
|
43
|
-
*/
|
|
44
|
-
const getModal=()=>{
|
|
45
|
-
return modal.value.getModal();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
close,
|
|
50
|
-
getModal
|
|
51
|
-
}
|
|
52
|
-
}
|
package/src/modal/index.ts
DELETED
package/src/style/index.css
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
@import "element-plus/dist/index.css";
|
|
2
|
-
@import "tailwindcss";
|
|
3
|
-
@import 'element-plus/theme-chalk/dark/css-vars.css';
|
|
4
|
-
|
|
5
|
-
:root {
|
|
6
|
-
--ax-bg-color: #F5F5F5;
|
|
7
|
-
--ax-block-color: #FFFFFF;
|
|
8
|
-
--ax-border-color: #E7E7E7;
|
|
9
|
-
--ax-small-radius: 4px;
|
|
10
|
-
--ax-normal-radius: 10px;
|
|
11
|
-
--el-fill-color-lighter: #EEF1F5;
|
|
12
|
-
--el-fill-color-blank: #fff;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
:root.dark {
|
|
16
|
-
--ax-bg-color: #14161A;
|
|
17
|
-
--ax-block-color: #1C1E23;
|
|
18
|
-
--ax-border-color: #1C1E23;
|
|
19
|
-
--el-fill-color-lighter: #313740;
|
|
20
|
-
--el-fill-color-blank: #191E27;
|
|
21
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex items-center gap-1">
|
|
3
|
-
<ax-button v-for="button in actionList.slice(0, over)" v-bind="button" :link="link" :isMl="false"></ax-button>
|
|
4
|
-
<ElPopover trigger="click" v-if="actionList.length>over">
|
|
5
|
-
<template #reference>
|
|
6
|
-
<el-icon style="transform: rotate(90deg);cursor: pointer">
|
|
7
|
-
<MoreFilled/>
|
|
8
|
-
</el-icon>
|
|
9
|
-
</template>
|
|
10
|
-
<div class="flex flex-col gap-2">
|
|
11
|
-
<ax-button v-for="button in hiddenAction.slice(0, over)" v-bind="button" :link="link" :isMl="false"></ax-button>
|
|
12
|
-
</div>
|
|
13
|
-
</ElPopover>
|
|
14
|
-
</div>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script setup lang="ts">
|
|
18
|
-
import type {ActionColumnProps} from "./props";
|
|
19
|
-
import {computed, provide} from "vue";
|
|
20
|
-
import {AxButton} from "@/button";
|
|
21
|
-
import {ElPopover, ElIcon} from "element-plus";
|
|
22
|
-
import {MoreFilled} from "@element-plus/icons-vue";
|
|
23
|
-
|
|
24
|
-
defineOptions({name: 'action-column'})
|
|
25
|
-
const {rowData = {}, link = true, over = 1, actionList = []} = defineProps<ActionColumnProps>()
|
|
26
|
-
provide("clickData", rowData.row)
|
|
27
|
-
const hiddenAction = computed(() => {
|
|
28
|
-
return actionList.slice(over);
|
|
29
|
-
})
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<style scoped>
|
|
33
|
-
|
|
34
|
-
</style>
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type {TableProps} from "element-plus";
|
|
2
|
-
import type {FetchOptions, FieldsConfig, RequestFetch} from "@aoao-y33/hooks";
|
|
3
|
-
import type {AxTableColumnsProps, AxTablePageOptions, AxTableSelectOptions} from "@/table";
|
|
4
|
-
import type {AxButtonOptions} from "@/button";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 分页数据结构
|
|
8
|
-
* 用于封装分页查询返回的数据格式
|
|
9
|
-
* @template T - 列表项数据类型
|
|
10
|
-
*/
|
|
11
|
-
export interface PageData<T> {
|
|
12
|
-
/** 数据总条数 */
|
|
13
|
-
total: number;
|
|
14
|
-
|
|
15
|
-
/** 当前页的数据列表 */
|
|
16
|
-
list: T[];
|
|
17
|
-
|
|
18
|
-
/** 当前页码 */
|
|
19
|
-
currentPage: number
|
|
20
|
-
|
|
21
|
-
/** 每页显示条数 */
|
|
22
|
-
currentSize: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* AxTable 表格组件属性接口
|
|
27
|
-
* 继承自 Element Plus TableProps,扩展了数据请求和分页功能
|
|
28
|
-
* @template T - 表格行数据类型,必须是对象类型
|
|
29
|
-
*/
|
|
30
|
-
export interface AxTableProps<T extends Record<string, any> = any> extends Partial<TableProps<T>> {
|
|
31
|
-
/**
|
|
32
|
-
* 表格数据源(本地数据)
|
|
33
|
-
* 如果提供了 api,则优先使用 api 获取数据
|
|
34
|
-
*/
|
|
35
|
-
data?: T[];
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* API 请求函数,用于从服务器获取表格数据
|
|
39
|
-
* 支持返回普通数组或分页数据结构
|
|
40
|
-
* @see RequestFetch - 请求函数类型
|
|
41
|
-
*/
|
|
42
|
-
api?: RequestFetch<any, T[] | PageData<T>>
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* API 请求配置项,包含请求参数、拦截器、转换函数等配置
|
|
46
|
-
* @see FetchOptions - 请求配置选项类型
|
|
47
|
-
*/
|
|
48
|
-
apiConfig?: FetchOptions<any, T[] | PageData<T>>
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* AxTable 表格组件事件发射接口
|
|
53
|
-
* 封装了 Element Plus Table 的所有事件
|
|
54
|
-
* @template T - 表格行数据类型
|
|
55
|
-
*/
|
|
56
|
-
export interface AxTableEmits<T extends Record<string, any> = any> {
|
|
57
|
-
/** 滚动事件 */
|
|
58
|
-
onScroll?: ((...args: T[]) => any) | undefined;
|
|
59
|
-
|
|
60
|
-
/** 选择行事件(点击复选框) */
|
|
61
|
-
onSelect?: ((...args: T[]) => any) | undefined;
|
|
62
|
-
|
|
63
|
-
/** 展开行变化事件 */
|
|
64
|
-
"onExpand-change"?: ((...args: T[]) => any) | undefined;
|
|
65
|
-
|
|
66
|
-
/** 当前页变化事件(分页) */
|
|
67
|
-
"onCurrent-change"?: ((...args: T[]) => any) | undefined;
|
|
68
|
-
|
|
69
|
-
/** 全选事件 */
|
|
70
|
-
"onSelect-all"?: ((...args: T[]) => any) | undefined;
|
|
71
|
-
|
|
72
|
-
/** 选中项变化事件 */
|
|
73
|
-
"onSelection-change"?: ((...args: T[]) => any) | undefined;
|
|
74
|
-
|
|
75
|
-
/** 单元格鼠标进入事件 */
|
|
76
|
-
"onCell-mouse-enter"?: ((...args: T[]) => any) | undefined;
|
|
77
|
-
|
|
78
|
-
/** 单元格鼠标离开事件 */
|
|
79
|
-
"onCell-mouse-leave"?: ((...args: T[]) => any) | undefined;
|
|
80
|
-
|
|
81
|
-
/** 单元格右键菜单事件 */
|
|
82
|
-
"onCell-contextmenu"?: ((...args: T[]) => any) | undefined;
|
|
83
|
-
|
|
84
|
-
/** 单元格单击事件 */
|
|
85
|
-
"onCell-click"?: ((...args: T[]) => any) | undefined;
|
|
86
|
-
|
|
87
|
-
/** 单元格双击事件 */
|
|
88
|
-
"onCell-dblclick"?: ((...args: T[]) => any) | undefined;
|
|
89
|
-
|
|
90
|
-
/** 行单击事件 */
|
|
91
|
-
"onRow-click"?: ((...args: T[]) => any) | undefined;
|
|
92
|
-
|
|
93
|
-
/** 行右键菜单事件 */
|
|
94
|
-
"onRow-contextmenu"?: ((...args: T[]) => any) | undefined;
|
|
95
|
-
|
|
96
|
-
/** 行双击事件 */
|
|
97
|
-
"onRow-dblclick"?: ((...args: T[]) => any) | undefined;
|
|
98
|
-
|
|
99
|
-
/** 表头单击事件 */
|
|
100
|
-
"onHeader-click"?: ((...args: T[]) => any) | undefined;
|
|
101
|
-
|
|
102
|
-
/** 表头右键菜单事件 */
|
|
103
|
-
"onHeader-contextmenu"?: ((...args: T[]) => any) | undefined;
|
|
104
|
-
|
|
105
|
-
/** 排序变化事件 */
|
|
106
|
-
"onSort-change"?: ((...args: T[]) => any) | undefined;
|
|
107
|
-
|
|
108
|
-
/** 筛选变化事件 */
|
|
109
|
-
"onFilter-change"?: ((...args: T[]) => any) | undefined;
|
|
110
|
-
|
|
111
|
-
/** 表头拖拽结束事件 */
|
|
112
|
-
"onHeader-dragend"?: ((...args: T[]) => any) | undefined;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* AxTable 表格配置选项接口
|
|
117
|
-
* 整合了表格属性、事件、列配置、分页配置、工具栏和搜索配置
|
|
118
|
-
* @template T - 表格行数据类型
|
|
119
|
-
* @template R - 搜索条件数据类型
|
|
120
|
-
*/
|
|
121
|
-
export interface AxTableOptions<T extends Record<string, any> = any, R extends Record<string, any> = any>
|
|
122
|
-
extends AxTableProps<T>, AxTableEmits<T>, AxTableEmits<T> {
|
|
123
|
-
/**
|
|
124
|
-
* 表格列配置映射表,用于定义表格的各个列(字段名、宽度、渲染方式等)
|
|
125
|
-
* @see FieldsConfig - 字段配置类型
|
|
126
|
-
* @see AxTableColumnsProps - 表格列属性类型
|
|
127
|
-
*/
|
|
128
|
-
columnConfig?: FieldsConfig<AxTableColumnsProps>
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 分页配置项,用于配置分页组件的显示和行为
|
|
132
|
-
* @see AxTablePageOptions - 分页选项类型
|
|
133
|
-
*/
|
|
134
|
-
pageConfig?: AxTablePageOptions
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* 工具栏按钮配置映射表,用于配置表格上方的操作按钮(新增、删除、导出等)
|
|
138
|
-
* @see FieldsConfig - 字段配置类型
|
|
139
|
-
* @see AxButtonOptions - 按钮选项类型
|
|
140
|
-
*/
|
|
141
|
-
toolConfig?: FieldsConfig<AxButtonOptions>
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* 搜索区域配置项,用于配置表格上方的搜索表单
|
|
145
|
-
* @see AxTableSelectOptions - 表格搜索选项类型
|
|
146
|
-
*/
|
|
147
|
-
searchConfig?: AxTableSelectOptions<R>
|
|
148
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex flex-col w-full h-full gap-2 overflow-hidden p-4" v-loading="_loading">
|
|
3
|
-
<div class="w-full rounded-(--ax-normal-radius) p-4 pb-0 bg-(--ax-block-color)" v-if="slots.search">
|
|
4
|
-
<slot name="search"></slot>
|
|
5
|
-
</div>
|
|
6
|
-
<div class="w-full rounded-(--ax-normal-radius) p-4 bg-(--ax-block-color)" v-if="slots.tool">
|
|
7
|
-
<slot name="tool"></slot>
|
|
8
|
-
</div>
|
|
9
|
-
<div class="flex-1 rounded-(--ax-normal-radius) overflow-hidden gap-2 flex flex-col bg-(--ax-block-color) p-4">
|
|
10
|
-
<div class="flex-1 overflow-auto">
|
|
11
|
-
<ElTable v-bind="{...tableProps,...attrs}"
|
|
12
|
-
:header-cell-class-name="'ax-table__header'+' '+headerCellClassName"
|
|
13
|
-
:stripe="true"
|
|
14
|
-
:showOverflowTooltip="showOverflowTooltip"
|
|
15
|
-
:data="_data" height="100%" ref="tableRef">
|
|
16
|
-
<slot></slot>
|
|
17
|
-
</ElTable>
|
|
18
|
-
</div>
|
|
19
|
-
<div v-if="slots.footer" class="flex justify-end">
|
|
20
|
-
<slot name="footer"></slot>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<script setup lang="ts">
|
|
27
|
-
import {ElTable, vLoading, type TableInstance} from "element-plus";
|
|
28
|
-
|
|
29
|
-
defineOptions({name: 'AxTable'})
|
|
30
|
-
import type {AxTableProps} from "./props";
|
|
31
|
-
import {useDefineProps, useFetch} from "@aoao-y33/hooks";
|
|
32
|
-
import {computed, onMounted, provide, ref, useAttrs, useSlots} from "vue";
|
|
33
|
-
|
|
34
|
-
const {
|
|
35
|
-
data = [],
|
|
36
|
-
showOverflowTooltip = true,
|
|
37
|
-
api = null,
|
|
38
|
-
apiConfig = {immediate: true},
|
|
39
|
-
...props
|
|
40
|
-
} = defineProps<AxTableProps>()
|
|
41
|
-
const attrs = useAttrs();
|
|
42
|
-
const slots = useSlots();
|
|
43
|
-
const [result, requestApi] = useFetch(null, apiConfig);
|
|
44
|
-
provide("requestApi", requestApi);
|
|
45
|
-
const tableProps = useDefineProps(props)
|
|
46
|
-
const tableRef = ref<TableInstance>();
|
|
47
|
-
const _data = computed(() => {
|
|
48
|
-
if (result.value) {
|
|
49
|
-
if (slots.footer) {
|
|
50
|
-
return result.value?.data?.data || []
|
|
51
|
-
}
|
|
52
|
-
return result.value?.data || []
|
|
53
|
-
}
|
|
54
|
-
return data;
|
|
55
|
-
})
|
|
56
|
-
const _loading = computed(() => {
|
|
57
|
-
return requestApi.getConfig().loading || false;
|
|
58
|
-
})
|
|
59
|
-
const getElTable = () => {
|
|
60
|
-
return tableRef.value as TableInstance;
|
|
61
|
-
}
|
|
62
|
-
onMounted(() => {
|
|
63
|
-
if (api) {
|
|
64
|
-
requestApi.setApi(api);
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
defineExpose({
|
|
68
|
-
getElTable,
|
|
69
|
-
...requestApi,
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
</script>
|
|
73
|
-
<style scoped lang="scss">
|
|
74
|
-
:deep(.ax-table__header) {
|
|
75
|
-
background: var(--el-fill-color-lighter) !important;
|
|
76
|
-
}
|
|
77
|
-
</style>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type {TableColumnCtx} from "element-plus";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* AxTableColumns 表格列组件属性接口
|
|
5
|
-
* 继承自 Element Plus TableColumnCtx,扩展了自定义列类型和组件配置功能
|
|
6
|
-
* @template T - 表格行数据类型,必须是对象类型
|
|
7
|
-
*/
|
|
8
|
-
export interface AxTableColumnsProps<T extends Record<string, any>= any> extends Partial<TableColumnCtx<T>>{
|
|
9
|
-
/**
|
|
10
|
-
* 列类型,决定该列的渲染方式
|
|
11
|
-
* @example
|
|
12
|
-
* - 'index': 索引列(显示行号)
|
|
13
|
-
* - 'selection': 选择列(复选框)
|
|
14
|
-
* - 'expand': 展开列(展开行内容)
|
|
15
|
-
* - 'custom': 自定义列(使用自定义组件渲染)
|
|
16
|
-
*/
|
|
17
|
-
type?:string,
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 自定义组件的属性配置
|
|
21
|
-
* 当列使用自定义组件渲染时,透传给该组件的属性
|
|
22
|
-
* @example
|
|
23
|
-
* componentProps: { color: 'red', size: 'large' }
|
|
24
|
-
*/
|
|
25
|
-
componentProps?:Record<string, any>
|
|
26
|
-
}
|