commit
edfed5492d
|
@ -67,15 +67,19 @@ interface TreeSelectorProps {
|
||||||
// 是否为内建 增、改、删。当有复杂表单的时候直接抛出去让外层能统一处理
|
// 是否为内建 增、改、删。当有复杂表单的时候直接抛出去让外层能统一处理
|
||||||
bultinCUD?: boolean;
|
bultinCUD?: boolean;
|
||||||
rootCreatable?: boolean;
|
rootCreatable?: boolean;
|
||||||
|
rootCreateTip?: string;
|
||||||
creatable?: boolean;
|
creatable?: boolean;
|
||||||
|
createTip?: string;
|
||||||
onAdd?: (
|
onAdd?: (
|
||||||
idx?: number | Array<number>,
|
idx?: number | Array<number>,
|
||||||
value?: any,
|
value?: any,
|
||||||
skipForm?: boolean
|
skipForm?: boolean
|
||||||
) => void;
|
) => void;
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
|
editTip?: string;
|
||||||
onEdit?: (value: Option, origin?: Option, skipForm?: boolean) => void;
|
onEdit?: (value: Option, origin?: Option, skipForm?: boolean) => void;
|
||||||
removable?: boolean;
|
removable?: boolean;
|
||||||
|
deleteTip?: string;
|
||||||
onDelete?: (value: Option) => void;
|
onDelete?: (value: Option) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +120,11 @@ export class TreeSelector extends React.Component<
|
||||||
rootLabel: '顶级',
|
rootLabel: '顶级',
|
||||||
rootValue: 0,
|
rootValue: 0,
|
||||||
cascade: false,
|
cascade: false,
|
||||||
selfDisabledAffectChildren: true
|
selfDisabledAffectChildren: true,
|
||||||
|
rootCreateTip: '添加一级节点',
|
||||||
|
createTip: '添加孩子节点',
|
||||||
|
editTip: '编辑该节点',
|
||||||
|
deleteTip: '移除该节点'
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
|
@ -466,7 +474,10 @@ export class TreeSelector extends React.Component<
|
||||||
minLength,
|
minLength,
|
||||||
creatable,
|
creatable,
|
||||||
editable,
|
editable,
|
||||||
removable
|
removable,
|
||||||
|
createTip,
|
||||||
|
editTip,
|
||||||
|
deleteTip
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const {
|
const {
|
||||||
unfolded,
|
unfolded,
|
||||||
|
@ -602,7 +613,7 @@ export class TreeSelector extends React.Component<
|
||||||
{creatable && hasAbility(item, 'creatable') ? (
|
{creatable && hasAbility(item, 'creatable') ? (
|
||||||
<a
|
<a
|
||||||
onClick={this.handleAdd.bind(this, item)}
|
onClick={this.handleAdd.bind(this, item)}
|
||||||
data-tooltip="添加孩子节点"
|
data-tooltip={createTip}
|
||||||
>
|
>
|
||||||
<Icon icon="plus" className="icon" />
|
<Icon icon="plus" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -611,7 +622,7 @@ export class TreeSelector extends React.Component<
|
||||||
{removable && hasAbility(item, 'removable') ? (
|
{removable && hasAbility(item, 'removable') ? (
|
||||||
<a
|
<a
|
||||||
onClick={this.handleRemove.bind(this, item)}
|
onClick={this.handleRemove.bind(this, item)}
|
||||||
data-tooltip="移除该节点"
|
data-tooltip={deleteTip}
|
||||||
>
|
>
|
||||||
<Icon icon="minus" className="icon" />
|
<Icon icon="minus" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -620,7 +631,7 @@ export class TreeSelector extends React.Component<
|
||||||
{editable && hasAbility(item, 'editable') ? (
|
{editable && hasAbility(item, 'editable') ? (
|
||||||
<a
|
<a
|
||||||
onClick={this.handleEdit.bind(this, item)}
|
onClick={this.handleEdit.bind(this, item)}
|
||||||
data-tooltip="编辑该节点"
|
data-tooltip={editTip}
|
||||||
>
|
>
|
||||||
<Icon icon="pencil" className="icon" />
|
<Icon icon="pencil" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -676,6 +687,7 @@ export class TreeSelector extends React.Component<
|
||||||
classnames: cx,
|
classnames: cx,
|
||||||
creatable,
|
creatable,
|
||||||
rootCreatable,
|
rootCreatable,
|
||||||
|
rootCreateTip,
|
||||||
disabled
|
disabled
|
||||||
} = this.props;
|
} = this.props;
|
||||||
let options = this.props.options;
|
let options = this.props.options;
|
||||||
|
@ -692,7 +704,7 @@ export class TreeSelector extends React.Component<
|
||||||
onClick={this.handleAdd.bind(this, null)}
|
onClick={this.handleAdd.bind(this, null)}
|
||||||
>
|
>
|
||||||
<Icon icon="plus" className="icon" />
|
<Icon icon="plus" className="icon" />
|
||||||
<span>添加一级节点</span>
|
<span>{rootCreateTip}</span>
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -731,7 +743,7 @@ export class TreeSelector extends React.Component<
|
||||||
{creatable ? (
|
{creatable ? (
|
||||||
<a
|
<a
|
||||||
onClick={this.handleAdd.bind(this, null)}
|
onClick={this.handleAdd.bind(this, null)}
|
||||||
data-tooltip="添加一级节点"
|
data-tooltip={rootCreateTip}
|
||||||
>
|
>
|
||||||
<Icon icon="plus" className="icon" />
|
<Icon icon="plus" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -774,9 +774,9 @@ export function registerOptionsControl(config: OptionsConfig) {
|
||||||
setOptions={this.setOptions}
|
setOptions={this.setOptions}
|
||||||
syncOptions={this.syncOptions}
|
syncOptions={this.syncOptions}
|
||||||
reloadOptions={this.reload}
|
reloadOptions={this.reload}
|
||||||
creatable={creatable || isEffectiveApi(addApi)}
|
creatable={creatable || creatable !== false && isEffectiveApi(addApi)}
|
||||||
editable={editable || isEffectiveApi(editApi)}
|
editable={editable || editable !== false && isEffectiveApi(editApi)}
|
||||||
removable={removable || isEffectiveApi(deleteApi)}
|
removable={removable || removable !== false && isEffectiveApi(deleteApi)}
|
||||||
onAdd={this.handleOptionAdd}
|
onAdd={this.handleOptionAdd}
|
||||||
onEdit={this.handleOptionEdit}
|
onEdit={this.handleOptionEdit}
|
||||||
onDelete={this.handleOptionDelete}
|
onDelete={this.handleOptionDelete}
|
||||||
|
|
|
@ -59,13 +59,17 @@ export default class TreeControl extends React.Component<TreeProps> {
|
||||||
showRadio,
|
showRadio,
|
||||||
onAdd,
|
onAdd,
|
||||||
creatable,
|
creatable,
|
||||||
|
createTip,
|
||||||
addControls,
|
addControls,
|
||||||
onEdit,
|
onEdit,
|
||||||
editable,
|
editable,
|
||||||
|
editTip,
|
||||||
editControls,
|
editControls,
|
||||||
removable,
|
removable,
|
||||||
|
deleteTip,
|
||||||
onDelete,
|
onDelete,
|
||||||
rootCreatable
|
rootCreatable,
|
||||||
|
rootCreateTip
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -99,10 +103,14 @@ export default class TreeControl extends React.Component<TreeProps> {
|
||||||
selfDisabledAffectChildren={false}
|
selfDisabledAffectChildren={false}
|
||||||
onAdd={onAdd}
|
onAdd={onAdd}
|
||||||
creatable={creatable}
|
creatable={creatable}
|
||||||
|
createTip={createTip}
|
||||||
rootCreatable={rootCreatable}
|
rootCreatable={rootCreatable}
|
||||||
|
rootCreateTip={rootCreateTip}
|
||||||
onEdit={onEdit}
|
onEdit={onEdit}
|
||||||
editable={editable}
|
editable={editable}
|
||||||
|
editTip={editTip}
|
||||||
removable={removable}
|
removable={removable}
|
||||||
|
deleteTip={deleteTip}
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
bultinCUD={!addControls && !editControls}
|
bultinCUD={!addControls && !editControls}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue