Commit a0c3197454b59a231cf6d27048b2e9c0bd7bf77f

Authored by vben
1 parent 3713487c

perf: update form types

CHANGELOG.zh_CN.md
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 ### ✨ Features 3 ### ✨ Features
4 4
  5 +- 更新组件文档
5 - 面包屑支持显示图标 6 - 面包屑支持显示图标
6 - 新增 tinymce 富文本组件 7 - 新增 tinymce 富文本组件
7 - 表单新增 submitOnReset 控制是否在重置时重新发起请求 8 - 表单新增 submitOnReset 控制是否在重置时重新发起请求
@@ -19,7 +20,6 @@ @@ -19,7 +20,6 @@
19 - 关闭多标签页 tabs 动画 20 - 关闭多标签页 tabs 动画
20 - 升级 vite 版本为`v1.0.0.rc6` 21 - 升级 vite 版本为`v1.0.0.rc6`
21 - 删除中文路径警告。rc6 已修复 22 - 删除中文路径警告。rc6 已修复
22 -- 更新部分组件文档  
23 23
24 ### 🐛 Bug Fixes 24 ### 🐛 Bug Fixes
25 25
README.en-US.md
@@ -228,11 +228,11 @@ yarn clean:lib # Delete node_modules, supported window @@ -228,11 +228,11 @@ yarn clean:lib # Delete node_modules, supported window
228 - [x] System performance optimization 228 - [x] System performance optimization
229 - [x] Data import and export 229 - [x] Data import and export
230 - [x] Global error handling 230 - [x] Global error handling
  231 +- [x] Rich text component
231 232
232 ## Developing features 233 ## Developing features
233 234
234 - [ ] Upload component 235 - [ ] Upload component
235 -- [ ] Rich text component  
236 - [ ] Theme configuration 236 - [ ] Theme configuration
237 - [ ] Dark theme 237 - [ ] Dark theme
238 - [ ] Build CDN 238 - [ ] Build CDN
README.md
@@ -226,11 +226,11 @@ yarn clean:lib # 删除node_modules,兼容window系统 @@ -226,11 +226,11 @@ yarn clean:lib # 删除node_modules,兼容window系统
226 - [x] 数据导入导出 226 - [x] 数据导入导出
227 - [x] 系统性能优化 227 - [x] 系统性能优化
228 - [x] 全局错误处理 228 - [x] 全局错误处理
  229 +- [x] 富文本组件
229 230
230 ## 正在开发的功能 231 ## 正在开发的功能
231 232
232 - [ ] 上传组件 233 - [ ] 上传组件
233 -- [ ] 富文本组件  
234 - [ ] 主题配置 234 - [ ] 主题配置
235 - [ ] 黑暗主题 235 - [ ] 黑暗主题
236 - [ ] 打包 CDN 236 - [ ] 打包 CDN
src/components/Button/types.ts 0 → 100644
  1 +import { VNodeChild } from 'vue';
  2 +
  3 +export interface BasicButtonProps {
  4 + /**
  5 + * can be set to primary ghost dashed danger(added in 2.7) or omitted (meaning default)
  6 + * @default 'default'
  7 + * @type string
  8 + */
  9 + type?: 'primary' | 'danger' | 'dashed' | 'ghost' | 'default';
  10 +
  11 + /**
  12 + * set the original html type of button
  13 + * @default 'button'
  14 + * @type string
  15 + */
  16 + htmlType?: 'button' | 'submit' | 'reset' | 'menu';
  17 +
  18 + /**
  19 + * set the icon of button
  20 + * @type string
  21 + */
  22 + icon?: VNodeChild | JSX.Element;
  23 +
  24 + /**
  25 + * can be set to circle or circle-outline or omitted
  26 + * @type string
  27 + */
  28 + shape?: 'circle' | 'circle-outline';
  29 +
  30 + /**
  31 + * can be set to small large or omitted
  32 + * @default 'default'
  33 + * @type string
  34 + */
  35 + size?: 'small' | 'large' | 'default';
  36 +
  37 + /**
  38 + * set the loading status of button
  39 + * @default false
  40 + * @type boolean | { delay: number }
  41 + */
  42 + loading?: boolean | { delay: number };
  43 +
  44 + /**
  45 + * disabled state of button
  46 + * @default false
  47 + * @type boolean
  48 + */
  49 + disabled?: boolean;
  50 +
  51 + /**
  52 + * make background transparent and invert text and border colors, added in 2.7
  53 + * @default false
  54 + * @type boolean
  55 + */
  56 + ghost?: boolean;
  57 +
  58 + /**
  59 + * option to fit button width to its parent width
  60 + * @default false
  61 + * @type boolean
  62 + */
  63 + block?: boolean;
  64 +
  65 + onClick?: (e?: Event) => void;
  66 +}
src/components/Form/src/types/form.ts
1 -import type { Form, ValidationRule } from 'ant-design-vue/types/form/form'; 1 +import type { Form, NamePath, ValidationRule } from 'ant-design-vue/types/form/form';
2 import type { VNode } from 'vue'; 2 import type { VNode } from 'vue';
3 import type { BasicButtonProps } from '/@/components/Button/types'; 3 import type { BasicButtonProps } from '/@/components/Button/types';
4 import type { FormItem } from './formItem'; 4 import type { FormItem } from './formItem';
@@ -12,16 +12,23 @@ export interface RenderCallbackParams { @@ -12,16 +12,23 @@ export interface RenderCallbackParams {
12 model: any; 12 model: any;
13 field: string; 13 field: string;
14 } 14 }
  15 +
  16 +export interface ButtonProps extends BasicButtonProps {
  17 + text?: string;
  18 +}
  19 +
15 export interface FormActionType extends Form { 20 export interface FormActionType extends Form {
16 - submit(): Promise<void>;  
17 - setFieldsValue<T>(values: T): void;  
18 - resetFields(): Promise<any>; 21 + submit: () => Promise<void>;
  22 + setFieldsValue: <T>(values: T) => void;
  23 + resetFields: () => Promise<any>;
19 getFieldsValue: () => any; 24 getFieldsValue: () => any;
20 clearValidate: (name?: string | string[]) => void; 25 clearValidate: (name?: string | string[]) => void;
21 - updateSchema(data: Partial<FormSchema> | Partial<FormSchema>[]): void;  
22 - setProps(formProps: Partial<FormProps>): void;  
23 - removeSchemaByFiled(field: string | string[]): void;  
24 - appendSchemaByField(schema: FormSchema, prefixField?: string): void; 26 + updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => void;
  27 + setProps: (formProps: Partial<FormProps>) => void;
  28 + removeSchemaByFiled: (field: string | string[]) => void;
  29 + appendSchemaByField: (schema: FormSchema, prefixField?: string) => void;
  30 + validateFields: (nameList?: NamePath[]) => Promise<any>;
  31 + validate: (nameList?: NamePath[]) => Promise<any>;
25 } 32 }
26 export type RegisterFn = (formInstance: FormActionType) => void; 33 export type RegisterFn = (formInstance: FormActionType) => void;
27 34
@@ -38,7 +45,7 @@ export interface FormProps { @@ -38,7 +45,7 @@ export interface FormProps {
38 wrapperCol?: Partial<ColEx>; 45 wrapperCol?: Partial<ColEx>;
39 46
40 // 通用col配置 47 // 通用col配置
41 - baseColProps?: any; 48 + baseColProps?: Partial<ColEx>;
42 49
43 // 表单配置规则 50 // 表单配置规则
44 schemas?: FormSchema[]; 51 schemas?: FormSchema[];
@@ -55,7 +62,7 @@ export interface FormProps { @@ -55,7 +62,7 @@ export interface FormProps {
55 // 时间区间字段映射成多个 62 // 时间区间字段映射成多个
56 fieldMapToTime?: FieldMapToTime; 63 fieldMapToTime?: FieldMapToTime;
57 // 自动设置placeholder 64 // 自动设置placeholder
58 - autoSetPlaceHolder: boolean; 65 + autoSetPlaceHolder?: boolean;
59 // 校验信息是否加入label 66 // 校验信息是否加入label
60 rulesMessageJoinLabel?: boolean; 67 rulesMessageJoinLabel?: boolean;
61 // 是否显示收起展开按钮 68 // 是否显示收起展开按钮
@@ -66,10 +73,10 @@ export interface FormProps { @@ -66,10 +73,10 @@ export interface FormProps {
66 showActionButtonGroup?: boolean; 73 showActionButtonGroup?: boolean;
67 74
68 // 重置按钮配置 75 // 重置按钮配置
69 - resetButtonOptions?: Partial<BasicButtonProps>; 76 + resetButtonOptions?: Partial<ButtonProps>;
70 77
71 // 确认按钮配置 78 // 确认按钮配置
72 - submitButtonOptions?: Partial<BasicButtonProps>; 79 + submitButtonOptions?: Partial<ButtonProps>;
73 80
74 // 操作列配置 81 // 操作列配置
75 actionColOptions?: Partial<ColEx>; 82 actionColOptions?: Partial<ColEx>;
@@ -129,7 +136,7 @@ export interface FormSchema { @@ -129,7 +136,7 @@ export interface FormSchema {
129 render?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string; 136 render?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string;
130 137
131 // 渲染 col内容,需要外层包裹 form-item 138 // 渲染 col内容,需要外层包裹 form-item
132 - renderColContent?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[]; 139 + renderColContent?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string;
133 140
134 renderComponentContent?: (renderCallbackParams: RenderCallbackParams) => any; 141 renderComponentContent?: (renderCallbackParams: RenderCallbackParams) => any;
135 142
src/components/Table/src/const.ts
@@ -2,21 +2,32 @@ import { SorterResult } from &#39;ant-design-vue/types/table/table&#39;; @@ -2,21 +2,32 @@ import { SorterResult } from &#39;ant-design-vue/types/table/table&#39;;
2 2
3 export const ROW_KEY = 'key'; 3 export const ROW_KEY = 'key';
4 4
  5 +// 可选的每页显示条数;
5 export const PAGE_SIZE_OPTIONS = ['10', '50', '80', '100']; 6 export const PAGE_SIZE_OPTIONS = ['10', '50', '80', '100'];
6 7
  8 +// 每页显示条数
7 export const PAGE_SIZE = ~~PAGE_SIZE_OPTIONS[0]; 9 export const PAGE_SIZE = ~~PAGE_SIZE_OPTIONS[0];
8 10
  11 +// 通用接口字段设置
  12 +// 支持 xxx.xxx.xxx格式
9 export const FETCH_SETTING = { 13 export const FETCH_SETTING = {
  14 + // 传给后台的当前页字段名
10 pageField: 'page', 15 pageField: 'page',
  16 + // 传给后台的每页显示记录数字段名
11 sizeField: 'pageSize', 17 sizeField: 'pageSize',
  18 + // 接口返回的表格数据字段名
12 listField: 'items', 19 listField: 'items',
  20 + // 接口返回的表格总数字段名
13 totalField: 'total', 21 totalField: 'total',
14 }; 22 };
15 23
  24 +// 配置通用排序函数
16 export function DEFAULT_SORT_FN(sortInfo: SorterResult<any>) { 25 export function DEFAULT_SORT_FN(sortInfo: SorterResult<any>) {
17 const { field, order } = sortInfo; 26 const { field, order } = sortInfo;
18 return { 27 return {
  28 + // 传给后台的排序字段你
19 field, 29 field,
  30 + // 传给后台的排序方式 asc/desc
20 order, 31 order,
21 }; 32 };
22 } 33 }
src/views/demo/comp/transition/index.vue
@@ -59,7 +59,6 @@ @@ -59,7 +59,6 @@
59 Select, 59 Select,
60 FadeTransition, 60 FadeTransition,
61 ScaleTransition, 61 ScaleTransition,
62 -  
63 SlideYTransition, 62 SlideYTransition,
64 ScrollYTransition, 63 ScrollYTransition,
65 SlideYReverseTransition, 64 SlideYReverseTransition,
src/views/demo/form/CustomerForm.vue
1 <template> 1 <template>
2 <div class="m-4"> 2 <div class="m-4">
3 - <div class="mb-4"> </div>  
4 <CollapseContainer title="自定义表单"> 3 <CollapseContainer title="自定义表单">
5 <BasicForm @register="register" @submit="handleSubmit" /> 4 <BasicForm @register="register" @submit="handleSubmit" />
6 </CollapseContainer> 5 </CollapseContainer>
src/views/demo/form/DynamicForm.vue
@@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
6 <a-button @click="appendField" class="mr-2">往字段3后面插入字段10</a-button> 6 <a-button @click="appendField" class="mr-2">往字段3后面插入字段10</a-button>
7 <a-button @click="deleteField" class="mr-2">删除字段11</a-button> 7 <a-button @click="deleteField" class="mr-2">删除字段11</a-button>
8 </div> 8 </div>
9 - <div class="mb-4"> </div>  
10 <CollapseContainer title="动态表单示例,动态根据表单内其他值改变"> 9 <CollapseContainer title="动态表单示例,动态根据表单内其他值改变">
11 <BasicForm @register="register" /> 10 <BasicForm @register="register" />
12 </CollapseContainer> 11 </CollapseContainer>
src/views/demo/form/RefForm.vue
@@ -53,7 +53,6 @@ @@ -53,7 +53,6 @@
53 修改查询按钮 53 修改查询按钮
54 </a-button> 54 </a-button>
55 </div> 55 </div>
56 - <div class="mb-4"> </div>  
57 <CollapseContainer title="使用ref调用表单内部函数示例"> 56 <CollapseContainer title="使用ref调用表单内部函数示例">
58 <BasicForm 57 <BasicForm
59 :schemas="schemas" 58 :schemas="schemas"
src/views/demo/form/RuleForm.vue
@@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
6 <a-button @click="getFormValues" class="mr-2">获取表单值</a-button> 6 <a-button @click="getFormValues" class="mr-2">获取表单值</a-button>
7 <a-button @click="setFormValues" class="mr-2">设置表单值</a-button> 7 <a-button @click="setFormValues" class="mr-2">设置表单值</a-button>
8 </div> 8 </div>
9 - <div class="mb-4"> </div>  
10 <CollapseContainer title="表单校验"> 9 <CollapseContainer title="表单校验">
11 <BasicForm @register="register" @submit="handleSubmit" /> 10 <BasicForm @register="register" @submit="handleSubmit" />
12 </CollapseContainer> 11 </CollapseContainer>
src/views/demo/form/UseForm.vue
@@ -53,7 +53,6 @@ @@ -53,7 +53,6 @@
53 修改查询按钮 53 修改查询按钮
54 </a-button> 54 </a-button>
55 </div> 55 </div>
56 - <div class="mb-4"> </div>  
57 <CollapseContainer title="useForm示例"> 56 <CollapseContainer title="useForm示例">
58 <BasicForm @register="register" @submit="handleSubmit" /> 57 <BasicForm @register="register" @submit="handleSubmit" />
59 </CollapseContainer> 58 </CollapseContainer>