vxe-gantt 3.4.10 → 3.5.0

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.
@@ -8,8 +8,10 @@ import GanttViewBodyComponent from './gantt-body';
8
8
  import GanttViewFooterComponent from './gantt-footer';
9
9
  const { globalEvents } = VxeUI;
10
10
  const sourceType = 'gantt';
11
+ const secondMs = 1000;
11
12
  const minuteMs = 1000 * 60;
12
- const dayMs = minuteMs * 60 * 24;
13
+ const hourMs = 1000 * 60 * 60;
14
+ const dayMs = hourMs * 24;
13
15
  function createInternalData() {
14
16
  return {
15
17
  xeTable: null,
@@ -70,8 +72,7 @@ const maxYHeight = 5e6;
70
72
  // const maxXWidth = 5e6
71
73
  function parseStringDate($xeGanttView, dateValue) {
72
74
  const $xeGantt = $xeGanttView.$xeGantt;
73
- const taskOpts = $xeGantt.computeTaskOpts;
74
- const { dateFormat } = taskOpts;
75
+ const dateFormat = $xeGantt.computeDateFormat;
75
76
  return XEUtils.toStringDate(dateValue, dateFormat || null);
76
77
  }
77
78
  function updateTodayData($xeGanttView) {
@@ -304,196 +305,270 @@ function parseWeekObj(date, firstDay) {
304
305
  }
305
306
  function createChartRender($xeGanttView, fullCols) {
306
307
  const $xeGantt = $xeGanttView.$xeGantt;
307
- const reactData = $xeGanttView.reactData;
308
- const { minViewDate } = reactData;
309
308
  const minScale = $xeGantt.computeMinScale;
310
309
  const scaleUnit = $xeGantt.computeScaleUnit;
311
310
  const weekScale = $xeGantt.computeWeekScale;
311
+ const dateFormat = $xeGantt.computeDateFormat;
312
312
  if (minScale) {
313
313
  switch (scaleUnit) {
314
314
  case 'year': {
315
+ const showActualProgress = /M|d|H|mm|ss|S/.test(dateFormat);
316
+ const renderFormat = 'yyyy';
315
317
  const indexMaps = {};
316
318
  fullCols.forEach(({ dateObj }, i) => {
317
319
  const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy');
318
320
  indexMaps[yyyyMM] = i;
319
321
  });
320
322
  return (startValue, endValue) => {
321
- const startDate = parseStringDate($xeGanttView, startValue);
322
- const endDate = parseStringDate($xeGanttView, endValue);
323
- const startStr = XEUtils.toDateString(startDate, 'yyyy');
324
- const startFirstDate = XEUtils.getWhatYear(startDate, 0, 'first');
325
- const endStr = XEUtils.toDateString(endDate, 'yyyy');
323
+ const startValDate = parseStringDate($xeGanttView, startValue);
324
+ const endValDate = parseStringDate($xeGanttView, endValue);
325
+ const startStr = XEUtils.toDateString(startValDate, renderFormat);
326
+ const startDate = showActualProgress ? startValDate : XEUtils.getWhatYear(startValDate, 0, 'first');
327
+ const startFirstDate = XEUtils.getWhatYear(startValDate, 0, 'first');
328
+ const endStr = XEUtils.toDateString(endValDate, renderFormat);
329
+ const endDate = showActualProgress ? endValDate : XEUtils.getWhatYear(endValDate, 0, 'last');
326
330
  const endFirstDate = XEUtils.getWhatYear(endDate, 0, 'first');
327
- const dateSize = Math.floor((XEUtils.getWhatYear(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs);
328
- const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize;
329
- const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize;
330
- const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
331
+ // 当前是年维度,当指定解析格式精确到天时,显示实际进度
332
+ let startSubtractSize = 0;
333
+ let endSubtractSize = 1;
334
+ if (showActualProgress) {
335
+ // 按年的天数比计算
336
+ const syDaySize = XEUtils.getDayOfYear(startDate, 0);
337
+ startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs / syDaySize;
338
+ const eyDaySize = XEUtils.getDayOfYear(endDate, 0);
339
+ endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs / eyDaySize;
340
+ }
341
+ const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
331
342
  return {
332
343
  offsetLeftSize,
333
- offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
344
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + endSubtractSize
334
345
  };
335
346
  };
336
347
  }
337
348
  case 'quarter': {
349
+ const showActualProgress = /M|d|H|mm|ss|S/.test(dateFormat);
350
+ const renderFormat = 'yyyy-q';
338
351
  const indexMaps = {};
339
352
  fullCols.forEach(({ dateObj }, i) => {
340
- const q = XEUtils.toDateString(dateObj.date, 'yyyy-q');
353
+ const q = XEUtils.toDateString(dateObj.date, renderFormat);
341
354
  indexMaps[q] = i;
342
355
  });
343
356
  return (startValue, endValue) => {
344
- const startDate = parseStringDate($xeGanttView, startValue);
345
- const endDate = parseStringDate($xeGanttView, endValue);
346
- const startStr = XEUtils.toDateString(startDate, 'yyyy-q');
347
- const startFirstDate = XEUtils.getWhatQuarter(startDate, 0, 'first');
348
- const endStr = XEUtils.toDateString(endDate, 'yyyy-q');
357
+ const startValDate = parseStringDate($xeGanttView, startValue);
358
+ const endValDate = parseStringDate($xeGanttView, endValue);
359
+ const startStr = XEUtils.toDateString(startValDate, renderFormat);
360
+ const startDate = showActualProgress ? startValDate : XEUtils.getWhatQuarter(startValDate, 0, 'first');
361
+ const startFirstDate = XEUtils.getWhatQuarter(startValDate, 0, 'first');
362
+ const endStr = XEUtils.toDateString(endValDate, renderFormat);
363
+ const endDate = showActualProgress ? endValDate : XEUtils.getWhatQuarter(endValDate, 0, 'last');
349
364
  const endFirstDate = XEUtils.getWhatQuarter(endDate, 0, 'first');
350
- const dateSize = Math.floor((XEUtils.getWhatQuarter(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs);
351
- const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize;
352
- const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize;
353
- const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
365
+ // 当前是季度维度,当指定解析格式精确到天时,显示实际进度
366
+ let startSubtractSize = 0;
367
+ let endSubtractSize = 1;
368
+ if (showActualProgress) {
369
+ // 按季度天数比计算
370
+ const sqDaySize = XEUtils.getDayOfQuarter(startDate, 0);
371
+ startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs / sqDaySize;
372
+ const eqDaySize = XEUtils.getDayOfQuarter(endDate, 0);
373
+ endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs / eqDaySize;
374
+ }
375
+ const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
354
376
  return {
355
377
  offsetLeftSize,
356
- offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
378
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + endSubtractSize
357
379
  };
358
380
  };
359
381
  }
360
382
  case 'month': {
383
+ const renderFormat = 'yyyy-MM';
384
+ const showActualProgress = /d|H|mm|ss|S/.test(dateFormat);
361
385
  const indexMaps = {};
362
386
  fullCols.forEach(({ dateObj }, i) => {
363
- const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM');
387
+ const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
364
388
  indexMaps[yyyyMM] = i;
365
389
  });
366
390
  return (startValue, endValue) => {
367
- const startDate = parseStringDate($xeGanttView, startValue);
368
- const endDate = parseStringDate($xeGanttView, endValue);
369
- const startStr = XEUtils.toDateString(startDate, 'yyyy-MM');
370
- const startFirstDate = XEUtils.getWhatMonth(startDate, 0, 'first');
371
- const endStr = XEUtils.toDateString(endDate, 'yyyy-MM');
391
+ const startValDate = parseStringDate($xeGanttView, startValue);
392
+ const endValDate = parseStringDate($xeGanttView, endValue);
393
+ const startStr = XEUtils.toDateString(startValDate, renderFormat);
394
+ const startDate = showActualProgress ? startValDate : XEUtils.getWhatMonth(startValDate, 0, 'first');
395
+ const startFirstDate = XEUtils.getWhatMonth(startValDate, 0, 'first');
396
+ const endStr = XEUtils.toDateString(endValDate, renderFormat);
397
+ const endDate = showActualProgress ? endValDate : XEUtils.getWhatMonth(endValDate, 0, 'last');
372
398
  const endFirstDate = XEUtils.getWhatMonth(endDate, 0, 'first');
373
- const dateSize = Math.floor((XEUtils.getWhatMonth(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / dayMs);
374
- const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize;
375
- const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize;
376
- const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
399
+ // 当前是月维度,当指定解析格式精确到天时,显示实际进度
400
+ let startSubtractSize = 0;
401
+ let endSubtractSize = 1;
402
+ if (showActualProgress) {
403
+ // 按月天数比计算
404
+ const smDaySize = XEUtils.getDayOfMonth(startDate, 0);
405
+ startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs / smDaySize;
406
+ const emDaySize = XEUtils.getDayOfMonth(endDate, 0);
407
+ endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs / emDaySize;
408
+ }
409
+ const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
377
410
  return {
378
411
  offsetLeftSize,
379
- offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
412
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + endSubtractSize
380
413
  };
381
414
  };
382
415
  }
383
416
  case 'week': {
417
+ const showActualProgress = /d|mm|ss|S/.test(dateFormat);
384
418
  const indexMaps = {};
385
419
  fullCols.forEach(({ dateObj }, i) => {
386
420
  const yyyyW = `${dateObj.yyyy}-${dateObj.W}`;
387
421
  indexMaps[yyyyW] = i;
388
422
  });
389
423
  return (startValue, endValue) => {
390
- const startDate = parseStringDate($xeGanttView, startValue);
391
- const endDate = parseStringDate($xeGanttView, endValue);
392
- const startWeekObj = parseWeekObj(startDate, weekScale ? weekScale.startDay : undefined);
424
+ const weekStartDay = weekScale ? weekScale.startDay : undefined;
425
+ const startValDate = parseStringDate($xeGanttView, startValue);
426
+ const endValDate = parseStringDate($xeGanttView, endValue);
427
+ const startDate = showActualProgress ? startValDate : XEUtils.getWhatWeek(startValDate, 0, 'first', weekStartDay);
428
+ const startWeekObj = parseWeekObj(startDate, weekStartDay);
393
429
  const startStr = `${startWeekObj.yyyy}-${startWeekObj.W}`;
394
- const startFirstDate = XEUtils.getWhatWeek(startDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined);
395
- const endWeekObj = parseWeekObj(endDate, weekScale ? weekScale.startDay : undefined);
430
+ const startFirstDate = XEUtils.getWhatWeek(startDate, 0, 'first', weekStartDay);
431
+ const endDate = showActualProgress ? endValDate : XEUtils.getWhatWeek(endValDate, 0, 'first', weekStartDay);
432
+ const endWeekObj = parseWeekObj(endDate, weekStartDay);
396
433
  const endStr = `${endWeekObj.yyyy}-${endWeekObj.W}`;
397
- const endFirstDate = XEUtils.getWhatWeek(endDate, 0, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined);
398
- const dateSize = Math.floor((XEUtils.getWhatWeek(endDate, 1, weekScale ? weekScale.startDay : undefined, weekScale ? weekScale.startDay : undefined).getTime() - endFirstDate.getTime()) / dayMs);
399
- const subtract = (startDate.getTime() - startFirstDate.getTime()) / dayMs / dateSize;
400
- const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / dayMs + 1) / dateSize;
401
- const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
434
+ const endFirstDate = XEUtils.getWhatWeek(endDate, 0, 'first', weekStartDay);
435
+ // 当前是周维度,当指定解析格式精确到天时,显示实际进度
436
+ let startSubtractSize = 0;
437
+ let endSubtractSize = 1;
438
+ if (showActualProgress) {
439
+ // 按周天数比计算
440
+ startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs / 7;
441
+ endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs / 7;
442
+ }
443
+ const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
402
444
  return {
403
445
  offsetLeftSize,
404
- offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
446
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + endSubtractSize
405
447
  };
406
448
  };
407
449
  }
408
450
  case 'day':
409
451
  case 'date': {
452
+ const renderFormat = 'yyyy-MM-dd';
453
+ const showActualProgress = /mm|ss|S/.test(dateFormat);
410
454
  const indexMaps = {};
411
455
  fullCols.forEach(({ dateObj }, i) => {
412
- const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd');
456
+ const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
413
457
  indexMaps[yyyyMM] = i;
414
458
  });
415
459
  return (startValue, endValue) => {
416
- const startDate = parseStringDate($xeGanttView, startValue);
417
- const endDate = parseStringDate($xeGanttView, endValue);
418
- const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd');
460
+ const startValDate = parseStringDate($xeGanttView, startValue);
461
+ const endValDate = parseStringDate($xeGanttView, endValue);
462
+ const startStr = XEUtils.toDateString(startValDate, renderFormat);
463
+ const startDate = showActualProgress ? startValDate : XEUtils.getWhatDay(startValDate, 0, 'first');
419
464
  const startFirstDate = XEUtils.getWhatDay(startDate, 0, 'first');
420
- const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd');
465
+ const endStr = XEUtils.toDateString(endValDate, renderFormat);
466
+ const endDate = showActualProgress ? endValDate : XEUtils.getWhatDay(endValDate, 0, 'last');
421
467
  const endFirstDate = XEUtils.getWhatDay(endDate, 0, 'first');
422
- const minuteSize = Math.floor((XEUtils.getWhatDay(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs);
423
- // 开始和结束时间是否存在偏移时
424
- const startSubtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize;
425
- const endSubtract = (endDate.getTime() - endFirstDate.getTime()) / minuteMs / minuteSize;
426
- const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize;
427
- const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtract;
428
- // 如果最小轴为天,当存在时分秒时,在当前单元格内渲染维度;如果不存在,则填充满单元格
468
+ // 当前是天维度,当指定解析格式精确到时分秒豪秒时,显示实际进度
469
+ let startSubtractSize = 0;
470
+ let endSubtractSize = 1;
471
+ if (showActualProgress) {
472
+ startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs;
473
+ endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs;
474
+ }
475
+ const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
429
476
  return {
430
477
  offsetLeftSize,
431
- offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize + (startSubtract || endSubtract ? 0 : 1)
478
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + endSubtractSize
432
479
  };
433
480
  };
434
481
  }
435
482
  case 'hour': {
483
+ const renderFormat = 'yyyy-MM-dd HH';
484
+ const showActualProgress = /mm|ss|S/.test(dateFormat);
436
485
  const indexMaps = {};
437
486
  fullCols.forEach(({ dateObj }, i) => {
438
- const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH');
487
+ const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
439
488
  indexMaps[yyyyMM] = i;
440
489
  });
441
490
  return (startValue, endValue) => {
442
- const startDate = parseStringDate($xeGanttView, startValue);
443
- const endDate = parseStringDate($xeGanttView, endValue);
444
- const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH');
491
+ const startValDate = parseStringDate($xeGanttView, startValue);
492
+ const endValDate = parseStringDate($xeGanttView, endValue);
493
+ const startStr = XEUtils.toDateString(startValDate, renderFormat);
494
+ const startDate = showActualProgress ? startValDate : XEUtils.getWhatHours(startValDate, 0, 'first');
445
495
  const startFirstDate = XEUtils.getWhatHours(startDate, 0, 'first');
446
- const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH');
496
+ const endStr = XEUtils.toDateString(endValDate, renderFormat);
497
+ const endDate = showActualProgress ? endValDate : XEUtils.getWhatHours(endValDate, 0, 'last');
447
498
  const endFirstDate = XEUtils.getWhatHours(endDate, 0, 'first');
448
- const minuteSize = Math.floor((XEUtils.getWhatHours(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs);
449
- // 开始和结束时间是否存在偏移时
450
- const startSubtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize;
451
- const endSubtract = (endDate.getTime() - endFirstDate.getTime()) / minuteMs / minuteSize;
452
- const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize;
453
- const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtract;
499
+ // 当前是小时维度,当指定解析格式精确到分秒豪秒时,显示实际进度
500
+ let startSubtractSize = 0;
501
+ let endSubtractSize = 1;
502
+ if (showActualProgress) {
503
+ startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / hourMs;
504
+ endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / hourMs;
505
+ }
506
+ const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
454
507
  return {
455
508
  offsetLeftSize,
456
- offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize + (startSubtract || endSubtract ? 0 : 1)
509
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + endSubtractSize
457
510
  };
458
511
  };
459
512
  }
460
513
  case 'minute': {
514
+ const renderFormat = 'yyyy-MM-dd HH:mm';
515
+ const showActualProgress = /ss|S/.test(dateFormat);
461
516
  const indexMaps = {};
462
517
  fullCols.forEach(({ dateObj }, i) => {
463
- const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy-MM-dd HH:mm');
518
+ const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
464
519
  indexMaps[yyyyMM] = i;
465
520
  });
466
521
  return (startValue, endValue) => {
467
- const startDate = parseStringDate($xeGanttView, startValue);
468
- const endDate = parseStringDate($xeGanttView, endValue);
469
- const startStr = XEUtils.toDateString(startDate, 'yyyy-MM-dd HH:mm');
522
+ const startValDate = parseStringDate($xeGanttView, startValue);
523
+ const endValDate = parseStringDate($xeGanttView, endValue);
524
+ const startStr = XEUtils.toDateString(startValDate, renderFormat);
525
+ const startDate = showActualProgress ? startValDate : XEUtils.getWhatMinutes(startValDate, 0, 'first');
470
526
  const startFirstDate = XEUtils.getWhatMinutes(startDate, 0, 'first');
471
- const endStr = XEUtils.toDateString(endDate, 'yyyy-MM-dd HH:mm');
527
+ const endStr = XEUtils.toDateString(endValDate, renderFormat);
528
+ const endDate = showActualProgress ? endValDate : XEUtils.getWhatMinutes(endValDate, 0, 'last');
472
529
  const endFirstDate = XEUtils.getWhatMinutes(endDate, 0, 'first');
473
- const minuteSize = Math.floor((XEUtils.getWhatMinutes(endDate, 1, 'first').getTime() - endFirstDate.getTime()) / minuteMs);
474
- const subtract = (startDate.getTime() - startFirstDate.getTime()) / minuteMs / minuteSize;
475
- const addSize = Math.max(0, (endDate.getTime() - endFirstDate.getTime()) / minuteMs + 1) / minuteSize;
476
- const offsetLeftSize = (indexMaps[startStr] || 0) + subtract;
530
+ // 当前是分钟维度,当指定解析格式精确到秒豪秒时,显示实际进度
531
+ let startSubtractSize = 0;
532
+ let endSubtractSize = 1;
533
+ if (showActualProgress) {
534
+ startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / minuteMs;
535
+ endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / minuteMs;
536
+ }
537
+ const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
477
538
  return {
478
539
  offsetLeftSize,
479
- offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + addSize
540
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + endSubtractSize
480
541
  };
481
542
  };
482
543
  }
483
544
  case 'second': {
484
- const gapTime = getStandardGapTime(minScale.type);
545
+ const renderFormat = 'yyyy-MM-dd HH:mm:ss';
546
+ const showActualProgress = /S/.test(dateFormat);
547
+ const indexMaps = {};
548
+ fullCols.forEach(({ dateObj }, i) => {
549
+ const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
550
+ indexMaps[yyyyMM] = i;
551
+ });
485
552
  return (startValue, endValue) => {
486
- const startDate = parseStringDate($xeGanttView, startValue);
487
- const endDate = parseStringDate($xeGanttView, endValue);
488
- let offsetLeftSize = 0;
489
- let offsetWidthSize = 0;
490
- if (minViewDate) {
491
- offsetLeftSize = (startDate.getTime() - minViewDate.getTime()) / gapTime;
492
- offsetWidthSize = ((endDate.getTime() - startDate.getTime()) / gapTime);
553
+ const startValDate = parseStringDate($xeGanttView, startValue);
554
+ const endValDate = parseStringDate($xeGanttView, endValue);
555
+ const startStr = XEUtils.toDateString(startValDate, renderFormat);
556
+ const startDate = showActualProgress ? startValDate : XEUtils.getWhatSeconds(startValDate, 0, 'first');
557
+ const startFirstDate = XEUtils.getWhatSeconds(startDate, 0, 'first');
558
+ const endStr = XEUtils.toDateString(endValDate, renderFormat);
559
+ const endDate = showActualProgress ? endValDate : XEUtils.getWhatSeconds(endValDate, 0, 'last');
560
+ const endFirstDate = XEUtils.getWhatSeconds(endDate, 0, 'first');
561
+ // 当前是秒维度,当指定解析格式精确到豪秒时,显示实际进度
562
+ let startSubtractSize = 0;
563
+ let endSubtractSize = 1;
564
+ if (showActualProgress) {
565
+ startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / secondMs;
566
+ endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / secondMs;
493
567
  }
568
+ const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
494
569
  return {
495
570
  offsetLeftSize,
496
- offsetWidthSize
571
+ offsetWidthSize: (indexMaps[endStr] || 0) - offsetLeftSize + endSubtractSize
497
572
  };
498
573
  };
499
574
  }
@@ -244,6 +244,12 @@ export default {
244
244
  const minScale = $xeGantt.computeMinScale;
245
245
  return minScale ? minScale.type : 'date';
246
246
  },
247
+ computeDateFormat() {
248
+ const $xeGantt = this;
249
+ const taskOpts = $xeGantt.computeTaskOpts;
250
+ const { dateFormat } = taskOpts;
251
+ return dateFormat || 'yyyy-MM-dd HH:m:ss';
252
+ },
247
253
  computeMinScale() {
248
254
  const $xeGantt = this;
249
255
  const reactData = $xeGantt.reactData;
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { setConfig, setIcon } = VxeUI;
3
- VxeUI.ganttVersion = "3.4.10";
3
+ VxeUI.ganttVersion = "3.5.0";
4
4
  const ymdFormat = 'yyyy-MM-dd';
5
5
  const ymdhmsFormat = 'yyyy-MM-dd HH:mm:ss';
6
6
  setConfig({
package/es/ui/src/log.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const ganttVersion = `gantt v${"3.4.10"}`;
3
+ const ganttVersion = `gantt v${"3.5.0"}`;
4
4
  export function createComponentLog(name) {
5
5
  const uiVersion = VxeUI.uiVersion ? `ui v${VxeUI.uiVersion}` : '';
6
6
  const tableVersion = VxeUI.tableVersion ? `table v${VxeUI.tableVersion}` : '';