cnhis-design-vue 3.1.12-beta.4 → 3.1.12-beta.7
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/es/packages/big-table/index.d.ts +0 -8
- package/es/packages/big-table/src/BigTable.vue.d.ts +0 -8
- package/es/packages/big-table/src/bigTableState.js +1 -1
- package/es/packages/fabric-chart/index.d.ts +195 -1
- package/es/packages/fabric-chart/src/FabricChart.vue.d.ts +196 -1
- package/es/packages/fabric-chart/src/FabricChart.vue_vue_type_script_setup_true_lang.js +269 -6
- package/es/packages/fabric-chart/src/components/PopupMenu.d.ts +46 -0
- package/es/packages/fabric-chart/src/components/PopupMenu.js +105 -0
- package/es/packages/fabric-chart/src/components/PopupTip.js +4 -0
- package/es/packages/fabric-chart/src/components/PopupTip.vue.d.ts +63 -0
- package/es/packages/fabric-chart/src/components/PopupTip.vue_vue_type_script_setup_true_lang.js +32 -0
- package/es/packages/fabric-chart/src/components/useStyle.d.ts +7 -0
- package/es/packages/fabric-chart/src/components/useStyle.js +36 -0
- package/es/packages/fabric-chart/src/hooks/constant.d.ts +14 -0
- package/es/packages/fabric-chart/src/hooks/constant.js +36 -0
- package/es/packages/fabric-chart/src/hooks/index.d.ts +9 -0
- package/es/packages/fabric-chart/src/hooks/index.js +9 -0
- package/es/packages/fabric-chart/src/hooks/useBottom.d.ts +4 -0
- package/es/packages/fabric-chart/src/hooks/useBottom.js +86 -0
- package/es/packages/fabric-chart/src/hooks/useCenter.d.ts +29 -0
- package/es/packages/fabric-chart/src/hooks/useCenter.js +475 -0
- package/es/packages/fabric-chart/src/hooks/useCumputedPoint.d.ts +7 -0
- package/es/packages/fabric-chart/src/hooks/useCumputedPoint.js +53 -0
- package/es/packages/fabric-chart/src/hooks/useDraw.d.ts +42 -0
- package/es/packages/fabric-chart/src/hooks/useDraw.js +86 -0
- package/es/packages/fabric-chart/src/hooks/useEvent.d.ts +1 -0
- package/es/packages/fabric-chart/src/hooks/useEvent.js +10 -0
- package/es/packages/fabric-chart/src/hooks/useGrid.d.ts +4 -0
- package/es/packages/fabric-chart/src/hooks/useGrid.js +44 -0
- package/es/packages/fabric-chart/src/hooks/useLeft.d.ts +4 -0
- package/es/packages/fabric-chart/src/hooks/useLeft.js +180 -0
- package/es/packages/fabric-chart/src/hooks/useOther.d.ts +4 -0
- package/es/packages/fabric-chart/src/hooks/useOther.js +34 -0
- package/es/packages/fabric-chart/src/hooks/useRight.d.ts +4 -0
- package/es/packages/fabric-chart/src/hooks/useRight.js +87 -0
- package/es/packages/fabric-chart/src/hooks/useShadow.d.ts +6 -0
- package/es/packages/fabric-chart/src/hooks/useShadow.js +127 -0
- package/es/packages/fabric-chart/src/hooks/useTop.d.ts +4 -0
- package/es/packages/fabric-chart/src/hooks/useTop.js +148 -0
- package/es/packages/fabric-chart/src/interface.d.ts +115 -0
- package/es/packages/fabric-chart/src/interface.js +3 -0
- package/es/packages/fabric-chart/src/utils/index.d.ts +2 -0
- package/es/packages/fabric-chart/src/utils/index.js +15334 -0
- package/es/packages/fabric-chart/style/index.css +43 -0
- package/es/packages/form-render/src/components/renderer/cascader.js +14 -0
- package/es/packages/form-render/src/components/renderer/checkbox.d.ts +2 -0
- package/es/packages/form-render/src/components/renderer/checkbox.js +4 -5
- package/es/packages/form-render/src/components/renderer/date.js +42 -10
- package/es/packages/form-render/src/components/renderer/index.d.ts +1 -0
- package/es/packages/form-render/src/components/renderer/index.js +1 -0
- package/es/packages/form-render/src/components/renderer/linebar.js +1 -1
- package/es/packages/form-render/src/components/renderer/select.js +11 -0
- package/es/packages/form-render/src/components/renderer/simpleComponent.d.ts +2 -0
- package/es/packages/form-render/src/components/renderer/simpleComponent.js +64 -0
- package/es/packages/form-render/src/components/renderer/slider.js +1 -1
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.d.ts +1 -1
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +24 -15
- package/es/packages/index.css +50 -2
- package/es/packages/scale-view/src/components/formitem/r-collection.d.ts +1 -1
- package/es/packages/scale-view/src/components/formitem/r-collection.js +2 -4
- package/es/packages/scale-view/src/hooks/scaleview-computed.js +1 -1
- package/es/packages/scale-view/src/hooks/scaleview-init.js +3 -1
- package/es/packages/scale-view/src/hooks/use-component.d.ts +5 -5
- package/es/packages/scale-view/style/index.css +0 -2
- package/es/packages/select-label/style/index.css +7 -0
- package/package.json +2 -2
|
@@ -1 +1,87 @@
|
|
|
1
|
+
import { fabric } from '../utils/index.js';
|
|
1
2
|
|
|
3
|
+
const defaultStyle = {
|
|
4
|
+
evented: false,
|
|
5
|
+
selectable: false
|
|
6
|
+
};
|
|
7
|
+
const defaultBorderStyle = {
|
|
8
|
+
stroke: "#999",
|
|
9
|
+
strokeWidth: 1,
|
|
10
|
+
...defaultStyle
|
|
11
|
+
};
|
|
12
|
+
const defaultLineStyle = {
|
|
13
|
+
stroke: "#000",
|
|
14
|
+
strokeWidth: 1,
|
|
15
|
+
strokeDashArray: [0, 0],
|
|
16
|
+
...defaultStyle
|
|
17
|
+
};
|
|
18
|
+
const defaultRectStyle = {
|
|
19
|
+
fill: "transparent",
|
|
20
|
+
stroke: "#999",
|
|
21
|
+
strokeWidth: 1,
|
|
22
|
+
originX: "center",
|
|
23
|
+
originY: "center",
|
|
24
|
+
...defaultStyle
|
|
25
|
+
};
|
|
26
|
+
const defaultTextStyle = {
|
|
27
|
+
fontFamily: "\u5FAE\u8F6F\u96C5\u9ED1",
|
|
28
|
+
fontSize: 12,
|
|
29
|
+
fill: "#000",
|
|
30
|
+
centeredRotation: true,
|
|
31
|
+
originX: "center",
|
|
32
|
+
originY: "center",
|
|
33
|
+
lineHeight: 1,
|
|
34
|
+
...defaultStyle
|
|
35
|
+
};
|
|
36
|
+
function drawLine(points, style) {
|
|
37
|
+
return new fabric.Line(points, {
|
|
38
|
+
...defaultLineStyle,
|
|
39
|
+
...style
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function drawTextGroup(rectStyle, fontStyle, groupStyle) {
|
|
43
|
+
const rect = new fabric.Rect({
|
|
44
|
+
...defaultRectStyle,
|
|
45
|
+
...rectStyle
|
|
46
|
+
});
|
|
47
|
+
const texts = new fabric.Text(String(fontStyle.value), {
|
|
48
|
+
...defaultTextStyle,
|
|
49
|
+
...fontStyle
|
|
50
|
+
});
|
|
51
|
+
return new fabric.Group([rect, texts], {
|
|
52
|
+
...groupStyle
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function drawPoint(type = "circle", style) {
|
|
56
|
+
let point = null;
|
|
57
|
+
const newStyle = {
|
|
58
|
+
originX: "center",
|
|
59
|
+
originY: "center",
|
|
60
|
+
hasControls: false,
|
|
61
|
+
hasBorders: false,
|
|
62
|
+
...style
|
|
63
|
+
};
|
|
64
|
+
switch (type) {
|
|
65
|
+
case "triangle":
|
|
66
|
+
point = new fabric.Triangle({
|
|
67
|
+
width: 20,
|
|
68
|
+
height: 20,
|
|
69
|
+
strokeWidth: 1,
|
|
70
|
+
scale: 1,
|
|
71
|
+
...newStyle
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
case "circle":
|
|
75
|
+
point = new fabric.Circle({
|
|
76
|
+
objectCaching: false,
|
|
77
|
+
strokeWidth: 1,
|
|
78
|
+
radius: 5,
|
|
79
|
+
scale: 1,
|
|
80
|
+
...newStyle
|
|
81
|
+
});
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
return point;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { defaultBorderStyle, defaultLineStyle, defaultRectStyle, defaultStyle, defaultTextStyle, drawLine, drawPoint, drawTextGroup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useEvent(element: HTMLCanvasElement | any): void;
|
|
@@ -1 +1,45 @@
|
|
|
1
|
+
import { onMounted, nextTick } from 'vue';
|
|
2
|
+
import { fabric } from '../utils/index.js';
|
|
3
|
+
import { drawLine } from './useDraw.js';
|
|
1
4
|
|
|
5
|
+
function useGrid(canvas, propItems) {
|
|
6
|
+
const { gridYNumber, originY, grid, originX, endX, xCellWidth, yCellHeight, gridXNumber, endY } = propItems;
|
|
7
|
+
const yList = [];
|
|
8
|
+
const xList = [];
|
|
9
|
+
for (let i = 0; i <= gridYNumber; i++) {
|
|
10
|
+
const y = originY + parseInt(String(yCellHeight * (gridYNumber - i)));
|
|
11
|
+
const style = i % grid.subYCell === 0 ? grid.mainLineStyle || {} : grid.subLineStyle || {};
|
|
12
|
+
yList.push(drawLine([originX, y, endX, y], {
|
|
13
|
+
id: i + "_" + new Date().getTime(),
|
|
14
|
+
...style
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
for (let i = 0; i <= gridXNumber; i++) {
|
|
18
|
+
const x = originX + parseInt(String(xCellWidth * i));
|
|
19
|
+
let style;
|
|
20
|
+
style = i % grid.subXCell === 0 ? grid.mainLineStyle || {} : grid.subLineStyle || {};
|
|
21
|
+
if (i % grid.subSecondXCell === 0) {
|
|
22
|
+
style = grid.subSecondLineStyle || {};
|
|
23
|
+
}
|
|
24
|
+
if (i % grid.subXCell === 0) {
|
|
25
|
+
style = grid.mainLineStyle || {};
|
|
26
|
+
}
|
|
27
|
+
xList.push(drawLine([x, originY, x, endY], {
|
|
28
|
+
id: i + "_" + new Date().getTime(),
|
|
29
|
+
...style
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
const group = new fabric.Group([...xList, ...yList], {
|
|
33
|
+
evented: false,
|
|
34
|
+
selectable: false
|
|
35
|
+
});
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
nextTick(() => {
|
|
38
|
+
canvas.value.add(group);
|
|
39
|
+
canvas.value.sendToBack(group);
|
|
40
|
+
canvas.value.renderAll();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { useGrid as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { fabric } from '../utils';
|
|
3
|
+
import { IPropItems } from '../interface';
|
|
4
|
+
export declare function useLeft(canvas: Ref<fabric.Canvas>, propItems: IPropItems, emits: any, setPopup: Function, pointTipProps: any, getXValue: Function, getYValue: Function, getEqualXTypes: Function): void;
|
|
@@ -1 +1,181 @@
|
|
|
1
|
+
import { onMounted, nextTick } from 'vue';
|
|
2
|
+
import { fabric } from '../utils/index.js';
|
|
3
|
+
import { defaultBorderStyle, defaultTextStyle, defaultStyle, defaultRectStyle, drawPoint, drawTextGroup } from './useDraw.js';
|
|
1
4
|
|
|
5
|
+
function useLeft(canvas, propItems, emits, setPopup, pointTipProps, getXValue, getYValue, getEqualXTypes) {
|
|
6
|
+
const {
|
|
7
|
+
originY,
|
|
8
|
+
endY,
|
|
9
|
+
originX,
|
|
10
|
+
endX,
|
|
11
|
+
yCellHeight,
|
|
12
|
+
borderStyle,
|
|
13
|
+
left,
|
|
14
|
+
vitalSignsOriginY,
|
|
15
|
+
painOriginY,
|
|
16
|
+
painHeight,
|
|
17
|
+
iconsWidth,
|
|
18
|
+
itemList
|
|
19
|
+
} = propItems;
|
|
20
|
+
function drwaPainScaleValue(item) {
|
|
21
|
+
const title = drawTextGroup({
|
|
22
|
+
width: originX - iconsWidth,
|
|
23
|
+
height: painHeight,
|
|
24
|
+
...defaultRectStyle
|
|
25
|
+
}, {
|
|
26
|
+
value: `${item.title.slice(0, 2)}
|
|
27
|
+
${item.title.slice(-2)}`,
|
|
28
|
+
...defaultTextStyle,
|
|
29
|
+
...item.titleStyle || {}
|
|
30
|
+
}, {
|
|
31
|
+
left: iconsWidth,
|
|
32
|
+
top: painOriginY.originY
|
|
33
|
+
});
|
|
34
|
+
const list = [];
|
|
35
|
+
item.list.forEach((v, i) => {
|
|
36
|
+
const top = painOriginY.endY - i * yCellHeight * item.spaceGridNumber;
|
|
37
|
+
const text = new fabric.Text(String(v), {
|
|
38
|
+
...defaultTextStyle,
|
|
39
|
+
originX: "right",
|
|
40
|
+
left: originX - (item.marginRight || 3),
|
|
41
|
+
top: i === 0 ? endY - 5 : top,
|
|
42
|
+
...item.style
|
|
43
|
+
});
|
|
44
|
+
list.push(text);
|
|
45
|
+
});
|
|
46
|
+
canvas.value.add(title, ...list);
|
|
47
|
+
}
|
|
48
|
+
function drawScaleValue() {
|
|
49
|
+
let groupList = [];
|
|
50
|
+
const column = !painHeight ? left.yScaleValue.length : left.yScaleValue.length - 1;
|
|
51
|
+
const colWidth = (originX - iconsWidth) / column;
|
|
52
|
+
const residue = (originX - iconsWidth) % column;
|
|
53
|
+
const firstColWidth = colWidth + residue;
|
|
54
|
+
left.yScaleValue.forEach((item, index) => {
|
|
55
|
+
if (item.type === "pain") {
|
|
56
|
+
drwaPainScaleValue(item);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let list = [];
|
|
60
|
+
const rectWidth = index === 0 ? firstColWidth : colWidth;
|
|
61
|
+
const rectLeft = index === 0 ? iconsWidth : firstColWidth + iconsWidth + (index - 1) * colWidth;
|
|
62
|
+
const line = index > 0 ? new fabric.Line([rectLeft, vitalSignsOriginY.originY, rectLeft, vitalSignsOriginY.endY], {
|
|
63
|
+
...defaultBorderStyle
|
|
64
|
+
}) : null;
|
|
65
|
+
line && list.push(line);
|
|
66
|
+
const leftVal = rectLeft + rectWidth / 2;
|
|
67
|
+
const spaceGridNumber = left.spaceGridNumber || 5;
|
|
68
|
+
item.list.forEach((v, i) => {
|
|
69
|
+
const top = vitalSignsOriginY.endY - i * yCellHeight * spaceGridNumber;
|
|
70
|
+
const text = new fabric.Text(String(v), {
|
|
71
|
+
...defaultTextStyle,
|
|
72
|
+
left: leftVal,
|
|
73
|
+
top: i === 0 ? top - 5 : top,
|
|
74
|
+
...item.style
|
|
75
|
+
});
|
|
76
|
+
list.push(text);
|
|
77
|
+
});
|
|
78
|
+
let title = item.title || "";
|
|
79
|
+
if (item.unit)
|
|
80
|
+
title += "\n" + item.unit;
|
|
81
|
+
title && list.push(new fabric.Text(String(title), {
|
|
82
|
+
...defaultTextStyle,
|
|
83
|
+
left: leftVal,
|
|
84
|
+
top: vitalSignsOriginY.originY + yCellHeight * spaceGridNumber / 2,
|
|
85
|
+
textAlign: "center",
|
|
86
|
+
...item.style
|
|
87
|
+
}));
|
|
88
|
+
const group2 = new fabric.Group(list, defaultStyle);
|
|
89
|
+
groupList.push(group2);
|
|
90
|
+
});
|
|
91
|
+
groupList.push(new fabric.Rect({
|
|
92
|
+
...defaultRectStyle,
|
|
93
|
+
width: originX - iconsWidth,
|
|
94
|
+
height: endY - originY,
|
|
95
|
+
left: iconsWidth,
|
|
96
|
+
top: originY,
|
|
97
|
+
originX: "left",
|
|
98
|
+
originY: "top"
|
|
99
|
+
}));
|
|
100
|
+
const group = groupList.length > 0 ? new fabric.Group([...groupList], { ...defaultStyle }) : null;
|
|
101
|
+
group && canvas.value.add(group);
|
|
102
|
+
group && group.sendToBack();
|
|
103
|
+
}
|
|
104
|
+
function drawIcons() {
|
|
105
|
+
let list = JSON.parse(JSON.stringify(itemList));
|
|
106
|
+
let topY = endY;
|
|
107
|
+
let leftX = iconsWidth - left.icons.marginRight;
|
|
108
|
+
list.reverse().forEach((item, index) => {
|
|
109
|
+
topY -= 10;
|
|
110
|
+
let title = item.title.replace(/(.{2})/g, "$1\n");
|
|
111
|
+
if (title.endsWith("\n")) {
|
|
112
|
+
title = title.slice(0, title.length - 1);
|
|
113
|
+
}
|
|
114
|
+
const text = new fabric.Text(String(title), {
|
|
115
|
+
...defaultStyle,
|
|
116
|
+
...item.titleStyle || {},
|
|
117
|
+
originX: "right",
|
|
118
|
+
originY: "bottom",
|
|
119
|
+
left: leftX - (item.pointAttr.width || 10) - 5,
|
|
120
|
+
top: topY,
|
|
121
|
+
lineHeight: 1,
|
|
122
|
+
fontSize: 12
|
|
123
|
+
});
|
|
124
|
+
const icon = drawPoint(item.type, {
|
|
125
|
+
left: leftX,
|
|
126
|
+
top: topY - (text.height || 30) / 2,
|
|
127
|
+
...item.pointAttr,
|
|
128
|
+
originY: "center",
|
|
129
|
+
originX: "right",
|
|
130
|
+
origin: {
|
|
131
|
+
title: item.title,
|
|
132
|
+
unit: item.unit,
|
|
133
|
+
type: item.bigType,
|
|
134
|
+
dataIndex: item.dataIndex
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
topY -= text.height || 30;
|
|
138
|
+
setPointEvent(icon);
|
|
139
|
+
canvas.value.add(text, icon);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function isLimit(point) {
|
|
143
|
+
return point.left >= originX && point.left <= endX && point.top >= originY && point.top <= endY;
|
|
144
|
+
}
|
|
145
|
+
function setPointEvent(point) {
|
|
146
|
+
point.on("moving", () => {
|
|
147
|
+
if (isLimit(point)) {
|
|
148
|
+
setPopup(point);
|
|
149
|
+
} else {
|
|
150
|
+
pointTipProps.show = false;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
point.on("mouseup:before", (event) => {
|
|
154
|
+
pointTipProps.show = false;
|
|
155
|
+
if (event.e.button === 0) {
|
|
156
|
+
if (isLimit(point)) {
|
|
157
|
+
if (!getEqualXTypes(point.left).includes(point.origin.type)) {
|
|
158
|
+
emits("add", {
|
|
159
|
+
data: {
|
|
160
|
+
time: getXValue(point.left),
|
|
161
|
+
value: getYValue(point.origin.type, point.top)
|
|
162
|
+
},
|
|
163
|
+
...point.origin
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
console.log("\u5F53\u524D\u65F6\u95F4\u6BB5\u5185\u65E0\u53EF\u65B0\u589E\u8282\u70B9");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
onMounted(() => {
|
|
173
|
+
nextTick(() => {
|
|
174
|
+
iconsWidth && drawIcons();
|
|
175
|
+
drawScaleValue();
|
|
176
|
+
canvas.value.renderAll();
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export { useLeft };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { onMounted, nextTick } from 'vue';
|
|
2
|
+
import { fabric } from '../utils/index.js';
|
|
3
|
+
import { defaultStyle } from './useDraw.js';
|
|
4
|
+
|
|
5
|
+
function useOther(canvas, propItems, cumputedX) {
|
|
6
|
+
const { originY, other, vitalSignsOriginY } = propItems;
|
|
7
|
+
function drawOther() {
|
|
8
|
+
if (!other || !other.list)
|
|
9
|
+
return false;
|
|
10
|
+
const list = [];
|
|
11
|
+
other.list.forEach((v, i) => {
|
|
12
|
+
const text = new fabric.Text(String(v.value.toString().split("").join("\n")), {
|
|
13
|
+
originX: "center",
|
|
14
|
+
top: vitalSignsOriginY.originY,
|
|
15
|
+
left: cumputedX(v.time),
|
|
16
|
+
textAlign: "center",
|
|
17
|
+
...defaultStyle,
|
|
18
|
+
...other.style || {}
|
|
19
|
+
});
|
|
20
|
+
list.push(text);
|
|
21
|
+
});
|
|
22
|
+
const group = list.length > 0 ? new fabric.Group([...list], { ...defaultStyle }) : null;
|
|
23
|
+
group && group.sendToBack();
|
|
24
|
+
group && canvas.value.add(group);
|
|
25
|
+
}
|
|
26
|
+
onMounted(() => {
|
|
27
|
+
nextTick(() => {
|
|
28
|
+
drawOther();
|
|
29
|
+
canvas.value.renderAll();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { useOther };
|
|
@@ -1 +1,88 @@
|
|
|
1
|
+
import { onMounted, nextTick } from 'vue';
|
|
2
|
+
import { fabric } from '../utils/index.js';
|
|
3
|
+
import { defaultBorderStyle, defaultRectStyle, defaultStyle } from './useDraw.js';
|
|
1
4
|
|
|
5
|
+
function useRight(canvas, propItems) {
|
|
6
|
+
const {
|
|
7
|
+
endX,
|
|
8
|
+
endY,
|
|
9
|
+
temperatureYCell,
|
|
10
|
+
canvasWidth,
|
|
11
|
+
canvasHeight,
|
|
12
|
+
left,
|
|
13
|
+
right,
|
|
14
|
+
breathingHeight,
|
|
15
|
+
vitalSignsOriginY,
|
|
16
|
+
painOriginY
|
|
17
|
+
} = propItems;
|
|
18
|
+
function drawScaleValue() {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
if (!right) {
|
|
21
|
+
canvas.value.add(new fabric.Line([canvasWidth - 1, 0, canvasWidth - 1, canvasHeight], defaultBorderStyle));
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
let list = [];
|
|
25
|
+
list.push(new fabric.Rect({
|
|
26
|
+
...defaultRectStyle,
|
|
27
|
+
width: canvasWidth - endX - 1,
|
|
28
|
+
height: endY + breathingHeight,
|
|
29
|
+
left: endX,
|
|
30
|
+
top: 0,
|
|
31
|
+
originX: "left",
|
|
32
|
+
originY: "top"
|
|
33
|
+
}));
|
|
34
|
+
const difVal = 6;
|
|
35
|
+
const spaceScaleNumber = right.yScaleValue.spaceScaleNumber || 5;
|
|
36
|
+
const mainScaleWidth = 9;
|
|
37
|
+
const subScaleWidth = 5;
|
|
38
|
+
const cList = left.yScaleValue.find((v) => v.type === "temperature").list;
|
|
39
|
+
const minC = Math.min(...cList);
|
|
40
|
+
const h1 = right.yScaleValue.list[1];
|
|
41
|
+
const h0 = right.yScaleValue.list[0];
|
|
42
|
+
const c1 = 5 * (h1 - 32) / 9;
|
|
43
|
+
const c0 = 5 * (h0 - 32) / 9;
|
|
44
|
+
const top1 = vitalSignsOriginY.endY - (c1 - minC) * temperatureYCell - difVal;
|
|
45
|
+
const top0 = vitalSignsOriginY.endY - (c0 - minC) * temperatureYCell - difVal;
|
|
46
|
+
const spaceHVaule = (top0 - top1) / spaceScaleNumber;
|
|
47
|
+
let endTop = 0;
|
|
48
|
+
right.yScaleValue.list.forEach((v, i) => {
|
|
49
|
+
var _a2;
|
|
50
|
+
const c = 5 * (+v - 32) / 9;
|
|
51
|
+
const top = vitalSignsOriginY.endY - (c - minC) * temperatureYCell - difVal;
|
|
52
|
+
if (i === right.yScaleValue.list.length - 1)
|
|
53
|
+
endTop = top;
|
|
54
|
+
const text = new fabric.Text(`${v}\xB0`, {
|
|
55
|
+
left: endX + mainScaleWidth,
|
|
56
|
+
top: i === 0 ? vitalSignsOriginY.endY - 5 : top - 5,
|
|
57
|
+
originX: "left",
|
|
58
|
+
...((_a2 = right.yScaleValue) == null ? void 0 : _a2.style) || {}
|
|
59
|
+
});
|
|
60
|
+
list.push(text);
|
|
61
|
+
const spaceHVaule0 = (vitalSignsOriginY.endY - top1) / spaceScaleNumber;
|
|
62
|
+
for (let k = 0; k < spaceScaleNumber; k++) {
|
|
63
|
+
const scaleTop = i === 0 ? vitalSignsOriginY.endY - k * spaceHVaule0 : top - k * spaceHVaule;
|
|
64
|
+
const line = new fabric.Line([endX, scaleTop, k > 0 ? endX + subScaleWidth : endX + mainScaleWidth, scaleTop], { ...defaultBorderStyle });
|
|
65
|
+
list.push(line);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const width = canvasWidth - endX;
|
|
69
|
+
const unit = right.yScaleValue.unit ? new fabric.Text((_b = (_a = right.yScaleValue) == null ? void 0 : _a.unit) == null ? void 0 : _b.split("").join("\n"), {
|
|
70
|
+
left: endX + width / 2,
|
|
71
|
+
top: endTop / 2,
|
|
72
|
+
originX: "center",
|
|
73
|
+
...((_c = right.yScaleValue) == null ? void 0 : _c.style) || {}
|
|
74
|
+
}) : null;
|
|
75
|
+
unit && list.push(unit);
|
|
76
|
+
const group = list.length > 0 ? new fabric.Group([...list], { ...defaultStyle }) : null;
|
|
77
|
+
group && group.sendToBack();
|
|
78
|
+
group && canvas.value.add(group);
|
|
79
|
+
}
|
|
80
|
+
onMounted(() => {
|
|
81
|
+
nextTick(() => {
|
|
82
|
+
drawScaleValue();
|
|
83
|
+
canvas.value.renderAll();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { useRight };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useMemoize } from '@vueuse/core';
|
|
2
|
+
import { fabric } from '../utils/index.js';
|
|
3
|
+
|
|
4
|
+
const getTangent = useMemoize((angle) => {
|
|
5
|
+
return +Math.tan(angle * Math.PI / 180);
|
|
6
|
+
});
|
|
7
|
+
function useShadow() {
|
|
8
|
+
function createShadowLines(coordinates, angle = 45, space = 10) {
|
|
9
|
+
const result = [];
|
|
10
|
+
angle = normalizeAngle(angle);
|
|
11
|
+
if (angle === 0)
|
|
12
|
+
return result;
|
|
13
|
+
const minX = Math.min(...coordinates.map(([x]) => x));
|
|
14
|
+
const maxX = Math.max(...coordinates.map(([x]) => x));
|
|
15
|
+
const minY = Math.min(...coordinates.map(([, y]) => y));
|
|
16
|
+
const maxY = Math.max(...coordinates.map(([, y]) => y));
|
|
17
|
+
const offsetX = (maxY - minY) / getTangent(angle);
|
|
18
|
+
const isLeanRight = angle > 0 && angle < 90 || angle > 180 && angle < 270;
|
|
19
|
+
let start = minX;
|
|
20
|
+
let end = maxX;
|
|
21
|
+
if (isLeanRight) {
|
|
22
|
+
end += offsetX;
|
|
23
|
+
} else {
|
|
24
|
+
start += offsetX;
|
|
25
|
+
}
|
|
26
|
+
getLinePoints(start, end).forEach((linePoint) => {
|
|
27
|
+
let intersectionPoints = [];
|
|
28
|
+
getShapeLinePoints(coordinates).forEach((shapeLinePoint) => {
|
|
29
|
+
const intersectionPoint = getIntersectionPoint(linePoint[0], linePoint[1], shapeLinePoint[0], shapeLinePoint[1]);
|
|
30
|
+
intersectionPoint && intersectionPoints.push(intersectionPoint);
|
|
31
|
+
});
|
|
32
|
+
intersectionPoints = sortPoints(uniquePoints(intersectionPoints));
|
|
33
|
+
if (intersectionPoints.length >= 2) {
|
|
34
|
+
for (let i = 0; i < intersectionPoints.length; i++) {
|
|
35
|
+
if (intersectionPoints[i + 1] && isInnerLine(intersectionPoints[i], intersectionPoints[i + 1])) {
|
|
36
|
+
result.push(createLine(intersectionPoints[i], intersectionPoints[i + 1]));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return result;
|
|
42
|
+
function isInnerLine(point1, point2) {
|
|
43
|
+
return isInPolygon([(point1[0] + point2[0]) / 2, (point1[1] + point2[1]) / 2], coordinates);
|
|
44
|
+
}
|
|
45
|
+
function normalizeAngle(angle2) {
|
|
46
|
+
angle2 = angle2 % 360;
|
|
47
|
+
angle2 = angle2 < 0 ? 180 - angle2 : angle2;
|
|
48
|
+
angle2 = angle2 >= 180 ? angle2 - 180 : angle2;
|
|
49
|
+
return angle2;
|
|
50
|
+
}
|
|
51
|
+
function getLinePoints(start2, end2) {
|
|
52
|
+
const result2 = [completePoint([start2, minY])];
|
|
53
|
+
while (start2 < end2) {
|
|
54
|
+
start2 += space;
|
|
55
|
+
result2.push(completePoint([start2, minY]));
|
|
56
|
+
}
|
|
57
|
+
return result2;
|
|
58
|
+
}
|
|
59
|
+
function completePoint(point) {
|
|
60
|
+
const otherPoint = [point[0] - offsetX, maxY];
|
|
61
|
+
return [point, otherPoint];
|
|
62
|
+
}
|
|
63
|
+
function getShapeLinePoints(coordinates2) {
|
|
64
|
+
return coordinates2.reduce((res, c, idx) => {
|
|
65
|
+
const next = coordinates2[idx + 1] || coordinates2[0];
|
|
66
|
+
res.push([c, next]);
|
|
67
|
+
return res;
|
|
68
|
+
}, []);
|
|
69
|
+
}
|
|
70
|
+
function createLine(startPoint, endPoint) {
|
|
71
|
+
return new fabric.Line([startPoint[0], startPoint[1], endPoint[0], endPoint[1]]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { createShadowLines };
|
|
75
|
+
function sortPoints(points) {
|
|
76
|
+
return points.sort((a, b) => a[1] - b[1]);
|
|
77
|
+
}
|
|
78
|
+
function getIntersectionPoint(a, b, c, d) {
|
|
79
|
+
const denominator = (b[1] - a[1]) * (d[0] - c[0]) - (a[0] - b[0]) * (c[1] - d[1]);
|
|
80
|
+
if (denominator === 0) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const x = ((b[0] - a[0]) * (d[0] - c[0]) * (c[1] - a[1]) + (b[1] - a[1]) * (d[0] - c[0]) * a[0] - (d[1] - c[1]) * (b[0] - a[0]) * c[0]) / denominator;
|
|
84
|
+
const y = -((b[1] - a[1]) * (d[1] - c[1]) * (c[0] - a[0]) + (b[0] - a[0]) * (d[1] - c[1]) * a[1] - (d[0] - c[0]) * (b[1] - a[1]) * c[1]) / denominator;
|
|
85
|
+
if (((x - a[0]) * (x - b[0]) < 0 || nearlyEqual(x, a[0]) || nearlyEqual(x, b[0])) && ((y - a[1]) * (y - b[1]) < 0 || nearlyEqual(y, a[1]) || nearlyEqual(y, b[1])) && ((x - c[0]) * (x - d[0]) < 0 || nearlyEqual(x, c[0]) || nearlyEqual(x, d[0])) && ((y - c[1]) * (y - d[1]) < 0 || nearlyEqual(y, c[1]) || nearlyEqual(y, d[1]))) {
|
|
86
|
+
return [x, y];
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
function uniquePoints(points) {
|
|
91
|
+
return points.reduce((fin, point) => {
|
|
92
|
+
if (!hasPoint(fin, point))
|
|
93
|
+
fin.push(point);
|
|
94
|
+
return fin;
|
|
95
|
+
}, []);
|
|
96
|
+
function hasPoint(points2, point) {
|
|
97
|
+
return points2.some((p) => nearlyEqual(p[0], point[0]) && nearlyEqual(p[1], point[1]));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function isInPolygon(checkPoint, polygonPoints) {
|
|
101
|
+
let counter = 0;
|
|
102
|
+
let xinters;
|
|
103
|
+
let p1, p2;
|
|
104
|
+
let pointCount = polygonPoints.length;
|
|
105
|
+
p1 = polygonPoints[0];
|
|
106
|
+
for (let i = 1; i <= pointCount; i++) {
|
|
107
|
+
p2 = polygonPoints[i % pointCount];
|
|
108
|
+
if (checkPoint[0] > Math.min(p1[0], p2[0]) && checkPoint[0] <= Math.max(p1[0], p2[0])) {
|
|
109
|
+
if (checkPoint[1] <= Math.max(p1[1], p2[1])) {
|
|
110
|
+
if (p1[0] != p2[0]) {
|
|
111
|
+
xinters = (checkPoint[0] - p1[0]) * (p2[1] - p1[1]) / (p2[0] - p1[0]) + p1[1];
|
|
112
|
+
if (p1[1] == p2[1] || checkPoint[1] <= xinters) {
|
|
113
|
+
counter++;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
p1 = p2;
|
|
119
|
+
}
|
|
120
|
+
return counter % 2 !== 0;
|
|
121
|
+
}
|
|
122
|
+
function nearlyEqual(v1, v2) {
|
|
123
|
+
return Math.abs(v1 - v2) <= 1e-4;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { useShadow };
|