/** * 基础 Action 组件, 主要实现了请求方式, 包含表单验证的方式 */ import { Component } from 'react'; import { getUrlParams } from 'uke-request/url-resolve'; import { Children } from 'ukelli-ui/core/utils'; import { FormLayoutProps } from 'ukelli-ui/core/form-generator/form-layout'; import { ReportTemplateProps, TemplateOptions, ReportActionBtn, PowerMapper, RecordActionBtn } from '../template-engine/for-report/types'; export interface ReqAgentReturn { err?: any; } export interface AgentOptions { /** 当前请求的 id */ id?: string; /** 在请求发起前设置组件的 state */ before?: () => {}; /** 在请求发起后设置组件的 state */ after?: (response: APIRetrue) => T | {}; /** response 的过滤器,用于过滤并返回 ActionAgent 的返回值 * * @example * const res = await actionAgent(api, { * resFilter: (resData) => { * resData.isDone = true; * return resData; * } * }) * console.log(res) // res = { ...other, isDone: true } */ resFilter?: (response?: APIRetrue) => T; /** 当前 api 的操作的 ref 值,用于做对应状态的 loading 切换 */ actingRef?: string; } export interface ReqAgentAPI extends Function { } declare class ActionAgent

extends Component { T: any; formBtns: FormLayoutProps['formBtns']; btnConfig: FormLayoutProps['formBtns']; formOptions: FormLayoutProps['formOptions']; templateOptions: TemplateOptions; keyMapper: ReportTemplateProps['keyMapper']; columns: ReportTemplateProps['columns']; conditionOptions: ReportTemplateProps['conditionOptions']; recordActionBtns: RecordActionBtn[]; reportActionBtns: ReportActionBtn[]; powerMapper: PowerMapper; getUrlParams: typeof getUrlParams; routerParams: string | object; agents: never[]; __unmount: any; _delayExec: any; getRecordBtns: (...args: any[]) => Children; componentWillUnmount(): void; /** * 请求过程的 state 状态代理 * @param {reqFunc} asyncFunc 业务 API * @param {agentOptions} object 此方法的配置项 * @return {async function} 返回传入的第一个参数的包装方法,在此过程插入一些生命周期函数 */ reqAgent(reqFunc: (...args: any[]) => Promise, agentOptions: AgentOptions): (...args: any[]) => Promise; _before(params: any, actingRef: any): any; _after(res: any): {}; /** * 在调用 after 之前执行的 checker 函数 * @param {response} res 系统传入的 res 对象 * @return {boolean} */ _checkRes(res: any): boolean; resStatus(res: any, id: any): void; delayExec(...args: any[]): any; stateSetter(state: any): void; } export default ActionAgent;