gunter-kgd 1.0.12 → 1.0.13

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.
@@ -11,10 +11,11 @@
11
11
  width:current_data.width?current_data.width+'px':0,
12
12
  transform: `translate3d(${current_data.left?current_data.left+'px':0},15px,0)`,
13
13
  transition: !DragObject.mouseDown ? 'width .5s linear, opacity .2s ease' : 'null',
14
- background:current_data.bg_color?current_data.bg_color:'#FD8A25',
14
+ background: progressColor,
15
15
  borderColor: current_data.bg_color ? `${current_data.bg_color} ${current_data.bg_color} transparent`: '#00b0ff #00b0ff transparent'}"
16
16
  class="ganteview-item" :class="{'has-child': current_data.children}">
17
- <span class="ganteview-item__label"></span>
17
+ <div class="ganteview-item__progress" :style="{width: progressWidth, background: taskBackground}"></div>
18
+ <span class="ganteview-item__label">{{ progressText }}</span>
18
19
  <span v-show="current_data.show_drag" @mousedown.stop="dragDown($event,'left')" data-drag="true" class="left-drag-line"></span>
19
20
  <span v-show="current_data.show_drag" @mousedown.stop="dragDown($event,'right')" data-drag="true" class="right-drag-line"></span>
20
21
  <div v-show="current_data.show_drag" data-drag="true" class="ganter_drag_hover"></div>
@@ -35,6 +36,7 @@
35
36
  justDragged: false,
36
37
  DragObject:{
37
38
  startX: 0, // 开始的位置
39
+ startY: 0,
38
40
  mouseDown: false,// 是否按下了鼠标
39
41
  scale: 0, // 刻度
40
42
  mode: 1, // 默认以小时为单位 1:小时 2 :天
@@ -45,6 +47,7 @@
45
47
  startAttr: null,// 开始时间的属性名
46
48
  endAttr: null,// 结束时间的属性名
47
49
  move_type: null, // 拖动的方式 left: 拖动左边时间 right: 拖动右边时间 drag: 拖动整体
50
+ moved: false,
48
51
  }
49
52
  }
50
53
  },
@@ -63,6 +66,29 @@
63
66
  const start = this.current_data && this.current_data.start_time
64
67
  const end = this.current_data && this.current_data.end_time
65
68
  return Number(start) > 0 && Number(end) > 0
69
+ },
70
+ progressValue(){
71
+ if(!this.current_data){
72
+ return 0
73
+ }
74
+ const raw = this.current_data.progress
75
+ const num = Number(raw)
76
+ if(Number.isNaN(num)){
77
+ return 0
78
+ }
79
+ return Math.max(0, Math.min(100, num))
80
+ },
81
+ progressWidth(){
82
+ return `${this.progressValue}%`
83
+ },
84
+ progressText(){
85
+ return `${this.progressValue}%`
86
+ },
87
+ progressColor(){
88
+ return this.current_data && this.current_data.bg_color ? this.current_data.bg_color : '#989b9c'
89
+ },
90
+ taskBackground(){
91
+ return this.current_data && this.current_data.task_color ? this.current_data.task_color : '#d6721f'
66
92
  }
67
93
  },
68
94
  methods:{
@@ -159,7 +185,13 @@
159
185
  toast.style.left = x + 'px'
160
186
  toast.style.top = y + 'px'
161
187
  if (add_toast) {
162
- document.getElementsByTagName('body')[0].appendChild(toast)
188
+ const host = document.fullscreenElement || document.getElementsByTagName('body')[0]
189
+ host.appendChild(toast)
190
+ } else if (document.fullscreenElement) {
191
+ const host = document.fullscreenElement
192
+ if (toast.parentNode !== host) {
193
+ host.appendChild(toast)
194
+ }
163
195
  }
164
196
  }
165
197
  }
@@ -193,9 +225,11 @@
193
225
  this.justDragged = false;
194
226
  this.DragObject.mouseDown = true;
195
227
  this.DragObject.startX = e.clientX;
228
+ this.DragObject.startY = e.clientY;
196
229
  this.DragObject.move_type = type;
197
230
  this.DragObject.start_width = this.current_data.width;
198
231
  this.DragObject.start_left = this.current_data.left;
232
+ this.DragObject.moved = false;
199
233
  for (let i in this.th_data) {
200
234
  if (this.current_data.params[i] != undefined) {
201
235
  if(this.th_data[i].time_mode == 1){
@@ -230,6 +264,14 @@
230
264
  // 拖动时间
231
265
  doc_move(e){
232
266
  if(this.DragObject.mouseDown){
267
+ const moveX = Math.abs(e.clientX - this.DragObject.startX)
268
+ const moveY = Math.abs(e.clientY - this.DragObject.startY)
269
+ if(!this.DragObject.moved){
270
+ if(moveX + moveY < 3){
271
+ return;
272
+ }
273
+ this.DragObject.moved = true;
274
+ }
233
275
  this.justDragged = true;
234
276
  this.hideToast();
235
277
  let move_mode_width = 0, // 宽度基值
@@ -260,8 +302,7 @@
260
302
  move_mode_width = -1
261
303
  }
262
304
  }
263
- let moveX = Math.abs(e.clientX - this.DragObject.startX), // 移动的距离
264
- move_unit = move_mode_width * (Math.ceil(moveX/this.DragObject.scale)), // 移动的时间
305
+ let move_unit = move_mode_width * (Math.ceil(moveX/this.DragObject.scale)), // 移动的时间
265
306
  time_mode = 60*60*1000 // 时间类型
266
307
  let start_time = this.DragObject.start_time,
267
308
  end_time = this.DragObject.end_time
@@ -336,7 +377,7 @@
336
377
  document.removeEventListener('mouseup',this.doc_up,false);
337
378
  document.body.classList.remove('unselecttable');
338
379
  document.body.style.cursor = null;
339
- if(this.DragObject.startX != e.clientX){
380
+ if(this.DragObject.moved){
340
381
  emitter.$emit('onDragChangeTime',
341
382
  {
342
383
  gunter_id: this.current_data.gunter_id,
@@ -351,6 +392,7 @@
351
392
  }
352
393
  this.DragObject = {
353
394
  startX: 0, // 开始的位置
395
+ startY: 0,
354
396
  mouseDown: false,// 是否按下了鼠标
355
397
  scale: 0, // 刻度
356
398
  mode: 1, // 默认以小时为单位 1:小时 2 :天
@@ -361,6 +403,7 @@
361
403
  startAttr: null,// 开始时间的属性名
362
404
  endAttr: null,// 结束时间的属性名
363
405
  move_type: null,
406
+ moved: false,
364
407
  };
365
408
  this.hideToast();
366
409
  if(this.justDragged){
@@ -385,11 +428,23 @@
385
428
  /*transition: width .5s linear, opacity .2s ease;*/
386
429
  opacity: 0.5;
387
430
  position: relative;
431
+ display: flex;
432
+ align-items: center;
433
+ .ganteview-item__progress{
434
+ position: absolute;
435
+ left: 0;
436
+ top: 0;
437
+ height: 100%;
438
+ border-radius: 3px;
439
+ z-index: 0;
440
+ }
388
441
  .ganteview-item__label{
389
442
  display: block;
390
443
  white-space: nowrap;
391
444
  overflow: hidden;
392
445
  text-overflow: ellipsis;
446
+ position: relative;
447
+ z-index: 1;
393
448
  }
394
449
  .left-drag-line,.right-drag-line{
395
450
  position: absolute;
@@ -241,31 +241,41 @@
241
241
  var list = [];
242
242
  if (time_mode == 1) {
243
243
  const dayMs = 24 * 60 * 60 * 1000;
244
+ const weekMs = 7 * dayMs;
245
+ const firstDay = new Date(this.first_day);
244
246
  let cursor = new Date(first_time);
247
+ const offset = (cursor.getDay() + 6) % 7;
248
+ cursor = new Date(cursor.getFullYear(), cursor.getMonth(), cursor.getDate() - offset);
245
249
  while (cursor.getTime() <= all_width) {
246
- const monthEnd = new Date(cursor.getFullYear(), cursor.getMonth() + 1, 1);
247
- const remainingDays = Math.ceil((monthEnd.getTime() - cursor.getTime()) / dayMs);
248
- if (remainingDays < 7 && list.length) {
249
- const prev = list[list.length - 1];
250
- const extraWidth = (monthEnd.getTime() - cursor.getTime()) / time;
251
- prev.width += extraWidth;
252
- this.header_width += extraWidth;
253
- cursor = monthEnd;
254
- continue;
250
+ const weekStart = cursor;
251
+ const weekEnd = new Date(weekStart.getTime() + weekMs);
252
+ let partStart = weekStart;
253
+ if (partStart.getTime() < firstDay.getTime()) {
254
+ partStart = new Date(firstDay);
255
255
  }
256
- let next = new Date(cursor.getFullYear(), cursor.getMonth(), cursor.getDate() + 7);
257
- if (next.getTime() > monthEnd.getTime()) {
258
- next = monthEnd;
256
+ let partEnd = weekEnd;
257
+ if (partEnd.getTime() > all_width) {
258
+ partEnd = new Date(all_width);
259
259
  }
260
- const width = (next.getTime() - cursor.getTime()) / time;
260
+ if (partEnd.getTime() <= partStart.getTime()) {
261
+ break;
262
+ }
263
+ const monthBoundary = new Date(partStart.getFullYear(), partStart.getMonth() + 1, 1);
264
+ let labelDate = partStart;
265
+ if (monthBoundary.getTime() > partStart.getTime() && monthBoundary.getTime() < partEnd.getTime()) {
266
+ const beforeDays = Math.round((monthBoundary.getTime() - partStart.getTime()) / dayMs);
267
+ const afterDays = Math.round((partEnd.getTime() - monthBoundary.getTime()) / dayMs);
268
+ labelDate = afterDays > beforeDays ? monthBoundary : partStart;
269
+ }
270
+ const width = (partEnd.getTime() - partStart.getTime()) / time;
261
271
  this.header_width += width;
262
272
  list.push({
263
- left: (cursor.getTime() - this.first_day.getTime()) / time,
273
+ left: (partStart.getTime() - this.first_day.getTime()) / time,
264
274
  width: width,
265
- date: this.format(cursor, 2)
275
+ date: this.format(labelDate, 2)
266
276
  });
267
- cursor = next;
268
- this.future_time = cursor.getTime();
277
+ cursor = weekEnd;
278
+ this.future_time = partEnd.getTime();
269
279
  }
270
280
  } else if (time_mode == 2) {
271
281
  const weekMs = 7 * 24 * 60 * 60 * 1000;
@@ -372,13 +382,13 @@
372
382
  // | `4` | 星期四 |
373
383
  // | `5` | 星期五 |
374
384
  // | `6` | 星期六 |
375
- if (old_time.getDay() == 0 || old_time.getDay() == 6) {
376
- is_rest = true
377
- }
385
+ // if (old_time.getDay() == 0 || old_time.getDay() == 6) {
386
+ // is_rest = true
387
+ // }
378
388
  } else if (mode == 2) {
379
389
  first_time = new Date(first_time.getFullYear(), first_time.getMonth(), first_time.getDate() + 7)
380
390
  const weekNumber = this.get_week_number(old_time)
381
- date = `W${weekNumber}`
391
+ date = `第${weekNumber}周`
382
392
  title = this.format(old_time, 1) + '~' + this.format(new Date(first_time.getFullYear(), first_time.getMonth(), first_time.getDate() - 1), 1)
383
393
  } else if (mode == 3) {
384
394
  first_time = new Date(first_time.getFullYear(), first_time.getMonth() + 1, 1)
@@ -1,6 +1,6 @@
1
1
  <!--中间分割线,分割左侧表格和右侧图表-->
2
2
  <template>
3
- <div @mousedown="down" ref="split_liu" :style="{left:Number(left)?left+'px':left}" class="gante-split-liu">
3
+ <div @mousedown.prevent="down" ref="split_liu" :style="{left:Number(left)?left+'px':left}" class="gante-split-liu">
4
4
  <div v-show="show_split" :style="{left:split_resize_left+'px'}" class="gante-split-liu-resize"></div>
5
5
  </div>
6
6
  </template>
@@ -232,6 +232,7 @@
232
232
  this.tTD.current_index = target.dataset.key //记录拖动的是哪个th
233
233
  this.proxy_left = this.oldx+3 //必须要加上3像素,不然拖动会有问题
234
234
  this.tTD.mouseDown = true
235
+ document.getElementsByTagName('body')[0].classList.add('unselecttable')
235
236
  // 给document绑定事件
236
237
  document.addEventListener('mousemove',this.doc_move,{passive:false})
237
238
  document.addEventListener('mouseup',this.doc_up,{passive:false})
@@ -267,6 +268,7 @@
267
268
  this.oldx = 0
268
269
  this.old_width = 0
269
270
  this.tTD.current_index = null
271
+ document.getElementsByTagName('body')[0].classList.remove('unselecttable')
270
272
  // 给document移除绑定事件
271
273
  document.removeEventListener('mousemove',this.doc_move,false)
272
274
  document.removeEventListener('mouseup',this.doc_up,false)
@@ -10,6 +10,10 @@
10
10
  class="gante-dropdown"
11
11
  @input="(val)=> trickMode(val)"
12
12
  ></dropdown>
13
+ <div @click="toFullScreen" class="fullScreen">
14
+ <img v-if="fullScreen" src="../../assets/outScreen.png" alt="">
15
+ <img v-else src="../../assets/fullScreen.png" alt="">
16
+ </div>
13
17
 
14
18
  </div>
15
19
  <!--左边表格-->
@@ -460,7 +464,7 @@
460
464
  box-sizing: border-box;
461
465
  .gante-menu{
462
466
  position: absolute;
463
- right: 20px;
467
+ right: 40px;
464
468
  top: 55px;
465
469
  display: flex;
466
470
  align-items: center;
@@ -34,9 +34,10 @@ export default {
34
34
  methods: {
35
35
  // 回到今天
36
36
  toToday(){
37
- let today = document.getElementById('today-ganteview-column');
38
- let ganteview = document.getElementsByClassName('ganteview')[0];
39
- if(ganteview){
37
+ const container = this.$refs && this.$refs.gante_box ? this.$refs.gante_box : this.$el;
38
+ const today = container ? container.querySelector('#today-ganteview-column') : null;
39
+ const ganteview = container ? container.querySelector('.ganteview') : null;
40
+ if(ganteview && today){
40
41
  let left = today.offsetLeft - ganteview.clientHeight/2;
41
42
  if(left<0){
42
43
  left = 0
@@ -65,7 +66,7 @@ export default {
65
66
  },
66
67
  //全屏 退出全屏
67
68
  toFullScreen(){
68
- let element = document.documentElement;
69
+ let element = this.$refs && this.$refs.gante_box ? this.$refs.gante_box : this.$el;
69
70
  // 判断是否已经是全屏
70
71
  // 如果是全屏,退出
71
72
  if (this.fullScreen) {
package/gante.vue CHANGED
@@ -10,7 +10,10 @@
10
10
  class="gante-dropdown"
11
11
  @input="(val)=> trickMode(val)"
12
12
  ></dropdown>
13
-
13
+ <div @click="toFullScreen" class="fullScreen">
14
+ <img v-if="fullScreen" src="../../assets/outScreen.png" alt="">
15
+ <img v-else src="../../assets/fullScreen.png" alt="">
16
+ </div>
14
17
  </div>
15
18
  <!--左边表格-->
16
19
  <div :style="{width: Number(tabe_width)? tabe_width+'px' : tabe_width }" class="gante-table-box">
@@ -474,7 +477,7 @@
474
477
  box-sizing: border-box;
475
478
  .gante-menu{
476
479
  position: absolute;
477
- right: 20px;
480
+ right: 40px;
478
481
  top: 55px;
479
482
  display: flex;
480
483
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gunter-kgd",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "main": "gante-vue.common.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"