import React, { Key } from 'react'; import { FormInstance } from 'antd/es/form'; import { NamePath } from 'antd/es/form/interface'; /** * 生成随机字符串 * @returns 随机字符串 */ export declare const getRandom: () => string; /** * 构建 AntD Table 的 rowKey 函数,支持字符串/函数两种形式, * 当用户指定字段值无效时(新增行尚未填写业务 key),自动降级到内部 record.rowKey。 * @param rowKey 用户传入的 rowKey prop * @returns AntD Table 可用的 rowKey 字符串或函数 */ export declare const buildTableRowKey: (rowKey?: string | number | symbol | ((record: any) => any)) => ((record: any) => string); /** * 表格行数据的浅比较:仅比较第一层字段引用/值,避免虚拟滚动时整行深比较开销。 * 行对象在本组件场景通常为扁平标量字段;同引用时由调用方另行处理。 */ export declare const isRecordShallowEqual: (a: Record | null | undefined, b: Record | null | undefined) => boolean; /** * 深层次对比两个对象且取出来差异值 * @param object 比较对象 * @param base 基准对象 * @returns 差异对象 */ export declare const difference: , U extends Record>(object: T, base: U) => Record; /** * 数组字段循环校验,解决validateFields无法批量校验的问题 * @param validateKeys 校验键数组 * @param form 表单实例 * @param rowName 行名称路径 * @returns 校验结果Promise */ export declare const customValidate: (validateKeys: NamePath[], form: FormInstance, rowName: NamePath) => Promise; /** * 拆解数组names * @param names 名称数组 * @returns 拆解后的字符串 */ export declare const splitNames: (names: any[]) => string; /** * 把行内变更的子键映射回「所属列的字段标识」,并去重。 * - names 组合列:任一子键命中 → 该列合并名(splitNames(names)),与 Form.Item 注册名/dataIndex 对齐 * - 普通列:原键本身 * * 用于行数据被联动改写(兄弟列 onFieldChange 回填)后,按真实字段名重校验与清理常驻报错, * 修复 group 列旧报错不清的问题。 */ export declare const resolveChangedFields: (changedKeys: string[], columns?: any[]) => string[]; /** * 把联动回填后的子键,重新组合并写回 names 组合列的合并字段(store)。 * * 背景:names 组合列真正被校验的是合并字段(splitNames(names),如 certType-certNo), * 其值仅在渲染期由 getValueProps 从子键组合后写回 store。联动回填(兄弟列 onFieldChange) * 只直接写入子键,不经过该字段的 normalize/渲染,导致合并字段 store 值未更新 → * 按合并名校验时读到旧空值、红字不清。这里按当前行子键即时组合并写回,确保 validateFields 读到最新值。 */ export declare const syncGroupCombinedValues: (form: FormInstance, rowPath: (string | number)[], changedKeys: string[], columns?: any[]) => void; /** * 获取中间formItem的name * @param name 名称路径 * @param virtualKey 虚拟键 * @returns 完整名称路径数组 */ export declare const getNamePath: (name: NamePath, virtualKey?: string) => (string | number)[]; /** * 删除操作 * @param params 删除参数 */ export declare const onDelete: ({ name, form, virtualKey, selectedRowKeys, }: { name: NamePath; form: FormInstance; virtualKey?: string; selectedRowKeys: Key[]; }) => void; /** * 获取最终的disabled, 两种模式【子级优先,全局优先】 * 全局优先:globalControl为true时,全局控制 * 子级优先:globalControl为false时,子级控制 * @param params 禁用参数 * @returns 是否禁用 */ export declare const getDisabled: ({ globalControl, formDisabled, column, tabledDisabled, columnFieldProps, params, rowDisabled, }: { globalControl: boolean; formDisabled?: boolean | ((record: any) => boolean); column: any; tabledDisabled?: boolean; columnFieldProps?: any; params: any[]; rowDisabled?: any; }) => boolean; /** * 表格自动滚动到报错位置 */ export declare const handleScrollToError: () => void; /** * 把「首个报错列的 cellKey」映射成它在表头 th 中的可见列索引。 * 列序 = [选择列?(hasSelection 时占位 1), ...用户列];names 列的 cellKey 用 splitNames 结果。 * @returns 表头 th 下标;未命中返回 -1 */ export declare const resolveErrorColumnIndex: (columns: any[], cellKey: string, hasSelection: boolean) => number; /** * 虚拟表格:横向滚动定位到「首个报错列」。 * * 背景:rc-table 虚拟表格对「列」也做了虚拟化(BodyGrid 仅渲染横向视口内的列), * 保存校验失败时报错列可能根本未渲染进 body DOM,无法用单元格测量定位(旧实现据此失效)。 * 而表头(thead)不被列虚拟化——渲染全部列且为真实测量宽度,故改以表头为列宽来源: * 累加报错列之前各列宽、减去 fixed-left 列宽(固定列悬浮,不占滚动偏移)得目标 scrollLeft。 * * 注意:ref.nativeElement 仅为 body 滚动容器,表头在其外层 table-container 内,需向上查找。 */ export declare const scrollVirtualToErrorColumn: (tableRef: React.MutableRefObject, columns: any[], cellKey?: string | null) => void; /** * 深copy一个对象,并过滤掉其中的React节点 * @param value 需要深拷贝的对象 * @returns 深拷贝后的对象,其中的React节点会被保留 */ export declare function cloneDeepFilterNode(value: T): T; /** * 分页校验 */ export declare const onPageCheck: ({ form, name, value, columns, setState, page, pagination, isView, disabled, }: { form: any; name: any; value: any; columns: any; setState: any; page: any; pagination: any; isView: any; disabled: any; }) => Promise;