...
|
...
|
@@ -8,6 +8,9 @@ import { QxBaseIcon } from '../qx-base-icon'; |
8
|
8
|
import { request } from '../utils';
|
9
|
9
|
import './index.less';
|
10
|
10
|
|
|
11
|
+let formIds: string[] = [];
|
|
12
|
+let targetParentNodes: INode[] = [];
|
|
13
|
+
|
11
|
14
|
const getAppsFields = (params: string[], appId = 'default') => {
|
12
|
15
|
return request.post(`/qx-apaas-lowcode/app/${appId}/fields`, {
|
13
|
16
|
data: params,
|
...
|
...
|
@@ -93,8 +96,6 @@ export const useNodeFieldDisplay = ({ |
93
|
96
|
(node) => !['default_DF_BRANCH'].includes(node.type),
|
94
|
97
|
) || [],
|
95
|
98
|
);
|
96
|
|
- const [targetParentNodes, setTargetParentNodes] = useState<INode[]>([]);
|
97
|
|
-
|
98
|
99
|
const [inputDisplay, setInputDisplay] = useState<React.ReactNode>();
|
99
|
100
|
const [optionalNodes, setOptionalNodes] = useState<FiledType[]>([]); // 根据 fieldType 过滤后的 nodes
|
100
|
101
|
|
...
|
...
|
@@ -221,7 +222,9 @@ export const useNodeFieldDisplay = ({ |
221
|
222
|
};
|
222
|
223
|
|
223
|
224
|
const handleRenderInputDisplay = (val = value) => {
|
224
|
|
- renderInputDisplay(val);
|
|
225
|
+ if (val) {
|
|
226
|
+ renderInputDisplay(val);
|
|
227
|
+ }
|
225
|
228
|
resolveDisplayConfig.current?.();
|
226
|
229
|
};
|
227
|
230
|
|
...
|
...
|
@@ -265,6 +268,9 @@ export const useNodeFieldDisplay = ({ |
265
|
268
|
if (!forms.length) return sourceParentNodes;
|
266
|
269
|
|
267
|
270
|
const ids = forms.map((item) => item.qxProps?.formId);
|
|
271
|
+ if (JSON.stringify(ids) === JSON.stringify(formIds) && ids.length)
|
|
272
|
+ return targetParentNodes;
|
|
273
|
+
|
268
|
274
|
if (Array.isArray(ids) && ids.length && subset) {
|
269
|
275
|
try {
|
270
|
276
|
const data = await getAppsFields(ids as any[]);
|
...
|
...
|
@@ -295,8 +301,8 @@ export const useNodeFieldDisplay = ({ |
295
|
301
|
console.error(error);
|
296
|
302
|
}
|
297
|
303
|
}
|
298
|
|
-
|
299
|
|
- setTargetParentNodes(sourceParentNodes);
|
|
304
|
+ targetParentNodes = sourceParentNodes;
|
|
305
|
+ formIds = ids as string[];
|
300
|
306
|
return sourceParentNodes;
|
301
|
307
|
};
|
302
|
308
|
|
...
|
...
|
@@ -363,8 +369,8 @@ export const useNodeFieldDisplay = ({ |
363
|
369
|
* 获取可被选择的节点和结果
|
364
|
370
|
*/
|
365
|
371
|
const getOptionalNodes = async () => {
|
366
|
|
- const targetParentNodes = await handleFormTypeAddChild(); // 给 form 类型的字段添加 child
|
367
|
|
- let newNodes = correctionNode(targetParentNodes);
|
|
372
|
+ const _targetParentNodes = await handleFormTypeAddChild(); // 给 form 类型的字段添加 child
|
|
373
|
+ let newNodes = correctionNode(_targetParentNodes);
|
368
|
374
|
|
369
|
375
|
/**
|
370
|
376
|
* 根据 limitType 获取可选择的字段
|
...
|
...
|
@@ -392,7 +398,7 @@ export const useNodeFieldDisplay = ({ |
392
|
398
|
if (Array.isArray(resultItem.child) && resultItem.child.length) {
|
393
|
399
|
const child = getEffectiveResult(resultItem.child);
|
394
|
400
|
if (child && child.length) {
|
395
|
|
- resultItem.child = child
|
|
401
|
+ resultItem.child = child;
|
396
|
402
|
newResult.push(resultItem);
|
397
|
403
|
}
|
398
|
404
|
}
|
...
|
...
|
@@ -421,11 +427,7 @@ export const useNodeFieldDisplay = ({ |
421
|
427
|
setOptionalNodes(newNodes);
|
422
|
428
|
resultFieldMap.current = getResultFieldMap(newNodes);
|
423
|
429
|
resolveFieldResultMap.current?.(resultFieldMap.current);
|
424
|
|
- if (value) {
|
425
|
|
- handleRenderInputDisplay();
|
426
|
|
- } else {
|
427
|
|
- resolveDisplayConfig.current?.();
|
428
|
|
- }
|
|
430
|
+ handleRenderInputDisplay();
|
429
|
431
|
};
|
430
|
432
|
|
431
|
433
|
const handleGetResultFieldMap = () => {
|
...
|
...
|
@@ -435,10 +437,6 @@ export const useNodeFieldDisplay = ({ |
435
|
437
|
});
|
436
|
438
|
};
|
437
|
439
|
|
438
|
|
- // useEffect(() => {
|
439
|
|
- // handleFormTypeAddChild(); // 给 form 类型的字段添加 child
|
440
|
|
- // }, [])
|
441
|
|
-
|
442
|
440
|
useEffect(() => {
|
443
|
441
|
getOptionalNodes();
|
444
|
442
|
}, []);
|
...
|
...
|
|