mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-16 01:40:53 +08:00
添加 AssocicatedCheckboxes 草稿
This commit is contained in:
parent
878bb8c8f3
commit
9dffaa875b
17
src/components/AssociatedCheckboxes.tsx
Normal file
17
src/components/AssociatedCheckboxes.tsx
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 关联多选框,仅支持两层关联选择。
|
||||
* 左边先点选,然后右边再次点选。
|
||||
* 可以满足,先从 tree 中选中一个元素,然后查出来一个列表再次勾选。
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
export interface AssociatedCheckboxesProps {}
|
||||
|
||||
export class AssociatedCheckboxes extends React.Component<
|
||||
AssociatedCheckboxesProps
|
||||
> {
|
||||
render() {
|
||||
return <div>todo</div>;
|
||||
}
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
/**
|
||||
* 级联多选框,支持无限极。从左侧到右侧一层层点选。
|
||||
*/
|
||||
import {Checkboxes, CheckboxesProps} from './Checkboxes';
|
||||
import {themeable} from '../theme';
|
||||
import React from 'react';
|
||||
@ -8,12 +11,16 @@ import {getTreeDepth} from '../utils/helper';
|
||||
import times from 'lodash/times';
|
||||
import Spinner from './Spinner';
|
||||
|
||||
export interface ChainedCheckboxesProps extends CheckboxesProps {
|
||||
defaultSelectedIndex?: string;
|
||||
}
|
||||
|
||||
export interface ChainedCheckboxesState {
|
||||
selected: Array<string>;
|
||||
}
|
||||
|
||||
export class ChainedCheckboxes extends Checkboxes<
|
||||
CheckboxesProps,
|
||||
ChainedCheckboxesProps,
|
||||
ChainedCheckboxesState
|
||||
> {
|
||||
valueArray: Array<Option>;
|
||||
@ -21,6 +28,16 @@ export class ChainedCheckboxes extends Checkboxes<
|
||||
selected: []
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const defaultSelectedIndex = this.props.defaultSelectedIndex;
|
||||
|
||||
if (defaultSelectedIndex !== undefined) {
|
||||
this.setState({
|
||||
selected: [`${defaultSelectedIndex}`]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
selectOption(option: Option, depth: number, id: string) {
|
||||
const {onDeferLoad} = this.props;
|
||||
|
||||
|
@ -150,6 +150,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
|
||||
onChange={onChange}
|
||||
option2value={option2value}
|
||||
onDeferLoad={onDeferLoad}
|
||||
defaultSelectedIndex={option.defaultSelectedIndex}
|
||||
/>
|
||||
) : (
|
||||
<ListCheckboxes
|
||||
|
Loading…
Reference in New Issue
Block a user