@lingxiteam/ebe-utils 0.0.10 → 0.0.11
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,44 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
export const renderHTML = (des: string) => {
|
|
4
|
+
if (des) {
|
|
5
|
+
// eslint-disable-next-line react/no-danger
|
|
6
|
+
return (
|
|
7
|
+
<span
|
|
8
|
+
dangerouslySetInnerHTML={{ __html: des }}
|
|
9
|
+
style={{ display: 'flex', justifyContent: 'center' }}
|
|
10
|
+
/>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
interface CompStateProps {
|
|
17
|
+
dataState: any;
|
|
18
|
+
type: 'loading' | 'empty';
|
|
19
|
+
tip?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const useCompState = (props: CompStateProps) => {
|
|
23
|
+
const { dataState, type, tip } = props;
|
|
24
|
+
const state = useMemo(() => dataState?.[type], [dataState?.[type]]);
|
|
25
|
+
|
|
26
|
+
const stateTip = useMemo(
|
|
27
|
+
() => renderHTML(tip || state?.tip),
|
|
28
|
+
[state?.tip, tip],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const stateIcon = useMemo(() => {
|
|
32
|
+
if (state?.iconIsCustom && state?.icon) {
|
|
33
|
+
return renderHTML(state.icon);
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}, [state?.iconIsCustom, state?.icon]);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
stateIcon,
|
|
40
|
+
stateTip,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default useCompState;
|
|
@@ -103,6 +103,7 @@ const langOptions = {
|
|
|
103
103
|
'Upload.actionStrict': '上传接口未配置,请返回修改!',
|
|
104
104
|
'Upload.fileLimit': (params: any) => `超出文件数量限制,当前为${params.num}`,
|
|
105
105
|
cancelConfirm: '取消后修改内容将不保存,确认取消吗?',
|
|
106
|
+
cancel: '取消',
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
export const lang = (t: string, tip?: unknown) => {
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/* eslint-disable no-continue */
|
|
2
|
+
import { EngineRelationMethods } from '@lingxiteam/types';
|
|
3
|
+
import { RefsManager } from './Context/context';
|
|
4
|
+
|
|
5
|
+
type RefsType = Record<string, any>;
|
|
6
|
+
|
|
7
|
+
const getFormsIdByUid = (uid: string, refs: RefsType) => {
|
|
8
|
+
// 不是表单组件
|
|
9
|
+
if (refs[uid].compName !== 'Form') {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const list = uid.match(/@@@([\d\w_]*)&&&/g);
|
|
14
|
+
if (!Array.isArray(list)) {
|
|
15
|
+
return list;
|
|
16
|
+
}
|
|
17
|
+
return list.map((it) => it.replace(/(@@@)|(&&&)/g, ''));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 通过循环容器id获取 循环容器内的表单
|
|
22
|
+
* @param loopId
|
|
23
|
+
* @param refs
|
|
24
|
+
*/
|
|
25
|
+
export const getFormOfInLoopByLoopId = (options: {
|
|
26
|
+
loopId: string;
|
|
27
|
+
engineRelation: EngineRelationMethods;
|
|
28
|
+
routerId: string;
|
|
29
|
+
refs: RefsType;
|
|
30
|
+
forms?: RefsType[];
|
|
31
|
+
inLoop?: boolean;
|
|
32
|
+
}) => {
|
|
33
|
+
const {
|
|
34
|
+
loopId,
|
|
35
|
+
routerId,
|
|
36
|
+
engineRelation,
|
|
37
|
+
forms = [],
|
|
38
|
+
refs,
|
|
39
|
+
inLoop = false,
|
|
40
|
+
} = options;
|
|
41
|
+
const uids = Object.keys(refs);
|
|
42
|
+
for (let index = 0; index < uids.length; index += 1) {
|
|
43
|
+
const uid = uids[index];
|
|
44
|
+
|
|
45
|
+
if (inLoop) {
|
|
46
|
+
if (refs[uid].compName === 'Form') {
|
|
47
|
+
forms.push(refs[uid]);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 先用---分割,解决多层循环块嵌套问题
|
|
53
|
+
const result = uid
|
|
54
|
+
.split('---')
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.find((id) => {
|
|
57
|
+
const [compId] = id.split('@@@');
|
|
58
|
+
return compId === loopId;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const engineRefs = engineRelation.getEngineRefsByUid(uid, routerId);
|
|
62
|
+
// 页面容器或者BOFramer在循环容器下
|
|
63
|
+
if ((result || inLoop) && engineRefs) {
|
|
64
|
+
// 页面容器和业务组件下也可能存在表单
|
|
65
|
+
getFormOfInLoopByLoopId({
|
|
66
|
+
loopId,
|
|
67
|
+
routerId,
|
|
68
|
+
engineRelation,
|
|
69
|
+
refs: engineRelation.getEngineRefsByUid(uid, routerId)?.refs || {},
|
|
70
|
+
forms,
|
|
71
|
+
inLoop: true,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 不是表单 或者不在循环容器内
|
|
76
|
+
if (refs[uid].compName !== 'Form' || !/[@@@|&&&]/.test(uid)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (result) {
|
|
81
|
+
forms.push(refs[uid]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return forms;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 获取gridview组件
|
|
89
|
+
* @param forms
|
|
90
|
+
* @param getFieldsValue
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
export const getLoopForms = async (
|
|
94
|
+
forms: RefsType[],
|
|
95
|
+
getFieldsValue: (form: any) => void,
|
|
96
|
+
) => {
|
|
97
|
+
const fieldValues: any = {};
|
|
98
|
+
let firstErrorInfo: any = null;
|
|
99
|
+
for (let index = 0; index < forms.length; index += 1) {
|
|
100
|
+
const form = forms[index];
|
|
101
|
+
const { formCode, scrollToErrorField } = form;
|
|
102
|
+
fieldValues[formCode] = fieldValues[formCode] ?? [];
|
|
103
|
+
try {
|
|
104
|
+
const values = await getFieldsValue(form);
|
|
105
|
+
fieldValues[formCode].push(values);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (!firstErrorInfo) {
|
|
108
|
+
firstErrorInfo = {
|
|
109
|
+
error,
|
|
110
|
+
form,
|
|
111
|
+
scrollToErrorField,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (firstErrorInfo) {
|
|
118
|
+
const { scrollToErrorField, error } = firstErrorInfo;
|
|
119
|
+
scrollToErrorField(error);
|
|
120
|
+
return Promise.reject(error);
|
|
121
|
+
}
|
|
122
|
+
return Promise.resolve(fieldValues);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 通过组件id获取表单列表
|
|
127
|
+
*/
|
|
128
|
+
export const getFormByCompId = (compId: string, refs: RefsType) => {
|
|
129
|
+
// 获取是否是表单
|
|
130
|
+
const form = refs[compId];
|
|
131
|
+
if (form) {
|
|
132
|
+
return form;
|
|
133
|
+
}
|
|
134
|
+
const uidArr = Object.keys(refs).filter((uid) => {
|
|
135
|
+
const ids = getFormsIdByUid(uid, refs);
|
|
136
|
+
if (!ids) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return ids.includes(compId);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
if (uidArr.length === 0) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return uidArr.map((uid) => refs[uid]);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const getFieldsValue = async (
|
|
150
|
+
forms: RefsType | RefsType[],
|
|
151
|
+
getFieldsValue: (form: any) => void,
|
|
152
|
+
) => {
|
|
153
|
+
// 当表单不存在时,应该获取的是undefined
|
|
154
|
+
if (!forms) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (Array.isArray(forms)) {
|
|
159
|
+
return Promise.all(forms.map((form) => getFieldsValue(form)));
|
|
160
|
+
}
|
|
161
|
+
return getFieldsValue(forms);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 获取表单类型
|
|
166
|
+
*/
|
|
167
|
+
export const getFormType = (uid: string) => {
|
|
168
|
+
// uid中包含@符号包含&符号
|
|
169
|
+
const hasAtOrAnd = /[@@@|&&&]/.test(uid);
|
|
170
|
+
const [loopId, formId, itemId] = uid.split(/@@@|&&&/g);
|
|
171
|
+
return {
|
|
172
|
+
type: hasAtOrAnd ? 'inLoop' : 'default',
|
|
173
|
+
loopId,
|
|
174
|
+
formId,
|
|
175
|
+
itemId,
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
interface FirstErrorInfoType {
|
|
180
|
+
error: any;
|
|
181
|
+
form?: any;
|
|
182
|
+
scrollToErrorField: any;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 当前的refs
|
|
187
|
+
* @param options
|
|
188
|
+
* @param getFieldsValue
|
|
189
|
+
*/
|
|
190
|
+
export const getOwnFormValues = async (
|
|
191
|
+
options: { currentRefs: RefsType; renderRefs: RefsManager },
|
|
192
|
+
getFieldsValue: (form: any) => void,
|
|
193
|
+
) => {
|
|
194
|
+
const { currentRefs, renderRefs } = options;
|
|
195
|
+
|
|
196
|
+
let firstErrorInfo: FirstErrorInfoType | null = null;
|
|
197
|
+
const values: any = {};
|
|
198
|
+
|
|
199
|
+
const formCodeTypes: Record<string, 'default' | 'array'> = {};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 获取单个引擎下的表单值
|
|
203
|
+
*/
|
|
204
|
+
const getRenderRefsFormValues = async (refs: RefsType = {}) => {
|
|
205
|
+
const uidArr = Object.keys(refs);
|
|
206
|
+
|
|
207
|
+
for (let index = 0; index < uidArr.length; index += 1) {
|
|
208
|
+
const uid = uidArr[index];
|
|
209
|
+
|
|
210
|
+
const ref = refs[uid];
|
|
211
|
+
if (['BOFramer', 'Pageview'].includes(ref.compName)) {
|
|
212
|
+
// 需要处理BOFramer和PageView这种渲染逻辑
|
|
213
|
+
const uidRefs = renderRefs.getComRefs(uid);
|
|
214
|
+
// const uidRefs = engineRelation.getEngineRefsByUid(uid, routerId);
|
|
215
|
+
if (uidRefs) {
|
|
216
|
+
await getRenderRefsFormValues(uidRefs);
|
|
217
|
+
}
|
|
218
|
+
} else if (ref.compName === 'Form') {
|
|
219
|
+
const {
|
|
220
|
+
formCode,
|
|
221
|
+
form,
|
|
222
|
+
scrollToErrorField,
|
|
223
|
+
compName,
|
|
224
|
+
_innerDynamicDataContainer,
|
|
225
|
+
} = ref;
|
|
226
|
+
if (!formCode) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (compName === 'Form' && _innerDynamicDataContainer) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const { type } = getFormType(uid);
|
|
235
|
+
try {
|
|
236
|
+
const value = await getFieldsValue(ref);
|
|
237
|
+
if (type === 'default') {
|
|
238
|
+
// 1. 首次赋值, 包含循环容器内逻辑
|
|
239
|
+
if (!values[formCode]) {
|
|
240
|
+
values[formCode] = value;
|
|
241
|
+
formCodeTypes[formCode] = 'default';
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
// 2. 存在编码相同时,切换成数组类型
|
|
245
|
+
if (formCodeTypes[formCode] === 'default') {
|
|
246
|
+
// 处理页面中存在多个相同的表单,但是表单编码一样。这时候表现为数组形式
|
|
247
|
+
values[formCode] = [values[formCode]];
|
|
248
|
+
formCodeTypes[formCode] = 'array';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 3. 给数组添加当前值
|
|
252
|
+
if (formCodeTypes[formCode] === 'array') {
|
|
253
|
+
values[formCode].push(value);
|
|
254
|
+
}
|
|
255
|
+
} else if (type === 'inLoop') {
|
|
256
|
+
// 1. 或许存在一个没包含在循环容器内表单,并且该表单和循环容器下的表单编码相同,
|
|
257
|
+
if (formCodeTypes[formCode] === 'default') {
|
|
258
|
+
values[formCode] = [values[formCode]];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
formCodeTypes[formCode] = 'array';
|
|
262
|
+
values[formCode] = Array.isArray(values[formCode])
|
|
263
|
+
? values[formCode]
|
|
264
|
+
: [];
|
|
265
|
+
values[formCode].push(value);
|
|
266
|
+
}
|
|
267
|
+
} catch (error) {
|
|
268
|
+
if (!firstErrorInfo) {
|
|
269
|
+
firstErrorInfo = {
|
|
270
|
+
error,
|
|
271
|
+
form,
|
|
272
|
+
scrollToErrorField,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
await getRenderRefsFormValues(currentRefs);
|
|
281
|
+
|
|
282
|
+
// 存在错误时,滚动到第一个出现错误的位置
|
|
283
|
+
if (firstErrorInfo) {
|
|
284
|
+
const { scrollToErrorField, error } = firstErrorInfo as FirstErrorInfoType;
|
|
285
|
+
scrollToErrorField(error);
|
|
286
|
+
return Promise.reject(error);
|
|
287
|
+
}
|
|
288
|
+
return Promise.resolve(values);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export const getAllForm = (options: {
|
|
292
|
+
currentRefs: RefsType;
|
|
293
|
+
renderRefs: RefsManager;
|
|
294
|
+
}) => {
|
|
295
|
+
const { currentRefs, renderRefs } = options;
|
|
296
|
+
const forms: RefsType[] = [];
|
|
297
|
+
const getRenderRefsFormValues = (refs: RefsType = {}) => {
|
|
298
|
+
const uidArr = Object.keys(refs);
|
|
299
|
+
|
|
300
|
+
for (let index = 0; index < uidArr.length; index += 1) {
|
|
301
|
+
const uid = uidArr[index];
|
|
302
|
+
|
|
303
|
+
const ref = refs[uid];
|
|
304
|
+
if (ref.compName !== 'Form') {
|
|
305
|
+
// 需要处理BOFramer和PageView这种渲染逻辑
|
|
306
|
+
const refs = renderRefs.getComRefs(uid);
|
|
307
|
+
if (refs) {
|
|
308
|
+
getRenderRefsFormValues(refs);
|
|
309
|
+
}
|
|
310
|
+
} else if (ref.has) {
|
|
311
|
+
forms.push(ref);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
getRenderRefsFormValues(currentRefs);
|
|
316
|
+
return forms;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 获取业务组件列表 可能存在
|
|
321
|
+
* @param compId
|
|
322
|
+
* @param refs
|
|
323
|
+
*/
|
|
324
|
+
export const getBOFramers = (compId: string, refs: RefsType = {}) => {
|
|
325
|
+
const boframerUids = Object.keys(refs).filter(
|
|
326
|
+
(id) => refs[id].compId === compId,
|
|
327
|
+
);
|
|
328
|
+
// 如果没找到组件,就返回null
|
|
329
|
+
if (!boframerUids.length) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const boframerRefs: RefsType = {};
|
|
334
|
+
|
|
335
|
+
boframerUids.forEach((uid) => {
|
|
336
|
+
boframerRefs[uid] = refs[uid];
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
return boframerRefs;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export const getBOFramerOwnFormValues = async (
|
|
343
|
+
options: {
|
|
344
|
+
refs: RefsType;
|
|
345
|
+
renderRefs: RefsManager;
|
|
346
|
+
compId: string;
|
|
347
|
+
},
|
|
348
|
+
getFieldsValue: (form: any) => void,
|
|
349
|
+
) => {
|
|
350
|
+
const { renderRefs, refs, compId } = options;
|
|
351
|
+
|
|
352
|
+
// 2种情况 1只有单个业务组件 2 业务组件放在循环容器下
|
|
353
|
+
const boframerRefs = getBOFramers(compId, refs);
|
|
354
|
+
|
|
355
|
+
let values = {};
|
|
356
|
+
if (boframerRefs) {
|
|
357
|
+
values = await getOwnFormValues(
|
|
358
|
+
{ currentRefs: boframerRefs, renderRefs },
|
|
359
|
+
getFieldsValue,
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// 理论上获取业务组件 应该都带有表单编码,但是由于需要兼容旧数据 需要把值展开
|
|
364
|
+
if (Object.keys(values).length === 1) {
|
|
365
|
+
const val = Object.values(values)[0] as Object;
|
|
366
|
+
if (Object.prototype.toString.call(val) === '[object Object]') {
|
|
367
|
+
values = val;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return values;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
// 获取BOFramer下所有表单
|
|
374
|
+
export const getBoframerOwnForms = (options: {
|
|
375
|
+
currentRefs: RefsType;
|
|
376
|
+
renderRefs: RefsManager;
|
|
377
|
+
compId: string;
|
|
378
|
+
}) => {
|
|
379
|
+
const { compId, currentRefs, renderRefs } = options;
|
|
380
|
+
const boframers = getBOFramers(compId, currentRefs);
|
|
381
|
+
|
|
382
|
+
const forms: RefsType[] = [];
|
|
383
|
+
const getAllForms = (refs: RefsType | null) => {
|
|
384
|
+
Object.keys(refs || {}).forEach((uid) => {
|
|
385
|
+
// const engineRef = engineRelation.getEngineRefsByUid(uid, routerId);
|
|
386
|
+
const renderId = uid;
|
|
387
|
+
if (renderId) {
|
|
388
|
+
const engineRefs = renderRefs.getComRefs(renderId);
|
|
389
|
+
if (engineRefs) {
|
|
390
|
+
Object.keys(engineRefs).forEach((compUid) => {
|
|
391
|
+
const r = engineRefs[compUid];
|
|
392
|
+
getAllForms(r);
|
|
393
|
+
if (r.compName === 'Form') {
|
|
394
|
+
forms.push(r);
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
getAllForms(boframers);
|
|
403
|
+
return forms;
|
|
404
|
+
};
|
|
405
|
+
/**
|
|
406
|
+
* 加载子节点数据
|
|
407
|
+
* @param nodeKey
|
|
408
|
+
* @param odata
|
|
409
|
+
* @param arr
|
|
410
|
+
* @param key
|
|
411
|
+
* @param title
|
|
412
|
+
* @param selectable
|
|
413
|
+
*/
|
|
414
|
+
export const updateNodeChildren = (
|
|
415
|
+
nodeKey: any,
|
|
416
|
+
odata: any[],
|
|
417
|
+
arr: any[],
|
|
418
|
+
key: string,
|
|
419
|
+
title: string,
|
|
420
|
+
selectable: string | undefined,
|
|
421
|
+
) => {
|
|
422
|
+
const transformBoolean = (value: any) => {
|
|
423
|
+
if (value === undefined || value === null) {
|
|
424
|
+
return undefined;
|
|
425
|
+
}
|
|
426
|
+
if (value === 'false') {
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
return Boolean(value);
|
|
430
|
+
};
|
|
431
|
+
arr.forEach((c, i) => {
|
|
432
|
+
if (`${c.key}` === `${nodeKey}`) {
|
|
433
|
+
const oldChildMap: any = {};
|
|
434
|
+
(arr[i].children || []).forEach((d: any) => {
|
|
435
|
+
oldChildMap[d.key] = d.children;
|
|
436
|
+
});
|
|
437
|
+
arr[i].children = odata.map((item: any) => ({
|
|
438
|
+
key: item[key], // 取值字段
|
|
439
|
+
title: item[title], // 显示字段
|
|
440
|
+
isLeaf: false,
|
|
441
|
+
selectable:
|
|
442
|
+
selectable !== undefined
|
|
443
|
+
? transformBoolean(item[selectable])
|
|
444
|
+
: undefined,
|
|
445
|
+
children: oldChildMap[item[key]],
|
|
446
|
+
data: item,
|
|
447
|
+
// 标识该节点数据是通过加载子节点动作设置的
|
|
448
|
+
_isReload: true,
|
|
449
|
+
}));
|
|
450
|
+
arr[i].isLeaf = odata.length === 0;
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (c.children && c.children.length) {
|
|
454
|
+
updateNodeChildren(nodeKey, odata, c.children, key, title, selectable);
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
return arr;
|
|
458
|
+
};
|
|
@@ -35,4 +35,11 @@ export const api = {
|
|
|
35
35
|
|
|
36
36
|
return resolveApiPath(security.createHttpSignWithUrl(`${url}${urlParam}`));
|
|
37
37
|
},
|
|
38
|
+
// 获取图形验证码
|
|
39
|
+
getValidateCodePicture: ({ validateCodeCount, t }: any) =>
|
|
40
|
+
resolveApiPath(
|
|
41
|
+
security.createHttpSignWithUrl(
|
|
42
|
+
`app/validateCode/getValidateCodePicture?validateCodeCount=${validateCodeCount}&t=${t}&X-B-AUTH=1`,
|
|
43
|
+
),
|
|
44
|
+
),
|
|
38
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxiteam/ebe-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@babel/parser": "^7.12.12",
|
|
18
18
|
"@babel/traverse": "^7.12.12",
|
|
19
19
|
"@babel/types": "^7.12.12",
|
|
20
|
-
"@lingxiteam/ebe": "0.0.
|
|
20
|
+
"@lingxiteam/ebe": "0.0.11",
|
|
21
21
|
"cac": "^6.7.14",
|
|
22
22
|
"fs-extra": "9.x"
|
|
23
23
|
},
|