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