gunter-kgd 1.0.0 → 1.0.2
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/common/dropdown.vue +227 -0
- package/components/common/loading.vue +67 -0
- package/components/gante_test/auto-scroll.js +32 -0
- package/components/gante_test/calendar.vue +257 -0
- package/components/gante_test/commit.js +2 -0
- package/components/gante_test/gante-drag-circle.vue +151 -0
- package/components/gante_test/gante-gc-item-content.vue +442 -0
- package/components/gante_test/gante-gc-item.vue +95 -0
- package/components/gante_test/gante-gc.vue +534 -0
- package/components/gante_test/gante-split.vue +125 -0
- package/components/gante_test/gante-table-td.vue +263 -0
- package/components/gante_test/gante-table-tr.vue +159 -0
- package/components/gante_test/gante-table.vue +349 -0
- package/components/gante_test/gante.vue +894 -0
- package/components/gante_test/gante_op.js +112 -0
- package/components/gante_test/requestAnimation.js +49 -0
- package/components/gante_test/resize.js +80 -0
- package/components/gante_test/search_last_width.js +27 -0
- package/gante.vue +9 -9
- package/index.js +1 -1
- package/package.json +3 -2
- package/utils/click-outside.js +18 -0
- package/utils/public.js +94 -0
- package/utils/requestAnimation.js +49 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="task-drag-circle"
|
|
3
|
+
:class="{active: dragInfo.mouseDown && dragInfo.taskId == current_data.gunter_id}"
|
|
4
|
+
ref="drag_circle"
|
|
5
|
+
:style="{transform: `translate3d(${left+'px'},-2px,0)`,opacity: current_data.is_hover ? 1 : 0}"
|
|
6
|
+
@mousedown="dragDown"
|
|
7
|
+
@mouseup="doc_up"
|
|
8
|
+
@mouseleave="out_op"
|
|
9
|
+
@mouseenter="enter">
|
|
10
|
+
<span></span>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import { mapState,mapMutations } from 'vuex';
|
|
16
|
+
import autoScroll from './auto-scroll';
|
|
17
|
+
import commitEmit from './commit.js';
|
|
18
|
+
export default {
|
|
19
|
+
name: "gante-drag-circle",
|
|
20
|
+
mixins:[autoScroll],
|
|
21
|
+
props:{
|
|
22
|
+
current_data: Object,
|
|
23
|
+
},
|
|
24
|
+
computed:{
|
|
25
|
+
...mapState([
|
|
26
|
+
'dragInfo',
|
|
27
|
+
'currentInfo'
|
|
28
|
+
]),
|
|
29
|
+
left(){
|
|
30
|
+
let _left = this.current_data.left ? this.current_data.left : 0,
|
|
31
|
+
_width = this.current_data.width ? this.current_data.width : 0;
|
|
32
|
+
return _left + _width + 20
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
data(){
|
|
36
|
+
return{
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
methods:{
|
|
41
|
+
...mapMutations([
|
|
42
|
+
'SET_DASHLINE',
|
|
43
|
+
'SET_DRAG_INFO',
|
|
44
|
+
'SET_CURRENT_INFO'
|
|
45
|
+
]),
|
|
46
|
+
// 按下拖动的圆点
|
|
47
|
+
dragDown(e){
|
|
48
|
+
if(this.current_data){
|
|
49
|
+
let _ganteview = document.getElementsByClassName('ganteview')[0],
|
|
50
|
+
c_x = Number(this.current_data.left) + Number(this.current_data.width) + 22,
|
|
51
|
+
c_y = e.target.getBoundingClientRect().top - _ganteview.getBoundingClientRect().top + 4,
|
|
52
|
+
scrollLeft = _ganteview.scrollLeft,
|
|
53
|
+
scrollTop = _ganteview.scrollTop
|
|
54
|
+
|
|
55
|
+
this.SET_DRAG_INFO({
|
|
56
|
+
data:{
|
|
57
|
+
mouseDown: true,
|
|
58
|
+
taskId: this.current_data.gunter_id,
|
|
59
|
+
right: Number(this.current_data.left) + Number(this.current_data.width),
|
|
60
|
+
offsetTop: this.$refs.drag_circle ? this.$refs.drag_circle.getBoundingClientRect().top : 0,
|
|
61
|
+
startData: {x: scrollLeft >0 ? e.target.getBoundingClientRect().left + scrollLeft : e.target.getBoundingClientRect().left,y: scrollTop > 0 ? e.target.getBoundingClientRect().top+ scrollTop : e.target.getBoundingClientRect().top}
|
|
62
|
+
},
|
|
63
|
+
mode: 2
|
|
64
|
+
})
|
|
65
|
+
this.SET_DASHLINE({
|
|
66
|
+
data:{
|
|
67
|
+
showLine: true,
|
|
68
|
+
left: c_x ,
|
|
69
|
+
top: c_y,
|
|
70
|
+
width: 0
|
|
71
|
+
},
|
|
72
|
+
mode: 2
|
|
73
|
+
});
|
|
74
|
+
document.addEventListener('mousemove',this.doc_move,{passive:false})
|
|
75
|
+
document.addEventListener('mouseup',this.doc_up,{passive:false});
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
doc_move(e){
|
|
80
|
+
if(this.dragInfo.mouseDown){
|
|
81
|
+
let _ganteview = document.getElementsByClassName('ganteview')[0];
|
|
82
|
+
let _currentX = (e.clientX + _ganteview.scrollLeft) - this.dragInfo.startData.x ,_currentY = (e.clientY + _ganteview.scrollTop) - this.dragInfo.startData.y;
|
|
83
|
+
this.SET_DASHLINE({
|
|
84
|
+
data:{
|
|
85
|
+
width: Math.sqrt(Math.pow(Math.abs(_currentX),2)+Math.pow(Math.abs(_currentY),2)),
|
|
86
|
+
scale: Math.atan2((_currentY),_currentX)/0.017453292
|
|
87
|
+
},
|
|
88
|
+
mode: 2
|
|
89
|
+
});
|
|
90
|
+
this.autoScroll(e,_ganteview);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
doc_up(e){
|
|
94
|
+
if(this.dragInfo.mouseDown){
|
|
95
|
+
if(this.currentInfo.taskId && this.currentInfo.before_id){
|
|
96
|
+
commitEmit.$emit('onBeforeDataChange',this.currentInfo.taskId, this.currentInfo.before_id,2)
|
|
97
|
+
}
|
|
98
|
+
this.SET_DRAG_INFO({
|
|
99
|
+
data:{},
|
|
100
|
+
mode: 1
|
|
101
|
+
})
|
|
102
|
+
this.SET_DASHLINE({
|
|
103
|
+
data:{},
|
|
104
|
+
mode: 1
|
|
105
|
+
});
|
|
106
|
+
this.SET_CURRENT_INFO({})
|
|
107
|
+
document.removeEventListener('mousemove',this.doc_move,false)
|
|
108
|
+
document.removeEventListener('mouseup',this.doc_up,false);
|
|
109
|
+
clearInterval(this.scrollFn);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
// 拖动时进入到当前元素上
|
|
113
|
+
enter(e){
|
|
114
|
+
if(!this.dragInfo.mouseDown) return;
|
|
115
|
+
if(!this.dragInfo.startData) return;
|
|
116
|
+
if(this.dragInfo.taskId == this.current_data.gunter_id) return;
|
|
117
|
+
this.SET_CURRENT_INFO({ taskId: this.current_data.gunter_id,before_id: this.dragInfo.taskId})
|
|
118
|
+
},
|
|
119
|
+
out_op(){
|
|
120
|
+
this.SET_CURRENT_INFO({})
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<style scoped lang="less">
|
|
127
|
+
/*右边拖动的圆点*/
|
|
128
|
+
.task-drag-circle {
|
|
129
|
+
width: 10px;
|
|
130
|
+
height: 10px;
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
position: relative;
|
|
133
|
+
transition: opacity .2s ease;
|
|
134
|
+
span{
|
|
135
|
+
position: absolute;
|
|
136
|
+
width: 6px;
|
|
137
|
+
height: 6px;
|
|
138
|
+
border-radius: 3px;
|
|
139
|
+
background: #7eabe8;
|
|
140
|
+
transition: transform .1s ease;
|
|
141
|
+
}
|
|
142
|
+
&:hover span{
|
|
143
|
+
transform: scale(1.3);
|
|
144
|
+
background:#3396fb;
|
|
145
|
+
}
|
|
146
|
+
&.active{
|
|
147
|
+
opacity: 1!important;
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
</style>
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
<!--图表每个条块-->
|
|
2
|
+
<template>
|
|
3
|
+
<div
|
|
4
|
+
@mousemove.passive="showToast"
|
|
5
|
+
@mouseleave="hideToast"
|
|
6
|
+
@mousedown="dragDown($event,'drag')"
|
|
7
|
+
:style="{
|
|
8
|
+
cursor: DragObject.mouseDown ? 'grabbing' : 'grab',
|
|
9
|
+
width:current_data.width?current_data.width+'px':0,
|
|
10
|
+
transform: `translate3d(${current_data.left?current_data.left+'px':0},10px,0)`,
|
|
11
|
+
transition: !DragObject.mouseDown ? 'width .5s linear, opacity .2s ease' : 'null',
|
|
12
|
+
background:current_data.bg_color?current_data.bg_color:'#FD8A25',
|
|
13
|
+
borderColor: current_data.bg_color ? `${current_data.bg_color} ${current_data.bg_color} transparent`: '#00b0ff #00b0ff transparent'}"
|
|
14
|
+
class="ganteview-item" :class="{'has-child': current_data.children}">
|
|
15
|
+
<span class="ganteview-item__label">{{`${myPublic.dateFormat.format(this.current_data.params.startTime,'YYYY-MM-DD')} ~ ${myPublic.dateFormat.format(this.current_data.params.endTime,'YYYY-MM-DD')}`}}</span>
|
|
16
|
+
<span v-show="current_data.show_drag" @mousedown.stop="dragDown($event,'left')" data-drag="true" class="left-drag-line"></span>
|
|
17
|
+
<span v-show="current_data.show_drag" @mousedown.stop="dragDown($event,'right')" data-drag="true" class="right-drag-line"></span>
|
|
18
|
+
<div v-show="current_data.show_drag" data-drag="true" class="ganter_drag_hover"></div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import myPublic from '../../utils/public';
|
|
24
|
+
import emitter from './commit'
|
|
25
|
+
export default {
|
|
26
|
+
name: "gante-gc-item-content",
|
|
27
|
+
data(){
|
|
28
|
+
return{
|
|
29
|
+
myPublic,
|
|
30
|
+
requestId: '',
|
|
31
|
+
canShow: false,// 是否可以显示toast ,为了防止触发了mouseout事件后立马触发showToast事件
|
|
32
|
+
toastClassResolved: '',
|
|
33
|
+
DragObject:{
|
|
34
|
+
startX: 0, // 开始的位置
|
|
35
|
+
mouseDown: false,// 是否按下了鼠标
|
|
36
|
+
scale: 0, // 刻度
|
|
37
|
+
mode: 1, // 默认以小时为单位 1:小时 2 :天
|
|
38
|
+
start_width: 0,// 记录开始的宽度
|
|
39
|
+
start_left: 0,// 记录开始的宽度
|
|
40
|
+
start_time: null, // 记录开始拖动时的时间
|
|
41
|
+
end_time:null, // 记录开始拖动时的时间
|
|
42
|
+
startAttr: null,// 开始时间的属性名
|
|
43
|
+
endAttr: null,// 结束时间的属性名
|
|
44
|
+
move_type: null, // 拖动的方式 left: 拖动左边时间 right: 拖动右边时间 drag: 拖动整体
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
props:{
|
|
49
|
+
current_data: Object,
|
|
50
|
+
th_data: Object,
|
|
51
|
+
time_1px:Number, // 1px代表的时间
|
|
52
|
+
time_mode:[Number,String],
|
|
53
|
+
start_time: {}, //开始时间
|
|
54
|
+
end_time: {},
|
|
55
|
+
toastRender: Function,
|
|
56
|
+
toastClass: String,
|
|
57
|
+
},
|
|
58
|
+
methods:{
|
|
59
|
+
buildToastContent() {
|
|
60
|
+
if (!this.current_data || !this.current_data.params) {
|
|
61
|
+
this.toastClassResolved = (this.toastClass || '').trim();
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
let list = '';
|
|
65
|
+
for (let i in this.th_data) {
|
|
66
|
+
if (this.current_data.params[i] != undefined && (this.th_data[i].showToast || this.th_data[i].time_mode == 1 || this.th_data[i].time_mode == 2)) {
|
|
67
|
+
list += `<p>${this.th_data[i].value}:${this.current_data.params[i]}</p>`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const defaultContent = list;
|
|
72
|
+
|
|
73
|
+
let resolvedContent = defaultContent;
|
|
74
|
+
let resolvedClass = (this.toastClass || '').trim();
|
|
75
|
+
if (typeof this.toastRender === 'function') {
|
|
76
|
+
const custom = this.toastRender({
|
|
77
|
+
currentData: this.current_data,
|
|
78
|
+
thData: this.th_data,
|
|
79
|
+
defaultContent
|
|
80
|
+
});
|
|
81
|
+
if (typeof custom === 'string') {
|
|
82
|
+
resolvedContent = custom;
|
|
83
|
+
} else if (custom && typeof custom === 'object') {
|
|
84
|
+
if (custom.content !== undefined) {
|
|
85
|
+
resolvedContent = custom.content;
|
|
86
|
+
}
|
|
87
|
+
if (custom.className) {
|
|
88
|
+
resolvedClass = `${resolvedClass ? resolvedClass + ' ' : ''}${custom.className}`.trim();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this.toastClassResolved = resolvedClass;
|
|
94
|
+
return resolvedContent;
|
|
95
|
+
},
|
|
96
|
+
showToast(e) {
|
|
97
|
+
this.canShow = true;
|
|
98
|
+
let animation = () => {
|
|
99
|
+
this.setMouseMode()
|
|
100
|
+
let x = e.clientX + 15, y = e.clientY + 15
|
|
101
|
+
if(this.current_data && this.canShow){
|
|
102
|
+
if(this.current_data.params){
|
|
103
|
+
let toast = document.createElement('div'), add_toast = true
|
|
104
|
+
const content = this.buildToastContent();
|
|
105
|
+
const toastClass = `gante-toast-liu${this.toastClassResolved ? ' ' + this.toastClassResolved : ''}`
|
|
106
|
+
toast.setAttribute('class', toastClass)
|
|
107
|
+
if (document.getElementsByClassName('gante-toast-liu')[0]) {
|
|
108
|
+
toast = document.getElementsByClassName('gante-toast-liu')[0];
|
|
109
|
+
toast.setAttribute('class', toastClass)
|
|
110
|
+
toast.style.display = 'block';
|
|
111
|
+
add_toast = false;
|
|
112
|
+
}
|
|
113
|
+
if(toast.innerHTML != content || content == ''){
|
|
114
|
+
toast.innerHTML = content
|
|
115
|
+
}
|
|
116
|
+
//判断是否到了页面底部
|
|
117
|
+
if (toast.clientHeight + y > window.innerHeight) {
|
|
118
|
+
//鼠标的位置在toast的中间
|
|
119
|
+
if (e.clientY >= window.innerHeight - toast.clientHeight) {
|
|
120
|
+
y = e.clientY - 10 - toast.clientHeight
|
|
121
|
+
} else {
|
|
122
|
+
y = window.innerHeight - toast.clientHeight
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (toast.clientWidth + x > window.innerWidth) {
|
|
126
|
+
x = window.innerWidth - toast.clientWidth
|
|
127
|
+
}
|
|
128
|
+
toast.style.left = x + 'px'
|
|
129
|
+
toast.style.top = y + 'px'
|
|
130
|
+
if (add_toast) {
|
|
131
|
+
document.getElementsByTagName('body')[0].appendChild(toast)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
this.requestId = requestAnimationFrame(animation)
|
|
137
|
+
},
|
|
138
|
+
// 设置鼠标样式
|
|
139
|
+
setMouseMode(){
|
|
140
|
+
if(!this.canShow){
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.$set(this.current_data,'show_drag',true)
|
|
144
|
+
},
|
|
145
|
+
// 隐藏toast
|
|
146
|
+
hideToast() {
|
|
147
|
+
// 如果在拖动的情况下就不隐藏
|
|
148
|
+
if(this.DragObject.mouseDown){
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this.canShow = false;
|
|
152
|
+
this.$set(this.current_data,'show_drag',false)
|
|
153
|
+
cancelAnimationFrame(this.requestId)
|
|
154
|
+
if (document.getElementsByClassName('gante-toast-liu') && document.getElementsByClassName('gante-toast-liu').length > 0) {
|
|
155
|
+
document.getElementsByClassName('gante-toast-liu')[0].style.display = 'none';
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
// 点击了准备拖动
|
|
159
|
+
dragDown(e,type){
|
|
160
|
+
if(this.current_data){
|
|
161
|
+
if(this.current_data.params){
|
|
162
|
+
this.DragObject.mouseDown = true;
|
|
163
|
+
this.DragObject.startX = e.clientX;
|
|
164
|
+
this.DragObject.move_type = type;
|
|
165
|
+
this.DragObject.start_width = this.current_data.width;
|
|
166
|
+
this.DragObject.start_left = this.current_data.left;
|
|
167
|
+
for (let i in this.th_data) {
|
|
168
|
+
if (this.current_data.params[i] != undefined) {
|
|
169
|
+
if(this.th_data[i].time_mode == 1){
|
|
170
|
+
this.DragObject.startAttr = i;
|
|
171
|
+
this.DragObject.start_time = this.current_data.params[i]
|
|
172
|
+
}
|
|
173
|
+
if(this.th_data[i].time_mode == 2){
|
|
174
|
+
this.DragObject.endAttr = i;
|
|
175
|
+
this.DragObject.end_time = this.current_data.params[i]
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if(this.time_mode == 1 || this.time_mode == 2){
|
|
180
|
+
this.DragObject.scale = 1000*60*60/this.time_1px; // 以小时为单位
|
|
181
|
+
this.DragObject.mode = 1;
|
|
182
|
+
}else{
|
|
183
|
+
this.DragObject.scale = 1000*60*60*24/this.time_1px // 以天为单位
|
|
184
|
+
this.DragObject.mode = 2;
|
|
185
|
+
}
|
|
186
|
+
document.body.classList.add('unselecttable');
|
|
187
|
+
if(type == 'drag'){
|
|
188
|
+
document.body.style.cursor = 'grabbing';
|
|
189
|
+
}else {
|
|
190
|
+
document.body.style.cursor = 'e-resize';
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
document.addEventListener('mousemove',this.doc_move,{passive:false})
|
|
194
|
+
document.addEventListener('mouseup',this.doc_up,{passive:false})
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
// 拖动时间
|
|
199
|
+
doc_move(e){
|
|
200
|
+
if(this.DragObject.mouseDown){
|
|
201
|
+
this.hideToast();
|
|
202
|
+
let move_mode_width = 0, // 宽度基值
|
|
203
|
+
move_mode_left = 0; // left基值
|
|
204
|
+
if(this.DragObject.move_type == 'left'){
|
|
205
|
+
document.body.style.cursor = 'e-resize';
|
|
206
|
+
if(e.clientX > this.DragObject.startX){
|
|
207
|
+
move_mode_width = -1;
|
|
208
|
+
move_mode_left = 1
|
|
209
|
+
}else if(e.clientX < this.DragObject.startX){
|
|
210
|
+
move_mode_width = 1;
|
|
211
|
+
move_mode_left = -1
|
|
212
|
+
}
|
|
213
|
+
}else if(this.DragObject.move_type == 'right'){
|
|
214
|
+
document.body.style.cursor = 'e-resize';
|
|
215
|
+
if(e.clientX > this.DragObject.startX){
|
|
216
|
+
move_mode_width = 1;
|
|
217
|
+
}else if(e.clientX < this.DragObject.startX){
|
|
218
|
+
move_mode_width = -1;
|
|
219
|
+
}
|
|
220
|
+
}else if(this.DragObject.move_type == 'drag'){
|
|
221
|
+
document.body.style.cursor = 'grabbing';
|
|
222
|
+
if(e.clientX > this.DragObject.startX){
|
|
223
|
+
move_mode_left = 1
|
|
224
|
+
move_mode_width = 1
|
|
225
|
+
}else if(e.clientX < this.DragObject.startX){
|
|
226
|
+
move_mode_left = -1
|
|
227
|
+
move_mode_width = -1
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
let moveX = Math.abs(e.clientX - this.DragObject.startX), // 移动的距离
|
|
231
|
+
move_unit = move_mode_width * (Math.ceil(moveX/this.DragObject.scale)), // 移动的时间
|
|
232
|
+
time_mode = 60*60*1000 // 时间类型
|
|
233
|
+
let start_time = this.DragObject.start_time,
|
|
234
|
+
end_time = this.DragObject.end_time
|
|
235
|
+
|
|
236
|
+
if(this.DragObject.mode == 2){
|
|
237
|
+
time_mode = 60*60*1000*24
|
|
238
|
+
}
|
|
239
|
+
if(this.DragObject.move_type == 'left'){
|
|
240
|
+
start_time = myPublic.dateFormat.format((new Date(myPublic.dateFormat.dateReplace(start_time)).getTime() - move_unit*time_mode),'YYYY-MM-DD HH:mm')
|
|
241
|
+
}else if(this.DragObject.move_type == 'right'){
|
|
242
|
+
end_time = myPublic.dateFormat.format((new Date(myPublic.dateFormat.dateReplace(end_time)).getTime() + move_unit*time_mode),'YYYY-MM-DD HH:mm')
|
|
243
|
+
}else{
|
|
244
|
+
console.log(start_time)
|
|
245
|
+
start_time = myPublic.dateFormat.format((new Date(myPublic.dateFormat.dateReplace(start_time)).getTime() + move_unit*time_mode),'YYYY-MM-DD HH:mm')
|
|
246
|
+
end_time = myPublic.dateFormat.format((new Date(myPublic.dateFormat.dateReplace(end_time)).getTime() + move_unit*time_mode),'YYYY-MM-DD HH:mm')
|
|
247
|
+
}
|
|
248
|
+
let move_width = this.DragObject.start_width + (moveX * move_mode_width), // 当前item的宽度
|
|
249
|
+
move_left = this.DragObject.start_left + (moveX * move_mode_left); // 当前item的left
|
|
250
|
+
//整体拖动时宽度是不变的
|
|
251
|
+
if(this.DragObject.move_type == 'drag'){
|
|
252
|
+
move_width = this.DragObject.start_width
|
|
253
|
+
}
|
|
254
|
+
// 设置最小宽度为10
|
|
255
|
+
if(move_width <= 10 && this.DragObject.move_type != 'drag'){
|
|
256
|
+
move_width = 10;
|
|
257
|
+
move_left = this.DragObject.start_left + ((this.DragObject.start_width - 10) * move_mode_left);
|
|
258
|
+
if(this.DragObject.move_type == 'left'){
|
|
259
|
+
start_time = myPublic.dateFormat.format((new Date(myPublic.dateFormat.dateReplace(end_time)).getTime() - (time_mode*(Math.ceil(10/this.DragObject.scale)))),'YYYY-MM-DD HH:mm')
|
|
260
|
+
}else if(this.DragObject.move_type == 'right'){
|
|
261
|
+
end_time = myPublic.dateFormat.format((new Date(myPublic.dateFormat.dateReplace(start_time)).getTime() + (time_mode*(Math.ceil(10/this.DragObject.scale)))),'YYYY-MM-DD HH:mm')
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// 为了实时触发视图更新
|
|
265
|
+
delete(this.current_data.width);
|
|
266
|
+
delete(this.current_data.left);
|
|
267
|
+
this.$set(this.current_data,'width',move_width);
|
|
268
|
+
this.$set(this.current_data,'left',move_left);
|
|
269
|
+
this.$set(this.current_data.params,this.DragObject.startAttr,start_time);
|
|
270
|
+
this.$set(this.current_data.params,this.DragObject.endAttr,end_time);
|
|
271
|
+
this.$set(this.current_data,'start_time',new Date(myPublic.dateFormat.dateReplace(start_time)).getTime());
|
|
272
|
+
this.$set(this.current_data,'end_time',new Date(myPublic.dateFormat.dateReplace(end_time)).getTime());
|
|
273
|
+
// 触发toast时间更新
|
|
274
|
+
let toast = null;
|
|
275
|
+
if (document.getElementsByClassName('gante-toast-liu')[0]) {
|
|
276
|
+
toast = document.getElementsByClassName('gante-toast-liu')[0]
|
|
277
|
+
toast.style.display = 'block';
|
|
278
|
+
const content = this.buildToastContent();
|
|
279
|
+
if(toast.innerHTML != content || content == ''){
|
|
280
|
+
toast.innerHTML = content
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
// 取消拖动时间
|
|
286
|
+
doc_up(e){
|
|
287
|
+
if(this.current_data.start_time < this.start_time || this.current_data.end_time > this.end_time){
|
|
288
|
+
|
|
289
|
+
if(this.current_data.start_time < this.start_time){
|
|
290
|
+
|
|
291
|
+
emitter.$emit('triggerInit',this.current_data.start_time, this.end_time)
|
|
292
|
+
}
|
|
293
|
+
if(this.current_data.end_time > this.end_time){
|
|
294
|
+
emitter.$emit('triggerInit',this.start_time, this.current_data.end_time)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
document.removeEventListener('mousemove',this.doc_move,false);
|
|
298
|
+
document.removeEventListener('mouseup',this.doc_up,false);
|
|
299
|
+
document.body.classList.remove('unselecttable');
|
|
300
|
+
document.body.style.cursor = null;
|
|
301
|
+
if(this.DragObject.startX != e.clientX){
|
|
302
|
+
emitter.$emit('onDragChangeTime',
|
|
303
|
+
{
|
|
304
|
+
gunter_id: this.current_data.gunter_id,
|
|
305
|
+
start_time: this.DragObject.start_time,
|
|
306
|
+
end_time: this.DragObject.end_time,
|
|
307
|
+
width: this.DragObject.start_width,
|
|
308
|
+
left: this.DragObject.start_left,
|
|
309
|
+
startAttr: this.DragObject.startAttr,
|
|
310
|
+
endAttr: this.DragObject.endAttr,
|
|
311
|
+
},
|
|
312
|
+
{start:this.current_data.params[this.DragObject.startAttr],end:this.current_data.params[this.DragObject.endAttr],gunter_id: this.current_data.gunter_id});
|
|
313
|
+
}
|
|
314
|
+
this.DragObject = {
|
|
315
|
+
startX: 0, // 开始的位置
|
|
316
|
+
mouseDown: false,// 是否按下了鼠标
|
|
317
|
+
scale: 0, // 刻度
|
|
318
|
+
mode: 1, // 默认以小时为单位 1:小时 2 :天
|
|
319
|
+
start_width: 0,// 记录开始的宽度
|
|
320
|
+
start_left: 0,// 记录开始的宽度
|
|
321
|
+
start_time: null, // 记录开始拖动时的时间
|
|
322
|
+
end_time:null, // 记录开始拖动时的时间
|
|
323
|
+
startAttr: null,// 开始时间的属性名
|
|
324
|
+
endAttr: null,// 结束时间的属性名
|
|
325
|
+
move_type: null,
|
|
326
|
+
};
|
|
327
|
+
this.hideToast();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
</script>
|
|
332
|
+
|
|
333
|
+
<style scoped lang="less">
|
|
334
|
+
.ganteview-item {
|
|
335
|
+
height: 20px;
|
|
336
|
+
line-height: 20px;
|
|
337
|
+
padding-left: 10px;
|
|
338
|
+
border-radius: 3px;
|
|
339
|
+
background: #00b0ff;
|
|
340
|
+
cursor: grab;
|
|
341
|
+
width: 0;
|
|
342
|
+
/*transition: width .5s linear, opacity .2s ease;*/
|
|
343
|
+
opacity: 0.5;
|
|
344
|
+
position: relative;
|
|
345
|
+
.ganteview-item__label{
|
|
346
|
+
display: block;
|
|
347
|
+
white-space: nowrap;
|
|
348
|
+
overflow: hidden;
|
|
349
|
+
text-overflow: ellipsis;
|
|
350
|
+
}
|
|
351
|
+
.left-drag-line,.right-drag-line{
|
|
352
|
+
position: absolute;
|
|
353
|
+
left: -15px;
|
|
354
|
+
height: 26px;
|
|
355
|
+
width: 15px;
|
|
356
|
+
top: 2px;
|
|
357
|
+
margin-top: -5px;
|
|
358
|
+
cursor: e-resize;
|
|
359
|
+
&:hover:after{
|
|
360
|
+
border-color: #3396fb;
|
|
361
|
+
}
|
|
362
|
+
&:after{
|
|
363
|
+
position: absolute;
|
|
364
|
+
content: '';
|
|
365
|
+
left: 6px;
|
|
366
|
+
top:8px;
|
|
367
|
+
width: 2px;
|
|
368
|
+
height: 10px;
|
|
369
|
+
border-left: 1px solid rgba(0,0,0,0.5);
|
|
370
|
+
border-right: 1px solid rgba(0,0,0,0.5);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/* 左边显示的时间 */
|
|
374
|
+
.time-tip-left{
|
|
375
|
+
position: absolute;
|
|
376
|
+
left: -85px;
|
|
377
|
+
width: 67px;
|
|
378
|
+
height: 15px;
|
|
379
|
+
line-height: 15px;
|
|
380
|
+
padding: 3px 4px;
|
|
381
|
+
border-radius: 3px;
|
|
382
|
+
background: #333;
|
|
383
|
+
color: #fff;
|
|
384
|
+
font-size: 12px;
|
|
385
|
+
}
|
|
386
|
+
.right-drag-line{
|
|
387
|
+
right: -15px;
|
|
388
|
+
left: auto;
|
|
389
|
+
}
|
|
390
|
+
.ganter_drag_hover{
|
|
391
|
+
position: absolute;
|
|
392
|
+
left: -15px;
|
|
393
|
+
height: 26px;
|
|
394
|
+
width: ~'calc(100% + 30px)';
|
|
395
|
+
top: -3px;
|
|
396
|
+
z-index: -1;
|
|
397
|
+
box-shadow: 1px 1px 3px 1px rgba(0,0,0,0.2);
|
|
398
|
+
border-radius: 3px;
|
|
399
|
+
}
|
|
400
|
+
&:hover{
|
|
401
|
+
.left-drag-line,.right-drag-line,.ganter_drag_hover{
|
|
402
|
+
display: block;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.ganteview-item:hover {
|
|
408
|
+
opacity: 1;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.ganteview-item.has-child {
|
|
412
|
+
height: 15px;
|
|
413
|
+
background: none!important;
|
|
414
|
+
border-style: solid;
|
|
415
|
+
border-width: 10px 5px 10px;
|
|
416
|
+
border-top-left-radius: 2px;
|
|
417
|
+
border-top-right-radius: 2px;
|
|
418
|
+
box-sizing: border-box;
|
|
419
|
+
.left-drag-line,.right-drag-line{
|
|
420
|
+
left: -17px;
|
|
421
|
+
top: -10px;
|
|
422
|
+
&:after{
|
|
423
|
+
left: 4px;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
.right-drag-line{
|
|
427
|
+
right: -17px;
|
|
428
|
+
left: auto;
|
|
429
|
+
&:after{
|
|
430
|
+
left: 6px;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
.ganter_drag_hover{
|
|
434
|
+
top: -15px;
|
|
435
|
+
width: calc(100% + 34px);
|
|
436
|
+
left: -17px;
|
|
437
|
+
}
|
|
438
|
+
.time-tip-left{
|
|
439
|
+
top: -12px;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
</style>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<!--整体条块,同级任务-->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="ganteview-content">
|
|
4
|
+
<div v-for="(item,index) in gante_data" :key="index" class="ganteview-ones">
|
|
5
|
+
<div class="ganteview-content-one" :class="{gj_hover_class: item.is_hover}" @mouseenter="enterTr($event,item)"
|
|
6
|
+
@mouseleave="leaveTr($event,item)">
|
|
7
|
+
<ganteGcItemContent
|
|
8
|
+
:start_time="start_time"
|
|
9
|
+
:end_time="end_time"
|
|
10
|
+
:current_data="item"
|
|
11
|
+
:index="index"
|
|
12
|
+
:th_data="th_data"
|
|
13
|
+
:time_1px="time_1px"
|
|
14
|
+
:time_mode="time_mode"
|
|
15
|
+
:toast-render="toastRender"
|
|
16
|
+
:toast-class="toastClass"></ganteGcItemContent>
|
|
17
|
+
<!--<ganteDragCircle :current_data="item"></ganteDragCircle>-->
|
|
18
|
+
</div>
|
|
19
|
+
<ganteview-item
|
|
20
|
+
v-show="item.open"
|
|
21
|
+
:start_time="start_time"
|
|
22
|
+
:end_time="end_time"
|
|
23
|
+
v-if="item.children"
|
|
24
|
+
:th_data="th_data"
|
|
25
|
+
:time_1px="time_1px"
|
|
26
|
+
:time_mode="time_mode"
|
|
27
|
+
:toast-render="toastRender"
|
|
28
|
+
:toast-class="toastClass"
|
|
29
|
+
:gante_data="item.children">
|
|
30
|
+
<span style="display: none">1</span>
|
|
31
|
+
</ganteview-item>
|
|
32
|
+
</div>
|
|
33
|
+
<slot></slot>
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
<script>
|
|
38
|
+
import ganteGcItemContent from './gante-gc-item-content'
|
|
39
|
+
// import ganteDragCircle from './gante-drag-circle'
|
|
40
|
+
export default {
|
|
41
|
+
name: 'ganteview-item',
|
|
42
|
+
components:{
|
|
43
|
+
ganteGcItemContent
|
|
44
|
+
},
|
|
45
|
+
data() {
|
|
46
|
+
return {
|
|
47
|
+
canAnimation: false,
|
|
48
|
+
bol: false,
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
props: {
|
|
52
|
+
gante_data: Array,
|
|
53
|
+
th_data: Object,
|
|
54
|
+
time_1px:Number, // 1px代表的时间
|
|
55
|
+
time_mode:[Number,String],
|
|
56
|
+
start_time: {}, //开始时间
|
|
57
|
+
end_time: {},
|
|
58
|
+
toastRender: Function,
|
|
59
|
+
toastClass: String,
|
|
60
|
+
},
|
|
61
|
+
methods: {
|
|
62
|
+
// 进入到了tr上
|
|
63
|
+
enterTr(ev, tr) {
|
|
64
|
+
this.$set(tr, 'is_hover', true)
|
|
65
|
+
},
|
|
66
|
+
// 离开了tr
|
|
67
|
+
leaveTr(ev, tr) {
|
|
68
|
+
this.$set(tr, 'is_hover', false)
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
74
|
+
<style scoped lang="less">
|
|
75
|
+
.ganteview-content {
|
|
76
|
+
position: relative;
|
|
77
|
+
.ganteview-ones-seat{
|
|
78
|
+
height: 41px;
|
|
79
|
+
line-height: 40px;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.ganteview-content-one {
|
|
84
|
+
height: 51px;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
line-height: 50px;
|
|
87
|
+
border-bottom: 1px solid #ebeef5;
|
|
88
|
+
position: relative;
|
|
89
|
+
z-index: 1;
|
|
90
|
+
}
|
|
91
|
+
.ganteview-content-one.gj_hover_class{
|
|
92
|
+
background: rgba(246, 246, 246, 0.7);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
</style>
|