Commit 42c9d596673f59c42a424c01aaa3758f63b8937e
Merge remote-tracking branch 'origin/feature/dataflow' into feature/dataflow
Showing
1 changed file
with
23 additions
and
18 deletions
| ... | ... | @@ -109,7 +109,7 @@ export const useNodeFieldDisplay = ({ |
| 109 | 109 | return null; |
| 110 | 110 | }; |
| 111 | 111 | |
| 112 | - const genDisplayDom = (value: string) => { | |
| 112 | + const genDisplayDom = (value: string, nodes: INode[]) => { | |
| 113 | 113 | const itemId = getId(value); |
| 114 | 114 | if (!itemId) return; |
| 115 | 115 | let displayConfig: any[] = []; |
| ... | ... | @@ -118,7 +118,7 @@ export const useNodeFieldDisplay = ({ |
| 118 | 118 | while (n && index <= 20) { |
| 119 | 119 | displayConfig = []; |
| 120 | 120 | // eslint-disable-next-line @typescript-eslint/no-use-before-define |
| 121 | - const curNode = cloneDeep(optionalNodes[index]) || {}; | |
| 121 | + const curNode = cloneDeep(nodes[index]) || {}; | |
| 122 | 122 | displayConfig.push({ |
| 123 | 123 | title: curNode.name, |
| 124 | 124 | icon: curNode.icon, |
| ... | ... | @@ -151,7 +151,6 @@ export const useNodeFieldDisplay = ({ |
| 151 | 151 | n = false; |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | - | |
| 155 | 154 | return ( |
| 156 | 155 | <> |
| 157 | 156 | {displayConfig?.map((item, idx) => ( |
| ... | ... | @@ -186,10 +185,10 @@ export const useNodeFieldDisplay = ({ |
| 186 | 185 | ); |
| 187 | 186 | }; |
| 188 | 187 | |
| 189 | - const renderInputDisplay = (val: string = value || '') => { | |
| 188 | + const renderInputDisplay = (nodes: INode[] = optionalNodes, val: string = value || '', ) => { | |
| 190 | 189 | setInputDisplay( |
| 191 | 190 | <Tag bordered={false} className="qx-node-select-input__content"> |
| 192 | - {genDisplayDom(val)} | |
| 191 | + {genDisplayDom(val, nodes)} | |
| 193 | 192 | </Tag>, |
| 194 | 193 | ); |
| 195 | 194 | }; |
| ... | ... | @@ -197,7 +196,7 @@ export const useNodeFieldDisplay = ({ |
| 197 | 196 | /*** |
| 198 | 197 | * 查找有 formId 的 result |
| 199 | 198 | */ |
| 200 | - const findResultByFormId = () => { | |
| 199 | + const findResultByFormId = (sourceParentNodes: INode[]) => { | |
| 201 | 200 | const forms: FiledType[] = []; |
| 202 | 201 | sourceParentNodes.forEach((node) => { |
| 203 | 202 | if (Array.isArray(node.data?.result)) { |
| ... | ... | @@ -230,7 +229,7 @@ export const useNodeFieldDisplay = ({ |
| 230 | 229 | * 查询所有 formId 的字段,并给 result 添加 child |
| 231 | 230 | */ |
| 232 | 231 | const handleGetAppsFields = async () => { |
| 233 | - const forms = findResultByFormId(); | |
| 232 | + const forms = findResultByFormId(sourceParentNodes); | |
| 234 | 233 | const ids = forms.map((item) => item.qxProps?.formId); |
| 235 | 234 | if (Array.isArray(ids) && ids.length && subset) { |
| 236 | 235 | try { |
| ... | ... | @@ -250,7 +249,7 @@ export const useNodeFieldDisplay = ({ |
| 250 | 249 | id: item.code, |
| 251 | 250 | type: item.extract?.fieldType, |
| 252 | 251 | })); |
| 253 | - | |
| 252 | + | |
| 254 | 253 | if (Array.isArray(form.child)) { |
| 255 | 254 | form.child.push(childItem); |
| 256 | 255 | } else { |
| ... | ... | @@ -261,7 +260,6 @@ export const useNodeFieldDisplay = ({ |
| 261 | 260 | } catch (error) { |
| 262 | 261 | // appsFields = {}; |
| 263 | 262 | } finally { |
| 264 | - renderInputDisplay(); | |
| 265 | 263 | } |
| 266 | 264 | } |
| 267 | 265 | return sourceParentNodes; |
| ... | ... | @@ -291,18 +289,22 @@ export const useNodeFieldDisplay = ({ |
| 291 | 289 | const getOptionalNodes = async () => { |
| 292 | 290 | const targetParentNodes = await handleGetAppsFields(); |
| 293 | 291 | |
| 294 | - for (let i = 0; i< targetParentNodes.length;i++) { | |
| 295 | - correctionNodeField(targetParentNodes[i].data?.result || []) | |
| 292 | + for (let i = 0; i < targetParentNodes.length; i++) { | |
| 293 | + correctionNodeField(targetParentNodes[i].data?.result || []); | |
| 294 | + } | |
| 295 | + | |
| 296 | + if (!limitTypes) { | |
| 297 | + setOptionalNodes(targetParentNodes); | |
| 298 | + renderInputDisplay(targetParentNodes); | |
| 299 | + return; | |
| 296 | 300 | } |
| 297 | - | |
| 298 | - if (!limitTypes) return setOptionalNodes(targetParentNodes); | |
| 299 | 301 | |
| 300 | 302 | function getEffectiveResult(result: FiledType[]) { |
| 301 | 303 | const newResult = []; |
| 302 | 304 | for (let i = 0; i < result.length; i++) { |
| 303 | - const resultItem = result[i] || {}; | |
| 304 | - correctionNodeField(resultItem) | |
| 305 | - | |
| 305 | + const resultItem = result[i] || {}; | |
| 306 | + correctionNodeField(resultItem); | |
| 307 | + | |
| 306 | 308 | if (resultItem.child) { |
| 307 | 309 | resultItem.child = getEffectiveResult(resultItem.child); |
| 308 | 310 | if ( |
| ... | ... | @@ -333,6 +335,7 @@ export const useNodeFieldDisplay = ({ |
| 333 | 335 | |
| 334 | 336 | const newNodes = getEffectiveNodes(targetParentNodes); |
| 335 | 337 | setOptionalNodes([...newNodes]); |
| 338 | + renderInputDisplay([...newNodes]); | |
| 336 | 339 | }; |
| 337 | 340 | |
| 338 | 341 | useEffect(() => { |
| ... | ... | @@ -388,7 +391,9 @@ const SelectItem = (props: any) => { |
| 388 | 391 | onClick={() => props.onClick(props)} |
| 389 | 392 | > |
| 390 | 393 | {/* @ts-ignore */} |
| 391 | - {props.icon ? props.icon : `[${FieldMapType[props.extract?.fieldType]}]`} | |
| 394 | + {props.icon | |
| 395 | + ? props.icon | |
| 396 | + : `[${FieldMapType[props.extract?.fieldType]}]`} | |
| 392 | 397 | {props.name} |
| 393 | 398 | </div> |
| 394 | 399 | ); |
| ... | ... | @@ -466,7 +471,7 @@ export const QxFlowNodeFieldSelector: React.FC<NodeFieldSelectProps> = ( |
| 466 | 471 | const newValue = '${' + `${nodeKey}|${item.id}` + '}'; |
| 467 | 472 | props.onChange?.(newValue, item); |
| 468 | 473 | if (!props.children) { |
| 469 | - renderInputDisplay(newValue); | |
| 474 | + renderInputDisplay(optionalNodes ,newValue); | |
| 470 | 475 | } |
| 471 | 476 | setVisible(false); |
| 472 | 477 | }; | ... | ... |