vxe-gantt 4.0.4 → 4.0.6

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.
Files changed (48) hide show
  1. package/es/gantt/src/emits.js +3 -1
  2. package/es/gantt/src/gantt-chart.js +18 -4
  3. package/es/gantt/src/gantt-header.js +29 -6
  4. package/es/gantt/src/gantt-view.js +232 -89
  5. package/es/gantt/src/gantt.js +60 -3
  6. package/es/gantt/src/util.js +6 -0
  7. package/es/gantt/style.css +2 -0
  8. package/es/gantt/style.min.css +1 -1
  9. package/es/style.css +1 -1
  10. package/es/style.min.css +1 -1
  11. package/es/ui/index.js +6 -1
  12. package/es/ui/src/log.js +1 -1
  13. package/es/vxe-gantt/style.css +2 -0
  14. package/es/vxe-gantt/style.min.css +1 -1
  15. package/lib/gantt/src/emits.js +1 -1
  16. package/lib/gantt/src/emits.min.js +1 -1
  17. package/lib/gantt/src/gantt-chart.js +24 -4
  18. package/lib/gantt/src/gantt-chart.min.js +1 -1
  19. package/lib/gantt/src/gantt-header.js +44 -6
  20. package/lib/gantt/src/gantt-header.min.js +1 -1
  21. package/lib/gantt/src/gantt-view.js +255 -99
  22. package/lib/gantt/src/gantt-view.min.js +1 -1
  23. package/lib/gantt/src/gantt.js +75 -2
  24. package/lib/gantt/src/gantt.min.js +1 -1
  25. package/lib/gantt/src/util.js +7 -0
  26. package/lib/gantt/src/util.min.js +1 -1
  27. package/lib/gantt/style/style.css +2 -0
  28. package/lib/gantt/style/style.min.css +1 -1
  29. package/lib/index.umd.js +461 -121
  30. package/lib/index.umd.min.js +1 -1
  31. package/lib/style.css +1 -1
  32. package/lib/style.min.css +1 -1
  33. package/lib/ui/index.js +6 -1
  34. package/lib/ui/index.min.js +1 -1
  35. package/lib/ui/src/log.js +1 -1
  36. package/lib/ui/src/log.min.js +1 -1
  37. package/lib/vxe-gantt/style/style.css +2 -0
  38. package/lib/vxe-gantt/style/style.min.css +1 -1
  39. package/package.json +3 -3
  40. package/packages/gantt/src/emits.ts +3 -1
  41. package/packages/gantt/src/gantt-chart.ts +20 -4
  42. package/packages/gantt/src/gantt-header.ts +30 -7
  43. package/packages/gantt/src/gantt-view.ts +243 -93
  44. package/packages/gantt/src/gantt.ts +69 -2
  45. package/packages/gantt/src/util.ts +7 -0
  46. package/packages/ui/index.ts +5 -0
  47. package/styles/components/gantt-module/gantt-chart.scss +2 -0
  48. package/styles/theme/base.scss +1 -1
package/lib/index.umd.js CHANGED
@@ -44,6 +44,45 @@ module.exports = function (argument, usingIterator) {
44
44
  };
45
45
 
46
46
 
47
+ /***/ }),
48
+
49
+ /***/ 116:
50
+ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
51
+
52
+
53
+ var $ = __webpack_require__(6518);
54
+ var call = __webpack_require__(9565);
55
+ var iterate = __webpack_require__(2652);
56
+ var aCallable = __webpack_require__(9306);
57
+ var anObject = __webpack_require__(8551);
58
+ var getIteratorDirect = __webpack_require__(1767);
59
+ var iteratorClose = __webpack_require__(9539);
60
+ var iteratorHelperWithoutClosingOnEarlyError = __webpack_require__(4549);
61
+
62
+ var findWithoutClosingOnEarlyError = iteratorHelperWithoutClosingOnEarlyError('find', TypeError);
63
+
64
+ // `Iterator.prototype.find` method
65
+ // https://tc39.es/ecma262/#sec-iterator.prototype.find
66
+ $({ target: 'Iterator', proto: true, real: true, forced: findWithoutClosingOnEarlyError }, {
67
+ find: function find(predicate) {
68
+ anObject(this);
69
+ try {
70
+ aCallable(predicate);
71
+ } catch (error) {
72
+ iteratorClose(this, 'throw', error);
73
+ }
74
+
75
+ if (findWithoutClosingOnEarlyError) return call(findWithoutClosingOnEarlyError, this, predicate);
76
+
77
+ var record = getIteratorDirect(this);
78
+ var counter = 0;
79
+ return iterate(record, function (value, stop) {
80
+ if (predicate(value, counter++)) return stop(value);
81
+ }, { IS_RECORD: true, INTERRUPTED: true }).result;
82
+ }
83
+ });
84
+
85
+
47
86
  /***/ }),
48
87
 
49
88
  /***/ 283:
@@ -2741,7 +2780,7 @@ var core_ = __webpack_require__(4345);
2741
2780
  const {
2742
2781
  log
2743
2782
  } = core_.VxeUI;
2744
- const version = `gantt v${"4.0.4"}`;
2783
+ const version = `gantt v${"4.0.6"}`;
2745
2784
  const warnLog = log.create('warn', version);
2746
2785
  const errLog = log.create('error', version);
2747
2786
  ;// ./packages/ui/index.ts
@@ -2752,7 +2791,7 @@ const {
2752
2791
  setIcon,
2753
2792
  checkVersion
2754
2793
  } = core_.VxeUI;
2755
- core_.VxeUI.ganttVersion = "4.0.4";
2794
+ core_.VxeUI.ganttVersion = "4.0.6";
2756
2795
  setConfig({
2757
2796
  gantt: {
2758
2797
  // size: null,
@@ -2791,6 +2830,11 @@ setConfig({
2791
2830
  // beforeSave: null,
2792
2831
  // afterSave: null
2793
2832
  },
2833
+ taskViewScaleConfs: {
2834
+ week: {
2835
+ startDay: 1
2836
+ }
2837
+ },
2794
2838
  taskSplitConfig: {
2795
2839
  enabled: true,
2796
2840
  resize: true,
@@ -3245,7 +3289,9 @@ const tableEmits = ['update:data', 'keydown-start', 'keydown', 'keydown-end', 'p
3245
3289
  const gridEmits = [...tableEmits, 'page-change', 'form-submit', 'form-submit-invalid', 'form-reset', 'form-collapse', 'form-toggle-collapse', 'proxy-query', 'proxy-delete', 'proxy-save', 'toolbar-button-click', 'toolbar-tool-click', 'zoom'];
3246
3290
  ;// ./packages/gantt/src/emits.ts
3247
3291
 
3248
- const ganttEmits = [...gridEmits, 'task-cell-click', 'task-cell-dblclick', 'task-bar-click', 'task-bar-dblclick'];
3292
+ const ganttEmits = [...gridEmits, 'task-cell-click', 'task-cell-dblclick', 'task-bar-click', 'task-bar-dblclick', 'task-view-cell-click', 'task-view-cell-dblclick'];
3293
+ // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.find.js
3294
+ var es_iterator_find = __webpack_require__(116);
3249
3295
  ;// ./packages/gantt/src/util.ts
3250
3296
  function getRefElem(refEl) {
3251
3297
  if (refEl) {
@@ -3256,6 +3302,12 @@ function getRefElem(refEl) {
3256
3302
  }
3257
3303
  return null;
3258
3304
  }
3305
+ function getCalcHeight(height) {
3306
+ if (height === 'unset') {
3307
+ return 0;
3308
+ }
3309
+ return height || 0;
3310
+ }
3259
3311
  function getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) {
3260
3312
  return rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight;
3261
3313
  }
@@ -3264,9 +3316,14 @@ function getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) {
3264
3316
 
3265
3317
 
3266
3318
 
3319
+
3320
+ const {
3321
+ getI18n
3322
+ } = core_.VxeUI;
3267
3323
  /* harmony default export */ var gantt_header = (defineVxeComponent({
3268
3324
  name: 'VxeGanttViewHeader',
3269
3325
  setup() {
3326
+ const $xeGantt = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)('$xeGantt', {});
3270
3327
  const $xeGanttView = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)('$xeGanttView', {});
3271
3328
  const {
3272
3329
  reactData,
@@ -3302,16 +3359,49 @@ function getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) {
3302
3359
  width: `${viewCellWidth}px`
3303
3360
  }
3304
3361
  });
3305
- })), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('thead', {}, headerGroups.map((cols, rIndex) => {
3362
+ })), (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('thead', {}, headerGroups.map(({
3363
+ scaleItem,
3364
+ columns
3365
+ }, $rowIndex) => {
3366
+ const {
3367
+ type,
3368
+ titleMethod,
3369
+ slots
3370
+ } = scaleItem;
3371
+ const titleSlot = slots ? slots.title : null;
3306
3372
  return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('tr', {
3307
- key: rIndex
3308
- }, cols.map((column, cIndex) => {
3373
+ key: $rowIndex
3374
+ }, columns.map((column, cIndex) => {
3375
+ const {
3376
+ childCount,
3377
+ dateObj
3378
+ } = column;
3379
+ let label = `${column.title}`;
3380
+ if ($rowIndex < headerGroups.length - 1) {
3381
+ if (scaleItem.type === 'day') {
3382
+ label = getI18n(`vxe.gantt.dayss.w${dateObj.e}`);
3383
+ } else {
3384
+ label = getI18n(`vxe.gantt.${!$rowIndex && headerGroups.length > 1 ? 'tFullFormat' : 'tSimpleFormat'}.${type}`, dateObj);
3385
+ }
3386
+ }
3387
+ let cellVNs = label;
3388
+ const ctParams = {
3389
+ scaleObj: scaleItem,
3390
+ title: label,
3391
+ dateObj: dateObj,
3392
+ $rowIndex
3393
+ };
3394
+ if (titleSlot) {
3395
+ cellVNs = $xeGantt.callSlot(titleSlot, ctParams);
3396
+ } else if (titleMethod) {
3397
+ cellVNs = `${titleMethod(ctParams)}`;
3398
+ }
3309
3399
  return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('th', {
3310
3400
  key: cIndex,
3311
3401
  class: 'vxe-gantt-view--header-column',
3312
- colspan: column.children ? column.children.length : null,
3313
- title: `${column.field}`
3314
- }, column.title);
3402
+ colspan: childCount || null,
3403
+ title: titleSlot ? null : label
3404
+ }, cellVNs);
3315
3405
  }));
3316
3406
  }))])])]);
3317
3407
  };
@@ -3398,15 +3488,36 @@ const {
3398
3488
  contentMethod,
3399
3489
  barStyle
3400
3490
  } = taskBarOpts;
3491
+ const isBarRowStyle = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isFunction(barStyle);
3492
+ const barStyObj = (barStyle ? isBarRowStyle ? barStyle({
3493
+ row,
3494
+ $gantt: $xeGantt
3495
+ }) : barStyle : {}) || {};
3401
3496
  const {
3402
3497
  round
3403
- } = barStyle || {};
3498
+ } = barStyObj;
3404
3499
  const rowRest = fullAllDataRowIdData[rowid] || {};
3405
3500
  const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0;
3406
3501
  const isRsHeight = resizeHeight > 0;
3407
3502
  const cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
3408
3503
  let title = getStringValue(external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, titleField));
3409
3504
  const progressValue = showProgress ? Math.min(100, Math.max(0, external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toNumber(external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, progressField)))) : 0;
3505
+ const vbStyle = {};
3506
+ const vpStyle = {
3507
+ width: `${progressValue || 0}%`
3508
+ };
3509
+ if (isBarRowStyle) {
3510
+ const {
3511
+ bgColor,
3512
+ completedBgColor
3513
+ } = barStyObj;
3514
+ if (bgColor) {
3515
+ vbStyle.backgroundColor = bgColor;
3516
+ }
3517
+ if (completedBgColor) {
3518
+ vpStyle.backgroundColor = completedBgColor;
3519
+ }
3520
+ }
3410
3521
  if (contentMethod) {
3411
3522
  title = getStringValue(contentMethod({
3412
3523
  row,
@@ -3425,6 +3536,7 @@ const {
3425
3536
  }
3426
3537
  }, [(0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('div', {
3427
3538
  class: taskBarSlot ? 'vxe-gantt-view--chart-custom-bar' : 'vxe-gantt-view--chart-bar',
3539
+ style: vbStyle,
3428
3540
  rowid,
3429
3541
  onClick(evnt) {
3430
3542
  $xeGantt.handleTaskBarClickEvent(evnt, {
@@ -3440,9 +3552,7 @@ const {
3440
3552
  row
3441
3553
  }) : [showProgress ? (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('div', {
3442
3554
  class: 'vxe-gantt-view--chart-progress',
3443
- style: {
3444
- width: `${progressValue || 0}%`
3445
- }
3555
+ style: vpStyle
3446
3556
  }) : renderEmptyElement($xeGantt), showContent ? (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('div', {
3447
3557
  class: 'vxe-gantt-view--chart-content'
3448
3558
  }, title) : renderEmptyElement($xeGantt)])]);
@@ -3827,6 +3937,7 @@ const {
3827
3937
 
3828
3938
 
3829
3939
 
3940
+
3830
3941
  const {
3831
3942
  globalEvents
3832
3943
  } = core_.VxeUI;
@@ -3868,7 +3979,6 @@ const maxYHeight = 5e6;
3868
3979
  const $xeGantt = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.inject)('$xeGantt', {});
3869
3980
  const {
3870
3981
  computeTaskOpts,
3871
- computeTaskViewOpts,
3872
3982
  computeStartField,
3873
3983
  computeEndField,
3874
3984
  computeScrollbarOpts,
@@ -3915,14 +4025,7 @@ const maxYHeight = 5e6;
3915
4025
  tableData: [],
3916
4026
  tableColumn: [],
3917
4027
  headerGroups: [],
3918
- viewCellWidth: 40,
3919
- rowHeightStore: {
3920
- large: 52,
3921
- default: 48,
3922
- medium: 44,
3923
- small: 40,
3924
- mini: 36
3925
- }
4028
+ viewCellWidth: 20
3926
4029
  });
3927
4030
  const internalData = createInternalData();
3928
4031
  const refMaps = {
@@ -3947,106 +4050,271 @@ const maxYHeight = 5e6;
3947
4050
  };
3948
4051
  const handleParseColumn = () => {
3949
4052
  const ganttProps = $xeGantt.props;
4053
+ const ganttReactData = $xeGantt.reactData;
3950
4054
  const {
3951
4055
  treeConfig
3952
4056
  } = ganttProps;
4057
+ const {
4058
+ taskScaleList
4059
+ } = ganttReactData;
3953
4060
  const {
3954
4061
  minViewDate,
3955
4062
  maxViewDate
3956
4063
  } = reactData;
3957
- const taskViewOpts = computeTaskViewOpts.value;
4064
+ const minScale = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().last(taskScaleList);
3958
4065
  const fullCols = [];
3959
4066
  const groupCols = [];
3960
- switch (taskViewOpts.mode) {
3961
- case 'year':
3962
- break;
3963
- case 'quarter':
3964
- break;
3965
- case 'month':
3966
- break;
3967
- case 'week':
3968
- break;
3969
- default:
3970
- {
3971
- if (minViewDate && maxViewDate) {
3972
- const currTime = minViewDate.getTime();
3973
- const diffDayNum = maxViewDate.getTime() - minViewDate.getTime();
3974
- const countDayNum = Math.max(6, Math.floor(diffDayNum / 86400000) + 1);
3975
- const groupList = [];
3976
- const colList = [];
3977
- const groupMaps = {};
3978
- for (let i = 0; i < countDayNum; i++) {
3979
- const itemDate = new Date(currTime + i * 86400000);
3980
- const yyyyy = `${itemDate.getFullYear()}-${itemDate.getMonth() + 1}`;
3981
- const mmDd = `${itemDate.getDate()}`;
3982
- let groupCol = groupMaps[yyyyy];
3983
- const column = {
3984
- field: `${yyyyy}-${mmDd}`,
3985
- title: mmDd
3986
- };
3987
- if (groupCol) {
3988
- groupCol.children.push(column);
3989
- fullCols.push(groupCol);
3990
- } else {
3991
- groupCol = {
3992
- field: yyyyy,
3993
- title: yyyyy,
3994
- children: [column]
3995
- };
3996
- groupList.push(groupCol);
3997
- fullCols.push(groupCol);
3998
- groupMaps[yyyyy] = groupCol;
3999
- }
4000
- colList.push(column);
4001
- }
4002
- groupCols.push(groupList, colList);
4003
- const $xeTable = internalData.xeTable;
4004
- if ($xeTable) {
4005
- const startField = computeStartField.value;
4006
- const endField = computeEndField.value;
4007
- const {
4008
- computeTreeOpts
4009
- } = $xeTable.getComputeMaps();
4010
- const tableInternalData = $xeTable.internalData;
4011
- const {
4012
- afterFullData,
4013
- afterTreeFullData
4014
- } = tableInternalData;
4015
- const treeOpts = computeTreeOpts.value;
4016
- const {
4017
- transform
4018
- } = treeOpts;
4019
- const childrenField = treeOpts.children || treeOpts.childrenField;
4020
- const ctMaps = {};
4021
- const handleParseRender = row => {
4022
- const rowid = $xeTable.getRowid(row);
4023
- const startValue = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, startField);
4024
- const endValue = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, endField);
4025
- if (startValue && endValue) {
4026
- const startDate = parseStringDate(startValue);
4027
- const endDate = parseStringDate(endValue);
4028
- const oLeftSize = Math.floor((startDate.getTime() - minViewDate.getTime()) / 86400000);
4029
- const oWidthSize = Math.floor((endDate.getTime() - startDate.getTime()) / 86400000) + 1;
4030
- ctMaps[rowid] = {
4031
- row,
4032
- rowid,
4033
- oLeftSize,
4034
- oWidthSize
4035
- };
4036
- }
4037
- };
4038
- if (treeConfig) {
4039
- external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().eachTree(afterTreeFullData, handleParseRender, {
4040
- children: transform ? treeOpts.mapChildrenField : childrenField
4041
- });
4042
- } else {
4043
- afterFullData.forEach(handleParseRender);
4044
- }
4045
- internalData.chartMaps = ctMaps;
4046
- }
4067
+ if (minScale && minViewDate && maxViewDate) {
4068
+ const minSType = minScale.type;
4069
+ const weekScale = taskScaleList.find(item => item.type === 'week');
4070
+ let gapTime = 1000 * 60 * 60 * 24;
4071
+ switch (minScale.type) {
4072
+ case 'hour':
4073
+ gapTime = 1000 * 60 * 60;
4074
+ break;
4075
+ case 'minute':
4076
+ gapTime = 1000 * 60;
4077
+ break;
4078
+ case 'second':
4079
+ gapTime = 1000;
4080
+ break;
4081
+ default:
4082
+ {
4083
+ break;
4084
+ }
4085
+ }
4086
+ const currTime = minViewDate.getTime();
4087
+ const diffDayNum = maxViewDate.getTime() - minViewDate.getTime();
4088
+ const countSize = Math.max(5, Math.floor(diffDayNum / gapTime) + 1);
4089
+ switch (minScale.type) {
4090
+ case 'day':
4091
+ case 'date':
4092
+ if (diffDayNum > 1000 * 60 * 60 * 24 * 366 * 3) {
4093
+ reactData.tableColumn = [];
4094
+ reactData.headerGroups = [];
4095
+ return;
4047
4096
  }
4048
4097
  break;
4098
+ case 'hour':
4099
+ if (diffDayNum > 1000 * 60 * 60 * 24 * 31 * 3) {
4100
+ reactData.tableColumn = [];
4101
+ reactData.headerGroups = [];
4102
+ return;
4103
+ }
4104
+ break;
4105
+ case 'minute':
4106
+ if (diffDayNum > 1000 * 60 * 60 * 24 * 3) {
4107
+ reactData.tableColumn = [];
4108
+ reactData.headerGroups = [];
4109
+ return;
4110
+ }
4111
+ break;
4112
+ case 'second':
4113
+ if (diffDayNum > 1000 * 60 * 60 * 3) {
4114
+ reactData.tableColumn = [];
4115
+ reactData.headerGroups = [];
4116
+ return;
4117
+ }
4118
+ break;
4119
+ }
4120
+ const renderListMaps = {
4121
+ year: [],
4122
+ quarter: [],
4123
+ month: [],
4124
+ week: [],
4125
+ day: [],
4126
+ date: [],
4127
+ hour: [],
4128
+ minute: [],
4129
+ second: []
4130
+ };
4131
+ const tempTypeMaps = {
4132
+ year: {},
4133
+ quarter: {},
4134
+ month: {},
4135
+ week: {},
4136
+ day: {},
4137
+ date: {},
4138
+ hour: {},
4139
+ minute: {},
4140
+ second: {}
4141
+ };
4142
+ const handleData = (type, colMaps, minCol) => {
4143
+ if (minSType === type) {
4144
+ return;
4145
+ }
4146
+ const currCol = colMaps[type];
4147
+ const currKey = `${currCol.field}`;
4148
+ let currGpCol = tempTypeMaps[type][currKey];
4149
+ if (!currGpCol) {
4150
+ currGpCol = currCol;
4151
+ tempTypeMaps[type][currKey] = currGpCol;
4152
+ renderListMaps[type].push(currGpCol);
4153
+ }
4154
+ if (currGpCol) {
4155
+ if (!currGpCol.children) {
4156
+ currGpCol.children = [];
4157
+ }
4158
+ currGpCol.children.push(minCol);
4159
+ }
4160
+ };
4161
+ for (let i = 0; i < countSize; i++) {
4162
+ const itemDate = new Date(currTime + i * gapTime);
4163
+ const [yyyy, MM, dd, HH, mm, ss] = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().toDateString(itemDate, 'yyyy-M-d-H-m-s').split('-');
4164
+ const e = itemDate.getDay();
4165
+ const E = e + 1;
4166
+ const q = Math.ceil((itemDate.getMonth() + 1) / 3);
4167
+ const W = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().getYearWeek(itemDate, weekScale ? weekScale.startDay : undefined);
4168
+ const dateObj = {
4169
+ yy: yyyy,
4170
+ M: MM,
4171
+ d: dd,
4172
+ H: HH,
4173
+ m: mm,
4174
+ s: ss,
4175
+ q,
4176
+ W,
4177
+ E,
4178
+ e
4179
+ };
4180
+ const colMaps = {
4181
+ year: {
4182
+ field: yyyy,
4183
+ title: yyyy,
4184
+ dateObj
4185
+ },
4186
+ quarter: {
4187
+ field: `${yyyy}_q${q}`,
4188
+ title: `${q}`,
4189
+ dateObj
4190
+ },
4191
+ month: {
4192
+ field: `${yyyy}_${MM}`,
4193
+ title: MM,
4194
+ dateObj
4195
+ },
4196
+ week: {
4197
+ field: `${yyyy}_W${W}`,
4198
+ title: `${W}`,
4199
+ dateObj
4200
+ },
4201
+ day: {
4202
+ field: `${yyyy}_${MM}_${dd}_E${E}`,
4203
+ title: `${E}`,
4204
+ dateObj
4205
+ },
4206
+ date: {
4207
+ field: `${yyyy}_${MM}_${dd}`,
4208
+ title: dd,
4209
+ dateObj
4210
+ },
4211
+ hour: {
4212
+ field: `${yyyy}_${MM}_${dd}_${HH}`,
4213
+ title: HH,
4214
+ dateObj
4215
+ },
4216
+ minute: {
4217
+ field: `${yyyy}_${MM}_${dd}_${HH}_${mm}`,
4218
+ title: mm,
4219
+ dateObj
4220
+ },
4221
+ second: {
4222
+ field: `${yyyy}_${MM}_${dd}_${HH}_${mm}_${ss}`,
4223
+ title: ss,
4224
+ dateObj
4225
+ }
4226
+ };
4227
+ const minCol = colMaps[minSType];
4228
+ if (minScale.level < 19) {
4229
+ handleData('year', colMaps, minCol);
4230
+ }
4231
+ if (minScale.level < 17) {
4232
+ handleData('quarter', colMaps, minCol);
4233
+ }
4234
+ if (minScale.level < 14) {
4235
+ handleData('month', colMaps, minCol);
4236
+ }
4237
+ if (minScale.level < 13) {
4238
+ handleData('week', colMaps, minCol);
4239
+ }
4240
+ if (minScale.level < 11) {
4241
+ handleData('day', colMaps, minCol);
4242
+ }
4243
+ if (minScale.level < 12) {
4244
+ handleData('date', colMaps, minCol);
4245
+ }
4246
+ if (minScale.level < 7) {
4247
+ handleData('hour', colMaps, minCol);
4248
+ }
4249
+ if (minScale.level < 5) {
4250
+ handleData('minute', colMaps, minCol);
4251
+ }
4252
+ fullCols.push(minCol);
4253
+ }
4254
+ taskScaleList.forEach(scaleItem => {
4255
+ if (scaleItem.type === minSType) {
4256
+ groupCols.push({
4257
+ scaleItem,
4258
+ columns: fullCols
4259
+ });
4260
+ return;
4049
4261
  }
4262
+ const list = renderListMaps[scaleItem.type] || [];
4263
+ if (list) {
4264
+ list.forEach(item => {
4265
+ item.childCount = item.children ? item.children.length : 0;
4266
+ item.children = undefined;
4267
+ });
4268
+ }
4269
+ groupCols.push({
4270
+ scaleItem,
4271
+ columns: list
4272
+ });
4273
+ });
4274
+ const $xeTable = internalData.xeTable;
4275
+ if ($xeTable) {
4276
+ const startField = computeStartField.value;
4277
+ const endField = computeEndField.value;
4278
+ const {
4279
+ computeTreeOpts
4280
+ } = $xeTable.getComputeMaps();
4281
+ const tableInternalData = $xeTable.internalData;
4282
+ const {
4283
+ afterFullData,
4284
+ afterTreeFullData
4285
+ } = tableInternalData;
4286
+ const treeOpts = computeTreeOpts.value;
4287
+ const {
4288
+ transform
4289
+ } = treeOpts;
4290
+ const childrenField = treeOpts.children || treeOpts.childrenField;
4291
+ const ctMaps = {};
4292
+ const handleParseRender = row => {
4293
+ const rowid = $xeTable.getRowid(row);
4294
+ const startValue = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, startField);
4295
+ const endValue = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, endField);
4296
+ if (startValue && endValue) {
4297
+ const startDate = parseStringDate(startValue);
4298
+ const endDate = parseStringDate(endValue);
4299
+ const oLeftSize = Math.floor((startDate.getTime() - minViewDate.getTime()) / gapTime);
4300
+ const oWidthSize = Math.floor((endDate.getTime() - startDate.getTime()) / gapTime) + 1;
4301
+ ctMaps[rowid] = {
4302
+ row,
4303
+ rowid,
4304
+ oLeftSize,
4305
+ oWidthSize
4306
+ };
4307
+ }
4308
+ };
4309
+ if (treeConfig) {
4310
+ external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().eachTree(afterTreeFullData, handleParseRender, {
4311
+ children: transform ? treeOpts.mapChildrenField : childrenField
4312
+ });
4313
+ } else {
4314
+ afterFullData.forEach(handleParseRender);
4315
+ }
4316
+ internalData.chartMaps = ctMaps;
4317
+ }
4050
4318
  }
4051
4319
  reactData.tableColumn = fullCols;
4052
4320
  reactData.headerGroups = groupCols;
@@ -4646,11 +4914,10 @@ const maxYHeight = 5e6;
4646
4914
  scrollXLoad,
4647
4915
  scrollYLoad
4648
4916
  } = reactData;
4649
- const taskViewOpts = computeTaskViewOpts.value;
4650
4917
  const scrollbarXToTop = computeScrollbarXToTop.value;
4651
4918
  return (0,external_commonjs_vue_commonjs2_vue_root_Vue_.h)('div', {
4652
4919
  ref: refElem,
4653
- class: ['vxe-gantt-view', `mode--${taskViewOpts.mode || 'day'}`, {
4920
+ class: ['vxe-gantt-view', {
4654
4921
  'is--scroll-y': overflowY,
4655
4922
  'is--scroll-x': overflowX,
4656
4923
  'is--virtual-x': scrollXLoad,
@@ -4713,7 +4980,7 @@ var external_root_VxeUITable_commonjs_vxe_table_commonjs2_vxe_table_amd_vxe_tabl
4713
4980
  const {
4714
4981
  getConfig,
4715
4982
  getIcon,
4716
- getI18n,
4983
+ getI18n: gantt_getI18n,
4717
4984
  commands,
4718
4985
  hooks,
4719
4986
  useFns,
@@ -4731,6 +4998,20 @@ function gantt_createInternalData() {
4731
4998
  resizeTableWidth: 0
4732
4999
  };
4733
5000
  }
5001
+ const viewTypeLevelMaps = {
5002
+ year: 19,
5003
+ quarter: 17,
5004
+ month: 15,
5005
+ week: 13,
5006
+ day: 11,
5007
+ date: 9,
5008
+ hour: 7,
5009
+ minute: 5,
5010
+ second: 3
5011
+ };
5012
+ function getViewTypeLevel(type) {
5013
+ return viewTypeLevelMaps[type || 'date'] || viewTypeLevelMaps.date;
5014
+ }
4734
5015
  /* harmony default export */ var gantt = (defineVxeComponent({
4735
5016
  name: 'VxeGantt',
4736
5017
  props: {
@@ -4743,6 +5024,7 @@ function gantt_createInternalData() {
4743
5024
  zoomConfig: Object,
4744
5025
  layouts: Array,
4745
5026
  taskConfig: Object,
5027
+ taskViewScaleConfs: Object,
4746
5028
  taskViewConfig: Object,
4747
5029
  taskBarConfig: Object,
4748
5030
  taskSplitConfig: Object,
@@ -4781,7 +5063,8 @@ function gantt_createInternalData() {
4781
5063
  currentPage: 1
4782
5064
  },
4783
5065
  showLeftView: true,
4784
- showRightView: true
5066
+ showRightView: true,
5067
+ taskScaleList: []
4785
5068
  });
4786
5069
  const internalData = gantt_createInternalData();
4787
5070
  const refElem = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)();
@@ -4847,6 +5130,9 @@ function gantt_createInternalData() {
4847
5130
  const computeTaskOpts = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
4848
5131
  return Object.assign({}, getConfig().gantt.taskConfig, props.taskConfig);
4849
5132
  });
5133
+ const computeTaskViewScaleMapsOpts = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
5134
+ return external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().merge({}, getConfig().gantt.taskViewScaleConfs, props.taskViewScaleConfs);
5135
+ });
4850
5136
  const computeTaskViewOpts = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
4851
5137
  return Object.assign({}, getConfig().gantt.taskViewConfig, props.taskViewConfig);
4852
5138
  });
@@ -4856,6 +5142,13 @@ function gantt_createInternalData() {
4856
5142
  const computeTaskSplitOpts = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
4857
5143
  return Object.assign({}, getConfig().gantt.taskSplitConfig, props.taskSplitConfig);
4858
5144
  });
5145
+ const computeTaskScaleConfs = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
5146
+ const taskViewOpts = computeTaskViewOpts.value;
5147
+ const {
5148
+ scales
5149
+ } = taskViewOpts;
5150
+ return scales;
5151
+ });
4859
5152
  const computeTitleField = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.computed)(() => {
4860
5153
  const taskOpts = computeTaskOpts.value;
4861
5154
  return taskOpts.titleField || 'title';
@@ -4911,7 +5204,7 @@ function gantt_createInternalData() {
4911
5204
  stys.maxHeight = maxHeight === 'auto' || maxHeight === '100%' ? '100%' : toCssUnit(maxHeight);
4912
5205
  }
4913
5206
  }
4914
- if (barStyle) {
5207
+ if (barStyle && !external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isFunction(barStyle)) {
4915
5208
  const {
4916
5209
  bgColor,
4917
5210
  completedBgColor
@@ -5090,9 +5383,11 @@ function gantt_createInternalData() {
5090
5383
  computeToolbarOpts,
5091
5384
  computeZoomOpts,
5092
5385
  computeTaskOpts,
5386
+ computeTaskViewScaleMapsOpts,
5093
5387
  computeTaskViewOpts,
5094
5388
  computeTaskBarOpts,
5095
5389
  computeTaskSplitOpts,
5390
+ computeTaskScaleConfs,
5096
5391
  computeTitleField,
5097
5392
  computeStartField,
5098
5393
  computeEndField,
@@ -5110,6 +5405,47 @@ function gantt_createInternalData() {
5110
5405
  getRefMaps: () => refMaps,
5111
5406
  getComputeMaps: () => computeMaps
5112
5407
  };
5408
+ const handleTaskScaleConfig = () => {
5409
+ const taskScaleConfs = computeTaskScaleConfs.value;
5410
+ const taskViewScaleMapsOpts = computeTaskViewScaleMapsOpts.value;
5411
+ const scaleConfs = [];
5412
+ if (taskScaleConfs) {
5413
+ const keyMaps = {};
5414
+ taskScaleConfs.forEach(conf => {
5415
+ const sConf = !conf || external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isString(conf) ? {
5416
+ type: conf
5417
+ } : conf;
5418
+ const {
5419
+ type
5420
+ } = sConf;
5421
+ if (!type || !viewTypeLevelMaps[type]) {
5422
+ errLog('vxe.error.errProp', [`type=${type}`, external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().keys(viewTypeLevelMaps).join(',')]);
5423
+ return;
5424
+ }
5425
+ if (keyMaps[type]) {
5426
+ errLog('vxe.error.repeatProp', ['type', type]);
5427
+ return;
5428
+ }
5429
+ keyMaps[type] = true;
5430
+ scaleConfs.push(Object.assign({}, type ? taskViewScaleMapsOpts[type] || {} : {}, sConf, {
5431
+ level: getViewTypeLevel(type)
5432
+ }));
5433
+ });
5434
+ }
5435
+ if (!scaleConfs.length) {
5436
+ scaleConfs.push({
5437
+ type: 'month',
5438
+ level: viewTypeLevelMaps.month
5439
+ }, {
5440
+ type: 'date',
5441
+ level: viewTypeLevelMaps.date
5442
+ });
5443
+ }
5444
+ reactData.taskScaleList = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().orderBy(scaleConfs, {
5445
+ field: 'level',
5446
+ order: 'desc'
5447
+ });
5448
+ };
5113
5449
  const initToolbar = () => {
5114
5450
  const toolbarOpts = computeToolbarOpts.value;
5115
5451
  if (props.toolbarConfig && isEnableConf(toolbarOpts)) {
@@ -5185,7 +5521,7 @@ function gantt_createInternalData() {
5185
5521
  if (core_.VxeUI.modal) {
5186
5522
  core_.VxeUI.modal.message({
5187
5523
  id: code,
5188
- content: getI18n('vxe.grid.selectOneRecord'),
5524
+ content: gantt_getI18n('vxe.grid.selectOneRecord'),
5189
5525
  status: 'warning'
5190
5526
  });
5191
5527
  }
@@ -5206,7 +5542,7 @@ function gantt_createInternalData() {
5206
5542
  $gantt: $xeGantt
5207
5543
  }) : external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(rest, messageProp);
5208
5544
  }
5209
- return msg || getI18n(defaultMsg);
5545
+ return msg || gantt_getI18n(defaultMsg);
5210
5546
  };
5211
5547
  const handleDeleteRow = (code, alertKey, callback) => {
5212
5548
  const isActiveMsg = computeIsActiveMsg.value;
@@ -5216,7 +5552,7 @@ function gantt_createInternalData() {
5216
5552
  if (core_.VxeUI.modal) {
5217
5553
  return core_.VxeUI.modal.confirm({
5218
5554
  id: `cfm_${code}`,
5219
- content: getI18n(alertKey),
5555
+ content: gantt_getI18n(alertKey),
5220
5556
  escClosable: true
5221
5557
  }).then(type => {
5222
5558
  if (type === 'confirm') {
@@ -5228,7 +5564,7 @@ function gantt_createInternalData() {
5228
5564
  if (core_.VxeUI.modal) {
5229
5565
  core_.VxeUI.modal.message({
5230
5566
  id: `msg_${code}`,
5231
- content: getI18n('vxe.grid.selectOneRecord'),
5567
+ content: gantt_getI18n('vxe.grid.selectOneRecord'),
5232
5568
  status: 'warning'
5233
5569
  });
5234
5570
  }
@@ -5918,7 +6254,7 @@ function gantt_createInternalData() {
5918
6254
  if (core_.VxeUI.modal) {
5919
6255
  core_.VxeUI.modal.message({
5920
6256
  id: code,
5921
- content: getI18n('vxe.grid.selectOneRecord'),
6257
+ content: gantt_getI18n('vxe.grid.selectOneRecord'),
5922
6258
  status: 'warning'
5923
6259
  });
5924
6260
  }
@@ -6023,7 +6359,7 @@ function gantt_createInternalData() {
6023
6359
  if (core_.VxeUI.modal) {
6024
6360
  core_.VxeUI.modal.message({
6025
6361
  id: code,
6026
- content: getI18n('vxe.grid.dataUnchanged'),
6362
+ content: gantt_getI18n('vxe.grid.dataUnchanged'),
6027
6363
  status: 'info'
6028
6364
  });
6029
6365
  }
@@ -6824,6 +7160,9 @@ function gantt_createInternalData() {
6824
7160
  (0,external_commonjs_vue_commonjs2_vue_root_Vue_.watch)(() => props.proxyConfig, () => {
6825
7161
  initProxy();
6826
7162
  });
7163
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.watch)(computeTaskScaleConfs, () => {
7164
+ handleTaskScaleConfig();
7165
+ });
6827
7166
  hooks.forEach(options => {
6828
7167
  const {
6829
7168
  setupGantt
@@ -6835,6 +7174,7 @@ function gantt_createInternalData() {
6835
7174
  }
6836
7175
  }
6837
7176
  });
7177
+ handleTaskScaleConfig();
6838
7178
  initPages();
6839
7179
  (0,external_commonjs_vue_commonjs2_vue_root_Vue_.onMounted)(() => {
6840
7180
  (0,external_commonjs_vue_commonjs2_vue_root_Vue_.nextTick)(() => {