fan-standard-comp 3.1.4 → 3.1.6
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/dist/f26952c118ab6cdcd23dc0028ee98c11.svg +173 -0
- package/dist/fan-standard-comp.umd.js +597 -0
- package/dist/fonts/iconfont.eot +0 -0
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/es/ButtonGroup/ButtonList.d.ts +2 -0
- package/es/ButtonGroup/ButtonList.js +37 -0
- package/es/ButtonGroup/ButtonMenu.d.ts +2 -0
- package/es/ButtonGroup/ButtonMenu.js +38 -0
- package/es/ButtonGroup/PopConfirmTitle.d.ts +9 -0
- package/es/ButtonGroup/PopConfirmTitle.js +37 -0
- package/es/ButtonGroup/index.d.ts +30 -0
- package/es/ButtonGroup/index.js +374 -0
- package/es/ButtonGroup/style/index.less +36 -0
- package/es/DragContent/DragBar.js +21 -0
- package/es/DragContent/index.d.ts +14 -0
- package/es/DragContent/index.js +173 -0
- package/es/DragContent/index.less +44 -0
- package/es/FormComp/ChunkUploader/api.js +76 -0
- package/es/FormComp/ChunkUploader/index.js +391 -0
- package/es/FormComp/ChunkUploader/lib.js +96 -0
- package/es/FormComp/ChunkUploader/style/style.less +3 -0
- package/es/FormComp/ChunkUploader/upload-queue.class.js +167 -0
- package/es/FormComp/ChunkUploader/worker.js +23 -0
- package/es/FormComp/EditButton/index.d.ts +26 -0
- package/es/FormComp/EditButton/index.js +140 -0
- package/es/FormComp/FieldComponent/ReUpload.d.ts +3 -0
- package/es/FormComp/FieldComponent/ReUpload.js +131 -0
- package/es/FormComp/FieldComponent/RefactorTreeSelect.js +251 -0
- package/es/FormComp/FieldComponent/TitleNode.d.ts +6 -0
- package/es/FormComp/FieldComponent/TitleNode.js +9 -0
- package/es/FormComp/FieldComponent/index.d.ts +38 -0
- package/es/FormComp/FieldComponent/index.js +413 -0
- package/es/FormComp/FieldComponent/setReadonlyValues.js +236 -0
- package/es/FormComp/FieldComponent/style/index.less +120 -0
- package/es/FormComp/RenderItemGroup/index.d.ts +37 -0
- package/es/FormComp/RenderItemGroup/index.js +234 -0
- package/es/FormComp/Uploader/index.d.ts +21 -0
- package/es/FormComp/Uploader/index.js +277 -0
- package/es/FormComp/Uploader/style/index.less +14 -0
- package/es/FormComp/Uploader/util.d.ts +8 -0
- package/es/FormComp/Uploader/util.js +38 -0
- package/es/FormComp/VarTemplate/index.js +293 -0
- package/es/FormComp/index.d.ts +1 -0
- package/es/FormComp/index.js +1 -0
- package/es/NavLeafScroll/index.js +379 -0
- package/es/NavLeafScroll/style/index.less +119 -0
- package/es/RefactorTree/data.d.ts +7 -0
- package/es/RefactorTree/index.d.ts +40 -0
- package/es/RefactorTree/index.js +167 -0
- package/es/RefactorTree/indexTreeNode.d.ts +39 -0
- package/es/RefactorTree/indexTreeNode.js +237 -0
- package/es/RefactorTree/style/index.d.ts +1 -0
- package/es/RefactorTree/style/index.js +1 -0
- package/es/RefactorTree/style/index.less +22 -0
- package/es/RefactorTree/util.d.ts +42 -0
- package/es/RefactorTree/util.js +187 -0
- package/es/SpecIcon/fonts/demo.css +539 -0
- package/es/SpecIcon/fonts/demo_index.html +1315 -0
- package/es/SpecIcon/fonts/iconfont.css +211 -0
- package/es/SpecIcon/fonts/iconfont.eot +0 -0
- package/es/SpecIcon/fonts/iconfont.js +41 -0
- package/es/SpecIcon/fonts/iconfont.json +352 -0
- package/es/SpecIcon/fonts/iconfont.svg +173 -0
- package/es/SpecIcon/fonts/iconfont.ttf +0 -0
- package/es/SpecIcon/fonts/iconfont.woff +0 -0
- package/es/SpecIcon/fonts/iconfont.woff2 +0 -0
- package/es/SpecIcon/index.d.ts +17 -0
- package/es/SpecIcon/index.js +77 -0
- package/es/SpecIcon/style/iconfont.less +213 -0
- package/es/SpecIcon/style/index.less +98 -0
- package/es/SplitterLayout/Pane.d.ts +13 -0
- package/es/SplitterLayout/Pane.js +36 -0
- package/es/SplitterLayout/index.js +375 -0
- package/es/SplitterLayout/index.less +58 -0
- package/es/StandardContent/SplitterLayout/Pane.js +50 -0
- package/es/StandardContent/SplitterLayout/index.js +374 -0
- package/es/StandardContent/SplitterLayout/index.less +58 -0
- package/es/StandardContent/SubfieldContent.d.ts +17 -0
- package/es/StandardContent/SubfieldContent.js +41 -0
- package/es/StandardContent/WrapperContent.d.ts +13 -0
- package/es/StandardContent/WrapperContent.js +29 -0
- package/es/StandardContent/data.d.ts +101 -0
- package/es/StandardContent/style/index.less +80 -0
- package/es/StandardDragModal/index.d.ts +11 -0
- package/es/StandardDragModal/index.js +30 -0
- package/es/StandardFilter/index.d.ts +35 -0
- package/es/StandardFilter/index.js +253 -0
- package/es/StandardFilter/style/index.less +62 -0
- package/es/StandardForm/ActionList.js +44 -0
- package/es/StandardForm/StepForm.d.ts +19 -0
- package/es/StandardForm/StepForm.js +267 -0
- package/es/StandardForm/TabForm.d.ts +19 -0
- package/es/StandardForm/TabForm.js +122 -0
- package/es/StandardForm/index.d.ts +32 -0
- package/es/StandardForm/index.js +170 -0
- package/es/StandardForm/style/index.less +58 -0
- package/es/StandardModal/UpdateFormRef.js +18 -0
- package/es/StandardModal/index.d.ts +44 -0
- package/es/StandardModal/index.js +495 -0
- package/es/StandardModal/style/index.less +50 -0
- package/es/StandardPanel/index.d.ts +28 -0
- package/es/StandardPanel/index.js +134 -0
- package/es/StandardPanel/style/index.less +135 -0
- package/es/StandardTable/index.d.ts +22 -0
- package/es/StandardTable/index.js +126 -0
- package/es/StandardTable/style/index.d.ts +1 -0
- package/es/StandardTable/style/index.js +1 -0
- package/es/StandardTable/style/index.less +206 -0
- package/es/components/IconNode/index.d.ts +16 -0
- package/es/components/IconNode/index.js +28 -0
- package/es/components/index.d.ts +2 -0
- package/es/components/index.js +2 -0
- package/es/data/func.code.js +112 -0
- package/es/data/general.config.js +172 -0
- package/es/data/index.js +3 -0
- package/es/index.d.ts +24 -0
- package/es/index.js +31 -0
- package/es/styles/index.less +0 -0
- package/es/theme/spec-variable.less +48 -0
- package/es/utils/ValueFormat.js +50 -0
- package/es/utils/filterPermission.js +111 -0
- package/es/utils/getParentNodes.js +215 -0
- package/es/utils/index.js +3 -0
- package/lib/ButtonGroup/ButtonList.d.ts +2 -0
- package/lib/ButtonGroup/ButtonList.js +55 -0
- package/lib/ButtonGroup/ButtonMenu.d.ts +2 -0
- package/lib/ButtonGroup/ButtonMenu.js +51 -0
- package/lib/ButtonGroup/PopConfirmTitle.d.ts +9 -0
- package/lib/ButtonGroup/PopConfirmTitle.js +48 -0
- package/lib/ButtonGroup/index.d.ts +30 -0
- package/lib/ButtonGroup/index.js +405 -0
- package/lib/ButtonGroup/style/index.less +36 -0
- package/lib/DragContent/DragBar.js +33 -0
- package/lib/DragContent/index.d.ts +14 -0
- package/lib/DragContent/index.js +191 -0
- package/lib/DragContent/index.less +44 -0
- package/lib/FormComp/ChunkUploader/api.js +89 -0
- package/lib/FormComp/ChunkUploader/index.js +410 -0
- package/lib/FormComp/ChunkUploader/lib.js +113 -0
- package/lib/FormComp/ChunkUploader/style/style.less +3 -0
- package/lib/FormComp/ChunkUploader/upload-queue.class.js +174 -0
- package/lib/FormComp/ChunkUploader/worker.js +28 -0
- package/lib/FormComp/EditButton/index.d.ts +26 -0
- package/lib/FormComp/EditButton/index.js +159 -0
- package/lib/FormComp/FieldComponent/ReUpload.d.ts +3 -0
- package/lib/FormComp/FieldComponent/ReUpload.js +151 -0
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +274 -0
- package/lib/FormComp/FieldComponent/TitleNode.d.ts +6 -0
- package/lib/FormComp/FieldComponent/TitleNode.js +19 -0
- package/lib/FormComp/FieldComponent/index.d.ts +38 -0
- package/lib/FormComp/FieldComponent/index.js +457 -0
- package/lib/FormComp/FieldComponent/setReadonlyValues.js +263 -0
- package/lib/FormComp/FieldComponent/style/index.less +120 -0
- package/lib/FormComp/RenderItemGroup/index.d.ts +37 -0
- package/lib/FormComp/RenderItemGroup/index.js +255 -0
- package/lib/FormComp/Uploader/index.d.ts +21 -0
- package/lib/FormComp/Uploader/index.js +303 -0
- package/lib/FormComp/Uploader/style/index.less +14 -0
- package/lib/FormComp/Uploader/util.d.ts +8 -0
- package/lib/FormComp/Uploader/util.js +47 -0
- package/lib/FormComp/VarTemplate/index.js +308 -0
- package/lib/FormComp/index.d.ts +1 -0
- package/lib/FormComp/index.js +15 -0
- package/lib/NavLeafScroll/index.js +397 -0
- package/lib/NavLeafScroll/style/index.less +119 -0
- package/lib/RefactorTree/data.d.ts +7 -0
- package/lib/RefactorTree/index.d.ts +40 -0
- package/lib/RefactorTree/index.js +190 -0
- package/lib/RefactorTree/indexTreeNode.d.ts +39 -0
- package/lib/RefactorTree/indexTreeNode.js +260 -0
- package/lib/RefactorTree/style/index.d.ts +1 -0
- package/lib/RefactorTree/style/index.js +3 -0
- package/lib/RefactorTree/style/index.less +22 -0
- package/lib/RefactorTree/util.d.ts +42 -0
- package/lib/RefactorTree/util.js +195 -0
- package/lib/SpecIcon/fonts/demo.css +539 -0
- package/lib/SpecIcon/fonts/demo_index.html +1315 -0
- package/lib/SpecIcon/fonts/iconfont.css +211 -0
- package/lib/SpecIcon/fonts/iconfont.eot +0 -0
- package/lib/SpecIcon/fonts/iconfont.js +43 -0
- package/lib/SpecIcon/fonts/iconfont.json +352 -0
- package/lib/SpecIcon/fonts/iconfont.svg +173 -0
- package/lib/SpecIcon/fonts/iconfont.ttf +0 -0
- package/lib/SpecIcon/fonts/iconfont.woff +0 -0
- package/lib/SpecIcon/fonts/iconfont.woff2 +0 -0
- package/lib/SpecIcon/index.d.ts +17 -0
- package/lib/SpecIcon/index.js +90 -0
- package/lib/SpecIcon/style/iconfont.less +213 -0
- package/lib/SpecIcon/style/index.less +98 -0
- package/lib/SplitterLayout/Pane.d.ts +13 -0
- package/lib/SplitterLayout/Pane.js +48 -0
- package/lib/SplitterLayout/index.js +386 -0
- package/lib/SplitterLayout/index.less +58 -0
- package/lib/StandardContent/SplitterLayout/Pane.js +62 -0
- package/lib/StandardContent/SplitterLayout/index.js +387 -0
- package/lib/StandardContent/SplitterLayout/index.less +58 -0
- package/lib/StandardContent/SubfieldContent.d.ts +17 -0
- package/lib/StandardContent/SubfieldContent.js +56 -0
- package/lib/StandardContent/WrapperContent.d.ts +13 -0
- package/lib/StandardContent/WrapperContent.js +43 -0
- package/lib/StandardContent/data.d.ts +101 -0
- package/lib/StandardContent/style/index.less +80 -0
- package/lib/StandardDragModal/index.d.ts +11 -0
- package/lib/StandardDragModal/index.js +43 -0
- package/lib/StandardFilter/index.d.ts +35 -0
- package/lib/StandardFilter/index.js +272 -0
- package/lib/StandardFilter/style/index.less +62 -0
- package/lib/StandardForm/ActionList.js +57 -0
- package/lib/StandardForm/StepForm.d.ts +19 -0
- package/lib/StandardForm/StepForm.js +295 -0
- package/lib/StandardForm/TabForm.d.ts +19 -0
- package/lib/StandardForm/TabForm.js +148 -0
- package/lib/StandardForm/index.d.ts +32 -0
- package/lib/StandardForm/index.js +197 -0
- package/lib/StandardForm/style/index.less +58 -0
- package/lib/StandardModal/UpdateFormRef.js +32 -0
- package/lib/StandardModal/index.d.ts +44 -0
- package/lib/StandardModal/index.js +525 -0
- package/lib/StandardModal/style/index.less +50 -0
- package/lib/StandardPanel/index.d.ts +28 -0
- package/lib/StandardPanel/index.js +155 -0
- package/lib/StandardPanel/style/index.less +135 -0
- package/lib/StandardTable/index.d.ts +22 -0
- package/lib/StandardTable/index.js +143 -0
- package/lib/StandardTable/style/index.d.ts +1 -0
- package/lib/StandardTable/style/index.js +3 -0
- package/lib/StandardTable/style/index.less +206 -0
- package/lib/components/IconNode/index.d.ts +16 -0
- package/lib/components/IconNode/index.js +39 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.js +15 -0
- package/lib/data/func.code.js +119 -0
- package/lib/data/general.config.js +179 -0
- package/lib/data/index.js +23 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +236 -0
- package/lib/styles/index.less +0 -0
- package/lib/theme/spec-variable.less +48 -0
- package/lib/utils/ValueFormat.js +58 -0
- package/lib/utils/filterPermission.js +127 -0
- package/lib/utils/getParentNodes.js +226 -0
- package/lib/utils/index.js +35 -0
- package/package.json +1 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
@root-entry-name: default;
|
|
2
|
+
@import (reference) '~antd/es/style/themes/index';
|
|
3
|
+
|
|
4
|
+
.refactor-tree-select {
|
|
5
|
+
position: relative;
|
|
6
|
+
.ant-select {
|
|
7
|
+
z-index: 2;
|
|
8
|
+
.ant-select-selector {
|
|
9
|
+
background: transparent;
|
|
10
|
+
}
|
|
11
|
+
.ant-select-selection-item {
|
|
12
|
+
//opacity: 0;
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
&.ant-select-disabled.ant-select-single:not(.ant-select-customize-input) .ant-select-selector {
|
|
16
|
+
background: transparent;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//.ant-select-disabled.ant-select-single:not(.ant-select-customize-input) ~ .refactor-tree-select-extra{
|
|
20
|
+
//}
|
|
21
|
+
}
|
|
22
|
+
&.refactor-disabled .refactor-tree-select-extra {
|
|
23
|
+
background: @disabled-bg;
|
|
24
|
+
color: @disabled-color;
|
|
25
|
+
}
|
|
26
|
+
.refactor-tree-select-extra {
|
|
27
|
+
width: 100%;
|
|
28
|
+
background: @component-background;
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 0;
|
|
31
|
+
left: 0;
|
|
32
|
+
bottom: 0;
|
|
33
|
+
height: @input-height-base;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
padding: 1px 22px 1px 8px;
|
|
36
|
+
line-height: 30px;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.spec-uploader-viewonly {
|
|
44
|
+
display: inline-block;
|
|
45
|
+
width: 100%;
|
|
46
|
+
&:after {
|
|
47
|
+
display: table;
|
|
48
|
+
clear: both;
|
|
49
|
+
content: '';
|
|
50
|
+
}
|
|
51
|
+
.spec-uploader-viewonly-item {
|
|
52
|
+
float: left;
|
|
53
|
+
width: 100px;
|
|
54
|
+
height: 100px;
|
|
55
|
+
padding: @padding-xs;
|
|
56
|
+
margin-right: @padding-xs;
|
|
57
|
+
margin-bottom: @padding-xs;
|
|
58
|
+
border: 1px solid @border-color-base;
|
|
59
|
+
border-radius: @border-radius-sm;
|
|
60
|
+
line-height: 88px;
|
|
61
|
+
text-align: center;
|
|
62
|
+
background: transparent;
|
|
63
|
+
img {
|
|
64
|
+
width: 100%;
|
|
65
|
+
height: 100%;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
.ant-image +.ant-image{
|
|
69
|
+
margin-left: 5px;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 下拉树只读列表
|
|
74
|
+
.tree-select-viewonly-list {
|
|
75
|
+
position: relative;
|
|
76
|
+
width: 100%;
|
|
77
|
+
border: 1px solid fade(@border-color-split, 60%);
|
|
78
|
+
border-radius: @border-radius-sm;
|
|
79
|
+
padding: @padding-xs @padding-sm;
|
|
80
|
+
&.collapsed {
|
|
81
|
+
padding-bottom: 28px;
|
|
82
|
+
}
|
|
83
|
+
.tree-select-viewonly-item b {
|
|
84
|
+
font-size: 18px;
|
|
85
|
+
}
|
|
86
|
+
.toggle-icon {
|
|
87
|
+
position: absolute;
|
|
88
|
+
bottom: 0;
|
|
89
|
+
left: 0;
|
|
90
|
+
width: 100%;
|
|
91
|
+
height: 28px;
|
|
92
|
+
line-height: 28px;
|
|
93
|
+
text-align: center;
|
|
94
|
+
font-size: @font-size-sm;
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
color: @text-color-secondary;
|
|
97
|
+
//color: color(~`colorPalette('@{text-color-secondary}', 3) `);
|
|
98
|
+
background-image: -webkit-gradient(linear, left top, left bottom, from(fade(@component-background, 0)), to(@component-background));
|
|
99
|
+
background-image: -webkit-linear-gradient(top, fade(@component-background, 0), @component-background);
|
|
100
|
+
background-image: linear-gradient(-180deg, fade(@component-background, 0), @component-background);
|
|
101
|
+
&:hover {
|
|
102
|
+
color: @primary-color;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.checkbox-viewonly-item{
|
|
108
|
+
display: inline ;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
.upload-viewonly {
|
|
113
|
+
.ant-upload-select.ant-upload-disabled {
|
|
114
|
+
display: none;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.form-item-view-only .ant-form-item-control-input-content {
|
|
119
|
+
word-break: break-all;
|
|
120
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FieldComponentProps } from '../FieldComponent';
|
|
3
|
+
export interface FieldsItemProps extends FieldComponentProps {
|
|
4
|
+
label?: string | React.ReactNode;
|
|
5
|
+
description?: string;
|
|
6
|
+
isHide?: (fields?: any, form?: any, fieldStatus?: string) => boolean | boolean;
|
|
7
|
+
customRender?: (form?: any, data?: FieldsItemProps, fieldStatus?: string) => React.ReactNode;
|
|
8
|
+
colSpan?: number;
|
|
9
|
+
display?: string | object;
|
|
10
|
+
protoFormItem?: object;
|
|
11
|
+
preExtra?: (config?: any, form?: any) => React.ReactNode;
|
|
12
|
+
extra?: (config?: any, form?: any) => React.ReactNode;
|
|
13
|
+
rules?: any;
|
|
14
|
+
fieldOptions?: any;
|
|
15
|
+
size?: 'large' | 'middle' | 'small' | string;
|
|
16
|
+
componentStyle?: React.CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
interface layoutProps {
|
|
19
|
+
labelCol?: any;
|
|
20
|
+
wrapperCol?: any;
|
|
21
|
+
}
|
|
22
|
+
interface displayLayoutProps extends layoutProps {
|
|
23
|
+
side?: layoutProps;
|
|
24
|
+
block?: layoutProps;
|
|
25
|
+
}
|
|
26
|
+
interface ItemGroupProps {
|
|
27
|
+
itemGroup: any | FieldsItemProps[];
|
|
28
|
+
size?: string;
|
|
29
|
+
fieldStatus?: 'default' | 'viewOnly' | 'disabled';
|
|
30
|
+
fieldSize?: 'large' | 'middle' | 'small' | any;
|
|
31
|
+
displayLayout?: displayLayoutProps;
|
|
32
|
+
form?: any;
|
|
33
|
+
layout?: string;
|
|
34
|
+
doUpdateFormFields?: () => void;
|
|
35
|
+
}
|
|
36
|
+
declare const RenderItemGroup: (props: ItemGroupProps) => any;
|
|
37
|
+
export default RenderItemGroup;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import "antd/es/row/style";
|
|
2
|
+
import _Row from "antd/es/row";
|
|
3
|
+
import "antd/es/tooltip/style";
|
|
4
|
+
import _Tooltip from "antd/es/tooltip";
|
|
5
|
+
import "antd/es/col/style";
|
|
6
|
+
import _Col from "antd/es/col";
|
|
7
|
+
import "antd/es/form/style";
|
|
8
|
+
import _Form from "antd/es/form";
|
|
9
|
+
|
|
10
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
11
|
+
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { general } from '../../data';
|
|
14
|
+
import Field from '../FieldComponent';
|
|
15
|
+
import SpecIcon from '../../SpecIcon';
|
|
16
|
+
var FormItem = _Form.Item;
|
|
17
|
+
|
|
18
|
+
var RenderItemGroup = function RenderItemGroup(props) {
|
|
19
|
+
var itemGroup = props.itemGroup,
|
|
20
|
+
_props$size = props.size,
|
|
21
|
+
size = _props$size === void 0 ? 'md' : _props$size,
|
|
22
|
+
_props$fieldStatus = props.fieldStatus,
|
|
23
|
+
fieldStatus = _props$fieldStatus === void 0 ? 'default' : _props$fieldStatus,
|
|
24
|
+
_props$fieldSize = props.fieldSize,
|
|
25
|
+
fieldSize = _props$fieldSize === void 0 ? 'middle' : _props$fieldSize,
|
|
26
|
+
displayLayout = props.displayLayout,
|
|
27
|
+
form = props.form,
|
|
28
|
+
doUpdateFormFields = props.doUpdateFormFields,
|
|
29
|
+
_props$layout = props.layout,
|
|
30
|
+
layout = _props$layout === void 0 ? "horizontal" : _props$layout;
|
|
31
|
+
|
|
32
|
+
var setColSpan = function setColSpan(display, modalSize) {
|
|
33
|
+
if (_typeof(display) === 'object' || display === 'block' || modalSize === 'xs' || modalSize === 'sm') {
|
|
34
|
+
return 24;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (modalSize === 'lg' || modalSize === 'xlg') {
|
|
38
|
+
return 8;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return 12;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var updateFormFields = function updateFormFields() {
|
|
45
|
+
// if (newVal) form && form.setFieldsValue({ ...newVal })
|
|
46
|
+
if (doUpdateFormFields) doUpdateFormFields(); // 用于触发更新表单实例赋值
|
|
47
|
+
}; // useEffect(() => {
|
|
48
|
+
// // updateFormFields()
|
|
49
|
+
// }, [form])
|
|
50
|
+
// 渲染隐藏指定控件
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
var itemIsHide = function itemIsHide(isHide, getFieldsValue, FormInstance) {
|
|
54
|
+
if (typeof isHide === 'function') {
|
|
55
|
+
return isHide(getFieldsValue, FormInstance, fieldStatus);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return isHide || false;
|
|
59
|
+
}; // 渲染表单控件
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
var renderFormField = function renderFormField(field) {
|
|
63
|
+
var componentStyle = field.componentStyle,
|
|
64
|
+
extra = field.extra,
|
|
65
|
+
preExtra = field.preExtra; // 当前可传参的配置值
|
|
66
|
+
// 带前缀或后缀控件渲染
|
|
67
|
+
|
|
68
|
+
if (preExtra || extra) {
|
|
69
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, preExtra ? preExtra(field, form) : '', /*#__PURE__*/React.createElement(FormItem, {
|
|
70
|
+
noStyle: true,
|
|
71
|
+
rules: field.rules || (field.fieldOptions ? field.fieldOptions.rules : []),
|
|
72
|
+
name: field.filedName
|
|
73
|
+
}, /*#__PURE__*/React.createElement(Field, Object.assign({}, field, {
|
|
74
|
+
onChange: function onChange(eOrValue) {
|
|
75
|
+
updateFormFields();
|
|
76
|
+
|
|
77
|
+
for (var _len = arguments.length, otherParams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
78
|
+
otherParams[_key - 1] = arguments[_key];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (field.onChange) field.onChange.apply(field, [eOrValue].concat(otherParams));
|
|
82
|
+
},
|
|
83
|
+
fieldStatus: field.fieldStatus || fieldStatus,
|
|
84
|
+
size: field.protoConfig && field.protoConfig.size || field.size || fieldSize,
|
|
85
|
+
style: componentStyle || Object.assign({}, general.formItemStyle.wide)
|
|
86
|
+
}))), extra ? extra(field, form) : '');
|
|
87
|
+
} else {
|
|
88
|
+
return /*#__PURE__*/React.createElement(Field, Object.assign({}, field, {
|
|
89
|
+
onChange: function onChange(eOrValue) {
|
|
90
|
+
// let updateValue = val
|
|
91
|
+
// if (field.type === 'input' || field.type === 'textarea' || field.type === 'radio' || field.type === 'password') {
|
|
92
|
+
// updateValue = val.target.value
|
|
93
|
+
// }
|
|
94
|
+
// updateFormFields({ [field.filedName]: updateValue })
|
|
95
|
+
updateFormFields(); // if (field.onChange) field.onChange(val, form)
|
|
96
|
+
|
|
97
|
+
for (var _len2 = arguments.length, otherParams = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
98
|
+
otherParams[_key2 - 1] = arguments[_key2];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (field.onChange) field.onChange.apply(field, [eOrValue].concat(otherParams));
|
|
102
|
+
},
|
|
103
|
+
fieldStatus: field.fieldStatus || fieldStatus,
|
|
104
|
+
size: field.protoConfig && field.protoConfig.size || field.size || fieldSize,
|
|
105
|
+
style: componentStyle || Object.assign({}, general.formItemStyle.wide)
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
var renderColFormItem = function renderColFormItem(item, index, formLayout) {
|
|
111
|
+
var label = item.label,
|
|
112
|
+
description = item.description,
|
|
113
|
+
type = item.type,
|
|
114
|
+
customRender = item.customRender,
|
|
115
|
+
filedName = item.filedName; // 当前可传参的配置值
|
|
116
|
+
|
|
117
|
+
if (layout === "horizontal") {
|
|
118
|
+
return /*#__PURE__*/React.createElement(_Col, {
|
|
119
|
+
key: index,
|
|
120
|
+
span: item.colSpan || setColSpan(item.display, size)
|
|
121
|
+
}, /*#__PURE__*/React.createElement(FormItem, Object.assign({
|
|
122
|
+
name: type !== 'custom' && filedName,
|
|
123
|
+
className: fieldStatus === 'viewOnly' ? 'form-item-view-only' : '',
|
|
124
|
+
label: description ? /*#__PURE__*/React.createElement("span", null, label, /*#__PURE__*/React.createElement(_Tooltip, {
|
|
125
|
+
title: description
|
|
126
|
+
}, /*#__PURE__*/React.createElement(SpecIcon, {
|
|
127
|
+
name: "info"
|
|
128
|
+
}))) : label,
|
|
129
|
+
rules: item.preExtra || item.extra ? [] : item.rules || (item.fieldOptions ? item.fieldOptions.rules : []),
|
|
130
|
+
required: item.rules && item.rules.filter(function (rItem) {
|
|
131
|
+
return rItem.required;
|
|
132
|
+
}).length > 0
|
|
133
|
+
}, formLayout, item.protoFormItem), type === 'custom' && customRender ? customRender(form, Object.assign({}, item), fieldStatus) : renderFormField(Object.assign({}, item))));
|
|
134
|
+
} else {
|
|
135
|
+
return /*#__PURE__*/React.createElement(FormItem, Object.assign({
|
|
136
|
+
key: index,
|
|
137
|
+
name: type !== 'custom' && filedName,
|
|
138
|
+
className: fieldStatus === 'viewOnly' ? 'form-item-view-only' : '',
|
|
139
|
+
label: description ? /*#__PURE__*/React.createElement("span", null, label, /*#__PURE__*/React.createElement(_Tooltip, {
|
|
140
|
+
title: description
|
|
141
|
+
}, /*#__PURE__*/React.createElement(SpecIcon, {
|
|
142
|
+
name: "info"
|
|
143
|
+
}))) : label,
|
|
144
|
+
rules: item.rules || (item.fieldOptions ? item.fieldOptions.rules : [])
|
|
145
|
+
}, formLayout, item.protoFormItem), type === 'custom' && customRender ? customRender(form, Object.assign({}, item), fieldStatus) : renderFormField(Object.assign({}, item)));
|
|
146
|
+
}
|
|
147
|
+
}; // 渲染表单控件列表
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
var renderItemGroupNode = function renderItemGroupNode() {
|
|
151
|
+
return itemGroup.map(function (item, index) {
|
|
152
|
+
var label = item.label,
|
|
153
|
+
isHide = item.isHide,
|
|
154
|
+
type = item.type,
|
|
155
|
+
_item$display = item.display,
|
|
156
|
+
display = _item$display === void 0 ? 'side' : _item$display; // 当前可传参的配置值
|
|
157
|
+
|
|
158
|
+
var formLayout = {}; // if (displayLayout) {
|
|
159
|
+
// // 如果未配置,则使用以下配置值
|
|
160
|
+
// formLayout = { ...displayLayout }
|
|
161
|
+
// }
|
|
162
|
+
// 优先级 displayLayout.side > displayLayout > general
|
|
163
|
+
// 优先级:若有displayLayout.block 则直接使用 general > displayLayout
|
|
164
|
+
|
|
165
|
+
formLayout = (displayLayout === null || displayLayout === void 0 ? void 0 : displayLayout.side) || ((displayLayout === null || displayLayout === void 0 ? void 0 : displayLayout.block) ? general.modalSize[size].formLayout : !displayLayout || JSON.stringify(displayLayout) === '{}' ? general.modalSize[size].formLayout : displayLayout);
|
|
166
|
+
|
|
167
|
+
if (item.hasOwnProperty('display')) {
|
|
168
|
+
if (typeof display === 'string') {
|
|
169
|
+
if (display === 'block') {
|
|
170
|
+
formLayout = (displayLayout === null || displayLayout === void 0 ? void 0 : displayLayout.block) || general.modalSize[size].formBlockLayout;
|
|
171
|
+
} else {// 使用默认
|
|
172
|
+
// formLayout = displayLayout?.side || (displayLayout?.block ? general.modalSize[size].formLayout : displayLayout) || general.modalSize[size].formLayout
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
formLayout = item.display; // 对象类型传值如: {labelCol: {span: 3},wrapperCol: {span: 8}} 优先级最高
|
|
176
|
+
}
|
|
177
|
+
} // 当布局为 'vertical'或'inline'时,不配置栅格结构
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
if (layout !== 'horizontal') {
|
|
181
|
+
formLayout = {};
|
|
182
|
+
} // title标题或html渲染
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
if (type === 'title' || type === 'html') {
|
|
186
|
+
return /*#__PURE__*/React.createElement(FormItem, {
|
|
187
|
+
key: index,
|
|
188
|
+
noStyle: true,
|
|
189
|
+
shouldUpdate: true
|
|
190
|
+
}, function (FormInstance) {
|
|
191
|
+
var _a; // isHide 返回为true则隐藏当前控件
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
return !itemIsHide(isHide, FormInstance.getFieldValue(), FormInstance) ? /*#__PURE__*/React.createElement(_Col, {
|
|
195
|
+
span: item.colSpan || 24
|
|
196
|
+
}, type === 'title' ? /*#__PURE__*/React.createElement("h3", Object.assign({
|
|
197
|
+
className: "modalPanelTitle ".concat((_a = item === null || item === void 0 ? void 0 : item.protoConfig) === null || _a === void 0 ? void 0 : _a.className)
|
|
198
|
+
}, item.protoConfig), label) : label) : /*#__PURE__*/React.createElement(React.Fragment, null, null);
|
|
199
|
+
});
|
|
200
|
+
} // 判断是否强制重新渲染表单
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
if (item.protoFormItem && item.protoFormItem.shouldUpdate) {
|
|
204
|
+
return /*#__PURE__*/React.createElement(FormItem, {
|
|
205
|
+
key: index,
|
|
206
|
+
noStyle: true,
|
|
207
|
+
shouldUpdate: item.protoFormItem.shouldUpdate
|
|
208
|
+
}, function (FormInstance) {
|
|
209
|
+
// isHide 返回为true则隐藏当前控件
|
|
210
|
+
return !itemIsHide(isHide, FormInstance.getFieldValue(), FormInstance) ? renderColFormItem(item, index, formLayout) : null;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return renderColFormItem(item, index, formLayout);
|
|
215
|
+
});
|
|
216
|
+
}; // itemGroup = Array 则按以下结构渲染
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
if (itemGroup && Array.isArray(itemGroup)) {
|
|
220
|
+
// 布局配置为'vertical或inline'
|
|
221
|
+
if (layout !== 'horizontal') {
|
|
222
|
+
return renderItemGroupNode();
|
|
223
|
+
} // 布局配置为horizontal
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
return /*#__PURE__*/React.createElement(_Row, null, renderItemGroupNode());
|
|
227
|
+
}
|
|
228
|
+
/* itemGroup = ReactNode则直接返回 */
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
return itemGroup;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export default RenderItemGroup;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface UploaderProps {
|
|
3
|
+
extraExt?: string;
|
|
4
|
+
accept?: string;
|
|
5
|
+
fileList?: any[];
|
|
6
|
+
fileType?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
isOnly?: boolean;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
onChange?: (file?: any) => void;
|
|
11
|
+
value?: any;
|
|
12
|
+
size?: number;
|
|
13
|
+
modalSize?: string;
|
|
14
|
+
onPreview?: (file?: any) => any;
|
|
15
|
+
beforeUpload?: (file: any, fileList: any) => any;
|
|
16
|
+
limit?: number;
|
|
17
|
+
modalConfig?: any;
|
|
18
|
+
modalZIndex?: number;
|
|
19
|
+
}
|
|
20
|
+
declare const Uploader: React.ForwardRefExoticComponent<UploaderProps & React.RefAttributes<unknown>>;
|
|
21
|
+
export default Uploader;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import "antd/es/upload/style";
|
|
2
|
+
import _Upload from "antd/es/upload";
|
|
3
|
+
import "antd/es/button/style";
|
|
4
|
+
import _Button from "antd/es/button";
|
|
5
|
+
import "antd/es/message/style";
|
|
6
|
+
import _message from "antd/es/message";
|
|
7
|
+
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
|
|
10
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
|
|
12
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
13
|
+
|
|
14
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
15
|
+
|
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
+
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
|
|
20
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
+
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
+
|
|
24
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
25
|
+
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
+
|
|
28
|
+
import { __awaiter } from "tslib";
|
|
29
|
+
import React, { useMemo, useState, useCallback, useEffect } from 'react';
|
|
30
|
+
import { PlusOutlined } from '@ant-design/icons';
|
|
31
|
+
import { getAccept, getBase64 } from "./util"; // import RcUpload from 'rc-upload';
|
|
32
|
+
|
|
33
|
+
import StandardModal from "../../StandardModal";
|
|
34
|
+
var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
35
|
+
var accept = props.accept,
|
|
36
|
+
extraExt = props.extraExt,
|
|
37
|
+
fileType = props.fileType,
|
|
38
|
+
className = props.className,
|
|
39
|
+
isOnly = props.isOnly,
|
|
40
|
+
children = props.children,
|
|
41
|
+
onChange = props.onChange,
|
|
42
|
+
value = props.value,
|
|
43
|
+
_props$size = props.size,
|
|
44
|
+
size = _props$size === void 0 ? 2 * 1024 * 1024 : _props$size,
|
|
45
|
+
_props$modalSize = props.modalSize,
|
|
46
|
+
modalSize = _props$modalSize === void 0 ? 'md' : _props$modalSize,
|
|
47
|
+
_props$modalConfig = props.modalConfig,
|
|
48
|
+
modalConfig = _props$modalConfig === void 0 ? {} : _props$modalConfig,
|
|
49
|
+
onPreview = props.onPreview,
|
|
50
|
+
beforeUpload = props.beforeUpload,
|
|
51
|
+
limit = props.limit; // 图片预览数据
|
|
52
|
+
|
|
53
|
+
var _useState = useState({
|
|
54
|
+
visible: false,
|
|
55
|
+
url: ''
|
|
56
|
+
}),
|
|
57
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
58
|
+
showConfig = _useState2[0],
|
|
59
|
+
setShowConfig = _useState2[1]; // 用于展示的缩略图
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
var _useState3 = useState([]),
|
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
+
fileList = _useState4[0],
|
|
65
|
+
setFileList = _useState4[1];
|
|
66
|
+
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
if (!value) {
|
|
69
|
+
setFileList([]);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var S4 = function S4() {
|
|
74
|
+
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
if (Object.prototype.toString.call(value) === '[object Array]') {
|
|
78
|
+
setFileList(value.map(function (file, index) {
|
|
79
|
+
file.uid = file.uid || "".concat(S4(), "-").concat(S4());
|
|
80
|
+
file.url = file.downloadUrl || file.url;
|
|
81
|
+
file.status = 'done';
|
|
82
|
+
return file;
|
|
83
|
+
}));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (Object.prototype.toString.call(value) === '[object Object]') {
|
|
88
|
+
setFileList([Object.assign({
|
|
89
|
+
uid: "".concat(S4(), "-").concat(S4()),
|
|
90
|
+
url: value.downloadUrl || value.url,
|
|
91
|
+
status: 'done'
|
|
92
|
+
}, value)]);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (Object.prototype.toString.call(value) === '[object String]') {
|
|
97
|
+
setFileList([{
|
|
98
|
+
uid: "".concat(S4(), "-").concat(S4()),
|
|
99
|
+
url: value,
|
|
100
|
+
name: '附件',
|
|
101
|
+
status: 'done'
|
|
102
|
+
}]);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}, [value]);
|
|
106
|
+
var splitAccept = useMemo(function () {
|
|
107
|
+
var res = getAccept(fileType);
|
|
108
|
+
|
|
109
|
+
if (extraExt) {
|
|
110
|
+
res = res + ',' + extraExt;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (accept) {
|
|
114
|
+
res = res + ',' + accept;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return res;
|
|
118
|
+
}, [fileType, extraExt]); // 点击文件链接或预览图标时的回调
|
|
119
|
+
|
|
120
|
+
var handlePreview = useCallback(function (file) {
|
|
121
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
122
|
+
var res;
|
|
123
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
124
|
+
while (1) {
|
|
125
|
+
switch (_context.prev = _context.next) {
|
|
126
|
+
case 0:
|
|
127
|
+
if (!(!file.url && !file.preview)) {
|
|
128
|
+
_context.next = 5;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_context.next = 3;
|
|
133
|
+
return getBase64(file.originFileObj);
|
|
134
|
+
|
|
135
|
+
case 3:
|
|
136
|
+
res = _context.sent;
|
|
137
|
+
|
|
138
|
+
if (res && res.status === 'success') {
|
|
139
|
+
file.preview = res.url;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
case 5:
|
|
143
|
+
setShowConfig({
|
|
144
|
+
visible: true,
|
|
145
|
+
url: file.url || file.preview
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
case 6:
|
|
149
|
+
case "end":
|
|
150
|
+
return _context.stop();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}, _callee);
|
|
154
|
+
}));
|
|
155
|
+
}, [setShowConfig]); // 检查文件是否规范
|
|
156
|
+
|
|
157
|
+
var handleCheck = useCallback(function (file) {
|
|
158
|
+
var isLtSize = file.size < size;
|
|
159
|
+
|
|
160
|
+
if (!isLtSize) {
|
|
161
|
+
_message.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7".concat(Math.round(size / 1024 / 1024 * 100) / 100, "MB!"));
|
|
162
|
+
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return true;
|
|
167
|
+
}, [fileType, size]);
|
|
168
|
+
var handleChange = useCallback(function (res) {
|
|
169
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
170
|
+
var isOk, result, list;
|
|
171
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
172
|
+
while (1) {
|
|
173
|
+
switch (_context2.prev = _context2.next) {
|
|
174
|
+
case 0:
|
|
175
|
+
if (!(res.file.status === 'removed')) {
|
|
176
|
+
_context2.next = 4;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
setFileList(res.fileList);
|
|
181
|
+
onChange && onChange(isOnly ? res.fileList[0] && res.fileList[0].originFileObj : res.fileList);
|
|
182
|
+
return _context2.abrupt("return");
|
|
183
|
+
|
|
184
|
+
case 4:
|
|
185
|
+
isOk = handleCheck(res.file);
|
|
186
|
+
|
|
187
|
+
if (isOk) {
|
|
188
|
+
list = res.fileList.map(function (file) {
|
|
189
|
+
if (!file.url) {
|
|
190
|
+
file.url = file.thumbUrl;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return file;
|
|
194
|
+
});
|
|
195
|
+
result = _toConsumableArray(list);
|
|
196
|
+
setFileList(list);
|
|
197
|
+
onChange && onChange(isOnly ? result[0] && result[0].originFileObj : result);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
case 6:
|
|
201
|
+
case "end":
|
|
202
|
+
return _context2.stop();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}, _callee2);
|
|
206
|
+
}));
|
|
207
|
+
}, [isOnly, handleCheck]); // 渲染预览窗口
|
|
208
|
+
|
|
209
|
+
var renderPreviewComponent = useMemo(function () {
|
|
210
|
+
if (fileType === 'image' || fileType === 'svg') {
|
|
211
|
+
var visible = showConfig.visible,
|
|
212
|
+
url = showConfig.url;
|
|
213
|
+
return /*#__PURE__*/React.createElement(StandardModal, Object.assign({
|
|
214
|
+
visible: visible,
|
|
215
|
+
hideFooter: true,
|
|
216
|
+
onCancel: function onCancel() {
|
|
217
|
+
return setShowConfig({
|
|
218
|
+
visible: false,
|
|
219
|
+
url: ''
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
size: modalSize
|
|
223
|
+
}, modalConfig), /*#__PURE__*/React.createElement("div", {
|
|
224
|
+
style: {
|
|
225
|
+
textAlign: 'center'
|
|
226
|
+
}
|
|
227
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
228
|
+
style: {
|
|
229
|
+
maxWidth: '100%'
|
|
230
|
+
},
|
|
231
|
+
src: url,
|
|
232
|
+
alt: ""
|
|
233
|
+
})));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return null;
|
|
237
|
+
}, [fileType, showConfig]);
|
|
238
|
+
var renderChildrenComponent = useMemo(function () {
|
|
239
|
+
var renderButton = function renderButton() {
|
|
240
|
+
if (fileType === 'image' || fileType === 'svg') {
|
|
241
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
242
|
+
className: 'spec-uploader-control'
|
|
243
|
+
}, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
className: "ant-upload-text"
|
|
245
|
+
}, "\u70B9\u51FB\u9009\u62E9"));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return /*#__PURE__*/React.createElement(_Button, {
|
|
249
|
+
className: 'spec-uploader-button'
|
|
250
|
+
}, /*#__PURE__*/React.createElement(PlusOutlined, null), "\u70B9\u51FB\u9009\u62E9");
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
if (children) {
|
|
254
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, " ", children, " ");
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (isOnly && fileList.length === 1 || limit && fileList.length === limit) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, renderButton());
|
|
262
|
+
}, [fileType, isOnly, children, fileList, limit]);
|
|
263
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Upload, Object.assign({}, props, {
|
|
264
|
+
ref: ref,
|
|
265
|
+
accept: splitAccept,
|
|
266
|
+
fileList: fileList,
|
|
267
|
+
listType: fileType === 'image' || fileType === 'svg' ? 'picture-card' : 'text',
|
|
268
|
+
className: "spec-uploader ".concat(className),
|
|
269
|
+
onPreview: onPreview ? onPreview : fileType === 'image' || fileType === 'svg' ? handlePreview : function () {},
|
|
270
|
+
beforeUpload: beforeUpload ? beforeUpload : function () {
|
|
271
|
+
return false;
|
|
272
|
+
},
|
|
273
|
+
onChange: handleChange
|
|
274
|
+
}), renderChildrenComponent), renderPreviewComponent);
|
|
275
|
+
}); // as IUploader
|
|
276
|
+
|
|
277
|
+
export default Uploader;
|