@wyfex/ivue 0.22.1 → 0.22.3

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.
Files changed (38) hide show
  1. package/dist/index.es.js +1 -1
  2. package/dist/index.umd.cjs +1 -1
  3. package/dist/ivue.css +1 -1
  4. package/dist/types/UseCrud/defaultExtConfig.d.ts +4 -3
  5. package/dist/types/UseCrud/hook.d.ts +4 -2
  6. package/dist/types/UseCrud/index.vue.d.ts +2 -1
  7. package/dist/types/UseCrud/types.d.ts +2 -10
  8. package/dist/types/UseElConfigProvider/defaultExtConfig.d.ts +12 -4
  9. package/dist/types/UseElConfigProvider/index.vue.d.ts +1 -1
  10. package/dist/types/UseElConfigProvider/types.d.ts +10 -2
  11. package/dist/types/UseElDescriptions/index.vue.d.ts +9 -18
  12. package/dist/types/UseElDescriptions/props.d.ts +5 -9
  13. package/dist/types/UseElForm/components/QueryForm.vue.d.ts +9 -18
  14. package/dist/types/UseElForm/components/RowForm.vue.d.ts +23 -28
  15. package/dist/types/UseElForm/components/controls/Cascader.vue.d.ts +2 -2
  16. package/dist/types/UseElForm/components/controls/Radio.vue.d.ts +2 -2
  17. package/dist/types/UseElForm/components/controls/Select.vue.d.ts +2 -2
  18. package/dist/types/UseElForm/components/controls/TreeSelect.vue.d.ts +2 -2
  19. package/dist/types/UseElForm/index.vue.d.ts +9 -18
  20. package/dist/types/UseElForm/props.d.ts +5 -9
  21. package/dist/types/UseElSelect/index.vue.d.ts +5 -5
  22. package/dist/types/UseElSelect/props.d.ts +3 -3
  23. package/dist/types/UseElTable/defaultExtConfig.d.ts +5 -0
  24. package/dist/types/UseElTable/index.vue.d.ts +6 -15
  25. package/dist/types/UseElTable/props.d.ts +3 -7
  26. package/dist/types/UseElTable/types.d.ts +15 -0
  27. package/package.json +1 -1
  28. package/src/components/UseCrud/defaultExtConfig.ts +1 -1
  29. package/src/components/UseCrud/types.ts +1 -18
  30. package/src/components/UseElConfigProvider/defaultExtConfig.ts +7 -1
  31. package/src/components/UseElConfigProvider/types.ts +21 -3
  32. package/src/components/UseElDescriptions/props.ts +8 -15
  33. package/src/components/UseElForm/props.ts +8 -15
  34. package/src/components/UseElSelect/props.ts +5 -4
  35. package/src/components/UseElTable/defaultExtConfig.ts +1 -0
  36. package/src/components/UseElTable/props.ts +4 -11
  37. package/src/components/UseElTable/types.ts +27 -0
  38. package/src/types/index.ts +36 -0
@@ -1,6 +1,7 @@
1
1
  import { Component, ExtractPropTypes } from 'vue';
2
2
  import { EditAttrs, GlobalConfig, UseDict } from '../../types';
3
3
  import { default as componentProps } from './props';
4
+ import { QueryApiPayload } from '../UseElConfigProvider/types';
4
5
  export type Props = ExtractPropTypes<typeof componentProps>;
5
6
  export type Emits = {
6
7
  (e: 'onDictKeys', value?: string[]): void;
@@ -59,7 +60,21 @@ export interface Selection {
59
60
  align?: string;
60
61
  fixed?: boolean;
61
62
  }
63
+ export type Query = {
64
+ api?: Function;
65
+ immediate?: boolean;
66
+ isPageApi?: boolean;
67
+ resolveParamsFn?: Function;
68
+ autoCancelStrategy?: 'none' | 'unmount' | 'deactivate' | 'both';
69
+ onQueryBefore?: (opts: {
70
+ params: Record<string, any>;
71
+ dictKeys: string[];
72
+ done: (continueRequest?: boolean) => void;
73
+ }) => void;
74
+ onQueryError?: (err: any) => void;
75
+ } & QueryApiPayload;
62
76
  export interface ExtConfig {
77
+ query?: Query;
63
78
  extraHeader?: {
64
79
  border?: boolean;
65
80
  class?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wyfex/ivue",
3
- "version": "0.22.1",
3
+ "version": "0.22.3",
4
4
  "description": "万有前端 X 体系下基于 Vite8 + Vue3 + Typescript6 + ElementPlus2 构建的以配置驱动视图组件库",
5
5
  "homepage": "https://wyfex.top/idocs/ivue",
6
6
  "type": "module",
@@ -4,7 +4,7 @@ import type { MergedExtConfig } from './types'
4
4
  * 默认扩展配置
5
5
  */
6
6
  export default {
7
- crudFetch: { queryImmediate: true, autoCancelQueryStrategy: 'unmount' },
7
+ query: { immediate: true, isPageApi: true, autoCancelStrategy: 'unmount' },
8
8
  mode: { type: 'PAGE' },
9
9
  actionBar: {
10
10
  margin: '20px 0',
@@ -76,21 +76,6 @@ export interface ActionBar {
76
76
  * extConfig接口
77
77
  */
78
78
  export interface ExtConfig {
79
- /** 增删改查请求配置项 */
80
- crudFetch?: {
81
- /** 查询api */
82
- queryApi?: Function
83
- /** 是否立即查询 */
84
- queryImmediate?: boolean
85
- /** 自动取消查询策略 配合signal实现接口取消请求 */
86
- autoCancelQueryStrategy?: 'none' | 'unmount' | 'deactivate' | 'both'
87
- /** 开始查询前钩子 用于注入字典数据等 */
88
- onQueryBefore?: (done: () => void) => void
89
- /** 查询错误钩子 */
90
- onQueryError?: (err: any) => void
91
- /** 删除api */
92
- deleteApi?: Function
93
- }
94
79
  /** 操作栏配置项 */
95
80
  actionBar?: ActionBar
96
81
  /** 弹窗配置项 */
@@ -128,8 +113,6 @@ export interface UseCrudState {
128
113
  pageSize: number
129
114
  /** 分页总数 */
130
115
  total: number
131
- /** 字典映射 */
132
- dictMap: Record<string, any>
133
116
  }
134
117
 
135
118
  /**
@@ -146,7 +129,7 @@ export interface UseCrudReturn {
146
129
  onCancelQueryRequest: () => void
147
130
  handleDelete: (
148
131
  payload: { id?: string | number; ids?: string | Array<string | number> },
149
- loadingConfig: { source?: Record<string, unknown>; key?: string },
132
+ config: { api: Function; source?: Record<string, unknown>; key?: string },
150
133
  successCb?: () => void,
151
134
  errorCb?: (err: unknown) => void,
152
135
  successMsg?: string
@@ -4,6 +4,12 @@ import type { ExtConfig } from './types'
4
4
  * 默认扩展配置
5
5
  */
6
6
  export default {
7
- dictProps: { value: 'value', label: 'label', children: 'children' },
7
+ dict: { props: { value: 'value', label: 'label', children: 'children' } },
8
+ queryApiPayload: {
9
+ pageField: 'page',
10
+ pageSizeField: 'pageSize',
11
+ records: 'records',
12
+ total: 'total'
13
+ },
8
14
  table: { pageBottomOffset: 20, modalBottomOffset: 92 }
9
15
  } satisfies ExtConfig
@@ -1,18 +1,36 @@
1
1
  import type { ExtractPropTypes } from 'vue'
2
2
  import componentProps from './props'
3
- import type { DictProps, UploadConfig } from '@/types'
3
+ import type { Dict, UploadConfig } from '@/types'
4
4
 
5
5
  /**
6
6
  * props类型
7
7
  */
8
8
  export type Props = ExtractPropTypes<typeof componentProps>
9
9
 
10
+ /**
11
+ * 查询接口载荷接口
12
+ */
13
+ export interface QueryApiPayload {
14
+ /** 分页字段 */
15
+ pageField?: string
16
+ /** 分页大小字段 */
17
+ pageSizeField?: string
18
+ /** 非分页接口响应数据载荷 */
19
+ default?: string
20
+ /** 分页接口响应数据载荷 */
21
+ records?: string
22
+ /** 分页接口响应总数载荷 */
23
+ total?: string
24
+ }
25
+
10
26
  /**
11
27
  * extConfig接口
12
28
  */
13
29
  export interface ExtConfig {
14
- /** 字典属性配置项 */
15
- dictProps?: DictProps
30
+ /** 字典配置项 */
31
+ dict?: Dict
32
+ /** 查询接口载荷配置项 */
33
+ queryApiPayload?: QueryApiPayload
16
34
  /** crud配置项 */
17
35
  crud?: {
18
36
  /** crud表格页面高度 extConfig.mode.type='PAGE'时生效,显式设置则表格自适应高度不生效,否则默认使用表格自适应高度 */
@@ -1,6 +1,6 @@
1
1
  import type { PropType } from 'vue'
2
2
  import type { ConfigColumn } from './types'
3
- import type { DictMap, DictProps } from '@/types'
3
+ import type { Dict } from '@/types'
4
4
  import type { RenderConfig } from '@/types'
5
5
 
6
6
  /**
@@ -22,25 +22,18 @@ export default {
22
22
  required: true
23
23
  },
24
24
  /**
25
- * 是否使用渲染器 默认否
26
- */
27
- useRender: {
28
- type: [Boolean, Object] as PropType<boolean | RenderConfig>,
29
- default: false
30
- },
31
- /**
32
- * 字典映射 数据结构为{ configs[][label | useDict | useDict.key]: Array<{ label: string, value: any }> }
25
+ * 字典 可配置api、payload和props等,默认由UseElConfigProvider提供
33
26
  */
34
- dictMap: {
35
- type: Object as PropType<DictMap>,
27
+ dict: {
28
+ type: Object as PropType<Dict>,
36
29
  default: () => ({})
37
30
  },
38
31
  /**
39
- * 字典属性 默认为{ value: 'value', label: 'label', children: 'children' },可通过全局配置进行设置,为适配全局配置此处不再设置默认值
32
+ * 是否使用渲染器 默认否
40
33
  */
41
- dictProps: {
42
- type: Object as PropType<DictProps>,
43
- default: () => ({})
34
+ useRender: {
35
+ type: [Boolean, Object] as PropType<boolean | RenderConfig>,
36
+ default: false
44
37
  },
45
38
  /**
46
39
  * 一行 Descriptions Item 的数量 默认2
@@ -1,6 +1,6 @@
1
1
  import type { PropType } from 'vue'
2
2
  import type { FormColumn, QueryConfig } from './types'
3
- import type { DictMap, DictProps, RenderConfig } from '@/types'
3
+ import type { Dict, RenderConfig } from '@/types'
4
4
 
5
5
  /**
6
6
  * 组件props
@@ -21,25 +21,18 @@ export default {
21
21
  required: true
22
22
  },
23
23
  /**
24
- * 是否使用渲染器 默认否
25
- */
26
- useRender: {
27
- type: [Boolean, Object] as PropType<boolean | RenderConfig>,
28
- default: false
29
- },
30
- /**
31
- * 字典映射 数据结构为{ formColumns[][label | useDict | useDict.key]: Array<{ label: string, value: any }> }
24
+ * 字典 可配置api、payload和props等,默认由UseElConfigProvider提供
32
25
  */
33
- dictMap: {
34
- type: Object as PropType<DictMap>,
26
+ dict: {
27
+ type: Object as PropType<Dict>,
35
28
  default: () => ({})
36
29
  },
37
30
  /**
38
- * 字典属性 默认为{ value: 'value', label: 'label', children: 'children' },可通过全局配置进行设置,为适配全局配置此处不再设置默认值
31
+ * 是否使用渲染器 默认否
39
32
  */
40
- dictProps: {
41
- type: Object as PropType<DictProps>,
42
- default: () => ({})
33
+ useRender: {
34
+ type: [Boolean, Object] as PropType<boolean | RenderConfig>,
35
+ default: false
43
36
  },
44
37
  /**
45
38
  * el-form-item宽度值
@@ -1,5 +1,5 @@
1
1
  import type { PropType } from 'vue'
2
- import type { DictProps, RenderConfig } from '@/types'
2
+ import type { Dict, RenderConfig } from '@/types'
3
3
 
4
4
  /**
5
5
  * 组件props
@@ -20,10 +20,11 @@ export default {
20
20
  default: () => []
21
21
  },
22
22
  /**
23
- * 字典属性 默认为{ value: 'value', label: 'label', children: 'children' },可通过全局配置进行设置,为适配全局配置此处不再设置默认值
23
+ * 字典 可配置api、payload和props等,默认由UseElConfigProvider提供
24
+ * todo:当前阶段本组件未对api和payload进行内部实现,后续实际业务需要再进行实现,暂时预留该配置
24
25
  */
25
- dictProps: {
26
- type: Object as PropType<DictProps>,
26
+ dict: {
27
+ type: Object as PropType<Dict>,
27
28
  default: () => ({})
28
29
  },
29
30
  /**
@@ -4,6 +4,7 @@ import type { ExtConfig } from './types'
4
4
  * 默认扩展配置
5
5
  */
6
6
  export default {
7
+ query: { immediate: true, isPageApi: true, autoCancelStrategy: 'unmount' },
7
8
  extraHeader: {
8
9
  style: {
9
10
  padding: '10px',
@@ -1,6 +1,6 @@
1
1
  import type { PropType } from 'vue'
2
2
  import type { ExtConfig, TableColumn } from './types'
3
- import type { DictMap, DictProps } from '@/types'
3
+ import type { Dict } from '@/types'
4
4
 
5
5
  /**
6
6
  * 组件props
@@ -38,17 +38,10 @@ export default {
38
38
  validator: (val: string) => ['left', 'center', 'right'].includes(val)
39
39
  },
40
40
  /**
41
- * 字典映射 数据结构为{ tableColumns[][label | useDict | useDict.key]: Array<{ label: string, value: any }> }
41
+ * 字典 可配置api、payload和props等,默认由UseElConfigProvider提供
42
42
  */
43
- dictMap: {
44
- type: Object as PropType<DictMap>,
45
- default: () => ({})
46
- },
47
- /**
48
- * 字典属性 默认为{ value: 'value', label: 'label',children:'children' },可通过全局配置进行设置,为适配全局配置此处不再设置默认值
49
- */
50
- dictProps: {
51
- type: Object as PropType<DictProps>,
43
+ dict: {
44
+ type: Object as PropType<Dict>,
52
45
  default: () => ({})
53
46
  },
54
47
  /**
@@ -1,6 +1,7 @@
1
1
  import type { Component, ExtractPropTypes } from 'vue'
2
2
  import type { EditAttrs, GlobalConfig, UseDict } from '@/types'
3
3
  import componentProps from './props'
4
+ import type { QueryApiPayload } from '../UseElConfigProvider/types'
4
5
 
5
6
  /**
6
7
  * props类型
@@ -134,10 +135,36 @@ export interface Selection {
134
135
  fixed?: boolean
135
136
  }
136
137
 
138
+ /**
139
+ * 查询类型
140
+ */
141
+ export type Query = {
142
+ /** 查询接口 */
143
+ api?: Function
144
+ /** 是否立即查询 */
145
+ immediate?: boolean
146
+ /** 是否是分页接口 */
147
+ isPageApi?: boolean
148
+ /** 处理查询参数的方法 */
149
+ resolveParamsFn?: Function
150
+ /** 自动取消查询策略 配合signal实现接口取消请求 */
151
+ autoCancelStrategy?: 'none' | 'unmount' | 'deactivate' | 'both'
152
+ /** 开始查询前钩子 用于注入字典数据等 */
153
+ onQueryBefore?: (opts: {
154
+ params: Record<string, any>
155
+ dictKeys: string[]
156
+ done: (continueRequest?: boolean) => void
157
+ }) => void
158
+ /** 查询错误钩子 */
159
+ onQueryError?: (err: any) => void
160
+ } & QueryApiPayload
161
+
137
162
  /**
138
163
  * UseElTable的extConfig接口
139
164
  */
140
165
  export interface ExtConfig {
166
+ /** 查询配置项 */
167
+ query?: Query
141
168
  /** 额外表头配置项 */
142
169
  extraHeader?: {
143
170
  /** 是否显示边框线 默认和el-table的border保持一致 */
@@ -68,6 +68,22 @@ export interface UseDict {
68
68
  /** 字典分割符 默认为逗号(,) */
69
69
  separator?: string
70
70
  }
71
+
72
+ /**
73
+ * 字典接口
74
+ */
75
+ export interface Dict {
76
+ /** 字典接口 */
77
+ api?: Function
78
+ /** 字典接口参数 */
79
+ apiParam?: string
80
+ /** 字典接口响应数据载荷 */
81
+ apiPayload?: string
82
+ /** 字典属性 */
83
+ props?: DictProps
84
+ /** 字典映射 数据结构为:{ formColumns[][label | useDict | useDict.key]: Array<{ label: string, value: any }> } */
85
+ map?: DictMap
86
+ }
71
87
  // =========================== 字典相关接口 end ===========================
72
88
 
73
89
  // =========================== 其他接口 start ===========================
@@ -91,10 +107,28 @@ export interface UploadConfig {
91
107
  export interface GlobalConfig {
92
108
  /** 最终语言 */
93
109
  finalLanguage: string
110
+
111
+ /** 最终字典api */
112
+ finalDictApi: Function
113
+ /** 最终字典接口响应数据载荷 */
114
+ finalDictApiPayload: string
94
115
  /** 最终字典属性 */
95
116
  finalDictProps: DictProps
96
117
  /** 最终字典映射 */
97
118
  finalDictMap: DictMap
119
+
120
+ /** 最终查询接口分页字段 */
121
+ finalQueryApiPageField: string
122
+ /** 最终查询接口分页大小字段 */
123
+ finalQueryApiPageSizeField: string
124
+
125
+ /** 最终查询接口非分页数据载荷 */
126
+ finalQueryApiDefaultPayload: string
127
+ /** 最终查询接口分页数据载荷 */
128
+ finalQueryApiRecordsPayload: string
129
+ /** 最终查询接口分页总数载荷 */
130
+ finalQueryApiTotalPayload: string
131
+
98
132
  /** 最终crud表格页面高度 */
99
133
  finalCrudTablePageHeight: string
100
134
  /** 最终crud表格弹窗高度 */
@@ -103,10 +137,12 @@ export interface GlobalConfig {
103
137
  finalTablePageHeight: string
104
138
  /** 最终表格弹窗高度 */
105
139
  finalTableModalHeight: string
140
+
106
141
  /** 最终表格页面底部预留偏移 */
107
142
  finalTablePageBottomOffset: number
108
143
  /** 最终表格弹窗底部预留偏移 tableMode=modal生效 */
109
144
  finalTableModalBottomOffset: number
145
+
110
146
  /** 最终上传配置 */
111
147
  finalUploadConfig: UploadConfig
112
148
  }