@lingxiteam/ebe-utils 0.0.10 → 0.0.12
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/README.md +6 -0
- package/es/index.d.ts +11 -6
- package/es/index.js +63 -52
- package/es/node/babel/getAllImportFiles.d.ts +1 -1
- package/es/node/babel/getAllImportFiles.js +4 -4
- package/es/node/move.d.ts +1 -0
- package/es/node/move.js +21 -13
- package/lib/h5public/src/components/factory/package.json +4 -0
- package/lib/h5public/src/components/factory/src/BlockSelect/index.tsx +9 -1
- package/lib/h5public/src/components/factory/src/DynamicDataContainer/index.tsx +24 -5
- package/lib/h5public/src/components/factory/src/DynamicList/MySwipe/index.tsx +1 -1
- package/lib/h5public/src/hooks/usePageForm.ts +108 -4
- package/lib/h5public/src/utils/LcdpSpin/index.tsx +15 -3
- package/lib/h5public/src/utils/formUtils.ts +336 -0
- package/lib/node/babel/getAllImportFiles.d.ts +1 -1
- package/lib/node/babel/getAllImportFiles.js +3 -3
- package/lib/node/move.d.ts +1 -0
- package/lib/node/move.js +19 -8
- package/lib/pcpublic/src/components/common/PreviewFile/index.less +200 -0
- package/lib/pcpublic/src/components/common/PreviewFile/index.tsx +787 -0
- package/lib/pcpublic/src/components/common/PreviewFile/utils.ts +90 -0
- package/lib/pcpublic/src/components/pcfactory/package.json +4 -0
- package/lib/pcpublic/src/components/pcfactory/src/Audio/index.tsx +6 -6
- package/lib/pcpublic/src/components/pcfactory/src/Cascader/index.tsx +15 -0
- package/lib/pcpublic/src/components/pcfactory/src/Checkbox/index.tsx +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/index.tsx +301 -0
- package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/useDynamicDataContainer.ts +27 -0
- package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +1 -0
- package/lib/pcpublic/src/components/pcfactory/src/GridView/GridView.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/Img/assets/placeholder.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/Input/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/LoopList/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/PictureVerifyCode/assets/placeholder.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/PictureVerifyCode/index.tsx +6 -6
- package/lib/pcpublic/src/components/pcfactory/src/QuillEditor/index.tsx +11 -0
- package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/components/ReactRender.tsx +5 -1
- package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/constant.ts +36 -0
- package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/index.tsx +28 -16
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +12 -5
- package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +65 -39
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/default.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/js.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/pdf.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/ppt.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/txt.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/word.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/xls.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/zip.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/index.tsx +11 -1
- package/lib/pcpublic/src/components/pcfactory/src/SuperSelect/ComSelect.tsx +1 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +8 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +4 -4
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +91 -34
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +22 -11
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +51 -8
- package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +28 -6
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/bodyCell.d.ts +22 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/contentStyle.d.ts +41 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +129 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +37 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +301 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +83 -31
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +119 -0
- package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +8 -3
- package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +4 -1
- package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +12 -1
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +28 -3
- package/lib/pcpublic/src/components/pcfactory/src/VerificationCode/assets/placeholder.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/VerificationCode/index.tsx +6 -6
- package/lib/pcpublic/src/components/pcfactory/src/VideoPlayer/index.tsx +12 -12
- package/lib/pcpublic/src/components/pcfactory/src/View/index.tsx +18 -4
- package/lib/pcpublic/src/components/pcfactory/src/index.component.ts +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +6 -1
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +4 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Input.less +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/InputNumber.less +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Table.less +5 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +29 -28
- package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +36 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +29 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +18 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +10 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +10 -5
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +46 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +44 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +1 -0
- package/lib/pcpublic/src/utils/formUtils.ts +458 -0
- package/lib/public/src/components/WaterMark/index.tsx +1 -1
- package/lib/public/src/services/api/index.ts +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const PREVIEW_MODE = {
|
|
2
|
+
PPT: 'IMG_PPT',
|
|
3
|
+
IMG: 'IMG',
|
|
4
|
+
PDF: 'PDF',
|
|
5
|
+
ZIP: 'ZIP',
|
|
6
|
+
VIDEO: 'VIDEO',
|
|
7
|
+
TXT: 'TXT',
|
|
8
|
+
IFRAME: 'IFRAME',
|
|
9
|
+
HTML: 'HTML',
|
|
10
|
+
};
|
|
11
|
+
// 是否可以放大缩小
|
|
12
|
+
export const CAN_SCALE = [
|
|
13
|
+
PREVIEW_MODE.PPT,
|
|
14
|
+
PREVIEW_MODE.IMG,
|
|
15
|
+
PREVIEW_MODE.PDF,
|
|
16
|
+
PREVIEW_MODE.ZIP,
|
|
17
|
+
];
|
|
18
|
+
// 先判断是否可以进行本地预览,若不可以则调用后端接口判断
|
|
19
|
+
// 部分格式后端可能不支持预览,或者本地可以直接预览的,不调用查询接口,直接转换预览
|
|
20
|
+
export const LOCAL_PREVIEW = [
|
|
21
|
+
{
|
|
22
|
+
previewMode: PREVIEW_MODE.VIDEO,
|
|
23
|
+
mimeTypeReg: /^video\/(mp4|webm|ogg|x-ms-wmv|quicktime)$/i,
|
|
24
|
+
suffix: /\.(mp4|mov)$/i,
|
|
25
|
+
// 平台定制预览是否支持跨域地址
|
|
26
|
+
cors: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
previewMode: PREVIEW_MODE.IMG,
|
|
30
|
+
mimeTypeReg: /^image\/(bmp|gif|jpeg|jpg|png|svg\+xml|tiff|webp|x-icon)$/i,
|
|
31
|
+
suffix: /\.(jpg|jpeg|png|svg|heic|ico|bmp|tiff|tif)$/i,
|
|
32
|
+
cors: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
previewMode: PREVIEW_MODE.PDF,
|
|
36
|
+
mimeTypeReg: /^application\/pdf$/i,
|
|
37
|
+
suffix: /\.pdf$/i,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
previewMode: PREVIEW_MODE.TXT,
|
|
41
|
+
mimeTypeReg:
|
|
42
|
+
/^(application|text)\/(json|javascript|x-javascript|plain|x-sh)$/i,
|
|
43
|
+
suffix: /\.(less|scss|lock|ts|txt|js|jsx)$/i,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
previewMode: PREVIEW_MODE.ZIP,
|
|
47
|
+
mimeTypeReg: /^(application\/zip)$/i,
|
|
48
|
+
suffix: /\.zip$/i,
|
|
49
|
+
cors: true,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export const parseFileInfo = (
|
|
54
|
+
fileInfo: {
|
|
55
|
+
fileId?: string;
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
},
|
|
58
|
+
serverFileInfo: {
|
|
59
|
+
previewMode: string;
|
|
60
|
+
fileId?: string;
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
},
|
|
63
|
+
) => {
|
|
64
|
+
if (!fileInfo) return fileInfo;
|
|
65
|
+
const { previewMode } = serverFileInfo || {};
|
|
66
|
+
const newFileInfo = { ...(serverFileInfo || {}), ...fileInfo };
|
|
67
|
+
switch (previewMode) {
|
|
68
|
+
case PREVIEW_MODE.PPT: {
|
|
69
|
+
if (
|
|
70
|
+
newFileInfo?.previewMode === PREVIEW_MODE.PPT &&
|
|
71
|
+
newFileInfo?.fileIdList.length > 0
|
|
72
|
+
) {
|
|
73
|
+
newFileInfo.totalPage = newFileInfo?.fileIdList.length;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
default: {
|
|
78
|
+
// 部分类型如doc,docx,服务端处理后会返回转换后的文件ID
|
|
79
|
+
if (!serverFileInfo?.serverFileId && serverFileInfo?.fileId) {
|
|
80
|
+
newFileInfo.serverFileId = serverFileInfo?.fileId;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return newFileInfo;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// 判断是否是网络地址,是的话不调用后端接口预览
|
|
89
|
+
export const isUrlFormat = (id: string) =>
|
|
90
|
+
/^https?:\/\/[^\s/$.?#].[^\s]*$/i.test(id);
|
|
@@ -146,16 +146,16 @@ const Audio: React.FC<MyAudioProps> = forwardRef((props, ref) => {
|
|
|
146
146
|
if (streamType === 'fileCode') {
|
|
147
147
|
// 选择的文件资源
|
|
148
148
|
if (fileCode) {
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
(async () => {
|
|
150
|
+
try {
|
|
151
151
|
const url = await engineApis?.service?.getAppFileUrlByFileCode(
|
|
152
152
|
fileCode,
|
|
153
153
|
);
|
|
154
154
|
setAudioUrl(url);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
155
|
+
} catch (e) {
|
|
156
|
+
console.error(`${getLocale?.('Audio.warning')}:${e}`);
|
|
157
|
+
}
|
|
158
|
+
})();
|
|
159
159
|
} else {
|
|
160
160
|
setAudioUrl('');
|
|
161
161
|
}
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
useCommonImperativeHandle,
|
|
8
8
|
useListenProps,
|
|
9
9
|
} from '../utils';
|
|
10
|
+
import EmptyComp from '../utils/Empty';
|
|
11
|
+
import { useLocale } from '../utils/hooks/useLocale';
|
|
10
12
|
import { renderCommonList } from '../utils/renderReadOnly';
|
|
11
13
|
|
|
12
14
|
const CASCADER_WRAPPER_CLASSNAME = 'ued-cascader-wrap';
|
|
@@ -74,6 +76,7 @@ export interface MyCascaderProps {
|
|
|
74
76
|
tipSize?: string; // 文字提示
|
|
75
77
|
tipWidth?: string; // 提示自定义的宽度
|
|
76
78
|
tipHeight?: string; // 提示自定义的高度
|
|
79
|
+
getEngineApis?: any;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
const prefixCls = 'cascader';
|
|
@@ -153,8 +156,13 @@ const MyCascader: React.FC<MyCascaderProps> = forwardRef((props, ref) => {
|
|
|
153
156
|
tipSize,
|
|
154
157
|
tipWidth,
|
|
155
158
|
tipHeight,
|
|
159
|
+
getEngineApis,
|
|
156
160
|
...restProps
|
|
157
161
|
} = props;
|
|
162
|
+
const engineApis = getEngineApis?.() || {};
|
|
163
|
+
|
|
164
|
+
const { dataState } = engineApis;
|
|
165
|
+
const { getLocale } = useLocale(engineApis);
|
|
158
166
|
|
|
159
167
|
const customStyle = restProps.style || {};
|
|
160
168
|
const dropdownClassName = `dropdownClassName_${compId}`;
|
|
@@ -342,6 +350,13 @@ const MyCascader: React.FC<MyCascaderProps> = forwardRef((props, ref) => {
|
|
|
342
350
|
style={restCusStyles}
|
|
343
351
|
multiple={multiple}
|
|
344
352
|
displayRender={renderDisplay}
|
|
353
|
+
notFoundContent={
|
|
354
|
+
<EmptyComp
|
|
355
|
+
getLocale={getLocale}
|
|
356
|
+
dataState={dataState}
|
|
357
|
+
clsName="pcfactory-empty-small"
|
|
358
|
+
/>
|
|
359
|
+
}
|
|
345
360
|
showSearch={
|
|
346
361
|
showSearch
|
|
347
362
|
? {
|
|
@@ -119,7 +119,7 @@ const MyCheckbox = React.forwardRef<any, MyCheckboxProps>((props, ref) => {
|
|
|
119
119
|
ref={formFieldsRef}
|
|
120
120
|
rules={finalRules}
|
|
121
121
|
handleFormValue={(value) => {
|
|
122
|
-
if (value === 'false') {
|
|
122
|
+
if (String(value).trim() === 'false') {
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
125
|
return value;
|
|
@@ -127,7 +127,7 @@ const MyCheckbox = React.forwardRef<any, MyCheckboxProps>((props, ref) => {
|
|
|
127
127
|
>
|
|
128
128
|
<CheckboxItem
|
|
129
129
|
{...rProps}
|
|
130
|
-
value={value === 'false' ? false : value}
|
|
130
|
+
value={String(value).trim() === 'false' ? false : value}
|
|
131
131
|
onChange={(e) => {
|
|
132
132
|
if (onChange) {
|
|
133
133
|
onChange(e.target.checked);
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DynamicDataFieldItem,
|
|
3
|
+
DynamicDataType,
|
|
4
|
+
LingxiForwardRef,
|
|
5
|
+
} from '@lingxiteam/types';
|
|
6
|
+
import { Form, FormInstance, Spin } from 'antd';
|
|
7
|
+
import {
|
|
8
|
+
CSSProperties,
|
|
9
|
+
useEffect,
|
|
10
|
+
useImperativeHandle,
|
|
11
|
+
useMemo,
|
|
12
|
+
useRef,
|
|
13
|
+
useState,
|
|
14
|
+
} from 'react';
|
|
15
|
+
import { DynamicDataContext, DynamicDataProvider } from '../utils';
|
|
16
|
+
import { useDynamicDataContainer } from './useDynamicDataContainer';
|
|
17
|
+
|
|
18
|
+
type RuleParameter = {
|
|
19
|
+
paramId: string;
|
|
20
|
+
valueCode?: string;
|
|
21
|
+
originValueCode?: string;
|
|
22
|
+
};
|
|
23
|
+
export interface DynamicDataContainerProps {
|
|
24
|
+
className: string;
|
|
25
|
+
style: CSSProperties;
|
|
26
|
+
'data-compid'?: string;
|
|
27
|
+
engineRule?: Array<Array<RuleParameter>>;
|
|
28
|
+
name: string;
|
|
29
|
+
scene?: 'edit' | 'readonly';
|
|
30
|
+
visible?: boolean;
|
|
31
|
+
boxSpace?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 编码
|
|
35
|
+
*/
|
|
36
|
+
dynamicCode: string;
|
|
37
|
+
onValuesChange?: (
|
|
38
|
+
formCode: string,
|
|
39
|
+
changedFieldName: string,
|
|
40
|
+
changedFieldValue: any,
|
|
41
|
+
allValues: Record<string, Record<string, any>>,
|
|
42
|
+
) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const DynamicDataContainer = LingxiForwardRef<any, DynamicDataContainerProps>(
|
|
46
|
+
(props, ref) => {
|
|
47
|
+
const {
|
|
48
|
+
className,
|
|
49
|
+
getEngineApis,
|
|
50
|
+
style = {},
|
|
51
|
+
engineRule,
|
|
52
|
+
$$componentItem,
|
|
53
|
+
name,
|
|
54
|
+
onValuesChange,
|
|
55
|
+
dynamicCode,
|
|
56
|
+
boxSpace,
|
|
57
|
+
} = props || {};
|
|
58
|
+
const engineApis = getEngineApis?.() || {};
|
|
59
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
60
|
+
const { service, dynamicDataUtils, renderDynamicPage } = engineApis;
|
|
61
|
+
const { dynamicData2DSL, diffChange } = dynamicDataUtils || {};
|
|
62
|
+
const formsRef = useRef<
|
|
63
|
+
Record<
|
|
64
|
+
string,
|
|
65
|
+
{
|
|
66
|
+
form: FormInstance;
|
|
67
|
+
validateFormAndScroll?: () => Promise<any>;
|
|
68
|
+
getFieldsValue?: FormInstance['getFieldsValue'];
|
|
69
|
+
setFieldsValue?: (values: any, refs: Record<string, any>) => void;
|
|
70
|
+
resetFields?: FormInstance['resetFields'];
|
|
71
|
+
setDisabled?: (v: boolean) => void;
|
|
72
|
+
setReadOnly?: (v: boolean) => void;
|
|
73
|
+
}
|
|
74
|
+
>
|
|
75
|
+
>({});
|
|
76
|
+
const [pageData, setPageData] = useState<any>();
|
|
77
|
+
const dynamicHelperRef = useRef<ReturnType<typeof dynamicData2DSL>>();
|
|
78
|
+
|
|
79
|
+
const { dynamicPageRef, staticAttrKeys } = useDynamicDataContainer({
|
|
80
|
+
dynamicHelper: dynamicHelperRef.current,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const getDynamicData = async (
|
|
84
|
+
rules: DynamicDataContainerProps['engineRule'],
|
|
85
|
+
) => {
|
|
86
|
+
try {
|
|
87
|
+
setLoading(true);
|
|
88
|
+
if (rules && rules?.length) {
|
|
89
|
+
const res = await service.batchMatchDynamicData({
|
|
90
|
+
terminalType: 'pc',
|
|
91
|
+
findDataDetail: true,
|
|
92
|
+
paramGroupList: rules,
|
|
93
|
+
});
|
|
94
|
+
if (res && typeof dynamicData2DSL === 'function') {
|
|
95
|
+
const dataHelper = dynamicData2DSL(
|
|
96
|
+
res as DynamicDataType[],
|
|
97
|
+
{ uid: $$componentItem.uid, name },
|
|
98
|
+
(
|
|
99
|
+
DSLCore,
|
|
100
|
+
dynamicData: DynamicDataType | DynamicDataFieldItem,
|
|
101
|
+
) => {
|
|
102
|
+
if ('dataId' in dynamicData) {
|
|
103
|
+
const node = DSLCore?.query?.(`Card_${dynamicData.dataId}`);
|
|
104
|
+
if (node && boxSpace) {
|
|
105
|
+
node?.setStyle?.({
|
|
106
|
+
margin: `0 0 ${boxSpace} 0`,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
setPageData(dataHelper.pageDSL);
|
|
113
|
+
dynamicHelperRef.current = dataHelper;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} finally {
|
|
117
|
+
setLoading(false);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
getDynamicData(engineRule);
|
|
123
|
+
}, [engineRule]);
|
|
124
|
+
|
|
125
|
+
const getDynamicFormValue = () => {
|
|
126
|
+
const allValues: Record<string, any> = {};
|
|
127
|
+
if (formsRef.current) {
|
|
128
|
+
Object.keys(formsRef.current).forEach((formCode) => {
|
|
129
|
+
const form = formsRef.current[formCode] || {};
|
|
130
|
+
allValues[formCode] = form?.getFieldsValue?.();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return allValues;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const resetFields = () => {
|
|
137
|
+
if (formsRef.current) {
|
|
138
|
+
const beforeData = getDynamicFormValue();
|
|
139
|
+
Object.keys(formsRef.current).forEach((formCode) => {
|
|
140
|
+
const form = formsRef.current[formCode] || {};
|
|
141
|
+
form?.resetFields?.();
|
|
142
|
+
});
|
|
143
|
+
const updateData = getDynamicFormValue();
|
|
144
|
+
const { event } = dynamicHelperRef.current || {};
|
|
145
|
+
diffChange(beforeData, updateData, (diff) => {
|
|
146
|
+
// 执行事件处理变更联动
|
|
147
|
+
event?.eval(diff.formCode, diff.changeFieldName);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const setFieldsValue = (
|
|
153
|
+
assignData: Record<string, unknown>,
|
|
154
|
+
format: boolean = true,
|
|
155
|
+
) => {
|
|
156
|
+
let formalFormData = assignData;
|
|
157
|
+
const { assign2FormData } = dynamicHelperRef.current || {};
|
|
158
|
+
if (format) {
|
|
159
|
+
// 解析赋值数据
|
|
160
|
+
formalFormData = assign2FormData?.(assignData) || {};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const beforeData = getDynamicFormValue();
|
|
164
|
+
if (formsRef.current) {
|
|
165
|
+
Object.keys(formsRef.current).forEach((formCode) => {
|
|
166
|
+
const form = formsRef.current[formCode] || {};
|
|
167
|
+
form?.setFieldsValue?.(
|
|
168
|
+
formalFormData[formCode] || {},
|
|
169
|
+
dynamicPageRef?.current?.sandboxContext?.refs,
|
|
170
|
+
);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const updateData = getDynamicFormValue();
|
|
174
|
+
const { event } = dynamicHelperRef.current || {};
|
|
175
|
+
|
|
176
|
+
diffChange(beforeData, updateData, (diff) => {
|
|
177
|
+
// 执行事件处理变更联动
|
|
178
|
+
event?.eval(diff.formCode, diff.changeFieldName);
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
useImperativeHandle(ref, () => ({
|
|
183
|
+
formCode: dynamicCode,
|
|
184
|
+
// 加载动态数据
|
|
185
|
+
setRules: (newRules: DynamicDataContainerProps['engineRule']) => {
|
|
186
|
+
return getDynamicData(newRules);
|
|
187
|
+
},
|
|
188
|
+
// 获取动态数据表单转换协议后的值
|
|
189
|
+
getFieldsValue: () => {
|
|
190
|
+
const allValues = getDynamicFormValue();
|
|
191
|
+
const { formData2Retrieve } = dynamicHelperRef.current || {};
|
|
192
|
+
return formData2Retrieve?.(allValues) || allValues;
|
|
193
|
+
},
|
|
194
|
+
// 获取动态数据表单原始值
|
|
195
|
+
getOriginValue: () => {
|
|
196
|
+
return getDynamicFormValue();
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
resetFields,
|
|
200
|
+
// 校验表单并取值
|
|
201
|
+
validateFormAndScroll: async () => {
|
|
202
|
+
const allValues: Record<string, any> = {};
|
|
203
|
+
if (formsRef.current) {
|
|
204
|
+
const validatePromiseList = Object.keys(formsRef.current).map(
|
|
205
|
+
(formCode) => {
|
|
206
|
+
const form = formsRef.current[formCode] || {};
|
|
207
|
+
return form?.validateFormAndScroll?.().then((res: any) => {
|
|
208
|
+
allValues[formCode] = res;
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
await Promise.all(validatePromiseList);
|
|
213
|
+
const { formData2Retrieve } = dynamicHelperRef.current || {};
|
|
214
|
+
return formData2Retrieve?.(allValues) || allValues;
|
|
215
|
+
}
|
|
216
|
+
return undefined;
|
|
217
|
+
},
|
|
218
|
+
setFieldsValue: (assignData: Record<string, unknown>) => {
|
|
219
|
+
return setFieldsValue(assignData, true);
|
|
220
|
+
},
|
|
221
|
+
}));
|
|
222
|
+
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (formsRef.current) {
|
|
225
|
+
Object.keys(formsRef.current).forEach((key) => {
|
|
226
|
+
const form = formsRef.current[key];
|
|
227
|
+
if (form?.setReadOnly) {
|
|
228
|
+
form.setReadOnly(props.scene === 'readonly');
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}, [props.scene]);
|
|
233
|
+
|
|
234
|
+
const providerValue: DynamicDataContext = useMemo(() => {
|
|
235
|
+
return {
|
|
236
|
+
onFormChange: (formName, changedFieldName, changedFieldValue) => {
|
|
237
|
+
const { formData2Retrieve, event } = dynamicHelperRef.current || {};
|
|
238
|
+
const allValues = getDynamicFormValue();
|
|
239
|
+
event?.eval(formName, changedFieldName);
|
|
240
|
+
if (typeof onValuesChange === 'function') {
|
|
241
|
+
onValuesChange(
|
|
242
|
+
formName,
|
|
243
|
+
changedFieldName,
|
|
244
|
+
changedFieldValue,
|
|
245
|
+
formData2Retrieve?.(allValues) || allValues,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
_innerDynamicDataContainer: true,
|
|
250
|
+
get formsRefMap() {
|
|
251
|
+
return formsRef.current;
|
|
252
|
+
},
|
|
253
|
+
updateFormChildRef: (formCode, formRef) => {
|
|
254
|
+
if (props.scene === 'readonly') {
|
|
255
|
+
// 只读时每次上报设置表单控件为只读状态
|
|
256
|
+
formRef?.setReadOnly(props?.scene === 'readonly');
|
|
257
|
+
}
|
|
258
|
+
formsRef.current[formCode] = formRef;
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
form: {
|
|
262
|
+
getFieldsValue: () => getDynamicFormValue(),
|
|
263
|
+
resetFields,
|
|
264
|
+
setFieldsValue: (assignData: Record<string, unknown>) => {
|
|
265
|
+
return setFieldsValue(assignData, false);
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
useWatch: (formCode: string, fieldCode: string) => {
|
|
269
|
+
return Form.useWatch(fieldCode, formsRef.current[formCode]?.form);
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}, [props.scene]);
|
|
274
|
+
|
|
275
|
+
const dynamicStyle = {
|
|
276
|
+
...(style || {}),
|
|
277
|
+
display: props?.visible ? undefined : 'none',
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<div
|
|
282
|
+
className={className}
|
|
283
|
+
data-compid={props?.['data-compid']}
|
|
284
|
+
style={dynamicStyle}
|
|
285
|
+
>
|
|
286
|
+
<Spin spinning={loading}>
|
|
287
|
+
<DynamicDataProvider value={providerValue}>
|
|
288
|
+
{pageData &&
|
|
289
|
+
renderDynamicPage(
|
|
290
|
+
pageData,
|
|
291
|
+
{ uid: $$componentItem.uid },
|
|
292
|
+
{ ref: dynamicPageRef, staticAttrKeys },
|
|
293
|
+
)}
|
|
294
|
+
</DynamicDataProvider>
|
|
295
|
+
</Spin>
|
|
296
|
+
</div>
|
|
297
|
+
);
|
|
298
|
+
},
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
export default DynamicDataContainer;
|
package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/useDynamicDataContainer.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useDynamicDataContainer = ({
|
|
4
|
+
dynamicHelper,
|
|
5
|
+
}: {
|
|
6
|
+
dynamicHelper?: any;
|
|
7
|
+
}) => {
|
|
8
|
+
const dynamicPageRef = useRef<any>(null);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
dynamicHelper?.updateSandboxContext(
|
|
12
|
+
() => dynamicPageRef.current?.sandboxContext,
|
|
13
|
+
);
|
|
14
|
+
}, [dynamicHelper, dynamicPageRef.current]);
|
|
15
|
+
|
|
16
|
+
const staticAttrKeys = useMemo(() => {
|
|
17
|
+
if (dynamicHelper?.event) {
|
|
18
|
+
return dynamicHelper?.event?.staticAttrKeys || [];
|
|
19
|
+
}
|
|
20
|
+
return [];
|
|
21
|
+
}, [dynamicHelper]);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
dynamicPageRef,
|
|
25
|
+
staticAttrKeys,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -10,8 +10,8 @@ import React, {
|
|
|
10
10
|
useRef,
|
|
11
11
|
useState,
|
|
12
12
|
} from 'react';
|
|
13
|
-
import { IconCheckSvg, IconNormalCheckSvg } from '../../../../utils/svgImage';
|
|
14
13
|
import { useListenProps } from '../utils';
|
|
14
|
+
import { IconCheckSvg, IconNormalCheckSvg } from '../utils/common';
|
|
15
15
|
|
|
16
16
|
const basicStyle = { backgroundColor: '#fff' };
|
|
17
17
|
|
|
Binary file
|
|
@@ -90,7 +90,7 @@ const INPUT_WRAPPER_CLASSNAME = 'ued-input-wrap';
|
|
|
90
90
|
|
|
91
91
|
const WrapperInput: React.FC<WrapperInputProps> = ({ children }) =>
|
|
92
92
|
React.cloneElement(children, {
|
|
93
|
-
className: `${INPUT_WRAPPER_CLASSNAME}`,
|
|
93
|
+
className: `${INPUT_WRAPPER_CLASSNAME} ${children?.props?.className || ''}`,
|
|
94
94
|
});
|
|
95
95
|
const Input = LingxiForwardRef<any, MyInputProps>((props, ref) => {
|
|
96
96
|
const {
|
|
@@ -7,7 +7,7 @@ import React, {
|
|
|
7
7
|
useImperativeHandle,
|
|
8
8
|
useMemo,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import { IconCheckSvg, IconNormalCheckSvg } from '
|
|
10
|
+
import { IconCheckSvg, IconNormalCheckSvg } from '../utils/common';
|
|
11
11
|
import useBackgroundStyle from '../View/useBackgroundStyle';
|
|
12
12
|
|
|
13
13
|
const basicStyle = { backgroundColor: '#fff' };
|
|
@@ -375,7 +375,7 @@ const ModalSelect = LingxiForwardRef<any, MyModalSelectProps>((props, ref) => {
|
|
|
375
375
|
};
|
|
376
376
|
const lastValue: any = useMemo(() => {
|
|
377
377
|
if (options?.length) {
|
|
378
|
-
return options[options?.length - 1]
|
|
378
|
+
return options[options?.length - 1];
|
|
379
379
|
}
|
|
380
380
|
return {};
|
|
381
381
|
}, [options]);
|
|
Binary file
|
|
@@ -26,18 +26,18 @@ const PictureVerifyCode: React.FC<PictureVerifyCodeProps> = forwardRef(
|
|
|
26
26
|
const getPicVerifyCode = () => {
|
|
27
27
|
const newTimestamp = new Date().getTime();
|
|
28
28
|
if (digit && newTimestamp) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
(async () => {
|
|
30
|
+
try {
|
|
31
31
|
const params = {
|
|
32
32
|
validateCodeCount: `${digit}`,
|
|
33
33
|
t: `${newTimestamp}`,
|
|
34
34
|
};
|
|
35
35
|
const url = await engineApis.getValidateCodePicture(params);
|
|
36
36
|
setImgSrc(url);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.log(e);
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
useEffect(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LingxiForwardRef } from '@lingxiteam/types';
|
|
2
2
|
import { useRef } from 'react';
|
|
3
3
|
import {
|
|
4
|
+
filterHtmlNode,
|
|
4
5
|
FormFields,
|
|
5
6
|
getFieldsProps,
|
|
6
7
|
useCommonImperativeHandle,
|
|
@@ -21,6 +22,16 @@ const QuillEditor = LingxiForwardRef<unknown, any>((props, ref) => {
|
|
|
21
22
|
disabled={disabled as any}
|
|
22
23
|
readOnly={readOnly}
|
|
23
24
|
rules={finalRules}
|
|
25
|
+
render={(val: string) => {
|
|
26
|
+
const newVal = filterHtmlNode(val);
|
|
27
|
+
return (
|
|
28
|
+
<span
|
|
29
|
+
className="ued-input-readonly"
|
|
30
|
+
// eslint-disable-next-line react/no-danger
|
|
31
|
+
dangerouslySetInnerHTML={{ __html: newVal ?? '--' }}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}}
|
|
24
35
|
>
|
|
25
36
|
<QuillEditorLoad
|
|
26
37
|
{...props}
|
package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/components/ReactRender.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { createRequires } from '@paciolan/remote-component/dist/createRequires';
|
|
|
3
3
|
import { createUseRemoteComponent } from '@paciolan/remote-component/dist/hooks/useRemoteComponent';
|
|
4
4
|
import { Empty, Spin } from 'antd';
|
|
5
5
|
import { useDynamicData } from '../../utils';
|
|
6
|
+
import { useForm } from '../../utils/formUtils/FormContext';
|
|
6
7
|
import RemoteCompConfig from '../remote-component.config';
|
|
7
8
|
|
|
8
9
|
export const getUseRemoteComponent = (config: any) => {
|
|
@@ -14,6 +15,7 @@ export interface MyRemoteComponentProps {
|
|
|
14
15
|
url?: string;
|
|
15
16
|
customProps: any;
|
|
16
17
|
useRemoteComponent?: any; // 自定义组件调用依赖的模块,可由调用方传入
|
|
18
|
+
forwardRef?: any;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
// const prefixCls = 'remoteComponent';
|
|
@@ -25,6 +27,7 @@ const RemoteComponent: LingXiFC<MyRemoteComponentProps> = (props) => {
|
|
|
25
27
|
const useRemoteComponentInst = props.useRemoteComponent || useRemoteComponent;
|
|
26
28
|
|
|
27
29
|
const dynamicDataContext = useDynamicData();
|
|
30
|
+
const formContext = useForm();
|
|
28
31
|
|
|
29
32
|
const [loading, err, Component] = useRemoteComponentInst(url);
|
|
30
33
|
|
|
@@ -47,7 +50,8 @@ const RemoteComponent: LingXiFC<MyRemoteComponentProps> = (props) => {
|
|
|
47
50
|
<Component
|
|
48
51
|
{...restProps}
|
|
49
52
|
{...customProps}
|
|
50
|
-
$lxApi={{ form: dynamicDataContext.form }}
|
|
53
|
+
$lxApi={{ form: dynamicDataContext.form, formCode: formContext.formCode }}
|
|
54
|
+
ref={props.forwardRef}
|
|
51
55
|
/>
|
|
52
56
|
);
|
|
53
57
|
};
|