Merge remote-tracking branch 'baidu/master'

This commit is contained in:
2betop 2020-02-14 12:49:31 +08:00
commit 59417650d4
5 changed files with 38 additions and 18 deletions

View File

@ -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>

View File

@ -500,7 +500,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
replaceLocation: boolean = false, replaceLocation: boolean = false,
search: boolean = true search: boolean = true
) { ) {
const {store, syncLocation, env, pageField, perPageField} = this.props; const {store, syncLocation, env, pageField, perPageField, loadDataOnceFetchOnFilter} = this.props;
values = syncLocation ? qs.parse(qsstringify(values)) : values; values = syncLocation ? qs.parse(qsstringify(values)) : values;
store.updateQuery( store.updateQuery(
@ -515,7 +515,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
perPageField perPageField
); );
this.lastQuery = store.query; this.lastQuery = store.query;
search && this.search(); search && this.search(undefined, undefined, undefined, loadDataOnceFetchOnFilter);
} }
handleBulkGo( handleBulkGo(
@ -673,7 +673,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
values?: any, values?: any,
silent?: boolean, silent?: boolean,
clearSelection?: boolean, clearSelection?: boolean,
forceReload = true forceReload = false
) { ) {
const { const {
store, store,
@ -782,7 +782,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
pageField, pageField,
perPageField perPageField
); );
this.search(undefined, undefined, undefined, false);
this.search(undefined, undefined, undefined);
if (autoJumpToTopOnPagerChange && this.control) { if (autoJumpToTopOnPagerChange && this.control) {
(findDOMNode(this.control) as HTMLElement).scrollIntoView(); (findDOMNode(this.control) as HTMLElement).scrollIntoView();
@ -1060,7 +1061,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
if (query) { if (query) {
return this.receive(query); return this.receive(query);
} else { } else {
this.search(undefined, undefined, true); this.search(undefined, undefined, true, true);
} }
} }

View File

@ -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}

View File

@ -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}
/> />

View File

@ -129,8 +129,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
) { ) {
try { try {
if ( if (
(options.forceReload === false || !options.forceReload &&
options.loadDataOnceFetchOnFilter === false) &&
options.loadDataOnce && options.loadDataOnce &&
self.total self.total
) { ) {