@cqsjjb/jjb-react-admin-component 3.0.14 → 3.0.16

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.
@@ -0,0 +1,57 @@
1
+ // @ts-ignore
2
+ import * as React from 'react';
3
+ import { ComponentProps } from '../types';
4
+
5
+ interface FormilyDescriptionsProps extends ComponentProps {
6
+ /**
7
+ * @description 表单配置
8
+ */
9
+ schema: any,
10
+ /**
11
+ * @description 表单数据
12
+ */
13
+ values: any,
14
+ /**
15
+ * @description 尺寸
16
+ */
17
+ size?: 'default' | 'middle' | 'small';
18
+ /**
19
+ * @description 图片宽度
20
+ */
21
+ imageWidth?: number;
22
+ /**
23
+ * @description 图片高度
24
+ */
25
+ imageHeight?: number;
26
+ /**
27
+ * @description 图片预览配置
28
+ * @see https://ant.design/components/image-cn#previewtype
29
+ */
30
+ imagePreview?: boolean | {}
31
+ /**
32
+ * @description 是否显示冒号
33
+ * @see https://ant.design/components/descriptions-cn#descriptions
34
+ */
35
+ colon?: boolean;
36
+ /**
37
+ * @description 显示布局
38
+ * @see https://ant.design/components/descriptions-cn#descriptions
39
+ */
40
+ layout?: 'vertical' | 'horizontal';
41
+ /**
42
+ * @description 参考antd/description
43
+ * @see https://ant.design/components/descriptions-cn#descriptions
44
+ */
45
+ labelStyle?: {};
46
+ /**
47
+ * @description 参考antd/description
48
+ * @see https://ant.design/components/descriptions-cn#descriptions
49
+ */
50
+ contentStyle?: {};
51
+ }
52
+
53
+ interface FormilyDescriptionsFc extends React.FC<FormilyDescriptionsProps> {
54
+ }
55
+
56
+ declare const FormilyDescriptions: FormilyDescriptionsFc;
57
+ export default FormilyDescriptions;
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import { tools } from '@cqsjjb/jjb-common-lib';
3
+ import { LinkOutlined } from '@ant-design/icons';
4
+ import { Descriptions, Empty, Image, Tooltip } from 'antd';
5
+ export default function FormilyDescriptions(props) {
6
+ const dataSource = tools.getDynamicFormilyFields(props.schema, props.values);
7
+ return dataSource.length === 0 ? /*#__PURE__*/React.createElement(Empty, {
8
+ image: Empty.PRESENTED_IMAGE_SIMPLE
9
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, dataSource.map((item, index) => {
10
+ const isLast = index === dataSource.length - 1;
11
+ return /*#__PURE__*/React.createElement(Descriptions, {
12
+ key: index,
13
+ size: props.size,
14
+ style: {
15
+ marginBottom: isLast ? 0 : 16
16
+ },
17
+ items: item.fromComponentEnum === 'GRID_FORM' ? item.children.map((child, childIndex) => {
18
+ return {
19
+ key: childIndex,
20
+ label: child.name,
21
+ children: tools.isStringArray(child.value) || tools.isNumberArray(child.value) ? child.value.join('、') : tools.isObjectArray(child.value) ? /*#__PURE__*/React.createElement("div", null, child.value.map((next, nextIndex) => {
22
+ if (next.url) {
23
+ if (next.isImage) {
24
+ return /*#__PURE__*/React.createElement("span", {
25
+ style: {
26
+ display: 'inline-block',
27
+ marginRight: 4,
28
+ marginBottom: 4
29
+ }
30
+ }, /*#__PURE__*/React.createElement(Image, {
31
+ key: nextIndex,
32
+ src: next.url,
33
+ width: props.imageWidth || 64,
34
+ height: props.imageHeight || 64,
35
+ preview: props.imagePreview
36
+ }));
37
+ } else {
38
+ return /*#__PURE__*/React.createElement(Tooltip, {
39
+ title: next.url
40
+ }, /*#__PURE__*/React.createElement("a", {
41
+ key: nextIndex,
42
+ href: next.url,
43
+ style: {
44
+ gap: 4,
45
+ display: 'flex',
46
+ alignItems: 'center'
47
+ },
48
+ target: "_blank"
49
+ }, /*#__PURE__*/React.createElement(LinkOutlined, null), "\u70B9\u51FB\u4E0B\u8F7D"));
50
+ }
51
+ } else {
52
+ return tools.textPlaceholder(next.name);
53
+ }
54
+ })) : tools.textPlaceholder(child.value)
55
+ };
56
+ }) : [{
57
+ key: 1,
58
+ label: item.name,
59
+ children: tools.textPlaceholder(item.value)
60
+ }],
61
+ colon: props.colon,
62
+ title: props.title,
63
+ extra: props.extra,
64
+ layout: props.layout || 'vertical',
65
+ column: 3,
66
+ labelStyle: props.labelStyle,
67
+ contentStyle: props.contentStyle
68
+ });
69
+ }));
70
+ }
File without changes
@@ -0,0 +1,102 @@
1
+ import React from 'react';
2
+
3
+ import { tools } from '@cqsjjb/jjb-common-lib';
4
+ import { LinkOutlined } from '@ant-design/icons';
5
+ import { Descriptions, Empty, Image, Tooltip } from 'antd';
6
+
7
+ export default function FormilyDescriptions(props) {
8
+ const dataSource = tools.getDynamicFormilyFields(props.schema, props.values);
9
+ return dataSource.length === 0
10
+ ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
11
+ : (
12
+ <React.Fragment>
13
+ {dataSource.map((item, index) => {
14
+ const isLast = index === dataSource.length - 1;
15
+
16
+ return (
17
+ <Descriptions
18
+ key={index}
19
+ size={props.size}
20
+ style={{
21
+ marginBottom: isLast
22
+ ? 0
23
+ : 16
24
+ }}
25
+ items={item.fromComponentEnum === 'GRID_FORM'
26
+ ? item.children.map((child, childIndex) => {
27
+ return {
28
+ key: childIndex,
29
+ label: child.name,
30
+ children: (tools.isStringArray(child.value) || tools.isNumberArray(child.value))
31
+ ? child.value.join('、')
32
+ : tools.isObjectArray(child.value)
33
+ ? (
34
+ <div>
35
+ {child.value.map((next, nextIndex) => {
36
+ if (next.url) {
37
+ if (next.isImage) {
38
+ return (
39
+ <span
40
+ style={{
41
+ display: 'inline-block',
42
+ marginRight: 4,
43
+ marginBottom: 4
44
+ }}
45
+ >
46
+ <Image
47
+ key={nextIndex}
48
+ src={next.url}
49
+ width={props.imageWidth || 64}
50
+ height={props.imageHeight || 64}
51
+ preview={props.imagePreview}
52
+ />
53
+ </span>
54
+ );
55
+ } else {
56
+ return (
57
+ <Tooltip title={next.url}>
58
+ <a
59
+ key={nextIndex}
60
+ href={next.url}
61
+ style={{
62
+ gap: 4,
63
+ display: 'flex',
64
+ alignItems: 'center'
65
+ }}
66
+ target="_blank"
67
+ >
68
+ <LinkOutlined />
69
+ 点击下载
70
+ </a>
71
+ </Tooltip>
72
+ );
73
+ }
74
+ } else {
75
+ return tools.textPlaceholder(next.name);
76
+ }
77
+ })}
78
+ </div>
79
+ )
80
+ : tools.textPlaceholder(child.value)
81
+ };
82
+ })
83
+ : [
84
+ {
85
+ key: 1,
86
+ label: item.name,
87
+ children: tools.textPlaceholder(item.value)
88
+ }
89
+ ]}
90
+ colon={props.colon}
91
+ title={props.title}
92
+ extra={props.extra}
93
+ layout={props.layout || 'vertical'}
94
+ column={3}
95
+ labelStyle={props.labelStyle}
96
+ contentStyle={props.contentStyle}
97
+ />
98
+ );
99
+ })}
100
+ </React.Fragment>
101
+ );
102
+ }
@@ -0,0 +1,38 @@
1
+ // @ts-ignore
2
+ import * as React from 'react';
3
+ import { ComponentProps } from '../types';
4
+
5
+ interface FormilyRendererProps extends ComponentProps {
6
+ /**
7
+ * @description 表单code
8
+ */
9
+ code: string,
10
+ /**
11
+ * @description 表单初始化值
12
+ */
13
+ initialValues?: Record<string, any>,
14
+ /**
15
+ * @description 禁用字段
16
+ */
17
+ disabledFields?: string[];
18
+ /**
19
+ * @description 获取表单示例
20
+ * @see https://core.formilyjs.org/api/models/form#method
21
+ */
22
+ getRef?: (form: object) => void;
23
+ /**
24
+ * @description 图片高度
25
+ */
26
+ width?: number;
27
+ /**
28
+ * @description 样式
29
+ * @see https://ant.design/components/image-cn#previewtype
30
+ */
31
+ style?: {}
32
+ }
33
+
34
+ interface FormilyRendererFc extends React.FC<FormilyRendererProps> {
35
+ }
36
+
37
+ declare const FormilyRenderer: FormilyRendererFc;
38
+ export default FormilyRenderer;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import Renderer from '@cqsjjb-formily/renderer';
3
+ import { http, tools } from '@cqsjjb/jjb-common-lib';
4
+ export default function FormilyRenderer(props) {
5
+ const form = React.useRef();
6
+ const [schema, setSchema] = React.useState({});
7
+ React.useEffect(() => {
8
+ http.Get(`/design/designs/${props.code}`).then(res => {
9
+ if (res.success) {
10
+ const {
11
+ config
12
+ } = res.data;
13
+ setSchema(tools.parseObject(config));
14
+ }
15
+ });
16
+ }, []);
17
+ React.useEffect(() => {
18
+ if (!tools.isEmptyObject(schema)) {
19
+ form.current.setValues(props.initialValues);
20
+ setTimeout(() => {
21
+ for (const field of tools.toArray(props.disabledFields)) {
22
+ if (form.current.fields[field]) {
23
+ form.current.fields[field].required = false;
24
+ form.current.fields[field].disabled = true;
25
+ }
26
+ }
27
+ }, 1000);
28
+ props.getRef && props.getRef(form);
29
+ }
30
+ }, [schema]);
31
+ return /*#__PURE__*/React.createElement("div", {
32
+ style: props.style
33
+ }, !tools.isEmptyObject(schema) && /*#__PURE__*/React.createElement(Renderer, {
34
+ ref: form,
35
+ schema: schema
36
+ }));
37
+ }
@@ -0,0 +1,6 @@
1
+ .@{ant-prefix}-form-renderer {
2
+ .@{ant-prefix}-formily-grid-layout {
3
+ gap: 4px 30px !important;
4
+ grid-template-columns: repeat(3, minmax(0px, 1fr)) !important;
5
+ }
6
+ }
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import Renderer from '@cqsjjb-formily/renderer';
3
+
4
+ import { http, tools } from '@cqsjjb/jjb-common-lib';
5
+
6
+ export default function FormilyRenderer (props) {
7
+ const form = React.useRef();
8
+ const [ schema, setSchema ] = React.useState({});
9
+
10
+ React.useEffect(() => {
11
+ http.Get(`/design/designs/${props.code}`).then(res => {
12
+ if (res.success) {
13
+ const { config } = res.data;
14
+ setSchema(tools.parseObject(config));
15
+ }
16
+ });
17
+ }, []);
18
+
19
+ React.useEffect(() => {
20
+ if (!tools.isEmptyObject(schema)) {
21
+ form.current.setValues(props.initialValues);
22
+ setTimeout(() => {
23
+ for (const field of tools.toArray(props.disabledFields)) {
24
+ if (form.current.fields[ field ]) {
25
+ form.current.fields[ field ].required = false;
26
+ form.current.fields[ field ].disabled = true;
27
+ }
28
+ }
29
+ }, 1000);
30
+ props.getRef && props.getRef(form);
31
+ }
32
+ }, [ schema ]);
33
+
34
+ return (
35
+ <div style={props.style}>
36
+ {!tools.isEmptyObject(schema) && (
37
+ <Renderer
38
+ ref={form}
39
+ schema={schema}
40
+ />
41
+ )}
42
+ </div>
43
+ );
44
+ }
@@ -4,7 +4,7 @@ import { MoreOutlined } from '@ant-design/icons';
4
4
  import { Dropdown, Space } from 'antd';
5
5
  export default function TableAction(props) {
6
6
  const maximum = props.maximum || 3;
7
- const children = tools.isArray(props.children) ? props.children : [].concat(props.children);
7
+ const children = (tools.isArray(props.children) ? props.children : [].concat(props.children)).filter(i => i);
8
8
  const showArray = children.slice(0, maximum);
9
9
  const hideArray = children.slice(maximum);
10
10
  return /*#__PURE__*/React.createElement(Space, {
@@ -8,7 +8,7 @@ export default function TableAction(props) {
8
8
  const maximum = props.maximum || 3;
9
9
  const children = (tools.isArray(props.children)
10
10
  ? props.children
11
- : [].concat(props.children));
11
+ : [].concat(props.children)).filter(i => i);
12
12
  const showArray = children.slice(0, maximum);
13
13
  const hideArray = children.slice(maximum);
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/jjb-react-admin-component",
3
- "version": "3.0.14",
3
+ "version": "3.0.16",
4
4
  "description": "jjb-react-admin-组件库@new",
5
5
  "main": "index.js",
6
6
  "author": "jjb-front-team",
@@ -13,6 +13,7 @@
13
13
  "spark-md5": "^3.0.2",
14
14
  "classnames": "^2.5.1",
15
15
  "antd-img-crop": "latest",
16
+ "@cqsjjb-formily/renderer": "latest",
16
17
  "@ant-design/pro-layout": "latest",
17
18
  "use-antd-resizable-header": "latest",
18
19
  "@ant-design/pro-components": "latest"