cnhis-design-vue 3.1.33-beta.4 → 3.1.33-beta.5

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.
@@ -1,344 +1,37 @@
1
- import { defineComponent, ref, computed, reactive, onMounted, onBeforeUnmount, openBlock, createElementBlock, Fragment, createElementVNode, unref, createBlock, mergeProps, createCommentVNode } from 'vue';
2
- import { fabric } from './utils/index.js';
3
- import { defaultBorderStyle } from './hooks/useDraw.js';
4
- import { useCumputedPoint } from './hooks/useCumputedPoint.js';
5
- import { useTop } from './hooks/useTop.js';
6
- import { useLeft } from './hooks/useLeft.js';
7
- import { useRight } from './hooks/useRight.js';
8
- import { useCenter } from './hooks/useCenter.js';
9
- import { useBottom } from './hooks/useBottom.js';
10
- import { useOther } from './hooks/useOther.js';
11
- import { useEvent, useCanvasEvent } from './hooks/useEvent.js';
12
- import PopupTip from './components/PopupTip.vue.js';
13
- import PopupMenu from './components/PopupMenu.js';
1
+ import { defineComponent, computed, ref, unref, openBlock, createBlock, mergeProps, createCommentVNode } from 'vue';
2
+ import TemperatureChart from './TemperatureChart.vue.js';
14
3
  import _export_sfc from '../../../_virtual/plugin-vue_export-helper.js';
15
4
 
16
5
  const _sfc_main = /* @__PURE__ */ defineComponent({
17
6
  __name: "FabricChart",
18
7
  props: {
19
- data: null,
20
- addRenderItem: null
8
+ mode: { type: String, default: "temperature" }
21
9
  },
22
- emits: [
23
- "change",
24
- "add",
25
- "select"
26
- ],
27
- setup(__props, { expose, emit: emits }) {
10
+ setup(__props, { expose }) {
11
+ var _a;
28
12
  const props = __props;
29
- const defaultHeight = 15;
30
- let select = ref();
31
- const canvasRef = ref(null);
32
- let canvas = ref();
33
- const dateHeight = computed(() => {
34
- const { top } = props.data;
35
- return top.date.show && (top.date.height || defaultHeight) || 0;
36
- });
37
- const hospitalDaysHeight = computed(() => {
38
- var _a;
39
- const { top } = props.data;
40
- return ((_a = top.hospitalDays) == null ? void 0 : _a.show) && (top.hospitalDays.height || defaultHeight) || 0;
41
- });
42
- const operationDaysHeight = computed(() => {
43
- var _a;
44
- const { top } = props.data;
45
- return ((_a = top.operationDays) == null ? void 0 : _a.show) && (top.operationDays.height || defaultHeight) || 0;
46
- });
47
- const xScalevalueHeight = computed(() => {
48
- var _a, _b, _c;
49
- const { top } = props.data;
50
- const height = ((_a = top.xScalevalue) == null ? void 0 : _a.show) && (top.xScalevalue.height || defaultHeight) || 0;
51
- const dayHeight = ((_b = top.xScalevalue) == null ? void 0 : _b.show) ? (_c = top.dayHeight) != null ? _c : 0 : 0;
52
- return height + dayHeight;
53
- });
54
- const breathingHeight = computed(() => {
55
- var _a;
56
- const { bottom } = props.data;
57
- return ((_a = bottom == null ? void 0 : bottom.breathing) == null ? void 0 : _a.show) && (bottom.breathing.height || defaultHeight * 2) || 0;
58
- });
59
- const gridXNumber = computed(() => {
60
- const { grid } = props.data;
61
- return grid.mainXCell * grid.subXCell + grid.surplusXCell;
62
- });
63
- const gridYNumber = computed(() => {
64
- const { grid } = props.data;
65
- return grid.mainYCell * grid.subYCell + grid.surplusYCell;
66
- });
67
- const endX = computed(() => {
68
- var _a;
69
- const { width, right = null, top } = props.data;
70
- if (!right)
71
- return width;
72
- const endWidth = (_a = right.width) != null ? _a : 0;
73
- return width - endWidth;
74
- });
75
- const endXLimit = computed(() => {
76
- const { grid } = props.data;
77
- return endX.value - grid.surplusXCell * xCellWidth.value;
78
- });
79
- const originX = computed(() => {
80
- const { top, left } = props.data;
81
- const originX2 = top.titleWidth + iconsWidth.value;
82
- return originX2;
83
- });
84
- const endY = computed(() => {
85
- const { bottom = null, height } = props.data;
86
- if (!bottom)
87
- return height;
88
- const endHeight = bottom.height || 30;
89
- return height - endHeight;
90
- });
91
- const originY = computed(() => {
92
- var _a;
93
- const { top } = props.data;
94
- const dayHeight = top.xScalevalue.show && ((_a = top.dayHeight) != null ? _a : 0) || 0;
95
- const xScaleHeight = top.xScalevalue.show && (top.xScalevalue.height || defaultHeight) || 0;
96
- const topHeight = dateHeight.value + dayHeight + xScaleHeight + hospitalDaysHeight.value + operationDaysHeight.value;
97
- return topHeight;
98
- });
99
- const originYLimit = computed(() => {
100
- const { grid } = props.data;
101
- return originY.value + grid.surplusYCell * yCellHeight.value;
102
- });
103
- const xCellWidth = computed(() => {
104
- return (endX.value - originX.value) / gridXNumber.value;
105
- });
106
- const yCellHeight = computed(() => {
107
- return (endY.value - originY.value) / gridYNumber.value;
108
- });
109
- const iconsWidth = computed(() => {
110
- var _a, _b;
111
- const { left } = props.data;
112
- return ((_a = left.icons) == null ? void 0 : _a.show) && (((_b = left.icons) == null ? void 0 : _b.width) || 100) || 0;
113
- });
114
- const xScaleList = computed(() => {
115
- const { top } = props.data;
116
- const dateList = top.date.list;
117
- const times = top.xScalevalue.times;
118
- let left = originX.value - xCellWidth.value;
119
- function getDate(date) {
120
- const [year = "2022", month = "01", day = "01"] = String(date).match(/\d+/g) || [];
121
- return `20${year}`.slice(-4) + "-" + `00${month}`.slice(-2) + "-" + `00${day}`.slice(-2);
122
- }
123
- const timeList = dateList.map((item) => {
124
- return times.map((v) => {
125
- left += xCellWidth.value;
126
- const start = new Date(`${getDate(item)} ${v.start}`).getTime();
127
- const end = new Date(`${getDate(item)} ${v.end}`).getTime();
128
- return {
129
- start,
130
- end,
131
- left,
132
- center: left + xCellWidth.value / 2,
133
- scaleCell: (end - start) / xCellWidth.value
134
- };
135
- });
136
- });
137
- return timeList.flat();
138
- });
139
- const breatheYCell = computed(() => {
140
- return computedYCell("breathe");
141
- });
142
- const pulseYCell = computed(() => {
143
- return computedYCell("pulse");
144
- });
145
- const temperatureYCell = computed(() => {
146
- return computedYCell("temperature");
147
- });
148
- const painYCell = computed(() => {
149
- return computedYCell("pain");
150
- });
151
- const event = computed(() => {
152
- var _a;
153
- return ((_a = props.data.grid) == null ? void 0 : _a.event) || { selectable: true, evented: true, hovered: true };
154
- });
155
- const itemList = computed(() => {
156
- const { left } = props.data;
157
- return left.yScaleValue.map((item) => {
158
- return item.dataList.map((v, dataIndex) => {
159
- return {
160
- ...v,
161
- bigType: item.type,
162
- unit: item.unit,
163
- dataIndex
164
- };
165
- });
166
- }).flat();
167
- });
168
- const painIndex = computed(() => {
169
- const { left } = props.data;
170
- return left.yScaleValue.findIndex((v) => v.type === "pain");
171
- });
172
- const painHeight = computed(() => {
173
- const { grid } = props.data;
174
- return painIndex.value === -1 ? 0 : yCellHeight.value * grid.subYCell;
175
- });
176
- const painOriginY = computed(() => {
177
- const { left } = props.data;
178
- let obj = {
179
- originY: endY.value,
180
- endY: endY.value
181
- };
182
- if (painIndex.value === 0 && left.yScaleValue.length > 1) {
183
- obj.originY = originYLimit.value;
184
- obj.endY = originYLimit.value + painHeight.value;
185
- } else if (painIndex.value === left.yScaleValue.length - 1) {
186
- obj.originY = endY.value - painHeight.value;
187
- obj.endY = endY.value;
188
- }
189
- return obj;
190
- });
191
- const vitalSignsOriginY = computed(() => {
192
- const { left } = props.data;
193
- let obj = {
194
- originY: originY.value,
195
- endY: endY.value
196
- };
197
- if (painIndex.value === 0 && left.yScaleValue.length > 1) {
198
- obj.originY = originYLimit.value + painHeight.value;
199
- obj.endY = endY.value;
200
- } else if (painIndex.value === left.yScaleValue.length - 1) {
201
- obj.originY = originYLimit.value;
202
- obj.endY = endY.value - painHeight.value;
203
- }
204
- return obj;
205
- });
206
- const topList = computed(() => {
207
- const { top } = props.data;
208
- let topList2 = [];
209
- for (let i in top) {
210
- if (top[i].show) {
211
- topList2.push({
212
- ...top[i],
213
- key: i
214
- });
215
- }
216
- }
217
- return topList2.sort((a, b) => a.seq - b.seq);
218
- });
219
- const getRightInfo = computed(() => {
220
- var _a;
221
- const { left, right } = props.data;
222
- const temperatureObj = left.yScaleValue.find((v) => v.type === "temperature");
223
- const yScaleValue = (right == null ? void 0 : right.yScaleValue) || {};
224
- if ((_a = temperatureObj == null ? void 0 : temperatureObj.list) == null ? void 0 : _a.length) {
225
- Object.assign(yScaleValue, {
226
- list: temperatureObj.list.map((v) => Math.floor((1.8 * v + 32) * 100) / 100),
227
- spaceGridNumber: temperatureObj.spaceGridNumber
228
- });
229
- }
230
- return yScaleValue;
231
- });
232
- const propItems = reactive({
233
- canvasWidth: props.data.width,
234
- canvasHeight: props.data.height,
235
- borderStyle: props.data.borderStyle || defaultBorderStyle,
236
- selectionStyle: props.data.selectionStyle || {},
237
- dateHeight: dateHeight.value,
238
- hospitalDaysHeight: hospitalDaysHeight.value,
239
- operationDaysHeight: operationDaysHeight.value,
240
- xScalevalueHeight: xScalevalueHeight.value,
241
- topList: topList.value,
242
- breathingHeight: breathingHeight.value,
243
- hospitalizationDate: props.data.hospitalizationDate,
244
- grid: props.data.grid,
245
- top: props.data.top,
246
- left: props.data.left,
247
- right: props.data.right,
248
- bottom: props.data.bottom,
249
- other: props.data.other,
250
- painIndex: painIndex.value,
251
- painHeight: painHeight.value,
252
- painOriginY: painOriginY.value,
253
- vitalSignsOriginY: vitalSignsOriginY.value,
254
- gridXNumber: gridXNumber.value,
255
- gridYNumber: gridYNumber.value,
256
- iconsWidth: iconsWidth.value,
257
- originX: originX.value,
258
- originY: originY.value,
259
- originYLimit: originYLimit.value,
260
- endX: endX.value,
261
- endXLimit: endXLimit.value,
262
- endY: endY.value,
263
- xCellWidth: xCellWidth.value,
264
- yCellHeight: yCellHeight.value,
265
- xScaleList: xScaleList.value,
266
- breatheYCell: breatheYCell.value,
267
- pulseYCell: pulseYCell.value,
268
- temperatureYCell: temperatureYCell.value,
269
- painYCell: painYCell.value,
270
- event: event.value,
271
- itemList: itemList.value,
272
- getRightInfo: getRightInfo.value,
273
- config: props.data.config || {}
274
- });
275
- function computedYCell(type) {
276
- const { yScaleValue } = props.data.left;
277
- const item = yScaleValue.find((v) => v.type === type);
278
- const list = (item == null ? void 0 : item.list) || [];
279
- if (!list.length)
280
- return 0;
281
- return yCellHeight.value / ((list[1] - list[0]) / item.spaceGridNumber);
13
+ const isTemperature = computed(() => props.mode === "temperature");
14
+ const fabricChartRef = ref();
15
+ function redrawPoints() {
16
+ var _a2;
17
+ (_a2 = fabricChartRef.value) == null ? void 0 : _a2.redrawPoints();
282
18
  }
283
- const { cumputedX, cumputedY, getXValue, getYValue } = useCumputedPoint(propItems);
284
- useTop(canvas, propItems);
285
- const { pointTipProps, pointMenuProps, clickMenu, setPopup, getEqualXTypes, isAddPoint, updateData, redrawPoints } = useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, getYValue, props.addRenderItem);
286
- const { drawScaleValue } = useLeft(
287
- canvas,
288
- propItems,
289
- emits,
290
- setPopup,
291
- pointTipProps,
292
- getXValue,
293
- getYValue,
294
- getEqualXTypes,
295
- isAddPoint,
296
- updateData
297
- );
298
- useRight(canvas, propItems, drawScaleValue);
299
- useBottom(canvas, propItems);
300
- useOther(canvas, propItems, cumputedX);
301
- onMounted(() => {
302
- canvas.value = new fabric.Canvas(canvasRef.value, {
303
- width: propItems.canvasWidth,
304
- height: propItems.canvasHeight,
305
- backgroundColor: "#fff",
306
- selection: false,
307
- containerClass: "c-fabric-chart",
308
- fireRightClick: true
309
- });
310
- useEvent(canvasRef.value);
311
- const { select: selectFunc } = useCanvasEvent(canvas, propItems, emits);
312
- select.value = selectFunc;
313
- });
314
- onBeforeUnmount(() => {
315
- canvas.value.clear();
316
- canvas.value = null;
317
- });
19
+ function select(key) {
20
+ var _a2;
21
+ (_a2 = fabricChartRef.value) == null ? void 0 : _a2.select(key);
22
+ }
23
+ const canvas = (_a = fabricChartRef.value) == null ? void 0 : _a.canvas;
318
24
  expose({
319
25
  redrawPoints,
320
26
  select,
321
27
  canvas
322
28
  });
323
29
  return (_ctx, _cache) => {
324
- return openBlock(), createElementBlock(Fragment, null, [
325
- createElementVNode("canvas", {
326
- ref_key: "canvasRef",
327
- ref: canvasRef
328
- }, null, 512),
329
- unref(canvas) ? (openBlock(), createBlock(PopupTip, mergeProps({
330
- key: 0,
331
- propItems
332
- }, unref(pointTipProps)), null, 16, ["propItems"])) : createCommentVNode("v-if", true),
333
- unref(canvas) ? (openBlock(), createBlock(unref(PopupMenu), mergeProps({
334
- key: 1,
335
- propItems
336
- }, unref(pointMenuProps), {
337
- show: unref(pointMenuProps).show,
338
- "onUpdate:show": _cache[0] || (_cache[0] = ($event) => unref(pointMenuProps).show = $event),
339
- onClickMenu: unref(clickMenu)
340
- }), null, 16, ["propItems", "show", "onClickMenu"])) : createCommentVNode("v-if", true)
341
- ], 64);
30
+ return unref(isTemperature) ? (openBlock(), createBlock(TemperatureChart, mergeProps({
31
+ key: 0,
32
+ ref_key: "fabricChartRef",
33
+ ref: fabricChartRef
34
+ }, _ctx.$attrs), null, 16)) : createCommentVNode("v-if", true);
342
35
  };
343
36
  }
344
37
  });
@@ -0,0 +1,215 @@
1
+ import { PropType } from 'vue';
2
+ import { IData, IDate, IPointType, IPropItems } from './interface';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ data: {
5
+ type: PropType<IData>;
6
+ required: true;
7
+ };
8
+ addRenderItem: {
9
+ type: FunctionConstructor;
10
+ };
11
+ }, {
12
+ defaultHeight: number;
13
+ props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
14
+ data: {
15
+ type: PropType<IData>;
16
+ required: true;
17
+ };
18
+ addRenderItem: {
19
+ type: FunctionConstructor;
20
+ };
21
+ }>> & {
22
+ onChange?: ((...args: any[]) => any) | undefined;
23
+ onSelect?: ((...args: any[]) => any) | undefined;
24
+ onAdd?: ((...args: any[]) => any) | undefined;
25
+ }>>;
26
+ emits: (event: "change" | "add" | "select", ...args: any[]) => void;
27
+ select: import("vue").Ref<any>;
28
+ canvasRef: any;
29
+ canvas: import("vue").Ref<any>;
30
+ dateHeight: import("vue").ComputedRef<number>;
31
+ hospitalDaysHeight: import("vue").ComputedRef<number>;
32
+ operationDaysHeight: import("vue").ComputedRef<number>;
33
+ xScalevalueHeight: import("vue").ComputedRef<number>;
34
+ breathingHeight: import("vue").ComputedRef<any>;
35
+ gridXNumber: import("vue").ComputedRef<number>;
36
+ gridYNumber: import("vue").ComputedRef<number>;
37
+ endX: import("vue").ComputedRef<number>;
38
+ endXLimit: import("vue").ComputedRef<number>;
39
+ originX: import("vue").ComputedRef<any>;
40
+ endY: import("vue").ComputedRef<number>;
41
+ originY: import("vue").ComputedRef<number>;
42
+ originYLimit: import("vue").ComputedRef<number>;
43
+ xCellWidth: import("vue").ComputedRef<number>;
44
+ yCellHeight: import("vue").ComputedRef<number>;
45
+ iconsWidth: import("vue").ComputedRef<any>;
46
+ xScaleList: import("vue").ComputedRef<any[]>;
47
+ breatheYCell: import("vue").ComputedRef<number>;
48
+ pulseYCell: import("vue").ComputedRef<number>;
49
+ temperatureYCell: import("vue").ComputedRef<number>;
50
+ painYCell: import("vue").ComputedRef<number>;
51
+ event: import("vue").ComputedRef<any>;
52
+ itemList: import("vue").ComputedRef<any[]>;
53
+ painIndex: import("vue").ComputedRef<number>;
54
+ painHeight: import("vue").ComputedRef<number>;
55
+ painOriginY: import("vue").ComputedRef<{
56
+ originY: number;
57
+ endY: number;
58
+ }>;
59
+ vitalSignsOriginY: import("vue").ComputedRef<{
60
+ originY: number;
61
+ endY: number;
62
+ }>;
63
+ topList: import("vue").ComputedRef<IDate[]>;
64
+ getRightInfo: import("vue").ComputedRef<any>;
65
+ propItems: any;
66
+ computedYCell: (type: IPointType) => number;
67
+ cumputedX: (value: string | number, setAllCenter?: boolean) => any;
68
+ cumputedY: (type: IPointType, scaleValueList: number[], value: string | number) => number;
69
+ getXValue: (pointX: number) => string | undefined;
70
+ getYValue: (type: IPointType, pointY: number) => number;
71
+ setPopup: (point: any) => void;
72
+ getEqualXTypes: (pointX: number) => IPointType[];
73
+ isAddPoint: (x: number) => boolean;
74
+ updateData: (params: any, mode?: string) => void;
75
+ redrawPoints: () => void;
76
+ pointTipProps: {
77
+ show: boolean;
78
+ point: {
79
+ x: number;
80
+ y: number;
81
+ };
82
+ list: string[];
83
+ };
84
+ pointMenuProps: {
85
+ show: boolean;
86
+ point: {
87
+ x: number;
88
+ y: number;
89
+ };
90
+ list: any[];
91
+ target: any;
92
+ };
93
+ clickMenu: ({ item, target }: {
94
+ item: any;
95
+ target: any;
96
+ }) => void;
97
+ drawScaleValue: (yScaleValueList: any[]) => void;
98
+ PopupTip: import("vue").DefineComponent<{
99
+ show: {
100
+ type: BooleanConstructor;
101
+ required: true;
102
+ default: boolean;
103
+ };
104
+ point: {
105
+ type: null;
106
+ required: true;
107
+ };
108
+ list: {
109
+ type: ArrayConstructor;
110
+ required: false;
111
+ default: () => never[];
112
+ };
113
+ propItems: {
114
+ type: null;
115
+ required: true;
116
+ };
117
+ }, {
118
+ props: {
119
+ show: boolean;
120
+ point: import("./interface").ICoordinateValue;
121
+ list: string[];
122
+ propItems: IPropItems;
123
+ };
124
+ pointStyle: import("vue").ComputedRef<{
125
+ top: string;
126
+ bottom: string;
127
+ left: string;
128
+ right: string;
129
+ 'transform-origin': string;
130
+ }>;
131
+ Teleport: {
132
+ new (): {
133
+ $props: import("vue").VNodeProps & import("vue").TeleportProps;
134
+ };
135
+ __isTeleport: true;
136
+ };
137
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
138
+ show: {
139
+ type: BooleanConstructor;
140
+ required: true;
141
+ default: boolean;
142
+ };
143
+ point: {
144
+ type: null;
145
+ required: true;
146
+ };
147
+ list: {
148
+ type: ArrayConstructor;
149
+ required: false;
150
+ default: () => never[];
151
+ };
152
+ propItems: {
153
+ type: null;
154
+ required: true;
155
+ };
156
+ }>>, {
157
+ list: unknown[];
158
+ }>;
159
+ PopupMenu: import("vue").DefineComponent<{
160
+ show: {
161
+ type: BooleanConstructor;
162
+ default: boolean;
163
+ };
164
+ list: {
165
+ type: ArrayConstructor;
166
+ default: () => never[];
167
+ };
168
+ point: {
169
+ type: PropType<import("./interface").ICoordinateValue>;
170
+ };
171
+ propItems: {
172
+ type: PropType<IPropItems>;
173
+ };
174
+ target: {
175
+ type: PropType<any>;
176
+ };
177
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:show" | "clickMenu")[], "clickMenu" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
178
+ show: {
179
+ type: BooleanConstructor;
180
+ default: boolean;
181
+ };
182
+ list: {
183
+ type: ArrayConstructor;
184
+ default: () => never[];
185
+ };
186
+ point: {
187
+ type: PropType<import("./interface").ICoordinateValue>;
188
+ };
189
+ propItems: {
190
+ type: PropType<IPropItems>;
191
+ };
192
+ target: {
193
+ type: PropType<any>;
194
+ };
195
+ }>> & {
196
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
197
+ onClickMenu?: ((...args: any[]) => any) | undefined;
198
+ }, {
199
+ show: boolean;
200
+ list: unknown[];
201
+ }>;
202
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "add" | "select")[], "change" | "add" | "select", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
203
+ data: {
204
+ type: PropType<IData>;
205
+ required: true;
206
+ };
207
+ addRenderItem: {
208
+ type: FunctionConstructor;
209
+ };
210
+ }>> & {
211
+ onChange?: ((...args: any[]) => any) | undefined;
212
+ onSelect?: ((...args: any[]) => any) | undefined;
213
+ onAdd?: ((...args: any[]) => any) | undefined;
214
+ }, {}>;
215
+ export default _default;