gunter-kgd 1.0.4 → 1.0.6
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/components/gante_test/gante-gc-item-content.vue +22 -0
- package/components/gante_test/gante-gc-item.vue +183 -2
- package/components/gante_test/gante-gc.vue +20 -3
- package/components/gante_test/gante-split.vue +53 -12
- package/components/gante_test/gante-table.vue +72 -5
- package/components/gante_test/gante.vue +14 -4
- package/gante.vue +13 -3
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
<div
|
|
4
4
|
@mousemove.passive="showToast"
|
|
5
5
|
@mouseleave="hideToast"
|
|
6
|
+
@click.stop="handleClick"
|
|
6
7
|
@mousedown="dragDown($event,'drag')"
|
|
7
8
|
:style="{
|
|
8
9
|
cursor: DragObject.mouseDown ? 'grabbing' : 'grab',
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
requestId: '',
|
|
31
32
|
canShow: false,// 是否可以显示toast ,为了防止触发了mouseout事件后立马触发showToast事件
|
|
32
33
|
toastClassResolved: '',
|
|
34
|
+
justDragged: false,
|
|
33
35
|
DragObject:{
|
|
34
36
|
startX: 0, // 开始的位置
|
|
35
37
|
mouseDown: false,// 是否按下了鼠标
|
|
@@ -56,6 +58,19 @@
|
|
|
56
58
|
toastClass: String,
|
|
57
59
|
},
|
|
58
60
|
methods:{
|
|
61
|
+
handleClick(){
|
|
62
|
+
if(this.DragObject.mouseDown || this.justDragged){
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if(!this.current_data){
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
emitter.$emit('on-click', {
|
|
69
|
+
argument: 'taskBar',
|
|
70
|
+
value: this.current_data.gunter_id,
|
|
71
|
+
data: JSON.parse(JSON.stringify(this.current_data))
|
|
72
|
+
});
|
|
73
|
+
},
|
|
59
74
|
buildToastContent() {
|
|
60
75
|
if (!this.current_data || !this.current_data.params) {
|
|
61
76
|
this.toastClassResolved = (this.toastClass || '').trim();
|
|
@@ -159,6 +174,7 @@
|
|
|
159
174
|
dragDown(e,type){
|
|
160
175
|
if(this.current_data){
|
|
161
176
|
if(this.current_data.params){
|
|
177
|
+
this.justDragged = false;
|
|
162
178
|
this.DragObject.mouseDown = true;
|
|
163
179
|
this.DragObject.startX = e.clientX;
|
|
164
180
|
this.DragObject.move_type = type;
|
|
@@ -198,6 +214,7 @@
|
|
|
198
214
|
// 拖动时间
|
|
199
215
|
doc_move(e){
|
|
200
216
|
if(this.DragObject.mouseDown){
|
|
217
|
+
this.justDragged = true;
|
|
201
218
|
this.hideToast();
|
|
202
219
|
let move_mode_width = 0, // 宽度基值
|
|
203
220
|
move_mode_left = 0; // left基值
|
|
@@ -325,6 +342,11 @@
|
|
|
325
342
|
move_type: null,
|
|
326
343
|
};
|
|
327
344
|
this.hideToast();
|
|
345
|
+
if(this.justDragged){
|
|
346
|
+
setTimeout(() => {
|
|
347
|
+
this.justDragged = false;
|
|
348
|
+
}, 30);
|
|
349
|
+
}
|
|
328
350
|
}
|
|
329
351
|
}
|
|
330
352
|
}
|
|
@@ -13,7 +13,28 @@
|
|
|
13
13
|
:time_1px="time_1px"
|
|
14
14
|
:time_mode="time_mode"
|
|
15
15
|
:toast-render="toastRender"
|
|
16
|
-
:toast-class="toastClass"
|
|
16
|
+
:toast-class="toastClass"
|
|
17
|
+
:instance-id="instanceId"></ganteGcItemContent>
|
|
18
|
+
<button
|
|
19
|
+
v-if="shouldShowLocateStart(item)"
|
|
20
|
+
type="button"
|
|
21
|
+
class="gc-locate-btn gc-locate-btn--left"
|
|
22
|
+
title="定位到开始时间"
|
|
23
|
+
@mousedown.stop.prevent
|
|
24
|
+
@click.stop="locateItem(item,'start')"
|
|
25
|
+
:style="getLocateBtnStyle('left')">
|
|
26
|
+
<span class="gc-locate-btn__arrow"><</span>
|
|
27
|
+
</button>
|
|
28
|
+
<button
|
|
29
|
+
v-if="shouldShowLocateEnd(item)"
|
|
30
|
+
type="button"
|
|
31
|
+
class="gc-locate-btn gc-locate-btn--right"
|
|
32
|
+
title="定位到结束时间"
|
|
33
|
+
@mousedown.stop.prevent
|
|
34
|
+
@click.stop="locateItem(item,'end')"
|
|
35
|
+
:style="getLocateBtnStyle('right')">
|
|
36
|
+
<span class="gc-locate-btn__arrow">></span>
|
|
37
|
+
</button>
|
|
17
38
|
<!--<ganteDragCircle :current_data="item"></ganteDragCircle>-->
|
|
18
39
|
</div>
|
|
19
40
|
<ganteview-item
|
|
@@ -26,7 +47,8 @@
|
|
|
26
47
|
:time_mode="time_mode"
|
|
27
48
|
:toast-render="toastRender"
|
|
28
49
|
:toast-class="toastClass"
|
|
29
|
-
:gante_data="item.children"
|
|
50
|
+
:gante_data="item.children"
|
|
51
|
+
:instance-id="instanceId">
|
|
30
52
|
<span style="display: none">1</span>
|
|
31
53
|
</ganteview-item>
|
|
32
54
|
</div>
|
|
@@ -36,6 +58,7 @@
|
|
|
36
58
|
</template>
|
|
37
59
|
<script>
|
|
38
60
|
import ganteGcItemContent from './gante-gc-item-content'
|
|
61
|
+
import commitEmit from './commit'
|
|
39
62
|
// import ganteDragCircle from './gante-drag-circle'
|
|
40
63
|
export default {
|
|
41
64
|
name: 'ganteview-item',
|
|
@@ -46,6 +69,10 @@
|
|
|
46
69
|
return {
|
|
47
70
|
canAnimation: false,
|
|
48
71
|
bol: false,
|
|
72
|
+
scrollInfo:{
|
|
73
|
+
scrollLeft: 0,
|
|
74
|
+
clientWidth: 0,
|
|
75
|
+
}
|
|
49
76
|
}
|
|
50
77
|
},
|
|
51
78
|
props: {
|
|
@@ -57,8 +84,129 @@
|
|
|
57
84
|
end_time: {},
|
|
58
85
|
toastRender: Function,
|
|
59
86
|
toastClass: String,
|
|
87
|
+
instanceId: String,
|
|
88
|
+
},
|
|
89
|
+
created() {
|
|
90
|
+
this._onGcScroll = (info = {}) => {
|
|
91
|
+
if(info && typeof info === 'object' && (!info.instanceId || info.instanceId === this.instanceId)){
|
|
92
|
+
this.scrollInfo.scrollLeft = Number(info.scrollLeft) || 0
|
|
93
|
+
this.scrollInfo.clientWidth = Number(info.clientWidth) || 0
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
commitEmit.$on('gc-scroll', this._onGcScroll)
|
|
97
|
+
},
|
|
98
|
+
destroyed() {
|
|
99
|
+
if(this._onGcScroll){
|
|
100
|
+
commitEmit.$off('gc-scroll', this._onGcScroll)
|
|
101
|
+
this._onGcScroll = null
|
|
102
|
+
}
|
|
60
103
|
},
|
|
61
104
|
methods: {
|
|
105
|
+
getScroller(){
|
|
106
|
+
if(this.$el && this.$el.closest){
|
|
107
|
+
const found = this.$el.closest('.ganteview')
|
|
108
|
+
if(found){
|
|
109
|
+
return found
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return document.getElementsByClassName('ganteview')[0] || null
|
|
113
|
+
},
|
|
114
|
+
getItemRange(item){
|
|
115
|
+
const start = Number(item && item.left) || 0
|
|
116
|
+
const width = Number(item && item.width) || 0
|
|
117
|
+
const end = start + width
|
|
118
|
+
return { start, end }
|
|
119
|
+
},
|
|
120
|
+
getLocateBtnStyle(side){
|
|
121
|
+
const padding = 6
|
|
122
|
+
const btnWidth = 18
|
|
123
|
+
const viewLeft = Number(this.scrollInfo.scrollLeft) || 0
|
|
124
|
+
const viewWidth = Number(this.scrollInfo.clientWidth) || 0
|
|
125
|
+
if(!viewWidth){
|
|
126
|
+
return {}
|
|
127
|
+
}
|
|
128
|
+
let left = viewLeft + padding
|
|
129
|
+
if(side === 'right'){
|
|
130
|
+
left = viewLeft + viewWidth - btnWidth - padding
|
|
131
|
+
if(left < viewLeft + padding){
|
|
132
|
+
left = viewLeft + padding
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return { left: left + 'px' }
|
|
136
|
+
},
|
|
137
|
+
shouldShowLocateStart(item){
|
|
138
|
+
if(!item || item.left == null || !this.scrollInfo.clientWidth){
|
|
139
|
+
return false
|
|
140
|
+
}
|
|
141
|
+
const { start, end } = this.getItemRange(item)
|
|
142
|
+
const barEnd = end || start
|
|
143
|
+
const padding = 20
|
|
144
|
+
const viewStart = this.scrollInfo.scrollLeft
|
|
145
|
+
const viewEnd = viewStart + this.scrollInfo.clientWidth
|
|
146
|
+
const fullyLeft = barEnd < viewStart
|
|
147
|
+
const fullyRight = start > viewEnd
|
|
148
|
+
if(fullyLeft){
|
|
149
|
+
return true
|
|
150
|
+
}
|
|
151
|
+
if(fullyRight){
|
|
152
|
+
return false
|
|
153
|
+
}
|
|
154
|
+
return start < viewStart + padding
|
|
155
|
+
},
|
|
156
|
+
shouldShowLocateEnd(item){
|
|
157
|
+
if(!item || item.left == null || !this.scrollInfo.clientWidth){
|
|
158
|
+
return false
|
|
159
|
+
}
|
|
160
|
+
const { start, end } = this.getItemRange(item)
|
|
161
|
+
const barEnd = end || start
|
|
162
|
+
const padding = 20
|
|
163
|
+
const viewStart = this.scrollInfo.scrollLeft
|
|
164
|
+
const viewEnd = viewStart + this.scrollInfo.clientWidth
|
|
165
|
+
const fullyLeft = barEnd < viewStart
|
|
166
|
+
const fullyRight = start > viewEnd
|
|
167
|
+
if(fullyRight){
|
|
168
|
+
return true
|
|
169
|
+
}
|
|
170
|
+
if(fullyLeft){
|
|
171
|
+
return false
|
|
172
|
+
}
|
|
173
|
+
return barEnd > viewEnd - padding
|
|
174
|
+
},
|
|
175
|
+
locateItem(item,edge){
|
|
176
|
+
const scroller = this.getScroller()
|
|
177
|
+
if(!scroller){
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
const { start, end } = this.getItemRange(item)
|
|
181
|
+
const viewStart = scroller.scrollLeft
|
|
182
|
+
const viewEnd = viewStart + scroller.clientWidth
|
|
183
|
+
const padding = 20
|
|
184
|
+
let nextScroll = null
|
|
185
|
+
|
|
186
|
+
if(edge === 'start'){
|
|
187
|
+
if(start < viewStart + padding || start > viewEnd - padding){
|
|
188
|
+
nextScroll = Math.max(start - padding,0)
|
|
189
|
+
}
|
|
190
|
+
}else{
|
|
191
|
+
const targetEdge = end || start
|
|
192
|
+
if(targetEdge > viewEnd - padding || targetEdge < viewStart + padding){
|
|
193
|
+
nextScroll = Math.max(targetEdge - scroller.clientWidth + padding,0)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if(nextScroll === null){
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
const maxScroll = Math.max(0,(scroller.scrollWidth || 0) - scroller.clientWidth)
|
|
200
|
+
const resolved = Math.min(nextScroll,maxScroll)
|
|
201
|
+
if(Math.abs(resolved - viewStart) < 1){
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
if(scroller.scrollTo){
|
|
205
|
+
scroller.scrollTo({left: resolved,behavior:'smooth'})
|
|
206
|
+
}else{
|
|
207
|
+
scroller.scrollLeft = resolved
|
|
208
|
+
}
|
|
209
|
+
},
|
|
62
210
|
// 进入到了tr上
|
|
63
211
|
enterTr(ev, tr) {
|
|
64
212
|
this.$set(tr, 'is_hover', true)
|
|
@@ -91,5 +239,38 @@
|
|
|
91
239
|
.ganteview-content-one.gj_hover_class{
|
|
92
240
|
background: rgba(246, 246, 246, 0.7);
|
|
93
241
|
}
|
|
242
|
+
.gc-locate-btn{
|
|
243
|
+
position: absolute;
|
|
244
|
+
top: 9px;
|
|
245
|
+
width: 18px;
|
|
246
|
+
height: 22px;
|
|
247
|
+
border-radius: 4px;
|
|
248
|
+
border: 1px solid rgba(0,0,0,0.12);
|
|
249
|
+
background: rgba(255,255,255,0.92);
|
|
250
|
+
cursor: pointer;
|
|
251
|
+
padding: 0;
|
|
252
|
+
display: inline-flex;
|
|
253
|
+
align-items: center;
|
|
254
|
+
justify-content: center;
|
|
255
|
+
color: #00a578;
|
|
256
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
257
|
+
z-index: 4;
|
|
258
|
+
&:hover{
|
|
259
|
+
background: #fff;
|
|
260
|
+
border-color: rgba(0,165,120,0.4);
|
|
261
|
+
}
|
|
262
|
+
.gc-locate-btn__arrow{
|
|
263
|
+
font-weight: 700;
|
|
264
|
+
font-size: 12px;
|
|
265
|
+
line-height: 1;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
.gc-locate-btn--left{
|
|
269
|
+
margin-right: 6px;
|
|
270
|
+
}
|
|
271
|
+
.gc-locate-btn--right{
|
|
272
|
+
margin-left: 6px;
|
|
273
|
+
margin-right: 6px;
|
|
274
|
+
}
|
|
94
275
|
|
|
95
276
|
</style>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div ref="ganteview" class="ganteview-box">
|
|
4
4
|
<div @scroll.passive="ganteview_scroll" class="ganteview">
|
|
5
5
|
<!-- <div class="current_move_time">{{current_move_time}}</div>-->
|
|
6
|
-
<div class="ganteview-header">
|
|
6
|
+
<div class="ganteview-header" :style="{width: header_width + 'px'}">
|
|
7
7
|
<div class="ganteview-toptime">
|
|
8
8
|
<div class="ganteview-headercell" :title="item.date" v-for="item in top_time_data"
|
|
9
9
|
:style="{width:item.width+'px',left:item.left+'px'}">{{item.date}}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
:time_mode="time_mode"
|
|
24
24
|
:toast-render="toastRender"
|
|
25
25
|
:toast-class="toastClass"
|
|
26
|
+
:instance-id="instanceId"
|
|
26
27
|
:style="{width:header_width+'px'}"
|
|
27
28
|
v-if="show_item"
|
|
28
29
|
class="ganteview-content-box"
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
end_time: {},
|
|
74
75
|
toastRender: Function,
|
|
75
76
|
toastClass: String,
|
|
77
|
+
instanceId: String,
|
|
76
78
|
},
|
|
77
79
|
methods: {
|
|
78
80
|
remove_before(item){
|
|
@@ -80,10 +82,18 @@
|
|
|
80
82
|
},
|
|
81
83
|
ganteview_scroll(e) {
|
|
82
84
|
// 让左侧表格跟随滚动
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
const container = this.$el && this.$el.closest ? this.$el.closest('.gante-box') : null
|
|
86
|
+
const tbody = container ? container.querySelector('.gante-tbody') : null
|
|
87
|
+
const header = this.$el ? this.$el.querySelector('.ganteview-header') : null
|
|
88
|
+
if(tbody){
|
|
89
|
+
tbody.style.top = -(e.target.scrollTop) + 'px'
|
|
90
|
+
}
|
|
91
|
+
if(header){
|
|
92
|
+
header.style.left = -(e.target.scrollLeft) + 'px'
|
|
93
|
+
}
|
|
85
94
|
this.$parent.show_calendar = false
|
|
86
95
|
let scrollEl = e.target
|
|
96
|
+
commitEmit.$emit('gc-scroll', { scrollLeft: scrollEl.scrollLeft, clientWidth: scrollEl.clientWidth, instanceId: this.instanceId })
|
|
87
97
|
if(scrollEl.scrollHeight <= scrollEl.scrollTop + scrollEl.clientHeight && this.requestBol){
|
|
88
98
|
this.requestBol = false
|
|
89
99
|
commitEmit.$emit('on-load')
|
|
@@ -186,6 +196,12 @@
|
|
|
186
196
|
this.get_top_time(mode, this.first_day, time, all_time, time_mode)
|
|
187
197
|
this.time_1px = time;
|
|
188
198
|
this.time_mode = time_mode;
|
|
199
|
+
this.$nextTick(() => {
|
|
200
|
+
const el = this.$el && this.$el.querySelector ? this.$el.querySelector('.ganteview') : null
|
|
201
|
+
if(el){
|
|
202
|
+
commitEmit.$emit('gc-scroll', { scrollLeft: el.scrollLeft, clientWidth: el.clientWidth, instanceId: this.instanceId })
|
|
203
|
+
}
|
|
204
|
+
})
|
|
189
205
|
return {time: time, start_time: start_time}
|
|
190
206
|
},
|
|
191
207
|
/**
|
|
@@ -380,6 +396,7 @@
|
|
|
380
396
|
height: 25px;
|
|
381
397
|
font-size: 13px;
|
|
382
398
|
z-index: 2;
|
|
399
|
+
background: #fff;
|
|
383
400
|
}
|
|
384
401
|
|
|
385
402
|
.ganteview-toptime, .ganteview-bottomtime {
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
<!--中间分割线,分割左侧表格和右侧图表-->
|
|
2
2
|
<template>
|
|
3
3
|
<div @mousedown="down" ref="split_liu" :style="{left:Number(left)?left+'px':left}" class="gante-split-liu">
|
|
4
|
-
<!--<div class="gante-split-column">-->
|
|
5
|
-
<!--<div></div>-->
|
|
6
|
-
<!--<div></div>-->
|
|
7
|
-
<!--<div></div>-->
|
|
8
|
-
<!--</div>-->
|
|
9
4
|
<div v-show="show_split" :style="{left:split_resize_left+'px'}" class="gante-split-liu-resize"></div>
|
|
10
5
|
</div>
|
|
11
6
|
</template>
|
|
@@ -17,14 +12,23 @@
|
|
|
17
12
|
return{
|
|
18
13
|
show_split:false,
|
|
19
14
|
split_resize_left:0,
|
|
20
|
-
mouseDown:false
|
|
15
|
+
mouseDown:false,
|
|
16
|
+
rafId: 0,
|
|
17
|
+
lastResizePayload: null,
|
|
21
18
|
}
|
|
22
19
|
},
|
|
23
|
-
props:
|
|
20
|
+
props:{
|
|
21
|
+
left: [Number,String],
|
|
22
|
+
th_data: Object,
|
|
23
|
+
onSplitResize: Function,
|
|
24
|
+
},
|
|
24
25
|
mounted(){
|
|
25
26
|
|
|
26
27
|
},
|
|
27
|
-
|
|
28
|
+
methods:{
|
|
29
|
+
getContainer(){
|
|
30
|
+
return this.$el && this.$el.closest ? this.$el.closest('.gante-box') : null;
|
|
31
|
+
},
|
|
28
32
|
// 获取元素距离浏览器的距离
|
|
29
33
|
getPos(ele){
|
|
30
34
|
var p=ele.offsetParent;
|
|
@@ -48,10 +52,15 @@
|
|
|
48
52
|
doc_move(e){
|
|
49
53
|
if(this.mouseDown){
|
|
50
54
|
var _body = document.getElementsByTagName('body')[0];
|
|
55
|
+
const container = this.getContainer();
|
|
56
|
+
const tableBox = container ? container.querySelector('.gante-table-box') : null;
|
|
57
|
+
const gcBox = container ? container.querySelector('.ganteview-box') : null;
|
|
58
|
+
if(!tableBox || !gcBox){
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
51
61
|
let _left = e.pageX - this.$refs.split_liu.getBoundingClientRect().left +3, // 移动的距离
|
|
52
|
-
_width =
|
|
53
|
-
_width_gc =
|
|
54
|
-
console.log(_left)
|
|
62
|
+
_width = tableBox.offsetWidth, // 表格的宽度
|
|
63
|
+
_width_gc = gcBox.offsetWidth; // 图表的宽度
|
|
55
64
|
if(_left + _width <= 480){
|
|
56
65
|
_left = 480 - _width
|
|
57
66
|
}
|
|
@@ -65,7 +74,13 @@
|
|
|
65
74
|
doc_up(){
|
|
66
75
|
if(this.mouseDown){
|
|
67
76
|
var _body = document.getElementsByTagName('body')[0]
|
|
68
|
-
|
|
77
|
+
const container = this.getContainer();
|
|
78
|
+
const tableBox = container ? container.querySelector('.gante-table-box') : null;
|
|
79
|
+
const gcBox = container ? container.querySelector('.ganteview-box') : null;
|
|
80
|
+
const baseTableWidth = tableBox ? tableBox.offsetWidth : 0;
|
|
81
|
+
const baseGanttWidth = gcBox ? gcBox.offsetWidth : 0;
|
|
82
|
+
const delta = this.split_resize_left;
|
|
83
|
+
this.$parent.tabe_width = delta + baseTableWidth;
|
|
69
84
|
this.find_attr(this.$parent.tabe_width,this.th_data)
|
|
70
85
|
this.show_split = false
|
|
71
86
|
this.split_resize_left = 0
|
|
@@ -74,8 +89,34 @@
|
|
|
74
89
|
_body.style.cursor = null
|
|
75
90
|
document.removeEventListener('mousemove',this.doc_move,false)
|
|
76
91
|
document.removeEventListener('mouseup',this.doc_up,false)
|
|
92
|
+
|
|
93
|
+
this.emitResize(this.$parent.tabe_width, baseGanttWidth - delta, true)
|
|
77
94
|
}
|
|
78
95
|
},
|
|
96
|
+
emitResize(tableWidth,ganttWidth,isFinal){
|
|
97
|
+
if(!isFinal){
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
if(typeof this.onSplitResize !== 'function'){
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
this.lastResizePayload = {
|
|
104
|
+
tableWidth,
|
|
105
|
+
ganttWidth,
|
|
106
|
+
isFinal,
|
|
107
|
+
}
|
|
108
|
+
if(this.rafId){
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
this.rafId = requestAnimationFrame(() => {
|
|
112
|
+
this.rafId = 0
|
|
113
|
+
if(!this.lastResizePayload){
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
this.onSplitResize(this.lastResizePayload)
|
|
117
|
+
this.lastResizePayload = null
|
|
118
|
+
})
|
|
119
|
+
},
|
|
79
120
|
down(){
|
|
80
121
|
this.mouseDown = true
|
|
81
122
|
this.show_split = true
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
proxy_left:0,
|
|
35
35
|
show_proxy:false,
|
|
36
|
+
rafId: 0,
|
|
37
|
+
lastResizePayload: null,
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
40
|
props:{
|
|
@@ -40,8 +42,53 @@
|
|
|
40
42
|
data:Array,
|
|
41
43
|
showLoading:Boolean,
|
|
42
44
|
cellSlots: Object,
|
|
45
|
+
onColumnResize: Function,
|
|
43
46
|
},
|
|
44
47
|
methods:{
|
|
48
|
+
getContainer(){
|
|
49
|
+
return this.$el && this.$el.closest ? this.$el.closest('.gante-box') : null;
|
|
50
|
+
},
|
|
51
|
+
getTableBox(){
|
|
52
|
+
const container = this.getContainer();
|
|
53
|
+
return container ? container.querySelector('.gante-table-box') : null;
|
|
54
|
+
},
|
|
55
|
+
collectColumnWidths(changedKey,changedWidth){
|
|
56
|
+
const columnWidths = {}
|
|
57
|
+
let tableWidth = 0
|
|
58
|
+
for(let key in this.th_data){
|
|
59
|
+
const th = this.th_data[key] || {}
|
|
60
|
+
if(th.show === false){
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
let width = th.width ? Number(th.width) : 80
|
|
64
|
+
if(changedKey && key === changedKey && typeof changedWidth === 'number' && !Number.isNaN(changedWidth)){
|
|
65
|
+
width = changedWidth
|
|
66
|
+
}
|
|
67
|
+
columnWidths[key] = width
|
|
68
|
+
tableWidth += width
|
|
69
|
+
}
|
|
70
|
+
return { columnWidths, tableWidth }
|
|
71
|
+
},
|
|
72
|
+
emitColumnResize(payload){
|
|
73
|
+
if(!payload || payload.isFinal !== true){
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
if(typeof this.onColumnResize !== 'function'){
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
this.lastResizePayload = payload
|
|
80
|
+
if(this.rafId){
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
this.rafId = requestAnimationFrame(() => {
|
|
84
|
+
this.rafId = 0
|
|
85
|
+
if(!this.lastResizePayload){
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
this.onColumnResize(this.lastResizePayload)
|
|
89
|
+
this.lastResizePayload = null
|
|
90
|
+
})
|
|
91
|
+
},
|
|
45
92
|
//排序
|
|
46
93
|
sortCaret(mode,key){
|
|
47
94
|
let cla = 'asc',assign_key = key
|
|
@@ -97,8 +144,12 @@
|
|
|
97
144
|
return; // 如果是水平滚动,直接返回不处理
|
|
98
145
|
}
|
|
99
146
|
let speed = -200
|
|
100
|
-
|
|
101
|
-
|
|
147
|
+
const container = this.$el && this.$el.closest ? this.$el.closest('.gante-box') : null
|
|
148
|
+
const ganteview = container ? container.querySelector('.ganteview') : null
|
|
149
|
+
if(!ganteview){
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
let scrollTop = ganteview.scrollTop
|
|
102
153
|
if(e.wheelDelta && e.wheelDelta < 0){//兼容IE,Opera,Chrome
|
|
103
154
|
speed = 200
|
|
104
155
|
}else if(e.detail > 0){
|
|
@@ -141,7 +192,11 @@
|
|
|
141
192
|
doc_move(e){
|
|
142
193
|
var _body = document.getElementsByTagName('body')[0]
|
|
143
194
|
if(this.tTD.mouseDown){
|
|
144
|
-
|
|
195
|
+
const gante_table_box = this.getTableBox()
|
|
196
|
+
if(!gante_table_box){
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
var gante_left = this.getPos(this.$refs.gante_table).x,cel = e.clientX
|
|
145
200
|
if(gante_table_box.scrollLeft){
|
|
146
201
|
cel = cel + gante_table_box.scrollLeft
|
|
147
202
|
}
|
|
@@ -159,7 +214,11 @@
|
|
|
159
214
|
if(e.target.tagName === 'SPAN' ||e.target.tagName === 'I'){
|
|
160
215
|
return;
|
|
161
216
|
}
|
|
162
|
-
|
|
217
|
+
const gante_table_box = this.getTableBox()
|
|
218
|
+
if(!gante_table_box){
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
var table_width = this.getPos(this.$refs.gante_table).x,target=e.target,client_x = e.clientX
|
|
163
222
|
if(target.classList.contains('cell')){
|
|
164
223
|
target = target.parentNode
|
|
165
224
|
}
|
|
@@ -184,7 +243,9 @@
|
|
|
184
243
|
// 设置拖动后的宽度
|
|
185
244
|
this.th_data[this.tTD.current_index].width = this.old_width+(this.proxy_left - this.oldx)
|
|
186
245
|
// 获取到左边表格所有td加起来的宽度
|
|
187
|
-
|
|
246
|
+
const gante_table_box = this.getTableBox()
|
|
247
|
+
const _width = gante_table_box ? gante_table_box.offsetWidth : 0;
|
|
248
|
+
let str = 0;
|
|
188
249
|
for(let key in this.th_data){
|
|
189
250
|
if(this.th_data[key].show != false){
|
|
190
251
|
str += this.th_data[key].width ? Number(this.th_data[key].width) + 1 : 81;
|
|
@@ -193,6 +254,12 @@
|
|
|
193
254
|
if(str < _width){
|
|
194
255
|
this.$parent.tabe_width = (str + 2) <= 480 ? 480 : (str + 2) + 'px';
|
|
195
256
|
}
|
|
257
|
+
const widths = this.collectColumnWidths()
|
|
258
|
+
this.emitColumnResize({
|
|
259
|
+
changedKey: this.tTD.current_index,
|
|
260
|
+
isFinal: true,
|
|
261
|
+
...widths
|
|
262
|
+
})
|
|
196
263
|
|
|
197
264
|
// 初始化所有的值
|
|
198
265
|
this.tTD.mouseDown = false
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
@sort="sortGunter"
|
|
19
19
|
:th_data="th_data"
|
|
20
20
|
:showLoading="showLoading"
|
|
21
|
-
:data="ganteData"
|
|
21
|
+
:data="ganteData"
|
|
22
|
+
:onColumnResize="onColumnResize">
|
|
22
23
|
|
|
23
24
|
</gante-table>
|
|
24
25
|
</div>
|
|
@@ -32,9 +33,10 @@
|
|
|
32
33
|
:th_data="th_data"
|
|
33
34
|
:gante_data="ganteData"
|
|
34
35
|
:toast-render="toastRender"
|
|
35
|
-
:toast-class="toastClass"
|
|
36
|
+
:toast-class="toastClass"
|
|
37
|
+
:instance-id="instanceId"></gante-gc>
|
|
36
38
|
</div>
|
|
37
|
-
<gante-split :left="tabe_width" :th_data="th_data"></gante-split>
|
|
39
|
+
<gante-split :left="tabe_width" :th_data="th_data" :onSplitResize="onSplitResize"></gante-split>
|
|
38
40
|
</div>
|
|
39
41
|
<!--日历-->
|
|
40
42
|
<calendar :left="calendar_left" :choose_date="checkDate" v-model="show_calendar" @change="chooseDate"
|
|
@@ -81,6 +83,9 @@
|
|
|
81
83
|
onClick: () => {},
|
|
82
84
|
onLoad: () => {},//懒加载
|
|
83
85
|
onDragChangeTime: () => {}, // 拖动改变时间
|
|
86
|
+
onSplitResize: () => {}, // 拖动分割线改变宽度回调
|
|
87
|
+
onColumnResize: () => {}, // 拖动列宽回调
|
|
88
|
+
instanceId: `gante-${Math.random().toString(36).slice(2)}`,
|
|
84
89
|
dropdownOptions: [
|
|
85
90
|
{ value: 1, label: '日' },
|
|
86
91
|
{ value: 2, label: '周' },
|
|
@@ -332,7 +337,12 @@
|
|
|
332
337
|
// 初始化
|
|
333
338
|
init(params,mode = true) {
|
|
334
339
|
|
|
335
|
-
Object.assign(
|
|
340
|
+
const cloneParams = Object.assign({}, params);
|
|
341
|
+
if(params.th_data){
|
|
342
|
+
cloneParams.th_data = JSON.parse(JSON.stringify(params.th_data));
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
Object.assign(this.$data, cloneParams);
|
|
336
346
|
|
|
337
347
|
if(params.ganteData == undefined){
|
|
338
348
|
let ganteData = JSON.parse(JSON.stringify(this.ganteData));
|
package/gante.vue
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
:th_data="th_data"
|
|
20
20
|
:showLoading="showLoading"
|
|
21
21
|
:data="ganteData"
|
|
22
|
+
:onColumnResize="onColumnResize"
|
|
22
23
|
:cell-slots="$scopedSlots">
|
|
23
24
|
|
|
24
25
|
</gante-table>
|
|
@@ -33,9 +34,10 @@
|
|
|
33
34
|
:th_data="th_data"
|
|
34
35
|
:gante_data="ganteData"
|
|
35
36
|
:toast-render="toastRender"
|
|
36
|
-
:toast-class="toastClass"
|
|
37
|
+
:toast-class="toastClass"
|
|
38
|
+
:instance-id="instanceId"></gante-gc>
|
|
37
39
|
</div>
|
|
38
|
-
<gante-split :left="tabe_width" :th_data="th_data"></gante-split>
|
|
40
|
+
<gante-split :left="tabe_width" :th_data="th_data" :onSplitResize="onSplitResize"></gante-split>
|
|
39
41
|
</div>
|
|
40
42
|
<!--日历-->
|
|
41
43
|
<calendar :left="calendar_left" :choose_date="checkDate" v-model="show_calendar" @change="chooseDate"
|
|
@@ -84,6 +86,9 @@
|
|
|
84
86
|
onClick: () => {},
|
|
85
87
|
onLoad: () => {},//懒加载
|
|
86
88
|
onDragChangeTime: () => {}, // 拖动改变时间
|
|
89
|
+
onSplitResize: () => {}, // 拖动分割线改变宽度回调
|
|
90
|
+
onColumnResize: () => {}, // 拖动列宽回调
|
|
91
|
+
instanceId: `gante-${Math.random().toString(36).slice(2)}`,
|
|
87
92
|
dropdownOptions: [
|
|
88
93
|
{ value: 1, label: '日' },
|
|
89
94
|
{ value: 2, label: '周' },
|
|
@@ -347,7 +352,12 @@
|
|
|
347
352
|
// 初始化
|
|
348
353
|
init(params,mode = true) {
|
|
349
354
|
|
|
350
|
-
Object.assign(
|
|
355
|
+
const cloneParams = Object.assign({}, params);
|
|
356
|
+
if(params.th_data){
|
|
357
|
+
cloneParams.th_data = JSON.parse(JSON.stringify(params.th_data));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
Object.assign(this.$data, cloneParams);
|
|
351
361
|
|
|
352
362
|
if(params.ganteData == undefined){
|
|
353
363
|
let ganteData = JSON.parse(JSON.stringify(this.ganteData));
|