zy-react-library 1.0.13 → 1.0.15
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/FormBuilder.js +1 -0
- package/components/FormBuilder/FormItemsRenderer.d.ts +2 -0
- package/components/FormBuilder/FormItemsRenderer.js +22 -6
- package/components/HeaderBack/index.d.ts +3 -1
- package/components/HeaderBack/index.js +2 -2
- package/components/HeaderBack/index.less +1 -0
- package/components/Search/index.js +1 -0
- package/components/Table/index.js +2 -1
- package/components/Table/index.less +3 -0
- package/package.json +1 -1
|
@@ -26,20 +26,31 @@ const FormItemsRenderer = ({
|
|
|
26
26
|
span = 12,
|
|
27
27
|
collapse = false,
|
|
28
28
|
useAutoGenerateRequired = true,
|
|
29
|
+
initialValues,
|
|
29
30
|
}) => {
|
|
30
31
|
const form = Form.useFormInstance();
|
|
31
32
|
|
|
33
|
+
// 获取表单值,优先使用 initialValues
|
|
34
|
+
const getFormValues = () => {
|
|
35
|
+
const formValues = form.getFieldsValue();
|
|
36
|
+
// 如果表单值为空但有 initialValues,则使用 initialValues
|
|
37
|
+
if (Object.keys(formValues).length === 0 && initialValues) {
|
|
38
|
+
return initialValues;
|
|
39
|
+
}
|
|
40
|
+
return formValues;
|
|
41
|
+
};
|
|
42
|
+
|
|
32
43
|
// 获取传给组件的属性
|
|
33
44
|
const getComponentProps = (option) => {
|
|
34
45
|
return typeof option.componentProps === "function"
|
|
35
|
-
? option.componentProps(
|
|
46
|
+
? option.componentProps(getFormValues())
|
|
36
47
|
: (option.componentProps || {});
|
|
37
48
|
};
|
|
38
49
|
|
|
39
50
|
// 获取传给formItem的属性
|
|
40
51
|
const getFormItemProps = (option) => {
|
|
41
52
|
const formItemProps = typeof option.formItemProps === "function"
|
|
42
|
-
? option.formItemProps(
|
|
53
|
+
? option.formItemProps(getFormValues())
|
|
43
54
|
: (option.formItemProps || {});
|
|
44
55
|
|
|
45
56
|
// 为日期组件添加特殊处理
|
|
@@ -90,7 +101,7 @@ const FormItemsRenderer = ({
|
|
|
90
101
|
|
|
91
102
|
// 支持动态计算 required
|
|
92
103
|
const required = typeof option.required === "function"
|
|
93
|
-
? option.required(
|
|
104
|
+
? option.required(getFormValues())
|
|
94
105
|
: (option.required ?? true);
|
|
95
106
|
|
|
96
107
|
if (required) {
|
|
@@ -290,10 +301,10 @@ const FormItemsRenderer = ({
|
|
|
290
301
|
shouldUpdate={option.shouldUpdate ?? option?.componentProps?.shouldUpdate}
|
|
291
302
|
dependencies={option.dependencies || option?.componentProps?.dependencies}
|
|
292
303
|
>
|
|
293
|
-
{(
|
|
304
|
+
{() => {
|
|
294
305
|
// 支持动态计算 hidden
|
|
295
306
|
const hidden = typeof option.hidden === "function"
|
|
296
|
-
? option.hidden(
|
|
307
|
+
? option.hidden(getFormValues())
|
|
297
308
|
: (option.hidden ?? false);
|
|
298
309
|
|
|
299
310
|
if (hidden)
|
|
@@ -319,7 +330,12 @@ const FormItemsRenderer = ({
|
|
|
319
330
|
}
|
|
320
331
|
|
|
321
332
|
// 普通表单项(静态配置)
|
|
322
|
-
|
|
333
|
+
// 支持动态计算 hidden
|
|
334
|
+
const hidden = typeof option.hidden === "function"
|
|
335
|
+
? option.hidden(getFormValues())
|
|
336
|
+
: (option.hidden ?? false);
|
|
337
|
+
|
|
338
|
+
if (hidden)
|
|
323
339
|
return null;
|
|
324
340
|
|
|
325
341
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FC, ReactNode } from "react";
|
|
1
|
+
import type { CSSProperties, FC, ReactNode } from "react";
|
|
2
2
|
|
|
3
3
|
export interface HeaderBackProps {
|
|
4
4
|
/** 标题 */
|
|
@@ -10,6 +10,8 @@ export interface HeaderBackProps {
|
|
|
10
10
|
};
|
|
11
11
|
/** 是否显示返回按钮,默认为 true */
|
|
12
12
|
previous?: boolean;
|
|
13
|
+
/** 自定义样式 */
|
|
14
|
+
style?: CSSProperties;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/** 头部返回组件 */
|
|
@@ -6,10 +6,10 @@ import "./index.less";
|
|
|
6
6
|
* 头部返回组件
|
|
7
7
|
*/
|
|
8
8
|
function HeaderBack(props) {
|
|
9
|
-
const { title, history, previous = true } = props;
|
|
9
|
+
const { title, history, previous = true, style = {} } = props;
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
|
-
<div className="header-back">
|
|
12
|
+
<div className="header-back" style={style}>
|
|
13
13
|
<div className="action">
|
|
14
14
|
{
|
|
15
15
|
previous
|
|
@@ -84,6 +84,7 @@ const Search = (props) => {
|
|
|
84
84
|
span={6}
|
|
85
85
|
collapse={collapse}
|
|
86
86
|
useAutoGenerateRequired={false}
|
|
87
|
+
initialValues={values}
|
|
87
88
|
/>
|
|
88
89
|
<Col span={showCollapseButton ? (collapse ? 6 : span) : span}>
|
|
89
90
|
<Form.Item label=" " colon={false} style={{ textAlign: "right" }}>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import Table from "@cqsjjb/jjb-react-admin-component/Table";
|
|
2
2
|
import { getIndexColumn } from "../../utils/index";
|
|
3
|
+
import "./index.less";
|
|
3
4
|
|
|
4
5
|
function TablePro(props) {
|
|
5
6
|
const {
|
|
6
7
|
columns = [],
|
|
7
8
|
showIndex = true,
|
|
8
9
|
useAlignCenter = true,
|
|
9
|
-
rowKey =
|
|
10
|
+
rowKey = "id",
|
|
10
11
|
...restProps
|
|
11
12
|
} = props;
|
|
12
13
|
|