From 66319d5405f50083081a01c18510b2b5afc03d05 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Wed, 30 Mar 2022 22:24:15 +0800 Subject: [PATCH] feat:add control options --- src/editor/dataset/constant/Control.ts | 6 ++++++ src/editor/index.ts | 11 ++++++++++- src/editor/interface/Control.ts | 13 ++++++++++--- src/editor/interface/Editor.ts | 2 ++ src/mock.ts | 15 ++++++++++++++- 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 src/editor/dataset/constant/Control.ts diff --git a/src/editor/dataset/constant/Control.ts b/src/editor/dataset/constant/Control.ts new file mode 100644 index 0000000..ff2ee47 --- /dev/null +++ b/src/editor/dataset/constant/Control.ts @@ -0,0 +1,6 @@ +import { IControlOption } from '../../interface/Control' + +export const defaultControlOption: Readonly> = { + placeholderColor: '#9c9b9b', + bracketColor: '#000000' +} \ No newline at end of file diff --git a/src/editor/index.ts b/src/editor/index.ts index 30dcced..ed805d5 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -19,6 +19,9 @@ import { IHeader } from './interface/Header' import { IWatermark } from './interface/Watermark' import { defaultHeaderOption } from './dataset/constant/Header' import { defaultWatermarkOption } from './dataset/constant/Watermark' +import { ControlType } from './dataset/enum/Control' +import { defaultControlOption } from './dataset/constant/Control' +import { IControlOption } from './interface/Control' export default class Editor { @@ -35,6 +38,10 @@ export default class Editor { ...defaultWatermarkOption, ...options.watermark } + const controlOptions: Required = { + ...defaultControlOption, + ...options.control + } const editorOptions: Required = { defaultMode: EditorMode.EDIT, defaultType: 'TEXT', @@ -68,7 +75,8 @@ export default class Editor { headerTop: 50, ...options, header: headerOptions, - watermark: waterMarkOptions + watermark: waterMarkOptions, + control: controlOptions } formatElementList(elementList) // 监听 @@ -95,6 +103,7 @@ export { RowFlex, EditorMode, ElementType, + ControlType, EditorComponent, EDITOR_COMPONENT } diff --git a/src/editor/interface/Control.ts b/src/editor/interface/Control.ts index 2f110e1..c4fedf4 100644 --- a/src/editor/interface/Control.ts +++ b/src/editor/interface/Control.ts @@ -1,4 +1,5 @@ import { ControlType } from '../dataset/enum/Control' +import { IElement } from './Element' export interface IValueSet { value: string; @@ -7,9 +8,15 @@ export interface IValueSet { export interface IControl { type: ControlType; - value: string; - conceptId: string; + value: IElement[] | null; + placeholder: string; + conceptId?: string; prefix?: string; postfix?: string; - valueSets?: IValueSet[] + valueSets?: IValueSet[]; +} + +export interface IControlOption { + placeholderColor?: string; + bracketColor?: string; } \ No newline at end of file diff --git a/src/editor/interface/Editor.ts b/src/editor/interface/Editor.ts index db221d5..055914b 100644 --- a/src/editor/interface/Editor.ts +++ b/src/editor/interface/Editor.ts @@ -1,5 +1,6 @@ import { IElement } from '..' import { EditorMode } from '../dataset/enum/Editor' +import { IControlOption } from './Control' import { IHeader } from './Header' import { IWatermark } from './Watermark' @@ -36,6 +37,7 @@ export interface IEditorOption { headerTop?: number; header?: IHeader; watermark?: IWatermark; + control?: IControlOption; } export interface IEditorResult { diff --git a/src/mock.ts b/src/mock.ts index 144b6c9..d4b708b 100644 --- a/src/mock.ts +++ b/src/mock.ts @@ -1,4 +1,4 @@ -import { ElementType, IEditorOption, IElement, RowFlex } from './editor' +import { ControlType, ElementType, IEditorOption, IElement, RowFlex } from './editor' const text = `人民医院门诊病历\n主诉:\n发热三天,咳嗽五天。\n现病史:\n患者于三天前无明显诱因,感冒后发现面部水肿,无皮疹,尿量减少,出现乏力,在外治疗无好转,现来我院就诊。\n既往史:\n有糖尿病10年,有高血压2年,有传染性疾病1年。没有报告其他既往疾病。\n流行病史:\n否认14天内接触过确诊患者、疑似患者、无症状感染者及其密切接触者;否认14天内去过以下场所:水产、肉类批发市场,农贸市场,集市,大型超市,夜市;否认14天内与以下场所工作人员密切接触:水产、肉类批发市场,农贸市场,集市,大型超市;否认14天内周围(如家庭、办公室)有2例以上聚集性发病;否认14天内接触过有发热或呼吸道症状的人员;否认14天内自身有发热或呼吸道症状;否认14天内接触过纳入隔离观察的人员及其他可能与新冠肺炎关联的情形;陪同家属无以上情况。\n体格检查:\nT:39.5℃,P:80bpm,R:20次/分,BP:120/80mmHg;\n辅助检查:\n2020年6月10日,普放:血细胞比容36.50%(偏低)40~50;单核细胞绝对值0.75*10/L(偏高)参考值:0.1~0.6;\n门诊诊断:\n1.高血压\n2.糖尿病\n3.病毒性感冒\n4.过敏性鼻炎\n5.过敏性鼻息肉\n处置治疗:\n1.超声引导下甲状腺细针穿刺术;\n2.乙型肝炎表面抗体测定;\n3.膜式病变细胞采集术、后颈皮下肤层;\n电子签名:【】\n其他记录:` @@ -209,6 +209,19 @@ elementList.push({ }] }) +// 文本控件 +elementList.splice(587, 0, { + type: ElementType.CONTROL, + value: '', + control: { + type: ControlType.TEXT, + value: null, + placeholder: '其他补充', + prefix: '{', + postfix: '}' + } +}) + // 模拟结尾文本 elementList.push(...[{ value: 'E',