gunter-kgd 1.0.5 → 1.0.7
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 +30 -0
- package/components/gante_test/gante-gc-item.vue +12 -3
- package/components/gante_test/gante-gc.vue +15 -5
- package/components/gante_test/gante-split.vue +17 -5
- package/components/gante_test/gante-table.vue +26 -5
- package/components/gante_test/gante.vue +9 -2
- package/gante.vue +9 -2
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<!--图表每个条块-->
|
|
2
2
|
<template>
|
|
3
3
|
<div
|
|
4
|
+
v-if="hasValidRange"
|
|
4
5
|
@mousemove.passive="showToast"
|
|
5
6
|
@mouseleave="hideToast"
|
|
7
|
+
@click.stop="handleClick"
|
|
6
8
|
@mousedown="dragDown($event,'drag')"
|
|
7
9
|
:style="{
|
|
8
10
|
cursor: DragObject.mouseDown ? 'grabbing' : 'grab',
|
|
@@ -30,6 +32,7 @@
|
|
|
30
32
|
requestId: '',
|
|
31
33
|
canShow: false,// 是否可以显示toast ,为了防止触发了mouseout事件后立马触发showToast事件
|
|
32
34
|
toastClassResolved: '',
|
|
35
|
+
justDragged: false,
|
|
33
36
|
DragObject:{
|
|
34
37
|
startX: 0, // 开始的位置
|
|
35
38
|
mouseDown: false,// 是否按下了鼠标
|
|
@@ -55,7 +58,27 @@
|
|
|
55
58
|
toastRender: Function,
|
|
56
59
|
toastClass: String,
|
|
57
60
|
},
|
|
61
|
+
computed: {
|
|
62
|
+
hasValidRange(){
|
|
63
|
+
const start = this.current_data && this.current_data.start_time
|
|
64
|
+
const end = this.current_data && this.current_data.end_time
|
|
65
|
+
return Number(start) > 0 && Number(end) > 0
|
|
66
|
+
}
|
|
67
|
+
},
|
|
58
68
|
methods:{
|
|
69
|
+
handleClick(){
|
|
70
|
+
if(this.DragObject.mouseDown || this.justDragged){
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if(!this.current_data){
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
emitter.$emit('on-click', {
|
|
77
|
+
argument: 'taskBar',
|
|
78
|
+
value: this.current_data.gunter_id,
|
|
79
|
+
data: JSON.parse(JSON.stringify(this.current_data))
|
|
80
|
+
});
|
|
81
|
+
},
|
|
59
82
|
buildToastContent() {
|
|
60
83
|
if (!this.current_data || !this.current_data.params) {
|
|
61
84
|
this.toastClassResolved = (this.toastClass || '').trim();
|
|
@@ -159,6 +182,7 @@
|
|
|
159
182
|
dragDown(e,type){
|
|
160
183
|
if(this.current_data){
|
|
161
184
|
if(this.current_data.params){
|
|
185
|
+
this.justDragged = false;
|
|
162
186
|
this.DragObject.mouseDown = true;
|
|
163
187
|
this.DragObject.startX = e.clientX;
|
|
164
188
|
this.DragObject.move_type = type;
|
|
@@ -198,6 +222,7 @@
|
|
|
198
222
|
// 拖动时间
|
|
199
223
|
doc_move(e){
|
|
200
224
|
if(this.DragObject.mouseDown){
|
|
225
|
+
this.justDragged = true;
|
|
201
226
|
this.hideToast();
|
|
202
227
|
let move_mode_width = 0, // 宽度基值
|
|
203
228
|
move_mode_left = 0; // left基值
|
|
@@ -325,6 +350,11 @@
|
|
|
325
350
|
move_type: null,
|
|
326
351
|
};
|
|
327
352
|
this.hideToast();
|
|
353
|
+
if(this.justDragged){
|
|
354
|
+
setTimeout(() => {
|
|
355
|
+
this.justDragged = false;
|
|
356
|
+
}, 30);
|
|
357
|
+
}
|
|
328
358
|
}
|
|
329
359
|
}
|
|
330
360
|
}
|
|
@@ -13,7 +13,8 @@
|
|
|
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>
|
|
17
18
|
<button
|
|
18
19
|
v-if="shouldShowLocateStart(item)"
|
|
19
20
|
type="button"
|
|
@@ -46,7 +47,8 @@
|
|
|
46
47
|
:time_mode="time_mode"
|
|
47
48
|
:toast-render="toastRender"
|
|
48
49
|
:toast-class="toastClass"
|
|
49
|
-
:gante_data="item.children"
|
|
50
|
+
:gante_data="item.children"
|
|
51
|
+
:instance-id="instanceId">
|
|
50
52
|
<span style="display: none">1</span>
|
|
51
53
|
</ganteview-item>
|
|
52
54
|
</div>
|
|
@@ -82,10 +84,11 @@
|
|
|
82
84
|
end_time: {},
|
|
83
85
|
toastRender: Function,
|
|
84
86
|
toastClass: String,
|
|
87
|
+
instanceId: String,
|
|
85
88
|
},
|
|
86
89
|
created() {
|
|
87
90
|
this._onGcScroll = (info = {}) => {
|
|
88
|
-
if(info && typeof info === 'object'){
|
|
91
|
+
if(info && typeof info === 'object' && (!info.instanceId || info.instanceId === this.instanceId)){
|
|
89
92
|
this.scrollInfo.scrollLeft = Number(info.scrollLeft) || 0
|
|
90
93
|
this.scrollInfo.clientWidth = Number(info.clientWidth) || 0
|
|
91
94
|
}
|
|
@@ -135,6 +138,9 @@
|
|
|
135
138
|
if(!item || item.left == null || !this.scrollInfo.clientWidth){
|
|
136
139
|
return false
|
|
137
140
|
}
|
|
141
|
+
if(!(Number(item.start_time) > 0 && Number(item.end_time) > 0)){
|
|
142
|
+
return false
|
|
143
|
+
}
|
|
138
144
|
const { start, end } = this.getItemRange(item)
|
|
139
145
|
const barEnd = end || start
|
|
140
146
|
const padding = 20
|
|
@@ -154,6 +160,9 @@
|
|
|
154
160
|
if(!item || item.left == null || !this.scrollInfo.clientWidth){
|
|
155
161
|
return false
|
|
156
162
|
}
|
|
163
|
+
if(!(Number(item.start_time) > 0 && Number(item.end_time) > 0)){
|
|
164
|
+
return false
|
|
165
|
+
}
|
|
157
166
|
const { start, end } = this.getItemRange(item)
|
|
158
167
|
const barEnd = end || start
|
|
159
168
|
const padding = 20
|
|
@@ -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,11 +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
|
|
87
|
-
commitEmit.$emit('gc-scroll', { scrollLeft: scrollEl.scrollLeft, clientWidth: scrollEl.clientWidth })
|
|
96
|
+
commitEmit.$emit('gc-scroll', { scrollLeft: scrollEl.scrollLeft, clientWidth: scrollEl.clientWidth, instanceId: this.instanceId })
|
|
88
97
|
if(scrollEl.scrollHeight <= scrollEl.scrollTop + scrollEl.clientHeight && this.requestBol){
|
|
89
98
|
this.requestBol = false
|
|
90
99
|
commitEmit.$emit('on-load')
|
|
@@ -190,7 +199,7 @@
|
|
|
190
199
|
this.$nextTick(() => {
|
|
191
200
|
const el = this.$el && this.$el.querySelector ? this.$el.querySelector('.ganteview') : null
|
|
192
201
|
if(el){
|
|
193
|
-
commitEmit.$emit('gc-scroll', { scrollLeft: el.scrollLeft, clientWidth: el.clientWidth })
|
|
202
|
+
commitEmit.$emit('gc-scroll', { scrollLeft: el.scrollLeft, clientWidth: el.clientWidth, instanceId: this.instanceId })
|
|
194
203
|
}
|
|
195
204
|
})
|
|
196
205
|
return {time: time, start_time: start_time}
|
|
@@ -387,6 +396,7 @@
|
|
|
387
396
|
height: 25px;
|
|
388
397
|
font-size: 13px;
|
|
389
398
|
z-index: 2;
|
|
399
|
+
background: #fff;
|
|
390
400
|
}
|
|
391
401
|
|
|
392
402
|
.ganteview-toptime, .ganteview-bottomtime {
|
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
mounted(){
|
|
26
26
|
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
methods:{
|
|
29
|
+
getContainer(){
|
|
30
|
+
return this.$el && this.$el.closest ? this.$el.closest('.gante-box') : null;
|
|
31
|
+
},
|
|
29
32
|
// 获取元素距离浏览器的距离
|
|
30
33
|
getPos(ele){
|
|
31
34
|
var p=ele.offsetParent;
|
|
@@ -49,9 +52,15 @@
|
|
|
49
52
|
doc_move(e){
|
|
50
53
|
if(this.mouseDown){
|
|
51
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
|
+
}
|
|
52
61
|
let _left = e.pageX - this.$refs.split_liu.getBoundingClientRect().left +3, // 移动的距离
|
|
53
|
-
_width =
|
|
54
|
-
_width_gc =
|
|
62
|
+
_width = tableBox.offsetWidth, // 表格的宽度
|
|
63
|
+
_width_gc = gcBox.offsetWidth; // 图表的宽度
|
|
55
64
|
if(_left + _width <= 480){
|
|
56
65
|
_left = 480 - _width
|
|
57
66
|
}
|
|
@@ -65,8 +74,11 @@
|
|
|
65
74
|
doc_up(){
|
|
66
75
|
if(this.mouseDown){
|
|
67
76
|
var _body = document.getElementsByTagName('body')[0]
|
|
68
|
-
const
|
|
69
|
-
const
|
|
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;
|
|
70
82
|
const delta = this.split_resize_left;
|
|
71
83
|
this.$parent.tabe_width = delta + baseTableWidth;
|
|
72
84
|
this.find_attr(this.$parent.tabe_width,this.th_data)
|
|
@@ -45,6 +45,13 @@
|
|
|
45
45
|
onColumnResize: Function,
|
|
46
46
|
},
|
|
47
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
|
+
},
|
|
48
55
|
collectColumnWidths(changedKey,changedWidth){
|
|
49
56
|
const columnWidths = {}
|
|
50
57
|
let tableWidth = 0
|
|
@@ -137,8 +144,12 @@
|
|
|
137
144
|
return; // 如果是水平滚动,直接返回不处理
|
|
138
145
|
}
|
|
139
146
|
let speed = -200
|
|
140
|
-
|
|
141
|
-
|
|
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
|
|
142
153
|
if(e.wheelDelta && e.wheelDelta < 0){//兼容IE,Opera,Chrome
|
|
143
154
|
speed = 200
|
|
144
155
|
}else if(e.detail > 0){
|
|
@@ -181,7 +192,11 @@
|
|
|
181
192
|
doc_move(e){
|
|
182
193
|
var _body = document.getElementsByTagName('body')[0]
|
|
183
194
|
if(this.tTD.mouseDown){
|
|
184
|
-
|
|
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
|
|
185
200
|
if(gante_table_box.scrollLeft){
|
|
186
201
|
cel = cel + gante_table_box.scrollLeft
|
|
187
202
|
}
|
|
@@ -199,7 +214,11 @@
|
|
|
199
214
|
if(e.target.tagName === 'SPAN' ||e.target.tagName === 'I'){
|
|
200
215
|
return;
|
|
201
216
|
}
|
|
202
|
-
|
|
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
|
|
203
222
|
if(target.classList.contains('cell')){
|
|
204
223
|
target = target.parentNode
|
|
205
224
|
}
|
|
@@ -224,7 +243,9 @@
|
|
|
224
243
|
// 设置拖动后的宽度
|
|
225
244
|
this.th_data[this.tTD.current_index].width = this.old_width+(this.proxy_left - this.oldx)
|
|
226
245
|
// 获取到左边表格所有td加起来的宽度
|
|
227
|
-
|
|
246
|
+
const gante_table_box = this.getTableBox()
|
|
247
|
+
const _width = gante_table_box ? gante_table_box.offsetWidth : 0;
|
|
248
|
+
let str = 0;
|
|
228
249
|
for(let key in this.th_data){
|
|
229
250
|
if(this.th_data[key].show != false){
|
|
230
251
|
str += this.th_data[key].width ? Number(this.th_data[key].width) + 1 : 81;
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
:th_data="th_data"
|
|
34
34
|
:gante_data="ganteData"
|
|
35
35
|
:toast-render="toastRender"
|
|
36
|
-
:toast-class="toastClass"
|
|
36
|
+
:toast-class="toastClass"
|
|
37
|
+
:instance-id="instanceId"></gante-gc>
|
|
37
38
|
</div>
|
|
38
39
|
<gante-split :left="tabe_width" :th_data="th_data" :onSplitResize="onSplitResize"></gante-split>
|
|
39
40
|
</div>
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
onDragChangeTime: () => {}, // 拖动改变时间
|
|
85
86
|
onSplitResize: () => {}, // 拖动分割线改变宽度回调
|
|
86
87
|
onColumnResize: () => {}, // 拖动列宽回调
|
|
88
|
+
instanceId: `gante-${Math.random().toString(36).slice(2)}`,
|
|
87
89
|
dropdownOptions: [
|
|
88
90
|
{ value: 1, label: '日' },
|
|
89
91
|
{ value: 2, label: '周' },
|
|
@@ -335,7 +337,12 @@
|
|
|
335
337
|
// 初始化
|
|
336
338
|
init(params,mode = true) {
|
|
337
339
|
|
|
338
|
-
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);
|
|
339
346
|
|
|
340
347
|
if(params.ganteData == undefined){
|
|
341
348
|
let ganteData = JSON.parse(JSON.stringify(this.ganteData));
|
package/gante.vue
CHANGED
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
:th_data="th_data"
|
|
35
35
|
:gante_data="ganteData"
|
|
36
36
|
:toast-render="toastRender"
|
|
37
|
-
:toast-class="toastClass"
|
|
37
|
+
:toast-class="toastClass"
|
|
38
|
+
:instance-id="instanceId"></gante-gc>
|
|
38
39
|
</div>
|
|
39
40
|
<gante-split :left="tabe_width" :th_data="th_data" :onSplitResize="onSplitResize"></gante-split>
|
|
40
41
|
</div>
|
|
@@ -87,6 +88,7 @@
|
|
|
87
88
|
onDragChangeTime: () => {}, // 拖动改变时间
|
|
88
89
|
onSplitResize: () => {}, // 拖动分割线改变宽度回调
|
|
89
90
|
onColumnResize: () => {}, // 拖动列宽回调
|
|
91
|
+
instanceId: `gante-${Math.random().toString(36).slice(2)}`,
|
|
90
92
|
dropdownOptions: [
|
|
91
93
|
{ value: 1, label: '日' },
|
|
92
94
|
{ value: 2, label: '周' },
|
|
@@ -350,7 +352,12 @@
|
|
|
350
352
|
// 初始化
|
|
351
353
|
init(params,mode = true) {
|
|
352
354
|
|
|
353
|
-
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);
|
|
354
361
|
|
|
355
362
|
if(params.ganteData == undefined){
|
|
356
363
|
let ganteData = JSON.parse(JSON.stringify(this.ganteData));
|