@hailin-zheng/editor-core 1.1.18 → 1.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/controls/SurfaceView.d.ts +2 -0
- package/index-cjs.js +1376 -86
- package/index-cjs.js.map +1 -1
- package/index.js +1375 -86
- package/index.js.map +1 -1
- package/med_editor/framework/document-selection.d.ts +1 -0
- package/med_editor/framework/element-util.d.ts +1 -0
- package/med_editor/texteditor.d.ts +6 -3
- package/package.json +1 -1
- package/timeline/TimeLineControl.d.ts +1 -0
- package/timeline/TimeValueGridControl.d.ts +10 -0
- package/timeline/TimelineConfig.d.ts +1 -0
package/index.js
CHANGED
@@ -4,6 +4,7 @@ import * as acor from 'acorn';
|
|
4
4
|
import { generate } from 'astring';
|
5
5
|
import * as estraverse from 'estraverse';
|
6
6
|
import bwipjs from 'bwip-js';
|
7
|
+
import moment$1 from 'moment/moment';
|
7
8
|
|
8
9
|
/**
|
9
10
|
* 元素事件
|
@@ -4411,6 +4412,10 @@ class SelectionState {
|
|
4411
4412
|
constructor() {
|
4412
4413
|
this.clear();
|
4413
4414
|
}
|
4415
|
+
destroy() {
|
4416
|
+
this.onChangedEvent.unsubscribe();
|
4417
|
+
this.clear();
|
4418
|
+
}
|
4414
4419
|
clear() {
|
4415
4420
|
this.range = null;
|
4416
4421
|
this.startOffset = -1;
|
@@ -7689,6 +7694,19 @@ class ElementUtil {
|
|
7689
7694
|
static getDataElement(ele) {
|
7690
7695
|
return this.getParent(ele, item => item instanceof DataElementInlineGroup);
|
7691
7696
|
}
|
7697
|
+
static getOSPlatform() {
|
7698
|
+
const userAgent = navigator.userAgent;
|
7699
|
+
if (userAgent.indexOf('Windows') > -1) {
|
7700
|
+
return 'Windows';
|
7701
|
+
}
|
7702
|
+
if (userAgent.indexOf('Mac') > -1) {
|
7703
|
+
return 'Mac';
|
7704
|
+
}
|
7705
|
+
if (userAgent.indexOf('Linux') > -1) {
|
7706
|
+
return 'Linux';
|
7707
|
+
}
|
7708
|
+
return 'Windows';
|
7709
|
+
}
|
7692
7710
|
}
|
7693
7711
|
|
7694
7712
|
class RenderContext {
|
@@ -14942,7 +14960,7 @@ class DocumentEvent {
|
|
14942
14960
|
});
|
14943
14961
|
document.execCommand('copy');
|
14944
14962
|
};
|
14945
|
-
if (
|
14963
|
+
if (ElementUtil.getOSPlatform() === 'Mac') {
|
14946
14964
|
if (evt.metaKey && evt.keyCode === 67) {
|
14947
14965
|
copy();
|
14948
14966
|
}
|
@@ -14991,6 +15009,7 @@ class DocumentInput {
|
|
14991
15009
|
onTabKeyEvent = new Subject$1();
|
14992
15010
|
constructor(node, docCtx) {
|
14993
15011
|
this.docCtx = docCtx;
|
15012
|
+
const os = ElementUtil.getOSPlatform();
|
14994
15013
|
node.addEventListener('input', evt => {
|
14995
15014
|
const { startControl, startOffset } = this.docCtx.selectionState;
|
14996
15015
|
this.onInputEvent.next({
|
@@ -15038,7 +15057,11 @@ class DocumentInput {
|
|
15038
15057
|
else if (evt.keyCode === 46) {
|
15039
15058
|
this.onDeleteEvent.next(evt);
|
15040
15059
|
}
|
15041
|
-
else if (evt.ctrlKey && evt.keyCode === 65) {
|
15060
|
+
else if (evt.ctrlKey && evt.keyCode === 65 && os !== 'Mac') {
|
15061
|
+
evt.preventDefault();
|
15062
|
+
this.onSelectAllEvent.next();
|
15063
|
+
}
|
15064
|
+
else if (evt.metaKey && evt.keyCode === 65 && os === 'Mac') {
|
15042
15065
|
evt.preventDefault();
|
15043
15066
|
this.onSelectAllEvent.next();
|
15044
15067
|
}
|
@@ -17788,7 +17811,6 @@ function setCurrentActiveAppContext(ctx) {
|
|
17788
17811
|
currentActiveAppContext = ctx;
|
17789
17812
|
}
|
17790
17813
|
function renderApp(root, renderCtx, nodeEvent) {
|
17791
|
-
window['root'] = root;
|
17792
17814
|
// const nodeEvent = new NodeEvent(root, renderCtx.mainContext.ctx.canvas);
|
17793
17815
|
let delayTask = false;
|
17794
17816
|
const flushTask = () => {
|
@@ -17807,8 +17829,10 @@ function renderApp(root, renderCtx, nodeEvent) {
|
|
17807
17829
|
};
|
17808
17830
|
flushTask();
|
17809
17831
|
root.onChangedEvent.subscribe(() => {
|
17832
|
+
if (root.isDisposed) {
|
17833
|
+
return;
|
17834
|
+
}
|
17810
17835
|
flushTask();
|
17811
|
-
//console.log('准备创建任务'+taskId)
|
17812
17836
|
});
|
17813
17837
|
nodeEvent.onSignal.subscribe(() => {
|
17814
17838
|
flushTask();
|
@@ -19073,6 +19097,7 @@ class SurfaceView extends NodeItems {
|
|
19073
19097
|
renderSchedule;
|
19074
19098
|
nodeEvent;
|
19075
19099
|
renderCtx;
|
19100
|
+
isDisposed = false;
|
19076
19101
|
onSizeChanged = new Subject();
|
19077
19102
|
constructor(canvas, input) {
|
19078
19103
|
super();
|
@@ -19155,6 +19180,10 @@ class SurfaceView extends NodeItems {
|
|
19155
19180
|
clearPopNodes() {
|
19156
19181
|
this.popNodes = [];
|
19157
19182
|
}
|
19183
|
+
destroy() {
|
19184
|
+
this.clearChildren();
|
19185
|
+
this.isDisposed = true;
|
19186
|
+
}
|
19158
19187
|
initInputEvent() {
|
19159
19188
|
let composition = false;
|
19160
19189
|
this.input.addEventListener('input', evt => {
|
@@ -20364,14 +20393,1317 @@ function pointInPoly(pt, poly) {
|
|
20364
20393
|
return c;
|
20365
20394
|
}
|
20366
20395
|
|
20396
|
+
const timelineConfig = {
|
20397
|
+
fontSize: 12,
|
20398
|
+
fontName: '宋体',
|
20399
|
+
/**
|
20400
|
+
* 单个时刻的宽度,像素
|
20401
|
+
*/
|
20402
|
+
timeTickWidth: 14,
|
20403
|
+
/**
|
20404
|
+
* 纵轴一个单位的高度
|
20405
|
+
*/
|
20406
|
+
timeValueHeight: 20,
|
20407
|
+
/**
|
20408
|
+
* 单个时刻宽度代表的小时数
|
20409
|
+
*/
|
20410
|
+
timeTickHours: 4,
|
20411
|
+
/**
|
20412
|
+
* 体温点的大小
|
20413
|
+
*/
|
20414
|
+
temperaturePointSize: 4,
|
20415
|
+
/**
|
20416
|
+
* 心率点的大小
|
20417
|
+
*/
|
20418
|
+
heartRatePointSize: 4,
|
20419
|
+
temperatureModels: [42, 41, 40, 39, 38, 37, 36, 35],
|
20420
|
+
heartRateModels: [180, 160, 140, 120, 100, 80, 40, 20],
|
20421
|
+
valueRuleCounts: 8,
|
20422
|
+
/**
|
20423
|
+
* 时刻头部高度
|
20424
|
+
*/
|
20425
|
+
tickHeaderHeight: 20,
|
20426
|
+
/**
|
20427
|
+
* 体温符号
|
20428
|
+
*/
|
20429
|
+
temperatureSymbol: '℃',
|
20430
|
+
heartRateSymbol: 'BPM'
|
20431
|
+
};
|
20432
|
+
class TimelineBaseControl extends AbsolutePanel {
|
20433
|
+
startTime;
|
20434
|
+
showDays = 0;
|
20435
|
+
constructor() {
|
20436
|
+
super();
|
20437
|
+
this.border = 1;
|
20438
|
+
this.borderColor = '#000';
|
20439
|
+
this.bgColor = '#fff';
|
20440
|
+
}
|
20441
|
+
measureOverride(e, availableSize) {
|
20442
|
+
this.build(e);
|
20443
|
+
return super.measureOverride(e, availableSize);
|
20444
|
+
}
|
20445
|
+
isBuild = false;
|
20446
|
+
build(e) {
|
20447
|
+
if (this.isBuild) {
|
20448
|
+
return;
|
20449
|
+
}
|
20450
|
+
this.clearChildren();
|
20451
|
+
this.buildOverride(e);
|
20452
|
+
this.isBuild = true;
|
20453
|
+
}
|
20454
|
+
reBuild() {
|
20455
|
+
this.isBuild = false;
|
20456
|
+
}
|
20457
|
+
buildOverride(e) {
|
20458
|
+
}
|
20459
|
+
}
|
20460
|
+
class TickContainer extends AbsolutePanel {
|
20461
|
+
tickControl;
|
20462
|
+
_startTime;
|
20463
|
+
_showDays = 0;
|
20464
|
+
scrollX = 0;
|
20465
|
+
get startTime() {
|
20466
|
+
return this._startTime;
|
20467
|
+
}
|
20468
|
+
set startTime(value) {
|
20469
|
+
this._startTime = value;
|
20470
|
+
this.tickControl.startTime = value;
|
20471
|
+
}
|
20472
|
+
get showDays() {
|
20473
|
+
return this._showDays;
|
20474
|
+
}
|
20475
|
+
set showDays(value) {
|
20476
|
+
this._showDays = value;
|
20477
|
+
this.tickControl.showDays = value;
|
20478
|
+
}
|
20479
|
+
arrangeOverride(e, finalSize) {
|
20480
|
+
this.controls.filter(item => item !== this.tickControl).forEach(item => {
|
20481
|
+
const itemRect = {
|
20482
|
+
x: item.x,
|
20483
|
+
y: item.y,
|
20484
|
+
width: item.desiredSize.width,
|
20485
|
+
height: item.desiredSize.height
|
20486
|
+
};
|
20487
|
+
item.arrange(e, itemRect);
|
20488
|
+
});
|
20489
|
+
this.tickControl.arrange(e, { x: this.tickControl.x - this.scrollX,
|
20490
|
+
y: this.tickControl.y,
|
20491
|
+
width: this.tickControl.desiredSize.width,
|
20492
|
+
height: this.tickControl.desiredSize.height });
|
20493
|
+
return finalSize;
|
20494
|
+
}
|
20495
|
+
}
|
20496
|
+
|
20497
|
+
class TemperaturePoint extends NodeCore {
|
20498
|
+
type;
|
20499
|
+
value;
|
20500
|
+
constructor(type = 'axillary', value) {
|
20501
|
+
super();
|
20502
|
+
this.type = type;
|
20503
|
+
this.value = value;
|
20504
|
+
this.bgColor = 'blue';
|
20505
|
+
this.width = timelineConfig.temperaturePointSize;
|
20506
|
+
this.height = timelineConfig.temperaturePointSize;
|
20507
|
+
this.addEventListener('mouseenter', evt => {
|
20508
|
+
this.bgColor = 'red';
|
20509
|
+
const onMouseLeave = () => {
|
20510
|
+
this.bgColor = 'blue';
|
20511
|
+
this.removeEventListener('mouseleave', onMouseLeave);
|
20512
|
+
};
|
20513
|
+
this.addEventListener('mouseleave', onMouseLeave);
|
20514
|
+
});
|
20515
|
+
}
|
20516
|
+
renderOutline(renderCtx) {
|
20517
|
+
translate(renderCtx, this.finalRect.x, this.finalRect.y);
|
20518
|
+
translate(renderCtx, this.border + this.padding, this.border + this.padding);
|
20519
|
+
}
|
20520
|
+
render(e) {
|
20521
|
+
if (this.type === 'axillary') {
|
20522
|
+
this.renderAxillary(e);
|
20523
|
+
}
|
20524
|
+
else if (this.type === 'oral') {
|
20525
|
+
this.renderOral(e);
|
20526
|
+
}
|
20527
|
+
else if (this.type === 'anal') {
|
20528
|
+
this.renderAnal(e);
|
20529
|
+
}
|
20530
|
+
}
|
20531
|
+
/**
|
20532
|
+
* 绘制腋下温度 X
|
20533
|
+
* @private
|
20534
|
+
*/
|
20535
|
+
renderAxillary(e) {
|
20536
|
+
const { width, height } = this.finalRect;
|
20537
|
+
const x = 0, y = 0;
|
20538
|
+
e.render.strokeLines([{ x, y }, { x: x + width, y: y + height }], 3, this.bgColor);
|
20539
|
+
e.render.strokeLines([{ x: x + width, y }, { x, y: y + height }], 3, this.bgColor);
|
20540
|
+
}
|
20541
|
+
/**
|
20542
|
+
* 绘制肛下温度 ○
|
20543
|
+
* @private
|
20544
|
+
*/
|
20545
|
+
renderAnal(e) {
|
20546
|
+
const width = this.finalRect.width;
|
20547
|
+
const ctx = e.render.ctx;
|
20548
|
+
ctx.save();
|
20549
|
+
ctx.beginPath();
|
20550
|
+
ctx.strokeStyle = this.bgColor;
|
20551
|
+
ctx.lineWidth = 2;
|
20552
|
+
ctx.arc(width / 2, width / 2, width, 0, 2 * Math.PI);
|
20553
|
+
ctx.stroke();
|
20554
|
+
ctx.restore();
|
20555
|
+
}
|
20556
|
+
/**
|
20557
|
+
* 绘制口腔温度 ●
|
20558
|
+
* @private
|
20559
|
+
*/
|
20560
|
+
renderOral(e) {
|
20561
|
+
const width = this.finalRect.width;
|
20562
|
+
e.render.fillCircular(width / 2, width / 2, width, this.bgColor);
|
20563
|
+
}
|
20564
|
+
}
|
20565
|
+
class HeartRatePoint extends NodeCore {
|
20566
|
+
value;
|
20567
|
+
constructor() {
|
20568
|
+
super();
|
20569
|
+
this.bgColor = 'red';
|
20570
|
+
this.width = timelineConfig.heartRatePointSize * 2;
|
20571
|
+
this.height = timelineConfig.heartRatePointSize * 2;
|
20572
|
+
this.addEventListener('mouseenter', evt => {
|
20573
|
+
this.bgColor = 'green';
|
20574
|
+
const tipLabel = new LabelNode();
|
20575
|
+
tipLabel.text = this.value;
|
20576
|
+
tipLabel.fontSize = timelineConfig.fontSize;
|
20577
|
+
tipLabel.shadowBlur = 5;
|
20578
|
+
tipLabel.shadowColor = '#000';
|
20579
|
+
tipLabel.bgColor = '#fff';
|
20580
|
+
tipLabel.x = this.x;
|
20581
|
+
tipLabel.y = this.y - tipLabel.fontSize - 2;
|
20582
|
+
this.parent?.addChild(tipLabel);
|
20583
|
+
const onMouseLeave = () => {
|
20584
|
+
this.bgColor = 'red';
|
20585
|
+
this.parent?.removeChild(tipLabel);
|
20586
|
+
this.removeEventListener('mouseleave', onMouseLeave);
|
20587
|
+
};
|
20588
|
+
this.addEventListener('mouseleave', onMouseLeave);
|
20589
|
+
});
|
20590
|
+
}
|
20591
|
+
renderOutline(renderCtx) {
|
20592
|
+
translate(renderCtx, this.finalRect.x, this.finalRect.y);
|
20593
|
+
translate(renderCtx, this.border + this.padding, this.border + this.padding);
|
20594
|
+
}
|
20595
|
+
render(e) {
|
20596
|
+
const heartRatePointSize = this.finalRect.width / 2;
|
20597
|
+
e.render.fillCircular(heartRatePointSize, heartRatePointSize, heartRatePointSize, this.bgColor);
|
20598
|
+
}
|
20599
|
+
}
|
20600
|
+
class TimeLinePath extends NodeCore {
|
20601
|
+
startPos;
|
20602
|
+
endPos;
|
20603
|
+
lineColor = '#000';
|
20604
|
+
lineWidth = 1;
|
20605
|
+
constructor() {
|
20606
|
+
super();
|
20607
|
+
this.allowHitTest = true;
|
20608
|
+
this.enableClip = false;
|
20609
|
+
}
|
20610
|
+
renderOutline(renderCtx) {
|
20611
|
+
translate(renderCtx, this.finalRect.x, this.finalRect.y);
|
20612
|
+
translate(renderCtx, this.border + this.padding, this.border + this.padding);
|
20613
|
+
}
|
20614
|
+
render(e) {
|
20615
|
+
e.render.strokeLines([this.startPos, this.endPos], this.lineWidth, this.lineColor);
|
20616
|
+
}
|
20617
|
+
}
|
20618
|
+
|
20619
|
+
class TimelineControl extends AbsolutePanel {
|
20620
|
+
render(e) {
|
20621
|
+
}
|
20622
|
+
constructor() {
|
20623
|
+
super();
|
20624
|
+
this.border = 1;
|
20625
|
+
this.borderColor = '#000';
|
20626
|
+
}
|
20627
|
+
measureOverride(e, availableSize) {
|
20628
|
+
const height = this.controls.reduce((prev, curr) => {
|
20629
|
+
curr.measure(e, availableSize);
|
20630
|
+
return prev + curr.desiredSize.height;
|
20631
|
+
}, 0);
|
20632
|
+
return {
|
20633
|
+
height, width: availableSize.width
|
20634
|
+
};
|
20635
|
+
}
|
20636
|
+
arrangeOverride(e, finalSize) {
|
20637
|
+
this.controls.reduce((prev, curr) => {
|
20638
|
+
const itemRect = {
|
20639
|
+
x: 0,
|
20640
|
+
y: prev,
|
20641
|
+
width: curr.desiredSize.width,
|
20642
|
+
height: curr.desiredSize.height
|
20643
|
+
};
|
20644
|
+
curr.arrange(e, itemRect);
|
20645
|
+
return prev + curr.desiredSize.height;
|
20646
|
+
}, 0);
|
20647
|
+
return finalSize;
|
20648
|
+
}
|
20649
|
+
rebuild() {
|
20650
|
+
treeForEach(this, item => {
|
20651
|
+
if (item instanceof NodeItems) {
|
20652
|
+
return item.controls;
|
20653
|
+
}
|
20654
|
+
else {
|
20655
|
+
return [];
|
20656
|
+
}
|
20657
|
+
}, (item) => {
|
20658
|
+
if (item instanceof TimelineBaseControl) {
|
20659
|
+
item.reBuild();
|
20660
|
+
}
|
20661
|
+
});
|
20662
|
+
}
|
20663
|
+
}
|
20664
|
+
function treeForEach(root, children, callback) {
|
20665
|
+
callback(root);
|
20666
|
+
children(root).forEach(node => {
|
20667
|
+
treeForEach(node, children, callback);
|
20668
|
+
});
|
20669
|
+
}
|
20670
|
+
/**
|
20671
|
+
* 中间网格数据绘制区域
|
20672
|
+
*/
|
20673
|
+
class TimeGridContainer extends AbsolutePanel {
|
20674
|
+
get gridHeight() {
|
20675
|
+
return this._gridHeight;
|
20676
|
+
}
|
20677
|
+
set gridHeight(value) {
|
20678
|
+
this._gridHeight = value;
|
20679
|
+
this.timelineGridControl.height = value;
|
20680
|
+
this.timeValueRuleContainer.height = value;
|
20681
|
+
}
|
20682
|
+
_startTime;
|
20683
|
+
_showDays = 7;
|
20684
|
+
get startTime() {
|
20685
|
+
return this._startTime;
|
20686
|
+
}
|
20687
|
+
set startTime(value) {
|
20688
|
+
this._startTime = value;
|
20689
|
+
this.timelineGridControl.startTime = value;
|
20690
|
+
}
|
20691
|
+
get showDays() {
|
20692
|
+
return this._showDays;
|
20693
|
+
}
|
20694
|
+
set showDays(value) {
|
20695
|
+
this._showDays = value;
|
20696
|
+
this.timelineGridControl.showDays = value;
|
20697
|
+
}
|
20698
|
+
/**
|
20699
|
+
* 网格区域高度
|
20700
|
+
*/
|
20701
|
+
_gridHeight = 0;
|
20702
|
+
scrollX = 0;
|
20703
|
+
timelineGridControl;
|
20704
|
+
timeValueRuleContainer;
|
20705
|
+
constructor() {
|
20706
|
+
super();
|
20707
|
+
this.timelineGridControl = new TimelineGridControl();
|
20708
|
+
this.addChild(this.timelineGridControl);
|
20709
|
+
this.timeValueRuleContainer = new TimeValueRuleContainer();
|
20710
|
+
this.addChild(this.timeValueRuleContainer);
|
20711
|
+
}
|
20712
|
+
init() {
|
20713
|
+
this.timelineGridControl.init();
|
20714
|
+
}
|
20715
|
+
measureOverride(e, availableSize) {
|
20716
|
+
this.timelineGridControl.measure(e, availableSize);
|
20717
|
+
const height = this.timelineGridControl.desiredSize.height;
|
20718
|
+
this.timeValueRuleContainer.measure(e, { height, width: availableSize.width });
|
20719
|
+
return { height, width: availableSize.width };
|
20720
|
+
}
|
20721
|
+
arrangeOverride(e, finalSize) {
|
20722
|
+
this.controls.filter(item => item !== this.timelineGridControl).forEach(item => {
|
20723
|
+
const itemRect = {
|
20724
|
+
x: item.x,
|
20725
|
+
y: item.y,
|
20726
|
+
width: item.desiredSize.width,
|
20727
|
+
height: item.desiredSize.height
|
20728
|
+
};
|
20729
|
+
item.arrange(e, itemRect);
|
20730
|
+
});
|
20731
|
+
this.timelineGridControl.arrange(e, {
|
20732
|
+
x: this.timelineGridControl.x - this.scrollX,
|
20733
|
+
y: this.timelineGridControl.y,
|
20734
|
+
width: this.timelineGridControl.desiredSize.width,
|
20735
|
+
height: this.timelineGridControl.desiredSize.height
|
20736
|
+
});
|
20737
|
+
return finalSize;
|
20738
|
+
}
|
20739
|
+
render(e) {
|
20740
|
+
}
|
20741
|
+
}
|
20742
|
+
class TimeValueRuleContainer extends AbsolutePanel {
|
20743
|
+
getLayoutWidth() {
|
20744
|
+
return this.controls.reduce((prev, curr) => prev + curr.width, 0);
|
20745
|
+
}
|
20746
|
+
init() {
|
20747
|
+
this.controls.reduce((prev, curr) => {
|
20748
|
+
curr.x = prev;
|
20749
|
+
return prev + curr.width;
|
20750
|
+
}, 0);
|
20751
|
+
}
|
20752
|
+
renderOutline(renderCtx) {
|
20753
|
+
translate(renderCtx, this.finalRect.x, this.finalRect.y);
|
20754
|
+
translate(renderCtx, this.border + this.padding, this.border + this.padding);
|
20755
|
+
}
|
20756
|
+
render(e) {
|
20757
|
+
}
|
20758
|
+
}
|
20759
|
+
/**
|
20760
|
+
* 标题区域
|
20761
|
+
* 时间刻度:日期、住院天数、手术天数、时刻
|
20762
|
+
* 数值标尺区域、数据网格区域
|
20763
|
+
* 文本时间轴区域
|
20764
|
+
*/
|
20765
|
+
class TimelineGridControl extends TimelineBaseControl {
|
20766
|
+
get isShowTemperature() {
|
20767
|
+
return this._isShowTemperature;
|
20768
|
+
}
|
20769
|
+
set isShowTemperature(value) {
|
20770
|
+
this.propertyChanged('isShowTemperature', this._isShowTemperature, value);
|
20771
|
+
this._isShowTemperature = value;
|
20772
|
+
}
|
20773
|
+
get isShowHeartRate() {
|
20774
|
+
return this._isShowHeartRate;
|
20775
|
+
}
|
20776
|
+
set isShowHeartRate(value) {
|
20777
|
+
this.propertyChanged('isShowHeartRate', this._isShowHeartRate, value);
|
20778
|
+
this._isShowHeartRate = value;
|
20779
|
+
}
|
20780
|
+
//体温数据
|
20781
|
+
temperatureData = [];
|
20782
|
+
//心率数据
|
20783
|
+
heartRateData = [];
|
20784
|
+
//体温时间轴值模型
|
20785
|
+
temperatureTimeLineValueModel = [];
|
20786
|
+
//心率时间轴值模型
|
20787
|
+
heartRateTimeLineValueModel = [];
|
20788
|
+
//图章数据
|
20789
|
+
eventData = [];
|
20790
|
+
_isShowTemperature = true;
|
20791
|
+
_isShowHeartRate = true;
|
20792
|
+
mousePos = null;
|
20793
|
+
constructor() {
|
20794
|
+
super();
|
20795
|
+
this.startTime = moment$1(moment$1().format("YYYY-MM-DD")).toDate();
|
20796
|
+
this.addEventListener('mousemove', evt => {
|
20797
|
+
const pos = evt.pos;
|
20798
|
+
const nodePos = getNodePosition(this, { x: 0, y: 0 });
|
20799
|
+
this.mousePos = { x: pos.x - nodePos.x, y: pos.y - nodePos.y };
|
20800
|
+
});
|
20801
|
+
this.addEventListener('mouseleave', evt => {
|
20802
|
+
this.mousePos = null;
|
20803
|
+
});
|
20804
|
+
}
|
20805
|
+
randomNum = (start, end) => {
|
20806
|
+
return Math.floor(Math.random() * (end - start) + start);
|
20807
|
+
};
|
20808
|
+
getLayoutWidth() {
|
20809
|
+
return this.showDays * (24 / timelineConfig.timeTickHours) * timelineConfig.timeTickWidth;
|
20810
|
+
}
|
20811
|
+
init() {
|
20812
|
+
this.temperatureTimeLineValueModel = timelineConfig.temperatureModels.map((item, index, arr) => ({
|
20813
|
+
value: item,
|
20814
|
+
offset: (index + 1) / (arr.length + 1)
|
20815
|
+
}));
|
20816
|
+
this.heartRateTimeLineValueModel = timelineConfig.heartRateModels.map((item, index, arr) => ({
|
20817
|
+
value: item,
|
20818
|
+
offset: (index + 1) / (arr.length + 1)
|
20819
|
+
}));
|
20820
|
+
const { timeTickHours } = timelineConfig;
|
20821
|
+
for (let i = 0; i < this.showDays; i++) {
|
20822
|
+
for (let j = 0; j < 24; j += timeTickHours) {
|
20823
|
+
this.temperatureData.push({
|
20824
|
+
date: moment$1(this.startTime).add(i, 'days').add(j, 'hours').toDate(),
|
20825
|
+
value: this.randomNum(33, 43) + this.randomNum(0, 10) / 10
|
20826
|
+
//value: 43
|
20827
|
+
});
|
20828
|
+
this.heartRateData.push({
|
20829
|
+
date: moment$1(this.startTime).add(i, 'days').add(j, 'hours').toDate(),
|
20830
|
+
value: this.randomNum(70, 150)
|
20831
|
+
});
|
20832
|
+
}
|
20833
|
+
this.eventData.push({ date: moment$1(this.startTime).add(i, 'days').toDate(), value: '入\r\n院' });
|
20834
|
+
}
|
20835
|
+
this.temperatureData.sort((prev, curr) => {
|
20836
|
+
return curr.date > prev.date ? 1 : -1;
|
20837
|
+
});
|
20838
|
+
this.heartRateData.sort((prev, curr) => curr.date > prev.date ? 1 : -1);
|
20839
|
+
}
|
20840
|
+
buildOverride(e) {
|
20841
|
+
this.buildTemperature(e);
|
20842
|
+
this.buildHearRate(e);
|
20843
|
+
this.buildStampUnit(e);
|
20844
|
+
const tipLabel = new LabelNode();
|
20845
|
+
tipLabel.text = '外\r\n科\r\n手\r\n术';
|
20846
|
+
tipLabel.borderColor = '#000';
|
20847
|
+
tipLabel.border = 1;
|
20848
|
+
tipLabel.shadowBlur = 5;
|
20849
|
+
tipLabel.shadowColor = 'red';
|
20850
|
+
tipLabel.fontSize = 12;
|
20851
|
+
tipLabel.bgColor = '#fff';
|
20852
|
+
tipLabel.color = 'red';
|
20853
|
+
tipLabel.textWrapping = 'wrap';
|
20854
|
+
//tipLabel.width = 14;
|
20855
|
+
tipLabel.x = 100;
|
20856
|
+
tipLabel.y = 30;
|
20857
|
+
this.addChild(tipLabel);
|
20858
|
+
}
|
20859
|
+
render(e) {
|
20860
|
+
const { timeValueHeight, timeTickHours, timeTickWidth } = timelineConfig;
|
20861
|
+
const ticks = 24 / timeTickHours;
|
20862
|
+
for (let i = 0; i < this.showDays; i++) {
|
20863
|
+
for (let j = 1; j <= ticks; j++) {
|
20864
|
+
const x = i * timeTickWidth * ticks + j * timeTickWidth;
|
20865
|
+
const color = j < ticks ? '#69c0ff' : '#ffadd2';
|
20866
|
+
e.render.strokeLines([{
|
20867
|
+
x,
|
20868
|
+
y: 0
|
20869
|
+
}, { x, y: this.finalRect.height }], 0.5, color);
|
20870
|
+
}
|
20871
|
+
}
|
20872
|
+
for (let i = timeValueHeight; i < this.finalRect.height; i += timeValueHeight) {
|
20873
|
+
e.render.strokeLines([{
|
20874
|
+
x: 0,
|
20875
|
+
y: i
|
20876
|
+
}, { x: this.finalRect.width, y: i }], 0.5, '#69c0ff');
|
20877
|
+
}
|
20878
|
+
this.renderTemperatureGuideLine(e);
|
20879
|
+
if (this.mousePos) {
|
20880
|
+
e.render.strokeLines([{ x: 0, y: this.mousePos.y }, { x: this.finalRect.width, y: this.mousePos.y }]);
|
20881
|
+
e.render.strokeLines([{ x: this.mousePos.x, y: 0 }, { x: this.mousePos.x, y: this.finalRect.height }]);
|
20882
|
+
}
|
20883
|
+
}
|
20884
|
+
renderTemperatureGuideLine(e) {
|
20885
|
+
const timelineValue = this.temperatureTimeLineValueModel.map(item => ({
|
20886
|
+
value: item.value,
|
20887
|
+
offset: this.height * item.offset
|
20888
|
+
}));
|
20889
|
+
//绘制正常36-37度,辅助线
|
20890
|
+
const startPoint = 36.5;
|
20891
|
+
const endPoint = 37.3;
|
20892
|
+
const startFilter = timelineValue.filter(item => item.value >= startPoint);
|
20893
|
+
const endFilter = timelineValue.filter(item => item.value >= endPoint);
|
20894
|
+
let startY = 0;
|
20895
|
+
let endY = 0;
|
20896
|
+
if (startFilter.length > 1) {
|
20897
|
+
const curr = startFilter[startFilter.length - 1];
|
20898
|
+
const next = startFilter[startFilter.length - 2];
|
20899
|
+
startY = curr.offset + (curr.value - startPoint) * (next.offset - curr.offset) / (curr.value - next.value);
|
20900
|
+
}
|
20901
|
+
if (endFilter.length > 1) {
|
20902
|
+
const curr = endFilter[endFilter.length - 1];
|
20903
|
+
const next = endFilter[endFilter.length - 2];
|
20904
|
+
endY = curr.offset + (curr.value - endPoint) * (next.offset - curr.offset) / (curr.value - next.value);
|
20905
|
+
}
|
20906
|
+
e.render.strokeLines([{ x: 0, y: startY }, { x: this.finalRect.width, y: startY }], 1, 'red');
|
20907
|
+
e.render.strokeLines([{ x: 0, y: endY }, { x: this.finalRect.width, y: endY }], 1, 'red');
|
20908
|
+
}
|
20909
|
+
buildTemperature(e) {
|
20910
|
+
if (this.temperatureData.length === 0) {
|
20911
|
+
return;
|
20912
|
+
}
|
20913
|
+
const height = this.height;
|
20914
|
+
const { timeValueHeight, timeTickHours, timeTickWidth, temperaturePointSize } = timelineConfig;
|
20915
|
+
const timelineValue = this.temperatureTimeLineValueModel.map(item => ({
|
20916
|
+
value: item.value,
|
20917
|
+
offset: height * item.offset
|
20918
|
+
}));
|
20919
|
+
//获取体温点纵向坐标
|
20920
|
+
const getTimelineVerValue = (val) => {
|
20921
|
+
const filter = timelineValue.filter(item => item.value >= val);
|
20922
|
+
if (filter.length) {
|
20923
|
+
if (filter.length > 1) {
|
20924
|
+
const curr = filter[filter.length - 1];
|
20925
|
+
const next = filter[filter.length - 2];
|
20926
|
+
return curr.offset + (curr.value - val) * (next.offset - curr.offset) / (curr.value - next.value);
|
20927
|
+
}
|
20928
|
+
else {
|
20929
|
+
return filter[0].offset;
|
20930
|
+
}
|
20931
|
+
}
|
20932
|
+
return -1;
|
20933
|
+
};
|
20934
|
+
let prevPos = null;
|
20935
|
+
for (let i = 0; i < this.showDays; i++) {
|
20936
|
+
const ticks = 24 / timeTickHours;
|
20937
|
+
for (let j = 0; j < ticks; j++) {
|
20938
|
+
const hourOffset = j * timeTickHours;
|
20939
|
+
const x = i * timeTickWidth * ticks + j * timeTickWidth;
|
20940
|
+
const startTime = moment$1(this.startTime).add(i, 'days').add(hourOffset, 'hours');
|
20941
|
+
const endTime = moment$1(this.startTime).add(i, 'days').add(hourOffset + timeTickHours, 'hours');
|
20942
|
+
const predicate = (item) => {
|
20943
|
+
return moment$1(item).isBetween(startTime, endTime, null, '(]');
|
20944
|
+
};
|
20945
|
+
const currTimePoints = this.temperatureData.filter(item => predicate(item.date));
|
20946
|
+
currTimePoints.forEach(item => {
|
20947
|
+
let currX = x;
|
20948
|
+
const diffMinutes = moment$1(item.date).diff(startTime, 'minutes');
|
20949
|
+
const offsetMinutes = diffMinutes * timeTickWidth / (timeTickHours * 60);
|
20950
|
+
currX += offsetMinutes;
|
20951
|
+
let currY = getTimelineVerValue(item.value);
|
20952
|
+
//超出显示范围
|
20953
|
+
if (currY > height) {
|
20954
|
+
currY = height;
|
20955
|
+
this.setExceededValueTip(e, item.value + '℃', currX, currY - 20);
|
20956
|
+
}
|
20957
|
+
if (currY < 0) {
|
20958
|
+
currY = 0;
|
20959
|
+
this.setExceededValueTip(e, item.value + '℃', currX, currY + 5);
|
20960
|
+
}
|
20961
|
+
const point = new TemperaturePoint('axillary', item.value);
|
20962
|
+
point.x = currX - point.width / 2;
|
20963
|
+
point.y = currY - point.width / 2;
|
20964
|
+
this.addChild(point);
|
20965
|
+
if (prevPos) {
|
20966
|
+
const linePath = new TimeLinePath();
|
20967
|
+
linePath.lineColor = 'blue';
|
20968
|
+
linePath.startPos = prevPos;
|
20969
|
+
linePath.endPos = { x: currX, y: currY };
|
20970
|
+
this.addChild(linePath);
|
20971
|
+
}
|
20972
|
+
prevPos = { x: currX, y: currY };
|
20973
|
+
});
|
20974
|
+
}
|
20975
|
+
}
|
20976
|
+
}
|
20977
|
+
setExceededValueTip(e, tip, x, y) {
|
20978
|
+
const tipLabel = new LabelNode();
|
20979
|
+
tipLabel.text = tip;
|
20980
|
+
tipLabel.borderColor = '#000';
|
20981
|
+
tipLabel.border = 1;
|
20982
|
+
tipLabel.shadowBlur = 5;
|
20983
|
+
tipLabel.shadowColor = '#000';
|
20984
|
+
tipLabel.fontSize = 10;
|
20985
|
+
tipLabel.bgColor = '#fff';
|
20986
|
+
const tipLabelWidth = e.render.measureText2(tipLabel.text, tipLabel);
|
20987
|
+
tipLabel.x = x -= tipLabelWidth / 2;
|
20988
|
+
tipLabel.y = y;
|
20989
|
+
this.addChild(tipLabel);
|
20990
|
+
}
|
20991
|
+
buildHearRate(e) {
|
20992
|
+
const height = this.height;
|
20993
|
+
const { timeTickHours, timeTickWidth, heartRateSymbol } = timelineConfig;
|
20994
|
+
const timelineValue = this.heartRateTimeLineValueModel.map(item => ({
|
20995
|
+
value: item.value,
|
20996
|
+
offset: height * item.offset
|
20997
|
+
}));
|
20998
|
+
//获取心率纵向坐标
|
20999
|
+
const getTimelineVerValue = (val) => {
|
21000
|
+
const filter = timelineValue.filter(item => item.value >= val);
|
21001
|
+
if (filter.length) {
|
21002
|
+
if (filter.length > 1) {
|
21003
|
+
const curr = filter[filter.length - 1];
|
21004
|
+
const next = filter[filter.length - 2];
|
21005
|
+
return curr.offset + (curr.value - val) * (next.offset - curr.offset) / (curr.value - next.value);
|
21006
|
+
}
|
21007
|
+
else {
|
21008
|
+
return filter[0].offset;
|
21009
|
+
}
|
21010
|
+
}
|
21011
|
+
return -1;
|
21012
|
+
};
|
21013
|
+
//const getTimelineHorValue=()
|
21014
|
+
let prevPos = null;
|
21015
|
+
for (let i = 0; i < this.showDays; i++) {
|
21016
|
+
const ticks = 24 / timeTickHours;
|
21017
|
+
for (let j = 0; j < ticks; j++) {
|
21018
|
+
const hourOffset = j * timeTickHours;
|
21019
|
+
const x = i * timeTickWidth * ticks + j * timeTickWidth;
|
21020
|
+
const startTime = moment$1(this.startTime).add(i, 'days').add(hourOffset, 'hours');
|
21021
|
+
const endTime = moment$1(this.startTime).add(i, 'days').add(hourOffset + timeTickHours, 'hours');
|
21022
|
+
const predicate = (item) => {
|
21023
|
+
return moment$1(item).isBetween(startTime, endTime, null, '(]');
|
21024
|
+
};
|
21025
|
+
const currTimePoints = this.heartRateData.filter(item => predicate(item.date));
|
21026
|
+
currTimePoints.forEach(item => {
|
21027
|
+
let currX = x;
|
21028
|
+
const diffMinutes = moment$1(item.date).diff(startTime, 'minutes');
|
21029
|
+
const offsetMinutes = diffMinutes * timeTickWidth / (timeTickHours * 60);
|
21030
|
+
currX += offsetMinutes;
|
21031
|
+
let currY = getTimelineVerValue(item.value);
|
21032
|
+
//超出显示范围
|
21033
|
+
if (currY > height) {
|
21034
|
+
currY = height;
|
21035
|
+
this.setExceededValueTip(e, item.value + heartRateSymbol, currX, currY - 20);
|
21036
|
+
}
|
21037
|
+
if (currY < 0) {
|
21038
|
+
currY = 0;
|
21039
|
+
this.setExceededValueTip(e, item.value + heartRateSymbol, currX, currY + 5);
|
21040
|
+
}
|
21041
|
+
const point = new HeartRatePoint();
|
21042
|
+
point.value = item.value + '次/分';
|
21043
|
+
point.x = currX - point.width / 2;
|
21044
|
+
point.y = currY - point.width / 2;
|
21045
|
+
this.addChild(point);
|
21046
|
+
if (prevPos) {
|
21047
|
+
const linePath = new TimeLinePath();
|
21048
|
+
linePath.lineColor = 'red';
|
21049
|
+
linePath.startPos = prevPos;
|
21050
|
+
linePath.endPos = { x: currX, y: currY };
|
21051
|
+
this.addChild(linePath);
|
21052
|
+
}
|
21053
|
+
prevPos = { x: currX, y: currY };
|
21054
|
+
});
|
21055
|
+
}
|
21056
|
+
}
|
21057
|
+
}
|
21058
|
+
buildStampUnit(e) {
|
21059
|
+
if (!this.eventData.length) {
|
21060
|
+
return;
|
21061
|
+
}
|
21062
|
+
const { timeTickHours, timeTickWidth, heartRateSymbol } = timelineConfig;
|
21063
|
+
for (let i = 0; i < this.showDays; i++) {
|
21064
|
+
const ticks = 24 / timeTickHours;
|
21065
|
+
for (let j = 0; j < ticks; j++) {
|
21066
|
+
const hourOffset = j * timeTickHours;
|
21067
|
+
const x = i * timeTickWidth * ticks + j * timeTickWidth;
|
21068
|
+
const startTime = moment$1(this.startTime).add(i, 'days').add(hourOffset, 'hours');
|
21069
|
+
const endTime = moment$1(this.startTime).add(i, 'days').add(hourOffset + timeTickHours, 'hours');
|
21070
|
+
const predicate = (item) => {
|
21071
|
+
return moment$1(item).isBetween(startTime, endTime, null, '(]');
|
21072
|
+
};
|
21073
|
+
const currTimePoints = this.eventData.filter(item => predicate(item.date));
|
21074
|
+
currTimePoints.forEach(item => {
|
21075
|
+
let currX = x;
|
21076
|
+
const diffMinutes = moment$1(item.date).diff(startTime, 'minutes');
|
21077
|
+
const offsetMinutes = diffMinutes * timeTickWidth / (timeTickHours * 60);
|
21078
|
+
currX += offsetMinutes;
|
21079
|
+
const tipLabel = new LabelNode();
|
21080
|
+
tipLabel.text = item.value;
|
21081
|
+
tipLabel.borderColor = '#000';
|
21082
|
+
tipLabel.border = 1;
|
21083
|
+
tipLabel.shadowBlur = 5;
|
21084
|
+
tipLabel.shadowColor = 'red';
|
21085
|
+
tipLabel.fontSize = 12;
|
21086
|
+
tipLabel.bgColor = '#fff';
|
21087
|
+
tipLabel.color = 'red';
|
21088
|
+
tipLabel.textWrapping = 'wrap';
|
21089
|
+
//tipLabel.width = 14;
|
21090
|
+
tipLabel.x = currX;
|
21091
|
+
tipLabel.y = 30;
|
21092
|
+
this.addChild(tipLabel);
|
21093
|
+
});
|
21094
|
+
}
|
21095
|
+
}
|
21096
|
+
}
|
21097
|
+
}
|
21098
|
+
/**
|
21099
|
+
* 心率数值标尺控件
|
21100
|
+
*/
|
21101
|
+
class HeartRateValueRuleControl extends TimelineBaseControl {
|
21102
|
+
constructor() {
|
21103
|
+
super();
|
21104
|
+
this.width = 50;
|
21105
|
+
}
|
21106
|
+
//体温时间轴值模型
|
21107
|
+
heartRateTimeLineValueModel = [];
|
21108
|
+
buildOverride(e) {
|
21109
|
+
const width = this.width;
|
21110
|
+
const height = this.height;
|
21111
|
+
const label = new LabelNode();
|
21112
|
+
label.text = '心率';
|
21113
|
+
label.fontSize = timelineConfig.fontSize;
|
21114
|
+
label.fontName = timelineConfig.fontName;
|
21115
|
+
label.y = 5;
|
21116
|
+
this.addChild(label);
|
21117
|
+
const textProps = new TextProps();
|
21118
|
+
textProps.fontSize = timelineConfig.fontSize;
|
21119
|
+
textProps.fontName = timelineConfig.fontName;
|
21120
|
+
label.x = (width - e.render.measureText(label.text, textProps).width) / 2;
|
21121
|
+
const timelineValue = this.heartRateTimeLineValueModel.map(item => ({
|
21122
|
+
value: item.value,
|
21123
|
+
offset: (height) * item.offset
|
21124
|
+
}));
|
21125
|
+
timelineValue.forEach(item => {
|
21126
|
+
const valueLabel = new LabelNode();
|
21127
|
+
valueLabel.fontName = timelineConfig.fontName;
|
21128
|
+
valueLabel.fontSize = timelineConfig.fontSize;
|
21129
|
+
valueLabel.text = item.value + '';
|
21130
|
+
valueLabel.x = (width - e.render.measureText(valueLabel.text, textProps).width) / 2;
|
21131
|
+
valueLabel.y = item.offset;
|
21132
|
+
this.addChild(valueLabel);
|
21133
|
+
});
|
21134
|
+
}
|
21135
|
+
render(e) {
|
21136
|
+
}
|
21137
|
+
}
|
21138
|
+
/**
|
21139
|
+
* 体温数值标尺控件
|
21140
|
+
*/
|
21141
|
+
class TemperatureValueRuleControl extends TimelineBaseControl {
|
21142
|
+
constructor() {
|
21143
|
+
super();
|
21144
|
+
this.width = 50;
|
21145
|
+
}
|
21146
|
+
//体温时间轴值模型
|
21147
|
+
temperatureTimeLineValueModel = [];
|
21148
|
+
buildOverride(e) {
|
21149
|
+
const width = this.width;
|
21150
|
+
const height = this.height;
|
21151
|
+
const label = new LabelNode();
|
21152
|
+
label.text = '体温';
|
21153
|
+
label.fontSize = timelineConfig.fontSize;
|
21154
|
+
label.fontName = timelineConfig.fontName;
|
21155
|
+
label.y = 5;
|
21156
|
+
this.addChild(label);
|
21157
|
+
label.x = (width - e.render.measureText2(label.text, label)) / 2;
|
21158
|
+
const timelineValue = this.temperatureTimeLineValueModel.map(item => ({
|
21159
|
+
value: item.value,
|
21160
|
+
offset: (height) * item.offset
|
21161
|
+
}));
|
21162
|
+
timelineValue.forEach(item => {
|
21163
|
+
const valueLabel = new LabelNode();
|
21164
|
+
valueLabel.fontName = timelineConfig.fontName;
|
21165
|
+
valueLabel.fontSize = timelineConfig.fontSize;
|
21166
|
+
valueLabel.text = item.value + '';
|
21167
|
+
valueLabel.x = (width - e.render.measureText2(valueLabel.text, valueLabel)) / 2;
|
21168
|
+
valueLabel.y = item.offset;
|
21169
|
+
this.addChild(valueLabel);
|
21170
|
+
});
|
21171
|
+
}
|
21172
|
+
render(e) {
|
21173
|
+
}
|
21174
|
+
}
|
21175
|
+
|
21176
|
+
/**
|
21177
|
+
* 事件轴标题
|
21178
|
+
* 日期、手术天数、术后天数、时刻
|
21179
|
+
*/
|
21180
|
+
class TimeTickTitleControl extends TimelineBaseControl {
|
21181
|
+
constructor() {
|
21182
|
+
super();
|
21183
|
+
this.bgColor = '#fff';
|
21184
|
+
}
|
21185
|
+
title;
|
21186
|
+
render(e) {
|
21187
|
+
}
|
21188
|
+
buildOverride(e) {
|
21189
|
+
const width = this.width;
|
21190
|
+
const height = this.height;
|
21191
|
+
const label = new LabelNode();
|
21192
|
+
label.text = this.title;
|
21193
|
+
label.fontSize = timelineConfig.fontSize;
|
21194
|
+
label.fontName = timelineConfig.fontName;
|
21195
|
+
const titleWidth = e.render.measureText2(label.text, label);
|
21196
|
+
label.x = (width - titleWidth) / 2;
|
21197
|
+
label.y = (height - label.fontSize) / 2;
|
21198
|
+
this.addChild(label);
|
21199
|
+
}
|
21200
|
+
}
|
21201
|
+
/**
|
21202
|
+
* 文本状态时刻控件,用于显示状态文本,例如:小便等
|
21203
|
+
*/
|
21204
|
+
class TextStatusTickControl extends TimelineBaseControl {
|
21205
|
+
render(e) {
|
21206
|
+
}
|
21207
|
+
buildOverride(e) {
|
21208
|
+
const { timeTickHours, timeTickWidth } = timelineConfig;
|
21209
|
+
const height = this.height;
|
21210
|
+
const ticks = 24 / timeTickHours;
|
21211
|
+
for (let i = 0; i < this.showDays; i++) {
|
21212
|
+
const width = ticks * timeTickWidth;
|
21213
|
+
// const curr = moment(this.startTime).add(i, 'days').format('YYYY-MM-DD');
|
21214
|
+
//
|
21215
|
+
// const label = new LabelNode();
|
21216
|
+
// label.text = curr + '';
|
21217
|
+
// label.fontSize = timelineConfig.fontSize;
|
21218
|
+
// label.fontName = timelineConfig.fontName;
|
21219
|
+
//
|
21220
|
+
// const dateTitleWidth = e.render.measureText2(curr + '', label);
|
21221
|
+
//
|
21222
|
+
// label.x = i * width + (width - dateTitleWidth) / 2;
|
21223
|
+
// label.y = (height - label.fontSize) / 2;
|
21224
|
+
// this.addChild(label);
|
21225
|
+
const path = new TimeLinePath();
|
21226
|
+
path.startPos = { x: i * width, y: 0 };
|
21227
|
+
path.endPos = { x: i * width, y: height };
|
21228
|
+
path.lineColor = '#ffadd2';
|
21229
|
+
this.addChild(path);
|
21230
|
+
}
|
21231
|
+
}
|
21232
|
+
}
|
21233
|
+
/**
|
21234
|
+
* 呼吸状态容器
|
21235
|
+
*/
|
21236
|
+
class TimelineHXStatusContainer extends TickContainer {
|
21237
|
+
tickTitleControl;
|
21238
|
+
constructor() {
|
21239
|
+
super();
|
21240
|
+
this.tickTitleControl = new TimeTickTitleControl();
|
21241
|
+
this.tickTitleControl.title = '呼吸';
|
21242
|
+
this.tickTitleControl.height = timelineConfig.tickHeaderHeight;
|
21243
|
+
this.tickControl = new TextStatusTickControl();
|
21244
|
+
this.tickControl.height = timelineConfig.tickHeaderHeight;
|
21245
|
+
this.addChild(this.tickControl);
|
21246
|
+
this.addChild(this.tickTitleControl);
|
21247
|
+
this.height = timelineConfig.tickHeaderHeight;
|
21248
|
+
}
|
21249
|
+
/**
|
21250
|
+
* 设置标题和刻度宽度
|
21251
|
+
* @param titleWidth
|
21252
|
+
* @param tickWidth
|
21253
|
+
*/
|
21254
|
+
setLayout(titleWidth, tickWidth) {
|
21255
|
+
this.width = tickWidth + titleWidth;
|
21256
|
+
this.tickTitleControl.width = titleWidth;
|
21257
|
+
this.tickControl.width = tickWidth;
|
21258
|
+
this.tickControl.x = titleWidth;
|
21259
|
+
}
|
21260
|
+
render(e) {
|
21261
|
+
}
|
21262
|
+
}
|
21263
|
+
/**
|
21264
|
+
* 小便状态容器
|
21265
|
+
*/
|
21266
|
+
class TimelineXBStatusContainer extends TickContainer {
|
21267
|
+
//statusControl: TextStatusTickControl;
|
21268
|
+
tickTitleControl;
|
21269
|
+
constructor() {
|
21270
|
+
super();
|
21271
|
+
this.tickTitleControl = new TimeTickTitleControl();
|
21272
|
+
this.tickTitleControl.title = '小便 ml';
|
21273
|
+
this.tickTitleControl.height = timelineConfig.tickHeaderHeight;
|
21274
|
+
this.tickControl = new TextStatusTickControl();
|
21275
|
+
this.tickControl.height = timelineConfig.tickHeaderHeight;
|
21276
|
+
this.addChild(this.tickControl);
|
21277
|
+
this.addChild(this.tickTitleControl);
|
21278
|
+
this.height = timelineConfig.tickHeaderHeight;
|
21279
|
+
}
|
21280
|
+
/**
|
21281
|
+
* 设置标题和刻度宽度
|
21282
|
+
* @param titleWidth
|
21283
|
+
* @param tickWidth
|
21284
|
+
*/
|
21285
|
+
setLayout(titleWidth, tickWidth) {
|
21286
|
+
this.width = tickWidth + titleWidth;
|
21287
|
+
this.tickTitleControl.width = titleWidth;
|
21288
|
+
this.tickControl.width = tickWidth;
|
21289
|
+
this.tickControl.x = titleWidth;
|
21290
|
+
}
|
21291
|
+
render(e) {
|
21292
|
+
}
|
21293
|
+
}
|
21294
|
+
/**
|
21295
|
+
* 其他状态容器
|
21296
|
+
*/
|
21297
|
+
class TimelineOtherStatusContainer extends TickContainer {
|
21298
|
+
//statusControl: TextStatusTickControl;
|
21299
|
+
tickTitleControl;
|
21300
|
+
constructor() {
|
21301
|
+
super();
|
21302
|
+
this.tickTitleControl = new TimeTickTitleControl();
|
21303
|
+
this.tickTitleControl.title = '其他';
|
21304
|
+
this.tickTitleControl.height = timelineConfig.tickHeaderHeight;
|
21305
|
+
this.tickControl = new TextStatusTickControl();
|
21306
|
+
this.tickControl.height = timelineConfig.tickHeaderHeight;
|
21307
|
+
this.addChild(this.tickControl);
|
21308
|
+
this.addChild(this.tickTitleControl);
|
21309
|
+
this.height = timelineConfig.tickHeaderHeight;
|
21310
|
+
}
|
21311
|
+
/**
|
21312
|
+
* 设置标题和刻度宽度
|
21313
|
+
* @param titleWidth
|
21314
|
+
* @param tickWidth
|
21315
|
+
*/
|
21316
|
+
setLayout(titleWidth, tickWidth) {
|
21317
|
+
this.width = tickWidth + titleWidth;
|
21318
|
+
this.tickTitleControl.width = titleWidth;
|
21319
|
+
this.tickControl.width = tickWidth;
|
21320
|
+
this.tickControl.x = titleWidth;
|
21321
|
+
}
|
21322
|
+
render(e) {
|
21323
|
+
}
|
21324
|
+
}
|
21325
|
+
|
21326
|
+
/**
|
21327
|
+
* 时间刻度区域
|
21328
|
+
* 循环日期显示
|
21329
|
+
* 住院天数
|
21330
|
+
* 术后天数
|
21331
|
+
* 时刻等
|
21332
|
+
*/
|
21333
|
+
/**
|
21334
|
+
* 日期时刻容器
|
21335
|
+
*/
|
21336
|
+
class DateTickContainer extends TickContainer {
|
21337
|
+
tickTitleControl;
|
21338
|
+
constructor() {
|
21339
|
+
super();
|
21340
|
+
this.tickTitleControl = new TimeTickTitleControl();
|
21341
|
+
this.tickTitleControl.title = '日期';
|
21342
|
+
this.tickTitleControl.height = timelineConfig.tickHeaderHeight;
|
21343
|
+
this.tickControl = new DateTickControl();
|
21344
|
+
this.tickControl.height = timelineConfig.tickHeaderHeight;
|
21345
|
+
this.addChild(this.tickControl);
|
21346
|
+
this.addChild(this.tickTitleControl);
|
21347
|
+
this.height = timelineConfig.tickHeaderHeight;
|
21348
|
+
}
|
21349
|
+
/**
|
21350
|
+
* 设置标题和刻度宽度
|
21351
|
+
* @param titleWidth
|
21352
|
+
* @param tickWidth
|
21353
|
+
*/
|
21354
|
+
setLayout(titleWidth, tickWidth) {
|
21355
|
+
this.width = tickWidth + titleWidth;
|
21356
|
+
this.tickTitleControl.width = titleWidth;
|
21357
|
+
this.tickControl.width = tickWidth;
|
21358
|
+
this.tickControl.x = titleWidth;
|
21359
|
+
}
|
21360
|
+
render(e) {
|
21361
|
+
}
|
21362
|
+
}
|
21363
|
+
/**
|
21364
|
+
* 日期刻度
|
21365
|
+
*/
|
21366
|
+
class DateTickControl extends TimelineBaseControl {
|
21367
|
+
buildOverride(e) {
|
21368
|
+
const { timeTickHours, timeTickWidth } = timelineConfig;
|
21369
|
+
const height = this.height;
|
21370
|
+
const ticks = 24 / timeTickHours;
|
21371
|
+
for (let i = 0; i < this.showDays; i++) {
|
21372
|
+
const width = ticks * timeTickWidth;
|
21373
|
+
const curr = moment$1(this.startTime).add(i, 'days').format('YYYY-MM-DD');
|
21374
|
+
const label = new LabelNode();
|
21375
|
+
label.text = curr + '';
|
21376
|
+
label.fontSize = timelineConfig.fontSize;
|
21377
|
+
label.fontName = timelineConfig.fontName;
|
21378
|
+
const dateTitleWidth = e.render.measureText2(curr + '', label);
|
21379
|
+
label.x = i * width + (width - dateTitleWidth) / 2;
|
21380
|
+
label.y = (height - label.fontSize) / 2;
|
21381
|
+
this.addChild(label);
|
21382
|
+
const path = new TimeLinePath();
|
21383
|
+
path.startPos = { x: i * width, y: 0 };
|
21384
|
+
path.endPos = { x: i * width, y: height };
|
21385
|
+
path.lineColor = '#ffadd2';
|
21386
|
+
this.addChild(path);
|
21387
|
+
}
|
21388
|
+
}
|
21389
|
+
render(e) {
|
21390
|
+
}
|
21391
|
+
}
|
21392
|
+
class TimeTickContainer extends TickContainer {
|
21393
|
+
tickTitleControl;
|
21394
|
+
constructor() {
|
21395
|
+
super();
|
21396
|
+
this.tickTitleControl = new TimeTickTitleControl();
|
21397
|
+
this.tickTitleControl.title = '时刻';
|
21398
|
+
this.tickTitleControl.height = timelineConfig.tickHeaderHeight;
|
21399
|
+
this.tickControl = new TimeTickControl();
|
21400
|
+
this.tickControl.height = timelineConfig.tickHeaderHeight;
|
21401
|
+
this.addChild(this.tickControl);
|
21402
|
+
this.addChild(this.tickTitleControl);
|
21403
|
+
this.height = timelineConfig.tickHeaderHeight;
|
21404
|
+
}
|
21405
|
+
/**
|
21406
|
+
* 设置标题和刻度宽度
|
21407
|
+
* @param titleWidth
|
21408
|
+
* @param tickWidth
|
21409
|
+
*/
|
21410
|
+
setLayout(titleWidth, tickWidth) {
|
21411
|
+
this.width = tickWidth + titleWidth;
|
21412
|
+
this.tickTitleControl.width = titleWidth;
|
21413
|
+
this.tickControl.width = tickWidth;
|
21414
|
+
this.tickControl.x = titleWidth;
|
21415
|
+
}
|
21416
|
+
render(e) {
|
21417
|
+
}
|
21418
|
+
}
|
21419
|
+
class TimeTickControl extends TimelineBaseControl {
|
21420
|
+
constructor() {
|
21421
|
+
super();
|
21422
|
+
this.border = 1;
|
21423
|
+
this.borderColor = '#000';
|
21424
|
+
}
|
21425
|
+
showDays = 7;
|
21426
|
+
buildOverride(e) {
|
21427
|
+
const { timeTickHours, timeTickWidth } = timelineConfig;
|
21428
|
+
const ticks = 24 / timeTickHours;
|
21429
|
+
for (let i = 0; i < this.showDays; i++) {
|
21430
|
+
for (let j = 1; j <= ticks; j++) {
|
21431
|
+
const hourOffset = j * timeTickHours;
|
21432
|
+
const x = i * timeTickWidth * ticks + j * timeTickWidth;
|
21433
|
+
const text = hourOffset + '';
|
21434
|
+
const label = new LabelNode();
|
21435
|
+
label.text = text;
|
21436
|
+
label.fontSize = timelineConfig.fontSize;
|
21437
|
+
label.fontName = timelineConfig.fontName;
|
21438
|
+
const dateTitleWidth = e.render.measureText2(text, label);
|
21439
|
+
label.x = x - timeTickWidth + (timeTickWidth - dateTitleWidth) / 2;
|
21440
|
+
label.y = 0;
|
21441
|
+
this.addChild(label);
|
21442
|
+
}
|
21443
|
+
}
|
21444
|
+
}
|
21445
|
+
render(e) {
|
21446
|
+
const { timeTickHours, timeTickWidth } = timelineConfig;
|
21447
|
+
const ticks = 24 / timeTickHours;
|
21448
|
+
for (let i = 0; i < this.showDays; i++) {
|
21449
|
+
for (let j = 1; j <= ticks; j++) {
|
21450
|
+
const x = i * timeTickWidth * ticks + j * timeTickWidth;
|
21451
|
+
const color = j < ticks ? '#69c0ff' : '#ffadd2';
|
21452
|
+
e.render.strokeLines([{
|
21453
|
+
x,
|
21454
|
+
y: 0
|
21455
|
+
}, { x, y: this.finalRect.height }], 1, color);
|
21456
|
+
}
|
21457
|
+
}
|
21458
|
+
}
|
21459
|
+
}
|
21460
|
+
class InPatDaysTickContainer extends TickContainer {
|
21461
|
+
//inPatDaysControl: InPatDaysControl;
|
21462
|
+
tickTitleControl;
|
21463
|
+
constructor() {
|
21464
|
+
super();
|
21465
|
+
this.tickTitleControl = new TimeTickTitleControl();
|
21466
|
+
this.tickTitleControl.title = '住院天数';
|
21467
|
+
this.tickTitleControl.height = timelineConfig.tickHeaderHeight;
|
21468
|
+
this.tickControl = new InPatDaysControl();
|
21469
|
+
this.tickControl.height = timelineConfig.tickHeaderHeight;
|
21470
|
+
this.addChild(this.tickControl);
|
21471
|
+
this.addChild(this.tickTitleControl);
|
21472
|
+
this.height = timelineConfig.tickHeaderHeight;
|
21473
|
+
}
|
21474
|
+
/**
|
21475
|
+
* 设置标题和刻度宽度
|
21476
|
+
* @param titleWidth
|
21477
|
+
* @param tickWidth
|
21478
|
+
*/
|
21479
|
+
setLayout(titleWidth, tickWidth) {
|
21480
|
+
this.width = tickWidth + titleWidth;
|
21481
|
+
this.tickTitleControl.width = titleWidth;
|
21482
|
+
this.tickControl.width = tickWidth;
|
21483
|
+
this.tickControl.x = titleWidth;
|
21484
|
+
}
|
21485
|
+
render(e) {
|
21486
|
+
}
|
21487
|
+
}
|
21488
|
+
class InPatDaysControl extends TimelineBaseControl {
|
21489
|
+
buildOverride(e) {
|
21490
|
+
const { timeTickHours, timeTickWidth } = timelineConfig;
|
21491
|
+
const height = this.height;
|
21492
|
+
const ticks = 24 / timeTickHours;
|
21493
|
+
for (let i = 0; i < this.showDays; i++) {
|
21494
|
+
const width = ticks * timeTickWidth;
|
21495
|
+
const text = (i + 1) + '';
|
21496
|
+
const label = new LabelNode();
|
21497
|
+
label.text = text;
|
21498
|
+
label.fontSize = timelineConfig.fontSize;
|
21499
|
+
label.fontName = timelineConfig.fontName;
|
21500
|
+
const dateTitleWidth = e.render.measureText2(text, label);
|
21501
|
+
label.x = i * width + (width - dateTitleWidth + label.fontSize) / 2;
|
21502
|
+
label.y = (height - label.fontSize) / 2;
|
21503
|
+
this.addChild(label);
|
21504
|
+
const path = new TimeLinePath();
|
21505
|
+
path.startPos = { x: i * width, y: 0 };
|
21506
|
+
path.endPos = { x: i * width, y: height };
|
21507
|
+
path.lineColor = '#ffadd2';
|
21508
|
+
this.addChild(path);
|
21509
|
+
}
|
21510
|
+
}
|
21511
|
+
render(e) {
|
21512
|
+
}
|
21513
|
+
}
|
21514
|
+
|
21515
|
+
class TimelineScrollBar extends NodeItems {
|
21516
|
+
//滚动条方向
|
21517
|
+
orientation = 'horizontal';
|
21518
|
+
thumb;
|
21519
|
+
thumbSize = 10;
|
21520
|
+
//按照百分比计算
|
21521
|
+
scrollChanged = new Subject();
|
21522
|
+
//总滚动宽度
|
21523
|
+
scrollSize = 0;
|
21524
|
+
//显示区域宽度
|
21525
|
+
viewSize = 0;
|
21526
|
+
scrollX = 0;
|
21527
|
+
scrollY = 0;
|
21528
|
+
constructor(orientation) {
|
21529
|
+
super();
|
21530
|
+
this.bgColor = '#fff';
|
21531
|
+
this.border = 1;
|
21532
|
+
this.borderColor = '#000';
|
21533
|
+
this.height = 16;
|
21534
|
+
this.orientation = orientation;
|
21535
|
+
this.thumb = new ScrollThumb();
|
21536
|
+
this.addChild(this.thumb);
|
21537
|
+
this.thumb.addEventListener('mousedown', evt => {
|
21538
|
+
const pos = { ...evt.pos };
|
21539
|
+
const { x, y } = this.thumb.finalRect;
|
21540
|
+
const mouseMoveListener = (evt2) => {
|
21541
|
+
//const scrollView = this.parent as ScrollView;
|
21542
|
+
const pos2 = evt2.pos;
|
21543
|
+
let moveX = pos2.x - pos.x;
|
21544
|
+
let moveY = pos2.y - pos.y;
|
21545
|
+
moveX += x;
|
21546
|
+
moveY += y;
|
21547
|
+
moveX = (moveX / this.finalRect.width) * this.scrollSize;
|
21548
|
+
moveY = (moveY / this.finalRect.height) * this.scrollSize;
|
21549
|
+
this.updateScroll(moveX, moveY);
|
21550
|
+
};
|
21551
|
+
const mouseUpListener = (evt3) => {
|
21552
|
+
this.thumb.removeEventListener('mousemove', mouseMoveListener);
|
21553
|
+
this.thumb.removeEventListener('mouseup', mouseUpListener);
|
21554
|
+
};
|
21555
|
+
this.thumb.addEventListener('mousemove', mouseMoveListener);
|
21556
|
+
this.thumb.addEventListener('mouseup', mouseUpListener);
|
21557
|
+
});
|
21558
|
+
}
|
21559
|
+
updateScroll(x, y) {
|
21560
|
+
//const scrollView = this.parent as ScrollView;
|
21561
|
+
if (this.orientation === 'horizontal') {
|
21562
|
+
if (this.finalRect.height === 0) {
|
21563
|
+
return;
|
21564
|
+
}
|
21565
|
+
if (x + this.viewSize > this.scrollSize) {
|
21566
|
+
x = this.scrollSize - this.viewSize;
|
21567
|
+
}
|
21568
|
+
x = x < 0 ? 0 : x;
|
21569
|
+
this.scrollChanged.next(x);
|
21570
|
+
this.scrollX = x;
|
21571
|
+
}
|
21572
|
+
}
|
21573
|
+
updateScrollByCurrent(increaseX, increaseY) {
|
21574
|
+
//const scrollView = this.parent as ScrollView;
|
21575
|
+
increaseX += this.scrollX;
|
21576
|
+
increaseY += this.scrollY;
|
21577
|
+
this.updateScroll(increaseX, increaseY);
|
21578
|
+
}
|
21579
|
+
measureOverride(e, availableSize) {
|
21580
|
+
if (this.orientation === 'horizontal') {
|
21581
|
+
return this.measureHorizontalBar(e, availableSize);
|
21582
|
+
}
|
21583
|
+
else {
|
21584
|
+
//return this.measureVerticalBar(e, availableSize);
|
21585
|
+
throw new Error('未实现');
|
21586
|
+
}
|
21587
|
+
}
|
21588
|
+
/**
|
21589
|
+
* 横向滚动条测量
|
21590
|
+
*/
|
21591
|
+
measureHorizontalBar(e, availableSize) {
|
21592
|
+
if (this.scrollSize > this.viewSize) {
|
21593
|
+
//计算滚动按钮的长度
|
21594
|
+
const thumbWidth = (this.viewSize / this.scrollSize) * availableSize.width;
|
21595
|
+
this.thumb.measure(e, { width: thumbWidth, height: this.thumbSize });
|
21596
|
+
return { width: availableSize.width, height: ScrollBarSize };
|
21597
|
+
}
|
21598
|
+
else {
|
21599
|
+
this.thumb.measure(e, { width: 0, height: 0 });
|
21600
|
+
return { width: 0, height: 0 };
|
21601
|
+
}
|
21602
|
+
}
|
21603
|
+
arrangeOverride(e, finalSize) {
|
21604
|
+
//const scrollView = this.parent as ScrollView;
|
21605
|
+
const { width, height } = this.thumb.desiredSize;
|
21606
|
+
const x = this.orientation === 'horizontal' ? (this.scrollX / this.scrollSize) * finalSize.width : (ScrollBarSize - this.thumbSize) / 2;
|
21607
|
+
const y = this.orientation === 'horizontal' ? (ScrollBarSize - this.thumbSize) / 2 : (this.scrollY / this.scrollSize) * finalSize.height;
|
21608
|
+
this.thumb.arrange(e, { x, y, width, height });
|
21609
|
+
return super.arrangeOverride(e, finalSize);
|
21610
|
+
}
|
21611
|
+
render(e) {
|
21612
|
+
//e.render.contentContext.clearRect(0,0,this.finalRect.width,this.finalRect.height);
|
21613
|
+
//e.render.fillRect(0, 0, this.finalRect.width, this.finalRect.height, 'red')
|
21614
|
+
}
|
21615
|
+
}
|
21616
|
+
|
21617
|
+
function createTimeline() {
|
21618
|
+
const timeline = new TimelineControl();
|
21619
|
+
timeline.width = 940;
|
21620
|
+
const timeGridContainer = new TimeGridContainer();
|
21621
|
+
//timeGridContainer.y = 80;
|
21622
|
+
const timelineGridControl = timeGridContainer.timelineGridControl; //new TimeLineControl();
|
21623
|
+
timelineGridControl.showDays = 30;
|
21624
|
+
timelineGridControl.width = timelineGridControl.getLayoutWidth();
|
21625
|
+
timelineGridControl.height = 300;
|
21626
|
+
timelineGridControl.init();
|
21627
|
+
const tempValueRule = new TemperatureValueRuleControl();
|
21628
|
+
tempValueRule.temperatureTimeLineValueModel = timelineGridControl.temperatureTimeLineValueModel;
|
21629
|
+
tempValueRule.bgColor = '#fff';
|
21630
|
+
tempValueRule.height = timelineGridControl.height;
|
21631
|
+
timeGridContainer.timeValueRuleContainer.addChild(tempValueRule);
|
21632
|
+
tempValueRule.addEventListener('mouseenter', evt => {
|
21633
|
+
tempValueRule.bgColor = 'grey';
|
21634
|
+
const mousemoveHandler = () => {
|
21635
|
+
tempValueRule.bgColor = '#fff';
|
21636
|
+
tempValueRule.removeEventListener('mouseleave', mousemoveHandler);
|
21637
|
+
};
|
21638
|
+
tempValueRule.addEventListener('mouseleave', mousemoveHandler);
|
21639
|
+
});
|
21640
|
+
const heartRateValueRule = new HeartRateValueRuleControl();
|
21641
|
+
heartRateValueRule.heartRateTimeLineValueModel = timelineGridControl.heartRateTimeLineValueModel;
|
21642
|
+
heartRateValueRule.bgColor = '#fff';
|
21643
|
+
heartRateValueRule.height = timelineGridControl.height;
|
21644
|
+
timeGridContainer.timeValueRuleContainer.addChild(heartRateValueRule);
|
21645
|
+
heartRateValueRule.addEventListener('mouseenter', evt => {
|
21646
|
+
heartRateValueRule.bgColor = 'grey';
|
21647
|
+
const mousemoveHandler = () => {
|
21648
|
+
heartRateValueRule.bgColor = '#fff';
|
21649
|
+
heartRateValueRule.removeEventListener('mouseleave', mousemoveHandler);
|
21650
|
+
};
|
21651
|
+
heartRateValueRule.addEventListener('mouseleave', mousemoveHandler);
|
21652
|
+
});
|
21653
|
+
timeGridContainer.timeValueRuleContainer.init();
|
21654
|
+
const titleWidth = timeGridContainer.timeValueRuleContainer.getLayoutWidth();
|
21655
|
+
timeGridContainer.timeValueRuleContainer.width = titleWidth;
|
21656
|
+
timeGridContainer.timeValueRuleContainer.height = timelineGridControl.height;
|
21657
|
+
timeGridContainer.timelineGridControl.x = timeGridContainer.timeValueRuleContainer.width;
|
21658
|
+
const dateHeader = new DateTickContainer();
|
21659
|
+
dateHeader.showDays = timelineGridControl.showDays;
|
21660
|
+
dateHeader.setLayout(titleWidth, timelineGridControl.width);
|
21661
|
+
timeline.addChild(dateHeader);
|
21662
|
+
const inDaysHeader = new InPatDaysTickContainer();
|
21663
|
+
inDaysHeader.showDays = timelineGridControl.showDays;
|
21664
|
+
inDaysHeader.setLayout(titleWidth, timelineGridControl.width);
|
21665
|
+
timeline.addChild(inDaysHeader);
|
21666
|
+
const timeHeader = new TimeTickContainer();
|
21667
|
+
timeHeader.showDays = timelineGridControl.showDays;
|
21668
|
+
timeHeader.setLayout(titleWidth, timelineGridControl.width);
|
21669
|
+
timeline.addChild(timeHeader);
|
21670
|
+
timeline.addChild(timeGridContainer);
|
21671
|
+
const hxStatus = new TimelineHXStatusContainer();
|
21672
|
+
hxStatus.showDays = timelineGridControl.showDays;
|
21673
|
+
hxStatus.setLayout(titleWidth, timelineGridControl.width);
|
21674
|
+
timeline.addChild(hxStatus);
|
21675
|
+
const xbStatus = new TimelineXBStatusContainer();
|
21676
|
+
xbStatus.showDays = timelineGridControl.showDays;
|
21677
|
+
xbStatus.setLayout(titleWidth, timelineGridControl.width);
|
21678
|
+
timeline.addChild(xbStatus);
|
21679
|
+
const otStatus = new TimelineOtherStatusContainer();
|
21680
|
+
otStatus.showDays = timelineGridControl.showDays;
|
21681
|
+
otStatus.setLayout(titleWidth, timelineGridControl.width);
|
21682
|
+
timeline.addChild(otStatus);
|
21683
|
+
const timelineScrollbar = new TimelineScrollBar('horizontal');
|
21684
|
+
timelineScrollbar.scrollSize = timelineGridControl.width;
|
21685
|
+
timelineScrollbar.viewSize = 840;
|
21686
|
+
timelineScrollbar.width = timeline.width;
|
21687
|
+
timelineScrollbar.scrollChanged.subscribe(data => {
|
21688
|
+
dateHeader.scrollX = data;
|
21689
|
+
inDaysHeader.scrollX = data;
|
21690
|
+
timeHeader.scrollX = data;
|
21691
|
+
timeGridContainer.scrollX = data;
|
21692
|
+
xbStatus.scrollX = data;
|
21693
|
+
hxStatus.scrollX = data;
|
21694
|
+
otStatus.scrollX = data;
|
21695
|
+
});
|
21696
|
+
timeline.addChild(timelineScrollbar);
|
21697
|
+
return timeline;
|
21698
|
+
}
|
21699
|
+
|
20367
21700
|
/**
|
20368
21701
|
* Node宽度定义
|
20369
21702
|
* 1.在单页模式下,文档最小宽度为单个文档宽度+合适的外边距
|
20370
21703
|
* 2.在多页模式下,文档最小宽度为单个文档宽度+合适的外边距
|
20371
21704
|
*/
|
20372
21705
|
class CanvasTextEditor extends AbsolutePanel {
|
20373
|
-
|
20374
|
-
editInput;
|
21706
|
+
container;
|
20375
21707
|
contentCtx;
|
20376
21708
|
viewOptions;
|
20377
21709
|
docCtx;
|
@@ -20399,10 +21731,12 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
20399
21731
|
onDocChangedEvent = new Subject$1();
|
20400
21732
|
//执行flushTask,refreshDoc之前,此时可以在文档计算排版之前改变内容
|
20401
21733
|
onBeforeRefreshDocument = new Subject$1();
|
20402
|
-
|
21734
|
+
editCanvas;
|
21735
|
+
editInput;
|
21736
|
+
constructor(container) {
|
20403
21737
|
super();
|
20404
|
-
this.
|
20405
|
-
this.
|
21738
|
+
this.container = container;
|
21739
|
+
this.createDocDOM();
|
20406
21740
|
this.viewOptions = new ViewOptions();
|
20407
21741
|
this.documentSelection = new DocumentSelection();
|
20408
21742
|
this.docCtx = new EditorContext(this.documentSelection.selectionState, this.viewOptions);
|
@@ -20425,14 +21759,13 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
20425
21759
|
this.viewOptions.fullPageView = false;
|
20426
21760
|
this.createDocViewer();
|
20427
21761
|
this.docComment = new DocumentComment(this.docCtx);
|
20428
|
-
this.contentCtx = editCanvas.getContext('2d');
|
21762
|
+
this.contentCtx = this.editCanvas.getContext('2d');
|
20429
21763
|
this.renderContext = new RenderContext(new PaintContent(this.contentCtx));
|
20430
21764
|
this.renderContext.init({ width: 500, height: 500, scale: 1 });
|
20431
21765
|
this.selectionState = this.documentSelection.selectionState;
|
20432
21766
|
this.selectionOverlays = new SelectionOverlays(this.documentSelection.selectionState);
|
20433
21767
|
this.documentPaint = new DocumentPaint(this.renderContext, this.docCtx, this.selectionOverlays.selectedSets);
|
20434
21768
|
this.elementReader = new ElementReader(this.docCtx);
|
20435
|
-
//this.docRule = new DocRule(this.ruleCanvas, this.docCtx);
|
20436
21769
|
this.documentInput = new DocumentInput(this, this.docCtx);
|
20437
21770
|
this.documentChange = new DocumentChange(this.elementReader, this.docCtx, this.docComment, this.documentInput);
|
20438
21771
|
this.documentEvent = new DocumentEvent(this, this.documentPaint, this.docCtx, this.documentInput);
|
@@ -20465,6 +21798,32 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
20465
21798
|
this.resetViewer(type);
|
20466
21799
|
});
|
20467
21800
|
}
|
21801
|
+
createDocDOM() {
|
21802
|
+
const container = document.getElementById(this.container);
|
21803
|
+
const canvas = document.createElement('canvas');
|
21804
|
+
const input = document.createElement('input');
|
21805
|
+
container.style.overflow = 'hidden';
|
21806
|
+
container.style.position = 'relative';
|
21807
|
+
container.style.fontSize = '0';
|
21808
|
+
container.style.height = '100%';
|
21809
|
+
input.style.position = 'absolute';
|
21810
|
+
input.style.width = '1px';
|
21811
|
+
input.style.padding = '0';
|
21812
|
+
input.style.border = 'none';
|
21813
|
+
input.style.outline = 'none';
|
21814
|
+
input.style.background = 'black';
|
21815
|
+
input.style.pointerEvents = 'none';
|
21816
|
+
this.editCanvas = canvas;
|
21817
|
+
this.editInput = input;
|
21818
|
+
container.appendChild(canvas);
|
21819
|
+
container.appendChild(input);
|
21820
|
+
container.insertAdjacentElement('afterbegin', input);
|
21821
|
+
container.insertAdjacentElement('afterbegin', canvas);
|
21822
|
+
}
|
21823
|
+
destroyDOM() {
|
21824
|
+
this.editInput.remove();
|
21825
|
+
this.editCanvas.remove();
|
21826
|
+
}
|
20468
21827
|
/**
|
20469
21828
|
* 设置标尺
|
20470
21829
|
*/
|
@@ -20887,6 +22246,9 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
20887
22246
|
destroy() {
|
20888
22247
|
this.docCtx.destroy();
|
20889
22248
|
this.documentEvent.clearSubEvent();
|
22249
|
+
this.selectionState.destroy();
|
22250
|
+
this.surfaceView.destroy();
|
22251
|
+
this.destroyDOM();
|
20890
22252
|
this.flushTask = null;
|
20891
22253
|
}
|
20892
22254
|
/**
|
@@ -21174,80 +22536,6 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
21174
22536
|
this.viewOptions.pageLayoutMode = mode;
|
21175
22537
|
this.flushToSchedule();
|
21176
22538
|
}
|
21177
|
-
// test2(): void {
|
21178
|
-
// //获取文档上下文
|
21179
|
-
// const docEleCtx = this.docCtx.getCtx(this.docCtx.document);
|
21180
|
-
// //获取年龄数据元
|
21181
|
-
// const dataEle = docEleCtx.getControlById('1493477712134672386') as DataElementText;
|
21182
|
-
// //获取要隐藏的数据组
|
21183
|
-
// const dataGroup = docEleCtx.ctx.treeFind((item) => item instanceof DataElementGroupElement) as DataElementGroupElement;
|
21184
|
-
// //侦听数据元更改时间
|
21185
|
-
// dataEle.onChangeSubject.subscribe((e) => {
|
21186
|
-
// //在文档重新排版、绘制前,获取最终的指定节点的内容
|
21187
|
-
// const beforeRefreshSub = this.onBeforeRefreshDocument.subscribe((e2) => {
|
21188
|
-
// console.log('内容发生改变,隐藏数据组');
|
21189
|
-
// //获取年龄数据元输入的值
|
21190
|
-
// const age = Number.parseInt(dataEle.getValue());
|
21191
|
-
// //年龄大于20,隐藏数据元
|
21192
|
-
// dataGroup.props.hidden = age > 20;
|
21193
|
-
// //取消订阅事件
|
21194
|
-
// beforeRefreshSub.unsubscribe();
|
21195
|
-
// });
|
21196
|
-
//
|
21197
|
-
// });
|
21198
|
-
// }
|
21199
|
-
//
|
21200
|
-
// //修改纸张尺寸,单位为毫米
|
21201
|
-
// //editor.setPaperSize(200,150)
|
21202
|
-
// test3(width: number, height: number): void {
|
21203
|
-
// this.setPaperSize(200, 150);
|
21204
|
-
// }
|
21205
|
-
//
|
21206
|
-
// //在当前段落后面插入新的段落,段落内容为当前时间
|
21207
|
-
// test4(): void {
|
21208
|
-
// const {startControl} = this.selectionState;
|
21209
|
-
// if (!startControl) {
|
21210
|
-
// return;
|
21211
|
-
// }
|
21212
|
-
// //1.获取当前段落
|
21213
|
-
// const currentParagraph = ElementUtil.getParentByType(startControl, ParagraphElement) as ParagraphElement;
|
21214
|
-
// //2.创建新段落对象
|
21215
|
-
// const newPara = ParagraphElement.createElement();
|
21216
|
-
//
|
21217
|
-
// //3.创建文本对象
|
21218
|
-
// const newText = new TextGroupElement();
|
21219
|
-
// newText.text = '当前时间为' + new Date();
|
21220
|
-
// newText.props.fontName = '楷体';
|
21221
|
-
// newText.props.fontSize = 18;
|
21222
|
-
// newText.props.color = '#5b8c00';
|
21223
|
-
// //4.将文本对象追加到新段落中
|
21224
|
-
// newPara.addChild(newText);
|
21225
|
-
// //5.在当前段落后面追加新段落
|
21226
|
-
// currentParagraph.parent.addChild(newPara, currentParagraph.getIndex() + 1);
|
21227
|
-
// //6.定位光标到新段落末尾处
|
21228
|
-
// this.selectionState.resetRange(newText,-1);
|
21229
|
-
// }
|
21230
|
-
//
|
21231
|
-
// //在当前位置插入文本数据元
|
21232
|
-
// test5():void{
|
21233
|
-
// const {startControl} = this.selectionState;
|
21234
|
-
// if (!startControl) {
|
21235
|
-
// return;
|
21236
|
-
// }
|
21237
|
-
// const newDataTextElement=new DataElementText();
|
21238
|
-
// newDataTextElement.props.nullText='请输入内容';
|
21239
|
-
// newDataTextElement.props.nullTextProps=new TextProps();
|
21240
|
-
// newDataTextElement.props.nullTextProps.fontSize=16;
|
21241
|
-
// newDataTextElement.props.nullTextProps.fontName='宋体';
|
21242
|
-
// newDataTextElement.props.nullTextProps.color='#ffc53d';
|
21243
|
-
// newDataTextElement.props.valueTextProps=new TextProps();
|
21244
|
-
// newDataTextElement.props.valueTextProps.fontSize=18;
|
21245
|
-
// newDataTextElement.props.valueTextProps.fontName='楷体';
|
21246
|
-
// newDataTextElement.props.valueTextProps.color='red';
|
21247
|
-
// this.insertNewElement(newDataTextElement);
|
21248
|
-
//
|
21249
|
-
// }
|
21250
|
-
//
|
21251
22539
|
// //覆盖修改页眉
|
21252
22540
|
// test6():void{
|
21253
22541
|
// //1.获取页眉对象
|
@@ -21307,7 +22595,8 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
21307
22595
|
const win = new Window();
|
21308
22596
|
win.width = 1000;
|
21309
22597
|
win.height = 800;
|
21310
|
-
|
22598
|
+
const timeLineControl = createTimeline();
|
22599
|
+
win.content.addChild(timeLineControl);
|
21311
22600
|
const rule2 = new RuleControl(this.docCtx);
|
21312
22601
|
this.rule = rule2;
|
21313
22602
|
rule2.width = 700;
|