Showing
3 changed files
with
52 additions
and
10 deletions
@@ -2,7 +2,7 @@ import { ControlOutlined } from '@ant-design/icons'; | @@ -2,7 +2,7 @@ import { ControlOutlined } from '@ant-design/icons'; | ||
2 | import { Select, Tooltip } from 'antd'; | 2 | import { Select, Tooltip } from 'antd'; |
3 | import { size } from 'lodash-es'; | 3 | import { size } from 'lodash-es'; |
4 | import React, { useState } from 'react'; | 4 | import React, { useState } from 'react'; |
5 | -import type { QxBaseConditionField } from '../qx-base-condition'; | 5 | +import { FieldBaseType, type QxBaseConditionField } from '../qx-base-condition'; |
6 | import { QxBaseIcon } from '../qx-base-icon'; | 6 | import { QxBaseIcon } from '../qx-base-icon'; |
7 | import { QxFieldSetter } from '../qx-field-setter'; | 7 | import { QxFieldSetter } from '../qx-field-setter'; |
8 | import type { INode } from '../qx-flow-node-selector'; | 8 | import type { INode } from '../qx-flow-node-selector'; |
@@ -15,6 +15,11 @@ import { QxWidgetIcon } from '../qx-widget-icon'; | @@ -15,6 +15,11 @@ import { QxWidgetIcon } from '../qx-widget-icon'; | ||
15 | 15 | ||
16 | import './index.less'; | 16 | import './index.less'; |
17 | 17 | ||
18 | +export const fieldLimitTypes: Record<string, string[]> = { | ||
19 | + TEXT: [], | ||
20 | + ENUM: ['TEXT', 'ENUM'], | ||
21 | +}; | ||
22 | + | ||
18 | export const multipleType = [ | 23 | export const multipleType = [ |
19 | 'STRING', | 24 | 'STRING', |
20 | 'REL_MULTI', | 25 | 'REL_MULTI', |
@@ -733,10 +738,13 @@ export const QxBaseConditionItem: React.FC<QxBaseConditionItemProps> = ({ | @@ -733,10 +738,13 @@ export const QxBaseConditionItem: React.FC<QxBaseConditionItemProps> = ({ | ||
733 | setOpen(false); | 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 | const { genDisplayDom } = useNodeFieldDisplay({ | 744 | const { genDisplayDom } = useNodeFieldDisplay({ |
737 | node: node, | 745 | node: node, |
738 | nodes: nodes, | 746 | nodes: nodes, |
739 | - limitTypes: [field.extract?.fieldType], | 747 | + limitTypes, |
740 | value: valuesObj?.value, | 748 | value: valuesObj?.value, |
741 | subset, | 749 | subset, |
742 | }); | 750 | }); |
@@ -829,7 +837,7 @@ export const QxBaseConditionItem: React.FC<QxBaseConditionItemProps> = ({ | @@ -829,7 +837,7 @@ export const QxBaseConditionItem: React.FC<QxBaseConditionItemProps> = ({ | ||
829 | open={open} | 837 | open={open} |
830 | value={valuesObj?.value} | 838 | value={valuesObj?.value} |
831 | onChange={handleAssignment} | 839 | onChange={handleAssignment} |
832 | - limitTypes={[field.extract?.fieldType]} | 840 | + limitTypes={limitTypes} |
833 | subset={subset} | 841 | subset={subset} |
834 | > | 842 | > |
835 | {RenderContent} | 843 | {RenderContent} |
@@ -8,6 +8,31 @@ export const FieldBaseType = { | @@ -8,6 +8,31 @@ export const FieldBaseType = { | ||
8 | DOUBLE: 'NUM', | 8 | DOUBLE: 'NUM', |
9 | NUMBER: 'NUM', | 9 | NUMBER: 'NUM', |
10 | YEAR_SEC: 'DATE', | 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 | export const QxBaseCondition: React.FC<QxBaseConditionProps> = (props) => { | 38 | export const QxBaseCondition: React.FC<QxBaseConditionProps> = (props) => { |
@@ -3,6 +3,7 @@ import { Collapse, Dropdown, Empty, Tag } from 'antd'; | @@ -3,6 +3,7 @@ import { Collapse, Dropdown, Empty, Tag } from 'antd'; | ||
3 | import cls from 'classnames'; | 3 | import cls from 'classnames'; |
4 | import { cloneDeep } from 'lodash-es'; | 4 | import { cloneDeep } from 'lodash-es'; |
5 | import React, { useEffect, useState } from 'react'; | 5 | import React, { useEffect, useState } from 'react'; |
6 | +import { FieldBaseType } from '../qx-base-condition'; | ||
6 | import { QxBaseIcon } from '../qx-base-icon'; | 7 | import { QxBaseIcon } from '../qx-base-icon'; |
7 | import { request } from '../utils'; | 8 | import { request } from '../utils'; |
8 | import './index.less'; | 9 | import './index.less'; |
@@ -151,11 +152,11 @@ export const useNodeFieldDisplay = ({ | @@ -151,11 +152,11 @@ export const useNodeFieldDisplay = ({ | ||
151 | } | 152 | } |
152 | } | 153 | } |
153 | 154 | ||
154 | - return displayConfig | ||
155 | - } | 155 | + return displayConfig; |
156 | + }; | ||
156 | 157 | ||
157 | const genDisplayDom = (value: string, nodes: INode[] = optionalNodes) => { | 158 | const genDisplayDom = (value: string, nodes: INode[] = optionalNodes) => { |
158 | - const displayConfig = getDisplayConfig(value, nodes) | 159 | + const displayConfig = getDisplayConfig(value, nodes); |
159 | return ( | 160 | return ( |
160 | <> | 161 | <> |
161 | {displayConfig?.map((item, idx) => ( | 162 | {displayConfig?.map((item, idx) => ( |
@@ -301,7 +302,7 @@ export const useNodeFieldDisplay = ({ | @@ -301,7 +302,7 @@ export const useNodeFieldDisplay = ({ | ||
301 | correctionNodeField(targetParentNodes[i].data?.result || []); | 302 | correctionNodeField(targetParentNodes[i].data?.result || []); |
302 | } | 303 | } |
303 | 304 | ||
304 | - if (!limitTypes) { | 305 | + if (!limitTypes || !limitTypes.length) { |
305 | setOptionalNodes(targetParentNodes); | 306 | setOptionalNodes(targetParentNodes); |
306 | renderInputDisplay(targetParentNodes); | 307 | renderInputDisplay(targetParentNodes); |
307 | return; | 308 | return; |
@@ -317,11 +318,19 @@ export const useNodeFieldDisplay = ({ | @@ -317,11 +318,19 @@ export const useNodeFieldDisplay = ({ | ||
317 | resultItem.child = getEffectiveResult(resultItem.child); | 318 | resultItem.child = getEffectiveResult(resultItem.child); |
318 | if ( | 319 | if ( |
319 | (Array.isArray(resultItem.child) && resultItem.child.length) || | 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 | newResult.push(resultItem); | 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 | newResult.push(resultItem); | 334 | newResult.push(resultItem); |
326 | } | 335 | } |
327 | } | 336 | } |
@@ -479,7 +488,7 @@ export const QxFlowNodeFieldSelector: React.FC<NodeFieldSelectProps> = ( | @@ -479,7 +488,7 @@ export const QxFlowNodeFieldSelector: React.FC<NodeFieldSelectProps> = ( | ||
479 | const newValue = '${' + `${nodeKey}|${item.id}` + '}'; | 488 | const newValue = '${' + `${nodeKey}|${item.id}` + '}'; |
480 | props.onChange?.(newValue, item); | 489 | props.onChange?.(newValue, item); |
481 | if (!props.children) { | 490 | if (!props.children) { |
482 | - renderInputDisplay(optionalNodes ,newValue); | 491 | + renderInputDisplay(optionalNodes, newValue); |
483 | } | 492 | } |
484 | setVisible(false); | 493 | setVisible(false); |
485 | }; | 494 | }; |