fix: CRUD兼容actionType方式触发reload (#4448)

This commit is contained in:
RUNZE LU 2022-05-25 20:13:57 +08:00 committed by GitHub
parent e435099576
commit 3fa85b0a9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 10 deletions

View File

@ -2172,21 +2172,35 @@ crud 组件支持通过配置`headerToolbar`和`footerToolbar`属性,实现在
} }
``` ```
它其实是个简化的 `button` 组件,可以参考 `button` 组件的文档做调整,比如 它其实是个简化的 `button` 组件,可以参考 `button` 组件的文档做调整。`reload`支持两种触发方式:
- `"type": "reload"`CRUD 内置的方法
- `{"actionType": "reload", "target": "targetName"}`,动作触发
```schema: scope="body" ```schema: scope="body"
{ {
"type": "crud", "type": "crud",
"name": "crud",
"syncLocation": false, "syncLocation": false,
"api": "/api/mock2/sample", "api": "/api/mock2/sample",
"headerToolbar": [ "headerToolbar": [
{
"type": "action",
"align": "right",
"icon": "iconfont icon-refresh",
"label": "刷新(actionType)",
"tooltip": "",
"level": "primary",
"actionType": 'reload',
"target": 'crud'
},
{ {
"type": "reload", "type": "reload",
"align": "right", "align": "right",
"icon": "iconfont icon-refresh", "icon": "iconfont icon-refresh",
"label": "刷新", "label": "刷新(type)",
"tooltip": "", "tooltip": "",
"level": "success" "level": "primary"
} }
], ],
"columns": [ "columns": [

View File

@ -670,6 +670,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
throw e; throw e;
} }
}); });
} else if (action.actionType === 'reload') {
this.reload();
} else if ( } else if (
pickerMode && pickerMode &&
(action.actionType === 'confirm' || action.actionType === 'submit') (action.actionType === 'confirm' || action.actionType === 'submit')

View File

@ -972,10 +972,7 @@ export default class Table extends React.Component<TableProps, object> {
return; return;
} }
onSaveOrder( onSaveOrder(movedItems, items);
movedItems,
items
);
} }
syncSelected() { syncSelected() {
@ -2300,7 +2297,10 @@ export default class Table extends React.Component<TableProps, object> {
onClick={async () => { onClick={async () => {
const {data, dispatchEvent} = this.props; const {data, dispatchEvent} = this.props;
const allToggled = !(store.activeToggaleColumns.length === store.toggableColumns.length); const allToggled = !(
store.activeToggaleColumns.length ===
store.toggableColumns.length
);
const rendererEvent = await dispatchEvent( const rendererEvent = await dispatchEvent(
'columnToggled', 'columnToggled',
createObject(data, { createObject(data, {
@ -2341,9 +2341,11 @@ export default class Table extends React.Component<TableProps, object> {
key={column.index} key={column.index}
onClick={async () => { onClick={async () => {
const {data, dispatchEvent} = this.props; const {data, dispatchEvent} = this.props;
let columns = store.activeToggaleColumns.map(item => item.pristine); let columns = store.activeToggaleColumns.map(
item => item.pristine
);
if (!column.toggled) { if (!column.toggled) {
columns.push(column.pristine) columns.push(column.pristine);
} else { } else {
columns = columns.filter(c => c.name !== column.pristine.name); columns = columns.filter(c => c.name !== column.pristine.name);
} }