vxe-gantt 4.5.3 → 4.6.0-beta.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.
package/dist/all.esm.js CHANGED
@@ -6,7 +6,7 @@ import DomZIndex from 'dom-zindex';
6
6
  import { VxeTable } from 'vxe-table';
7
7
 
8
8
  const { setConfig: setConfig$1, setIcon } = VxeUI;
9
- VxeUI.ganttVersion = "4.5.3";
9
+ VxeUI.ganttVersion = "4.6.0-beta.0";
10
10
  const ymdFormat = 'yyyy-MM-dd';
11
11
  const ymdhmsFormat = 'yyyy-MM-dd HH:mm:ss';
12
12
  setConfig$1({
@@ -114,7 +114,7 @@ setIcon({
114
114
  });
115
115
 
116
116
  const { log } = VxeUI;
117
- const ganttVersion = `gantt v${"4.5.3"}`;
117
+ const ganttVersion = `gantt v${"4.6.0-beta.0"}`;
118
118
  function createComponentLog(name) {
119
119
  const uiVersion = VxeUI.uiVersion ? `ui v${VxeUI.uiVersion}` : '';
120
120
  const tableVersion = VxeUI.tableVersion ? `table v${VxeUI.tableVersion}` : '';
@@ -1355,7 +1355,7 @@ var GanttViewComponent = defineVxeComponent({
1355
1355
  const xID = XEUtils.uniqueId();
1356
1356
  const $xeGantt = inject('$xeGantt', {});
1357
1357
  const { reactData: ganttReactData, internalData: ganttInternalData } = $xeGantt;
1358
- const { computeDateFormat, computeTaskViewOpts, computeStartField, computeEndField, computeTypeField, computeScrollbarOpts, computeScrollbarXToTop, computeScrollbarYToLeft, computeScaleUnit, computeWeekScale, computeMinScale, computeTaskNowLineOpts } = $xeGantt.getComputeMaps();
1358
+ const { computeDateFormat, computeTaskViewOpts, computeStartField, computeEndField, computeTypeField, computeScrollbarOpts, computeScrollbarXToTop, computeScrollbarYToLeft, computeScaleUnit, computeWeekScale, computeMinScale, computeTaskNowLineOpts, computeScaleStep } = $xeGantt.getComputeMaps();
1359
1359
  const refElem = ref();
1360
1360
  const refScrollXVirtualElem = ref();
1361
1361
  const refScrollYVirtualElem = ref();
@@ -1381,6 +1381,7 @@ var GanttViewComponent = defineVxeComponent({
1381
1381
  const { minViewDate, maxViewDate } = reactData;
1382
1382
  const taskViewOpts = computeTaskViewOpts.value;
1383
1383
  const minScale = computeMinScale.value;
1384
+ const scaleStep = computeScaleStep.value;
1384
1385
  const { gridding } = taskViewOpts;
1385
1386
  const dateList = [];
1386
1387
  if (!minScale || !minViewDate || !maxViewDate) {
@@ -1389,7 +1390,6 @@ var GanttViewComponent = defineVxeComponent({
1389
1390
  const { type, startDay } = minScale;
1390
1391
  const leftSize = -(ganttReactData.currLeftSpacing + XEUtils.toNumber(gridding ? gridding.leftSpacing || 0 : 0));
1391
1392
  const rightSize = ganttReactData.currRightSpacing + XEUtils.toNumber(gridding ? gridding.rightSpacing || 0 : 0);
1392
- const currStep = 1; // XEUtils.toNumber(step || 1) || 1
1393
1393
  switch (type) {
1394
1394
  case 'year': {
1395
1395
  let currDate = XEUtils.getWhatYear(minViewDate, leftSize, 'first');
@@ -1397,7 +1397,7 @@ var GanttViewComponent = defineVxeComponent({
1397
1397
  while (currDate <= endDate) {
1398
1398
  const itemDate = currDate;
1399
1399
  dateList.push(itemDate);
1400
- currDate = XEUtils.getWhatYear(currDate, currStep);
1400
+ currDate = XEUtils.getWhatYear(currDate, scaleStep);
1401
1401
  }
1402
1402
  break;
1403
1403
  }
@@ -1407,7 +1407,7 @@ var GanttViewComponent = defineVxeComponent({
1407
1407
  while (currDate <= endDate) {
1408
1408
  const itemDate = currDate;
1409
1409
  dateList.push(itemDate);
1410
- currDate = XEUtils.getWhatQuarter(currDate, currStep);
1410
+ currDate = XEUtils.getWhatQuarter(currDate, scaleStep);
1411
1411
  }
1412
1412
  break;
1413
1413
  }
@@ -1417,7 +1417,7 @@ var GanttViewComponent = defineVxeComponent({
1417
1417
  while (currDate <= endDate) {
1418
1418
  const itemDate = currDate;
1419
1419
  dateList.push(itemDate);
1420
- currDate = XEUtils.getWhatMonth(currDate, currStep);
1420
+ currDate = XEUtils.getWhatMonth(currDate, scaleStep);
1421
1421
  }
1422
1422
  break;
1423
1423
  }
@@ -1427,7 +1427,7 @@ var GanttViewComponent = defineVxeComponent({
1427
1427
  while (currDate <= endDate) {
1428
1428
  const itemDate = currDate;
1429
1429
  dateList.push(itemDate);
1430
- currDate = XEUtils.getWhatWeek(currDate, currStep);
1430
+ currDate = XEUtils.getWhatWeek(currDate, scaleStep);
1431
1431
  }
1432
1432
  break;
1433
1433
  }
@@ -1438,14 +1438,14 @@ var GanttViewComponent = defineVxeComponent({
1438
1438
  while (currDate <= endDate) {
1439
1439
  const itemDate = currDate;
1440
1440
  dateList.push(itemDate);
1441
- currDate = XEUtils.getWhatDay(currDate, currStep);
1441
+ currDate = XEUtils.getWhatDay(currDate, scaleStep);
1442
1442
  }
1443
1443
  break;
1444
1444
  }
1445
1445
  case 'hour':
1446
1446
  case 'minute':
1447
1447
  case 'second': {
1448
- const gapTime = getStandardGapTime(minScale.type) * currStep;
1448
+ const gapTime = getStandardGapTime(minScale.type) * scaleStep;
1449
1449
  let currTime = minViewDate.getTime() + (leftSize * gapTime);
1450
1450
  const endTime = maxViewDate.getTime() + (rightSize * gapTime);
1451
1451
  while (currTime <= endTime) {
@@ -1744,18 +1744,28 @@ var GanttViewComponent = defineVxeComponent({
1744
1744
  };
1745
1745
  const createChartRender = (fullCols) => {
1746
1746
  const minScale = computeMinScale.value;
1747
+ const scaleStep = computeScaleStep.value;
1747
1748
  const scaleUnit = computeScaleUnit.value;
1748
1749
  const weekScale = computeWeekScale.value;
1749
1750
  const dateFormat = computeDateFormat.value;
1750
1751
  if (minScale) {
1752
+ const currRatio = scaleStep > 1 ? 1 / scaleStep : 0;
1751
1753
  switch (scaleUnit) {
1752
1754
  case 'year': {
1753
- const showActualProgress = /M|d|H|mm|ss|S/.test(dateFormat);
1755
+ const showActualProgress = /M|d|H|m|s|S/.test(dateFormat);
1754
1756
  const renderFormat = 'yyyy';
1755
1757
  const indexMaps = {};
1756
1758
  fullCols.forEach(({ dateObj }, i) => {
1757
- const yyyyMM = XEUtils.toDateString(dateObj.date, 'yyyy');
1758
- indexMaps[yyyyMM] = i;
1759
+ const currStr = XEUtils.toDateString(dateObj.date, 'yyyy');
1760
+ indexMaps[currStr] = i;
1761
+ if (currRatio) {
1762
+ let currStep = scaleStep - 1;
1763
+ while (currStep) {
1764
+ const currStr = XEUtils.toDateString(XEUtils.getWhatYear(dateObj.date, scaleStep - currStep), renderFormat);
1765
+ indexMaps[currStr] = i + currRatio;
1766
+ currStep--;
1767
+ }
1768
+ }
1759
1769
  });
1760
1770
  return (startValue, endValue) => {
1761
1771
  const startValDate = parseStringDate(startValue);
@@ -1775,6 +1785,10 @@ var GanttViewComponent = defineVxeComponent({
1775
1785
  startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs / syDaySize;
1776
1786
  const eyDaySize = XEUtils.getDayOfYear(endDate, 0);
1777
1787
  endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs / eyDaySize;
1788
+ if (currRatio) {
1789
+ startSubtractSize *= currRatio;
1790
+ endSubtractSize *= currRatio;
1791
+ }
1778
1792
  }
1779
1793
  const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
1780
1794
  return {
@@ -1784,12 +1798,20 @@ var GanttViewComponent = defineVxeComponent({
1784
1798
  };
1785
1799
  }
1786
1800
  case 'quarter': {
1787
- const showActualProgress = /M|d|H|mm|ss|S/.test(dateFormat);
1801
+ const showActualProgress = /M|d|H|m|ss|S/.test(dateFormat);
1788
1802
  const renderFormat = 'yyyy-q';
1789
1803
  const indexMaps = {};
1790
1804
  fullCols.forEach(({ dateObj }, i) => {
1791
- const q = XEUtils.toDateString(dateObj.date, renderFormat);
1792
- indexMaps[q] = i;
1805
+ const currStr = XEUtils.toDateString(dateObj.date, renderFormat);
1806
+ indexMaps[currStr] = i;
1807
+ if (currRatio) {
1808
+ let currStep = scaleStep - 1;
1809
+ while (currStep) {
1810
+ const currStr = XEUtils.toDateString(XEUtils.getWhatQuarter(dateObj.date, scaleStep - currStep), renderFormat);
1811
+ indexMaps[currStr] = i + currRatio;
1812
+ currStep--;
1813
+ }
1814
+ }
1793
1815
  });
1794
1816
  return (startValue, endValue) => {
1795
1817
  const startValDate = parseStringDate(startValue);
@@ -1809,6 +1831,10 @@ var GanttViewComponent = defineVxeComponent({
1809
1831
  startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs / sqDaySize;
1810
1832
  const eqDaySize = XEUtils.getDayOfQuarter(endDate, 0);
1811
1833
  endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs / eqDaySize;
1834
+ if (currRatio) {
1835
+ startSubtractSize *= currRatio;
1836
+ endSubtractSize *= currRatio;
1837
+ }
1812
1838
  }
1813
1839
  const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
1814
1840
  return {
@@ -1819,11 +1845,19 @@ var GanttViewComponent = defineVxeComponent({
1819
1845
  }
1820
1846
  case 'month': {
1821
1847
  const renderFormat = 'yyyy-MM';
1822
- const showActualProgress = /d|H|mm|ss|S/.test(dateFormat);
1848
+ const showActualProgress = /d|H|m|ss|S/.test(dateFormat);
1823
1849
  const indexMaps = {};
1824
1850
  fullCols.forEach(({ dateObj }, i) => {
1825
- const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
1826
- indexMaps[yyyyMM] = i;
1851
+ const currStr = XEUtils.toDateString(dateObj.date, renderFormat);
1852
+ indexMaps[currStr] = i;
1853
+ if (currRatio) {
1854
+ let currStep = scaleStep - 1;
1855
+ while (currStep) {
1856
+ const currStr = XEUtils.toDateString(XEUtils.getWhatMonth(dateObj.date, scaleStep - currStep), renderFormat);
1857
+ indexMaps[currStr] = i + currRatio;
1858
+ currStep--;
1859
+ }
1860
+ }
1827
1861
  });
1828
1862
  return (startValue, endValue) => {
1829
1863
  const startValDate = parseStringDate(startValue);
@@ -1843,6 +1877,10 @@ var GanttViewComponent = defineVxeComponent({
1843
1877
  startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs / smDaySize;
1844
1878
  const emDaySize = XEUtils.getDayOfMonth(endDate, 0);
1845
1879
  endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs / emDaySize;
1880
+ if (currRatio) {
1881
+ startSubtractSize *= currRatio;
1882
+ endSubtractSize *= currRatio;
1883
+ }
1846
1884
  }
1847
1885
  const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
1848
1886
  return {
@@ -1852,14 +1890,28 @@ var GanttViewComponent = defineVxeComponent({
1852
1890
  };
1853
1891
  }
1854
1892
  case 'week': {
1855
- const showActualProgress = /d|mm|ss|S/.test(dateFormat);
1893
+ const weekStartDay = weekScale ? weekScale.startDay : undefined;
1894
+ const showActualProgress = /d|H|m|s|S/.test(dateFormat);
1856
1895
  const indexMaps = {};
1857
1896
  fullCols.forEach(({ dateObj }, i) => {
1858
- const yyyyW = `${dateObj.yyyy}-${dateObj.W}`;
1859
- indexMaps[yyyyW] = i;
1897
+ const currStr = `${dateObj.yyyy}-${dateObj.W}`;
1898
+ indexMaps[currStr] = i;
1899
+ if (currRatio) {
1900
+ let currStep = scaleStep - 1;
1901
+ while (currStep) {
1902
+ const offsetDate = XEUtils.getWhatWeek(dateObj.date, scaleStep - currStep, weekStartDay, weekStartDay);
1903
+ let [yyyy, M] = XEUtils.toDateString(offsetDate, 'yyyy-M-MM-dd-HH-mm-ss').split('-');
1904
+ const W = `${XEUtils.getYearWeek(offsetDate, weekScale ? weekScale.startDay : undefined)}`;
1905
+ if (checkWeekOfsetYear(W, M)) {
1906
+ yyyy = `${Number(yyyy) + 1}`;
1907
+ }
1908
+ const currStr = `${yyyy}-${W}`;
1909
+ indexMaps[currStr] = i + currRatio;
1910
+ currStep--;
1911
+ }
1912
+ }
1860
1913
  });
1861
1914
  return (startValue, endValue) => {
1862
- const weekStartDay = weekScale ? weekScale.startDay : undefined;
1863
1915
  const startValDate = parseStringDate(startValue);
1864
1916
  const endValDate = parseStringDate(endValue);
1865
1917
  const startDate = showActualProgress ? startValDate : XEUtils.getWhatWeek(startValDate, 0, 'first', weekStartDay);
@@ -1877,6 +1929,10 @@ var GanttViewComponent = defineVxeComponent({
1877
1929
  // 按周天数比计算
1878
1930
  startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs / 7;
1879
1931
  endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs / 7;
1932
+ if (currRatio) {
1933
+ startSubtractSize *= currRatio;
1934
+ endSubtractSize *= currRatio;
1935
+ }
1880
1936
  }
1881
1937
  const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
1882
1938
  return {
@@ -1888,11 +1944,19 @@ var GanttViewComponent = defineVxeComponent({
1888
1944
  case 'day':
1889
1945
  case 'date': {
1890
1946
  const renderFormat = 'yyyy-MM-dd';
1891
- const showActualProgress = /mm|ss|S/.test(dateFormat);
1947
+ const showActualProgress = /H|m|s|S/.test(dateFormat);
1892
1948
  const indexMaps = {};
1893
1949
  fullCols.forEach(({ dateObj }, i) => {
1894
- const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
1895
- indexMaps[yyyyMM] = i;
1950
+ const currStr = XEUtils.toDateString(dateObj.date, renderFormat);
1951
+ indexMaps[currStr] = i;
1952
+ if (currRatio) {
1953
+ let currStep = scaleStep - 1;
1954
+ while (currStep) {
1955
+ const currStr = XEUtils.toDateString(XEUtils.getWhatDay(dateObj.date, scaleStep - currStep), renderFormat);
1956
+ indexMaps[currStr] = i + currRatio;
1957
+ currStep--;
1958
+ }
1959
+ }
1896
1960
  });
1897
1961
  return (startValue, endValue) => {
1898
1962
  const startValDate = parseStringDate(startValue);
@@ -1909,6 +1973,10 @@ var GanttViewComponent = defineVxeComponent({
1909
1973
  if (showActualProgress) {
1910
1974
  startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / dayMs;
1911
1975
  endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / dayMs;
1976
+ if (currRatio) {
1977
+ startSubtractSize *= currRatio;
1978
+ endSubtractSize *= currRatio;
1979
+ }
1912
1980
  }
1913
1981
  const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
1914
1982
  return {
@@ -1919,11 +1987,19 @@ var GanttViewComponent = defineVxeComponent({
1919
1987
  }
1920
1988
  case 'hour': {
1921
1989
  const renderFormat = 'yyyy-MM-dd HH';
1922
- const showActualProgress = /mm|ss|S/.test(dateFormat);
1990
+ const showActualProgress = /m|s|S/.test(dateFormat);
1923
1991
  const indexMaps = {};
1924
1992
  fullCols.forEach(({ dateObj }, i) => {
1925
- const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
1926
- indexMaps[yyyyMM] = i;
1993
+ const currStr = XEUtils.toDateString(dateObj.date, renderFormat);
1994
+ indexMaps[currStr] = i;
1995
+ if (currRatio) {
1996
+ let currStep = scaleStep - 1;
1997
+ while (currStep) {
1998
+ const currStr = XEUtils.toDateString(XEUtils.getWhatHours(dateObj.date, scaleStep - currStep), renderFormat);
1999
+ indexMaps[currStr] = i + currRatio;
2000
+ currStep--;
2001
+ }
2002
+ }
1927
2003
  });
1928
2004
  return (startValue, endValue) => {
1929
2005
  const startValDate = parseStringDate(startValue);
@@ -1940,6 +2016,10 @@ var GanttViewComponent = defineVxeComponent({
1940
2016
  if (showActualProgress) {
1941
2017
  startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / hourMs;
1942
2018
  endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / hourMs;
2019
+ if (currRatio) {
2020
+ startSubtractSize *= currRatio;
2021
+ endSubtractSize *= currRatio;
2022
+ }
1943
2023
  }
1944
2024
  const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
1945
2025
  return {
@@ -1950,11 +2030,19 @@ var GanttViewComponent = defineVxeComponent({
1950
2030
  }
1951
2031
  case 'minute': {
1952
2032
  const renderFormat = 'yyyy-MM-dd HH:mm';
1953
- const showActualProgress = /ss|S/.test(dateFormat);
2033
+ const showActualProgress = /s|S/.test(dateFormat);
1954
2034
  const indexMaps = {};
1955
2035
  fullCols.forEach(({ dateObj }, i) => {
1956
- const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
1957
- indexMaps[yyyyMM] = i;
2036
+ const currStr = XEUtils.toDateString(dateObj.date, renderFormat);
2037
+ indexMaps[currStr] = i;
2038
+ if (currRatio) {
2039
+ let currStep = scaleStep - 1;
2040
+ while (currStep) {
2041
+ const currStr = XEUtils.toDateString(XEUtils.getWhatMinutes(dateObj.date, scaleStep - currStep), renderFormat);
2042
+ indexMaps[currStr] = i + currRatio;
2043
+ currStep--;
2044
+ }
2045
+ }
1958
2046
  });
1959
2047
  return (startValue, endValue) => {
1960
2048
  const startValDate = parseStringDate(startValue);
@@ -1971,6 +2059,10 @@ var GanttViewComponent = defineVxeComponent({
1971
2059
  if (showActualProgress) {
1972
2060
  startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / minuteMs;
1973
2061
  endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / minuteMs;
2062
+ if (currRatio) {
2063
+ startSubtractSize *= currRatio;
2064
+ endSubtractSize *= currRatio;
2065
+ }
1974
2066
  }
1975
2067
  const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
1976
2068
  return {
@@ -1984,8 +2076,16 @@ var GanttViewComponent = defineVxeComponent({
1984
2076
  const showActualProgress = /S/.test(dateFormat);
1985
2077
  const indexMaps = {};
1986
2078
  fullCols.forEach(({ dateObj }, i) => {
1987
- const yyyyMM = XEUtils.toDateString(dateObj.date, renderFormat);
1988
- indexMaps[yyyyMM] = i;
2079
+ const currStr = XEUtils.toDateString(dateObj.date, renderFormat);
2080
+ indexMaps[currStr] = i;
2081
+ if (currRatio) {
2082
+ let currStep = scaleStep - 1;
2083
+ while (currStep) {
2084
+ const currStr = XEUtils.toDateString(XEUtils.getWhatSeconds(dateObj.date, scaleStep - currStep), renderFormat);
2085
+ indexMaps[currStr] = i + currRatio;
2086
+ currStep--;
2087
+ }
2088
+ }
1989
2089
  });
1990
2090
  return (startValue, endValue) => {
1991
2091
  const startValDate = parseStringDate(startValue);
@@ -2002,6 +2102,10 @@ var GanttViewComponent = defineVxeComponent({
2002
2102
  if (showActualProgress) {
2003
2103
  startSubtractSize = (startDate.getTime() - startFirstDate.getTime()) / secondMs;
2004
2104
  endSubtractSize = (endDate.getTime() - endFirstDate.getTime()) / secondMs;
2105
+ if (currRatio) {
2106
+ startSubtractSize *= currRatio;
2107
+ endSubtractSize *= currRatio;
2108
+ }
2005
2109
  }
2006
2110
  const offsetLeftSize = (indexMaps[startStr] || 0) + startSubtractSize;
2007
2111
  return {
@@ -3312,6 +3416,11 @@ var VxeGanttComponent = defineVxeComponent({
3312
3416
  const { taskScaleList } = reactData;
3313
3417
  return XEUtils.last(taskScaleList);
3314
3418
  });
3419
+ const computeScaleStep = computed(() => {
3420
+ const minScale = computeMinScale.value;
3421
+ const { step } = minScale;
3422
+ return XEUtils.toNumber(step || 1) || 1;
3423
+ });
3315
3424
  const computeWeekScale = computed(() => {
3316
3425
  const { taskScaleList } = reactData;
3317
3426
  return taskScaleList.find(item => item.type === 'week');
@@ -3572,6 +3681,7 @@ var VxeGanttComponent = defineVxeComponent({
3572
3681
  computeScaleUnit,
3573
3682
  computeDateFormat,
3574
3683
  computeMinScale,
3684
+ computeScaleStep,
3575
3685
  computeWeekScale,
3576
3686
  computeTitleField,
3577
3687
  computeStartField,
@@ -3601,11 +3711,7 @@ var VxeGanttComponent = defineVxeComponent({
3601
3711
  scaleList.forEach(conf => {
3602
3712
  const sConf = !conf || XEUtils.isString(conf) ? { type: conf } : conf;
3603
3713
  const type = sConf.type;
3604
- const step = sConf.step;
3605
3714
  const level = getViewTypeLevel(type);
3606
- if (step) {
3607
- errLog('vxe.error.errProp', [`step=${step}`, 'step=1']);
3608
- }
3609
3715
  if (!type || !viewTypeLevelMaps[type]) {
3610
3716
  errLog('vxe.error.errProp', [`type=${type}`, XEUtils.keys(viewTypeLevelMaps).join(',')]);
3611
3717
  return;