zy-react-library 1.0.169 → 1.0.171
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/components/FormBuilder/FormItemsRenderer.d.ts +4 -11
- package/components/FormBuilder/FormItemsRenderer.js +6 -2
- package/components/ImportFile/index.d.ts +5 -1
- package/components/ImportFile/index.js +4 -1
- package/components/Select/Personnel/Gwj/index.d.ts +12 -2
- package/components/Select/Personnel/Gwj/index.js +6 -3
- package/components/Table/index.less +4 -0
- package/enum/formItemRender/index.d.ts +65 -37
- package/package.json +1 -1
|
@@ -4,14 +4,7 @@ import type { FormListFieldData } from "antd/es/form/FormList";
|
|
|
4
4
|
import type { Gutter } from "antd/es/grid/row";
|
|
5
5
|
import type { NamePath } from "rc-field-form/lib/interface";
|
|
6
6
|
import type { FC, ReactNode } from "react";
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 表单项渲染类型
|
|
11
|
-
*/
|
|
12
|
-
export type FormItemRenderType
|
|
13
|
-
= | (typeof FORM_ITEM_RENDER_ENUM)[keyof typeof FORM_ITEM_RENDER_ENUM]
|
|
14
|
-
| ReactNode;
|
|
7
|
+
import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender";
|
|
15
8
|
|
|
16
9
|
/**
|
|
17
10
|
* 选项项数据类型
|
|
@@ -62,7 +55,7 @@ export interface FormListUniqueProps {
|
|
|
62
55
|
/**
|
|
63
56
|
* 表单配置项
|
|
64
57
|
*/
|
|
65
|
-
export interface FormOption {
|
|
58
|
+
export interface FormOption<T extends keyof FORM_ITEM_RENDER_TYPE_MAP = keyof FORM_ITEM_RENDER_TYPE_MAP> {
|
|
66
59
|
/** React 需要的 key,如果传递了唯一的 name,则不需要 */
|
|
67
60
|
key?: string;
|
|
68
61
|
/** 表单项字段名 */
|
|
@@ -70,7 +63,7 @@ export interface FormOption {
|
|
|
70
63
|
/** 表单项标签 */
|
|
71
64
|
label?: ReactNode;
|
|
72
65
|
/** 渲染类型 */
|
|
73
|
-
render?:
|
|
66
|
+
render?: T | ReactNode;
|
|
74
67
|
/** 占据栅格列数,默认 12 */
|
|
75
68
|
span?: number | string;
|
|
76
69
|
/** 是否必填,默认 true,支持函数动态计算 */
|
|
@@ -92,7 +85,7 @@ export interface FormOption {
|
|
|
92
85
|
/** 字段键配置 */
|
|
93
86
|
itemsField?: itemsFieldConfig;
|
|
94
87
|
/** 传递给表单控件的属性,支持函数动态计算 */
|
|
95
|
-
componentProps?:
|
|
88
|
+
componentProps?: FORM_ITEM_RENDER_TYPE_MAP[T] | ((formValues: FormValues) => FORM_ITEM_RENDER_TYPE_MAP[T]);
|
|
96
89
|
/** 传递给 Form.Item 的属性,支持函数动态计算 */
|
|
97
90
|
formItemProps?: FormItemProps | ((formValues: FormValues) => FormItemProps);
|
|
98
91
|
/** label 栅格配置,默认直接使用外层的 labelCol,如果 span 等于 24,是外层的 labelCol.span 一半 */
|
|
@@ -408,6 +408,8 @@ const FormItemsRenderer = ({
|
|
|
408
408
|
|
|
409
409
|
// 渲染特殊类型的表单项
|
|
410
410
|
const renderOtherTypeItem = ({ option, style, col, index }) => {
|
|
411
|
+
const componentProps = getComponentProps(option);
|
|
412
|
+
|
|
411
413
|
// 如果是 customizeRender 类型,完全交给外部控制渲染
|
|
412
414
|
if (option.customizeRender) {
|
|
413
415
|
return (
|
|
@@ -435,7 +437,7 @@ const FormItemsRenderer = ({
|
|
|
435
437
|
if (option.render === FORM_ITEM_RENDER_ENUM.DIVIDER) {
|
|
436
438
|
return (
|
|
437
439
|
<Col key={getKey(option) || index} span={col.span} style={style}>
|
|
438
|
-
<Divider orientation="left">{option.label}</Divider>
|
|
440
|
+
<Divider orientation="left" {...componentProps}>{option.label}</Divider>
|
|
439
441
|
</Col>
|
|
440
442
|
);
|
|
441
443
|
}
|
|
@@ -446,9 +448,11 @@ const FormItemsRenderer = ({
|
|
|
446
448
|
// 渲染 Form.List
|
|
447
449
|
const renderFormList = (option, index, col, style) => {
|
|
448
450
|
const formListUniqueProps = getFormListUniqueProps(option);
|
|
451
|
+
const componentProps = getComponentProps(option);
|
|
452
|
+
|
|
449
453
|
return (
|
|
450
454
|
<Col key={getKey(option) || index} span={col.span} style={style}>
|
|
451
|
-
<Form.List name={option.name}>
|
|
455
|
+
<Form.List name={option.name} {...componentProps}>
|
|
452
456
|
{(fields, { add, remove }) => (
|
|
453
457
|
<>
|
|
454
458
|
{fields.map((field, fieldIndex) => {
|
|
@@ -12,13 +12,17 @@ export interface ImportFileProps extends Omit<FormProps, "form"> {
|
|
|
12
12
|
/** 弹窗标题 */
|
|
13
13
|
title?: string;
|
|
14
14
|
/** 模板文件地址 */
|
|
15
|
-
templateUrl
|
|
15
|
+
templateUrl?: string;
|
|
16
16
|
/** 子组件 */
|
|
17
17
|
children?: ReactNode | ((props: { form: FormInstance }) => ReactNode);
|
|
18
18
|
/** 确认回调 */
|
|
19
19
|
onConfirm: (values: FormValues) => void;
|
|
20
20
|
/** 取消回调 */
|
|
21
21
|
onCancel: () => void;
|
|
22
|
+
/** 导出模板按钮文字,默认 “导出模板” */
|
|
23
|
+
exportTemplateButtonText?: ReactNode;
|
|
24
|
+
/** 额外按钮 */
|
|
25
|
+
extraButtons?: ReactNode;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
/**
|
|
@@ -14,6 +14,8 @@ const ImportFile = (props) => {
|
|
|
14
14
|
templateUrl,
|
|
15
15
|
labelCol = { span: 4 },
|
|
16
16
|
children,
|
|
17
|
+
exportTemplateButtonText = "导出模板",
|
|
18
|
+
extraButtons,
|
|
17
19
|
...restProps
|
|
18
20
|
} = props;
|
|
19
21
|
|
|
@@ -55,9 +57,10 @@ const ImportFile = (props) => {
|
|
|
55
57
|
footer={[
|
|
56
58
|
templateUrl && (
|
|
57
59
|
<Button key="export" onClick={handleExportTemplate}>
|
|
58
|
-
|
|
60
|
+
{exportTemplateButtonText}
|
|
59
61
|
</Button>
|
|
60
62
|
),
|
|
63
|
+
{extraButtons},
|
|
61
64
|
<Button key="cancel" onClick={handleClose}>
|
|
62
65
|
取消
|
|
63
66
|
</Button>,
|
|
@@ -13,6 +13,16 @@ export interface Params {
|
|
|
13
13
|
departmentId?: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* 额外请求参数
|
|
18
|
+
*/
|
|
19
|
+
export interface ExtraParams {
|
|
20
|
+
/** 返回值是否存在主账号 */
|
|
21
|
+
noMain: 1 | "";
|
|
22
|
+
/** 入职状态 */
|
|
23
|
+
eqEmploymentFlag: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
27
|
* 组件属性
|
|
18
28
|
*/
|
|
@@ -27,8 +37,8 @@ export interface PersonnelSelectProps extends Omit<BasicSelectProps, "data" | "p
|
|
|
27
37
|
isNeedPostId?: boolean;
|
|
28
38
|
/** 是否需要部门id,默认 true */
|
|
29
39
|
isNeedDepartmentId?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
|
|
40
|
+
/** 额外请求参数 */
|
|
41
|
+
extraParams?: ExtraParams;
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
/**
|
|
@@ -12,7 +12,10 @@ function PersonnelSelect(props) {
|
|
|
12
12
|
isNeedCorpInfoId = false,
|
|
13
13
|
isNeedDepartmentId = true,
|
|
14
14
|
isNeedPostId = false,
|
|
15
|
-
|
|
15
|
+
extraParams= {
|
|
16
|
+
noMain: "",
|
|
17
|
+
eqEmploymentFlag: 1,
|
|
18
|
+
},
|
|
16
19
|
...restProps
|
|
17
20
|
} = props;
|
|
18
21
|
|
|
@@ -28,13 +31,13 @@ function PersonnelSelect(props) {
|
|
|
28
31
|
if (isNeedPostId && !params.postId)
|
|
29
32
|
return;
|
|
30
33
|
|
|
31
|
-
const { data } = await request("/basicInfo/user/listAll", "get", { ...params,
|
|
34
|
+
const { data } = await request("/basicInfo/user/listAll", "get", { ...params, ...extraParams });
|
|
32
35
|
setData(data);
|
|
33
36
|
};
|
|
34
37
|
|
|
35
38
|
useEffect(() => {
|
|
36
39
|
getData();
|
|
37
|
-
}, [JSON.stringify(params), isNeedCorpInfoId, isNeedDepartmentId, isNeedPostId,
|
|
40
|
+
}, [JSON.stringify(params), isNeedCorpInfoId, isNeedDepartmentId, isNeedPostId, JSON.stringify(extraParams)]);
|
|
38
41
|
|
|
39
42
|
return (
|
|
40
43
|
<BasicSelect data={data} placeholder={placeholder} {...restProps} />
|
|
@@ -1,37 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import type { CheckboxProps } from "antd/es/checkbox";
|
|
2
|
+
import type { DatePickerProps } from "antd/es/date-picker";
|
|
3
|
+
import type { DividerProps } from "antd/es/divider";
|
|
4
|
+
import type { FormListProps } from "antd/es/form";
|
|
5
|
+
import type { InputProps, TextAreaProps } from "antd/es/input";
|
|
6
|
+
import type { InputNumberProps } from "antd/es/input-number";
|
|
7
|
+
import type { RadioProps } from "antd/es/radio";
|
|
8
|
+
import type { SelectProps } from "antd/es/select";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 表单项类型枚举
|
|
12
|
+
*/
|
|
13
|
+
export declare const FORM_ITEM_RENDER_ENUM: {
|
|
14
|
+
/** 映射为 antd Input */
|
|
15
|
+
INPUT: "input";
|
|
16
|
+
/** 映射为 antd Input.TextArea */
|
|
17
|
+
TEXTAREA: "textarea";
|
|
18
|
+
/** 映射为 antd InputNumber */
|
|
19
|
+
INPUT_NUMBER: "inputNumber";
|
|
20
|
+
/** 映射为 antd InputNumber */
|
|
21
|
+
NUMBER: "number";
|
|
22
|
+
/** 映射为 antd Select */
|
|
23
|
+
SELECT: "select";
|
|
24
|
+
/** 映射为 antd Radio.Group */
|
|
25
|
+
RADIO: "radio";
|
|
26
|
+
/** 映射为 antd Checkbox.Group */
|
|
27
|
+
CHECKBOX: "checkbox";
|
|
28
|
+
/** 映射为 antd DatePicker,日期格式为YYYY-MM-DD */
|
|
29
|
+
DATE: "date";
|
|
30
|
+
/** 映射为 antd DatePicker.MonthPicker,日期格式为YYYY-MM */
|
|
31
|
+
DATE_MONTH: "dateMonth";
|
|
32
|
+
/** 映射为 antd DatePicker.YearPicker,日期格式为YYYY */
|
|
33
|
+
DATE_YEAR: "dateYear";
|
|
34
|
+
/** 映射为 antd DatePicker.WeekPicker,日期格式为YYYY-wo */
|
|
35
|
+
DATE_WEEK: "dateWeek";
|
|
36
|
+
/** 映射为 antd DatePicker.RangePicker,日期格式为YYYY-MM-DD */
|
|
37
|
+
DATE_RANGE: "dateRange";
|
|
38
|
+
/** 映射为 antd DatePicker,日期格式为YYYY-MM-DD HH:mm:ss */
|
|
39
|
+
DATETIME: "datetime";
|
|
40
|
+
/** 映射为 antd DatePicker.RangePicker,日期格式为YYYY-MM-DD HH:mm:ss */
|
|
41
|
+
DATETIME_RANGE: "datetimeRange";
|
|
42
|
+
/** 映射为 antd Divider */
|
|
43
|
+
DIVIDER: "divider";
|
|
44
|
+
/** 映射为 antd FormList */
|
|
45
|
+
FORM_LIST: "formList";
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export interface FORM_ITEM_RENDER_TYPE_MAP {
|
|
49
|
+
input: InputProps;
|
|
50
|
+
textarea: TextAreaProps;
|
|
51
|
+
inputNumber: InputNumberProps;
|
|
52
|
+
number: InputNumberProps;
|
|
53
|
+
select: SelectProps;
|
|
54
|
+
radio: RadioProps;
|
|
55
|
+
checkbox: CheckboxProps;
|
|
56
|
+
date: DatePickerProps;
|
|
57
|
+
dateMonth: DatePickerProps;
|
|
58
|
+
dateYear: DatePickerProps;
|
|
59
|
+
dateWeek: DatePickerProps;
|
|
60
|
+
dateRange: DatePickerProps;
|
|
61
|
+
datetime: DatePickerProps;
|
|
62
|
+
datetimeRange: DatePickerProps;
|
|
63
|
+
divider: DividerProps;
|
|
64
|
+
formList: FormListProps;
|
|
65
|
+
}
|