cnhis-design-vue 2.1.12 → 2.1.15
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/CHANGELOG.md +2206 -2148
- package/es/affix/index.js +8 -8
- package/es/age/index.js +10 -10
- package/es/alert/index.js +8 -8
- package/es/anchor/index.js +8 -8
- package/es/auto-complete/index.js +8 -8
- package/es/avatar/index.js +8 -8
- package/es/back-top/index.js +8 -8
- package/es/badge/index.js +8 -8
- package/es/base/index.js +8 -8
- package/es/big-table/index.js +358 -277
- package/es/big-table/style.css +1 -1
- package/es/breadcrumb/index.js +8 -8
- package/es/button/index.js +1741 -2774
- package/es/button/style.css +1 -1
- package/es/calendar/index.js +8 -8
- package/es/captcha/index.js +3 -3
- package/es/card/index.js +8 -8
- package/es/carousel/index.js +8 -8
- package/es/cascader/index.js +8 -8
- package/es/checkbox/index.js +9 -9
- package/es/col/index.js +8 -8
- package/es/collapse/index.js +8 -8
- package/es/color-picker/index.js +1 -1
- package/es/comment/index.js +8 -8
- package/es/config-provider/index.js +8 -8
- package/es/date-picker/index.js +8 -8
- package/es/descriptions/index.js +8 -8
- package/es/divider/index.js +8 -8
- package/es/drag-layout/index.js +3 -3
- package/es/drawer/index.js +8 -8
- package/es/dropdown/index.js +8 -8
- package/es/editor/index.js +1 -1
- package/es/empty/index.js +8 -8
- package/es/fabric-chart/index.js +121 -167
- package/es/form/index.js +8 -8
- package/es/form-model/index.js +8 -8
- package/es/form-table/index.js +62 -62
- package/es/index/index.js +2836 -3668
- package/es/index/style.css +1 -1
- package/es/input/index.js +9 -9
- package/es/input-number/index.js +8 -8
- package/es/layout/index.js +8 -8
- package/es/list/index.js +8 -8
- package/es/locale-provider/index.js +8 -8
- package/es/map/index.js +9 -9
- package/es/mentions/index.js +8 -8
- package/es/menu/index.js +8 -8
- package/es/message/index.js +8 -8
- package/es/multi-chat/index.js +247 -144
- package/es/multi-chat/style.css +1 -1
- package/es/multi-chat-client/index.js +272 -164
- package/es/multi-chat-client/style.css +1 -1
- package/es/multi-chat-history/index.js +4 -4
- package/es/multi-chat-record/index.js +14 -14
- package/es/multi-chat-setting/index.js +28 -28
- package/es/multi-chat-sip/index.js +1 -1
- package/es/notification/index.js +8 -8
- package/es/page-header/index.js +8 -8
- package/es/pagination/index.js +8 -8
- package/es/popconfirm/index.js +8 -8
- package/es/popover/index.js +8 -8
- package/es/progress/index.js +8 -8
- package/es/radio/index.js +9 -9
- package/es/rate/index.js +8 -8
- package/es/result/index.js +8 -8
- package/es/row/index.js +8 -8
- package/es/scale-view/index.js +33 -33
- package/es/select/index.js +11 -11
- package/es/select-label/index.js +11 -11
- package/es/select-person/index.js +20 -20
- package/es/skeleton/index.js +8 -8
- package/es/slider/index.js +8 -8
- package/es/space/index.js +8 -8
- package/es/spin/index.js +8 -8
- package/es/statistic/index.js +8 -8
- package/es/steps/index.js +8 -8
- package/es/switch/index.js +8 -8
- package/es/table-filter/index.js +1903 -2885
- package/es/table-filter/style.css +1 -1
- package/es/tabs/index.js +8 -8
- package/es/tag/index.js +9 -9
- package/es/time-picker/index.js +8 -8
- package/es/timeline/index.js +8 -8
- package/es/tooltip/index.js +8 -8
- package/es/transfer/index.js +8 -8
- package/es/tree/index.js +8 -8
- package/es/tree-select/index.js +8 -8
- package/es/upload/index.js +8 -8
- package/es/verification-code/index.js +2 -2
- package/lib/cui.common.js +2913 -3384
- package/lib/cui.umd.js +2913 -3384
- package/lib/cui.umd.min.js +81 -79
- package/package.json +107 -107
- package/packages/big-table/src/BigTable.vue +3038 -2988
- package/packages/big-table/src/assets/style/table-base.less +370 -360
- package/packages/big-table/src/components/AutoLayoutButton.vue +270 -270
- package/packages/big-table/src/utils/bigTableProps.js +95 -95
- package/packages/button/src/ButtonPrint/components/IdentityVerification.vue +181 -181
- package/packages/button/src/ButtonPrint/index.vue +724 -723
- package/packages/button/src/ButtonPrint/js/print.es.min.js +4 -1
- package/packages/fabric-chart/src/components/TimeScaleValue.vue +117 -117
- package/packages/fabric-chart/src/const/defaultVaule.js +59 -59
- package/packages/fabric-chart/src/fabric-chart/FabricCanvas.vue +3 -1
- package/packages/fabric-chart/src/fabric-chart/FabricPolylines.vue +960 -960
- package/packages/fabric-chart/src/fabric-chart/FabricScaleValue.vue +133 -133
- package/packages/fabric-chart/src/fabric-chart/FabricTextGroup.vue +558 -579
- package/packages/fabric-chart/src/fabric-chart2/FabricTop.vue +172 -172
- package/packages/multi-chat/chat/chatFooter.vue +1598 -1598
- package/packages/multi-chat/chat/chatHeader.vue +9 -4
- package/packages/multi-chat/chat/chatMain.vue +1442 -1442
- package/packages/multi-chat/chat/client/clientChat.vue +3 -0
- package/packages/multi-chat/chat/quickReply.vue +439 -361
- package/packages/multi-chat/chat/scrollList.vue +1232 -1232
- package/packages/multi-chat/setting/baseInfo/index.vue +1302 -1302
- package/packages/multi-chat/store/actions.js +448 -448
- package/packages/multi-chat/store/state.js +112 -112
- package/packages/scale-view/formitem/r-choice.vue +714 -714
- package/packages/scale-view/scaleView.vue +2010 -2010
- package/packages/select-person/select-person.vue +1658 -1658
- package/packages/table-filter/src/base-search-com/BaseSearch.vue +2462 -2462
- package/packages/table-filter/src/components/c-tree-select/tree-select.vue +336 -336
- package/packages/table-filter/src/components/multi-select/multi-select.vue +219 -219
- package/packages/table-filter/src/components/out-quick-search/out-quick-search.vue +340 -340
- package/packages/table-filter/src/const/dataOptions.js +43 -43
- package/packages/table-filter/src/mixins/mixins.js +695 -695
- package/packages/table-filter/src/quick-search/QuickSearch.vue +2083 -2051
- package/src/directive/preventReClick.js +12 -12
|
@@ -1,579 +1,558 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="text-group">
|
|
3
|
-
<MouseRightClick v-if="isRightVisible" :getContainer="getContainer" :nodeList="rightClickNode" :rightPos="rightPos" @nodeClick="handleRightClick" @closeRight="isRightVisible = false" />
|
|
4
|
-
<DropPopup v-if="isDropVisible" :val="dropVal" :dropPos="dropPos" />
|
|
5
|
-
</div>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script>
|
|
9
|
-
import fabricCommon from '../mixins/fabricCommon';
|
|
10
|
-
import draw from '../mixins/draw';
|
|
11
|
-
import defaultVaule from '../const/defaultVaule';
|
|
12
|
-
import DropPopup from '../components/DropPopup';
|
|
13
|
-
import MouseRightClick from '../components/MouseRightClick';
|
|
14
|
-
import eventCommon from '../mixins/eventCommon';
|
|
15
|
-
|
|
16
|
-
const rightClickNode = [
|
|
17
|
-
{ name: '修改', type: 'edit' },
|
|
18
|
-
{ name: '删除', type: 'delete' }
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
let topTotalList = [];
|
|
22
|
-
const getTopTotalList = (tree, topTotalList) => {
|
|
23
|
-
tree.forEach(item => {
|
|
24
|
-
if (item?.children?.length) {
|
|
25
|
-
getTopTotalList(item.children, topTotalList);
|
|
26
|
-
} else {
|
|
27
|
-
const obj = JSON.parse(JSON.stringify(item));
|
|
28
|
-
topTotalList.push(obj?.total || '');
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default {
|
|
34
|
-
name: 'fabric-text-group',
|
|
35
|
-
components: {
|
|
36
|
-
DropPopup,
|
|
37
|
-
MouseRightClick
|
|
38
|
-
},
|
|
39
|
-
mixins: [fabricCommon, draw, eventCommon],
|
|
40
|
-
props: {
|
|
41
|
-
templateData: {
|
|
42
|
-
type: Object,
|
|
43
|
-
required: true
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
watch: {
|
|
47
|
-
'templateData.other': {
|
|
48
|
-
handler(value) {
|
|
49
|
-
if (value) {
|
|
50
|
-
this.removeOther();
|
|
51
|
-
this.drawTextDataGroup(value);
|
|
52
|
-
this.canvas.renderAll();
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
deep: true
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
data() {
|
|
59
|
-
return {
|
|
60
|
-
leftStartX: 0,
|
|
61
|
-
isDropVisible: false,
|
|
62
|
-
dropVal: {},
|
|
63
|
-
dropPos: { clientX: 0, clientY: 0 },
|
|
64
|
-
isRightVisible: false,
|
|
65
|
-
rightPos: { clientX: 0, clientY: 0 },
|
|
66
|
-
rightClickNode: [],
|
|
67
|
-
activeEvent: null // 当前可右键活动的对象
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
mounted() {
|
|
71
|
-
this.$nextTick(() => {
|
|
72
|
-
this.init();
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
computed: {
|
|
76
|
-
girdLineStyle() {
|
|
77
|
-
return Object.assign({}, defaultVaule.borderStyle, this.templateData.borderStyle || {});
|
|
78
|
-
},
|
|
79
|
-
eventStyle() {
|
|
80
|
-
return this.propItems.eventStyle;
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
methods: {
|
|
84
|
-
init() {
|
|
85
|
-
if (this.propItems.treeList?.length) {
|
|
86
|
-
this.topTreeTextGroup(this.propItems.treeList);
|
|
87
|
-
if (this.propItems.topTotal?.width) {
|
|
88
|
-
topTotalList = [];
|
|
89
|
-
getTopTotalList(this.templateData.top.list, topTotalList);
|
|
90
|
-
this.drawTopTotal(topTotalList);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
this.templateData.left && this.drawLeftScaleGroup(this.templateData.left);
|
|
94
|
-
this.templateData.other && this.drawTextDataGroup(this.templateData.other);
|
|
95
|
-
this.eventStyle.evented && this.createEvent();
|
|
96
|
-
this.drawBorder();
|
|
97
|
-
this.canvas.renderAll();
|
|
98
|
-
this.templateData.bottom && this.drawBottomTextDataGroup(this.templateData.bottom);
|
|
99
|
-
},
|
|
100
|
-
drawBorder() {
|
|
101
|
-
const { endX, canvasWidth, canvasHeight, topTotal } = this.propItems;
|
|
102
|
-
const curEndX = topTotal.width ? canvasWidth : endX;
|
|
103
|
-
// 右 下两条线宽度和高度顶格不显示未发现具体原因 暂时减一处理
|
|
104
|
-
// 上边线
|
|
105
|
-
this.canvas.add(this.drawLine([0, 0, curEndX, 0], { ...this.girdLineStyle }));
|
|
106
|
-
// 右边线
|
|
107
|
-
this.canvas.add(this.drawLine([topTotal.width ? curEndX - 1 : curEndX, 0, topTotal.width ? curEndX - 1 : curEndX, canvasHeight], { ...this.girdLineStyle }));
|
|
108
|
-
// 下边线
|
|
109
|
-
this.canvas.add(this.drawLine([0, canvasHeight - 1, curEndX, canvasHeight - 1], { ...this.girdLineStyle }));
|
|
110
|
-
// 左侧边框线
|
|
111
|
-
this.canvas.add(this.drawLine([0, 0, 0, canvasHeight], { ...this.girdLineStyle }));
|
|
112
|
-
},
|
|
113
|
-
createEvent() {
|
|
114
|
-
this.canvas.on('mouse:up', event => {
|
|
115
|
-
if (event.button === 3) {
|
|
116
|
-
const { x, y } = event.pointer;
|
|
117
|
-
const { originX, originY, endX, endY } = this.$propItems();
|
|
118
|
-
if (!(x < originX || x > endX || y < originY || y > endY)) {
|
|
119
|
-
this.activeEvent = event;
|
|
120
|
-
document.querySelector('.upper-canvas').addEventListener('contextmenu', this.addEventListenerContextmenu, true);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
// 打开右键菜单
|
|
126
|
-
openRightModal(event) {
|
|
127
|
-
this.rightPos = {
|
|
128
|
-
clientX: event.e.clientX || event.e.pageX,
|
|
129
|
-
clientY: event.e.clientY || event.e.pageY
|
|
130
|
-
};
|
|
131
|
-
this.isRightVisible = false;
|
|
132
|
-
const target = event.target;
|
|
133
|
-
const id = target ? target.id : '';
|
|
134
|
-
this.$nextTick(() => {
|
|
135
|
-
if (id && id.includes('_other')) {
|
|
136
|
-
this._currentPoint = target || '';
|
|
137
|
-
this.rightClickNode = Object.freeze(rightClickNode.slice());
|
|
138
|
-
this.isRightVisible = true;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
// 关闭右键菜单,打开添加节点弹窗表单
|
|
143
|
-
handleRightClick({ type }) {
|
|
144
|
-
this.isRightVisible = false;
|
|
145
|
-
const text = this._currentPoint;
|
|
146
|
-
this._currentPoint = '';
|
|
147
|
-
const obj = {
|
|
148
|
-
type: text.type,
|
|
149
|
-
index: text.index,
|
|
150
|
-
dataIndex: text.dataIndex
|
|
151
|
-
};
|
|
152
|
-
this.$emit(`${type}Other`, obj);
|
|
153
|
-
},
|
|
154
|
-
removeOther() {
|
|
155
|
-
this.canvas.forEachObject(obj => {
|
|
156
|
-
if (obj.id && obj.id.includes('_other')) {
|
|
157
|
-
this.canvas.remove(obj);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
},
|
|
161
|
-
drawTopTotal(topTotalList) {
|
|
162
|
-
const { endX, canvasWidth, yCellHeightTop, topTotal, endYTop, spaceHeight } = this.propItems;
|
|
163
|
-
const textList = [];
|
|
164
|
-
const left = endX + (canvasWidth - endX) / 2;
|
|
165
|
-
topTotalList.forEach((v, i) => {
|
|
166
|
-
const top = i * yCellHeightTop + yCellHeightTop / 2;
|
|
167
|
-
const text = v
|
|
168
|
-
? new this.fabric.Text(String(v), {
|
|
169
|
-
...defaultVaule.style,
|
|
170
|
-
...(topTotal.style || defaultVaule.textStyle),
|
|
171
|
-
left,
|
|
172
|
-
top,
|
|
173
|
-
originX: 'center',
|
|
174
|
-
originY: 'center'
|
|
175
|
-
})
|
|
176
|
-
: null;
|
|
177
|
-
text && textList.push(text);
|
|
178
|
-
});
|
|
179
|
-
const title = this.drawTextGroup(
|
|
180
|
-
{ width: canvasWidth - endX, height: spaceHeight, strokeWidth: 1 },
|
|
181
|
-
{ text: String(topTotal.title), ...(topTotal.style || defaultVaule.textStyle) },
|
|
182
|
-
{ left: endX, top: endYTop }
|
|
183
|
-
);
|
|
184
|
-
this.canvas.add(...textList, title);
|
|
185
|
-
},
|
|
186
|
-
topTreeTextGroup(list) {
|
|
187
|
-
list.forEach(item => {
|
|
188
|
-
if (item?.children?.length) {
|
|
189
|
-
this.canvas.add(
|
|
190
|
-
this.drawTextGroup(
|
|
191
|
-
{ width: item.width, height: item.height, strokeWidth: 1 },
|
|
192
|
-
{ text: String(item.title), ...(this.templateData.top.treeTableTextStyle || {}) },
|
|
193
|
-
{ left: item.left, top: item.top }
|
|
194
|
-
)
|
|
195
|
-
);
|
|
196
|
-
this.topTreeTextGroup(item.children);
|
|
197
|
-
} else {
|
|
198
|
-
// 此处的文本text的中心源的定位由于draw.js中封装反向的,所以此时文本需要向左排列originX值应为right
|
|
199
|
-
this.canvas.add(
|
|
200
|
-
this.drawTextGroup(
|
|
201
|
-
{ width: item.width, height: item.height, strokeWidth: 1 },
|
|
202
|
-
{ text: String(item.title), ...(this.templateData.top.treeTableTextStyle || {}), originX: 'right', left: -Math.floor(item.width / 2) + 5 },
|
|
203
|
-
{ left: item.left, top: item.top }
|
|
204
|
-
)
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
// 绘制x轴下方的数据
|
|
211
|
-
drawTextDataGroup(obj) {
|
|
212
|
-
if (obj.list) {
|
|
213
|
-
this.drawTextDataGroupList(obj.list);
|
|
214
|
-
}
|
|
215
|
-
if (obj.colList) {
|
|
216
|
-
this.drawTextDataGroupColList(obj.colList);
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
drawTextDataGroupColList(colList) {
|
|
220
|
-
const { originY } = this.propItems;
|
|
221
|
-
let textList = [];
|
|
222
|
-
colList.forEach((item, index) => {
|
|
223
|
-
const baseTop = originY + (item.marginTop || 10);
|
|
224
|
-
if (this.isLimit(item.scalevalue)) {
|
|
225
|
-
item.dataList.forEach((v, i) => {
|
|
226
|
-
const top = baseTop + i * (item.lineHeight || 15);
|
|
227
|
-
const text = new this.fabric.Text(String(v.value), {
|
|
228
|
-
...defaultVaule.style,
|
|
229
|
-
...defaultVaule.textStyle,
|
|
230
|
-
...item.style,
|
|
231
|
-
originX: 'left',
|
|
232
|
-
originY: 'center',
|
|
233
|
-
left: this.cumputedX(item.scalevalue),
|
|
234
|
-
top,
|
|
235
|
-
lockMovementX: true,
|
|
236
|
-
lockMovementY: true,
|
|
237
|
-
dataIndex: index,
|
|
238
|
-
index: i,
|
|
239
|
-
type: 'colList',
|
|
240
|
-
id: `${index}_${i}_other_${Date.now()}`,
|
|
241
|
-
...this.eventStyle
|
|
242
|
-
});
|
|
243
|
-
text.hasControls = text.hasBorders = false;
|
|
244
|
-
textList.push(text);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
this.canvas.add(...textList);
|
|
249
|
-
},
|
|
250
|
-
drawTextDataGroupList(list) {
|
|
251
|
-
let textList = [];
|
|
252
|
-
const { originX, originY } = this.propItems;
|
|
253
|
-
let top = originY + 10;
|
|
254
|
-
list.forEach((item, index) => {
|
|
255
|
-
const marginLeft = item.titleStyle?.marginLeft || 8;
|
|
256
|
-
const left = originX - marginLeft; // 防止最左边的数据与名称显示重合了
|
|
257
|
-
|
|
258
|
-
if (list[index - 1]) {
|
|
259
|
-
top += item.lineHeight || 15;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const title = new this.fabric.Text(String(item.title), {
|
|
263
|
-
...defaultVaule.style,
|
|
264
|
-
...defaultVaule.textStyle,
|
|
265
|
-
...item.style,
|
|
266
|
-
...(item.titleStyle || {}),
|
|
267
|
-
originX: 'right',
|
|
268
|
-
originY: 'center',
|
|
269
|
-
left,
|
|
270
|
-
top,
|
|
271
|
-
id: `${index}_other_${Date.now()}`
|
|
272
|
-
});
|
|
273
|
-
textList.push(title);
|
|
274
|
-
item.dataList.forEach((v, i) => {
|
|
275
|
-
if (this.isLimit(v.time)) {
|
|
276
|
-
const text = new this.fabric.Text(String(v.value), {
|
|
277
|
-
...defaultVaule.style,
|
|
278
|
-
...defaultVaule.textStyle,
|
|
279
|
-
...item.style,
|
|
280
|
-
originX: 'center',
|
|
281
|
-
originY: 'center',
|
|
282
|
-
left: this.cumputedX(v.time),
|
|
283
|
-
top,
|
|
284
|
-
lockMovementX: true,
|
|
285
|
-
lockMovementY: true,
|
|
286
|
-
dataIndex: index,
|
|
287
|
-
index: i,
|
|
288
|
-
type: 'list',
|
|
289
|
-
id: `${index}_${i}_other_${Date.now()}`,
|
|
290
|
-
...this.eventStyle
|
|
291
|
-
});
|
|
292
|
-
text.hasControls = text.hasBorders = false;
|
|
293
|
-
textList.push(text);
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
this.canvas.add(...textList);
|
|
298
|
-
},
|
|
299
|
-
// 判断当前时间是否超出网格区域
|
|
300
|
-
isLimit(value) {
|
|
301
|
-
const { xScaleList } = this.propItems;
|
|
302
|
-
const minTime = Math.min(...xScaleList);
|
|
303
|
-
const maxTime = Math.max(...xScaleList);
|
|
304
|
-
const time = new Date(value).getTime();
|
|
305
|
-
return time >= minTime && time <= maxTime;
|
|
306
|
-
},
|
|
307
|
-
removeMark() {
|
|
308
|
-
this.canvas.forEachObject(obj => {
|
|
309
|
-
if (obj.type && obj.type === 'mark') {
|
|
310
|
-
this.canvas.remove(obj);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
},
|
|
314
|
-
// 底部标记
|
|
315
|
-
drawBottomTextDataGroup(obj) {
|
|
316
|
-
if (!obj.list) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const { endX, originX, endY, canvasHeight, topTotal } = this.propItems;
|
|
320
|
-
topTotal.width && this.canvas.add(this.drawLine([endX, endY - 1, endX, canvasHeight], { ...this.defaultRectStyle }));
|
|
321
|
-
// const textList = [];
|
|
322
|
-
const marginLeft = this.templateData.left.leftYScalevalue.spaceGridNumber || defaultVaule.spaceGridNumber;
|
|
323
|
-
const left = originX - marginLeft * 4; // 默认减去4倍的左边距,防止最左边的数据与名称显示重合了
|
|
324
|
-
const title = new this.fabric.Text(String(obj.title), {
|
|
325
|
-
...defaultVaule.style,
|
|
326
|
-
...defaultVaule.textStyle,
|
|
327
|
-
...obj.style,
|
|
328
|
-
originX: 'right',
|
|
329
|
-
originY: 'center',
|
|
330
|
-
left,
|
|
331
|
-
top: endY + (canvasHeight - endY) / 2,
|
|
332
|
-
type: 'mark'
|
|
333
|
-
});
|
|
334
|
-
this.canvas.add(title);
|
|
335
|
-
// textList.push(title);
|
|
336
|
-
const baseY = endY + 2; // 目前固定10像素的下边距
|
|
337
|
-
const baseYLimit = endY - 2; // 目前固定10像素的上边距
|
|
338
|
-
const
|
|
339
|
-
obj.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
point.
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
this
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
});
|
|
560
|
-
rect.sendToBack(); // 向下跳底层
|
|
561
|
-
this.canvas.add(rect);
|
|
562
|
-
},
|
|
563
|
-
drawLeftTitle(dataLeft) {
|
|
564
|
-
if (dataLeft.title) {
|
|
565
|
-
this.canvas.add(
|
|
566
|
-
this.drawTextGroup(
|
|
567
|
-
{ width: this.propItems.treeTableminCellWidth, height: this.propItems.canvasHeight - this.propItems.originY },
|
|
568
|
-
{ text: String(dataLeft.title.split('').join('\n')), ...defaultVaule.textStyle, ...dataLeft.titleStyle },
|
|
569
|
-
{ left: 0, top: this.propItems.originY }
|
|
570
|
-
)
|
|
571
|
-
);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
// render(h) {
|
|
576
|
-
// return this.$slots.default ? h('div', this.$slots.default) : undefined;
|
|
577
|
-
// }
|
|
578
|
-
};
|
|
579
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="text-group">
|
|
3
|
+
<MouseRightClick v-if="isRightVisible" :getContainer="getContainer" :nodeList="rightClickNode" :rightPos="rightPos" @nodeClick="handleRightClick" @closeRight="isRightVisible = false" />
|
|
4
|
+
<DropPopup v-if="isDropVisible" :val="dropVal" :dropPos="dropPos" />
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import fabricCommon from '../mixins/fabricCommon';
|
|
10
|
+
import draw from '../mixins/draw';
|
|
11
|
+
import defaultVaule from '../const/defaultVaule';
|
|
12
|
+
import DropPopup from '../components/DropPopup';
|
|
13
|
+
import MouseRightClick from '../components/MouseRightClick';
|
|
14
|
+
import eventCommon from '../mixins/eventCommon';
|
|
15
|
+
|
|
16
|
+
const rightClickNode = [
|
|
17
|
+
{ name: '修改', type: 'edit' },
|
|
18
|
+
{ name: '删除', type: 'delete' }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
let topTotalList = [];
|
|
22
|
+
const getTopTotalList = (tree, topTotalList) => {
|
|
23
|
+
tree.forEach(item => {
|
|
24
|
+
if (item?.children?.length) {
|
|
25
|
+
getTopTotalList(item.children, topTotalList);
|
|
26
|
+
} else {
|
|
27
|
+
const obj = JSON.parse(JSON.stringify(item));
|
|
28
|
+
topTotalList.push(obj?.total || '');
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
name: 'fabric-text-group',
|
|
35
|
+
components: {
|
|
36
|
+
DropPopup,
|
|
37
|
+
MouseRightClick
|
|
38
|
+
},
|
|
39
|
+
mixins: [fabricCommon, draw, eventCommon],
|
|
40
|
+
props: {
|
|
41
|
+
templateData: {
|
|
42
|
+
type: Object,
|
|
43
|
+
required: true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
watch: {
|
|
47
|
+
'templateData.other': {
|
|
48
|
+
handler(value) {
|
|
49
|
+
if (value) {
|
|
50
|
+
this.removeOther();
|
|
51
|
+
this.drawTextDataGroup(value);
|
|
52
|
+
this.canvas.renderAll();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
deep: true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
data() {
|
|
59
|
+
return {
|
|
60
|
+
leftStartX: 0,
|
|
61
|
+
isDropVisible: false,
|
|
62
|
+
dropVal: {},
|
|
63
|
+
dropPos: { clientX: 0, clientY: 0 },
|
|
64
|
+
isRightVisible: false,
|
|
65
|
+
rightPos: { clientX: 0, clientY: 0 },
|
|
66
|
+
rightClickNode: [],
|
|
67
|
+
activeEvent: null // 当前可右键活动的对象
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
mounted() {
|
|
71
|
+
this.$nextTick(() => {
|
|
72
|
+
this.init();
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
computed: {
|
|
76
|
+
girdLineStyle() {
|
|
77
|
+
return Object.assign({}, defaultVaule.borderStyle, this.templateData.borderStyle || {});
|
|
78
|
+
},
|
|
79
|
+
eventStyle() {
|
|
80
|
+
return this.propItems.eventStyle;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
methods: {
|
|
84
|
+
init() {
|
|
85
|
+
if (this.propItems.treeList?.length) {
|
|
86
|
+
this.topTreeTextGroup(this.propItems.treeList);
|
|
87
|
+
if (this.propItems.topTotal?.width) {
|
|
88
|
+
topTotalList = [];
|
|
89
|
+
getTopTotalList(this.templateData.top.list, topTotalList);
|
|
90
|
+
this.drawTopTotal(topTotalList);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
this.templateData.left && this.drawLeftScaleGroup(this.templateData.left);
|
|
94
|
+
this.templateData.other && this.drawTextDataGroup(this.templateData.other);
|
|
95
|
+
this.eventStyle.evented && this.createEvent();
|
|
96
|
+
this.drawBorder();
|
|
97
|
+
this.canvas.renderAll();
|
|
98
|
+
this.templateData.bottom && this.drawBottomTextDataGroup(this.templateData.bottom);
|
|
99
|
+
},
|
|
100
|
+
drawBorder() {
|
|
101
|
+
const { endX, canvasWidth, canvasHeight, topTotal } = this.propItems;
|
|
102
|
+
const curEndX = topTotal.width ? canvasWidth : endX;
|
|
103
|
+
// 右 下两条线宽度和高度顶格不显示未发现具体原因 暂时减一处理
|
|
104
|
+
// 上边线
|
|
105
|
+
this.canvas.add(this.drawLine([0, 0, curEndX, 0], { ...this.girdLineStyle }));
|
|
106
|
+
// 右边线
|
|
107
|
+
this.canvas.add(this.drawLine([topTotal.width ? curEndX - 1 : curEndX, 0, topTotal.width ? curEndX - 1 : curEndX, canvasHeight], { ...this.girdLineStyle }));
|
|
108
|
+
// 下边线
|
|
109
|
+
this.canvas.add(this.drawLine([0, canvasHeight - 1, curEndX, canvasHeight - 1], { ...this.girdLineStyle }));
|
|
110
|
+
// 左侧边框线
|
|
111
|
+
this.canvas.add(this.drawLine([0, 0, 0, canvasHeight], { ...this.girdLineStyle }));
|
|
112
|
+
},
|
|
113
|
+
createEvent() {
|
|
114
|
+
this.canvas.on('mouse:up', event => {
|
|
115
|
+
if (event.button === 3) {
|
|
116
|
+
const { x, y } = event.pointer;
|
|
117
|
+
const { originX, originY, endX, endY } = this.$propItems();
|
|
118
|
+
if (!(x < originX || x > endX || y < originY || y > endY)) {
|
|
119
|
+
this.activeEvent = event;
|
|
120
|
+
document.querySelector('.upper-canvas').addEventListener('contextmenu', this.addEventListenerContextmenu, true);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
// 打开右键菜单
|
|
126
|
+
openRightModal(event) {
|
|
127
|
+
this.rightPos = {
|
|
128
|
+
clientX: event.e.clientX || event.e.pageX,
|
|
129
|
+
clientY: event.e.clientY || event.e.pageY
|
|
130
|
+
};
|
|
131
|
+
this.isRightVisible = false;
|
|
132
|
+
const target = event.target;
|
|
133
|
+
const id = target ? target.id : '';
|
|
134
|
+
this.$nextTick(() => {
|
|
135
|
+
if (id && id.includes('_other')) {
|
|
136
|
+
this._currentPoint = target || '';
|
|
137
|
+
this.rightClickNode = Object.freeze(rightClickNode.slice());
|
|
138
|
+
this.isRightVisible = true;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
// 关闭右键菜单,打开添加节点弹窗表单
|
|
143
|
+
handleRightClick({ type }) {
|
|
144
|
+
this.isRightVisible = false;
|
|
145
|
+
const text = this._currentPoint;
|
|
146
|
+
this._currentPoint = '';
|
|
147
|
+
const obj = {
|
|
148
|
+
type: text.type,
|
|
149
|
+
index: text.index,
|
|
150
|
+
dataIndex: text.dataIndex
|
|
151
|
+
};
|
|
152
|
+
this.$emit(`${type}Other`, obj);
|
|
153
|
+
},
|
|
154
|
+
removeOther() {
|
|
155
|
+
this.canvas.forEachObject(obj => {
|
|
156
|
+
if (obj.id && obj.id.includes('_other')) {
|
|
157
|
+
this.canvas.remove(obj);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
drawTopTotal(topTotalList) {
|
|
162
|
+
const { endX, canvasWidth, yCellHeightTop, topTotal, endYTop, spaceHeight } = this.propItems;
|
|
163
|
+
const textList = [];
|
|
164
|
+
const left = endX + (canvasWidth - endX) / 2;
|
|
165
|
+
topTotalList.forEach((v, i) => {
|
|
166
|
+
const top = i * yCellHeightTop + yCellHeightTop / 2;
|
|
167
|
+
const text = v
|
|
168
|
+
? new this.fabric.Text(String(v), {
|
|
169
|
+
...defaultVaule.style,
|
|
170
|
+
...(topTotal.style || defaultVaule.textStyle),
|
|
171
|
+
left,
|
|
172
|
+
top,
|
|
173
|
+
originX: 'center',
|
|
174
|
+
originY: 'center'
|
|
175
|
+
})
|
|
176
|
+
: null;
|
|
177
|
+
text && textList.push(text);
|
|
178
|
+
});
|
|
179
|
+
const title = this.drawTextGroup(
|
|
180
|
+
{ width: canvasWidth - endX, height: spaceHeight, strokeWidth: 1 },
|
|
181
|
+
{ text: String(topTotal.title), ...(topTotal.style || defaultVaule.textStyle) },
|
|
182
|
+
{ left: endX, top: endYTop }
|
|
183
|
+
);
|
|
184
|
+
this.canvas.add(...textList, title);
|
|
185
|
+
},
|
|
186
|
+
topTreeTextGroup(list) {
|
|
187
|
+
list.forEach(item => {
|
|
188
|
+
if (item?.children?.length) {
|
|
189
|
+
this.canvas.add(
|
|
190
|
+
this.drawTextGroup(
|
|
191
|
+
{ width: item.width, height: item.height, strokeWidth: 1 },
|
|
192
|
+
{ text: String(item.title), ...(this.templateData.top.treeTableTextStyle || {}) },
|
|
193
|
+
{ left: item.left, top: item.top }
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
this.topTreeTextGroup(item.children);
|
|
197
|
+
} else {
|
|
198
|
+
// 此处的文本text的中心源的定位由于draw.js中封装反向的,所以此时文本需要向左排列originX值应为right
|
|
199
|
+
this.canvas.add(
|
|
200
|
+
this.drawTextGroup(
|
|
201
|
+
{ width: item.width, height: item.height, strokeWidth: 1 },
|
|
202
|
+
{ text: String(item.title), ...(this.templateData.top.treeTableTextStyle || {}), originX: 'right', left: -Math.floor(item.width / 2) + 5 },
|
|
203
|
+
{ left: item.left, top: item.top }
|
|
204
|
+
)
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// 绘制x轴下方的数据
|
|
211
|
+
drawTextDataGroup(obj) {
|
|
212
|
+
if (obj.list) {
|
|
213
|
+
this.drawTextDataGroupList(obj.list);
|
|
214
|
+
}
|
|
215
|
+
if (obj.colList) {
|
|
216
|
+
this.drawTextDataGroupColList(obj.colList);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
drawTextDataGroupColList(colList) {
|
|
220
|
+
const { originY } = this.propItems;
|
|
221
|
+
let textList = [];
|
|
222
|
+
colList.forEach((item, index) => {
|
|
223
|
+
const baseTop = originY + (item.marginTop || 10);
|
|
224
|
+
if (this.isLimit(item.scalevalue)) {
|
|
225
|
+
item.dataList.forEach((v, i) => {
|
|
226
|
+
const top = baseTop + i * (item.lineHeight || 15);
|
|
227
|
+
const text = new this.fabric.Text(String(v.value), {
|
|
228
|
+
...defaultVaule.style,
|
|
229
|
+
...defaultVaule.textStyle,
|
|
230
|
+
...item.style,
|
|
231
|
+
originX: 'left',
|
|
232
|
+
originY: 'center',
|
|
233
|
+
left: this.cumputedX(item.scalevalue),
|
|
234
|
+
top,
|
|
235
|
+
lockMovementX: true,
|
|
236
|
+
lockMovementY: true,
|
|
237
|
+
dataIndex: index,
|
|
238
|
+
index: i,
|
|
239
|
+
type: 'colList',
|
|
240
|
+
id: `${index}_${i}_other_${Date.now()}`,
|
|
241
|
+
...this.eventStyle
|
|
242
|
+
});
|
|
243
|
+
text.hasControls = text.hasBorders = false;
|
|
244
|
+
textList.push(text);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
this.canvas.add(...textList);
|
|
249
|
+
},
|
|
250
|
+
drawTextDataGroupList(list) {
|
|
251
|
+
let textList = [];
|
|
252
|
+
const { originX, originY } = this.propItems;
|
|
253
|
+
let top = originY + 10;
|
|
254
|
+
list.forEach((item, index) => {
|
|
255
|
+
const marginLeft = item.titleStyle?.marginLeft || 8;
|
|
256
|
+
const left = originX - marginLeft; // 防止最左边的数据与名称显示重合了
|
|
257
|
+
|
|
258
|
+
if (list[index - 1]) {
|
|
259
|
+
top += item.lineHeight || 15;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const title = new this.fabric.Text(String(item.title), {
|
|
263
|
+
...defaultVaule.style,
|
|
264
|
+
...defaultVaule.textStyle,
|
|
265
|
+
...item.style,
|
|
266
|
+
...(item.titleStyle || {}),
|
|
267
|
+
originX: 'right',
|
|
268
|
+
originY: 'center',
|
|
269
|
+
left,
|
|
270
|
+
top,
|
|
271
|
+
id: `${index}_other_${Date.now()}`
|
|
272
|
+
});
|
|
273
|
+
textList.push(title);
|
|
274
|
+
item.dataList.forEach((v, i) => {
|
|
275
|
+
if (this.isLimit(v.time)) {
|
|
276
|
+
const text = new this.fabric.Text(String(v.value), {
|
|
277
|
+
...defaultVaule.style,
|
|
278
|
+
...defaultVaule.textStyle,
|
|
279
|
+
...item.style,
|
|
280
|
+
originX: 'center',
|
|
281
|
+
originY: 'center',
|
|
282
|
+
left: this.cumputedX(v.time),
|
|
283
|
+
top,
|
|
284
|
+
lockMovementX: true,
|
|
285
|
+
lockMovementY: true,
|
|
286
|
+
dataIndex: index,
|
|
287
|
+
index: i,
|
|
288
|
+
type: 'list',
|
|
289
|
+
id: `${index}_${i}_other_${Date.now()}`,
|
|
290
|
+
...this.eventStyle
|
|
291
|
+
});
|
|
292
|
+
text.hasControls = text.hasBorders = false;
|
|
293
|
+
textList.push(text);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
this.canvas.add(...textList);
|
|
298
|
+
},
|
|
299
|
+
// 判断当前时间是否超出网格区域
|
|
300
|
+
isLimit(value) {
|
|
301
|
+
const { xScaleList } = this.propItems;
|
|
302
|
+
const minTime = Math.min(...xScaleList);
|
|
303
|
+
const maxTime = Math.max(...xScaleList);
|
|
304
|
+
const time = new Date(value).getTime();
|
|
305
|
+
return time >= minTime && time <= maxTime;
|
|
306
|
+
},
|
|
307
|
+
removeMark() {
|
|
308
|
+
this.canvas.forEachObject(obj => {
|
|
309
|
+
if (obj.type && obj.type === 'mark') {
|
|
310
|
+
this.canvas.remove(obj);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
// 底部标记
|
|
315
|
+
drawBottomTextDataGroup(obj) {
|
|
316
|
+
if (!obj.list) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const { endX, originX, endY, canvasHeight, topTotal } = this.propItems;
|
|
320
|
+
topTotal.width && this.canvas.add(this.drawLine([endX, endY - 1, endX, canvasHeight], { ...this.defaultRectStyle }));
|
|
321
|
+
// const textList = [];
|
|
322
|
+
const marginLeft = this.templateData.left.leftYScalevalue.spaceGridNumber || defaultVaule.spaceGridNumber;
|
|
323
|
+
const left = originX - marginLeft * 4; // 默认减去4倍的左边距,防止最左边的数据与名称显示重合了
|
|
324
|
+
const title = new this.fabric.Text(String(obj.title), {
|
|
325
|
+
...defaultVaule.style,
|
|
326
|
+
...defaultVaule.textStyle,
|
|
327
|
+
...obj.style,
|
|
328
|
+
originX: 'right',
|
|
329
|
+
originY: 'center',
|
|
330
|
+
left,
|
|
331
|
+
top: endY + (canvasHeight - endY) / 2,
|
|
332
|
+
type: 'mark'
|
|
333
|
+
});
|
|
334
|
+
this.canvas.add(title);
|
|
335
|
+
// textList.push(title);
|
|
336
|
+
const baseY = endY + 2; // 目前固定10像素的下边距
|
|
337
|
+
const baseYLimit = endY - 2; // 目前固定10像素的上边距
|
|
338
|
+
const lineHeightText = (obj.style?.fontSize || 12) + 2;
|
|
339
|
+
const lineHeightImg = (obj.iconStyle?.height || 12) + 2;
|
|
340
|
+
const lineHeightSeq = (obj.seqStyle?.circle?.radius || 9) * 2 + 2;
|
|
341
|
+
obj.list.forEach((item, index) => {
|
|
342
|
+
let limitIndex = -1; // 标志点是否往上排列的标志,大于-1则表示需要往上排列
|
|
343
|
+
let y = baseY;
|
|
344
|
+
const x = this.cumputedX(item[0]);
|
|
345
|
+
if (this.isLimit(item[0])) {
|
|
346
|
+
item[1].forEach(async (v, i) => {
|
|
347
|
+
const common = {
|
|
348
|
+
left: x,
|
|
349
|
+
originX: 'center',
|
|
350
|
+
originY: 'center',
|
|
351
|
+
data: v.data || {},
|
|
352
|
+
other: v.other || {},
|
|
353
|
+
time: item[0],
|
|
354
|
+
name: v.name,
|
|
355
|
+
type: 'mark'
|
|
356
|
+
};
|
|
357
|
+
function setTop(lineHeight) {
|
|
358
|
+
if (!~limitIndex) {
|
|
359
|
+
y += i === 0 ? lineHeight / 2 : lineHeight;
|
|
360
|
+
if (y >= canvasHeight - lineHeight / 2) {
|
|
361
|
+
limitIndex++;
|
|
362
|
+
if (limitIndex === 0) {
|
|
363
|
+
y = baseYLimit;
|
|
364
|
+
y -= lineHeight / 2;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
y -= lineHeight;
|
|
369
|
+
}
|
|
370
|
+
common.top = y;
|
|
371
|
+
}
|
|
372
|
+
const eventStyle = !this.eventStyle.evented
|
|
373
|
+
? {
|
|
374
|
+
lockMovementX: true,
|
|
375
|
+
lockMovementY: true
|
|
376
|
+
}
|
|
377
|
+
: {};
|
|
378
|
+
|
|
379
|
+
const addCanvas = async point => {
|
|
380
|
+
point.hasControls = point.hasBorders = false;
|
|
381
|
+
this.pointEvent(point);
|
|
382
|
+
this.canvas.add(point);
|
|
383
|
+
this.canvas.requestRenderAll();
|
|
384
|
+
};
|
|
385
|
+
if (this.isObject(v) && !v.value) {
|
|
386
|
+
setTop(lineHeightImg);
|
|
387
|
+
const option = Object.assign({}, obj.iconStyle || {}, v || {}, {
|
|
388
|
+
...common,
|
|
389
|
+
...eventStyle
|
|
390
|
+
});
|
|
391
|
+
let ele;
|
|
392
|
+
if (v?.iconClassName) {
|
|
393
|
+
ele = await this.createImage(v.iconClassName, v);
|
|
394
|
+
}
|
|
395
|
+
const img = await this.createPoint(v?.url || v?.iconClassName ? 'img' : v.type, {
|
|
396
|
+
ele: ele || '',
|
|
397
|
+
...option
|
|
398
|
+
});
|
|
399
|
+
addCanvas(img);
|
|
400
|
+
} else if (v.value) {
|
|
401
|
+
if (v.seq) {
|
|
402
|
+
setTop(lineHeightSeq);
|
|
403
|
+
// 标记增加序号
|
|
404
|
+
const circle = await this.createPoint('circle', {
|
|
405
|
+
...common,
|
|
406
|
+
radius: 5,
|
|
407
|
+
strokeWidth: 1,
|
|
408
|
+
stroke: '#000',
|
|
409
|
+
fill: 'transparent',
|
|
410
|
+
...(obj.seqStyle?.circle || {})
|
|
411
|
+
});
|
|
412
|
+
const text = new this.fabric.Text(String(v.value), {
|
|
413
|
+
...defaultVaule.textStyle,
|
|
414
|
+
...common,
|
|
415
|
+
...(obj.seqStyle?.text || {})
|
|
416
|
+
});
|
|
417
|
+
const group = new this.fabric.Group([circle, text], {
|
|
418
|
+
...common,
|
|
419
|
+
// hoverCursor: 'default',
|
|
420
|
+
...eventStyle
|
|
421
|
+
});
|
|
422
|
+
addCanvas(group);
|
|
423
|
+
} else {
|
|
424
|
+
setTop(lineHeightText);
|
|
425
|
+
const text = new this.fabric.Text(String(v.value), {
|
|
426
|
+
...defaultVaule.textStyle,
|
|
427
|
+
...obj.style,
|
|
428
|
+
...common,
|
|
429
|
+
...eventStyle
|
|
430
|
+
});
|
|
431
|
+
addCanvas(text);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
// this.canvas.add(...textList);
|
|
438
|
+
},
|
|
439
|
+
pointEvent(point) {
|
|
440
|
+
point.on('mouseover', () => {
|
|
441
|
+
this.showDrapPopup(point, true);
|
|
442
|
+
});
|
|
443
|
+
point.on('mouseout', () => {
|
|
444
|
+
this.isDropVisible = false;
|
|
445
|
+
});
|
|
446
|
+
// 移动中 实时更新相关联的线的坐标
|
|
447
|
+
if (this.eventStyle.evented) {
|
|
448
|
+
point.on('moving', () => {
|
|
449
|
+
this.moveLimit(point);
|
|
450
|
+
this.canvas.renderAll();
|
|
451
|
+
this.showDrapPopup(point);
|
|
452
|
+
});
|
|
453
|
+
point.on('moved', () => {
|
|
454
|
+
this.isDropVisible = false;
|
|
455
|
+
const value = {
|
|
456
|
+
data: point.data,
|
|
457
|
+
oldVal: point.time,
|
|
458
|
+
newVal: this.getXValue(point.left)
|
|
459
|
+
};
|
|
460
|
+
this.$emit('markChange', value);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
moveLimit(point) {
|
|
465
|
+
point.setCoords();
|
|
466
|
+
const { originX, endX, originY, canvasHeight } = this.propItems;
|
|
467
|
+
const bottom = this.templateData.bottom;
|
|
468
|
+
// 如果是起始标记,如入手术室时间
|
|
469
|
+
if (point.other?.isStart) {
|
|
470
|
+
const newList = JSON.parse(JSON.stringify(bottom.list)).sort((a, b) => {
|
|
471
|
+
return new Date(a[0]).getTime() - new Date(b[0]).getTime();
|
|
472
|
+
});
|
|
473
|
+
const obj = newList.find(v => {
|
|
474
|
+
const isStart = v[1].some(k => k.other?.isStart);
|
|
475
|
+
return !isStart && new Date(v[0]).getTime() >= new Date(point.time).getTime();
|
|
476
|
+
});
|
|
477
|
+
const limitRight = obj ? this.cumputedX(obj[0]) : endX;
|
|
478
|
+
if (point.left > limitRight) {
|
|
479
|
+
point.set('left', limitRight);
|
|
480
|
+
}
|
|
481
|
+
if (point.left < originX) {
|
|
482
|
+
point.set('left', originX);
|
|
483
|
+
}
|
|
484
|
+
} else {
|
|
485
|
+
const startList = bottom.list.find(v => v[1].some(k => k.other?.isStart));
|
|
486
|
+
const leftId = point.other?.limitLeft;
|
|
487
|
+
const limitLeftTime = leftId ? bottom.list.find(v => v[1].some(k => k.data?.id && k.data?.id === leftId))[0] : null;
|
|
488
|
+
const rightId = point.other?.limitRight;
|
|
489
|
+
const limitRightTime = rightId ? bottom.list.find(v => v[1].some(k => k.data?.id && k.data?.id === rightId))[0] : null;
|
|
490
|
+
const limitLeft =
|
|
491
|
+
(limitLeftTime && !startList) || (limitLeftTime && startList && new Date(limitLeftTime).getTime() >= new Date(startList[0]).getTime())
|
|
492
|
+
? this.cumputedX(limitLeftTime)
|
|
493
|
+
: (!limitLeftTime && startList) || (limitLeftTime && startList && new Date(limitLeftTime).getTime() < new Date(startList[0]).getTime())
|
|
494
|
+
? this.cumputedX(startList[0])
|
|
495
|
+
: originX;
|
|
496
|
+
const limitRight = limitRightTime ? this.cumputedX(limitRightTime) : endX;
|
|
497
|
+
if (point.left > limitRight) {
|
|
498
|
+
point.set('left', limitRight);
|
|
499
|
+
}
|
|
500
|
+
if (point.left < limitLeft) {
|
|
501
|
+
point.set('left', limitLeft);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (point.top > canvasHeight - 14) {
|
|
505
|
+
point.set('top', canvasHeight - 14);
|
|
506
|
+
}
|
|
507
|
+
if (point.top < originY) {
|
|
508
|
+
point.set('top', originY);
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
showDrapPopup(point) {
|
|
512
|
+
// 第二个参数表示需要展示提供的viewTime时间
|
|
513
|
+
this.isDropVisible = true;
|
|
514
|
+
this.dropPos = {
|
|
515
|
+
left: point.left,
|
|
516
|
+
top: point.top,
|
|
517
|
+
margin: { top: this.propItems.yCellHeight }
|
|
518
|
+
};
|
|
519
|
+
const x = arguments.length > 1 && point.other?.viewTime ? point.other.viewTime : this.getXValue(point.left);
|
|
520
|
+
this.dropVal = {
|
|
521
|
+
title: point.name || '',
|
|
522
|
+
list: [{ id: '1', name: '时间', value: x }]
|
|
523
|
+
};
|
|
524
|
+
},
|
|
525
|
+
|
|
526
|
+
drawLeftScaleGroup(dataLeft) {
|
|
527
|
+
this.drawLeftTitle(dataLeft);
|
|
528
|
+
const { canvasHeight, originX, originY, treeTableminCellWidth } = this.propItems;
|
|
529
|
+
let rect = new this.fabric.Rect({
|
|
530
|
+
left: treeTableminCellWidth,
|
|
531
|
+
top: originY,
|
|
532
|
+
width: originX - treeTableminCellWidth,
|
|
533
|
+
height: canvasHeight - originY,
|
|
534
|
+
...defaultVaule.rectStyle,
|
|
535
|
+
...defaultVaule.style,
|
|
536
|
+
originX: 'left',
|
|
537
|
+
originY: 'top'
|
|
538
|
+
});
|
|
539
|
+
rect.sendToBack(); // 向下跳底层
|
|
540
|
+
this.canvas.add(rect);
|
|
541
|
+
},
|
|
542
|
+
drawLeftTitle(dataLeft) {
|
|
543
|
+
if (dataLeft.title) {
|
|
544
|
+
this.canvas.add(
|
|
545
|
+
this.drawTextGroup(
|
|
546
|
+
{ width: this.propItems.treeTableminCellWidth, height: this.propItems.canvasHeight - this.propItems.originY },
|
|
547
|
+
{ text: String(dataLeft.title.split('').join('\n')), ...defaultVaule.textStyle, ...dataLeft.titleStyle },
|
|
548
|
+
{ left: 0, top: this.propItems.originY }
|
|
549
|
+
)
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
// render(h) {
|
|
555
|
+
// return this.$slots.default ? h('div', this.$slots.default) : undefined;
|
|
556
|
+
// }
|
|
557
|
+
};
|
|
558
|
+
</script>
|