cnhis-design-vue 0.1.40 → 0.1.42
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/big-table/index.js +74 -67
- package/es/big-table/style.css +1 -1
- package/es/button/index.js +2 -2
- package/es/color-picker/index.js +1 -1
- package/es/color-picker/style.css +1 -1
- package/es/fabric-chart/index.js +4 -4
- package/es/fabric-chart/style.css +1 -1
- package/es/index/index.js +42 -42
- package/es/index/style.css +2 -2
- package/es/modal/index.js +4 -4
- package/es/select/index.js +7 -7
- package/es/select/style.css +1 -1
- package/es/table-filter/index.js +22 -22
- package/es/table-filter/style.css +1 -1
- package/lib/cui.common.js +4223 -1783
- package/lib/cui.umd.js +4223 -1783
- package/lib/cui.umd.min.js +52 -52
- package/package.json +1 -1
- package/packages/big-table/index.js +6 -0
- package/packages/big-table/src/BigTable.vue +11 -94
- package/packages/big-table/src/Fieldset.vue +4 -4
- package/packages/big-table/src/utils/bigTableProps.js +82 -0
- package/packages/color-picker/src/color-picker.vue +14 -2
- package/packages/color-picker/src/style.less +1 -1
- package/packages/fabric-chart/src/FabricChart.vue +0 -1
- package/packages/fabric-chart/src/const/defaultVaule.js +20 -1
- package/packages/fabric-chart/src/fabric-chart/FabricCanvas.vue +39 -43
- package/packages/fabric-chart/src/fabric-chart/FabricLines.vue +46 -37
- package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +169 -109
- package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +111 -51
- package/packages/fabric-chart/src/fabric-chart2/FabricCenter.vue +8 -12
- package/packages/fabric-chart/src/mixins/{polylineCommon.js → eventCommon.js} +13 -3
- package/packages/index.js +6 -7
- package/packages/modal/index.js +6 -2
- package/packages/modal/src/Modal.js +7 -0
- package/packages/select/src/TableSelect/index.vue +138 -75
- package/packages/table-filter/src/base-search-com/BaseSearch.vue +30 -22
- package/packages/table-filter/src/classification/Classification-com.vue +6 -2
- package/packages/table-filter/src/components/multi-select/multi-select.vue +1 -1
- package/packages/table-filter/src/components/search-condition/SearchCondition.vue +2 -0
- package/packages/table-filter/src/quick-search/QuickSearch.vue +25 -22
- package/src/style/style.less +2 -2
- package/src/utils/clickoutside.js +14 -13
- package/docs_20211021.zip +0 -0
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<script>
|
|
10
10
|
import FabricCommon from '../mixins/fabricCommon';
|
|
11
11
|
import draw from '../mixins/draw';
|
|
12
|
-
import
|
|
12
|
+
import eventCommon from '../mixins/eventCommon';
|
|
13
13
|
import MouseRightClick from '../components/MouseRightClick';
|
|
14
14
|
import DropPopup from '../components/DropPopup';
|
|
15
15
|
import defaultVaule from '../const/defaultVaule';
|
|
@@ -20,7 +20,7 @@ const rightClickNode = [
|
|
|
20
20
|
];
|
|
21
21
|
export default {
|
|
22
22
|
name: 'fabric-polylines',
|
|
23
|
-
mixins: [FabricCommon, draw,
|
|
23
|
+
mixins: [FabricCommon, draw, eventCommon],
|
|
24
24
|
inject: ['$propItems'],
|
|
25
25
|
props: {
|
|
26
26
|
polyline: {
|
|
@@ -54,9 +54,14 @@ export default {
|
|
|
54
54
|
activeEvent: null, // 当前可右键活动的对象
|
|
55
55
|
addPointList: [], // 快速新增的节点list
|
|
56
56
|
isSelectArea: false, // 是否正在选区
|
|
57
|
-
selectArea: null
|
|
57
|
+
selectArea: null // 选区矩形对象
|
|
58
58
|
};
|
|
59
59
|
},
|
|
60
|
+
computed: {
|
|
61
|
+
eventStyle() {
|
|
62
|
+
return this.propItems.eventStyle;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
60
65
|
|
|
61
66
|
watch: {
|
|
62
67
|
// polyline() {
|
|
@@ -80,7 +85,7 @@ export default {
|
|
|
80
85
|
this.createPolyline(polylineType, polylineTypeId);
|
|
81
86
|
});
|
|
82
87
|
|
|
83
|
-
this.createEvent();
|
|
88
|
+
this.eventStyle.evented && this.createEvent();
|
|
84
89
|
});
|
|
85
90
|
},
|
|
86
91
|
|
|
@@ -167,12 +172,18 @@ export default {
|
|
|
167
172
|
this.polylineList.forEach((item, index) => {
|
|
168
173
|
item.dataList.forEach((v, i) => {
|
|
169
174
|
// 配置是否可拖动标题图标批量增加-
|
|
170
|
-
const isAdd = v.list.length
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
const isAdd = v.list.length
|
|
176
|
+
? !v.list.some(k => {
|
|
177
|
+
return k.time && new Date(k.time).getTime() >= minTime && new Date(k.time).getTime() < xScaleCellList[1].time;
|
|
178
|
+
})
|
|
179
|
+
: true;
|
|
173
180
|
let rightLimit = endX;
|
|
174
181
|
const point = v.list.find(k => k.time && new Date(k.time).getTime() >= xScaleCellList[1].time && new Date(k.time).getTime() <= maxTime);
|
|
175
|
-
const limitObj =
|
|
182
|
+
const limitObj =
|
|
183
|
+
point &&
|
|
184
|
+
JSON.parse(JSON.stringify(this.propItems.xScaleCellList))
|
|
185
|
+
.reverse()
|
|
186
|
+
.find(k => new Date(point.time).getTime() > k.time);
|
|
176
187
|
limitObj && (rightLimit = limitObj.x);
|
|
177
188
|
point && !limitObj && new Date(point.time).getTime() === maxTime && (rightLimit = xScaleCellList[xScaleCellList.length - 1].x);
|
|
178
189
|
leftTitleList.push({
|
|
@@ -185,37 +196,41 @@ export default {
|
|
|
185
196
|
isAdd,
|
|
186
197
|
rightLimit
|
|
187
198
|
});
|
|
188
|
-
})
|
|
189
|
-
})
|
|
199
|
+
});
|
|
200
|
+
});
|
|
190
201
|
|
|
191
202
|
// 配置左侧title图标(但不是折线项目)
|
|
192
203
|
if (this.other?.list && Array.isArray(this.other.list)) {
|
|
193
204
|
if (this.other.position && this.other.position === 'top') {
|
|
194
|
-
leftTitleList.push(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
leftTitleList.push(
|
|
206
|
+
...this.other.list.map(v => {
|
|
207
|
+
return {
|
|
208
|
+
title: v.name,
|
|
209
|
+
type: v.type,
|
|
210
|
+
pointAttr: v,
|
|
211
|
+
isAdd: false,
|
|
212
|
+
polylineTypeId: -1,
|
|
213
|
+
polylineIndex: -1
|
|
214
|
+
};
|
|
215
|
+
})
|
|
216
|
+
);
|
|
204
217
|
} else {
|
|
205
|
-
leftTitleList.unshift(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
leftTitleList.unshift(
|
|
219
|
+
...this.other.list.map(v => {
|
|
220
|
+
return {
|
|
221
|
+
title: v.name,
|
|
222
|
+
type: v.type,
|
|
223
|
+
pointAttr: v,
|
|
224
|
+
isAdd: false,
|
|
225
|
+
polylineTypeId: -1,
|
|
226
|
+
polylineIndex: -1
|
|
227
|
+
};
|
|
228
|
+
})
|
|
229
|
+
);
|
|
215
230
|
}
|
|
216
231
|
}
|
|
217
232
|
|
|
218
|
-
const eventStyle = {selectable: false, evented: false};
|
|
233
|
+
const eventStyle = { selectable: false, evented: false };
|
|
219
234
|
leftTitleList.forEach(async (v, i) => {
|
|
220
235
|
const baseTop = canvasHeight - lableMargin[1];
|
|
221
236
|
const top = baseTop - i * lableLineHeight;
|
|
@@ -229,10 +244,10 @@ export default {
|
|
|
229
244
|
top,
|
|
230
245
|
originY: 'center',
|
|
231
246
|
...defaultVaule.style,
|
|
232
|
-
id: pointId
|
|
247
|
+
id: pointId
|
|
233
248
|
});
|
|
234
|
-
const isOriginXCenter = v.type === 'arrow' || v.type === '+' || v.type === 'shjs' || v.type === 'shks'|| v.type === 'cg';
|
|
235
|
-
|
|
249
|
+
const isOriginXCenter = v.type === 'arrow' || v.type === '+' || v.type === 'shjs' || v.type === 'shks' || v.type === 'cg';
|
|
250
|
+
|
|
236
251
|
const iconLeft = isOriginXCenter ? text.width + text.left + 10 : text.width + text.left + 5;
|
|
237
252
|
const option = {
|
|
238
253
|
left: iconLeft,
|
|
@@ -245,7 +260,7 @@ export default {
|
|
|
245
260
|
id: pointId,
|
|
246
261
|
polylineTypeId: v.polylineTypeId,
|
|
247
262
|
polylineIndex: v.polylineIndex,
|
|
248
|
-
...(v.isAdd ? {} : eventStyle),
|
|
263
|
+
...(v.isAdd && this.eventStyle.evented ? {} : eventStyle),
|
|
249
264
|
rightLimit: v.rightLimit || ''
|
|
250
265
|
};
|
|
251
266
|
let ele;
|
|
@@ -254,7 +269,7 @@ export default {
|
|
|
254
269
|
}
|
|
255
270
|
const icon = await this.createPoint(v.type, {
|
|
256
271
|
ele: ele || '',
|
|
257
|
-
...option
|
|
272
|
+
...option
|
|
258
273
|
});
|
|
259
274
|
icon.hasControls = icon.hasBorders = false;
|
|
260
275
|
let originTop = top;
|
|
@@ -264,15 +279,15 @@ export default {
|
|
|
264
279
|
icon.clone(clonedObj => {
|
|
265
280
|
cloneIconId = '_polylinePoint_temp_' + new Date().getTime();
|
|
266
281
|
clonedObj.set({
|
|
267
|
-
id: cloneIconId
|
|
282
|
+
id: cloneIconId // 此id必须,用于remove节点的时候
|
|
268
283
|
});
|
|
269
284
|
clonedObj.bringForward();
|
|
270
285
|
this.canvas.add(clonedObj);
|
|
271
286
|
this.canvas.renderAll();
|
|
272
287
|
});
|
|
273
288
|
}
|
|
274
|
-
|
|
275
|
-
icon.set({ originX: 'center'});
|
|
289
|
+
|
|
290
|
+
icon.set({ originX: 'center' });
|
|
276
291
|
this.moveLimit(icon);
|
|
277
292
|
icon.left >= originX && icon.left < originX + 5 && (originTop = icon.top);
|
|
278
293
|
if (icon.left >= originX) {
|
|
@@ -291,7 +306,7 @@ export default {
|
|
|
291
306
|
this.canvas.renderAll();
|
|
292
307
|
this.removeTitle();
|
|
293
308
|
this.removePolyline(cloneIconId);
|
|
294
|
-
|
|
309
|
+
|
|
295
310
|
if (icon.id.includes('_polylinePoint_') && this.isDropVisible) {
|
|
296
311
|
this.isDropVisible = false;
|
|
297
312
|
if (icon.left >= originX) {
|
|
@@ -300,7 +315,7 @@ export default {
|
|
|
300
315
|
this.$emit('pointOperation', 'increasePointBatch', this.addPointList);
|
|
301
316
|
this.addPointList = [];
|
|
302
317
|
}
|
|
303
|
-
}
|
|
318
|
+
}
|
|
304
319
|
this.removePolyline(icon.id);
|
|
305
320
|
// 重绘折线标题
|
|
306
321
|
this.drawPolylineTitle();
|
|
@@ -333,7 +348,53 @@ export default {
|
|
|
333
348
|
if (obj.id && obj.id.includes('isTitle')) {
|
|
334
349
|
this.canvas.remove(obj);
|
|
335
350
|
}
|
|
336
|
-
})
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
isLimit(time) {
|
|
354
|
+
const minMinute = Math.min(...this.propItems.xScaleList);
|
|
355
|
+
const maxMinute = Math.max(...this.propItems.xScaleList);
|
|
356
|
+
const getTime = new Date(time).getTime();
|
|
357
|
+
return getTime >= minMinute && getTime <= maxMinute;
|
|
358
|
+
},
|
|
359
|
+
// 创建危急值
|
|
360
|
+
createCritical(polyline, polylineIndex, polylineType, polylineTypeId) {
|
|
361
|
+
const { critical = null, list } = polyline;
|
|
362
|
+
if (!critical?.max && !critical?.min) return;
|
|
363
|
+
|
|
364
|
+
const { originX, endX } = this.propItems;
|
|
365
|
+
const isMax = critical?.max?.value && list.some(v => +v.value >= +critical.max.value && this.isLimit(v.time));
|
|
366
|
+
const isMin = critical?.min?.value && list.some(v => +v.value <= +critical.min.value && this.isLimit(v.time));
|
|
367
|
+
const lines = [];
|
|
368
|
+
|
|
369
|
+
const drawLine = ({ value, lineStyle }) => {
|
|
370
|
+
const top = this.cumputedY(polylineType, +value, polylineTypeId);
|
|
371
|
+
return this.drawLine([originX, top, endX, top], { polylineIndex, lineIndex: 0, polylineTypeId, ...(lineStyle || defaultVaule.criticalStyle) });
|
|
372
|
+
};
|
|
373
|
+
const drawText = ({ name, nameStyle }, top) => {
|
|
374
|
+
return new this.fabric.Text(String(name || ''), {
|
|
375
|
+
...defaultVaule.style,
|
|
376
|
+
...defaultVaule.textStyle,
|
|
377
|
+
...nameStyle,
|
|
378
|
+
originY: 'bottom',
|
|
379
|
+
left: originX + 5,
|
|
380
|
+
top: top - 5
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
if (isMax) {
|
|
385
|
+
const line = drawLine(critical.max);
|
|
386
|
+
const text = drawText(critical.max, line.top);
|
|
387
|
+
line.text = text;
|
|
388
|
+
lines.push(line, text);
|
|
389
|
+
}
|
|
390
|
+
if (isMin) {
|
|
391
|
+
const line = drawLine(critical.min);
|
|
392
|
+
const text = drawText(critical.min, line.top);
|
|
393
|
+
line.text = text;
|
|
394
|
+
lines.push(line, text);
|
|
395
|
+
}
|
|
396
|
+
this.canvas.add(...lines);
|
|
397
|
+
this.canvas.renderAll();
|
|
337
398
|
},
|
|
338
399
|
/**
|
|
339
400
|
* 绘制一条折线
|
|
@@ -344,51 +405,42 @@ export default {
|
|
|
344
405
|
* @param {polylineIndex} 当前折线 index
|
|
345
406
|
*/
|
|
346
407
|
drawPolyline(polyline, polylineIndex, polylineType, polylineTypeId) {
|
|
408
|
+
const { originY, endY } = this.propItems;
|
|
347
409
|
const { pointAttr, lineAttr } = polyline;
|
|
348
410
|
this._iconClassName = polyline.type === 'img' && pointAttr.iconClassName ? pointAttr.iconClassName : '';
|
|
349
411
|
|
|
350
412
|
const list = polyline.list;
|
|
351
413
|
const pointList = [];
|
|
352
414
|
let lineList = [];
|
|
353
|
-
const minMinute = Math.min(...this.propItems.xScaleList);
|
|
354
|
-
const maxMinute = Math.max(...this.propItems.xScaleList);
|
|
355
415
|
|
|
356
416
|
list.forEach((linePoints, index) => {
|
|
357
417
|
// 当前点
|
|
358
418
|
let points = null;
|
|
359
|
-
|
|
419
|
+
let isInit = false;
|
|
420
|
+
if (linePoints.time && (linePoints.value || linePoints.value == 0)) {
|
|
360
421
|
const x = this.cumputedX(linePoints.time);
|
|
361
422
|
const y = this.cumputedY(polylineType, linePoints.value, polylineTypeId);
|
|
362
|
-
|
|
363
|
-
if (
|
|
423
|
+
isInit = y < originY || y > endY;
|
|
424
|
+
if (this.isLimit(linePoints.time)) points = [x, y < originY ? originY : y > endY ? endY : y];
|
|
364
425
|
}
|
|
365
426
|
|
|
366
427
|
// 下一个点
|
|
367
428
|
const nextPoints = list[index + 1];
|
|
368
429
|
let nextPoint = null;
|
|
369
|
-
if (nextPoints?.time && nextPoints
|
|
430
|
+
if (nextPoints?.time && (nextPoints.value || nextPoints.value == 0)) {
|
|
370
431
|
const nextX = this.cumputedX(nextPoints.time);
|
|
371
432
|
const nextY = this.cumputedY(polylineType, nextPoints.value, polylineTypeId);
|
|
372
|
-
|
|
373
|
-
if (nextMinute > minMinute && nextMinute <= maxMinute) nextPoint = [nextX, nextY];
|
|
433
|
+
if (this.isLimit(nextPoints.time)) nextPoint = [nextX, nextY < originY ? originY : nextY > endY ? endY : nextY];
|
|
374
434
|
}
|
|
375
435
|
let line;
|
|
376
436
|
let point;
|
|
377
437
|
let previousLine;
|
|
378
438
|
|
|
379
|
-
line =
|
|
380
|
-
points && nextPoint
|
|
381
|
-
? this.drawLine([...points, ...nextPoint], { polylineIndex, lineIndex: index, ...lineAttr })
|
|
382
|
-
: null;
|
|
439
|
+
line = points && nextPoint ? this.drawLine([...points, ...nextPoint], { polylineIndex, lineIndex: index, ...lineAttr }) : null;
|
|
383
440
|
previousLine = lineList[index - 1];
|
|
384
|
-
// const customData = linePoints.find(v => this.isObject(v)) || '';
|
|
385
441
|
const pointOthers = { polylineTypeId, polylineIndex, pointIndex: index, ...pointAttr, lineAttr };
|
|
386
|
-
if (
|
|
387
|
-
point =
|
|
388
|
-
} else {
|
|
389
|
-
if (points) {
|
|
390
|
-
point = this.drawPoint(...points, null, line, polyline.type, pointOthers);
|
|
391
|
-
}
|
|
442
|
+
if (points) {
|
|
443
|
+
point = previousLine ? this.drawPoint(...points, previousLine, line, polyline.type, pointOthers, isInit) : this.drawPoint(...points, null, line, polyline.type, pointOthers, isInit);
|
|
392
444
|
}
|
|
393
445
|
lineList.push(line);
|
|
394
446
|
point && pointList.push(point);
|
|
@@ -407,9 +459,11 @@ export default {
|
|
|
407
459
|
this.canvas.add(...lineList, ...res);
|
|
408
460
|
this.canvas.requestRenderAll();
|
|
409
461
|
});
|
|
462
|
+
|
|
463
|
+
this.createCritical(polyline, polylineIndex, polylineType, polylineTypeId);
|
|
410
464
|
},
|
|
411
465
|
// 计算y轴坐标
|
|
412
|
-
cumputedY(polylineType, linePointY, polylineTypeId) {
|
|
466
|
+
cumputedY(polylineType, linePointY, polylineTypeId) {
|
|
413
467
|
const yScaleCell = polylineTypeId == 1 ? this.propItems.yScaleCellLeft : this.propItems.yScaleCellRight; // polylineTypeId值为1表示是右边单位的折线数据,即℃
|
|
414
468
|
const yCellUnit = linePointY - Math.min(...polylineType.list);
|
|
415
469
|
return this.propItems.endY - yScaleCell * yCellUnit;
|
|
@@ -421,9 +475,9 @@ export default {
|
|
|
421
475
|
* @param {type} 折线点类型
|
|
422
476
|
* @param {others} 参数 polylineIndex | pointIndex | ...polyline.pointAttr
|
|
423
477
|
*/
|
|
424
|
-
async drawPoint(left, top, line1, line2, type, others) {
|
|
478
|
+
async drawPoint(left, top, line1, line2, type, others, isInit) {
|
|
425
479
|
const pointId = `${others.polylineTypeId}_${others.polylineIndex}_${others.pointIndex}_polylinePoint_${new Date().getTime()}`;
|
|
426
|
-
const ele = this._iconClassName && await this.createImage(this._iconClassName, others);
|
|
480
|
+
const ele = this._iconClassName && (await this.createImage(this._iconClassName, others));
|
|
427
481
|
let point = await this.createPoint(type, {
|
|
428
482
|
id: pointId,
|
|
429
483
|
left: left,
|
|
@@ -431,7 +485,12 @@ export default {
|
|
|
431
485
|
ele: ele || '',
|
|
432
486
|
...defaultVaule.pointStyle,
|
|
433
487
|
...others,
|
|
434
|
-
...this.
|
|
488
|
+
...(!this.eventStyle.evented
|
|
489
|
+
? {
|
|
490
|
+
lockMovementX: true,
|
|
491
|
+
lockMovementY: true
|
|
492
|
+
}
|
|
493
|
+
: {})
|
|
435
494
|
});
|
|
436
495
|
point.hasControls = point.hasBorders = false;
|
|
437
496
|
line1 && (point.line1 = line1);
|
|
@@ -443,26 +502,35 @@ export default {
|
|
|
443
502
|
this.isDropVisible = false;
|
|
444
503
|
});
|
|
445
504
|
// 折线点移动中 实时更新相关联的线的坐标
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
505
|
+
if (this.eventStyle.evented) {
|
|
506
|
+
point.on('moving', () => {
|
|
507
|
+
this.pointMoveLimit(point);
|
|
508
|
+
this.pointMoveUpdateLine(point);
|
|
509
|
+
this.addPoint(point, left, top);
|
|
510
|
+
this.canvas.renderAll();
|
|
511
|
+
this.showDrapPopup(point);
|
|
512
|
+
});
|
|
513
|
+
// 折线点停止拖拽后 更新polylineList中对应的坐标
|
|
514
|
+
point.on('moved', () => {
|
|
515
|
+
if (point && point.id.includes('_polylinePoint_')) {
|
|
516
|
+
this.isDropVisible = false;
|
|
517
|
+
this.setEmitFunction(point);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// 超出表格最高或最低值则需要触发pointChange事件并且不能更新视图,否则连接节点判断不会成功
|
|
523
|
+
isInit && this.setEmitFunction(point, isInit);
|
|
524
|
+
|
|
460
525
|
return point;
|
|
461
526
|
},
|
|
462
527
|
// 拖动停止后 设置回调触发方法
|
|
463
|
-
setEmitFunction(point) {
|
|
528
|
+
setEmitFunction(point, isInit = false) {
|
|
464
529
|
const { data, x, y } = this.getValue(point);
|
|
465
|
-
data
|
|
530
|
+
Object.assign(data, {
|
|
531
|
+
value: { time: x, value: y },
|
|
532
|
+
isInit
|
|
533
|
+
});
|
|
466
534
|
if (this.addPointList.length === 0) {
|
|
467
535
|
this.$emit('pointChange', data);
|
|
468
536
|
} else {
|
|
@@ -498,12 +566,12 @@ export default {
|
|
|
498
566
|
* @param {*} originLeft 拖动的源节点的left值
|
|
499
567
|
* @param {*} originTop 拖动的源节点的top值
|
|
500
568
|
* @return {*}
|
|
501
|
-
*/
|
|
569
|
+
*/
|
|
502
570
|
addPoint(point, originLeft, originTop) {
|
|
503
571
|
const { xCellWidth, table, originX } = this.propItems;
|
|
504
572
|
// const addPointSpaceGridNumbers = table.addPointSpaceGridNumbers || [];
|
|
505
573
|
let addPointSpaceGridNumber = table.addPointSpaceGridNumber || 1;
|
|
506
|
-
|
|
574
|
+
|
|
507
575
|
let { left, top } = point;
|
|
508
576
|
const currentLeft = left;
|
|
509
577
|
|
|
@@ -511,7 +579,7 @@ export default {
|
|
|
511
579
|
const n = 5; // 拖动范围,在需要增加节点的刻度左右吸入的范围值
|
|
512
580
|
const spaceWidth = xCellWidth * addPointSpaceGridNumber;
|
|
513
581
|
const residue = (left - originLeft) % spaceWidth;
|
|
514
|
-
|
|
582
|
+
|
|
515
583
|
const condition = residue > spaceWidth - n || residue < n;
|
|
516
584
|
|
|
517
585
|
if (!point.line2 && left > originLeft && condition) {
|
|
@@ -551,23 +619,23 @@ export default {
|
|
|
551
619
|
left: point.nextPoint.get('left'),
|
|
552
620
|
top: point.nextPoint.get('top'),
|
|
553
621
|
scaleX: point.scale === 1 ? 1.5 : 0.1,
|
|
554
|
-
scaleY: point.scale === 1 ? 1.5 : 0.1
|
|
622
|
+
scaleY: point.scale === 1 ? 1.5 : 0.1
|
|
555
623
|
});
|
|
556
624
|
} else if (point.nextPoint) {
|
|
557
625
|
point.set({
|
|
558
626
|
scaleX: point.scale,
|
|
559
|
-
scaleY: point.scale
|
|
627
|
+
scaleY: point.scale
|
|
560
628
|
});
|
|
561
629
|
}
|
|
562
630
|
// 如果往回拖动则删除经过的已存在的节点
|
|
563
631
|
if (startLength > 0 && currentLeft <= this.addPointList[startLength - 1].left) {
|
|
564
632
|
this.removePolyline('increasePointBatch', left);
|
|
565
|
-
this.addPointList = this.addPointList.filter(
|
|
633
|
+
this.addPointList = this.addPointList.filter(v => v.left < left);
|
|
566
634
|
const endLength = this.addPointList.length;
|
|
567
635
|
if (endLength === 0) this.removePolyline('increasePointBatch', originLeft);
|
|
568
636
|
if (endLength > 0) {
|
|
569
637
|
point.set({
|
|
570
|
-
prePoints: [this.addPointList[endLength - 1].left, this.addPointList[endLength - 1].top]
|
|
638
|
+
prePoints: [this.addPointList[endLength - 1].left, this.addPointList[endLength - 1].top]
|
|
571
639
|
});
|
|
572
640
|
}
|
|
573
641
|
}
|
|
@@ -575,7 +643,7 @@ export default {
|
|
|
575
643
|
clonePoint(point, points) {
|
|
576
644
|
let evented, selectable, lineIndex, polylineIndex, lineAttr, polylineTypeId;
|
|
577
645
|
evented = selectable = false;
|
|
578
|
-
lineAttr = {...point.lineAttr};
|
|
646
|
+
lineAttr = { ...point.lineAttr };
|
|
579
647
|
lineIndex = point.pointIndex;
|
|
580
648
|
polylineIndex = point.polylineIndex;
|
|
581
649
|
polylineTypeId = point.polylineTypeId;
|
|
@@ -587,11 +655,11 @@ export default {
|
|
|
587
655
|
idClone: 'increasePointBatch',
|
|
588
656
|
id: '_polylinePoint_' + new Date().getTime(), // 此id必须,用于remove节点的时候
|
|
589
657
|
polylineTypeId,
|
|
590
|
-
polylineIndex: point.polylineIndex
|
|
658
|
+
polylineIndex: point.polylineIndex
|
|
591
659
|
});
|
|
592
660
|
clonedObj.hasControls = clonedObj.hasBorders = false;
|
|
593
661
|
point.set({
|
|
594
|
-
prePoints: [point.left, point.top]
|
|
662
|
+
prePoints: [point.left, point.top]
|
|
595
663
|
});
|
|
596
664
|
const line = this.drawLine([...points], { evented, selectable, ...lineAttr, polylineIndex, polylineTypeId, lineIndex });
|
|
597
665
|
clonedObj.line1 = line;
|
|
@@ -648,9 +716,9 @@ export default {
|
|
|
648
716
|
this.dropVal = {
|
|
649
717
|
title: data.title,
|
|
650
718
|
list: [
|
|
651
|
-
{id: '11', name: '时间', value: x},
|
|
652
|
-
{id: '22', name: '值', value: Math.round(y)}
|
|
653
|
-
]
|
|
719
|
+
{ id: '11', name: '时间', value: x },
|
|
720
|
+
{ id: '22', name: '值', value: Math.round(y) }
|
|
721
|
+
]
|
|
654
722
|
};
|
|
655
723
|
},
|
|
656
724
|
// 折线点移动时 setCoords()方法手动更新相关联的线坐标
|
|
@@ -666,9 +734,6 @@ export default {
|
|
|
666
734
|
},
|
|
667
735
|
// 打开右键菜单
|
|
668
736
|
openRightModal(event) {
|
|
669
|
-
if (!this.propItems.eventStyle.evented) {
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
737
|
this.rightPos = {
|
|
673
738
|
clientX: event.e.clientX || event.e.pageX,
|
|
674
739
|
clientY: event.e.clientY || event.e.pageY
|
|
@@ -694,7 +759,7 @@ export default {
|
|
|
694
759
|
const id = this._currentPointId;
|
|
695
760
|
this._currentPointId = '';
|
|
696
761
|
const { left, top } = this._active;
|
|
697
|
-
let data = id ? this.getDataById(id) : this.getValue({ left, top});
|
|
762
|
+
let data = id ? this.getDataById(id) : this.getValue({ left, top });
|
|
698
763
|
this.$emit('pointOperation', type, data);
|
|
699
764
|
},
|
|
700
765
|
getDataById(id) {
|
|
@@ -704,7 +769,7 @@ export default {
|
|
|
704
769
|
const value = data?.dataList?.[lineIndex]?.list?.[pointIndex]?.data || '';
|
|
705
770
|
return {
|
|
706
771
|
title: data?.dataList?.[lineIndex].title || '',
|
|
707
|
-
position: data.position,
|
|
772
|
+
position: data.position,
|
|
708
773
|
dataIndex: lineIndex,
|
|
709
774
|
pointIndex: pointIndex,
|
|
710
775
|
data: value
|
|
@@ -716,7 +781,7 @@ export default {
|
|
|
716
781
|
const pointId = left ? 'idClone' : 'id';
|
|
717
782
|
const point = this.canvas.getObjects().filter(item => item[pointId] === id);
|
|
718
783
|
if (point && point.length > 0) {
|
|
719
|
-
point.forEach(
|
|
784
|
+
point.forEach(v => {
|
|
720
785
|
if (left && v.left >= left) {
|
|
721
786
|
this.canvas.remove(v);
|
|
722
787
|
v.line1 && this.canvas.remove(v.line1);
|
|
@@ -724,18 +789,19 @@ export default {
|
|
|
724
789
|
this.canvas.remove(v);
|
|
725
790
|
v.line1 && this.canvas.remove(v.line1);
|
|
726
791
|
}
|
|
727
|
-
})
|
|
792
|
+
});
|
|
728
793
|
}
|
|
729
794
|
return;
|
|
730
795
|
}
|
|
731
796
|
// 删除一条线
|
|
732
797
|
if ((polylineTypeId === 0 || polylineTypeId) && (polylineIndex === 0 || polylineIndex)) {
|
|
733
798
|
this.canvas.forEachObject(obj => {
|
|
734
|
-
const isPolyLine = obj.polylineTypeId === polylineTypeId && obj.polylineIndex === polylineIndex
|
|
799
|
+
const isPolyLine = obj.polylineTypeId === polylineTypeId && obj.polylineIndex === polylineIndex;
|
|
735
800
|
if (obj.id && /_polyline(Point|Line)_/.test(obj.id) && !obj.id.includes('isTitle') && isPolyLine) {
|
|
736
|
-
this.canvas.remove(obj);
|
|
801
|
+
obj.text && this.canvas.remove(obj.text);
|
|
737
802
|
obj.line1 && this.canvas.remove(obj.line1);
|
|
738
803
|
obj.line2 && this.canvas.remove(obj.line2);
|
|
804
|
+
this.canvas.remove(obj);
|
|
739
805
|
}
|
|
740
806
|
});
|
|
741
807
|
return;
|
|
@@ -771,12 +837,6 @@ export default {
|
|
|
771
837
|
this.drawPolyline(this.polylineList[polylineTypeId].dataList[parseInt(dadaIndex)], parseInt(dadaIndex), this.polylineList[polylineTypeId], polylineTypeId);
|
|
772
838
|
}
|
|
773
839
|
}
|
|
774
|
-
},
|
|
775
|
-
beforeDestroy() {
|
|
776
|
-
const upperCanvas = document.querySelector('.upper-canvas');
|
|
777
|
-
upperCanvas && upperCanvas.removeEventListener('contextmenu', this.addEventListenerContextmenu, true);
|
|
778
|
-
document.removeEventListener('click', this.addEventListenerClick, true);
|
|
779
|
-
document.removeEventListener('scroll', this.addEventListenerScroll, true);
|
|
780
840
|
}
|
|
781
841
|
};
|
|
782
842
|
</script>
|