import { ProCardProps } from '@ant-design/pro-card/es/ProCard'; import { ActionType, DragTableProps, DrawerFormProps, ModalFormProps, PageContainerProps, ProColumns, ProDescriptionsItemProps, ProTableProps, } from '@ant-design/pro-components'; import { ProListMetas, ProListProps } from '@ant-design/pro-list'; import { TourStepProps } from 'antd'; import { TabsProps } from 'antd/es/tabs'; import { Dayjs } from 'dayjs'; import React, { MutableRefObject } from 'react'; export type BizValueType = | 'user' | 'customField' | 'status' | 'remark' | 'order' | 'dealer' | 'paymentTask' | 'company' | 'orderCost' | 'supplier'; export type FormType = 'modal' | 'drawer' | 'step'; export type ModeType = | 'tree' | 'page' | 'drag' | 'list' | 'calender' | 'detail' | 'create' | 'update' | 'import' | 'destroy'; export interface ApiProps> { rowKey?: string; permission?: string; intlPrefix?: string; func?: Func; method?: string; methodUpper?: string; isMobile?: boolean; } export type BizFormType> = | ({ formType: 'modal' } & { fieldProps?: ModalFormProps }) | ({ formType: 'drawer' } & { fieldProps?: DrawerFormProps }) | ({ formType: 'step' } & { fieldProps?: DrawerFormProps }); export type BizCreateProps< BizVO extends Record, BizCreateCmd extends Record, Func extends Record, > = { formType?: FormType; formContext?: React.ReactNode; initValues?: Record; onFinish?: (record: BizVO) => void; trigger?: () => React.ReactNode; showNextCreate?: boolean; showUserCard?: boolean; request?: (formData: BizCreateCmd) => Promise; display?: (record?: BizVO) => boolean; } & ApiProps & BizFormType; export type BizImportProps< BizVO extends Record, BizCreateCmd extends Record, Func extends Record, > = { formType?: FormType; columns: ProColumns[]; transformData: (record: Record) => Promise; initValues?: Record; onFinish?: () => void; trigger?: () => React.ReactNode; tips?: string; display?: () => boolean; } & ApiProps & BizFormType; export type BizUpdateProps< BizVO extends Record, BizUpdateCmd extends Record, Func extends Record, > = { rowId?: string; row?: BizVO; formType?: FormType; formContext?: React.ReactNode; initValues?: Record; onFinish?: (record: BizUpdateCmd) => void; transform?: (record: BizVO) => Promise>; trigger?: (record?: BizVO) => React.ReactNode; request?: (formData: BizUpdateCmd) => Promise; display?: (record?: BizVO) => boolean; positionKey?: string; } & ApiProps & BizFormType; export type BizListProps< BizVO extends Record, BizPageQry extends Record, Func extends Record, > = { columns: ProColumns[]; metas: ProListMetas; options?: ( record: BizVO, actionRef: MutableRefObject, ) => React.ReactNode; fieldProps?: ProListProps; trigger?: () => React.ReactNode; } & ApiProps; export type BizPageProps< BizVO extends Record, BizPageQry extends Record, Func extends Record, > = { columns: ProColumns[]; options?: ( record: BizVO, actionRef: MutableRefObject, ) => React.ReactNode; fieldProps?: ProTableProps; trigger?: () => React.ReactNode; } & ApiProps; export interface BizTreeProps< BizVO extends Record, BizPageQry extends Record, Func extends Record, > extends ApiProps { columns: ProColumns[]; options?: ( record: BizVO, actionRef: MutableRefObject, ) => React.ReactNode; fieldProps?: ProTableProps; trigger?: () => React.ReactNode; } export interface BizDragProps< BizVO extends Record, BizPageQry extends Record, Func extends Record, > extends ApiProps { columns: ProColumns[]; options?: ( record: BizVO, actionRef: MutableRefObject, ) => React.ReactNode; fieldProps?: DragTableProps; trigger?: () => React.ReactNode; mode?: ModeType; } export interface BizCalenderProps< BizVO extends Record, BizPageQry extends Record, Func extends Record, > extends ApiProps { fieldProps: { rowKey: string; cardProps?: ProCardProps; rowName?: string; params?: BizPageQry; detailRender?: (record: BizVO, value: Dayjs) => React.ReactNode; actionRef?: MutableRefObject<{ reload: () => void } | undefined>; }; trigger?: () => React.ReactNode; } export type FormContextMode = 'tab' | 'flat'; export type BizDetailProps< BizVO extends Record, Func extends Record, > = { rowId?: string; row?: BizVO; formType: FormType; formContext?: ( record: BizVO, onValueChange: () => void, ) => TabsProps['items']; formContextMode?: FormContextMode; initValues?: (rowId: string) => Record; onFinish?: (record: BizVO) => void; trigger?: (record?: BizVO) => React.ReactNode; display?: (record?: BizVO) => boolean; columns?: ProDescriptionsItemProps[]; positionKey?: string; showDetail?: boolean; } & ApiProps & BizFormType; export interface BizDestroyProps< BizVO extends Record, Func extends Record, > extends ApiProps { rowId?: string; row?: BizVO; onFinish?: () => void; display?: (record?: BizVO) => boolean; disable?: (record?: BizVO) => boolean; positionKey?: string; } export type RemarkProps = { mode?: 'textarea' | 'editor'; ghost?: () => boolean; }; export interface BizTourProps { steps?: TourStepProps[]; expandSteps?: TourStepProps[]; } export type BizProps< Func extends Record, BizVO extends Record, BizPageQry extends Record, BizCreateCmd extends Record, BizUpdateCmd extends Record, > = { rowKey: string; permission: string; func: Func; method: string; methodUpper: string; intlPrefix: string; onValueChange?: () => void; remark?: RemarkProps; status?: boolean; modeType: ModeType; container: { ghost?: boolean; fieldProps?: PageContainerProps; }; tour?: false | BizTourProps; page?: false | BizPageProps; list?: false | BizListProps; tree?: false | BizTreeProps; drag?: false | BizDragProps; calender?: false | BizCalenderProps; create?: false | BizCreateProps; update?: false | BizUpdateProps; destroy?: false | BizDestroyProps; detail?: false | BizDetailProps; batchImport?: false | BizImportProps; }; // 定义固定位置按钮类型 export type FixedPositionKey = 'edit' | 'view' | 'delete'; export type InsertPosition = | `before:${FixedPositionKey}` | `after:${FixedPositionKey}`;