Showing
3 changed files
with
52 additions
and
10 deletions
... | ... | @@ -2,7 +2,7 @@ import { ControlOutlined } from '@ant-design/icons'; |
2 | 2 | import { Select, Tooltip } from 'antd'; |
3 | 3 | import { size } from 'lodash-es'; |
4 | 4 | import React, { useState } from 'react'; |
5 | -import type { QxBaseConditionField } from '../qx-base-condition'; | |
5 | +import { FieldBaseType, type QxBaseConditionField } from '../qx-base-condition'; | |
6 | 6 | import { QxBaseIcon } from '../qx-base-icon'; |
7 | 7 | import { QxFieldSetter } from '../qx-field-setter'; |
8 | 8 | import type { INode } from '../qx-flow-node-selector'; |
... | ... | @@ -15,6 +15,11 @@ import { QxWidgetIcon } from '../qx-widget-icon'; |
15 | 15 | |
16 | 16 | import './index.less'; |
17 | 17 | |
18 | +export const fieldLimitTypes: Record<string, string[]> = { | |
19 | + TEXT: [], | |
20 | + ENUM: ['TEXT', 'ENUM'], | |
21 | +}; | |
22 | + | |
18 | 23 | export const multipleType = [ |
19 | 24 | 'STRING', |
20 | 25 | 'REL_MULTI', |
... | ... | @@ -733,10 +738,13 @@ export const QxBaseConditionItem: React.FC<QxBaseConditionItemProps> = ({ |
733 | 738 | setOpen(false); |
734 | 739 | }; |
735 | 740 | |
741 | + const baseType = FieldBaseType[field.extract?.fieldType] || field.extract?.fieldType | |
742 | + const limitTypes = fieldLimitTypes[baseType] ? fieldLimitTypes[baseType] : [baseType] | |
743 | + | |
736 | 744 | const { genDisplayDom } = useNodeFieldDisplay({ |
737 | 745 | node: node, |
738 | 746 | nodes: nodes, |
739 | - limitTypes: [field.extract?.fieldType], | |
747 | + limitTypes, | |
740 | 748 | value: valuesObj?.value, |
741 | 749 | subset, |
742 | 750 | }); |
... | ... | @@ -829,7 +837,7 @@ export const QxBaseConditionItem: React.FC<QxBaseConditionItemProps> = ({ |
829 | 837 | open={open} |
830 | 838 | value={valuesObj?.value} |
831 | 839 | onChange={handleAssignment} |
832 | - limitTypes={[field.extract?.fieldType]} | |
840 | + limitTypes={limitTypes} | |
833 | 841 | subset={subset} |
834 | 842 | > |
835 | 843 | {RenderContent} | ... | ... |
... | ... | @@ -8,6 +8,31 @@ export const FieldBaseType = { |
8 | 8 | DOUBLE: 'NUM', |
9 | 9 | NUMBER: 'NUM', |
10 | 10 | YEAR_SEC: 'DATE', |
11 | + TIME: 'DATE', | |
12 | + YEAR: 'DATE', | |
13 | + YEAR_MONTH: 'DATE', | |
14 | + YEAR_DATE: 'DATE', | |
15 | + YEAR_MIN: 'DATE', | |
16 | + YEAR_HOUR: 'DATE', | |
17 | + HOUR: 'DATE', | |
18 | + HOUR_MIN: 'DATE', | |
19 | + HOUR_SEC: 'DATE', | |
20 | + PERCENT: 'NUM', | |
21 | + DECIMAL: 'NUM', | |
22 | + /** | |
23 | + * 用户 | |
24 | + */ | |
25 | + USER: 'USER', | |
26 | + /** | |
27 | + * 多选用户 | |
28 | + */ | |
29 | + USER_MULTI: 'USER', | |
30 | + ORG: 'ORG', | |
31 | + ORG_MULTI: 'ORG', | |
32 | + REL: 'FORM', | |
33 | + REL_MULTI: 'FORM', | |
34 | + TABLE: 'FORM', | |
35 | + TREE: 'FORM', | |
11 | 36 | }; |
12 | 37 | |
13 | 38 | export const QxBaseCondition: React.FC<QxBaseConditionProps> = (props) => { | ... | ... |
... | ... | @@ -3,6 +3,7 @@ import { Collapse, Dropdown, Empty, Tag } from 'antd'; |
3 | 3 | import cls from 'classnames'; |
4 | 4 | import { cloneDeep } from 'lodash-es'; |
5 | 5 | import React, { useEffect, useState } from 'react'; |
6 | +import { FieldBaseType } from '../qx-base-condition'; | |
6 | 7 | import { QxBaseIcon } from '../qx-base-icon'; |
7 | 8 | import { request } from '../utils'; |
8 | 9 | import './index.less'; |
... | ... | @@ -151,11 +152,11 @@ export const useNodeFieldDisplay = ({ |
151 | 152 | } |
152 | 153 | } |
153 | 154 | |
154 | - return displayConfig | |
155 | - } | |
155 | + return displayConfig; | |
156 | + }; | |
156 | 157 | |
157 | 158 | const genDisplayDom = (value: string, nodes: INode[] = optionalNodes) => { |
158 | - const displayConfig = getDisplayConfig(value, nodes) | |
159 | + const displayConfig = getDisplayConfig(value, nodes); | |
159 | 160 | return ( |
160 | 161 | <> |
161 | 162 | {displayConfig?.map((item, idx) => ( |
... | ... | @@ -301,7 +302,7 @@ export const useNodeFieldDisplay = ({ |
301 | 302 | correctionNodeField(targetParentNodes[i].data?.result || []); |
302 | 303 | } |
303 | 304 | |
304 | - if (!limitTypes) { | |
305 | + if (!limitTypes || !limitTypes.length) { | |
305 | 306 | setOptionalNodes(targetParentNodes); |
306 | 307 | renderInputDisplay(targetParentNodes); |
307 | 308 | return; |
... | ... | @@ -317,11 +318,19 @@ export const useNodeFieldDisplay = ({ |
317 | 318 | resultItem.child = getEffectiveResult(resultItem.child); |
318 | 319 | if ( |
319 | 320 | (Array.isArray(resultItem.child) && resultItem.child.length) || |
320 | - limitTypes?.includes(resultItem.type) | |
321 | + limitTypes?.includes( | |
322 | + FieldBaseType[resultItem.type as keyof typeof FieldBaseType] || | |
323 | + resultItem.type, | |
324 | + ) | |
321 | 325 | ) { |
322 | 326 | newResult.push(resultItem); |
323 | 327 | } |
324 | - } else if (limitTypes?.includes(resultItem.type)) { | |
328 | + } else if ( | |
329 | + limitTypes?.includes( | |
330 | + FieldBaseType[resultItem.type as keyof typeof FieldBaseType] || | |
331 | + resultItem.type, | |
332 | + ) | |
333 | + ) { | |
325 | 334 | newResult.push(resultItem); |
326 | 335 | } |
327 | 336 | } |
... | ... | @@ -479,7 +488,7 @@ export const QxFlowNodeFieldSelector: React.FC<NodeFieldSelectProps> = ( |
479 | 488 | const newValue = '${' + `${nodeKey}|${item.id}` + '}'; |
480 | 489 | props.onChange?.(newValue, item); |
481 | 490 | if (!props.children) { |
482 | - renderInputDisplay(optionalNodes ,newValue); | |
491 | + renderInputDisplay(optionalNodes, newValue); | |
483 | 492 | } |
484 | 493 | setVisible(false); |
485 | 494 | }; | ... | ... |