Skip to content

Commit a1ec68f

Browse files
committed
Merge branch '3.5.x'
2 parents 5cb16ab + 9906b5e commit a1ec68f

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

framework/elsa/fit-elsa-react/src/components/intelligentForm/FormItemSelectValue.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ export const FormItemSelectValue = ({item, shapeStatus, onChange, label, inputRe
123123
return <JadeReferenceTreeSelect
124124
className='jade-input-tree-title-tree-select jade-select'
125125
disabled={shapeStatus.referenceDisabled}
126-
rules={[{
126+
rules={inputRequired ? [{
127127
required: true, message: t('fieldValueCannotBeEmpty'),
128-
}]}
128+
}] : []}
129129
reference={item}
130130
onReferencedKeyChange={(e) => onReferenceKeyChange(e)}
131131
onReferencedValueChange={(referenceKey, value, type) => onReferenceValueChange(referenceKey, value, type)}

framework/elsa/fit-elsa-react/src/components/intelligentForm/IntelligentFormWrapper.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export default function IntelligentFormWrapper({data, shapeStatus}) {
127127
}
128128
className="jade-panel"
129129
style={{marginBottom: 8, borderRadius: '8px', width: '100%'}}
130+
forceRender
130131
>
131132
<div className={'jade-custom-panel-content'}>
132133
<IntelligentInputFormItem item={item} items={items} shapeStatus={shapeStatus} output={output}/>

framework/elsa/fit-elsa-react/src/components/intelligentForm/IntelligentInputFormItem.jsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,35 @@ const _IntelligentInputFormItem = ({item, items, shapeStatus, output}) => {
3838
* @param entries 修改的数组
3939
*/
4040
const handleFormValueChange = (id, entries = []) => {
41-
const changes = new Map(entries.map(({ key, value }) => [key, value])); // 将 entries 转换为 Map
42-
// 如果 type 是 'type',清空 renderType
43-
if (changes.has('renderType') && changes.get('renderType') !== item.renderType) {
44-
changes.set('type', undefined);
45-
if (changes.get('renderType') === RENDER_TYPE.CHECK_BOX) {
46-
changes.set('type', DATA_TYPES.ARRAY);
41+
const changes = new Map(entries.map(({key, value}) => [key, value])); // 将 entries 转换为 Map
42+
43+
const updateFormValues = (newValue) => {
44+
const fieldName = `value-${item.id}`;
45+
const formValue = Array.isArray(newValue) ? newValue : newValue || undefined;
46+
changes.set('value', newValue);
47+
form.setFieldsValue({ [fieldName]: formValue });
48+
};
49+
50+
const handleRenderTypeChange = () => {
51+
if (!changes.has('renderType') || changes.get('renderType') === item.renderType) {
52+
return;
4753
}
48-
changes.set('value', null);
49-
form.setFieldsValue({[`value-${item.id}`]: undefined});
50-
}
51-
dispatch({ type: 'updateParam', id: id, changes });
54+
const isCheckbox = changes.get('renderType') === RENDER_TYPE.CHECK_BOX;
55+
changes.set('type', isCheckbox ? DATA_TYPES.ARRAY : undefined);
56+
updateFormValues(isCheckbox ? [] : '');
57+
};
58+
59+
const handleTypeChange = () => {
60+
if (!changes.has('type') || changes.get('type') === item.type) {
61+
return;
62+
}
63+
const isArrayType = changes.get('type') === DATA_TYPES.ARRAY;
64+
updateFormValues(isArrayType ? [] : '');
65+
};
66+
67+
handleRenderTypeChange();
68+
handleTypeChange();
69+
dispatch({type: 'updateParam', id: id, changes});
5270
};
5371

5472
const handleOptionsChange = (id, entries = []) => {

framework/elsa/fit-elsa-react/src/components/start/StartFormWrapper.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export default function StartFormWrapper({data, shapeStatus}) {
163163
}
164164
className="jade-panel"
165165
style={{marginBottom: 8, borderRadius: '8px', width: '100%'}}
166+
forceRender
166167
>
167168
<div className={'jade-custom-panel-content'}>
168169
<StartInputForm item={item} items={items}/>

0 commit comments

Comments
 (0)