-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
394 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...mponents/form-builder/registry/associated-records/associative-rules-config/dataSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
/* eslint-disable react/prop-types */ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Cascader } from 'antd'; | ||
|
||
const DataSelect = (pro: any)=> { | ||
const { value, props, mutators } = pro || {}; | ||
const enumArr = JSON.parse(JSON.stringify(props?.enum || [])); | ||
const { componentName, appID, tableID } = enumArr.find((item: any)=>item?.value === value) || {}; | ||
const { rulesOptions = [] } = props?.['x-component-props'] || {}; | ||
const showSelect = componentName !== 'associateddata'; | ||
const [options, setOptions] = useState([]); | ||
const [defaultValue, setDefaultValue] = useState([]); | ||
|
||
useEffect(()=>{ | ||
setOptions(rulesOptions.sort((a: any, b: any)=>a.index - b.index)); | ||
}, [rulesOptions]); | ||
|
||
useEffect(()=>{ | ||
const _arr = value?.split('.'); | ||
const _defaultValue: any = []; | ||
const item: any = options?.find((item: any)=>{ | ||
return item.value === _arr?.[0]; | ||
}); | ||
item && _defaultValue.push(item?.label); | ||
if (_arr?.length === 2) { | ||
const child = item?.children?.find((child: any)=>{ | ||
return child.value === _arr?.[1]; | ||
}); | ||
child && _defaultValue.push(child?.label); | ||
} | ||
setDefaultValue(_defaultValue); | ||
}, [value, options]); | ||
|
||
const handleChange = (value: any) => { | ||
mutators?.change(value.join('.')); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Cascader options = {options} value={defaultValue} allowClear={false} onChange={handleChange} /> | ||
</> | ||
); | ||
}; | ||
|
||
DataSelect.isFieldComponent = true; | ||
|
||
export default DataSelect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
max-width: 12px; | ||
min-width: 12px; | ||
} | ||
|
||
.ml-210{ | ||
margin-left: 210px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.