interface Document { categoryId: string; _id: string; valid: number; properties: any; styles: any; scripts: any; layout: any; document: any; } interface Validator { name: string; level: string; message: string; } export type EditorMode = "form" | "free" | "readonly" | "design"; export interface DataElements { [key: string]: DataElementItem | DataElementItem[]; } export type DataElementItem = { id: string; value: any | null; element: { id: string; type: string; name: string; code: { internal: string; dataElement: string; business: string }; labels: null; attributes: []; }; }; type CursorPlace = | "PARAGRAPH_START" | "PARAGRAPH_END" | "DOCUMENT_START" | "DOCUMENT_END"; interface MenuItem { global: { text: string; menu?: { items: MenuItem[]; }; handler?: (menu?: any) => void; }[]; } interface NodesByCode { target: { setReadonly: (val: boolean) => void; setDeletable: (val: boolean) => void; }; } interface ElementByValue extends HTMLElement { /** * 元素聚焦 */ focusEnter: () => void; } type customEdit = { _getPatientInfo: () => any; }; export declare type EditType = { EMR: { getDocument(): { getTablesByCode: (id: string) => any[]; }; }; setViewStyle: (view, value) => void; isRevisionMode: boolean; documentData: { _id: string; categoryId: string; properties: { categoryCode: string; }; }; _cacheDB: IDBTransaction; loadCacheData: (val: string) => any; delCacheData: (val: string) => any; setCacheData: (val: string) => any; openCache: () => void; _cacheDBIsOpen: boolean; on: (name: string, callback: (...args: any[]) => void) => void; /** * 用于获取当前病历完整数据 该方法通常用于保存病历数据时调用 * * 参数:无 * 返回值:返回json结构,参见:文档结构。 * 业务系统可在保存前对其内容进行修改。 */ getDocument: () => Document; getEditorMode: () => EditorMode; highlight: (comp: HTMLElement, time: number) => void; getElementsData: () => { [key: string]: any; }; getElementByValue: (id: string, value?: any) => ElementByValue; view: HTMLElement & { container: { find: (id: string) => any[] & { each: (fn: (index: number, item: any) => void) => void; }; }; }; ModelService: { setWalkerRoot: (walker: any, node: any) => any; createTreeWalker: (node: any) => any; getDataElementsFromWalker: ( walker: any, name: string, value: string ) => any; getElementsDataFromWalker: (walker: any, name?: string) => any; }; setEditorMode: (val: EditorMode) => void; getValidator: () => { /** * * @param val 是否显示节点信息 , 默认值 false */ valid: (val: boolean) => Validator[]; }; /** * {Boolean} includeEmptyValue 是否获取非必填并且不是数据元 值为空的元素 默认 false * @param val type 要获取的编码类型 默认 code。 code|business|internal|dataElement, 一般不用dataElement,当指定的编码类型不存在时返回 code */ getDataElements: ( val: "code" | "business" | "internal" | "dataElement", a?: boolean, b?: boolean ) => DataElements; /** * 批量设置组件值 * * 适用组件:智能文本框(smarttext)、复选框(checkfield) * 参数: * {Object} data 要设置的key/value对象 同getAppContext中的data节点 * {Boolean} overwrite 是否覆盖原来的值 默认true * {Boolean}. commandStack 是否进入撤销命令栈 默认true。当setValues在一个操作命令中调用的时候commandStack设置为false和合并父操作的命令栈 例如插入片段事件/或设置值后出发的change事件 * {DocumentFragment} documdentFragment插入的文档片段模型,为空时将值填充到整个文档,不为空时将值填充到文档片段 * 返回值 无 * @param val */ setValues: ( val: object, overwrite?: boolean, commandStack?: boolean, documentFragment?: object ) => void; getComponents: () => any[]; /** * editor.execute(commandName,[...args]) * * 执行编辑器命令 * * 参数 * @param name commandName 命令名称 * @param value args 执行命令携带的参数 */ execute: (name: string | "insertContents", ...value: any[]) => void; /** * 移动光标到place 指定位置 * * 参数: * {string} place PARAGRAPH_START | PARAGRAPH_END | DOCUMENT_START | DOCUMENT_END * PARAGRAPH_START:移动光标到当前段落开头 * PARAGRAPH_END:移动光标到当前段落结尾 * DOCUMENT_START:移动光标到文档开头 * DOCUMENT_END:移动光标到文档结尾 * 返回值:undefined * @param place */ setCursor: (place: CursorPlace) => void; /** * 滚动到当前光标所在位置 * * editor.scrollToCursor([middle]) * * @param middle middle 当光标在可视区域后方时,是否滚动到屏幕中间 默认false */ scrollToCursor: (...middle: boolean[]) => void; model: { document: { getRoot: () => { getChild: (val: number) => { view: any; }; childCount: number; getChildren: any; }; }; }; /** * 设置审阅模式 * * 参数 * {String} mode 接收 on:开启审阅模式,off:关闭审阅模式 * 开启审阅模式后,病历上的修改会被记录下来,默认开启后,页面上没有任何表现,需要通过调用editor.setRevisionShowMode(flag) 展示修改 */ setRevisionMode: (val: "on" | "off") => void; /** * 设置审阅模式的展现方式 * @param val flag可接受的值如下 * 0: 页面上不显示修改记录 * 1: 病历右侧会以列表的形式显示 添加,删除,更新的记录 * 2: 嵌入病历显示修改记录,新增的记录会用背景颜色标记,删除的记录 通过画删除线标记 */ setRevisionShowMode: (val: 0 | 1 | 2 | number) => void; getScriptRuntime: () => { EMR: { getDocument: () => { getNodesByCode: (val: any, name: string) => NodesByCode[]; getComponentsByCode: (name: string) => any[]; }; }; }; getViewByElType: (value: any, name: string) => any; /** * 自定义编辑器快捷键 * * 参数 * {Function} callback * @param keyName 绑定快捷键 * @param callback 快捷键触发函数 该函数接受3个参数 evt:事件 * view: 当前光标或者选区开始所在位置的组件view * position: {x ,y} 光标或者选区开始位置坐标(相对于文档,内部通过getBoundingClientRect()方法获取) */ setShortcutKey: ( keyName: string, callback: ( e: Event, view: any, position: { x: number; y: number; } ) => void ) => void; /** * 注册右键菜单 * @param menuItem 数据 */ regCtxMenu: (menuItem: MenuItem) => void; /** * 获取鼠标位置 */ getCursorPosition: () => { x: number; y: number }; /** * 用于设置当前病历文档完整数据 * * 参数 * @param data 完整的病历文档结构。 * @param isRender 是否根据文档结构进行立即渲染页面,如果为false 则只设置文档数据不进行渲染操作 * @param clearUndoStack 是否清空撤销栈 */ setDocument: ( data: any, isRender?: boolean, clearUndoStack?: boolean ) => void; /** * 设置实时分页 * @param isPaginate true:开启实时分页 false:关闭实时分页 */ setPaginate: (isPaginate: boolean) => void; renderer: { pageView: { marginTopWithPaging: number; /** * 重新绘制页面布局 */ attachLayout: () => void; fixEmpty: () => void; }; }; /** * 获取大纲的树状图 */ getOutline: () => Outline[]; /** * 设置 setApplicatioinContext * @param data 数据 * @param filling 是否填充 * @param forcedReplacement 是否强制替换 */ setApplicationContext: ( data: any, filling: boolean, forcedReplacement: boolean ) => void; } & customEdit; export declare type Runtime = { saveDocument: ( document: any, success: (res?: any) => void, error: (err?: any) => void ) => void; loadDocument: ( success: (res?: any) => void, error: (err?: any) => void, param: any ) => void; }; export interface Outline { id: string; type: string; typeName: string; text: string; parent: string; business: string; children: { business: string; code: string; dataElement: string; id: string; internal: string; leaf: boolean; parent: string; text: string; type: string; typeName: string; }[]; }