vxe-gantt 3.0.23 → 3.0.25
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/es/gantt/src/gantt-body.js +31 -10
- package/es/gantt/src/gantt-view.js +97 -2
- package/es/gantt/src/gantt.js +152 -35
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/utils.js +3 -0
- package/lib/gantt/src/gantt-body.js +30 -5
- package/lib/gantt/src/gantt-body.min.js +1 -1
- package/lib/gantt/src/gantt-view.js +96 -2
- package/lib/gantt/src/gantt-view.min.js +1 -1
- package/lib/gantt/src/gantt.js +195 -75
- package/lib/gantt/src/gantt.min.js +1 -1
- package/lib/index.umd.js +383 -142
- package/lib/index.umd.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/ui/src/utils.js +4 -0
- package/lib/ui/src/utils.min.js +1 -1
- package/package.json +3 -3
- package/packages/gantt/src/gantt-body.ts +39 -17
- package/packages/gantt/src/gantt-view.ts +99 -2
- package/packages/gantt/src/gantt.ts +181 -65
- package/packages/ui/src/utils.ts +4 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { defineVxeComponent } from '../../ui/src/comp';
|
|
2
2
|
import { getCellRestHeight } from './util';
|
|
3
|
+
import { getClass } from '../../ui/src/utils';
|
|
4
|
+
import XEUtils from 'xe-utils';
|
|
3
5
|
import GanttViewChartComponent from './gantt-chart';
|
|
4
6
|
const sourceType = 'gantt';
|
|
5
7
|
const viewType = 'body';
|
|
@@ -35,9 +37,10 @@ export default defineVxeComponent({
|
|
|
35
37
|
const { headerGroups } = reactData;
|
|
36
38
|
const { todayDateMaps } = internalData;
|
|
37
39
|
const taskViewOpts = $xeGantt.computeTaskViewOpts;
|
|
38
|
-
const { showNowLine } = taskViewOpts;
|
|
40
|
+
const { showNowLine, viewStyle } = taskViewOpts;
|
|
39
41
|
const { scaleItem } = headerGroups[headerGroups.length - 1] || {};
|
|
40
|
-
const { field } = column;
|
|
42
|
+
const { field, dateObj } = column;
|
|
43
|
+
const { cellClassName, cellStyle } = viewStyle || {};
|
|
41
44
|
const todayValue = showNowLine && scaleItem ? todayDateMaps[scaleItem.type] : null;
|
|
42
45
|
const rowRest = fullAllDataRowIdData[rowid] || {};
|
|
43
46
|
const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0;
|
|
@@ -78,16 +81,24 @@ export default defineVxeComponent({
|
|
|
78
81
|
}
|
|
79
82
|
}));
|
|
80
83
|
}
|
|
81
|
-
const ctParams = { source: sourceType, type: viewType, row, column, $rowIndex, rowIndex, _rowIndex };
|
|
84
|
+
const ctParams = { source: sourceType, type: viewType, dateObj, row, column, $rowIndex, rowIndex, _rowIndex };
|
|
82
85
|
return h('td', {
|
|
83
86
|
key: $columnIndex,
|
|
84
|
-
class: [
|
|
87
|
+
class: [
|
|
88
|
+
'vxe-gantt-view--body-column',
|
|
89
|
+
{
|
|
85
90
|
'is--now': showNowLine && todayValue === field,
|
|
86
91
|
'col--rs-height': isRsHeight
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
},
|
|
93
|
+
getClass(cellClassName, ctParams)
|
|
94
|
+
],
|
|
95
|
+
style: cellStyle
|
|
96
|
+
? Object.assign({}, XEUtils.isFunction(cellStyle) ? cellStyle(ctParams) : cellStyle, {
|
|
97
|
+
height: `${cellHeight}px`
|
|
98
|
+
})
|
|
99
|
+
: {
|
|
100
|
+
height: `${cellHeight}px`
|
|
101
|
+
},
|
|
91
102
|
on: {
|
|
92
103
|
click(evnt) {
|
|
93
104
|
$xeGantt.handleTaskCellClickEvent(evnt, { row, column });
|
|
@@ -104,6 +115,7 @@ export default defineVxeComponent({
|
|
|
104
115
|
renderRows(h, $xeTable, tableData) {
|
|
105
116
|
const _vm = this;
|
|
106
117
|
const $xeGanttView = _vm.$xeGanttView;
|
|
118
|
+
const $xeGantt = _vm.$xeGantt;
|
|
107
119
|
const { reactData } = $xeGanttView;
|
|
108
120
|
const tableProps = $xeTable;
|
|
109
121
|
const { treeConfig, stripe, highlightHoverRow, editConfig } = tableProps;
|
|
@@ -117,6 +129,9 @@ export default defineVxeComponent({
|
|
|
117
129
|
const treeOpts = $xeTable.computeTreeOpts;
|
|
118
130
|
const { transform } = treeOpts;
|
|
119
131
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
132
|
+
const taskViewOpts = $xeGantt.computeTaskViewOpts;
|
|
133
|
+
const { viewStyle } = taskViewOpts;
|
|
134
|
+
const { rowClassName, rowStyle } = viewStyle || {};
|
|
120
135
|
const { tableColumn, scrollYLoad } = reactData;
|
|
121
136
|
const trVNs = [];
|
|
122
137
|
tableData.forEach((row, $rowIndex) => {
|
|
@@ -149,15 +164,21 @@ export default defineVxeComponent({
|
|
|
149
164
|
trOns.dragend = $xeTable.handleRowDragDragendEvent;
|
|
150
165
|
trOns.dragover = $xeTable.handleRowDragDragoverEvent;
|
|
151
166
|
}
|
|
167
|
+
const rowParams = { source: sourceType, type: viewType, row, rowIndex, $rowIndex, _rowIndex };
|
|
152
168
|
trVNs.push(h('tr', {
|
|
153
169
|
key: treeConfig ? rowid : $rowIndex,
|
|
154
|
-
class: [
|
|
170
|
+
class: [
|
|
171
|
+
'vxe-gantt-view--body-row',
|
|
172
|
+
{
|
|
155
173
|
'row--stripe': stripe && (_rowIndex + 1) % 2 === 0,
|
|
156
174
|
'is--new': isNewRow,
|
|
157
175
|
'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
|
|
158
176
|
'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
|
|
159
177
|
'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid]
|
|
160
|
-
}
|
|
178
|
+
},
|
|
179
|
+
getClass(rowClassName, rowParams)
|
|
180
|
+
],
|
|
181
|
+
style: rowStyle ? XEUtils.isFunction(rowStyle) ? rowStyle(rowParams) : rowStyle : undefined,
|
|
161
182
|
attrs: {
|
|
162
183
|
rowid
|
|
163
184
|
},
|
|
@@ -7,6 +7,7 @@ import GanttViewHeaderComponent from './gantt-header';
|
|
|
7
7
|
import GanttViewBodyComponent from './gantt-body';
|
|
8
8
|
import GanttViewFooterComponent from './gantt-footer';
|
|
9
9
|
const { globalEvents } = VxeUI;
|
|
10
|
+
const sourceType = 'gantt';
|
|
10
11
|
function createInternalData() {
|
|
11
12
|
return {
|
|
12
13
|
xeTable: null,
|
|
@@ -751,10 +752,104 @@ function checkLastSyncScroll($xeGanttView, isRollX, isRollY) {
|
|
|
751
752
|
reactData.lazScrollLoading = false;
|
|
752
753
|
}, 200);
|
|
753
754
|
}
|
|
754
|
-
|
|
755
|
-
|
|
755
|
+
function handleScrollData($xeGanttView, isRollY, isRollX, scrollTop, scrollLeft) {
|
|
756
|
+
const reactData = $xeGanttView.reactData;
|
|
757
|
+
const internalData = $xeGanttView.internalData;
|
|
758
|
+
if (isRollX) {
|
|
759
|
+
internalData.lastScrollLeft = scrollLeft;
|
|
760
|
+
}
|
|
761
|
+
if (isRollY) {
|
|
762
|
+
internalData.lastScrollTop = scrollTop;
|
|
763
|
+
}
|
|
764
|
+
reactData.lastScrollTime = Date.now();
|
|
756
765
|
checkLastSyncScroll($xeGanttView, isRollX, isRollY);
|
|
757
766
|
}
|
|
767
|
+
function handleScrollEvent($xeGanttView, evnt, isRollY, isRollX, scrollTop, scrollLeft) {
|
|
768
|
+
const $xeGantt = $xeGanttView.$xeGantt;
|
|
769
|
+
const internalData = $xeGanttView.internalData;
|
|
770
|
+
const $xeTable = internalData.xeTable;
|
|
771
|
+
const { lastScrollLeft, lastScrollTop } = internalData;
|
|
772
|
+
const xHandleEl = $xeGanttView.$refs.refScrollXHandleElem;
|
|
773
|
+
const yHandleEl = $xeGanttView.$refs.refScrollYHandleElem;
|
|
774
|
+
if (!xHandleEl || !yHandleEl) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
if (!$xeTable) {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
const bodyHeight = yHandleEl.clientHeight;
|
|
781
|
+
const bodyWidth = xHandleEl.clientWidth;
|
|
782
|
+
const scrollHeight = yHandleEl.scrollHeight;
|
|
783
|
+
const scrollWidth = xHandleEl.scrollWidth;
|
|
784
|
+
let isTop = false;
|
|
785
|
+
let isBottom = false;
|
|
786
|
+
let isLeft = false;
|
|
787
|
+
let isRight = false;
|
|
788
|
+
let direction = '';
|
|
789
|
+
let isTopBoundary = false;
|
|
790
|
+
let isBottomBoundary = false;
|
|
791
|
+
let isLeftBoundary = false;
|
|
792
|
+
let isRightBoundary = false;
|
|
793
|
+
if (isRollX) {
|
|
794
|
+
const xThreshold = $xeTable.computeScrollXThreshold;
|
|
795
|
+
isLeft = scrollLeft <= 0;
|
|
796
|
+
if (!isLeft) {
|
|
797
|
+
isRight = scrollLeft + bodyWidth >= scrollWidth - 1;
|
|
798
|
+
}
|
|
799
|
+
if (scrollLeft > lastScrollLeft) {
|
|
800
|
+
direction = 'right';
|
|
801
|
+
if (scrollLeft + bodyWidth >= scrollWidth - xThreshold) {
|
|
802
|
+
isRightBoundary = true;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
direction = 'left';
|
|
807
|
+
if (scrollLeft <= xThreshold) {
|
|
808
|
+
isLeftBoundary = true;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
if (isRollY) {
|
|
813
|
+
const yThreshold = $xeTable.computeScrollYThreshold;
|
|
814
|
+
isTop = scrollTop <= 0;
|
|
815
|
+
if (!isTop) {
|
|
816
|
+
isBottom = scrollTop + bodyHeight >= scrollHeight - 1;
|
|
817
|
+
}
|
|
818
|
+
if (scrollTop > lastScrollTop) {
|
|
819
|
+
direction = 'bottom';
|
|
820
|
+
if (scrollTop + bodyHeight >= scrollHeight - yThreshold) {
|
|
821
|
+
isBottomBoundary = true;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
else {
|
|
825
|
+
direction = 'top';
|
|
826
|
+
if (scrollTop <= yThreshold) {
|
|
827
|
+
isTopBoundary = true;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
handleScrollData($xeGanttView, isRollY, isRollX, scrollTop, scrollLeft);
|
|
832
|
+
const evntParams = {
|
|
833
|
+
source: sourceType,
|
|
834
|
+
scrollTop,
|
|
835
|
+
scrollLeft,
|
|
836
|
+
bodyHeight,
|
|
837
|
+
bodyWidth,
|
|
838
|
+
scrollHeight,
|
|
839
|
+
scrollWidth,
|
|
840
|
+
isX: isRollX,
|
|
841
|
+
isY: isRollY,
|
|
842
|
+
isTop,
|
|
843
|
+
isBottom,
|
|
844
|
+
isLeft,
|
|
845
|
+
isRight,
|
|
846
|
+
direction
|
|
847
|
+
};
|
|
848
|
+
if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
|
|
849
|
+
$xeGantt.dispatchEvent('scroll-boundary', evntParams, evnt);
|
|
850
|
+
}
|
|
851
|
+
$xeGantt.dispatchEvent('scroll', evntParams, evnt);
|
|
852
|
+
}
|
|
758
853
|
/**
|
|
759
854
|
* 同步表格滚动
|
|
760
855
|
*/
|
package/es/gantt/src/gantt.js
CHANGED
|
@@ -59,6 +59,7 @@ XEUtils.each(VxeTableComponent.methods, (fn, name) => {
|
|
|
59
59
|
});
|
|
60
60
|
function createInternalData() {
|
|
61
61
|
return {
|
|
62
|
+
uFoot: false,
|
|
62
63
|
resizeTableWidth: 0
|
|
63
64
|
};
|
|
64
65
|
}
|
|
@@ -90,6 +91,7 @@ export default {
|
|
|
90
91
|
filterData: [],
|
|
91
92
|
formData: {},
|
|
92
93
|
sortData: [],
|
|
94
|
+
footerData: [],
|
|
93
95
|
tZindex: 0,
|
|
94
96
|
tablePage: {
|
|
95
97
|
total: 0,
|
|
@@ -253,7 +255,9 @@ export default {
|
|
|
253
255
|
const rest = {};
|
|
254
256
|
const gridProps = props;
|
|
255
257
|
propKeys.forEach(key => {
|
|
256
|
-
|
|
258
|
+
if (gridProps[key] !== undefined) {
|
|
259
|
+
rest[key] = gridProps[key];
|
|
260
|
+
}
|
|
257
261
|
});
|
|
258
262
|
return rest;
|
|
259
263
|
},
|
|
@@ -261,8 +265,8 @@ export default {
|
|
|
261
265
|
const $xeGantt = this;
|
|
262
266
|
const props = $xeGantt;
|
|
263
267
|
const reactData = $xeGantt.reactData;
|
|
264
|
-
const { seqConfig, pagerConfig, editConfig, proxyConfig } = props;
|
|
265
|
-
const { isZMax, tablePage } = reactData;
|
|
268
|
+
const { showFooter, seqConfig, pagerConfig, editConfig, proxyConfig } = props;
|
|
269
|
+
const { isZMax, tablePage, footerData } = reactData;
|
|
266
270
|
const taskViewOpts = $xeGantt.computeTaskViewOpts;
|
|
267
271
|
const { tableStyle } = taskViewOpts;
|
|
268
272
|
const tableExtendProps = $xeGantt.computeTableExtendProps;
|
|
@@ -281,8 +285,16 @@ export default {
|
|
|
281
285
|
tProps.border = border;
|
|
282
286
|
}
|
|
283
287
|
}
|
|
288
|
+
if (showFooter && !tProps.footerData) {
|
|
289
|
+
// 如果未设置自己的标位数据,则使用代理的
|
|
290
|
+
tProps.footerData = footerData;
|
|
291
|
+
}
|
|
292
|
+
else if (proxyOpts.footer && footerData.length) {
|
|
293
|
+
// 如果代理标为数据,且未请求到数据,则用自己的
|
|
294
|
+
tProps.footerData = footerData;
|
|
295
|
+
}
|
|
284
296
|
if (isZMax) {
|
|
285
|
-
if (
|
|
297
|
+
if (tProps.maxHeight) {
|
|
286
298
|
tProps.maxHeight = '100%';
|
|
287
299
|
}
|
|
288
300
|
else {
|
|
@@ -600,6 +612,7 @@ export default {
|
|
|
600
612
|
const $xeGantt = this;
|
|
601
613
|
const props = $xeGantt;
|
|
602
614
|
const reactData = $xeGantt.reactData;
|
|
615
|
+
const internalData = $xeGantt.internalData;
|
|
603
616
|
const $xeTable = $xeGantt.$refs.refTable;
|
|
604
617
|
const { proxyConfig } = props;
|
|
605
618
|
const proxyOpts = $xeGantt.computeProxyOpts;
|
|
@@ -609,9 +622,12 @@ export default {
|
|
|
609
622
|
reactData.filterData = params.filterList;
|
|
610
623
|
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
611
624
|
reactData.tablePage.currentPage = 1;
|
|
625
|
+
internalData.uFoot = true;
|
|
612
626
|
$xeGantt.commitProxy('query').then((rest) => {
|
|
613
627
|
$xeGantt.dispatchEvent('proxy-query', rest, params.$event);
|
|
614
628
|
});
|
|
629
|
+
internalData.uFoot = false;
|
|
630
|
+
$xeGantt.updateQueryFooter();
|
|
615
631
|
}
|
|
616
632
|
}
|
|
617
633
|
},
|
|
@@ -629,30 +645,38 @@ export default {
|
|
|
629
645
|
const $xeGantt = this;
|
|
630
646
|
const props = $xeGantt;
|
|
631
647
|
const reactData = $xeGantt.reactData;
|
|
648
|
+
const internalData = $xeGantt.internalData;
|
|
632
649
|
const { proxyConfig } = props;
|
|
633
650
|
const proxyOpts = $xeGantt.computeProxyOpts;
|
|
634
651
|
if (reactData.tableLoading) {
|
|
635
652
|
return;
|
|
636
653
|
}
|
|
637
654
|
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
655
|
+
internalData.uFoot = true;
|
|
638
656
|
$xeGantt.commitProxy('reload').then((rest) => {
|
|
639
657
|
$xeGantt.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isReload: true }), params.$event);
|
|
640
658
|
});
|
|
659
|
+
internalData.uFoot = false;
|
|
660
|
+
$xeGantt.updateQueryFooter();
|
|
641
661
|
}
|
|
642
662
|
$xeGantt.dispatchEvent('form-submit', params, params.$event);
|
|
643
663
|
},
|
|
644
664
|
resetFormEvent(params) {
|
|
645
665
|
const $xeGantt = this;
|
|
646
666
|
const props = $xeGantt;
|
|
667
|
+
const internalData = $xeGantt.internalData;
|
|
647
668
|
const $xeTable = $xeGantt.$refs.refTable;
|
|
648
669
|
const { proxyConfig } = props;
|
|
649
670
|
const { $event } = params;
|
|
650
671
|
const proxyOpts = $xeGantt.computeProxyOpts;
|
|
651
672
|
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
652
673
|
$xeTable.clearScroll();
|
|
674
|
+
internalData.uFoot = true;
|
|
653
675
|
$xeGantt.commitProxy('reload').then((rest) => {
|
|
654
676
|
$xeGantt.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isReload: true }), $event);
|
|
655
677
|
});
|
|
678
|
+
internalData.uFoot = false;
|
|
679
|
+
$xeGantt.updateQueryFooter();
|
|
656
680
|
}
|
|
657
681
|
$xeGantt.dispatchEvent('form-reset', params, $event);
|
|
658
682
|
},
|
|
@@ -798,6 +822,7 @@ export default {
|
|
|
798
822
|
const $xeGantt = this;
|
|
799
823
|
const props = $xeGantt;
|
|
800
824
|
const reactData = $xeGantt.reactData;
|
|
825
|
+
const internalData = $xeGantt.internalData;
|
|
801
826
|
const { proxyConfig, formConfig } = props;
|
|
802
827
|
const { proxyInited } = reactData;
|
|
803
828
|
const proxyOpts = $xeGantt.computeProxyOpts;
|
|
@@ -806,14 +831,30 @@ export default {
|
|
|
806
831
|
if (isEnableConf(formConfig) && proxyOpts.form && formOpts.items) {
|
|
807
832
|
reactData.formData = $xeGantt.getDefaultFormData();
|
|
808
833
|
}
|
|
809
|
-
if (!proxyInited
|
|
834
|
+
if (!proxyInited) {
|
|
810
835
|
reactData.proxyInited = true;
|
|
811
|
-
|
|
812
|
-
$xeGantt
|
|
813
|
-
|
|
836
|
+
if (proxyOpts.autoLoad !== false) {
|
|
837
|
+
$xeGantt.$nextTick().then(() => {
|
|
838
|
+
internalData.uFoot = true;
|
|
839
|
+
const rest = $xeGantt.commitProxy('initial');
|
|
840
|
+
internalData.uFoot = false;
|
|
841
|
+
$xeGantt.updateQueryFooter();
|
|
842
|
+
return rest;
|
|
843
|
+
}).then((rest) => {
|
|
844
|
+
$xeGantt.dispatchEvent('proxy-query', Object.assign(Object.assign({}, rest), { isInited: true }), new Event('initial'));
|
|
845
|
+
});
|
|
846
|
+
}
|
|
814
847
|
}
|
|
815
848
|
}
|
|
816
849
|
},
|
|
850
|
+
updateQueryFooter() {
|
|
851
|
+
const $xeGantt = this;
|
|
852
|
+
const proxyOpts = $xeGantt.computeProxyOpts;
|
|
853
|
+
const { ajax } = proxyOpts;
|
|
854
|
+
if (ajax && ajax.queryFooter) {
|
|
855
|
+
return $xeGantt.commitProxy('queryFooter');
|
|
856
|
+
}
|
|
857
|
+
},
|
|
817
858
|
handleGlobalKeydownEvent(evnt) {
|
|
818
859
|
const $xeGantt = this;
|
|
819
860
|
const reactData = $xeGantt.reactData;
|
|
@@ -835,20 +876,21 @@ export default {
|
|
|
835
876
|
const $xeGantt = this;
|
|
836
877
|
const props = $xeGantt;
|
|
837
878
|
const reactData = $xeGantt.reactData;
|
|
879
|
+
const internalData = $xeGantt.internalData;
|
|
838
880
|
/**
|
|
839
881
|
* 已废弃
|
|
840
882
|
* @deprecated
|
|
841
883
|
*/
|
|
842
884
|
const toolbar = props.toolbar;
|
|
843
|
-
const { proxyConfig, toolbarConfig, pagerConfig, editRules, validConfig } = props;
|
|
885
|
+
const { showFooter, proxyConfig, toolbarConfig, pagerConfig, editRules, validConfig } = props;
|
|
844
886
|
const { tablePage } = reactData;
|
|
845
887
|
const isActiveMsg = $xeGantt.computeIsActiveMsg;
|
|
846
888
|
const isRespMsg = $xeGantt.computeIsRespMsg;
|
|
847
889
|
const proxyOpts = $xeGantt.computeProxyOpts;
|
|
848
890
|
const pagerOpts = $xeGantt.computePagerOpts;
|
|
849
891
|
const toolbarOpts = $xeGantt.computeToolbarOpts;
|
|
850
|
-
const { beforeQuery, afterQuery, beforeDelete, afterDelete, beforeSave, afterSave, ajax = {} } = proxyOpts;
|
|
851
|
-
const resConfigs = proxyOpts.response || proxyOpts.props || {};
|
|
892
|
+
const { beforeQuery, afterQuery, beforeQueryFooter, afterQueryFooter, beforeDelete, afterDelete, beforeSave, afterSave, ajax = {} } = proxyOpts;
|
|
893
|
+
const resConfigs = (proxyOpts.response || proxyOpts.props || {});
|
|
852
894
|
const $xeTable = $xeGantt.$refs.refTable;
|
|
853
895
|
let formData = $xeGantt.getFormData();
|
|
854
896
|
let button = null;
|
|
@@ -896,23 +938,25 @@ export default {
|
|
|
896
938
|
case 'initial':
|
|
897
939
|
case 'reload':
|
|
898
940
|
case 'query': {
|
|
899
|
-
const
|
|
900
|
-
const
|
|
901
|
-
const
|
|
902
|
-
if (
|
|
941
|
+
const qMethods = ajax.query;
|
|
942
|
+
const qsMethods = ajax.querySuccess;
|
|
943
|
+
const qeMethods = ajax.queryError;
|
|
944
|
+
if (qMethods) {
|
|
903
945
|
const isInited = code === 'initial';
|
|
904
946
|
const isReload = code === 'reload';
|
|
905
947
|
if (!isInited && reactData.tableLoading) {
|
|
906
948
|
return $xeGantt.$nextTick();
|
|
907
949
|
}
|
|
950
|
+
let operPromise = null;
|
|
908
951
|
let sortList = [];
|
|
909
952
|
let filterList = [];
|
|
910
953
|
let pageParams = {};
|
|
911
954
|
if (pagerConfig) {
|
|
912
955
|
if (isInited || isReload) {
|
|
956
|
+
// 重置分页
|
|
913
957
|
tablePage.currentPage = 1;
|
|
914
958
|
}
|
|
915
|
-
if (isEnableConf(
|
|
959
|
+
if (isEnableConf(pagerOpts)) {
|
|
916
960
|
pageParams = Object.assign({}, tablePage);
|
|
917
961
|
}
|
|
918
962
|
}
|
|
@@ -957,7 +1001,7 @@ export default {
|
|
|
957
1001
|
else {
|
|
958
1002
|
if ($xeTable) {
|
|
959
1003
|
if (isReload) {
|
|
960
|
-
$xeTable.clearAll();
|
|
1004
|
+
operPromise = $xeTable.clearAll();
|
|
961
1005
|
}
|
|
962
1006
|
else {
|
|
963
1007
|
sortList = $xeTable.getSortColumns();
|
|
@@ -978,23 +1022,25 @@ export default {
|
|
|
978
1022
|
sorts: sortList,
|
|
979
1023
|
filters: filterList,
|
|
980
1024
|
form: formData,
|
|
981
|
-
options:
|
|
1025
|
+
options: qMethods
|
|
982
1026
|
};
|
|
983
1027
|
reactData.sortData = sortList;
|
|
984
1028
|
reactData.filterData = filterList;
|
|
985
1029
|
reactData.tableLoading = true;
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1030
|
+
return Promise.all([
|
|
1031
|
+
Promise.resolve((beforeQuery || qMethods)(commitParams, ...args)),
|
|
1032
|
+
operPromise
|
|
1033
|
+
]).then(([rest]) => {
|
|
989
1034
|
let tableData = [];
|
|
990
1035
|
reactData.tableLoading = false;
|
|
991
1036
|
if (rest) {
|
|
1037
|
+
const reParams = { data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt };
|
|
992
1038
|
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
993
1039
|
const totalProp = resConfigs.total;
|
|
994
|
-
const total = (XEUtils.isFunction(totalProp) ? totalProp(
|
|
1040
|
+
const total = (XEUtils.isFunction(totalProp) ? totalProp(reParams) : XEUtils.get(rest, totalProp || 'page.total')) || 0;
|
|
995
1041
|
tablePage.total = XEUtils.toNumber(total);
|
|
996
1042
|
const resultProp = resConfigs.result;
|
|
997
|
-
tableData = (XEUtils.isFunction(resultProp) ? resultProp(
|
|
1043
|
+
tableData = (XEUtils.isFunction(resultProp) ? resultProp(reParams) : XEUtils.get(rest, resultProp || 'result')) || [];
|
|
998
1044
|
// 检验当前页码,不能超出当前最大页数
|
|
999
1045
|
const pageCount = Math.max(Math.ceil(total / tablePage.pageSize), 1);
|
|
1000
1046
|
if (tablePage.currentPage > pageCount) {
|
|
@@ -1003,36 +1049,89 @@ export default {
|
|
|
1003
1049
|
}
|
|
1004
1050
|
else {
|
|
1005
1051
|
const listProp = resConfigs.list;
|
|
1006
|
-
|
|
1052
|
+
if (XEUtils.isArray(rest)) {
|
|
1053
|
+
tableData = rest;
|
|
1054
|
+
}
|
|
1055
|
+
else if (listProp) {
|
|
1056
|
+
tableData = (XEUtils.isFunction(listProp) ? listProp(reParams) : XEUtils.get(rest, listProp)) || [];
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
if (showFooter) {
|
|
1060
|
+
const fdProp = resConfigs.footerData;
|
|
1061
|
+
const footerList = fdProp ? (XEUtils.isFunction(fdProp) ? fdProp(reParams) : XEUtils.get(rest, fdProp)) : [];
|
|
1062
|
+
if (XEUtils.isArray(footerList)) {
|
|
1063
|
+
reactData.footerData = footerList;
|
|
1064
|
+
}
|
|
1007
1065
|
}
|
|
1008
1066
|
}
|
|
1009
1067
|
if ($xeTable) {
|
|
1010
1068
|
$xeTable.loadData(tableData);
|
|
1011
1069
|
}
|
|
1012
1070
|
else {
|
|
1013
|
-
$
|
|
1071
|
+
$xeGantt.$nextTick(() => {
|
|
1072
|
+
const $xeTable = $xeGantt.$refs.refTable;
|
|
1014
1073
|
if ($xeTable) {
|
|
1015
1074
|
$xeTable.loadData(tableData);
|
|
1016
1075
|
}
|
|
1017
1076
|
});
|
|
1018
1077
|
}
|
|
1019
1078
|
if (afterQuery) {
|
|
1020
|
-
afterQuery(...
|
|
1079
|
+
afterQuery(commitParams, ...args);
|
|
1021
1080
|
}
|
|
1022
|
-
if (
|
|
1023
|
-
|
|
1081
|
+
if (qsMethods) {
|
|
1082
|
+
qsMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1024
1083
|
}
|
|
1025
1084
|
return { status: true };
|
|
1026
1085
|
}).catch((rest) => {
|
|
1027
1086
|
reactData.tableLoading = false;
|
|
1028
|
-
if (
|
|
1029
|
-
|
|
1087
|
+
if (qeMethods) {
|
|
1088
|
+
qeMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1089
|
+
}
|
|
1090
|
+
return { status: false };
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
else {
|
|
1094
|
+
errLog('vxe.error.notFunc', ['[gantt] proxy-config.ajax.query']);
|
|
1095
|
+
}
|
|
1096
|
+
break;
|
|
1097
|
+
}
|
|
1098
|
+
case 'queryFooter': {
|
|
1099
|
+
const qfMethods = ajax.queryFooter;
|
|
1100
|
+
const qfSuccessMethods = ajax.queryFooterSuccess;
|
|
1101
|
+
const qfErrorMethods = ajax.queryFooterError;
|
|
1102
|
+
if (qfMethods) {
|
|
1103
|
+
let filterList = [];
|
|
1104
|
+
if ($xeTable) {
|
|
1105
|
+
filterList = $xeTable.getCheckedFilters();
|
|
1106
|
+
}
|
|
1107
|
+
const commitParams = {
|
|
1108
|
+
$table: $xeTable,
|
|
1109
|
+
$grid: null,
|
|
1110
|
+
$gantt: $xeGantt,
|
|
1111
|
+
code,
|
|
1112
|
+
button,
|
|
1113
|
+
filters: filterList,
|
|
1114
|
+
form: formData,
|
|
1115
|
+
options: qfMethods
|
|
1116
|
+
};
|
|
1117
|
+
return Promise.resolve((beforeQueryFooter || qfMethods)(commitParams, ...args)).then(rest => {
|
|
1118
|
+
reactData.footerData = XEUtils.isArray(rest) ? rest : [];
|
|
1119
|
+
if (afterQueryFooter) {
|
|
1120
|
+
afterQueryFooter(commitParams, ...args);
|
|
1121
|
+
}
|
|
1122
|
+
if (qfSuccessMethods) {
|
|
1123
|
+
qfSuccessMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1124
|
+
}
|
|
1125
|
+
return { status: true };
|
|
1126
|
+
}).catch((rest) => {
|
|
1127
|
+
if (qfErrorMethods) {
|
|
1128
|
+
qfErrorMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
1030
1129
|
}
|
|
1031
1130
|
return { status: false };
|
|
1032
1131
|
});
|
|
1033
1132
|
}
|
|
1034
1133
|
else {
|
|
1035
|
-
errLog('vxe.error.notFunc', ['proxy-config.ajax.
|
|
1134
|
+
errLog('vxe.error.notFunc', ['[gantt] proxy-config.ajax.queryFooter']);
|
|
1036
1135
|
}
|
|
1037
1136
|
break;
|
|
1038
1137
|
}
|
|
@@ -1076,7 +1175,10 @@ export default {
|
|
|
1076
1175
|
afterDelete(...applyArgs);
|
|
1077
1176
|
}
|
|
1078
1177
|
else {
|
|
1178
|
+
internalData.uFoot = true;
|
|
1079
1179
|
$xeGantt.commitProxy('query');
|
|
1180
|
+
internalData.uFoot = false;
|
|
1181
|
+
$xeGantt.updateQueryFooter();
|
|
1080
1182
|
}
|
|
1081
1183
|
if (deleteSuccessMethods) {
|
|
1082
1184
|
deleteSuccessMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
@@ -1167,7 +1269,10 @@ export default {
|
|
|
1167
1269
|
afterSave(...applyArgs);
|
|
1168
1270
|
}
|
|
1169
1271
|
else {
|
|
1272
|
+
internalData.uFoot = true;
|
|
1170
1273
|
$xeGantt.commitProxy('query');
|
|
1274
|
+
internalData.uFoot = false;
|
|
1275
|
+
$xeGantt.updateQueryFooter();
|
|
1171
1276
|
}
|
|
1172
1277
|
if (saveSuccessMethods) {
|
|
1173
1278
|
saveSuccessMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
|
|
@@ -1476,12 +1581,24 @@ export default {
|
|
|
1476
1581
|
},
|
|
1477
1582
|
triggerToolbarCommitEvent(params, evnt) {
|
|
1478
1583
|
const $xeGantt = this;
|
|
1584
|
+
const internalData = $xeGantt.internalData;
|
|
1479
1585
|
const { code } = params;
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1586
|
+
if (code) {
|
|
1587
|
+
const isUf = ['reload', 'delete', 'save'].includes(code);
|
|
1588
|
+
if (isUf) {
|
|
1589
|
+
internalData.uFoot = true;
|
|
1483
1590
|
}
|
|
1484
|
-
|
|
1591
|
+
const rest = $xeGantt.commitProxy(params, evnt).then((rest) => {
|
|
1592
|
+
if (code && rest && rest.status && ['query', 'reload', 'delete', 'save'].includes(code)) {
|
|
1593
|
+
$xeGantt.dispatchEvent(code === 'delete' || code === 'save' ? `proxy-${code}` : 'proxy-query', Object.assign(Object.assign({}, rest), { isReload: code === 'reload' }), evnt);
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
if (isUf) {
|
|
1597
|
+
$xeGantt.updateQueryFooter();
|
|
1598
|
+
}
|
|
1599
|
+
internalData.uFoot = false;
|
|
1600
|
+
return rest;
|
|
1601
|
+
}
|
|
1485
1602
|
},
|
|
1486
1603
|
triggerToolbarBtnEvent(button, evnt) {
|
|
1487
1604
|
const $xeGantt = this;
|
package/es/ui/index.js
CHANGED
package/es/ui/src/log.js
CHANGED
package/es/ui/src/utils.js
CHANGED
|
@@ -39,3 +39,6 @@ export function eqEmptyValue(cellValue) {
|
|
|
39
39
|
export function getStringValue(cellValue) {
|
|
40
40
|
return eqEmptyValue(cellValue) ? '' : cellValue;
|
|
41
41
|
}
|
|
42
|
+
export function getClass(property, params) {
|
|
43
|
+
return property ? XEUtils.isFunction(property) ? property(params) : property : '';
|
|
44
|
+
}
|