diff --git a/docs/zh-CN/components/crud.md b/docs/zh-CN/components/crud.md index b6d980f9091..057c565ab09 100755 --- a/docs/zh-CN/components/crud.md +++ b/docs/zh-CN/components/crud.md @@ -1903,7 +1903,11 @@ interface CRUDMatchFunc { /* 列配置 */ columns: any; /** match-sorter 匹配函数 */ - matchSorter: (items: any[], value: string, options?: MatchSorterOptions) => any[] + matchSorter: ( + items: any[], + value: string, + options?: MatchSorterOptions + ) => any[]; } ): boolean; } @@ -3445,17 +3449,66 @@ itemAction 里的 onClick 还能通过 `data` 参数拿到当前行的数据, 当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细查看[事件动作](../../docs/concepts/event-action)。 -| 事件名称 | 事件参数 | 说明 | -| -------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------- | -| selectedChange | `selectedItems: item[]` 已选择行
`unSelectedItems: item[]` 未选择行 | 手动选择表格项时触发 | -| columnSort | `orderBy: string` 列排序列名
`orderDir: string` 列排序值 | 点击列排序时触发 | -| columnFilter | `filterName: string` 列筛选列名
`filterValue: string \| undefined` 列筛选值 | 点击列筛选时触发,点击重置后事件参数`filterValue`为`undefined` | -| columnSearch | `searchName: string` 列搜索列名
`searchValue: object` 列搜索数据 | 点击列搜索时触发 | -| orderChange | `movedItems: item[]` 已排序数据 | 手动拖拽行排序时触发 | -| columnToggled | `columns: item[]` 当前显示的列配置数据 | 点击自定义列时触发 | -| rowClick | `item: object` 行点击数据
`index: number` 行索引 | 点击整行时触发 | -| rowMouseEnter | `item: object` 行移入数据
`index: number` 行索引 | 移入整行时触发 | -| rowMouseLeave | `item: object` 行移出数据
`index: number` 行索引 | 移出整行时触发 | +| 事件名称 | 事件参数 | 说明 | +| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- | +| fetchInited | `responseData: any` 请求的响应数据
`responseStatus: number` 响应状态,0 表示成功
`responseMsg: string`响应消息, `error`表示接口是否成功
`[name]: any` 当前数据域中指定字段的值 | api 接口请求完成时触发 | +| selectedChange | `selectedItems: item[]` 已选择行
`unSelectedItems: item[]` 未选择行 | 手动选择表格项时触发 | +| columnSort | `orderBy: string` 列排序列名
`orderDir: string` 列排序值 | 点击列排序时触发 | +| columnFilter | `filterName: string` 列筛选列名
`filterValue: string \| undefined` 列筛选值 | 点击列筛选时触发,点击重置后事件参数`filterValue`为`undefined` | +| columnSearch | `searchName: string` 列搜索列名
`searchValue: object` 列搜索数据 | 点击列搜索时触发 | +| orderChange | `movedItems: item[]` 已排序数据 | 手动拖拽行排序时触发 | +| columnToggled | `columns: item[]` 当前显示的列配置数据 | 点击自定义列时触发 | +| rowClick | `item: object` 行点击数据
`index: number` 行索引 | 点击整行时触发 | +| rowMouseEnter | `item: object` 行移入数据
`index: number` 行索引 | 移入整行时触发 | +| rowMouseLeave | `item: object` 行移出数据
`index: number` 行索引 | 移出整行时触发 | + +### fetchInited + +```schema: scope="body" +{ + "type": "crud", + "api": "/api/mock2/sample", + "syncLocation": false, + "onEvent": { + "fetchInited": { + "actions": [ + { + "actionType": "toast", + "args": { + "msg": "count:${event.data.responseData.count},status:${event.data.responseStatus}" + } + } + ] + } + }, + "columns": [ + { + "name": "id", + "label": "ID" + }, + { + "name": "engine", + "label": "Rendering engine" + }, + { + "name": "browser", + "label": "Browser" + }, + { + "name": "platform", + "label": "Platform(s)" + }, + { + "name": "version", + "label": "Engine version" + }, + { + "name": "grade", + "label": "CSS grade" + } + ] + } +``` ### selectedChange diff --git a/docs/zh-CN/components/page.md b/docs/zh-CN/components/page.md index 85f996e0c33..dce97c42f3b 100755 --- a/docs/zh-CN/components/page.md +++ b/docs/zh-CN/components/page.md @@ -322,7 +322,7 @@ Page 默认将页面分为几个区域,分别是**内容区(`body`)**、** "actionType": "toast", "args": { "msgType": "info", - "msg": "${event.data.responseData|json}" + "msg": "data:${event.data.responseData|json},status:${event.data.responseStatus}" } } ] diff --git a/packages/amis-core/src/store/crud.ts b/packages/amis-core/src/store/crud.ts index a72c3b8c74f..7edc6ed46f1 100644 --- a/packages/amis-core/src/store/crud.ts +++ b/packages/amis-core/src/store/crud.ts @@ -511,6 +511,8 @@ export const CRUDStore = ServiceStore.named('CRUDStore') self.markFetching(false); + self.updateMessage(e.message || e, true); + if (env.isCancel(e)) { return; } diff --git a/packages/amis-core/src/store/service.ts b/packages/amis-core/src/store/service.ts index 0a2a48efb92..1f64b37951f 100644 --- a/packages/amis-core/src/store/service.ts +++ b/packages/amis-core/src/store/service.ts @@ -145,6 +145,7 @@ export const ServiceStore = iRendererStore markFetching(false); console.error(e); let message = e.message || e; + updateMessage(message, true); if (e && e.message === 'Network Error') { message = self.__('networkError'); } @@ -252,6 +253,7 @@ export const ServiceStore = iRendererStore markFetching(false); console.error(e); let message = e.message || e; + updateMessage(message, true); if (e && e.message === 'Network Error') { message = self.__('networkError'); } @@ -348,6 +350,8 @@ export const ServiceStore = iRendererStore console.error(e); + updateMessage(e.message || e, true); + if (!(api as ApiObject).silent) { if (e.type === 'ServerError') { const result = (e as ServerError).response; @@ -489,6 +493,7 @@ export const ServiceStore = iRendererStore console.error(e); let message = e.message || e; + updateMessage(message, true); if (e && e.message === 'Network Error') { message = self.__('networkError'); }