/**************************************************** * Audit Information Platform Component * 搜索参照 * 2020-08 * Sunny ****************************************************/ import { PureComponent, ReactNode } from "react"; import "bee-button/build/Button.css"; import { RefItemInstance } from "./RefItem"; import { ComponentService, ModelRef, ReferenceItem, StringAnyMap, StringStringMap, TinperBeeFormState } from "../types"; import "../style/AIPSearchPanel.css"; export interface StringRefItemInstanceMap { [key: string]: RefItemInstance; } export interface StringReferenceItemMap { [key: string]: ReferenceItem; } export interface StringRefItemInstanceArrayMap { [key: string]: RefItemInstance[]; } export interface StringReferenceItemArrayMap { [key: string]: ReferenceItem[]; } /** * 参照面板组件的属性项定义 */ export interface AIPSearchPanelProp { /** * React 组件id */ id: string; /** * React 组件key */ key?: string; /** * 参照ID */ refid: string; prefixUrl?: string; service: ComponentService; /** * 检索按钮label */ searchBtnText?: string; /** * 清空按钮label */ cleanBtnText?: string; /** * 是否禁用清空条件按钮 */ disableClear?: boolean; /** * 弹出面板是否点击空白关闭 */ backDrop?: boolean; /** * 是否启用参数加密传输 */ encryption?: boolean; appendSpecialParam?: () => StringAnyMap; /** * 从本地缓存获取初始数据的方法 * * @param {string} refId 参照组件的id */ loadCacheFn?: (refId: string) => Promise; /** * 组件完成初始化后的回调函数 */ loadedfunc?: (immediateSearch?: boolean, model?: ModelRef) => void; /** * 检索 * @param {StringStringMap} params 检索参数 */ doSearch?: (params: StringStringMap) => void; /** * 清除条件 */ doClear?: () => void; /** * 数据请求完毕回调接口 * @param {any} data 实际返回的数据 * @param {StringStringMap} params 查询参数 * @param {string} url 数据请求URL */ fetchCallback?: (data: any, params: StringStringMap, url?: string) => void; } /** * 参照面板组件的状态项定义(可不关注) */ export interface AIPSearchPanelState extends ModelRef { key: string; mustItems: ReferenceItem[]; allSortedItems: ReferenceItem[]; noRef: boolean; showAlert: boolean; form: TinperBeeFormState; resetFields: () => void; } /** * AIP参照搜索框组件 * * @class AIPSearchPanel * * @extends { PureComponent } * * @description 配合参照设计显示搜索条件框 * * * ### 涉及数据结构 ### * * - 服务返回的参照数据必须符合结构,详细规范参考类 ModelRef * ~~~json * { * "createtime": "2021-03-09", * "creator": null, * "orderindex": null, * "name": "科目余额表参照", * "refType": null, * "description": "科目余额表查询条件", * "refitems": [ * { * "valuefield": "账套编号", * "defaultValue": null, * "multiple": "0", * "refitem": [], * "pageable": false, * "displayorder": 0, * "label": "账套名称", * "type": "table", * "url": "/dataretriver/retrive?type=ref&id=e44eb7e5-1e59-494d-9343-0831a3f4a4b8&index=0", * "name": "账套编号", * "options": [], * "width": 200, * "must": true, * "id": "672db682-5dc1-4870-922e-8e8acf0c723e", * "displayfield": "账套名称" * }, * { * "valuefield": "年度", * "defaultValue": null, * "multiple": "1", * "refitem": [ * "账套编号" * ], * "pageable": false, * "displayorder": 1, * "label": "账套年度", * "type": "select", * "url": "/dataretriver/retrive?type=ref&id=e44eb7e5-1e59-494d-9343-0831a3f4a4b8&index=1", * "name": "年度期间", * "options": [], * "width": 170, * "must": true, * "id": "5c55e835-3510-49c2-b18f-dd297e70cb34", * "displayfield": "年度" * }, * { * "valuefield": "value", * "defaultValue": null, * "multiple": "0", * "refitem": [], * "pageable": false, * "displayorder": 5, * "label": null, * "type": "select", * "url": "/dataretriver/retrive?type=ref&id=e44eb7e5-1e59-494d-9343-0831a3f4a4b8&index=5", * "name": "科目级次", * "options": [ * { * "label": "1级", * "value": "1" * }, * { * "label": "到末级", * "value": "到末级" * } * ], * "width": 80, * "must": true, * "id": "0e29906b-7af4-4560-85f4-b98b10916c51", * "displayfield": "label" * } * ], * "id": "e44eb7e5-1e59-494d-9343-0831a3f4a4b8", * "sourceref": null * } * ~~~ */ declare class AIPSearchPanel extends PureComponent { /** * 注册新的组件,如果已存在,将覆盖原有组件实现 * * @param {string} componentName * @param {any} componentClass */ static registComponent(componentName: string, componentClass: any): void; /** * 获取参照系统已经注册的组件信息 * 返回Map为 {compnentName: componentClass} * * @function * * @returns {StringAnyMap} */ static getRegistedComponents(): StringAnyMap; state: AIPSearchPanelState; /** * 依赖参照相关数据结构,依赖参照map * { "年度期间": ["账套编号"], "账套年度": [] } */ private _notifyItems; /** 参照项快表,通过参照项名称快速获取参照项对象 */ private _refsSnapshot; /** * 依赖参照链快表 { "账套编号": ["账套年度"], "账套年度": [] } */ private _refDepnedMaps; /** * 上下文路径 */ private _contextPath; /** * 主控端缓存所有的值,以便快速完成调度 */ private _cacheRefrenceValues; /** * 特殊的参数 */ private _specialParams; /** * 默认参照项数据 */ private _defaultParams; /** * 构建依赖参照需要的参数对象 * @function * * @param {string} name 参照的名称 * @returns {any[]} 返回依赖相关的参数 */ private _buildRefParams; /** * 给参照提供必要的参数 * @function * * @param paramKey 加入参数的名称 * @param paramValue 加入的参数值 */ appendParam: (paramKey: string, paramValue: string) => void; /** * 构建指定条件的依赖快照 * @function * * @param {string} name 条件名 * @param {ReferenceItem[]} refrenceItems 所有参照对象列表 * @param {Set} cSet 各个条件的参照表 */ private _buildRefDepends; /** * 重新整理通知列表,将参考实际字段修正事件通知列表 * @function * * @param {Map} refDepnedMaps 目前已有的通知列表 * @param {any[]} refItems 参照记录 */ private _afterBuildRefDepends; /** * 将Map数据结构的key转为数组 * @function * * @param {StringAnyMap} mp * @returns {string[]} */ private _mapKey2Array; /** * 获取参照项的组件引用(非参照项对象) * @function * * @param {string} refName * @returns {RefItemInstance} */ private _getRefByName; /** * 参照请求调度核心 * @function * * @param {string} itemName 调度`itemName`条件的关联依赖组件请求,可选参数,为空则从头调用 */ private _scheduler; /** * 参数数据项值改变通知 * @function * * @param {string} itemName 参照名 * @param {string | null} value 参照当前值 */ private _refItemValueChange; /** * 重新初始化部分对象变量 * @function */ private _resetState; /** * 载入(初始化)参照 * @function * * @param {StringStringMap} params 初始化参数 **可选** */ private _loadRefrences; /** * React component lifecycle method */ componentDidMount(): void; /** * React component lifecycle method */ componentWillUnmount(): void; /** * 注册全局服务,暴露部分信息到浏览器以便外部了解组件当前信息 * @function */ private _installServices; private _uninstallServices; /** * 获取当前状态选取的参数 * @function * * @param {boolean} ignoreMust 是否忽略必填,如果为true,将返回目前已选的条件信息,如果为false,有必选条件未选将返回null * @returns {StringStringMap | null} 返回参数,可能值为 null或者StringStringMap */ getParams: (ignoreMust?: boolean) => StringStringMap | null; /** * 检索 * @function * * @param {Event} e 事件对象,可选参数 * @returns {void} */ search: (e?: Event) => void; /** * 重新载入所有参照数据 * @function */ reload: () => void; /** * 清空所有参照项的值 * @function * * @param {Event} e 事件对象,可选参数 */ clear: (e?: Event) => void; /** * 根据给定的path获取上下文路径 * @function * * @param {string} path * @returns {string} */ private _getContextPath; /** * 确定当前的参照是否可以自动搜索 * * @returns {boolean} 是否可以自动搜索 */ canAutoSearch: () => boolean; /** * 渲染每个参照项的组件 * @function * * @param {ReferenceItem} refItem 参照项对象 * @param {number} idx 序号 * @returns {ReactNode} */ private _eachRender; render(): ReactNode; } export default AIPSearchPanel;