mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
fix: 修复crud2按钮列表管理编辑bug
This commit is contained in:
parent
f468044072
commit
dd2eb4348b
@ -1,8 +1,8 @@
|
|||||||
import React from 'react';
|
import React, {StrictMode} from 'react';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import flattenDeep from 'lodash/flattenDeep';
|
import flattenDeep from 'lodash/flattenDeep';
|
||||||
import {Button, Icon} from 'amis';
|
import {Button, Icon} from 'amis';
|
||||||
import {getVariable, isObject} from 'amis-core';
|
import {dataMapping, getVariable, isObject} from 'amis-core';
|
||||||
import {
|
import {
|
||||||
BasePlugin,
|
BasePlugin,
|
||||||
BasicRendererInfo,
|
BasicRendererInfo,
|
||||||
@ -610,6 +610,7 @@ export class TableCell2Plugin extends BasePlugin {
|
|||||||
body: [
|
body: [
|
||||||
{
|
{
|
||||||
type: 'ae-feature-control',
|
type: 'ae-feature-control',
|
||||||
|
strictMode: false, // 注意需要添加这个才能及时获取表单data变更
|
||||||
label: false,
|
label: false,
|
||||||
manager,
|
manager,
|
||||||
addable: true,
|
addable: true,
|
||||||
@ -652,7 +653,7 @@ export class TableCell2Plugin extends BasePlugin {
|
|||||||
schema.buttons.push({
|
schema.buttons.push({
|
||||||
label: '新增按钮',
|
label: '新增按钮',
|
||||||
level: 'link'
|
level: 'link'
|
||||||
}),
|
});
|
||||||
onBulkChange(schema);
|
onBulkChange(schema);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@ import React from 'react';
|
|||||||
import {findDOMNode} from 'react-dom';
|
import {findDOMNode} from 'react-dom';
|
||||||
import Sortable from 'sortablejs';
|
import Sortable from 'sortablejs';
|
||||||
import cx from 'classnames';
|
import cx from 'classnames';
|
||||||
import clone from 'lodash/clone';
|
import cloneDeep from 'lodash/cloneDeep';
|
||||||
import remove from 'lodash/remove';
|
import remove from 'lodash/remove';
|
||||||
import isPlainObject from 'lodash/isPlainObject';
|
import isPlainObject from 'lodash/isPlainObject';
|
||||||
import {FormItem, Button, Icon, FormControlProps, autobind} from 'amis';
|
import {FormItem, Button, Icon, FormControlProps, autobind} from 'amis';
|
||||||
@ -106,21 +106,23 @@ export default class FeatureControl extends React.Component<
|
|||||||
@autobind
|
@autobind
|
||||||
handleRemove(item: FeatureOption, index: number) {
|
handleRemove(item: FeatureOption, index: number) {
|
||||||
const {removeFeature, data, onBulkChange} = this.props;
|
const {removeFeature, data, onBulkChange} = this.props;
|
||||||
|
const schema = cloneDeep(data);
|
||||||
const {inUseFeat, unUseFeat} = this.state;
|
const {inUseFeat, unUseFeat} = this.state;
|
||||||
item.remove?.(data);
|
item.remove?.(schema);
|
||||||
removeFeature?.(item, data);
|
removeFeature?.(item, schema);
|
||||||
onBulkChange?.(data);
|
|
||||||
|
|
||||||
remove(inUseFeat, item);
|
remove(inUseFeat, item);
|
||||||
item.add && unUseFeat.push(item);
|
item.add && unUseFeat.push(item);
|
||||||
|
onBulkChange?.(schema);
|
||||||
|
|
||||||
this.setState({inUseFeat, unUseFeat});
|
this.setState({inUseFeat, unUseFeat});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSort(e: any) {
|
handleSort(e: any) {
|
||||||
const {data, onBulkChange, onSort} = this.props;
|
const {data, onBulkChange, onSort} = this.props;
|
||||||
onSort?.(data, e);
|
let schema = cloneDeep(data);
|
||||||
onBulkChange?.(data);
|
onSort?.(schema, e);
|
||||||
|
onBulkChange?.(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
@ -131,7 +133,7 @@ export default class FeatureControl extends React.Component<
|
|||||||
inUseFeat.push(item);
|
inUseFeat.push(item);
|
||||||
remove(unUseFeat, item);
|
remove(unUseFeat, item);
|
||||||
|
|
||||||
const schema = clone(data);
|
const schema = cloneDeep(data);
|
||||||
item.add?.(schema);
|
item.add?.(schema);
|
||||||
addFeature?.(item, schema);
|
addFeature?.(item, schema);
|
||||||
onBulkChange?.(schema);
|
onBulkChange?.(schema);
|
||||||
@ -187,6 +189,7 @@ export default class FeatureControl extends React.Component<
|
|||||||
|
|
||||||
const value = this.state.inUseFeat.concat();
|
const value = this.state.inUseFeat.concat();
|
||||||
value[e.oldIndex] = value.splice(e.newIndex, 1, value[e.oldIndex])[0];
|
value[e.oldIndex] = value.splice(e.newIndex, 1, value[e.oldIndex])[0];
|
||||||
|
|
||||||
this.setState({inUseFeat: value}, () => {
|
this.setState({inUseFeat: value}, () => {
|
||||||
this.handleSort({
|
this.handleSort({
|
||||||
oldIndex: e.oldIndex,
|
oldIndex: e.oldIndex,
|
||||||
@ -208,7 +211,7 @@ export default class FeatureControl extends React.Component<
|
|||||||
@autobind
|
@autobind
|
||||||
handleCheck(res: boolean, index: number) {
|
handleCheck(res: boolean, index: number) {
|
||||||
const {data, onBulkChange, onItemCheck} = this.props;
|
const {data, onBulkChange, onItemCheck} = this.props;
|
||||||
const schema = clone(data);
|
const schema = cloneDeep(data);
|
||||||
onItemCheck?.(res, index, schema);
|
onItemCheck?.(res, index, schema);
|
||||||
onBulkChange?.(schema);
|
onBulkChange?.(schema);
|
||||||
}
|
}
|
||||||
@ -282,7 +285,7 @@ export default class FeatureControl extends React.Component<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (customAction && typeof customAction === 'function') {
|
if (customAction && typeof customAction === 'function') {
|
||||||
const schema = customAction({onBulkChange, schema: clone(data)});
|
const schema = customAction({onBulkChange, schema: cloneDeep(data)});
|
||||||
|
|
||||||
if (isPlainObject(schema) && typeof schema.type === 'string') {
|
if (isPlainObject(schema) && typeof schema.type === 'string') {
|
||||||
return render('custom-action', schema);
|
return render('custom-action', schema);
|
||||||
|
Loading…
Reference in New Issue
Block a user