gi-component 0.0.26 → 0.0.27
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.
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import type * as El from 'element-plus'
|
|
2
|
-
import type { FormProps as ElFormProps } from 'element-plus'
|
|
3
|
-
import type { VNode } from 'vue'
|
|
4
|
-
import type { MergeMultiple } from '../../../types/tool'
|
|
5
|
-
import type { GridItemProps, GridProps } from '../../grid/src/interface'
|
|
6
|
-
import type { InputSearchInstance } from '../../input-search'
|
|
7
|
-
|
|
8
|
-
export type FormColumnType
|
|
9
|
-
= | 'input'
|
|
10
|
-
| 'textarea'
|
|
11
|
-
| 'input-number'
|
|
12
|
-
| 'input-tag'
|
|
13
|
-
| 'input-search'
|
|
14
|
-
| 'select'
|
|
15
|
-
| 'select-v2'
|
|
16
|
-
| 'tree-select'
|
|
17
|
-
| 'cascader'
|
|
18
|
-
| 'slider'
|
|
19
|
-
| 'switch'
|
|
20
|
-
| 'rate'
|
|
21
|
-
| 'checkbox-group'
|
|
22
|
-
| 'checkbox'
|
|
23
|
-
| 'radio-group'
|
|
24
|
-
| 'radio'
|
|
25
|
-
| 'date-picker'
|
|
26
|
-
| 'time-picker'
|
|
27
|
-
| 'time-select'
|
|
28
|
-
| 'color-picker'
|
|
29
|
-
| 'transfer'
|
|
30
|
-
| 'autocomplete'
|
|
31
|
-
| 'upload'
|
|
32
|
-
| 'title'
|
|
33
|
-
| 'slot'
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 表单列属性类型,根据组件类型使用对应的属性类型
|
|
37
|
-
*/
|
|
38
|
-
export type FormColumnProps = MergeMultiple<[El.InputProps, El.InputNumberProps, El.InputTagProps, El.SelectProps, El.SelectV2Props, El.TreeInstance['$props'], El.CascaderProps, El.SliderProps, El.SwitchProps, El.RateProps, El.CheckboxGroupProps, El.CheckboxProps, El.RadioGroupProps, El.RadioProps, El.DatePickerProps, El.TimePickerDefaultProps, El.TimeSelectProps, El.ColorPickerProps, El.TransferProps, El.AutocompleteProps, El.UploadProps, InputSearchInstance['$props']]>
|
|
39
|
-
|
|
40
|
-
export type FormColumnItemHide<F> = boolean | ((form: F) => boolean)
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 表单列插槽类型,根据组件类型使用对应的插槽类型
|
|
44
|
-
*/
|
|
45
|
-
export type FormColumnSlots = Partial<
|
|
46
|
-
El.InputInstance['$slots']
|
|
47
|
-
| El.InputNumberInstance['$slots']
|
|
48
|
-
| El.InputTagInstance['$slots']
|
|
49
|
-
| El.AutocompleteInstance['$slots']
|
|
50
|
-
| El.CascaderInstance['$slots']
|
|
51
|
-
| El.DatePickerInstance['$slots']
|
|
52
|
-
>
|
|
53
|
-
|
|
54
|
-
export interface FormColumnItem<F = any> {
|
|
55
|
-
type: FormColumnType
|
|
56
|
-
label?: string
|
|
57
|
-
labelRender?: () => VNode
|
|
58
|
-
field: string
|
|
59
|
-
fieldName?: string
|
|
60
|
-
span?: number | GridItemProps['span']
|
|
61
|
-
props?: FormColumnProps
|
|
62
|
-
formItemProps?: El.FormItemProps
|
|
63
|
-
gridItemProps?: any
|
|
64
|
-
required?: boolean
|
|
65
|
-
rules?: El.FormItemRule[]
|
|
66
|
-
hide?: FormColumnItemHide<F> // 是否隐藏
|
|
67
|
-
tip?: string
|
|
68
|
-
dictCode?: string // 字典编码
|
|
69
|
-
slotName?: string
|
|
70
|
-
slots?: FormColumnSlots
|
|
71
|
-
extra?: string | (() => VNode) // 右侧额外内容
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface FormProps extends Partial<ElFormProps> {
|
|
75
|
-
modelValue: any
|
|
76
|
-
columns?: FormColumnItem[]
|
|
77
|
-
fc?: Record<string, { disabled?: boolean, hidden?: boolean, required?: boolean }> // 表单控制
|
|
78
|
-
gridProps?: GridProps // grid默认配置
|
|
79
|
-
gridItemProps?: GridItemProps // grid-item默认配置
|
|
80
|
-
search?: boolean
|
|
81
|
-
searchText?: string
|
|
82
|
-
hideFoldBtn?: boolean
|
|
83
|
-
defaultCollapsed?: boolean | undefined
|
|
84
|
-
}
|
|
1
|
+
import type * as El from 'element-plus'
|
|
2
|
+
import type { FormProps as ElFormProps } from 'element-plus'
|
|
3
|
+
import type { VNode } from 'vue'
|
|
4
|
+
import type { MergeMultiple } from '../../../types/tool'
|
|
5
|
+
import type { GridItemProps, GridProps } from '../../grid/src/interface'
|
|
6
|
+
import type { InputSearchInstance } from '../../input-search'
|
|
7
|
+
|
|
8
|
+
export type FormColumnType
|
|
9
|
+
= | 'input'
|
|
10
|
+
| 'textarea'
|
|
11
|
+
| 'input-number'
|
|
12
|
+
| 'input-tag'
|
|
13
|
+
| 'input-search'
|
|
14
|
+
| 'select'
|
|
15
|
+
| 'select-v2'
|
|
16
|
+
| 'tree-select'
|
|
17
|
+
| 'cascader'
|
|
18
|
+
| 'slider'
|
|
19
|
+
| 'switch'
|
|
20
|
+
| 'rate'
|
|
21
|
+
| 'checkbox-group'
|
|
22
|
+
| 'checkbox'
|
|
23
|
+
| 'radio-group'
|
|
24
|
+
| 'radio'
|
|
25
|
+
| 'date-picker'
|
|
26
|
+
| 'time-picker'
|
|
27
|
+
| 'time-select'
|
|
28
|
+
| 'color-picker'
|
|
29
|
+
| 'transfer'
|
|
30
|
+
| 'autocomplete'
|
|
31
|
+
| 'upload'
|
|
32
|
+
| 'title'
|
|
33
|
+
| 'slot'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 表单列属性类型,根据组件类型使用对应的属性类型
|
|
37
|
+
*/
|
|
38
|
+
export type FormColumnProps = MergeMultiple<[El.InputProps, El.InputNumberProps, El.InputTagProps, El.SelectProps, El.SelectV2Props, El.TreeInstance['$props'], El.CascaderProps, El.SliderProps, El.SwitchProps, El.RateProps, El.CheckboxGroupProps, El.CheckboxProps, El.RadioGroupProps, El.RadioProps, El.DatePickerProps, El.TimePickerDefaultProps, El.TimeSelectProps, El.ColorPickerProps, El.TransferProps, El.AutocompleteProps, El.UploadProps, InputSearchInstance['$props']]>
|
|
39
|
+
|
|
40
|
+
export type FormColumnItemHide<F> = boolean | ((form: F) => boolean)
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 表单列插槽类型,根据组件类型使用对应的插槽类型
|
|
44
|
+
*/
|
|
45
|
+
export type FormColumnSlots = Partial<
|
|
46
|
+
El.InputInstance['$slots']
|
|
47
|
+
| El.InputNumberInstance['$slots']
|
|
48
|
+
| El.InputTagInstance['$slots']
|
|
49
|
+
| El.AutocompleteInstance['$slots']
|
|
50
|
+
| El.CascaderInstance['$slots']
|
|
51
|
+
| El.DatePickerInstance['$slots']
|
|
52
|
+
>
|
|
53
|
+
|
|
54
|
+
export interface FormColumnItem<F = any> {
|
|
55
|
+
type: FormColumnType
|
|
56
|
+
label?: string
|
|
57
|
+
labelRender?: () => VNode
|
|
58
|
+
field: string
|
|
59
|
+
fieldName?: string
|
|
60
|
+
span?: number | GridItemProps['span']
|
|
61
|
+
props?: FormColumnProps
|
|
62
|
+
formItemProps?: El.FormItemProps
|
|
63
|
+
gridItemProps?: any
|
|
64
|
+
required?: boolean
|
|
65
|
+
rules?: El.FormItemRule[]
|
|
66
|
+
hide?: FormColumnItemHide<F> // 是否隐藏
|
|
67
|
+
tip?: string
|
|
68
|
+
dictCode?: string // 字典编码
|
|
69
|
+
slotName?: string
|
|
70
|
+
slots?: FormColumnSlots
|
|
71
|
+
extra?: string | (() => VNode) // 右侧额外内容
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface FormProps extends Partial<ElFormProps> {
|
|
75
|
+
modelValue: any
|
|
76
|
+
columns?: FormColumnItem[]
|
|
77
|
+
fc?: Record<string, { disabled?: boolean, hidden?: boolean, required?: boolean }> // 表单控制
|
|
78
|
+
gridProps?: GridProps // grid默认配置
|
|
79
|
+
gridItemProps?: GridItemProps // grid-item默认配置
|
|
80
|
+
search?: boolean
|
|
81
|
+
searchText?: string
|
|
82
|
+
hideFoldBtn?: boolean
|
|
83
|
+
defaultCollapsed?: boolean | undefined
|
|
84
|
+
}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
@use './el.scss';
|
|
3
3
|
|
|
4
4
|
body {
|
|
5
|
+
// 主要作用于页面
|
|
5
6
|
--padding: 14px;
|
|
6
7
|
--margin: 14px;
|
|
8
|
+
// 主要作用于内置组件(不建议使用)
|
|
7
9
|
--padding-x: 14px;
|
|
8
10
|
--padding-x-small: 10px;
|
|
9
11
|
--padding-y: 12px;
|
|
@@ -144,4 +146,8 @@ body {
|
|
|
144
146
|
|
|
145
147
|
.gi-flex-column {
|
|
146
148
|
flex-direction: column;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.gi-tool {
|
|
152
|
+
gap: 8px;
|
|
147
153
|
}
|
|
@@ -1,48 +1,55 @@
|
|
|
1
1
|
import type { Component } from 'vue'
|
|
2
2
|
import type { DialogOptions } from '../index'
|
|
3
3
|
import { ElMessage } from 'element-plus'
|
|
4
|
-
import { h, ref } from 'vue'
|
|
4
|
+
import { h, ref } from 'vue'
|
|
5
5
|
import { Dialog } from '../index'
|
|
6
6
|
|
|
7
|
+
// 创建选择弹窗的参数
|
|
7
8
|
interface CreateSelectDialogParams extends Omit<DialogOptions, 'content' | 'onOk' | 'onBeforeOk'> {
|
|
8
|
-
component: Component
|
|
9
|
-
componentProps?: Record<string, any>
|
|
10
|
-
tip?: string
|
|
9
|
+
component: Component // 内容组件
|
|
10
|
+
componentProps?: Record<string, any> // 内容组件属性
|
|
11
|
+
tip?: string // 提示信息
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
// 默认选项
|
|
15
|
+
interface DefaultOption {
|
|
16
|
+
queryParams?: Record<string, any>
|
|
17
|
+
componentProps?: Record<string, any>
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// 打开选择弹窗的选项
|
|
21
|
+
type DialogOption<T, Q extends DefaultOption = DefaultOption> = {
|
|
22
|
+
title?: string // 标题
|
|
23
|
+
multiple?: boolean // 是否多选
|
|
24
|
+
queryParams?: (Q extends { queryParams: infer P } ? P : DefaultOption['queryParams']) // 查询参数
|
|
25
|
+
componentProps?: (Q extends { componentProps: infer P } ? P : DefaultOption['componentProps']) // 组件属性
|
|
26
|
+
onOk?: (data: T) => void // 确定回调
|
|
27
|
+
onBeforeOk?: (data: T) => Promise<boolean> // 确定前的回调
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
/**
|
|
26
31
|
* 创建选择弹窗
|
|
27
32
|
* @description component组件必须暴露一个getSelectedData方法
|
|
28
33
|
*/
|
|
29
|
-
export const createSelectDialog = <T, Q extends
|
|
34
|
+
export const createSelectDialog = <T, Q extends DefaultOption = DefaultOption>(
|
|
30
35
|
params: CreateSelectDialogParams
|
|
31
36
|
) => {
|
|
32
37
|
return function (options: DialogOption<T, Q>) {
|
|
33
|
-
const { multiple = false, onOk, onBeforeOk, queryParams } = options
|
|
38
|
+
const { multiple = false, onOk, onBeforeOk, queryParams, componentProps } = options
|
|
34
39
|
const DialogTableRef = ref<any>()
|
|
40
|
+
const { component, componentProps: componentPropsFromParams, tip, ...restParams } = params
|
|
35
41
|
|
|
36
42
|
Dialog.open({
|
|
37
43
|
bodyClass: 'gi-p0',
|
|
38
|
-
...
|
|
44
|
+
...restParams,
|
|
39
45
|
title: params.title || options.title,
|
|
40
46
|
content: () =>
|
|
41
47
|
h(params.component, {
|
|
42
48
|
ref: (e: any) => (DialogTableRef.value = e),
|
|
43
49
|
multiple,
|
|
44
50
|
queryParams,
|
|
45
|
-
...params.componentProps
|
|
51
|
+
...params.componentProps,
|
|
52
|
+
...componentProps
|
|
46
53
|
}),
|
|
47
54
|
style: { maxWidth: '1000px', ...params.style },
|
|
48
55
|
onBeforeOk: async () => {
|