forked from p96170835/amis
添加 AssocicatedCheckboxes 草稿
This commit is contained in:
parent
878bb8c8f3
commit
9dffaa875b
|
@ -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 {Checkboxes, CheckboxesProps} from './Checkboxes';
|
||||||
import {themeable} from '../theme';
|
import {themeable} from '../theme';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
@ -8,12 +11,16 @@ import {getTreeDepth} from '../utils/helper';
|
||||||
import times from 'lodash/times';
|
import times from 'lodash/times';
|
||||||
import Spinner from './Spinner';
|
import Spinner from './Spinner';
|
||||||
|
|
||||||
|
export interface ChainedCheckboxesProps extends CheckboxesProps {
|
||||||
|
defaultSelectedIndex?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ChainedCheckboxesState {
|
export interface ChainedCheckboxesState {
|
||||||
selected: Array<string>;
|
selected: Array<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ChainedCheckboxes extends Checkboxes<
|
export class ChainedCheckboxes extends Checkboxes<
|
||||||
CheckboxesProps,
|
ChainedCheckboxesProps,
|
||||||
ChainedCheckboxesState
|
ChainedCheckboxesState
|
||||||
> {
|
> {
|
||||||
valueArray: Array<Option>;
|
valueArray: Array<Option>;
|
||||||
|
@ -21,6 +28,16 @@ export class ChainedCheckboxes extends Checkboxes<
|
||||||
selected: []
|
selected: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const defaultSelectedIndex = this.props.defaultSelectedIndex;
|
||||||
|
|
||||||
|
if (defaultSelectedIndex !== undefined) {
|
||||||
|
this.setState({
|
||||||
|
selected: [`${defaultSelectedIndex}`]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
selectOption(option: Option, depth: number, id: string) {
|
selectOption(option: Option, depth: number, id: string) {
|
||||||
const {onDeferLoad} = this.props;
|
const {onDeferLoad} = this.props;
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,7 @@ export class TabsTransfer extends React.Component<TabsTransferProps> {
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
option2value={option2value}
|
option2value={option2value}
|
||||||
onDeferLoad={onDeferLoad}
|
onDeferLoad={onDeferLoad}
|
||||||
|
defaultSelectedIndex={option.defaultSelectedIndex}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ListCheckboxes
|
<ListCheckboxes
|
||||||
|
|
Loading…
Reference in New Issue