vxe-gantt 0.0.1 → 0.0.3
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/LICENSE +21 -0
- package/README.en.md +72 -0
- package/README.ja-JP.md +72 -0
- package/README.md +82 -2
- package/README.zh-TW.md +73 -0
- package/es/components.js +12 -0
- package/es/gantt/index.js +13 -0
- package/es/gantt/src/emits.js +4 -0
- package/es/gantt/src/gantt-body.js +103 -0
- package/es/gantt/src/gantt-chart.js +77 -0
- package/es/gantt/src/gantt-header.js +70 -0
- package/es/gantt/src/gantt-view.js +768 -0
- package/es/gantt/src/gantt.js +1746 -0
- package/es/gantt/src/grid-emits.js +16 -0
- package/es/gantt/src/grid-props.js +7 -0
- package/es/gantt/src/props.js +2 -0
- package/es/gantt/src/table-emits.js +97 -0
- package/es/gantt/src/table-props.js +298 -0
- package/es/gantt/src/util.js +12 -0
- package/es/gantt/style.css +599 -0
- package/es/gantt/style.min.css +1 -0
- package/es/index.esm.js +3 -0
- package/es/style.css +1 -0
- package/es/style.min.css +1 -0
- package/es/ui/index.js +52 -0
- package/es/ui/src/comp.js +2 -0
- package/es/ui/src/dom.js +169 -0
- package/es/ui/src/log.js +4 -0
- package/es/ui/src/utils.js +41 -0
- package/es/ui/src/vn.js +1 -0
- package/es/ui/style.css +0 -0
- package/es/ui/style.min.css +0 -0
- package/es/vxe-gantt/index.js +3 -0
- package/es/vxe-gantt/style.css +599 -0
- package/es/vxe-gantt/style.min.css +1 -0
- package/es/vxe-ui/index.js +3 -0
- package/es/vxe-ui/style.css +0 -0
- package/es/vxe-ui/style.min.css +0 -0
- package/helper/vetur/attributes.json +1 -0
- package/helper/vetur/tags.json +1 -0
- package/lib/components.js +42 -0
- package/lib/components.min.js +1 -0
- package/lib/gantt/index.js +20 -0
- package/lib/gantt/index.min.js +1 -0
- package/lib/gantt/src/emits.js +8 -0
- package/lib/gantt/src/emits.min.js +1 -0
- package/lib/gantt/src/gantt-body.js +118 -0
- package/lib/gantt/src/gantt-body.min.js +1 -0
- package/lib/gantt/src/gantt-chart.js +94 -0
- package/lib/gantt/src/gantt-chart.min.js +1 -0
- package/lib/gantt/src/gantt-header.js +78 -0
- package/lib/gantt/src/gantt-header.min.js +1 -0
- package/lib/gantt/src/gantt-view.js +810 -0
- package/lib/gantt/src/gantt-view.min.js +1 -0
- package/lib/gantt/src/gantt.js +1997 -0
- package/lib/gantt/src/gantt.min.js +1 -0
- package/lib/gantt/src/grid-emits.js +8 -0
- package/lib/gantt/src/grid-emits.min.js +1 -0
- package/lib/gantt/src/grid-props.js +24 -0
- package/lib/gantt/src/grid-props.min.js +1 -0
- package/lib/gantt/src/props.js +13 -0
- package/lib/gantt/src/props.min.js +1 -0
- package/lib/gantt/src/table-emits.js +7 -0
- package/lib/gantt/src/table-emits.min.js +1 -0
- package/lib/gantt/src/table-props.js +306 -0
- package/lib/gantt/src/table-props.min.js +1 -0
- package/lib/gantt/src/util.js +19 -0
- package/lib/gantt/src/util.min.js +1 -0
- package/lib/gantt/style/index.js +1 -0
- package/lib/gantt/style/style.css +599 -0
- package/lib/gantt/style/style.min.css +1 -0
- package/lib/index.common.js +21 -0
- package/lib/index.umd.js +6731 -0
- package/lib/index.umd.min.js +1 -0
- package/lib/style.css +1 -0
- package/lib/style.min.css +1 -0
- package/lib/ui/index.js +69 -0
- package/lib/ui/index.min.js +1 -0
- package/lib/ui/src/comp.js +8 -0
- package/lib/ui/src/comp.min.js +1 -0
- package/lib/ui/src/dom.js +217 -0
- package/lib/ui/src/dom.min.js +1 -0
- package/lib/ui/src/log.js +10 -0
- package/lib/ui/src/log.min.js +1 -0
- package/lib/ui/src/utils.js +59 -0
- package/lib/ui/src/utils.min.js +1 -0
- package/lib/ui/src/vn.js +1 -0
- package/lib/ui/src/vn.min.js +0 -0
- package/lib/ui/style/index.js +1 -0
- package/lib/ui/style/style.css +0 -0
- package/lib/ui/style/style.min.css +0 -0
- package/lib/vxe-gantt/index.js +21 -0
- package/lib/vxe-gantt/index.min.js +1 -0
- package/lib/vxe-gantt/style/index.js +1 -0
- package/lib/vxe-gantt/style/style.css +599 -0
- package/lib/vxe-gantt/style/style.min.css +1 -0
- package/lib/vxe-ui/index.js +21 -0
- package/lib/vxe-ui/index.min.js +1 -0
- package/lib/vxe-ui/style/index.js +1 -0
- package/lib/vxe-ui/style/style.css +0 -0
- package/lib/vxe-ui/style/style.min.css +0 -0
- package/package.json +58 -21
- package/packages/components.ts +19 -0
- package/packages/gantt/index.ts +17 -0
- package/packages/gantt/src/emits.ts +7 -0
- package/packages/gantt/src/gantt-body.ts +119 -0
- package/packages/gantt/src/gantt-chart.ts +92 -0
- package/packages/gantt/src/gantt-header.ts +79 -0
- package/packages/gantt/src/gantt-view.ts +840 -0
- package/packages/gantt/src/gantt.ts +1869 -0
- package/packages/gantt/src/grid-emits.ts +19 -0
- package/packages/gantt/src/grid-props.ts +23 -0
- package/packages/gantt/src/props.ts +13 -0
- package/packages/gantt/src/table-emits.ts +109 -0
- package/packages/gantt/src/table-props.ts +304 -0
- package/packages/gantt/src/util.ts +15 -0
- package/packages/index.ts +4 -0
- package/packages/ui/index.ts +58 -0
- package/packages/ui/src/comp.ts +3 -0
- package/packages/ui/src/dom.ts +196 -0
- package/packages/ui/src/log.ts +6 -0
- package/packages/ui/src/utils.ts +50 -0
- package/packages/ui/src/vn.ts +0 -0
- package/styles/all.scss +3 -0
- package/styles/base.scss +2 -0
- package/styles/components/gantt-module/all.scss +1 -0
- package/styles/components/gantt-module/gantt-chart.scss +46 -0
- package/styles/components/gantt.scss +586 -0
- package/styles/components/ui.scss +0 -0
- package/styles/cssvar.scss +0 -0
- package/styles/helpers/baseMixin.scss +96 -0
- package/styles/helpers/baseVar.scss +4 -0
- package/styles/helpers/placement.scss +39 -0
- package/styles/theme/base.scss +7 -0
- package/styles/theme/dark.scss +7 -0
- package/styles/theme/light.scss +7 -0
- package/styles/variable.scss +0 -0
- package/types/all.d.ts +16 -0
- package/types/index.d.ts +4 -0
|
@@ -0,0 +1,1869 @@
|
|
|
1
|
+
import { h, ref, computed, provide, reactive, onUnmounted, watch, nextTick, VNode, ComponentPublicInstance, onMounted } from 'vue'
|
|
2
|
+
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
|
+
import XEUtils from 'xe-utils'
|
|
4
|
+
import { getLastZIndex, nextZIndex, isEnableConf } from '../../ui/src/utils'
|
|
5
|
+
import { getOffsetHeight, getPaddingTopBottomSize, getDomNode, toCssUnit, addClass, removeClass } from '../../ui/src/dom'
|
|
6
|
+
import { VxeUI } from '../../ui'
|
|
7
|
+
import { ganttProps } from './props'
|
|
8
|
+
import { ganttEmits } from './emits'
|
|
9
|
+
import { tableEmits } from './table-emits'
|
|
10
|
+
import { tableProps } from './table-props'
|
|
11
|
+
import { warnLog, errLog } from '../../ui/src/log'
|
|
12
|
+
import GanttViewComponent from './gantt-view'
|
|
13
|
+
|
|
14
|
+
import type { VxeGanttConstructor, VxeGanttEmits, GanttReactData, GanttInternalData, VxeGanttPropTypes, GanttMethods, GanttPrivateMethods, VxeGanttPrivateMethods, GanttPrivateRef, VxeGanttProps, VxeGanttPrivateComputed, VxeGanttViewInstance, VxeGanttDefines } from '../../../types'
|
|
15
|
+
import type { ValueOf, VxeFormEvents, VxeFormInstance, VxePagerEvents, VxeFormItemProps, VxePagerInstance, VxeComponentStyleType } from 'vxe-pc-ui'
|
|
16
|
+
import type { VxeTableMethods, VxeToolbarPropTypes, VxeTableProps, VxeTableConstructor, VxeTablePrivateMethods, VxeTableEvents, VxeTableDefines, VxeTableEventProps, VxeToolbarInstance } from 'vxe-table'
|
|
17
|
+
|
|
18
|
+
const { getConfig, getIcon, getI18n, commands, hooks, useFns, createEvent, globalEvents, GLOBAL_EVENT_KEYS, renderEmptyElement, getSlotVNs } = VxeUI
|
|
19
|
+
|
|
20
|
+
const tableComponentPropKeys = Object.keys(tableProps) as (keyof VxeTableProps)[]
|
|
21
|
+
const tableComponentMethodKeys: (keyof VxeTableMethods)[] = ['clearAll', 'syncData', 'updateData', 'loadData', 'reloadData', 'reloadRow', 'loadColumn', 'reloadColumn', 'getRowNode', 'getColumnNode', 'getRowIndex', 'getVTRowIndex', 'getVMRowIndex', 'getColumnIndex', 'getVTColumnIndex', 'getVMColumnIndex', 'setRow', 'createData', 'createRow', 'revertData', 'clearData', 'isRemoveByRow', 'isInsertByRow', 'isUpdateByRow', 'getColumns', 'getColumnById', 'getColumnByField', 'getTableColumn', 'getFullColumns', 'getData', 'getCheckboxRecords', 'getParentRow', 'getTreeRowChildren', 'getTreeParentRow', 'getRowSeq', 'getRowById', 'getRowid', 'getTableData', 'getFullData', 'setColumnFixed', 'clearColumnFixed', 'setColumnWidth', 'getColumnWidth', 'recalcRowHeight', 'setRowHeightConf', 'getRowHeightConf', 'setRowHeight', 'getRowHeight', 'hideColumn', 'showColumn', 'resetColumn', 'refreshColumn', 'refreshScroll', 'recalculate', 'closeTooltip', 'isAllCheckboxChecked', 'isAllCheckboxIndeterminate', 'getCheckboxIndeterminateRecords', 'setCheckboxRow', 'setCheckboxRowKey', 'isCheckedByCheckboxRow', 'isCheckedByCheckboxRowKey', 'isIndeterminateByCheckboxRow', 'isIndeterminateByCheckboxRowKey', 'toggleCheckboxRow', 'setAllCheckboxRow', 'getRadioReserveRecord', 'clearRadioReserve', 'getCheckboxReserveRecords', 'clearCheckboxReserve', 'toggleAllCheckboxRow', 'clearCheckboxRow', 'setCurrentRow', 'isCheckedByRadioRow', 'isCheckedByRadioRowKey', 'setRadioRow', 'setRadioRowKey', 'clearCurrentRow', 'clearRadioRow', 'getCurrentRecord', 'getRadioRecord', 'getCurrentColumn', 'setCurrentColumn', 'clearCurrentColumn', 'setPendingRow', 'togglePendingRow', 'hasPendingByRow', 'isPendingByRow', 'getPendingRecords', 'clearPendingRow', 'setFilterByEvent', 'sort', 'setSort', 'setSortByEvent', 'clearSort', 'clearSortByEvent', 'isSort', 'getSortColumns', 'closeFilter', 'isFilter', 'clearFilterByEvent', 'isActiveFilterByColumn', 'isRowExpandLoaded', 'clearRowExpandLoaded', 'reloadRowExpand', 'reloadRowExpand', 'toggleRowExpand', 'setAllRowExpand', 'setRowExpand', 'isExpandByRow', 'isRowExpandByRow', 'clearRowExpand', 'clearRowExpandReserve', 'getRowExpandRecords', 'getTreeExpandRecords', 'isTreeExpandLoaded', 'clearTreeExpandLoaded', 'reloadTreeExpand', 'reloadTreeChilds', 'toggleTreeExpand', 'setAllTreeExpand', 'setTreeExpand', 'isTreeExpandByRow', 'clearTreeExpand', 'clearTreeExpandReserve', 'getScroll', 'scrollTo', 'scrollToRow', 'scrollToColumn', 'clearScroll', 'updateFooter', 'updateStatus', 'setMergeCells', 'removeInsertRow', 'removeMergeCells', 'getMergeCells', 'clearMergeCells', 'setMergeFooterItems', 'removeMergeFooterItems', 'getMergeFooterItems', 'clearMergeFooterItems', 'getCustomStoreData', 'setRowGroupExpand', 'setAllRowGroupExpand', 'clearRowGroupExpand', 'isRowGroupExpandByRow', 'isRowGroupRecord', 'isAggregateRecord', 'isAggregateExpandByRow', 'getAggregateContentByRow', 'getAggregateRowChildren', 'setRowGroups', 'clearRowGroups', 'openTooltip', 'moveColumnTo', 'moveRowTo', 'getCellLabel', 'getCellElement', 'focus', 'blur', 'connect']
|
|
22
|
+
|
|
23
|
+
function createInternalData (): GanttInternalData {
|
|
24
|
+
return {
|
|
25
|
+
resizeTableWidth: 0
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default defineVxeComponent({
|
|
30
|
+
name: 'VxeGantt',
|
|
31
|
+
props: ganttProps,
|
|
32
|
+
emits: ganttEmits,
|
|
33
|
+
setup (props, context) {
|
|
34
|
+
const { slots, emit } = context
|
|
35
|
+
|
|
36
|
+
const xID = XEUtils.uniqueId()
|
|
37
|
+
|
|
38
|
+
// 使用已安装的组件,如果未安装则不渲染
|
|
39
|
+
const VxeUIFormComponent = VxeUI.getComponent('VxeForm')
|
|
40
|
+
const VxeUIPagerComponent = VxeUI.getComponent('VxePager')
|
|
41
|
+
const VxeTableComponent = VxeUI.getComponent('VxeTable')
|
|
42
|
+
const VxeToolbarComponent = VxeUI.getComponent('VxeToolbar')
|
|
43
|
+
|
|
44
|
+
const defaultLayouts: VxeGanttPropTypes.Layouts = [['Form'], ['Toolbar', 'Top', 'Gantt', 'Bottom', 'Pager']]
|
|
45
|
+
|
|
46
|
+
const { computeSize } = useFns.useSize(props)
|
|
47
|
+
|
|
48
|
+
const reactData = reactive<GanttReactData>({
|
|
49
|
+
tableLoading: false,
|
|
50
|
+
proxyInited: false,
|
|
51
|
+
isZMax: false,
|
|
52
|
+
tableData: [],
|
|
53
|
+
filterData: [],
|
|
54
|
+
formData: {},
|
|
55
|
+
sortData: [],
|
|
56
|
+
tZindex: 0,
|
|
57
|
+
tablePage: {
|
|
58
|
+
total: 0,
|
|
59
|
+
pageSize: getConfig().pager?.pageSize || 10,
|
|
60
|
+
currentPage: 1
|
|
61
|
+
},
|
|
62
|
+
showLeftView: true,
|
|
63
|
+
showRightView: true
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const internalData = createInternalData()
|
|
67
|
+
|
|
68
|
+
const refElem = ref<HTMLDivElement>()
|
|
69
|
+
const refTable = ref<ComponentPublicInstance<VxeTableProps, VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods>>()
|
|
70
|
+
const refForm = ref<VxeFormInstance>()
|
|
71
|
+
const refToolbar = ref<VxeToolbarInstance>()
|
|
72
|
+
const refPager = ref<VxePagerInstance>()
|
|
73
|
+
const refGanttContainer = ref<HTMLDivElement>()
|
|
74
|
+
const refGanttView = ref<VxeGanttViewInstance>()
|
|
75
|
+
|
|
76
|
+
const refFormWrapper = ref<HTMLDivElement>()
|
|
77
|
+
const refToolbarWrapper = ref<HTMLDivElement>()
|
|
78
|
+
const refTopWrapper = ref<HTMLDivElement>()
|
|
79
|
+
const refBottomWrapper = ref<HTMLDivElement>()
|
|
80
|
+
const refPagerWrapper = ref<HTMLDivElement>()
|
|
81
|
+
const refTableWrapper = ref<HTMLDivElement>()
|
|
82
|
+
const refGanttWrapper = ref<HTMLDivElement>()
|
|
83
|
+
|
|
84
|
+
const refResizableSplitTip = ref<HTMLDivElement>()
|
|
85
|
+
|
|
86
|
+
const extendTableMethods = <T>(methodKeys: T[]) => {
|
|
87
|
+
const funcs: any = {}
|
|
88
|
+
methodKeys.forEach(name => {
|
|
89
|
+
funcs[name] = (...args: any[]) => {
|
|
90
|
+
const $xeTable: any = refTable.value
|
|
91
|
+
if ($xeTable && $xeTable[name]) {
|
|
92
|
+
return $xeTable[name](...args)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
return funcs
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const ganttExtendTableMethods = extendTableMethods(tableComponentMethodKeys) as VxeTableMethods
|
|
100
|
+
|
|
101
|
+
tableComponentMethodKeys.forEach(name => {
|
|
102
|
+
ganttExtendTableMethods[name] = (...args: any[]) => {
|
|
103
|
+
const $xeTable: any = refTable.value
|
|
104
|
+
if ($xeTable && $xeTable[name]) {
|
|
105
|
+
return $xeTable && $xeTable[name](...args)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const computeProxyOpts = computed(() => {
|
|
111
|
+
return XEUtils.merge({}, XEUtils.clone(getConfig().gantt.proxyConfig, true), props.proxyConfig)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const computeIsRespMsg = computed(() => {
|
|
115
|
+
const proxyOpts = computeProxyOpts.value
|
|
116
|
+
return !!(XEUtils.isBoolean(proxyOpts.message) ? proxyOpts.message : proxyOpts.showResponseMsg)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const computeIsActiveMsg = computed(() => {
|
|
120
|
+
const proxyOpts = computeProxyOpts.value
|
|
121
|
+
return XEUtils.isBoolean(proxyOpts.showActionMsg) ? proxyOpts.showActionMsg : !!proxyOpts.showActiveMsg
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
const computePagerOpts = computed(() => {
|
|
125
|
+
return Object.assign({}, getConfig().gantt.pagerConfig, props.pagerConfig)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const computeFormOpts = computed(() => {
|
|
129
|
+
return Object.assign({}, getConfig().gantt.formConfig, props.formConfig)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const computeToolbarOpts = computed(() => {
|
|
133
|
+
return Object.assign({}, getConfig().gantt.toolbarConfig, props.toolbarConfig)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const computeZoomOpts = computed(() => {
|
|
137
|
+
return Object.assign({}, getConfig().gantt.zoomConfig, props.zoomConfig)
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
const computeTaskOpts = computed(() => {
|
|
141
|
+
return Object.assign({}, getConfig().gantt.taskConfig, props.taskConfig)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
const computeTaskViewOpts = computed(() => {
|
|
145
|
+
return Object.assign({}, getConfig().gantt.taskViewConfig, props.taskViewConfig)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
const computeTaskBarOpts = computed(() => {
|
|
149
|
+
return Object.assign({}, getConfig().gantt.taskBarConfig, props.taskBarConfig)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const computeTitleField = computed(() => {
|
|
153
|
+
const taskOpts = computeTaskOpts.value
|
|
154
|
+
return taskOpts.titleField || 'title'
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
const computeStartField = computed(() => {
|
|
158
|
+
const taskOpts = computeTaskOpts.value
|
|
159
|
+
return taskOpts.startField || 'startDate'
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
const computeEndField = computed(() => {
|
|
163
|
+
const taskOpts = computeTaskOpts.value
|
|
164
|
+
return taskOpts.endField || 'endDate'
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
const computeProgressField = computed(() => {
|
|
168
|
+
const taskOpts = computeTaskOpts.value
|
|
169
|
+
return taskOpts.progressField || 'progress'
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
const computeScrollbarOpts = computed(() => {
|
|
173
|
+
return Object.assign({}, getConfig().gantt.scrollbarConfig, props.scrollbarConfig)
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
const computeScrollbarXToTop = computed(() => {
|
|
177
|
+
const scrollbarOpts = computeScrollbarOpts.value
|
|
178
|
+
return !!(scrollbarOpts.x && scrollbarOpts.x.position === 'top')
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
const computeScrollbarYToLeft = computed(() => {
|
|
182
|
+
const scrollbarOpts = computeScrollbarOpts.value
|
|
183
|
+
return !!(scrollbarOpts.y && scrollbarOpts.y.position === 'left')
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
const computeStyles = computed(() => {
|
|
187
|
+
const { height, maxHeight } = props
|
|
188
|
+
const { isZMax, tZindex } = reactData
|
|
189
|
+
const stys: VxeComponentStyleType = {}
|
|
190
|
+
if (isZMax) {
|
|
191
|
+
stys.zIndex = tZindex
|
|
192
|
+
} else {
|
|
193
|
+
if (height) {
|
|
194
|
+
stys.height = height === 'auto' || height === '100%' ? '100%' : toCssUnit(height)
|
|
195
|
+
}
|
|
196
|
+
if (maxHeight) {
|
|
197
|
+
stys.maxHeight = maxHeight === 'auto' || maxHeight === '100%' ? '100%' : toCssUnit(maxHeight)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return stys
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
const computeTableExtendProps = computed(() => {
|
|
204
|
+
const rest: Record<string, any> = {}
|
|
205
|
+
tableComponentPropKeys.forEach((key) => {
|
|
206
|
+
rest[key] = props[key]
|
|
207
|
+
})
|
|
208
|
+
return rest
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
const computeTableProps = computed(() => {
|
|
212
|
+
const { seqConfig, pagerConfig, editConfig, proxyConfig } = props
|
|
213
|
+
const { isZMax, tablePage } = reactData
|
|
214
|
+
const tableExtendProps = computeTableExtendProps.value
|
|
215
|
+
const proxyOpts = computeProxyOpts.value
|
|
216
|
+
const pagerOpts = computePagerOpts.value
|
|
217
|
+
const isLoading = computeIsLoading.value
|
|
218
|
+
const tProps = Object.assign({}, tableExtendProps, {
|
|
219
|
+
showOverflow: true,
|
|
220
|
+
showHeaderOverflow: true,
|
|
221
|
+
showFooterOverflow: true,
|
|
222
|
+
showFooter: false
|
|
223
|
+
})
|
|
224
|
+
if (isZMax) {
|
|
225
|
+
if (tableExtendProps.maxHeight) {
|
|
226
|
+
tProps.maxHeight = '100%'
|
|
227
|
+
} else {
|
|
228
|
+
tProps.height = '100%'
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
232
|
+
tProps.loading = isLoading
|
|
233
|
+
if (pagerConfig && proxyOpts.seq && isEnableConf(pagerOpts)) {
|
|
234
|
+
tProps.seqConfig = Object.assign({}, seqConfig, { startIndex: (tablePage.currentPage - 1) * tablePage.pageSize })
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (editConfig) {
|
|
238
|
+
tProps.editConfig = Object.assign({}, editConfig)
|
|
239
|
+
}
|
|
240
|
+
return tProps
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
const computeCurrLayoutConf = computed(() => {
|
|
244
|
+
const { layouts } = props
|
|
245
|
+
let confs: VxeGanttPropTypes.Layouts = []
|
|
246
|
+
if (layouts && layouts.length) {
|
|
247
|
+
confs = layouts
|
|
248
|
+
} else {
|
|
249
|
+
confs = getConfig().gantt.layouts || defaultLayouts
|
|
250
|
+
}
|
|
251
|
+
let headKeys: VxeGanttDefines.LayoutKey[] = []
|
|
252
|
+
let bodyKeys: VxeGanttDefines.LayoutKey[] = []
|
|
253
|
+
let footKeys: VxeGanttDefines.LayoutKey[] = []
|
|
254
|
+
if (confs.length) {
|
|
255
|
+
if (XEUtils.isArray(confs[0])) {
|
|
256
|
+
headKeys = confs[0] as VxeGanttDefines.LayoutKey[]
|
|
257
|
+
bodyKeys = (confs[1] || []) as VxeGanttDefines.LayoutKey[]
|
|
258
|
+
footKeys = (confs[2] || []) as VxeGanttDefines.LayoutKey[]
|
|
259
|
+
} else {
|
|
260
|
+
bodyKeys = confs as VxeGanttDefines.LayoutKey[]
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
headKeys,
|
|
265
|
+
bodyKeys,
|
|
266
|
+
footKeys
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
const computeCustomCurrentPageFlag = computed(() => {
|
|
271
|
+
const pagerOpts = computePagerOpts.value
|
|
272
|
+
return pagerOpts.currentPage
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
const computeCustomPageSizeFlag = computed(() => {
|
|
276
|
+
const pagerOpts = computePagerOpts.value
|
|
277
|
+
return pagerOpts.pageSize
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
const computeCustomTotalFlag = computed(() => {
|
|
281
|
+
const pagerOpts = computePagerOpts.value
|
|
282
|
+
return pagerOpts.total
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
const computePageCount = computed(() => {
|
|
286
|
+
const { tablePage } = reactData
|
|
287
|
+
return Math.max(Math.ceil(tablePage.total / tablePage.pageSize), 1)
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
const computeIsLoading = computed(() => {
|
|
291
|
+
const { loading, proxyConfig } = props
|
|
292
|
+
const { tableLoading } = reactData
|
|
293
|
+
const proxyOpts = computeProxyOpts.value
|
|
294
|
+
const { showLoading } = proxyOpts
|
|
295
|
+
return loading || (tableLoading && showLoading && proxyConfig && isEnableConf(proxyOpts))
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
const computeTableBorder = computed(() => {
|
|
299
|
+
const { border } = props
|
|
300
|
+
if (border === true) {
|
|
301
|
+
return 'full'
|
|
302
|
+
}
|
|
303
|
+
if (border) {
|
|
304
|
+
return border
|
|
305
|
+
}
|
|
306
|
+
return 'default'
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
const refMaps: GanttPrivateRef = {
|
|
310
|
+
refElem,
|
|
311
|
+
refTable,
|
|
312
|
+
refForm,
|
|
313
|
+
refToolbar,
|
|
314
|
+
refPager
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const computeMaps: VxeGanttPrivateComputed = {
|
|
318
|
+
computeProxyOpts,
|
|
319
|
+
computePagerOpts,
|
|
320
|
+
computeFormOpts,
|
|
321
|
+
computeToolbarOpts,
|
|
322
|
+
computeZoomOpts,
|
|
323
|
+
computeTaskOpts,
|
|
324
|
+
computeTaskViewOpts,
|
|
325
|
+
computeTaskBarOpts,
|
|
326
|
+
computeTitleField,
|
|
327
|
+
computeStartField,
|
|
328
|
+
computeEndField,
|
|
329
|
+
computeProgressField,
|
|
330
|
+
computeScrollbarOpts,
|
|
331
|
+
computeScrollbarXToTop,
|
|
332
|
+
computeScrollbarYToLeft
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const $xeGantt = {
|
|
336
|
+
xID,
|
|
337
|
+
props: props as VxeGanttProps,
|
|
338
|
+
context,
|
|
339
|
+
reactData,
|
|
340
|
+
internalData,
|
|
341
|
+
getRefMaps: () => refMaps,
|
|
342
|
+
getComputeMaps: () => computeMaps
|
|
343
|
+
} as VxeGanttConstructor & VxeGanttPrivateMethods
|
|
344
|
+
|
|
345
|
+
const initToolbar = () => {
|
|
346
|
+
const toolbarOpts = computeToolbarOpts.value
|
|
347
|
+
if (props.toolbarConfig && isEnableConf(toolbarOpts)) {
|
|
348
|
+
nextTick(() => {
|
|
349
|
+
const $xeTable = refTable.value
|
|
350
|
+
const $xeToolbar = refToolbar.value
|
|
351
|
+
if ($xeTable && $xeToolbar) {
|
|
352
|
+
$xeTable.connectToolbar($xeToolbar)
|
|
353
|
+
}
|
|
354
|
+
})
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const initGanttView = () => {
|
|
359
|
+
const $xeTable = refTable.value
|
|
360
|
+
const $ganttView = refGanttView.value
|
|
361
|
+
if ($xeTable && $ganttView) {
|
|
362
|
+
$xeTable.handleConnectGanttView($ganttView)
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const getFormData = () => {
|
|
367
|
+
const { proxyConfig } = props
|
|
368
|
+
const { formData } = reactData
|
|
369
|
+
const proxyOpts = computeProxyOpts.value
|
|
370
|
+
const formOpts = computeFormOpts.value
|
|
371
|
+
return proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form ? formData : formOpts.data
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const initPages = (propKey?: 'currentPage' | 'pageSize' | 'total') => {
|
|
375
|
+
const { tablePage } = reactData
|
|
376
|
+
const { pagerConfig } = props
|
|
377
|
+
const pagerOpts = computePagerOpts.value
|
|
378
|
+
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
379
|
+
if (propKey) {
|
|
380
|
+
if (pagerOpts[propKey]) {
|
|
381
|
+
tablePage[propKey] = XEUtils.toNumber(pagerOpts[propKey])
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
const { currentPage, pageSize, total } = pagerOpts
|
|
385
|
+
if (currentPage) {
|
|
386
|
+
tablePage.currentPage = currentPage
|
|
387
|
+
}
|
|
388
|
+
if (pageSize) {
|
|
389
|
+
tablePage.pageSize = pageSize
|
|
390
|
+
}
|
|
391
|
+
if (total) {
|
|
392
|
+
tablePage.total = total
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const triggerPendingEvent = (code: string) => {
|
|
399
|
+
const isActiveMsg = computeIsActiveMsg.value
|
|
400
|
+
const $xeTable = refTable.value
|
|
401
|
+
const selectRecords = $xeTable ? $xeTable.getCheckboxRecords() : []
|
|
402
|
+
if (selectRecords.length) {
|
|
403
|
+
if ($xeTable) {
|
|
404
|
+
$xeTable.togglePendingRow(selectRecords)
|
|
405
|
+
}
|
|
406
|
+
$xeGantt.clearCheckboxRow()
|
|
407
|
+
} else {
|
|
408
|
+
if (isActiveMsg) {
|
|
409
|
+
if (VxeUI.modal) {
|
|
410
|
+
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' })
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const getRespMsg = (rest: any, defaultMsg: string) => {
|
|
417
|
+
const proxyOpts = computeProxyOpts.value
|
|
418
|
+
const resConfigs = proxyOpts.response || proxyOpts.props || {}
|
|
419
|
+
const messageProp = resConfigs.message
|
|
420
|
+
const $xeTable = refTable.value
|
|
421
|
+
let msg
|
|
422
|
+
if (rest && messageProp) {
|
|
423
|
+
msg = XEUtils.isFunction(messageProp) ? messageProp({ data: rest, $table: $xeTable as VxeTableConstructor, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, messageProp)
|
|
424
|
+
}
|
|
425
|
+
return msg || getI18n(defaultMsg)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const handleDeleteRow = (code: string, alertKey: string, callback: () => void): Promise<void> => {
|
|
429
|
+
const isActiveMsg = computeIsActiveMsg.value
|
|
430
|
+
const selectRecords = $xeGantt.getCheckboxRecords()
|
|
431
|
+
if (isActiveMsg) {
|
|
432
|
+
if (selectRecords.length) {
|
|
433
|
+
if (VxeUI.modal) {
|
|
434
|
+
return VxeUI.modal.confirm({ id: `cfm_${code}`, content: getI18n(alertKey), escClosable: true }).then((type) => {
|
|
435
|
+
if (type === 'confirm') {
|
|
436
|
+
return callback()
|
|
437
|
+
}
|
|
438
|
+
})
|
|
439
|
+
}
|
|
440
|
+
} else {
|
|
441
|
+
if (VxeUI.modal) {
|
|
442
|
+
VxeUI.modal.message({ id: `msg_${code}`, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' })
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
} else {
|
|
446
|
+
if (selectRecords.length) {
|
|
447
|
+
callback()
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return Promise.resolve()
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const pageChangeEvent: VxePagerEvents.PageChange = (params) => {
|
|
454
|
+
const { proxyConfig } = props
|
|
455
|
+
const { tablePage } = reactData
|
|
456
|
+
const { $event, currentPage, pageSize } = params
|
|
457
|
+
const proxyOpts = computeProxyOpts.value
|
|
458
|
+
tablePage.currentPage = currentPage
|
|
459
|
+
tablePage.pageSize = pageSize
|
|
460
|
+
$xeGantt.dispatchEvent('page-change', params, $event)
|
|
461
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
462
|
+
$xeGantt.commitProxy('query').then((rest) => {
|
|
463
|
+
$xeGantt.dispatchEvent('proxy-query', rest, $event)
|
|
464
|
+
})
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
const handleSortEvent: VxeTableEvents.SortChange | VxeTableEvents.ClearAllSort = (params) => {
|
|
469
|
+
const $xeTable = refTable.value
|
|
470
|
+
const { proxyConfig } = props
|
|
471
|
+
if (!$xeTable) {
|
|
472
|
+
return
|
|
473
|
+
}
|
|
474
|
+
const { computeSortOpts } = $xeTable.getComputeMaps()
|
|
475
|
+
const proxyOpts = computeProxyOpts.value
|
|
476
|
+
const sortOpts = computeSortOpts.value
|
|
477
|
+
// 如果是服务端排序
|
|
478
|
+
if (sortOpts.remote) {
|
|
479
|
+
reactData.sortData = params.sortList
|
|
480
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
481
|
+
reactData.tablePage.currentPage = 1
|
|
482
|
+
$xeGantt.commitProxy('query').then((rest) => {
|
|
483
|
+
$xeGantt.dispatchEvent('proxy-query', rest, params.$event)
|
|
484
|
+
})
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const sortChangeEvent: VxeTableEvents.SortChange = (params) => {
|
|
490
|
+
handleSortEvent(params)
|
|
491
|
+
$xeGantt.dispatchEvent('sort-change', params, params.$event)
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const clearAllSortEvent: VxeTableEvents.ClearAllSort = (params) => {
|
|
495
|
+
handleSortEvent(params)
|
|
496
|
+
$xeGantt.dispatchEvent('clear-all-sort', params, params.$event)
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const handleFilterEvent: VxeTableEvents.FilterChange | VxeTableEvents.ClearAllFilter = (params) => {
|
|
500
|
+
const $xeTable = refTable.value
|
|
501
|
+
const { proxyConfig } = props
|
|
502
|
+
if (!$xeTable) {
|
|
503
|
+
return
|
|
504
|
+
}
|
|
505
|
+
const { computeFilterOpts } = $xeTable.getComputeMaps()
|
|
506
|
+
const proxyOpts = computeProxyOpts.value
|
|
507
|
+
const filterOpts = computeFilterOpts.value
|
|
508
|
+
// 如果是服务端过滤
|
|
509
|
+
if (filterOpts.remote) {
|
|
510
|
+
reactData.filterData = params.filterList
|
|
511
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
512
|
+
reactData.tablePage.currentPage = 1
|
|
513
|
+
$xeGantt.commitProxy('query').then((rest) => {
|
|
514
|
+
$xeGantt.dispatchEvent('proxy-query', rest, params.$event)
|
|
515
|
+
})
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
const filterChangeEvent: VxeTableEvents.FilterChange = (params) => {
|
|
521
|
+
handleFilterEvent(params)
|
|
522
|
+
$xeGantt.dispatchEvent('filter-change', params, params.$event)
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const clearAllFilterEvent: VxeTableEvents.ClearAllFilter = (params) => {
|
|
526
|
+
handleFilterEvent(params)
|
|
527
|
+
$xeGantt.dispatchEvent('clear-all-filter', params, params.$event)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const submitFormEvent: VxeFormEvents.Submit = (params) => {
|
|
531
|
+
const { proxyConfig } = props
|
|
532
|
+
const proxyOpts = computeProxyOpts.value
|
|
533
|
+
if (reactData.tableLoading) {
|
|
534
|
+
return
|
|
535
|
+
}
|
|
536
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
537
|
+
$xeGantt.commitProxy('reload').then((rest) => {
|
|
538
|
+
$xeGantt.dispatchEvent('proxy-query', { ...rest, isReload: true }, params.$event)
|
|
539
|
+
})
|
|
540
|
+
}
|
|
541
|
+
$xeGantt.dispatchEvent('form-submit', params, params.$event)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
const resetFormEvent: VxeFormEvents.Reset = (params) => {
|
|
545
|
+
const $xeTable = refTable.value
|
|
546
|
+
const { proxyConfig } = props
|
|
547
|
+
const { $event } = params
|
|
548
|
+
const proxyOpts = computeProxyOpts.value
|
|
549
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
550
|
+
if ($xeTable) {
|
|
551
|
+
$xeTable.clearScroll()
|
|
552
|
+
}
|
|
553
|
+
$xeGantt.commitProxy('reload').then((rest) => {
|
|
554
|
+
$xeGantt.dispatchEvent('proxy-query', { ...rest, isReload: true }, $event)
|
|
555
|
+
})
|
|
556
|
+
}
|
|
557
|
+
$xeGantt.dispatchEvent('form-reset', params, $event)
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const submitInvalidEvent: VxeFormEvents.SubmitInvalid = (params) => {
|
|
561
|
+
$xeGantt.dispatchEvent('form-submit-invalid', params, params.$event)
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
const collapseEvent: VxeFormEvents.Collapse = (params) => {
|
|
565
|
+
const { $event } = params
|
|
566
|
+
$xeGantt.dispatchEvent('form-toggle-collapse', params, $event)
|
|
567
|
+
$xeGantt.dispatchEvent('form-collapse', params, $event)
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const handleZoom = (isMax?: boolean) => {
|
|
571
|
+
const { isZMax } = reactData
|
|
572
|
+
if (isMax ? !isZMax : isZMax) {
|
|
573
|
+
reactData.isZMax = !isZMax
|
|
574
|
+
if (reactData.tZindex < getLastZIndex()) {
|
|
575
|
+
reactData.tZindex = nextZIndex()
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return nextTick()
|
|
579
|
+
.then(() => $xeGantt.recalculate(true))
|
|
580
|
+
.then(() => {
|
|
581
|
+
setTimeout(() => $xeGantt.recalculate(true), 15)
|
|
582
|
+
return reactData.isZMax
|
|
583
|
+
})
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const getFuncSlot = (optSlots: any, slotKey: string) => {
|
|
587
|
+
const funcSlot = optSlots[slotKey]
|
|
588
|
+
if (funcSlot) {
|
|
589
|
+
if (XEUtils.isString(funcSlot)) {
|
|
590
|
+
if (slots[funcSlot]) {
|
|
591
|
+
return slots[funcSlot]
|
|
592
|
+
} else {
|
|
593
|
+
errLog('vxe.error.notSlot', [funcSlot])
|
|
594
|
+
}
|
|
595
|
+
} else {
|
|
596
|
+
return funcSlot
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return null
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
const getConfigSlot = (slotConfigs?: Record<string, any>) => {
|
|
603
|
+
const slotConf: Record<string, any> = {}
|
|
604
|
+
XEUtils.objectMap(slotConfigs, (slotFunc, slotKey) => {
|
|
605
|
+
if (slotFunc) {
|
|
606
|
+
if (XEUtils.isString(slotFunc)) {
|
|
607
|
+
if (slots[slotFunc]) {
|
|
608
|
+
slotConf[slotKey] = slots[slotFunc]
|
|
609
|
+
} else {
|
|
610
|
+
errLog('vxe.error.notSlot', [slotFunc])
|
|
611
|
+
}
|
|
612
|
+
} else {
|
|
613
|
+
slotConf[slotKey] = slotFunc
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
})
|
|
617
|
+
return slotConf
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
const dragSplitEvent = (evnt: MouseEvent) => {
|
|
621
|
+
const el = refElem.value
|
|
622
|
+
if (!el) {
|
|
623
|
+
return
|
|
624
|
+
}
|
|
625
|
+
const ganttContainerEl = refGanttContainer.value
|
|
626
|
+
if (!ganttContainerEl) {
|
|
627
|
+
return
|
|
628
|
+
}
|
|
629
|
+
const tableWrapperEl = refTableWrapper.value
|
|
630
|
+
if (!tableWrapperEl) {
|
|
631
|
+
return
|
|
632
|
+
}
|
|
633
|
+
const rsSplitLineEl = refResizableSplitTip.value
|
|
634
|
+
if (!rsSplitLineEl) {
|
|
635
|
+
return
|
|
636
|
+
}
|
|
637
|
+
const taskViewOpts = computeTaskViewOpts.value
|
|
638
|
+
const containerRect = ganttContainerEl.getBoundingClientRect()
|
|
639
|
+
const rsSplitTipEl = rsSplitLineEl.children[0] as HTMLDivElement
|
|
640
|
+
const disX = evnt.clientX
|
|
641
|
+
const ganttWidth = ganttContainerEl.clientWidth
|
|
642
|
+
const tableWidth = tableWrapperEl.clientWidth
|
|
643
|
+
const tableMinWidth = (taskViewOpts.tableStyle && XEUtils.toNumber(taskViewOpts.tableStyle.minWidth)) || 80
|
|
644
|
+
let targetTableWidth = tableWidth
|
|
645
|
+
let offsetLeft = -1
|
|
646
|
+
addClass(el, 'is--split-drag')
|
|
647
|
+
|
|
648
|
+
const handleReStyle = (evnt: MouseEvent) => {
|
|
649
|
+
const rsNumLeftEl = rsSplitTipEl.children[0] as HTMLDivElement
|
|
650
|
+
const rsNumRightEl = rsSplitTipEl.children[1] as HTMLDivElement
|
|
651
|
+
let tipHeight = 0
|
|
652
|
+
if (rsNumLeftEl) {
|
|
653
|
+
if (offsetLeft < 0) {
|
|
654
|
+
rsNumLeftEl.textContent = `${targetTableWidth}px`
|
|
655
|
+
rsNumLeftEl.style.display = 'block'
|
|
656
|
+
tipHeight = rsNumLeftEl.offsetHeight
|
|
657
|
+
} else {
|
|
658
|
+
rsNumLeftEl.style.display = 'none'
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (rsNumRightEl) {
|
|
662
|
+
if (offsetLeft < 0) {
|
|
663
|
+
rsNumRightEl.style.display = 'none'
|
|
664
|
+
} else {
|
|
665
|
+
rsNumRightEl.textContent = `${Math.floor(containerRect.width - targetTableWidth)}px`
|
|
666
|
+
rsNumRightEl.style.display = 'block'
|
|
667
|
+
tipHeight = rsNumRightEl.offsetHeight
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
const tipTop = evnt.clientY - containerRect.top - tipHeight / 2
|
|
671
|
+
rsSplitLineEl.style.left = `${targetTableWidth}px`
|
|
672
|
+
rsSplitTipEl.style.top = `${Math.min(containerRect.height - tipHeight - 1, Math.max(1, tipTop))}px`
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
document.onmousemove = (evnt) => {
|
|
676
|
+
evnt.preventDefault()
|
|
677
|
+
offsetLeft = (evnt.clientX - disX)
|
|
678
|
+
targetTableWidth = Math.min(ganttWidth - 80, Math.max(tableMinWidth, tableWidth + offsetLeft))
|
|
679
|
+
handleReStyle(evnt)
|
|
680
|
+
}
|
|
681
|
+
document.onmouseup = () => {
|
|
682
|
+
document.onmousemove = null
|
|
683
|
+
document.onmouseup = null
|
|
684
|
+
rsSplitLineEl.style.display = ''
|
|
685
|
+
tableWrapperEl.style.width = `${targetTableWidth}px`
|
|
686
|
+
removeClass(el, 'is--split-drag')
|
|
687
|
+
const $xeTable = refTable.value
|
|
688
|
+
if ($xeTable) {
|
|
689
|
+
$xeTable.recalculate(true)
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
rsSplitLineEl.style.display = 'block'
|
|
693
|
+
handleReStyle(evnt)
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
const handleSplitLeftViewEvent = () => {
|
|
697
|
+
reactData.showLeftView = !reactData.showLeftView
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const handleSplitRightViewEvent = () => {
|
|
701
|
+
reactData.showRightView = !reactData.showRightView
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
const tableCompEvents: VxeTableEventProps = {}
|
|
705
|
+
tableEmits.forEach(name => {
|
|
706
|
+
const type = XEUtils.camelCase(`on-${name}`) as keyof VxeTableEventProps
|
|
707
|
+
tableCompEvents[type] = (...args: any[]) => emit(name, ...args)
|
|
708
|
+
})
|
|
709
|
+
|
|
710
|
+
const getDefaultFormData = () => {
|
|
711
|
+
const formOpts = computeFormOpts.value
|
|
712
|
+
if (formOpts.items) {
|
|
713
|
+
const fData: any = {}
|
|
714
|
+
formOpts.items.forEach(item => {
|
|
715
|
+
const { field, itemRender } = item
|
|
716
|
+
if (field) {
|
|
717
|
+
let itemValue: any = null
|
|
718
|
+
if (itemRender) {
|
|
719
|
+
const { defaultValue } = itemRender
|
|
720
|
+
if (XEUtils.isFunction(defaultValue)) {
|
|
721
|
+
itemValue = defaultValue({ item })
|
|
722
|
+
} else if (!XEUtils.isUndefined(defaultValue)) {
|
|
723
|
+
itemValue = defaultValue
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
fData[field] = itemValue
|
|
727
|
+
}
|
|
728
|
+
})
|
|
729
|
+
return fData
|
|
730
|
+
}
|
|
731
|
+
return {}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
const initProxy = () => {
|
|
735
|
+
const { proxyConfig, formConfig } = props
|
|
736
|
+
const { proxyInited } = reactData
|
|
737
|
+
const proxyOpts = computeProxyOpts.value
|
|
738
|
+
const formOpts = computeFormOpts.value
|
|
739
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
740
|
+
if (formConfig && isEnableConf(formOpts) && proxyOpts.form && formOpts.items) {
|
|
741
|
+
reactData.formData = getDefaultFormData()
|
|
742
|
+
}
|
|
743
|
+
if (!proxyInited) {
|
|
744
|
+
reactData.proxyInited = true
|
|
745
|
+
if (proxyOpts.autoLoad !== false) {
|
|
746
|
+
nextTick().then(() => $xeGantt.commitProxy('initial')).then((rest) => {
|
|
747
|
+
dispatchEvent('proxy-query', { ...rest, isInited: true }, new Event('initial'))
|
|
748
|
+
})
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
const handleGlobalKeydownEvent = (evnt: KeyboardEvent) => {
|
|
755
|
+
const zoomOpts = computeZoomOpts.value
|
|
756
|
+
const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE)
|
|
757
|
+
if (isEsc && reactData.isZMax && zoomOpts.escRestore !== false) {
|
|
758
|
+
$xeGantt.triggerZoomEvent(evnt)
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
const dispatchEvent = (type: ValueOf<VxeGanttEmits>, params: Record<string, any>, evnt: Event | null) => {
|
|
763
|
+
emit(type, createEvent(evnt, { $grid: null, $gantt: $xeGantt }, params))
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
const ganttMethods: GanttMethods = {
|
|
767
|
+
dispatchEvent,
|
|
768
|
+
getEl () {
|
|
769
|
+
return refElem.value as HTMLDivElement
|
|
770
|
+
},
|
|
771
|
+
/**
|
|
772
|
+
* 提交指令,支持 code 或 button
|
|
773
|
+
* @param {String/Object} code 字符串或对象
|
|
774
|
+
*/
|
|
775
|
+
commitProxy (proxyTarget: string | VxeToolbarPropTypes.ButtonConfig, ...args: any[]) {
|
|
776
|
+
const { proxyConfig, toolbarConfig, pagerConfig, editRules, validConfig } = props
|
|
777
|
+
const { tablePage } = reactData
|
|
778
|
+
const isActiveMsg = computeIsActiveMsg.value
|
|
779
|
+
const isRespMsg = computeIsRespMsg.value
|
|
780
|
+
const proxyOpts = computeProxyOpts.value
|
|
781
|
+
const pagerOpts = computePagerOpts.value
|
|
782
|
+
const toolbarOpts = computeToolbarOpts.value
|
|
783
|
+
const { beforeQuery, afterQuery, beforeDelete, afterDelete, beforeSave, afterSave, ajax = {} } = proxyOpts
|
|
784
|
+
const resConfigs = proxyOpts.response || proxyOpts.props || {}
|
|
785
|
+
const $xeTable = refTable.value
|
|
786
|
+
if (!$xeTable) {
|
|
787
|
+
return nextTick()
|
|
788
|
+
}
|
|
789
|
+
let formData = getFormData()
|
|
790
|
+
let button: VxeToolbarPropTypes.ButtonConfig | null = null
|
|
791
|
+
let code: string | null = null
|
|
792
|
+
if (XEUtils.isString(proxyTarget)) {
|
|
793
|
+
const { buttons } = toolbarOpts
|
|
794
|
+
const matchObj = toolbarConfig && isEnableConf(toolbarOpts) && buttons ? XEUtils.findTree(buttons, (item) => item.code === proxyTarget, { children: 'dropdowns' }) : null
|
|
795
|
+
button = matchObj ? matchObj.item : null
|
|
796
|
+
code = proxyTarget
|
|
797
|
+
} else {
|
|
798
|
+
button = proxyTarget
|
|
799
|
+
code = button.code as string
|
|
800
|
+
}
|
|
801
|
+
const btnParams = button ? button.params : null
|
|
802
|
+
switch (code) {
|
|
803
|
+
case 'insert':
|
|
804
|
+
return $xeTable.insert({})
|
|
805
|
+
case 'insert_edit':
|
|
806
|
+
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true))
|
|
807
|
+
|
|
808
|
+
// 已废弃
|
|
809
|
+
case 'insert_actived':
|
|
810
|
+
return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true))
|
|
811
|
+
// 已废弃
|
|
812
|
+
|
|
813
|
+
case 'mark_cancel':
|
|
814
|
+
triggerPendingEvent(code)
|
|
815
|
+
break
|
|
816
|
+
case 'remove':
|
|
817
|
+
return handleDeleteRow(code, 'vxe.grid.removeSelectRecord', () => $xeTable.removeCheckboxRow())
|
|
818
|
+
case 'import':
|
|
819
|
+
$xeTable.importData(btnParams)
|
|
820
|
+
break
|
|
821
|
+
case 'open_import':
|
|
822
|
+
$xeTable.openImport(btnParams)
|
|
823
|
+
break
|
|
824
|
+
case 'export':
|
|
825
|
+
$xeTable.exportData(btnParams)
|
|
826
|
+
break
|
|
827
|
+
case 'open_export':
|
|
828
|
+
$xeTable.openExport(btnParams)
|
|
829
|
+
break
|
|
830
|
+
case 'reset_custom':
|
|
831
|
+
return $xeTable.resetCustom(true)
|
|
832
|
+
case 'initial':
|
|
833
|
+
case 'reload':
|
|
834
|
+
case 'query': {
|
|
835
|
+
const ajaxMethods = ajax.query
|
|
836
|
+
const querySuccessMethods = ajax.querySuccess
|
|
837
|
+
const queryErrorMethods = ajax.queryError
|
|
838
|
+
if (ajaxMethods) {
|
|
839
|
+
const isInited = code === 'initial'
|
|
840
|
+
const isReload = code === 'reload'
|
|
841
|
+
if (!isInited && reactData.tableLoading) {
|
|
842
|
+
return nextTick()
|
|
843
|
+
}
|
|
844
|
+
let sortList: any[] = []
|
|
845
|
+
let filterList: VxeTableDefines.FilterCheckedParams[] = []
|
|
846
|
+
let pageParams: any = {}
|
|
847
|
+
if (pagerConfig) {
|
|
848
|
+
if (isInited || isReload) {
|
|
849
|
+
// 重置分页
|
|
850
|
+
tablePage.currentPage = 1
|
|
851
|
+
}
|
|
852
|
+
if (isEnableConf(pagerOpts)) {
|
|
853
|
+
pageParams = { ...tablePage }
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (isInited) {
|
|
857
|
+
// 重置代理表单数据
|
|
858
|
+
if (proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form) {
|
|
859
|
+
formData = getDefaultFormData()
|
|
860
|
+
reactData.formData = formData
|
|
861
|
+
}
|
|
862
|
+
if ($xeTable) {
|
|
863
|
+
const tableInternalData = $xeTable.internalData
|
|
864
|
+
const { tableFullColumn, fullColumnFieldData } = tableInternalData
|
|
865
|
+
const { computeSortOpts } = $xeTable.getComputeMaps()
|
|
866
|
+
const sortOpts = computeSortOpts.value
|
|
867
|
+
let defaultSort = sortOpts.defaultSort
|
|
868
|
+
tableFullColumn.forEach((column) => {
|
|
869
|
+
column.order = null
|
|
870
|
+
})
|
|
871
|
+
// 如果使用默认排序
|
|
872
|
+
if (defaultSort) {
|
|
873
|
+
if (!XEUtils.isArray(defaultSort)) {
|
|
874
|
+
defaultSort = [defaultSort]
|
|
875
|
+
}
|
|
876
|
+
sortList = defaultSort.map((item) => {
|
|
877
|
+
const { field, order } = item
|
|
878
|
+
const colRest = fullColumnFieldData[field]
|
|
879
|
+
if (colRest) {
|
|
880
|
+
const column = colRest.column
|
|
881
|
+
if (column) {
|
|
882
|
+
column.order = order
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return {
|
|
886
|
+
field,
|
|
887
|
+
property: field,
|
|
888
|
+
order
|
|
889
|
+
}
|
|
890
|
+
})
|
|
891
|
+
}
|
|
892
|
+
filterList = $xeTable.getCheckedFilters()
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
if ($xeTable) {
|
|
896
|
+
if (isReload) {
|
|
897
|
+
$xeTable.clearAll()
|
|
898
|
+
} else {
|
|
899
|
+
sortList = $xeTable.getSortColumns()
|
|
900
|
+
filterList = $xeTable.getCheckedFilters()
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
const commitParams = {
|
|
905
|
+
$table: $xeTable,
|
|
906
|
+
$grid: null,
|
|
907
|
+
$gantt: $xeGantt,
|
|
908
|
+
code,
|
|
909
|
+
button,
|
|
910
|
+
isInited,
|
|
911
|
+
isReload,
|
|
912
|
+
page: pageParams,
|
|
913
|
+
sort: sortList.length ? sortList[0] : {},
|
|
914
|
+
sorts: sortList,
|
|
915
|
+
filters: filterList,
|
|
916
|
+
form: formData,
|
|
917
|
+
options: ajaxMethods
|
|
918
|
+
}
|
|
919
|
+
reactData.sortData = sortList
|
|
920
|
+
reactData.filterData = filterList
|
|
921
|
+
reactData.tableLoading = true
|
|
922
|
+
return Promise.resolve((beforeQuery || ajaxMethods)(commitParams, ...args))
|
|
923
|
+
.then(rest => {
|
|
924
|
+
let tableData: any[] = []
|
|
925
|
+
reactData.tableLoading = false
|
|
926
|
+
if (rest) {
|
|
927
|
+
if (pagerConfig && isEnableConf(pagerOpts)) {
|
|
928
|
+
const totalProp = resConfigs.total
|
|
929
|
+
const total = (XEUtils.isFunction(totalProp) ? totalProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, totalProp || 'page.total')) || 0
|
|
930
|
+
tablePage.total = XEUtils.toNumber(total)
|
|
931
|
+
const resultProp = resConfigs.result
|
|
932
|
+
tableData = (XEUtils.isFunction(resultProp) ? resultProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, resultProp || 'result')) || []
|
|
933
|
+
// 检验当前页码,不能超出当前最大页数
|
|
934
|
+
const pageCount = Math.max(Math.ceil(total / tablePage.pageSize), 1)
|
|
935
|
+
if (tablePage.currentPage > pageCount) {
|
|
936
|
+
tablePage.currentPage = pageCount
|
|
937
|
+
}
|
|
938
|
+
} else {
|
|
939
|
+
const listProp = resConfigs.list
|
|
940
|
+
tableData = (listProp ? (XEUtils.isFunction(listProp) ? listProp({ data: rest, $table: $xeTable, $grid: null, $gantt: $xeGantt }) : XEUtils.get(rest, listProp)) : rest) || []
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if ($xeTable as any) {
|
|
944
|
+
$xeTable.loadData(tableData)
|
|
945
|
+
} else {
|
|
946
|
+
nextTick(() => {
|
|
947
|
+
if ($xeTable) {
|
|
948
|
+
$xeTable.loadData(tableData)
|
|
949
|
+
}
|
|
950
|
+
})
|
|
951
|
+
}
|
|
952
|
+
if (afterQuery) {
|
|
953
|
+
afterQuery(commitParams, ...args)
|
|
954
|
+
}
|
|
955
|
+
if (querySuccessMethods) {
|
|
956
|
+
querySuccessMethods({ ...commitParams, response: rest })
|
|
957
|
+
}
|
|
958
|
+
return { status: true }
|
|
959
|
+
}).catch((rest) => {
|
|
960
|
+
reactData.tableLoading = false
|
|
961
|
+
if (queryErrorMethods) {
|
|
962
|
+
queryErrorMethods({ ...commitParams, response: rest })
|
|
963
|
+
}
|
|
964
|
+
return { status: false }
|
|
965
|
+
})
|
|
966
|
+
} else {
|
|
967
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.query'])
|
|
968
|
+
}
|
|
969
|
+
break
|
|
970
|
+
}
|
|
971
|
+
case 'delete': {
|
|
972
|
+
const ajaxMethods = ajax.delete
|
|
973
|
+
const deleteSuccessMethods = ajax.deleteSuccess
|
|
974
|
+
const deleteErrorMethods = ajax.deleteError
|
|
975
|
+
if (ajaxMethods) {
|
|
976
|
+
const selectRecords = $xeGantt.getCheckboxRecords()
|
|
977
|
+
const removeRecords = selectRecords.filter(row => !$xeTable.isInsertByRow(row))
|
|
978
|
+
const body = { removeRecords }
|
|
979
|
+
const commitParams = {
|
|
980
|
+
$table: $xeTable,
|
|
981
|
+
$grid: null,
|
|
982
|
+
$gantt: $xeGantt,
|
|
983
|
+
code,
|
|
984
|
+
button,
|
|
985
|
+
body,
|
|
986
|
+
form: formData,
|
|
987
|
+
options: ajaxMethods
|
|
988
|
+
}
|
|
989
|
+
if (selectRecords.length) {
|
|
990
|
+
return handleDeleteRow(code, 'vxe.grid.deleteSelectRecord', () => {
|
|
991
|
+
if (!removeRecords.length) {
|
|
992
|
+
return $xeTable.remove(selectRecords)
|
|
993
|
+
}
|
|
994
|
+
reactData.tableLoading = true
|
|
995
|
+
return Promise.resolve((beforeDelete || ajaxMethods)(commitParams, ...args))
|
|
996
|
+
.then(rest => {
|
|
997
|
+
reactData.tableLoading = false
|
|
998
|
+
$xeTable.setPendingRow(removeRecords, false)
|
|
999
|
+
if (isRespMsg) {
|
|
1000
|
+
if (VxeUI.modal) {
|
|
1001
|
+
VxeUI.modal.message({ content: getRespMsg(rest, 'vxe.grid.delSuccess'), status: 'success' })
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
if (afterDelete) {
|
|
1005
|
+
afterDelete(commitParams, ...args)
|
|
1006
|
+
} else {
|
|
1007
|
+
$xeGantt.commitProxy('query')
|
|
1008
|
+
}
|
|
1009
|
+
if (deleteSuccessMethods) {
|
|
1010
|
+
deleteSuccessMethods({ ...commitParams, response: rest })
|
|
1011
|
+
}
|
|
1012
|
+
return { status: true }
|
|
1013
|
+
})
|
|
1014
|
+
.catch(rest => {
|
|
1015
|
+
reactData.tableLoading = false
|
|
1016
|
+
if (isRespMsg) {
|
|
1017
|
+
if (VxeUI.modal) {
|
|
1018
|
+
VxeUI.modal.message({ id: code, content: getRespMsg(rest, 'vxe.grid.operError'), status: 'error' })
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
if (deleteErrorMethods) {
|
|
1022
|
+
deleteErrorMethods({ ...commitParams, response: rest })
|
|
1023
|
+
}
|
|
1024
|
+
return { status: false }
|
|
1025
|
+
})
|
|
1026
|
+
})
|
|
1027
|
+
} else {
|
|
1028
|
+
if (isActiveMsg) {
|
|
1029
|
+
if (VxeUI.modal) {
|
|
1030
|
+
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.selectOneRecord'), status: 'warning' })
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
} else {
|
|
1035
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.delete'])
|
|
1036
|
+
}
|
|
1037
|
+
break
|
|
1038
|
+
}
|
|
1039
|
+
case 'save': {
|
|
1040
|
+
const ajaxMethods = ajax.save
|
|
1041
|
+
const saveSuccessMethods = ajax.saveSuccess
|
|
1042
|
+
const saveErrorMethods = ajax.saveError
|
|
1043
|
+
if (ajaxMethods) {
|
|
1044
|
+
const body = $xeTable.getRecordset()
|
|
1045
|
+
const { insertRecords, removeRecords, updateRecords, pendingRecords } = body
|
|
1046
|
+
const commitParams = {
|
|
1047
|
+
$table: $xeTable,
|
|
1048
|
+
$grid: null,
|
|
1049
|
+
$gantt: $xeGantt,
|
|
1050
|
+
code,
|
|
1051
|
+
button,
|
|
1052
|
+
body,
|
|
1053
|
+
form: formData,
|
|
1054
|
+
options: ajaxMethods
|
|
1055
|
+
}
|
|
1056
|
+
// 排除掉新增且标记为删除的数据
|
|
1057
|
+
if (insertRecords.length) {
|
|
1058
|
+
body.pendingRecords = pendingRecords.filter((row) => $xeTable.findRowIndexOf(insertRecords, row) === -1)
|
|
1059
|
+
}
|
|
1060
|
+
// 排除已标记为删除的数据
|
|
1061
|
+
if (pendingRecords.length) {
|
|
1062
|
+
body.insertRecords = insertRecords.filter((row) => $xeTable.findRowIndexOf(pendingRecords, row) === -1)
|
|
1063
|
+
}
|
|
1064
|
+
let restPromise: Promise<any> = Promise.resolve()
|
|
1065
|
+
if (editRules) {
|
|
1066
|
+
// 只校验新增和修改的数据
|
|
1067
|
+
restPromise = $xeTable[validConfig && validConfig.msgMode === 'full' ? 'fullValidate' : 'validate'](body.insertRecords.concat(updateRecords))
|
|
1068
|
+
}
|
|
1069
|
+
return restPromise.then((errMap) => {
|
|
1070
|
+
if (errMap) {
|
|
1071
|
+
// 如果校验不通过
|
|
1072
|
+
return
|
|
1073
|
+
}
|
|
1074
|
+
if (body.insertRecords.length || removeRecords.length || updateRecords.length || body.pendingRecords.length) {
|
|
1075
|
+
reactData.tableLoading = true
|
|
1076
|
+
return Promise.resolve((beforeSave || ajaxMethods)(commitParams, ...args))
|
|
1077
|
+
.then(rest => {
|
|
1078
|
+
reactData.tableLoading = false
|
|
1079
|
+
$xeTable.clearPendingRow()
|
|
1080
|
+
if (isRespMsg) {
|
|
1081
|
+
if (VxeUI.modal) {
|
|
1082
|
+
VxeUI.modal.message({ content: getRespMsg(rest, 'vxe.grid.saveSuccess'), status: 'success' })
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
if (afterSave) {
|
|
1086
|
+
afterSave(commitParams, ...args)
|
|
1087
|
+
} else {
|
|
1088
|
+
$xeGantt.commitProxy('query')
|
|
1089
|
+
}
|
|
1090
|
+
if (saveSuccessMethods) {
|
|
1091
|
+
saveSuccessMethods({ ...commitParams, response: rest })
|
|
1092
|
+
}
|
|
1093
|
+
return { status: true }
|
|
1094
|
+
})
|
|
1095
|
+
.catch(rest => {
|
|
1096
|
+
reactData.tableLoading = false
|
|
1097
|
+
if (isRespMsg) {
|
|
1098
|
+
if (VxeUI.modal) {
|
|
1099
|
+
VxeUI.modal.message({ id: code, content: getRespMsg(rest, 'vxe.grid.operError'), status: 'error' })
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if (saveErrorMethods) {
|
|
1103
|
+
saveErrorMethods({ ...commitParams, response: rest })
|
|
1104
|
+
}
|
|
1105
|
+
return { status: false }
|
|
1106
|
+
})
|
|
1107
|
+
} else {
|
|
1108
|
+
if (isActiveMsg) {
|
|
1109
|
+
if (VxeUI.modal) {
|
|
1110
|
+
VxeUI.modal.message({ id: code, content: getI18n('vxe.grid.dataUnchanged'), status: 'info' })
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
})
|
|
1115
|
+
} else {
|
|
1116
|
+
errLog('vxe.error.notFunc', ['proxy-config.ajax.save'])
|
|
1117
|
+
}
|
|
1118
|
+
break
|
|
1119
|
+
}
|
|
1120
|
+
default: {
|
|
1121
|
+
const gCommandOpts = commands.get(code)
|
|
1122
|
+
if (gCommandOpts) {
|
|
1123
|
+
const tCommandMethod = gCommandOpts.tableCommandMethod || gCommandOpts.commandMethod
|
|
1124
|
+
if (tCommandMethod) {
|
|
1125
|
+
tCommandMethod({ code, button, $table: $xeTable, $grid: null, $gantt: $xeGantt }, ...args)
|
|
1126
|
+
} else {
|
|
1127
|
+
errLog('vxe.error.notCommands', [code])
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
return nextTick()
|
|
1133
|
+
},
|
|
1134
|
+
getParams () {
|
|
1135
|
+
return props.params
|
|
1136
|
+
},
|
|
1137
|
+
zoom () {
|
|
1138
|
+
if (reactData.isZMax) {
|
|
1139
|
+
return $xeGantt.revert()
|
|
1140
|
+
}
|
|
1141
|
+
return $xeGantt.maximize()
|
|
1142
|
+
},
|
|
1143
|
+
isMaximized () {
|
|
1144
|
+
return reactData.isZMax
|
|
1145
|
+
},
|
|
1146
|
+
maximize () {
|
|
1147
|
+
return handleZoom(true)
|
|
1148
|
+
},
|
|
1149
|
+
revert () {
|
|
1150
|
+
return handleZoom()
|
|
1151
|
+
},
|
|
1152
|
+
getFormData,
|
|
1153
|
+
getFormItems (itemIndex?: number): any {
|
|
1154
|
+
const formOpts = computeFormOpts.value
|
|
1155
|
+
const { formConfig } = props
|
|
1156
|
+
const { items } = formOpts
|
|
1157
|
+
const itemList: VxeFormItemProps[] = []
|
|
1158
|
+
XEUtils.eachTree(formConfig && isEnableConf(formOpts) && items ? items : [], item => {
|
|
1159
|
+
itemList.push(item)
|
|
1160
|
+
}, { children: 'children' })
|
|
1161
|
+
return XEUtils.isUndefined(itemIndex) ? itemList : itemList[itemIndex]
|
|
1162
|
+
},
|
|
1163
|
+
resetForm () {
|
|
1164
|
+
const $form = refForm.value
|
|
1165
|
+
if ($form) {
|
|
1166
|
+
return $form.reset()
|
|
1167
|
+
}
|
|
1168
|
+
return nextTick()
|
|
1169
|
+
},
|
|
1170
|
+
validateForm () {
|
|
1171
|
+
const $form = refForm.value
|
|
1172
|
+
if ($form) {
|
|
1173
|
+
return $form.validate()
|
|
1174
|
+
}
|
|
1175
|
+
return nextTick()
|
|
1176
|
+
},
|
|
1177
|
+
validateFormField (field) {
|
|
1178
|
+
const $form = refForm.value
|
|
1179
|
+
if ($form) {
|
|
1180
|
+
return $form.validateField(field)
|
|
1181
|
+
}
|
|
1182
|
+
return nextTick()
|
|
1183
|
+
},
|
|
1184
|
+
clearFormValidate (field) {
|
|
1185
|
+
const $form = refForm.value
|
|
1186
|
+
if ($form) {
|
|
1187
|
+
return $form.clearValidate(field)
|
|
1188
|
+
}
|
|
1189
|
+
return nextTick()
|
|
1190
|
+
},
|
|
1191
|
+
homePage () {
|
|
1192
|
+
const { tablePage } = reactData
|
|
1193
|
+
tablePage.currentPage = 1
|
|
1194
|
+
return nextTick()
|
|
1195
|
+
},
|
|
1196
|
+
homePageByEvent (evnt) {
|
|
1197
|
+
const $pager = refPager.value
|
|
1198
|
+
if ($pager) {
|
|
1199
|
+
$pager.homePageByEvent(evnt)
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
endPage () {
|
|
1203
|
+
const { tablePage } = reactData
|
|
1204
|
+
const pageCount = computePageCount.value
|
|
1205
|
+
tablePage.currentPage = pageCount
|
|
1206
|
+
return nextTick()
|
|
1207
|
+
},
|
|
1208
|
+
endPageByEvent (evnt) {
|
|
1209
|
+
const $pager = refPager.value
|
|
1210
|
+
if ($pager) {
|
|
1211
|
+
$pager.endPageByEvent(evnt)
|
|
1212
|
+
}
|
|
1213
|
+
},
|
|
1214
|
+
setCurrentPage (currentPage) {
|
|
1215
|
+
const { tablePage } = reactData
|
|
1216
|
+
const pageCount = computePageCount.value
|
|
1217
|
+
tablePage.currentPage = Math.min(pageCount, Math.max(1, XEUtils.toNumber(currentPage)))
|
|
1218
|
+
return nextTick()
|
|
1219
|
+
},
|
|
1220
|
+
setCurrentPageByEvent (evnt, currentPage) {
|
|
1221
|
+
const $pager = refPager.value
|
|
1222
|
+
if ($pager) {
|
|
1223
|
+
$pager.setCurrentPageByEvent(evnt, currentPage)
|
|
1224
|
+
}
|
|
1225
|
+
},
|
|
1226
|
+
setPageSize (pageSize) {
|
|
1227
|
+
const { tablePage } = reactData
|
|
1228
|
+
tablePage.pageSize = Math.max(1, XEUtils.toNumber(pageSize))
|
|
1229
|
+
return nextTick()
|
|
1230
|
+
},
|
|
1231
|
+
setPageSizeByEvent (evnt, pageSize) {
|
|
1232
|
+
const $pager = refPager.value
|
|
1233
|
+
if ($pager) {
|
|
1234
|
+
$pager.setPageSizeByEvent(evnt, pageSize)
|
|
1235
|
+
}
|
|
1236
|
+
},
|
|
1237
|
+
getProxyInfo () {
|
|
1238
|
+
const $xeTable = refTable.value
|
|
1239
|
+
if (props.proxyConfig) {
|
|
1240
|
+
const { sortData } = reactData
|
|
1241
|
+
return {
|
|
1242
|
+
data: $xeTable ? $xeTable.getFullData() : [],
|
|
1243
|
+
filter: reactData.filterData,
|
|
1244
|
+
form: getFormData(),
|
|
1245
|
+
sort: sortData.length ? sortData[0] : {},
|
|
1246
|
+
sorts: sortData,
|
|
1247
|
+
pager: reactData.tablePage,
|
|
1248
|
+
pendingRecords: $xeTable ? $xeTable.getPendingRecords() : []
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
return null
|
|
1252
|
+
}
|
|
1253
|
+
// setProxyInfo (options) {
|
|
1254
|
+
// if (props.proxyConfig && options) {
|
|
1255
|
+
// const { pager, form } = options
|
|
1256
|
+
// const proxyOpts = computeProxyOpts.value
|
|
1257
|
+
// if (pager) {
|
|
1258
|
+
// if (pager.currentPage) {
|
|
1259
|
+
// reactData.tablePage.currentPage = Number(pager.currentPage)
|
|
1260
|
+
// }
|
|
1261
|
+
// if (pager.pageSize) {
|
|
1262
|
+
// reactData.tablePage.pageSize = Number(pager.pageSize)
|
|
1263
|
+
// }
|
|
1264
|
+
// }
|
|
1265
|
+
// if (proxyOpts.form && form) {
|
|
1266
|
+
// Object.assign(reactData.formData, form)
|
|
1267
|
+
// }
|
|
1268
|
+
// }
|
|
1269
|
+
// return nextTick()
|
|
1270
|
+
// }
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
const ganttPrivateMethods: GanttPrivateMethods = {
|
|
1274
|
+
extendTableMethods,
|
|
1275
|
+
callSlot (slotFunc, params) {
|
|
1276
|
+
if (slotFunc) {
|
|
1277
|
+
if (XEUtils.isString(slotFunc)) {
|
|
1278
|
+
slotFunc = slots[slotFunc] || null
|
|
1279
|
+
}
|
|
1280
|
+
if (XEUtils.isFunction(slotFunc)) {
|
|
1281
|
+
return getSlotVNs(slotFunc(params))
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
return []
|
|
1285
|
+
},
|
|
1286
|
+
/**
|
|
1287
|
+
* 获取需要排除的高度
|
|
1288
|
+
*/
|
|
1289
|
+
getExcludeHeight () {
|
|
1290
|
+
const { isZMax } = reactData
|
|
1291
|
+
const el = refElem.value
|
|
1292
|
+
if (el) {
|
|
1293
|
+
const formWrapper = refFormWrapper.value
|
|
1294
|
+
const toolbarWrapper = refToolbarWrapper.value
|
|
1295
|
+
const topWrapper = refTopWrapper.value
|
|
1296
|
+
const bottomWrapper = refBottomWrapper.value
|
|
1297
|
+
const pagerWrapper = refPagerWrapper.value
|
|
1298
|
+
const parentEl = el.parentElement as HTMLElement
|
|
1299
|
+
const parentPaddingSize = isZMax ? 0 : (parentEl ? getPaddingTopBottomSize(parentEl) : 0)
|
|
1300
|
+
return parentPaddingSize + getPaddingTopBottomSize(el) + getOffsetHeight(formWrapper) + getOffsetHeight(toolbarWrapper) + getOffsetHeight(topWrapper) + getOffsetHeight(bottomWrapper) + getOffsetHeight(pagerWrapper)
|
|
1301
|
+
}
|
|
1302
|
+
return 0
|
|
1303
|
+
},
|
|
1304
|
+
getParentHeight () {
|
|
1305
|
+
const el = refElem.value
|
|
1306
|
+
if (el) {
|
|
1307
|
+
const parentEl = el.parentElement as HTMLElement
|
|
1308
|
+
return (reactData.isZMax ? getDomNode().visibleHeight : (parentEl ? XEUtils.toNumber(getComputedStyle(parentEl).height) : 0)) - ganttPrivateMethods.getExcludeHeight()
|
|
1309
|
+
}
|
|
1310
|
+
return 0
|
|
1311
|
+
},
|
|
1312
|
+
triggerToolbarCommitEvent (params, evnt) {
|
|
1313
|
+
const { code } = params
|
|
1314
|
+
return $xeGantt.commitProxy(params, evnt).then((rest) => {
|
|
1315
|
+
if (code && rest && rest.status && ['query', 'reload', 'delete', 'save'].includes(code)) {
|
|
1316
|
+
$xeGantt.dispatchEvent(code === 'delete' || code === 'save' ? `proxy-${code as 'delete' | 'save'}` : 'proxy-query', { ...rest, isReload: code === 'reload' }, evnt)
|
|
1317
|
+
}
|
|
1318
|
+
})
|
|
1319
|
+
},
|
|
1320
|
+
triggerToolbarBtnEvent (button, evnt) {
|
|
1321
|
+
$xeGantt.triggerToolbarCommitEvent(button, evnt)
|
|
1322
|
+
$xeGantt.dispatchEvent('toolbar-button-click', { code: button.code, button }, evnt)
|
|
1323
|
+
},
|
|
1324
|
+
triggerToolbarTolEvent (tool, evnt) {
|
|
1325
|
+
$xeGantt.triggerToolbarCommitEvent(tool, evnt)
|
|
1326
|
+
$xeGantt.dispatchEvent('toolbar-tool-click', { code: tool.code, tool }, evnt)
|
|
1327
|
+
},
|
|
1328
|
+
triggerZoomEvent (evnt) {
|
|
1329
|
+
$xeGantt.zoom()
|
|
1330
|
+
$xeGantt.dispatchEvent('zoom', { type: reactData.isZMax ? 'max' : 'revert' }, evnt)
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
Object.assign($xeGantt, ganttExtendTableMethods, ganttMethods, ganttPrivateMethods, {
|
|
1335
|
+
// 检查插槽
|
|
1336
|
+
loadColumn (columns: any[]) {
|
|
1337
|
+
const $xeTable = refTable.value
|
|
1338
|
+
XEUtils.eachTree(columns, (column) => {
|
|
1339
|
+
if (column.slots) {
|
|
1340
|
+
XEUtils.each(column.slots, (func) => {
|
|
1341
|
+
if (!XEUtils.isFunction(func)) {
|
|
1342
|
+
if (!slots[func]) {
|
|
1343
|
+
errLog('vxe.error.notSlot', [func])
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
})
|
|
1347
|
+
}
|
|
1348
|
+
})
|
|
1349
|
+
if ($xeTable) {
|
|
1350
|
+
return $xeTable.loadColumn(columns)
|
|
1351
|
+
}
|
|
1352
|
+
return nextTick()
|
|
1353
|
+
},
|
|
1354
|
+
reloadColumn (columns: any[]) {
|
|
1355
|
+
$xeGantt.clearAll()
|
|
1356
|
+
return $xeGantt.loadColumn(columns)
|
|
1357
|
+
}
|
|
1358
|
+
})
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* 渲染表单
|
|
1362
|
+
*/
|
|
1363
|
+
const renderForm = () => {
|
|
1364
|
+
const { formConfig, proxyConfig } = props
|
|
1365
|
+
const { formData } = reactData
|
|
1366
|
+
const proxyOpts = computeProxyOpts.value
|
|
1367
|
+
const formOpts = computeFormOpts.value
|
|
1368
|
+
if ((formConfig && isEnableConf(formOpts)) || slots.form) {
|
|
1369
|
+
let slotVNs: VNode[] = []
|
|
1370
|
+
if (slots.form) {
|
|
1371
|
+
slotVNs = slots.form({ $grid: null, $gantt: $xeGantt })
|
|
1372
|
+
} else {
|
|
1373
|
+
if (formOpts.items) {
|
|
1374
|
+
const formSlots: { [key: string]: () => VNode[] } = {}
|
|
1375
|
+
if (!(formOpts as any).inited) {
|
|
1376
|
+
(formOpts as any).inited = true
|
|
1377
|
+
const beforeItem = proxyOpts.beforeItem
|
|
1378
|
+
if (proxyOpts && beforeItem) {
|
|
1379
|
+
formOpts.items.forEach((item) => {
|
|
1380
|
+
beforeItem({ $grid: null, $gantt: $xeGantt, item })
|
|
1381
|
+
})
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
// 处理插槽
|
|
1385
|
+
formOpts.items.forEach((item) => {
|
|
1386
|
+
XEUtils.each(item.slots, (func) => {
|
|
1387
|
+
if (!XEUtils.isFunction(func)) {
|
|
1388
|
+
if (slots[func]) {
|
|
1389
|
+
formSlots[func] = slots[func] as any
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
})
|
|
1393
|
+
})
|
|
1394
|
+
if (VxeUIFormComponent) {
|
|
1395
|
+
slotVNs.push(
|
|
1396
|
+
h(VxeUIFormComponent, {
|
|
1397
|
+
ref: refForm,
|
|
1398
|
+
...Object.assign({}, formOpts, {
|
|
1399
|
+
data: proxyConfig && isEnableConf(proxyOpts) && proxyOpts.form ? formData : formOpts.data
|
|
1400
|
+
}),
|
|
1401
|
+
onSubmit: submitFormEvent,
|
|
1402
|
+
onReset: resetFormEvent,
|
|
1403
|
+
onSubmitInvalid: submitInvalidEvent,
|
|
1404
|
+
onCollapse: collapseEvent
|
|
1405
|
+
}, formSlots)
|
|
1406
|
+
)
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
return h('div', {
|
|
1411
|
+
ref: refFormWrapper,
|
|
1412
|
+
key: 'form',
|
|
1413
|
+
class: 'vxe-gantt--form-wrapper'
|
|
1414
|
+
}, slotVNs)
|
|
1415
|
+
}
|
|
1416
|
+
return renderEmptyElement($xeGantt)
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* 渲染工具栏
|
|
1421
|
+
*/
|
|
1422
|
+
const renderToolbar = () => {
|
|
1423
|
+
const { toolbarConfig } = props
|
|
1424
|
+
const toolbarOpts = computeToolbarOpts.value
|
|
1425
|
+
if ((toolbarConfig && isEnableConf(toolbarOpts)) || slots.toolbar) {
|
|
1426
|
+
let slotVNs: VNode[] = []
|
|
1427
|
+
if (slots.toolbar) {
|
|
1428
|
+
slotVNs = slots.toolbar({ $grid: null, $gantt: $xeGantt })
|
|
1429
|
+
} else {
|
|
1430
|
+
const toolbarOptSlots = toolbarOpts.slots
|
|
1431
|
+
const toolbarSlots: {
|
|
1432
|
+
buttons?(params: any): any
|
|
1433
|
+
buttonPrefix?(params: any): any
|
|
1434
|
+
buttonSuffix?(params: any): any
|
|
1435
|
+
tools?(params: any): any
|
|
1436
|
+
toolPrefix?(params: any): any
|
|
1437
|
+
toolSuffix?(params: any): any
|
|
1438
|
+
} = {}
|
|
1439
|
+
if (toolbarOptSlots) {
|
|
1440
|
+
const buttonsSlot = getFuncSlot(toolbarOptSlots, 'buttons')
|
|
1441
|
+
const buttonPrefixSlot = getFuncSlot(toolbarOptSlots, 'buttonPrefix')
|
|
1442
|
+
const buttonSuffixSlot = getFuncSlot(toolbarOptSlots, 'buttonSuffix')
|
|
1443
|
+
const toolsSlot = getFuncSlot(toolbarOptSlots, 'tools')
|
|
1444
|
+
const toolPrefixSlot = getFuncSlot(toolbarOptSlots, 'toolPrefix')
|
|
1445
|
+
const toolSuffixSlot = getFuncSlot(toolbarOptSlots, 'toolSuffix')
|
|
1446
|
+
if (buttonsSlot) {
|
|
1447
|
+
toolbarSlots.buttons = buttonsSlot
|
|
1448
|
+
}
|
|
1449
|
+
if (buttonPrefixSlot) {
|
|
1450
|
+
toolbarSlots.buttonPrefix = buttonPrefixSlot
|
|
1451
|
+
}
|
|
1452
|
+
if (buttonSuffixSlot) {
|
|
1453
|
+
toolbarSlots.buttonSuffix = buttonSuffixSlot
|
|
1454
|
+
}
|
|
1455
|
+
if (toolsSlot) {
|
|
1456
|
+
toolbarSlots.tools = toolsSlot
|
|
1457
|
+
}
|
|
1458
|
+
if (toolPrefixSlot) {
|
|
1459
|
+
toolbarSlots.toolPrefix = toolPrefixSlot
|
|
1460
|
+
}
|
|
1461
|
+
if (toolSuffixSlot) {
|
|
1462
|
+
toolbarSlots.toolSuffix = toolSuffixSlot
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
slotVNs.push(
|
|
1466
|
+
h(VxeToolbarComponent, {
|
|
1467
|
+
ref: refToolbar,
|
|
1468
|
+
...toolbarOpts,
|
|
1469
|
+
slots: undefined
|
|
1470
|
+
}, toolbarSlots)
|
|
1471
|
+
)
|
|
1472
|
+
}
|
|
1473
|
+
return h('div', {
|
|
1474
|
+
ref: refToolbarWrapper,
|
|
1475
|
+
key: 'toolbar',
|
|
1476
|
+
class: 'vxe-gantt--toolbar-wrapper'
|
|
1477
|
+
}, slotVNs)
|
|
1478
|
+
}
|
|
1479
|
+
return renderEmptyElement($xeGantt)
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
/**
|
|
1483
|
+
* 渲染表格顶部区域
|
|
1484
|
+
*/
|
|
1485
|
+
const renderTop = () => {
|
|
1486
|
+
const topSlot = slots.top
|
|
1487
|
+
if (topSlot) {
|
|
1488
|
+
return h('div', {
|
|
1489
|
+
ref: refTopWrapper,
|
|
1490
|
+
key: 'top',
|
|
1491
|
+
class: 'vxe-gantt--top-wrapper'
|
|
1492
|
+
}, topSlot({ $grid: null, $gantt: $xeGantt }))
|
|
1493
|
+
}
|
|
1494
|
+
return renderEmptyElement($xeGantt)
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
const renderTableLeft = () => {
|
|
1498
|
+
const leftSlot = slots.left
|
|
1499
|
+
if (leftSlot) {
|
|
1500
|
+
return h('div', {
|
|
1501
|
+
class: 'vxe-gantt--left-wrapper'
|
|
1502
|
+
}, leftSlot({ $grid: null, $gantt: $xeGantt }))
|
|
1503
|
+
}
|
|
1504
|
+
return renderEmptyElement($xeGantt)
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
const renderTableRight = () => {
|
|
1508
|
+
const rightSlot = slots.right
|
|
1509
|
+
if (rightSlot) {
|
|
1510
|
+
return h('div', {
|
|
1511
|
+
class: 'vxe-gantt--right-wrapper'
|
|
1512
|
+
}, rightSlot({ $grid: null, $gantt: $xeGantt }))
|
|
1513
|
+
}
|
|
1514
|
+
return renderEmptyElement($xeGantt)
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* 渲染表格
|
|
1519
|
+
*/
|
|
1520
|
+
const renderTable = () => {
|
|
1521
|
+
const { proxyConfig } = props
|
|
1522
|
+
const tableProps = computeTableProps.value
|
|
1523
|
+
const proxyOpts = computeProxyOpts.value
|
|
1524
|
+
const tableOns = Object.assign({}, tableCompEvents)
|
|
1525
|
+
const emptySlot = slots.empty
|
|
1526
|
+
const loadingSlot = slots.loading
|
|
1527
|
+
const rowDragIconSlot = slots.rowDragIcon || slots['row-drag-icon']
|
|
1528
|
+
const columnDragIconSlot = slots.columnDragIcon || slots['column-drag-icon']
|
|
1529
|
+
if (proxyConfig && isEnableConf(proxyOpts)) {
|
|
1530
|
+
if (proxyOpts.sort) {
|
|
1531
|
+
tableOns.onSortChange = sortChangeEvent
|
|
1532
|
+
tableOns.onClearAllSort = clearAllSortEvent
|
|
1533
|
+
}
|
|
1534
|
+
if (proxyOpts.filter) {
|
|
1535
|
+
tableOns.onFilterChange = filterChangeEvent
|
|
1536
|
+
tableOns.onClearAllFilter = clearAllFilterEvent
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
const slotObj: {
|
|
1540
|
+
empty?(params: any): any
|
|
1541
|
+
loading?(params: any): any
|
|
1542
|
+
rowDragIcon?(params: any): any
|
|
1543
|
+
columnDragIcon?(params: any): any
|
|
1544
|
+
} = {}
|
|
1545
|
+
if (emptySlot) {
|
|
1546
|
+
slotObj.empty = emptySlot
|
|
1547
|
+
}
|
|
1548
|
+
if (loadingSlot) {
|
|
1549
|
+
slotObj.loading = loadingSlot
|
|
1550
|
+
}
|
|
1551
|
+
if (rowDragIconSlot) {
|
|
1552
|
+
slotObj.rowDragIcon = rowDragIconSlot
|
|
1553
|
+
}
|
|
1554
|
+
if (columnDragIconSlot) {
|
|
1555
|
+
slotObj.columnDragIcon = columnDragIconSlot
|
|
1556
|
+
}
|
|
1557
|
+
return h('div', {
|
|
1558
|
+
ref: refTableWrapper,
|
|
1559
|
+
class: 'vxe-gantt--table-wrapper'
|
|
1560
|
+
}, [
|
|
1561
|
+
h(VxeTableComponent, {
|
|
1562
|
+
ref: refTable,
|
|
1563
|
+
...tableProps,
|
|
1564
|
+
...tableOns
|
|
1565
|
+
}, slotObj)
|
|
1566
|
+
])
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* 渲染表格底部区域
|
|
1571
|
+
*/
|
|
1572
|
+
const renderBottom = () => {
|
|
1573
|
+
if (slots.bottom) {
|
|
1574
|
+
return h('div', {
|
|
1575
|
+
ref: refBottomWrapper,
|
|
1576
|
+
key: 'bottom',
|
|
1577
|
+
class: 'vxe-gantt--bottom-wrapper'
|
|
1578
|
+
}, slots.bottom({ $grid: null, $gantt: $xeGantt }))
|
|
1579
|
+
}
|
|
1580
|
+
return renderEmptyElement($xeGantt)
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* 渲染分页
|
|
1585
|
+
*/
|
|
1586
|
+
const renderPager = () => {
|
|
1587
|
+
const { proxyConfig, pagerConfig } = props
|
|
1588
|
+
const proxyOpts = computeProxyOpts.value
|
|
1589
|
+
const pagerOpts = computePagerOpts.value
|
|
1590
|
+
const pagerSlot = slots.pager
|
|
1591
|
+
if ((pagerConfig && isEnableConf(pagerOpts)) || slots.pager) {
|
|
1592
|
+
return h('div', {
|
|
1593
|
+
ref: refPagerWrapper,
|
|
1594
|
+
key: 'pager',
|
|
1595
|
+
class: 'vxe-gantt--pager-wrapper'
|
|
1596
|
+
}, pagerSlot
|
|
1597
|
+
? pagerSlot({ $grid: null, $gantt: $xeGantt })
|
|
1598
|
+
: [
|
|
1599
|
+
VxeUIPagerComponent
|
|
1600
|
+
? h(VxeUIPagerComponent, {
|
|
1601
|
+
ref: refPager,
|
|
1602
|
+
...pagerOpts,
|
|
1603
|
+
...(proxyConfig && isEnableConf(proxyOpts) ? reactData.tablePage : {}),
|
|
1604
|
+
onPageChange: pageChangeEvent
|
|
1605
|
+
}, getConfigSlot(pagerOpts.slots))
|
|
1606
|
+
: renderEmptyElement($xeGantt)
|
|
1607
|
+
])
|
|
1608
|
+
}
|
|
1609
|
+
return renderEmptyElement($xeGantt)
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* 渲染任务视图
|
|
1614
|
+
*/
|
|
1615
|
+
const renderTaskView = () => {
|
|
1616
|
+
return h('div', {
|
|
1617
|
+
ref: refGanttWrapper,
|
|
1618
|
+
class: 'vxe-gantt--view-wrapper'
|
|
1619
|
+
}, [
|
|
1620
|
+
h(GanttViewComponent, {
|
|
1621
|
+
ref: refGanttView
|
|
1622
|
+
})
|
|
1623
|
+
])
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
const renderSplitBar = () => {
|
|
1627
|
+
const { showLeftView, showRightView } = reactData
|
|
1628
|
+
return h('div', {
|
|
1629
|
+
class: 'vxe-gantt--view-split-bar'
|
|
1630
|
+
}, [
|
|
1631
|
+
h('div', {
|
|
1632
|
+
class: 'vxe-gantt--view-split-bar-handle',
|
|
1633
|
+
onMousedown: dragSplitEvent
|
|
1634
|
+
}),
|
|
1635
|
+
h('div', {
|
|
1636
|
+
class: 'vxe-gantt--view-split-bar-btn-wrapper'
|
|
1637
|
+
}, [
|
|
1638
|
+
showRightView
|
|
1639
|
+
? h('div', {
|
|
1640
|
+
class: 'vxe-gantt--view-split-bar-left-btn',
|
|
1641
|
+
onClick: handleSplitLeftViewEvent
|
|
1642
|
+
}, [
|
|
1643
|
+
h('i', {
|
|
1644
|
+
class: showLeftView ? getIcon().GANTT_VIEW_LEFT_OPEN : getIcon().GANTT_VIEW_LEFT_CLOSE
|
|
1645
|
+
})
|
|
1646
|
+
])
|
|
1647
|
+
: renderEmptyElement($xeGantt),
|
|
1648
|
+
showLeftView
|
|
1649
|
+
? h('div', {
|
|
1650
|
+
class: 'vxe-gantt--view-split-bar-right-btn',
|
|
1651
|
+
onClick: handleSplitRightViewEvent
|
|
1652
|
+
}, [
|
|
1653
|
+
h('i', {
|
|
1654
|
+
class: showRightView ? getIcon().GANTT_VIEW_RIGHT_OPEN : getIcon().GANTT_VIEW_RIGHT_CLOSE
|
|
1655
|
+
})
|
|
1656
|
+
])
|
|
1657
|
+
: renderEmptyElement($xeGantt)
|
|
1658
|
+
])
|
|
1659
|
+
])
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
const renderChildLayout = (layoutKeys: VxeGanttDefines.LayoutKey[]) => {
|
|
1663
|
+
const childVNs: VNode[] = []
|
|
1664
|
+
layoutKeys.forEach(key => {
|
|
1665
|
+
switch (key) {
|
|
1666
|
+
case 'Form':
|
|
1667
|
+
childVNs.push(renderForm())
|
|
1668
|
+
break
|
|
1669
|
+
case 'Toolbar':
|
|
1670
|
+
childVNs.push(renderToolbar())
|
|
1671
|
+
break
|
|
1672
|
+
case 'Top':
|
|
1673
|
+
childVNs.push(renderTop())
|
|
1674
|
+
break
|
|
1675
|
+
case 'Gantt':
|
|
1676
|
+
childVNs.push(
|
|
1677
|
+
h('div', {
|
|
1678
|
+
ref: refGanttContainer,
|
|
1679
|
+
key: 'tv',
|
|
1680
|
+
class: 'vxe-gantt--gantt-container'
|
|
1681
|
+
}, [
|
|
1682
|
+
renderTableLeft(),
|
|
1683
|
+
renderTable(),
|
|
1684
|
+
renderSplitBar(),
|
|
1685
|
+
renderTaskView(),
|
|
1686
|
+
renderTableRight(),
|
|
1687
|
+
h('div', {
|
|
1688
|
+
ref: refResizableSplitTip,
|
|
1689
|
+
class: 'vxe-gantt--resizable-split-tip'
|
|
1690
|
+
}, [
|
|
1691
|
+
h('div', {
|
|
1692
|
+
class: 'vxe-gantt--resizable-split-tip-number'
|
|
1693
|
+
}, [
|
|
1694
|
+
h('div', {
|
|
1695
|
+
class: 'vxe-gantt--resizable-split-number-left'
|
|
1696
|
+
}, '10px'),
|
|
1697
|
+
h('div', {
|
|
1698
|
+
class: 'vxe-gantt--resizable-split-number-right'
|
|
1699
|
+
}, '20px')
|
|
1700
|
+
])
|
|
1701
|
+
])
|
|
1702
|
+
])
|
|
1703
|
+
)
|
|
1704
|
+
break
|
|
1705
|
+
case 'Bottom':
|
|
1706
|
+
childVNs.push(renderBottom())
|
|
1707
|
+
break
|
|
1708
|
+
case 'Pager':
|
|
1709
|
+
childVNs.push(renderPager())
|
|
1710
|
+
break
|
|
1711
|
+
default:
|
|
1712
|
+
errLog('vxe.error.notProp', [`layouts -> ${key}`])
|
|
1713
|
+
break
|
|
1714
|
+
}
|
|
1715
|
+
})
|
|
1716
|
+
return childVNs
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
const renderLayout = () => {
|
|
1720
|
+
const currLayoutConf = computeCurrLayoutConf.value
|
|
1721
|
+
const { headKeys, bodyKeys, footKeys } = currLayoutConf
|
|
1722
|
+
const asideLeftSlot = slots.asideLeft || slots['aside-left']
|
|
1723
|
+
const asideRightSlot = slots.asideRight || slots['aside-right']
|
|
1724
|
+
return [
|
|
1725
|
+
h('div', {
|
|
1726
|
+
class: 'vxe-gantt--layout-header-wrapper'
|
|
1727
|
+
}, renderChildLayout(headKeys)),
|
|
1728
|
+
h('div', {
|
|
1729
|
+
class: 'vxe-gantt--layout-body-wrapper'
|
|
1730
|
+
}, [
|
|
1731
|
+
asideLeftSlot
|
|
1732
|
+
? h('div', {
|
|
1733
|
+
class: 'vxe-gantt--layout-aside-left-wrapper'
|
|
1734
|
+
}, asideLeftSlot({}))
|
|
1735
|
+
: renderEmptyElement($xeGantt),
|
|
1736
|
+
h('div', {
|
|
1737
|
+
class: 'vxe-gantt--layout-body-content-wrapper'
|
|
1738
|
+
}, renderChildLayout(bodyKeys)),
|
|
1739
|
+
asideRightSlot
|
|
1740
|
+
? h('div', {
|
|
1741
|
+
class: 'vxe-gantt--layout-aside-right-wrapper'
|
|
1742
|
+
}, asideRightSlot({}))
|
|
1743
|
+
: renderEmptyElement($xeGantt)
|
|
1744
|
+
]),
|
|
1745
|
+
h('div', {
|
|
1746
|
+
class: 'vxe-gantt--layout-footer-wrapper'
|
|
1747
|
+
}, renderChildLayout(footKeys)),
|
|
1748
|
+
h('div', {
|
|
1749
|
+
class: 'vxe-gantt--border-line'
|
|
1750
|
+
})
|
|
1751
|
+
]
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
const renderVN = () => {
|
|
1755
|
+
const { showLeftView, showRightView } = reactData
|
|
1756
|
+
const vSize = computeSize.value
|
|
1757
|
+
const styles = computeStyles.value
|
|
1758
|
+
const isLoading = computeIsLoading.value
|
|
1759
|
+
const tableBorder = computeTableBorder.value
|
|
1760
|
+
const scrollbarXToTop = computeScrollbarXToTop.value
|
|
1761
|
+
const scrollbarYToLeft = computeScrollbarYToLeft.value
|
|
1762
|
+
return h('div', {
|
|
1763
|
+
ref: refElem,
|
|
1764
|
+
class: ['vxe-gantt', `border--${tableBorder}`, `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
|
|
1765
|
+
[`size--${vSize}`]: vSize,
|
|
1766
|
+
'is--round': props.round,
|
|
1767
|
+
'is--maximize': reactData.isZMax,
|
|
1768
|
+
'is--loading': isLoading,
|
|
1769
|
+
'show--left': showLeftView,
|
|
1770
|
+
'show--right': showRightView
|
|
1771
|
+
}],
|
|
1772
|
+
style: styles
|
|
1773
|
+
}, renderLayout())
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
const columnFlag = ref(0)
|
|
1777
|
+
watch(() => props.columns ? props.columns.length : -1, () => {
|
|
1778
|
+
columnFlag.value++
|
|
1779
|
+
})
|
|
1780
|
+
watch(() => props.columns, () => {
|
|
1781
|
+
columnFlag.value++
|
|
1782
|
+
})
|
|
1783
|
+
watch(columnFlag, () => {
|
|
1784
|
+
nextTick(() => $xeGantt.loadColumn(props.columns || []))
|
|
1785
|
+
})
|
|
1786
|
+
|
|
1787
|
+
watch(() => props.toolbarConfig, () => {
|
|
1788
|
+
initToolbar()
|
|
1789
|
+
})
|
|
1790
|
+
|
|
1791
|
+
watch(computeCustomCurrentPageFlag, () => {
|
|
1792
|
+
initPages('currentPage')
|
|
1793
|
+
})
|
|
1794
|
+
|
|
1795
|
+
watch(computeCustomPageSizeFlag, () => {
|
|
1796
|
+
initPages('pageSize')
|
|
1797
|
+
})
|
|
1798
|
+
|
|
1799
|
+
watch(computeCustomTotalFlag, () => {
|
|
1800
|
+
initPages('total')
|
|
1801
|
+
})
|
|
1802
|
+
|
|
1803
|
+
watch(() => props.proxyConfig, () => {
|
|
1804
|
+
initProxy()
|
|
1805
|
+
})
|
|
1806
|
+
|
|
1807
|
+
hooks.forEach((options) => {
|
|
1808
|
+
const { setupGantt } = options
|
|
1809
|
+
if (setupGantt) {
|
|
1810
|
+
const hookRest = setupGantt($xeGantt)
|
|
1811
|
+
if (hookRest && XEUtils.isObject(hookRest)) {
|
|
1812
|
+
Object.assign($xeGantt, hookRest)
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
})
|
|
1816
|
+
|
|
1817
|
+
initPages()
|
|
1818
|
+
|
|
1819
|
+
onMounted(() => {
|
|
1820
|
+
nextTick(() => {
|
|
1821
|
+
const { columns } = props
|
|
1822
|
+
const proxyOpts = computeProxyOpts.value
|
|
1823
|
+
|
|
1824
|
+
if (props.formConfig) {
|
|
1825
|
+
if (!VxeUIFormComponent) {
|
|
1826
|
+
errLog('vxe.error.reqComp', ['vxe-form'])
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
if (props.pagerConfig) {
|
|
1830
|
+
if (!VxeUIPagerComponent) {
|
|
1831
|
+
errLog('vxe.error.reqComp', ['vxe-pager'])
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
// const { data, columns, proxyConfig } = props
|
|
1836
|
+
// const formOpts = computeFormOpts.value
|
|
1837
|
+
// if (isEnableConf(proxyConfig) && (data || (proxyOpts.form && formOpts.data))) {
|
|
1838
|
+
// errLog('vxe.error.errConflicts', ['grid.data', 'grid.proxy-config'])
|
|
1839
|
+
// }
|
|
1840
|
+
|
|
1841
|
+
if (proxyOpts.props) {
|
|
1842
|
+
warnLog('vxe.error.delProp', ['proxy-config.props', 'proxy-config.response'])
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
if (columns && columns.length) {
|
|
1846
|
+
$xeGantt.loadColumn(columns)
|
|
1847
|
+
}
|
|
1848
|
+
initToolbar()
|
|
1849
|
+
initProxy()
|
|
1850
|
+
})
|
|
1851
|
+
initGanttView()
|
|
1852
|
+
globalEvents.on($xeGantt, 'keydown', handleGlobalKeydownEvent)
|
|
1853
|
+
})
|
|
1854
|
+
|
|
1855
|
+
onUnmounted(() => {
|
|
1856
|
+
globalEvents.off($xeGantt, 'keydown')
|
|
1857
|
+
XEUtils.assign(internalData, createInternalData())
|
|
1858
|
+
})
|
|
1859
|
+
|
|
1860
|
+
$xeGantt.renderVN = renderVN
|
|
1861
|
+
|
|
1862
|
+
provide('$xeGantt', $xeGantt)
|
|
1863
|
+
|
|
1864
|
+
return $xeGantt
|
|
1865
|
+
},
|
|
1866
|
+
render () {
|
|
1867
|
+
return this.renderVN()
|
|
1868
|
+
}
|
|
1869
|
+
})
|