cnhis-design-vue 0.1.32 → 0.1.36
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/{docs_202193.zip → docs_2021926.zip} +0 -0
- package/lib/cui.common.js +564 -368
- package/lib/cui.umd.js +564 -368
- package/lib/cui.umd.min.js +6 -6
- package/package.json +1 -1
- package/packages/fabric-chart/src/FabricChart.vue +23 -9
- package/packages/fabric-chart/src/fabric-chart/FabricCanvas.vue +52 -71
- package/packages/fabric-chart/src/fabric-chart/FabricLines.vue +74 -49
- package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +5 -6
- package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +158 -81
- package/packages/fabric-chart/src/mixins/fabricCommon.js +4 -5
- package/packages/fabric-chart/src/mixins/polylineCommon.js +4 -2
package/package.json
CHANGED
|
@@ -23,13 +23,16 @@
|
|
|
23
23
|
|
|
24
24
|
<template v-else>
|
|
25
25
|
<fabric-text-group
|
|
26
|
+
v-if="hasXScalevalue"
|
|
26
27
|
:templateData="templateData"
|
|
28
|
+
:other="templateData.other"
|
|
27
29
|
v-on="$listeners"
|
|
28
30
|
></fabric-text-group>
|
|
29
31
|
<fabric-grid></fabric-grid>
|
|
30
|
-
<fabric-scale-value :templateData="templateData"></fabric-scale-value>
|
|
31
|
-
<fabric-lines ref="lines" :linesObj="templateData.top" v-on="$listeners"></fabric-lines>
|
|
32
|
+
<fabric-scale-value v-if="hasTable" :templateData="templateData"></fabric-scale-value>
|
|
33
|
+
<fabric-lines v-if="hasTopTable" ref="lines" :linesObj="templateData.top" v-on="$listeners"></fabric-lines>
|
|
32
34
|
<fabric-polylines ref="polylines"
|
|
35
|
+
v-if="hasTable"
|
|
33
36
|
:polyline="polylines"
|
|
34
37
|
:other="templateData.left.other || {}"
|
|
35
38
|
@pointOperation="pointOperation"
|
|
@@ -91,16 +94,27 @@ export default create({
|
|
|
91
94
|
computed: {
|
|
92
95
|
polylines() {
|
|
93
96
|
const list = [];
|
|
94
|
-
if (this.templateData?.right
|
|
95
|
-
const position = this.templateData.right
|
|
96
|
-
list.push({ position, ...
|
|
97
|
+
if (this.templateData?.right?.rightYScalevalue?.dataList?.length) {
|
|
98
|
+
const { position, rightYScalevalue } = this.templateData.right;
|
|
99
|
+
list.push({ position, ...rightYScalevalue });
|
|
97
100
|
}
|
|
98
|
-
if (this.templateData?.left
|
|
99
|
-
const position = this.templateData.left
|
|
100
|
-
list.push({ position, ...
|
|
101
|
+
if (this.templateData?.left?.leftYScalevalue?.dataList?.length) {
|
|
102
|
+
const { position, leftYScalevalue } = this.templateData.left;
|
|
103
|
+
list.push({ position, ...leftYScalevalue });
|
|
101
104
|
}
|
|
102
105
|
return list;
|
|
103
|
-
}
|
|
106
|
+
},
|
|
107
|
+
hasTopTable() {
|
|
108
|
+
return this.templateData.top?.list?.length > 0;
|
|
109
|
+
},
|
|
110
|
+
hasTable() {
|
|
111
|
+
const hasLeft = this.templateData.left?.leftYScalevalue?.list?.length > 0;
|
|
112
|
+
const hasRight = this.templateData.right?.rightYScalevalue?.list?.length > 0;
|
|
113
|
+
return this.hasXScalevalue && hasLeft && hasRight;
|
|
114
|
+
},
|
|
115
|
+
hasXScalevalue() {
|
|
116
|
+
return this.templateData.top?.xScalevalue?.list?.length > 0;
|
|
117
|
+
},
|
|
104
118
|
},
|
|
105
119
|
data() {
|
|
106
120
|
return {
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
<script>
|
|
9
9
|
import { fabric } from 'fabric';
|
|
10
10
|
|
|
11
|
+
const topSpaceHeight = 10; // templateData.top.spaceHeight
|
|
12
|
+
const topSpaceGridNumber = 3; // templateData.top.xScalevalue.spaceGridNumber
|
|
13
|
+
const leftSpaceGridNumber = 2; // templateData.left.leftYScalevalue.spaceGridNumber
|
|
14
|
+
const rightSpaceGridNumber = 2; // templateData.right.rightYScalevalue.spaceGridNumber
|
|
11
15
|
export default {
|
|
12
16
|
name: 'FabricCanvas',
|
|
13
17
|
props: {
|
|
@@ -72,14 +76,22 @@ export default {
|
|
|
72
76
|
}
|
|
73
77
|
};
|
|
74
78
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
created() {
|
|
80
|
+
if (!this.templateData.top) {
|
|
81
|
+
try {
|
|
82
|
+
throw new Error('缺少顶部数据对象, 无法生成水平方向刻度');
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.warn(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (!this.templateData.left || !this.templateData.right) {
|
|
88
|
+
try {
|
|
89
|
+
throw new Error('缺少左/右侧数据对象, 无法生成垂直方向刻度');
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.warn(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
83
95
|
computed: {
|
|
84
96
|
canvasWidth() {
|
|
85
97
|
// 画布宽度
|
|
@@ -90,7 +102,7 @@ export default {
|
|
|
90
102
|
return this.templateData.canvasHeight;
|
|
91
103
|
},
|
|
92
104
|
treeTableminCellWidth() {
|
|
93
|
-
return this.templateData.top?.treeTableminCellWidth || 20;
|
|
105
|
+
return this.templateData.top?.treeTableminCellWidth || this.templateData.left?.titleWidth || 20;
|
|
94
106
|
},
|
|
95
107
|
gridXNumber() {
|
|
96
108
|
// 网格水平方向总数 如果设置了默认值就直接取用
|
|
@@ -98,58 +110,24 @@ export default {
|
|
|
98
110
|
return this.templateData.table.mainXCell * this.templateData.table.subXCell;
|
|
99
111
|
}
|
|
100
112
|
// 如果没设置 就从顶部列表内自己计算一下 list遍历后将每一项完全展开后的数组长度存入topListLength取出最大值即可
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// return Math.max(...topLenList);
|
|
104
|
-
const spaceGridNumber = this.templateData.top.xScalevalue.spaceGridNumber || 3;
|
|
105
|
-
return this.templateData.top.xScalevalue.list.length * spaceGridNumber;
|
|
113
|
+
const spaceGridNumber = this.templateData.top?.xScalevalue?.spaceGridNumber || topSpaceGridNumber;
|
|
114
|
+
return (this.templateData.top?.xScalevalue?.list?.length || 1) * spaceGridNumber;
|
|
106
115
|
},
|
|
107
116
|
gridYNumber() {
|
|
108
117
|
// 网格垂直方向总数
|
|
109
|
-
// if (this.templateData.table.mainYCell && this.templateData.table.subYCell) {
|
|
110
118
|
return this.templateData.table.mainYCell * this.templateData.table.subYCell;
|
|
111
|
-
// }
|
|
112
|
-
// const leftLenList = [];
|
|
113
|
-
// this.templateData.left.list.forEach(item => {
|
|
114
|
-
// if (isObject(item)) {
|
|
115
|
-
// // 当前列内没有上下区分 左右区分针对item.list遍历即可 占用列数 => item.list.length 示例: 温度: 摄氏度 华氏度
|
|
116
|
-
// leftLenList.push(item.list.length);
|
|
117
|
-
// } else if (Array.isArray(item)) {
|
|
118
|
-
// // 当前列内有上下之分 列数暂时默认 +1 ----- 若有更复杂情况(上下列中含有左右列的情况)可以改为递归形式
|
|
119
|
-
// let len = 0;
|
|
120
|
-
// item.forEach(v => (len += v.list.length));
|
|
121
|
-
// leftLenList.push(len);
|
|
122
|
-
// }
|
|
123
|
-
// });
|
|
124
|
-
// return Math.max(...leftLenList);
|
|
125
119
|
},
|
|
126
120
|
originX() {
|
|
127
121
|
// 网格左侧起始坐标 X, 也是整个区域左侧列表坐标最大坐标值 取出初始化后网格区域水平方向多出的余数 添加到左栏宽度上
|
|
128
|
-
|
|
129
|
-
// this.templateData.left.list.forEach(item => {
|
|
130
|
-
// if (isObject(item)) { // 当前列内没有上下区分 左右区分针对item.list遍历即可 占用列数 => item.list.length 示例: 温度: 摄氏度 华氏度
|
|
131
|
-
// columns += item.list.length;
|
|
132
|
-
// } else if (Array.isArray(item)) { // 当前列内有上下之分 列数暂时默认 +1 ----- 若有更复杂情况(上下列中含有左右列的情况)可以改为递归形式
|
|
133
|
-
// columns += 1;
|
|
134
|
-
// }
|
|
135
|
-
// })
|
|
136
|
-
// const originX = this.templateData.left.width * columns;
|
|
137
|
-
// const residue = (this.endX - originX) % this.gridXNumber;
|
|
138
|
-
const originX = this.templateData.top.treeTableWidth;
|
|
122
|
+
const originX = this.templateData.top?.treeTableWidth || this.templateData.left?.width || 200;
|
|
139
123
|
const residue = (this.endX - originX) % this.gridXNumber;
|
|
140
124
|
return originX + residue;
|
|
141
125
|
},
|
|
142
126
|
originY() {
|
|
143
127
|
// 顶部列表高度 网格不需要的高度放到顶部,因为底部不一定存在列表
|
|
144
|
-
// const height = this.templateData.top.height ? this.templateData.top.height : 30;
|
|
145
|
-
// const topheight = this.templateData.top.list.length * height;
|
|
146
|
-
// // const residue = (this.canvasHeight - topheight - this.endY) % this.gridYNumber; // 此处算法不对,会导致后面高度值计算出小数,造成表格重影
|
|
147
|
-
// const residue = (this.endY - topheight) % this.gridYNumber;
|
|
148
|
-
// return topheight + residue;
|
|
149
|
-
|
|
150
128
|
const topHeight = this.endYTop;
|
|
151
129
|
const residue = (this.endY - topHeight) % this.gridYNumber;
|
|
152
|
-
return topHeight + residue + this.templateData.top
|
|
130
|
+
return topHeight + residue + (this.templateData.top?.spaceHeight || topSpaceHeight);
|
|
153
131
|
},
|
|
154
132
|
endX() {
|
|
155
133
|
// 网格区域水平方向最大坐标值, 也是整个画布右侧列表坐标起始值,网格右下角x轴坐标值
|
|
@@ -174,18 +152,18 @@ export default {
|
|
|
174
152
|
// 头部表格底部空白位置的高,用于显示x轴时间点
|
|
175
153
|
const topHeight = this.endYTop;
|
|
176
154
|
const residue = (this.endY - topHeight) % this.gridYNumber;
|
|
177
|
-
return residue + this.templateData.top
|
|
155
|
+
return residue + (this.templateData.top?.spaceHeight || topSpaceHeight);
|
|
178
156
|
},
|
|
179
157
|
yCellHeightTop() {
|
|
180
158
|
// 头部表格垂直方向网格高度
|
|
181
|
-
return this.templateData.top
|
|
159
|
+
return this.templateData.top?.treeTableminCellHeight || 20;
|
|
182
160
|
},
|
|
183
161
|
endYTop() {
|
|
184
162
|
return this.gridYnumberTop * this.yCellHeightTop;
|
|
185
163
|
},
|
|
186
164
|
// 转换为时间戳的x轴时间列表
|
|
187
165
|
xScaleList() {
|
|
188
|
-
const list = this.templateData.top
|
|
166
|
+
const list = this.templateData.top?.xScalevalue?.list || [];
|
|
189
167
|
return list.map(item => {
|
|
190
168
|
return new Date(item).getTime();
|
|
191
169
|
})
|
|
@@ -217,13 +195,13 @@ export default {
|
|
|
217
195
|
// },
|
|
218
196
|
// y轴每mmHg的脉搏/血压的高度值
|
|
219
197
|
yScaleCellLeft() {
|
|
220
|
-
const list = this.templateData.left
|
|
221
|
-
return this.yCellHeight / ((parseInt(list[1]) - parseInt(list[0])) / this.templateData.left
|
|
198
|
+
const list = this.templateData.left?.leftYScalevalue?.list || [];
|
|
199
|
+
return list?.length ? this.yCellHeight / ((parseInt(list[1]) - parseInt(list[0])) / (this.templateData.left?.leftYScalevalue?.spaceGridNumber || leftSpaceGridNumber)) : 10;
|
|
222
200
|
},
|
|
223
201
|
// y轴每摄氏度的高度值
|
|
224
202
|
yScaleCellRight() {
|
|
225
|
-
const list = this.templateData.right
|
|
226
|
-
return this.yCellHeight / ((parseInt(list[1]) - parseInt(list[0])) / this.templateData.right
|
|
203
|
+
const list = this.templateData.right?.rightYScalevalue?.list || [];
|
|
204
|
+
return list?.length ? this.yCellHeight / ((parseInt(list[1]) - parseInt(list[0])) / (this.templateData.right?.rightYScalevalue?.spaceGridNumber || rightSpaceGridNumber)) : 10;
|
|
227
205
|
},
|
|
228
206
|
eventStyle() {
|
|
229
207
|
return this.templateData.table?.eventStyle || {selectable: true,evented: true};
|
|
@@ -241,13 +219,15 @@ export default {
|
|
|
241
219
|
...this.canvasAttr
|
|
242
220
|
});
|
|
243
221
|
|
|
244
|
-
|
|
245
|
-
|
|
222
|
+
if (this.templateData.top?.list?.length) {
|
|
223
|
+
this.getGridYnumberTop(this.templateData.top.list);
|
|
224
|
+
this.treeList = this.setTreeStyle(this.templateData.top.list);
|
|
225
|
+
}
|
|
246
226
|
},
|
|
247
227
|
getGridYnumberTop(list) {
|
|
248
228
|
// 头部表格垂直方向网格总数
|
|
249
229
|
for (let i = 0; i < list.length; i++) {
|
|
250
|
-
if (list[i].children
|
|
230
|
+
if (list[i].children?.length) {
|
|
251
231
|
this.getGridYnumberTop(list[i].children);
|
|
252
232
|
} else {
|
|
253
233
|
this.gridYnumberTop++;
|
|
@@ -262,26 +242,27 @@ export default {
|
|
|
262
242
|
*/
|
|
263
243
|
|
|
264
244
|
setTreeStyle(list, levelCol = 0) {
|
|
265
|
-
|
|
245
|
+
const arr = [];
|
|
246
|
+
const { treeTableminCellWidth, treeTableminCellHeight } = this.templateData.top;
|
|
266
247
|
for (let i = 0; i < list.length; i++) {
|
|
267
|
-
|
|
268
|
-
obj
|
|
269
|
-
|
|
270
|
-
|
|
248
|
+
const obj = {};
|
|
249
|
+
Object.assign(obj, {
|
|
250
|
+
title: list[i].title || '',
|
|
251
|
+
left: levelCol * treeTableminCellWidth,
|
|
252
|
+
top: this.levelRow * treeTableminCellHeight
|
|
253
|
+
});
|
|
271
254
|
this.levelRow++;
|
|
272
|
-
if (list[i].children
|
|
273
|
-
obj.title = obj.title.split('').join('\n'); // 如果有子级则文字竖形排列
|
|
255
|
+
if (list[i].children?.length) {
|
|
274
256
|
this.levelRow--;
|
|
275
|
-
obj.
|
|
257
|
+
obj.title = obj.title.split('').join('\n'); // 如果有子级则文字竖形排列
|
|
258
|
+
obj.width = treeTableminCellWidth;
|
|
276
259
|
obj.children = this.setTreeStyle(list[i].children, levelCol + 1);
|
|
277
260
|
obj.subSize = this.getChildrenSize(list[i].children);
|
|
278
|
-
obj.height = obj.subSize *
|
|
261
|
+
obj.height = obj.subSize * treeTableminCellHeight;
|
|
279
262
|
} else {
|
|
280
263
|
obj.width = this.originX - obj.left;
|
|
281
|
-
obj.height =
|
|
282
|
-
obj.
|
|
283
|
-
obj.lineList = [...list[i].lineList];
|
|
284
|
-
obj.type = list[i].type;
|
|
264
|
+
obj.height = treeTableminCellHeight;
|
|
265
|
+
obj.lineList = JSON.parse(JSON.stringify(list[i].lineList));
|
|
285
266
|
}
|
|
286
267
|
arr.push(obj);
|
|
287
268
|
}
|
|
@@ -290,7 +271,7 @@ export default {
|
|
|
290
271
|
getChildrenSize(list) {
|
|
291
272
|
let subSize = 0;
|
|
292
273
|
for (let i = 0; i < list.length; i++) {
|
|
293
|
-
if (list[i].children
|
|
274
|
+
if (list[i].children?.length) {
|
|
294
275
|
subSize += this.getChildrenSize(list[i].children);
|
|
295
276
|
} else {
|
|
296
277
|
subSize += 1;
|
|
@@ -13,8 +13,8 @@ import DropPopup from '../components/DropPopup';
|
|
|
13
13
|
import polylineCommon from '../mixins/polylineCommon';
|
|
14
14
|
|
|
15
15
|
const rightClickNode = [
|
|
16
|
-
{ name: '
|
|
17
|
-
{ name: '
|
|
16
|
+
{ name: '修改', type: 'edit' },
|
|
17
|
+
{ name: '删除', type: 'delete' }
|
|
18
18
|
];
|
|
19
19
|
export default {
|
|
20
20
|
name: 'fabric-lines',
|
|
@@ -65,9 +65,6 @@ export default {
|
|
|
65
65
|
},
|
|
66
66
|
|
|
67
67
|
methods: {
|
|
68
|
-
getContainer() {
|
|
69
|
-
return this.$el;
|
|
70
|
-
},
|
|
71
68
|
init() {
|
|
72
69
|
this.getLineList(this.linesObj.list);
|
|
73
70
|
this.createLine();
|
|
@@ -113,7 +110,7 @@ export default {
|
|
|
113
110
|
this.$nextTick(() => {
|
|
114
111
|
if (id && id.includes('_lineGroup_')) {
|
|
115
112
|
this._currentPoint = target || '';
|
|
116
|
-
this.rightClickNode = Object.freeze(rightClickNode.slice(
|
|
113
|
+
this.rightClickNode = Object.freeze(rightClickNode.slice());
|
|
117
114
|
this.isRightVisible = true;
|
|
118
115
|
}
|
|
119
116
|
});
|
|
@@ -124,7 +121,8 @@ export default {
|
|
|
124
121
|
const line = this._currentPoint;
|
|
125
122
|
this._currentPoint = '';
|
|
126
123
|
const { lineObj } = this.updateData(line, true);
|
|
127
|
-
|
|
124
|
+
// editLine:编辑 deleteLine:删除
|
|
125
|
+
this.$emit(`${type}Line`, lineObj);
|
|
128
126
|
},
|
|
129
127
|
// 递归返回一维数据
|
|
130
128
|
getLineList(list) {
|
|
@@ -143,14 +141,17 @@ export default {
|
|
|
143
141
|
});
|
|
144
142
|
},
|
|
145
143
|
drawLineData(line, i) {
|
|
144
|
+
const lineList = line.lineList || [];
|
|
146
145
|
const { originX, endX, xScaleList, yCellHeightTop } = this.propItems;
|
|
147
146
|
const spaceHeight = Math.round(yCellHeightTop / 6);
|
|
148
147
|
const minMinute = Math.min(...xScaleList);
|
|
149
148
|
const maxMinute = Math.max(...xScaleList);
|
|
150
|
-
|
|
149
|
+
const lineItemList = [];
|
|
151
150
|
const y1 = i * yCellHeightTop;
|
|
152
151
|
const y2 = yCellHeightTop * (i + 1);
|
|
153
|
-
|
|
152
|
+
let textArr = []; // 用于存放多个线段的文字内容,显示格式为:第一段线的文字—第二段线的文字
|
|
153
|
+
const textList = [];
|
|
154
|
+
lineList.forEach((item, j) => {
|
|
154
155
|
if ( !item[0] || isObject(item[0])) return;
|
|
155
156
|
const startMinute = new Date(item[0]).getTime();
|
|
156
157
|
const endMinute = item[1] ? new Date(item[1]).getTime() : '';
|
|
@@ -158,6 +159,7 @@ export default {
|
|
|
158
159
|
let x2 = this.cumputedX(item[1]);
|
|
159
160
|
// 数字文字
|
|
160
161
|
const textObj = item[3] || {};
|
|
162
|
+
const textContent = textObj.content || '';
|
|
161
163
|
|
|
162
164
|
// 左边手柄竖线
|
|
163
165
|
let leftLine;
|
|
@@ -220,17 +222,22 @@ export default {
|
|
|
220
222
|
|
|
221
223
|
// 文字内容
|
|
222
224
|
const textTop = x2 ? (y1 + y2) / 2 : y1 + yCellHeightTop / 2;
|
|
223
|
-
|
|
225
|
+
let textLimitRight;
|
|
226
|
+
let text =
|
|
224
227
|
((endMinute === '' && leftLine) || (item[1] && (!(x1 === originX && x2 === originX) && !(x1 === endX && x2 === endX))))
|
|
225
|
-
? this.drawLineText(
|
|
228
|
+
? this.drawLineText(textArr.concat([textContent]), textTop, i, j, centerLine, x1, x2)
|
|
226
229
|
: null;
|
|
227
|
-
//
|
|
230
|
+
// 文字内容居右侧竖线且超出当前线段右边界则移除
|
|
228
231
|
if (text) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
} else {
|
|
232
|
+
textLimitRight = lineList[j + 1]?.[0] && this.cumputedX(lineList[j + 1][0]) <= endX ? this.cumputedX(lineList[j + 1][0]) : endX;
|
|
233
|
+
if (text.originX === 'left' && text.left + text.width + 2 >= textLimitRight) {
|
|
234
|
+
textLimitRight !== endX && textArr.push(textContent);
|
|
233
235
|
this.canvas.remove(text);
|
|
236
|
+
text = null;
|
|
237
|
+
} else {
|
|
238
|
+
textArr = [];
|
|
239
|
+
this.hoverEvent(text, {textObj, startTime: item[0], endTime: item[1]});
|
|
240
|
+
textList.push(text);
|
|
234
241
|
}
|
|
235
242
|
}
|
|
236
243
|
|
|
@@ -238,8 +245,8 @@ export default {
|
|
|
238
245
|
let leftLimit = {};
|
|
239
246
|
leftLimit.x2 = x2 ? x2 : endX;
|
|
240
247
|
leftLimit.x1 = originX;
|
|
241
|
-
if (
|
|
242
|
-
const [preItem0, preItem1] =
|
|
248
|
+
if (lineList[j - 1]) {
|
|
249
|
+
const [preItem0, preItem1] = lineList[j - 1];
|
|
243
250
|
if (preItem1) {
|
|
244
251
|
const preEndMinute = new Date(preItem1).getTime();
|
|
245
252
|
if (preEndMinute >= minMinute && preEndMinute < maxMinute) leftLimit.x1 = this.cumputedX(preItem1);
|
|
@@ -251,25 +258,29 @@ export default {
|
|
|
251
258
|
let rightLimt = {};
|
|
252
259
|
rightLimt.x1 = x2 ? x1 : originX;
|
|
253
260
|
rightLimt.x2 = endX;
|
|
254
|
-
if (
|
|
255
|
-
const [preItem0] =
|
|
261
|
+
if (lineList[j + 1]) {
|
|
262
|
+
const [preItem0] = lineList[j + 1];
|
|
256
263
|
if (preItem0) {
|
|
257
264
|
const preStartMinute = new Date(preItem0).getTime();
|
|
258
265
|
if (preStartMinute > minMinute && preStartMinute <= maxMinute) rightLimt.x2 = this.cumputedX(preItem0);
|
|
259
266
|
}
|
|
260
267
|
}
|
|
261
268
|
|
|
262
|
-
this.lineEvent({line: leftLine, line1: centerLine, text, textObj, limitX: leftLimit, startTime: item[0], endTime: item[1]});
|
|
263
|
-
this.lineEvent({line: rightLine, line2: centerLine, text, textObj, limitX: rightLimt, startTime: item[0], endTime: item[1]});
|
|
269
|
+
this.lineEvent({line: leftLine, line1: centerLine, text, textObj, limitX: leftLimit, startTime: item[0], endTime: item[1], preText: textList[text ? textList.length - 2 : textList.length - 1] || null, textLimitRight});
|
|
270
|
+
this.lineEvent({line: rightLine, line2: centerLine, text, textObj, limitX: rightLimt, startTime: item[0], endTime: item[1], preText: null, textLimitRight: rightLimt.x2});
|
|
264
271
|
});
|
|
265
|
-
this.canvas.add(...lineItemList);
|
|
272
|
+
this.canvas.add(...lineItemList, ...textList);
|
|
266
273
|
this.canvas.requestRenderAll();
|
|
267
274
|
},
|
|
268
|
-
drawLineText(
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
const
|
|
272
|
-
const
|
|
275
|
+
drawLineText(textArr, top, i, j, centerLine, x1, x2) {
|
|
276
|
+
// const value = textArr.map(v => {
|
|
277
|
+
// const channel = v.channel ? `(${v.channel})` : '';
|
|
278
|
+
// const consistence = v.consistence ? `(${v.consistence})` : '';
|
|
279
|
+
// const total = v.total ? `(${v.total})` : '';
|
|
280
|
+
// return `${v.currentSpeed || ''}${channel}${consistence}${total}`
|
|
281
|
+
// }).join('—');
|
|
282
|
+
const value = textArr.filter(v => v !== '').join('—');
|
|
283
|
+
|
|
273
284
|
if (value === '') return null;
|
|
274
285
|
const text = new this.fabric.Text(value, {
|
|
275
286
|
top,
|
|
@@ -357,13 +368,15 @@ export default {
|
|
|
357
368
|
});
|
|
358
369
|
},
|
|
359
370
|
lineEvent(attr) {
|
|
360
|
-
const {line, line1, line2, text, textObj, limitX, startTime, endTime} = attr;
|
|
371
|
+
const {line, line1, line2, text, textObj, limitX, startTime, endTime, preText, textLimitRight} = attr;
|
|
361
372
|
if (line) {
|
|
362
373
|
line.hasControls = line.hasBorders = false;
|
|
363
374
|
line1 && (line.line1 = line1);
|
|
364
375
|
line2 && (line.line2 = line2);
|
|
365
376
|
text && (line.text = text);
|
|
366
377
|
line.limitX = limitX;
|
|
378
|
+
preText && (line.preText = preText);
|
|
379
|
+
textLimitRight && (line.textLimitRight = textLimitRight);
|
|
367
380
|
this.hoverEvent(line, {textObj, startTime, endTime});
|
|
368
381
|
// 移动中 实时更新相关联的线的坐标
|
|
369
382
|
line.on('moving', () => {
|
|
@@ -460,15 +473,13 @@ export default {
|
|
|
460
473
|
return line;
|
|
461
474
|
},
|
|
462
475
|
lineMoveLimit(line) {
|
|
463
|
-
line.setCoords();
|
|
464
|
-
|
|
465
|
-
if (objBoundingBox.left < line.limitX.x1) {
|
|
476
|
+
line.setCoords(); // 需调用setCoords()才能重新计算控制位置(改变Object状态)
|
|
477
|
+
if (line.left < line.limitX.x1) {
|
|
466
478
|
line.set('left', line.limitX.x1);
|
|
467
479
|
}
|
|
468
|
-
if (
|
|
480
|
+
if (line.left > line.limitX.x2) {
|
|
469
481
|
line.set('left', line.limitX.x2);
|
|
470
482
|
}
|
|
471
|
-
line.setCoords();
|
|
472
483
|
},
|
|
473
484
|
lineMoveUpdateLine(line) {
|
|
474
485
|
if (line.line1) {
|
|
@@ -482,22 +493,36 @@ export default {
|
|
|
482
493
|
},
|
|
483
494
|
textUpdatePositionX(line) {
|
|
484
495
|
const text = line.text || null;
|
|
485
|
-
if (
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
496
|
+
if (text) {
|
|
497
|
+
// 如果line2存在说明当前拖动的是右边手柄,line1存在则是左边手柄,都不存在说明不存在中间线
|
|
498
|
+
const centerLine = line.line1 || line.line2 || null;
|
|
499
|
+
const left = line.left;
|
|
500
|
+
const limitWidth = text.width + 2;
|
|
501
|
+
let originX = text.originX;
|
|
502
|
+
let v;
|
|
503
|
+
if (centerLine?.x2 - centerLine?.x1 > limitWidth) {
|
|
504
|
+
v = left + (centerLine.width / 2) * (line.line2 ? -1 : 1);
|
|
505
|
+
originX = 'center';
|
|
506
|
+
} else {
|
|
507
|
+
v = this.textMarginLeft + (centerLine ? centerLine.x2 : left);
|
|
508
|
+
originX = 'left';
|
|
509
|
+
// 移动到最右边界时候文字超出当前线段可拖动的右边界的情况
|
|
510
|
+
if (line.textLimitRight && v + limitWidth > line.textLimitRight) {
|
|
511
|
+
v = this.propItems.endX + 100; // 此值随便设置,只要达到隐藏效果即可
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
text.setCoords();
|
|
515
|
+
text.set({ left: v, originX });
|
|
516
|
+
}
|
|
517
|
+
// 拖动左侧竖线时需要更改上一线段文字的位置,以防止文字被遮挡
|
|
518
|
+
const preText = line.preText || null;
|
|
519
|
+
if (!preText) return;
|
|
520
|
+
const limitWidth = preText.width + 2;
|
|
521
|
+
if (preText.originX === 'left' && preText.left + limitWidth > line.left) {
|
|
522
|
+
const v = this.propItems.endX + 100; // 此值随便设置,只要达到隐藏效果即可
|
|
523
|
+
preText.setCoords();
|
|
524
|
+
preText.set({ left: v });
|
|
498
525
|
}
|
|
499
|
-
text.setCoords();
|
|
500
|
-
text.set({ left: v, originX });
|
|
501
526
|
},
|
|
502
527
|
repaintLine() {
|
|
503
528
|
if (this.lines.length) {
|
|
@@ -85,9 +85,6 @@ export default {
|
|
|
85
85
|
},
|
|
86
86
|
|
|
87
87
|
methods: {
|
|
88
|
-
getContainer() {
|
|
89
|
-
return this.$el;
|
|
90
|
-
},
|
|
91
88
|
createEvent() {
|
|
92
89
|
this.canvas.on('mouse:up', event => {
|
|
93
90
|
if (event.button === 3) {
|
|
@@ -224,9 +221,10 @@ export default {
|
|
|
224
221
|
const top = baseTop - i * lableLineHeight;
|
|
225
222
|
const left = lableMargin[0] + treeTableminCellWidth;
|
|
226
223
|
const pointId = `${v.polylineTypeId}_${v.polylineIndex}_-1_polylinePoint_'${new Date().getTime()}_isTitle`;
|
|
224
|
+
const { fill: fillColor = '#000', stroke } = v.pointAttr;
|
|
227
225
|
let text = new this.fabric.Text(String(v.title), {
|
|
228
226
|
fontSize: style.fontSize,
|
|
229
|
-
fill:
|
|
227
|
+
fill: fillColor && stroke ? stroke : fillColor,
|
|
230
228
|
left,
|
|
231
229
|
top,
|
|
232
230
|
originY: 'center',
|
|
@@ -682,11 +680,12 @@ export default {
|
|
|
682
680
|
if (id && id.includes('_polylinePoint_')) {
|
|
683
681
|
this._currentPointId = id;
|
|
684
682
|
this.rightClickNode = Object.freeze(rightClickNode.slice());
|
|
685
|
-
|
|
683
|
+
this.isRightVisible = true;
|
|
684
|
+
} else if (!id) {
|
|
686
685
|
this._currentPointId = '';
|
|
687
686
|
this.rightClickNode = Object.freeze(rightClickNode.slice(0, 1));
|
|
687
|
+
this.isRightVisible = true;
|
|
688
688
|
}
|
|
689
|
-
this.isRightVisible = true;
|
|
690
689
|
});
|
|
691
690
|
},
|
|
692
691
|
// 关闭右键菜单,打开添加节点弹窗表单
|