vxe-table 3.7.0-beta.9 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/helper/vetur/attributes.json +26 -2
- package/helper/vetur/tags.json +6 -0
- package/lib/button/style/style.css +2 -3
- package/lib/button/style/style.min.css +1 -1
- package/lib/edit/src/mixin.js +265 -214
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/export/src/mixin.js +11 -7
- package/lib/export/src/mixin.min.js +1 -1
- package/lib/form/src/form-config-item.js +5 -1
- package/lib/form/src/form-config-item.min.js +1 -1
- package/lib/form/src/form-item.js +9 -1
- package/lib/form/src/form-item.min.js +1 -1
- package/lib/form/src/form.js +4 -0
- package/lib/form/src/form.min.js +1 -1
- package/lib/form/style/style.css +12 -0
- package/lib/form/style/style.min.css +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.umd.js +1151 -716
- package/lib/index.umd.min.js +1 -1
- package/lib/input/src/input.js +24 -1
- package/lib/input/src/input.min.js +1 -1
- package/lib/input/style/style.css +21 -0
- package/lib/input/style/style.min.css +1 -1
- package/lib/keyboard/src/mixin.js +4 -1
- package/lib/keyboard/src/mixin.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/src/body.js +17 -14
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +38 -34
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/methods.js +641 -421
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +27 -19
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +4 -2
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +2 -2
- package/lib/table/style/style.min.css +1 -1
- package/lib/tools/log.js +1 -1
- package/lib/tools/log.min.js +1 -1
- package/lib/tools/utils.js +3 -5
- package/lib/tools/utils.min.js +1 -1
- package/lib/v-x-e-table/index.js +15 -12
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/v-x-e-table/src/commands.js +7 -7
- package/lib/v-x-e-table/src/commands.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +2 -2
- package/lib/v-x-e-table/src/conf.min.js +1 -1
- package/lib/v-x-e-table/src/{setup.js → config.js} +3 -3
- package/lib/v-x-e-table/src/config.min.js +1 -0
- package/lib/v-x-e-table/src/formats.js +7 -7
- package/lib/v-x-e-table/src/formats.min.js +1 -1
- package/lib/v-x-e-table/src/menus.js +7 -7
- package/lib/v-x-e-table/src/menus.min.js +1 -1
- package/lib/v-x-e-table/src/renderer.js +4 -4
- package/lib/v-x-e-table/src/renderer.min.js +1 -1
- package/lib/validator/src/mixin.js +4 -1
- package/lib/validator/src/mixin.min.js +1 -1
- package/package.json +7 -8
- package/packages/edit/src/mixin.js +185 -142
- package/packages/export/src/mixin.js +9 -7
- package/packages/form/src/form-config-item.js +4 -2
- package/packages/form/src/form-item.js +8 -2
- package/packages/form/src/form.js +4 -0
- package/packages/input/src/input.js +24 -1
- package/packages/keyboard/src/mixin.js +2 -1
- package/packages/table/src/body.js +17 -14
- package/packages/table/src/cell.js +32 -23
- package/packages/table/src/methods.js +476 -230
- package/packages/table/src/table.js +25 -17
- package/packages/table/src/util.js +4 -2
- package/packages/tools/utils.js +3 -6
- package/packages/v-x-e-table/index.js +7 -4
- package/packages/v-x-e-table/src/commands.js +6 -6
- package/packages/v-x-e-table/src/conf.js +2 -2
- package/packages/v-x-e-table/src/{setup.js → config.js} +2 -2
- package/packages/v-x-e-table/src/formats.js +6 -6
- package/packages/v-x-e-table/src/menus.js +6 -6
- package/packages/v-x-e-table/src/renderer.js +4 -4
- package/packages/validator/src/mixin.js +2 -1
- package/styles/button.scss +5 -3
- package/styles/css-variable.scss +3 -3
- package/styles/form.scss +14 -0
- package/styles/input.scss +25 -0
- package/styles/table.scss +6 -2
- package/styles/textarea.scss +3 -3
- package/styles/variable.scss +3 -3
- package/types/form-item.d.ts +1 -0
- package/types/form.d.ts +1 -0
- package/types/table.d.ts +16 -1
- package/types/v-x-e-table/index.d.ts +22 -10
- package/lib/v-x-e-table/src/setup.min.js +0 -1
- /package/lib/icon/style/{iconfont.1690761747506.ttf → iconfont.1694737793729.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1690761747506.woff → iconfont.1694737793729.woff} +0 -0
- /package/lib/icon/style/{iconfont.1690761747506.woff2 → iconfont.1694737793729.woff2} +0 -0
- /package/lib/{iconfont.1690761747506.ttf → iconfont.1694737793729.ttf} +0 -0
- /package/lib/{iconfont.1690761747506.woff → iconfont.1694737793729.woff} +0 -0
- /package/lib/{iconfont.1690761747506.woff2 → iconfont.1694737793729.woff2} +0 -0
- /package/types/v-x-e-table/{setup.d.ts → config.d.ts} +0 -0
|
@@ -7,7 +7,8 @@ import { warnLog, errLog, getLog } from '../../tools/log'
|
|
|
7
7
|
|
|
8
8
|
function insertTreeRow (_vm, newRecords, isAppend) {
|
|
9
9
|
const { tableFullTreeData, afterFullData, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm
|
|
10
|
-
const { rowField, parentField,
|
|
10
|
+
const { rowField, parentField, mapChildrenField } = treeOpts
|
|
11
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
11
12
|
const funcName = isAppend ? 'push' : 'unshift'
|
|
12
13
|
newRecords.forEach(item => {
|
|
13
14
|
const parentRowId = item[parentField]
|
|
@@ -17,11 +18,16 @@ function insertTreeRow (_vm, newRecords, isAppend) {
|
|
|
17
18
|
const { item: parentRow } = matchObj
|
|
18
19
|
const parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)]
|
|
19
20
|
const parentLevel = parentRest ? parentRest.level : 0
|
|
20
|
-
let parentChilds = parentRow[childrenField
|
|
21
|
+
let parentChilds = parentRow[childrenField]
|
|
22
|
+
let mapChilds = parentRow[mapChildrenField]
|
|
21
23
|
if (!XEUtils.isArray(parentChilds)) {
|
|
22
|
-
parentChilds = parentRow[childrenField
|
|
24
|
+
parentChilds = parentRow[childrenField] = []
|
|
25
|
+
}
|
|
26
|
+
if (!XEUtils.isArray(mapChilds)) {
|
|
27
|
+
mapChilds = parentRow[childrenField] = []
|
|
23
28
|
}
|
|
24
29
|
parentChilds[funcName](item)
|
|
30
|
+
mapChilds[funcName](item)
|
|
25
31
|
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
|
|
26
32
|
fullDataRowIdData[rowid] = rest
|
|
27
33
|
fullAllDataRowIdData[rowid] = rest
|
|
@@ -40,6 +46,156 @@ function insertTreeRow (_vm, newRecords, isAppend) {
|
|
|
40
46
|
})
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
function handleInsertRowAt (_vm, records, row, isInsertNextRow) {
|
|
50
|
+
const { tableFullTreeData, mergeList, afterFullData, editStore, tableFullData, treeConfig, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm
|
|
51
|
+
const { transform, rowField, mapChildrenField } = treeOpts
|
|
52
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
53
|
+
if (!XEUtils.isArray(records)) {
|
|
54
|
+
records = [records]
|
|
55
|
+
}
|
|
56
|
+
const newRecords = _vm.defineField(records.map(record => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record)))
|
|
57
|
+
if (!row) {
|
|
58
|
+
// 如果为虚拟树
|
|
59
|
+
if (treeConfig && transform) {
|
|
60
|
+
insertTreeRow(_vm, newRecords, false)
|
|
61
|
+
} else {
|
|
62
|
+
afterFullData.unshift(...newRecords)
|
|
63
|
+
tableFullData.unshift(...newRecords)
|
|
64
|
+
// 刷新单元格合并
|
|
65
|
+
mergeList.forEach(mergeItem => {
|
|
66
|
+
const { row: mergeRowIndex } = mergeItem
|
|
67
|
+
if (mergeRowIndex > 0) {
|
|
68
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
if (row === -1) {
|
|
74
|
+
// 如果为虚拟树
|
|
75
|
+
if (treeConfig && transform) {
|
|
76
|
+
insertTreeRow(_vm, newRecords, true)
|
|
77
|
+
} else {
|
|
78
|
+
afterFullData.push(...newRecords)
|
|
79
|
+
tableFullData.push(...newRecords)
|
|
80
|
+
// 刷新单元格合并
|
|
81
|
+
mergeList.forEach(mergeItem => {
|
|
82
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
83
|
+
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
84
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// 如果为虚拟树
|
|
90
|
+
if (treeConfig && transform) {
|
|
91
|
+
const matchMapObj = XEUtils.findTree(tableFullTreeData, item => row[rowField] === item[rowField], { children: mapChildrenField })
|
|
92
|
+
if (matchMapObj) {
|
|
93
|
+
const { parent: parentRow } = matchMapObj
|
|
94
|
+
const parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData
|
|
95
|
+
const parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)]
|
|
96
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
97
|
+
newRecords.forEach((item, i) => {
|
|
98
|
+
const rowid = getRowid(_vm, item)
|
|
99
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
100
|
+
if (item[treeOpts.parentField]) {
|
|
101
|
+
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
|
|
102
|
+
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`])
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (parentRow) {
|
|
107
|
+
item[treeOpts.parentField] = parentRow[rowField]
|
|
108
|
+
}
|
|
109
|
+
let targetIndex = matchMapObj.index + i
|
|
110
|
+
if (isInsertNextRow) {
|
|
111
|
+
targetIndex = targetIndex + 1
|
|
112
|
+
}
|
|
113
|
+
parentMapChilds.splice(targetIndex, 0, item)
|
|
114
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1 }
|
|
115
|
+
fullDataRowIdData[rowid] = rest
|
|
116
|
+
fullAllDataRowIdData[rowid] = rest
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
// 源
|
|
120
|
+
if (parentRow) {
|
|
121
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, item => row[rowField] === item[rowField], { children: childrenField })
|
|
122
|
+
if (matchObj) {
|
|
123
|
+
const parentChilds = matchObj.items
|
|
124
|
+
let targetIndex = matchObj.index
|
|
125
|
+
if (isInsertNextRow) {
|
|
126
|
+
targetIndex = targetIndex + 1
|
|
127
|
+
}
|
|
128
|
+
parentChilds.splice(targetIndex, 0, ...newRecords)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
133
|
+
warnLog('vxe.error.unableInsert')
|
|
134
|
+
}
|
|
135
|
+
insertTreeRow(_vm, newRecords, true)
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
if (treeConfig) {
|
|
139
|
+
throw new Error(getLog('vxe.error.noTree', ['insert']))
|
|
140
|
+
}
|
|
141
|
+
let afIndex = -1
|
|
142
|
+
// 如果是可视索引
|
|
143
|
+
if (XEUtils.isNumber(row)) {
|
|
144
|
+
if (row < afterFullData.length) {
|
|
145
|
+
afIndex = row
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
afIndex = _vm.findRowIndexOf(afterFullData, row)
|
|
149
|
+
}
|
|
150
|
+
// 如果是插入指定行的下一行
|
|
151
|
+
if (isInsertNextRow) {
|
|
152
|
+
afIndex = Math.max(afterFullData.length, afIndex + 1)
|
|
153
|
+
}
|
|
154
|
+
if (afIndex === -1) {
|
|
155
|
+
throw new Error(errLog('vxe.error.unableInsert'))
|
|
156
|
+
}
|
|
157
|
+
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
158
|
+
tableFullData.splice(_vm.findRowIndexOf(tableFullData, row), 0, ...newRecords)
|
|
159
|
+
// 刷新单元格合并
|
|
160
|
+
mergeList.forEach(mergeItem => {
|
|
161
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
162
|
+
if (mergeRowIndex > afIndex) {
|
|
163
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
164
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
165
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const { insertList, insertMaps } = editStore
|
|
172
|
+
newRecords.forEach(newRow => {
|
|
173
|
+
const rowid = getRowid(_vm, newRow)
|
|
174
|
+
insertMaps[rowid] = newRow
|
|
175
|
+
})
|
|
176
|
+
insertList.unshift(...newRecords)
|
|
177
|
+
_vm.cacheRowMap()
|
|
178
|
+
_vm.updateScrollYStatus()
|
|
179
|
+
_vm.handleTableData(treeConfig && transform)
|
|
180
|
+
if (!(treeConfig && transform)) {
|
|
181
|
+
_vm.updateAfterDataIndex()
|
|
182
|
+
}
|
|
183
|
+
_vm.updateFooter()
|
|
184
|
+
_vm.checkSelectionStatus()
|
|
185
|
+
if (_vm.scrollYLoad) {
|
|
186
|
+
_vm.updateScrollYSpace()
|
|
187
|
+
}
|
|
188
|
+
return _vm.$nextTick().then(() => {
|
|
189
|
+
_vm.updateCellAreas()
|
|
190
|
+
return _vm.recalculate()
|
|
191
|
+
}).then(() => {
|
|
192
|
+
return {
|
|
193
|
+
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
194
|
+
rows: newRecords
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
|
|
43
199
|
export default {
|
|
44
200
|
methods: {
|
|
45
201
|
/**
|
|
@@ -48,7 +204,7 @@ export default {
|
|
|
48
204
|
* @param {*} records
|
|
49
205
|
*/
|
|
50
206
|
_insert (records) {
|
|
51
|
-
return this
|
|
207
|
+
return handleInsertRowAt(this, records, null)
|
|
52
208
|
},
|
|
53
209
|
/**
|
|
54
210
|
* 往表格指定行中插入临时数据
|
|
@@ -57,133 +213,13 @@ export default {
|
|
|
57
213
|
* 如果 row 为有效行则插入到该行的位置
|
|
58
214
|
* @param {Object/Array} records 新的数据
|
|
59
215
|
* @param {Row} row 指定行
|
|
216
|
+
* @returns
|
|
60
217
|
*/
|
|
61
218
|
_insertAt (records, row) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
const newRecords = this.defineField(records.map(record => Object.assign({}, record)))
|
|
68
|
-
if (!row) {
|
|
69
|
-
// 如果为虚拟树
|
|
70
|
-
if (treeConfig && transform) {
|
|
71
|
-
insertTreeRow(this, newRecords, false)
|
|
72
|
-
} else {
|
|
73
|
-
afterFullData.unshift(...newRecords)
|
|
74
|
-
tableFullData.unshift(...newRecords)
|
|
75
|
-
// 刷新单元格合并
|
|
76
|
-
mergeList.forEach(mergeItem => {
|
|
77
|
-
const { row: mergeRowIndex } = mergeItem
|
|
78
|
-
if (mergeRowIndex > 0) {
|
|
79
|
-
mergeItem.row = mergeRowIndex + newRecords.length
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
if (row === -1) {
|
|
85
|
-
// 如果为虚拟树
|
|
86
|
-
if (treeConfig && transform) {
|
|
87
|
-
insertTreeRow(this, newRecords, true)
|
|
88
|
-
} else {
|
|
89
|
-
afterFullData.push(...newRecords)
|
|
90
|
-
tableFullData.push(...newRecords)
|
|
91
|
-
// 刷新单元格合并
|
|
92
|
-
mergeList.forEach(mergeItem => {
|
|
93
|
-
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
94
|
-
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
95
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
// 如果为虚拟树
|
|
101
|
-
if (treeConfig && transform) {
|
|
102
|
-
const matchObj = XEUtils.findTree(tableFullTreeData, item => row[rowField] === item[rowField], { children: mapChildrenField })
|
|
103
|
-
if (matchObj) {
|
|
104
|
-
const { parent: parentRow } = matchObj
|
|
105
|
-
const parentChilds = matchObj.items
|
|
106
|
-
const parentRest = fullAllDataRowIdData[getRowid(this, parentRow)]
|
|
107
|
-
const parentLevel = parentRest ? parentRest.level : 0
|
|
108
|
-
newRecords.forEach((item, i) => {
|
|
109
|
-
const rowid = getRowid(this, item)
|
|
110
|
-
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
111
|
-
if (item[treeOpts.parentField]) {
|
|
112
|
-
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
|
|
113
|
-
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`])
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (parentRow) {
|
|
118
|
-
item[treeOpts.parentField] = parentRow[rowField]
|
|
119
|
-
}
|
|
120
|
-
parentChilds.splice(matchObj.index + i, 0, item)
|
|
121
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1 }
|
|
122
|
-
fullDataRowIdData[rowid] = rest
|
|
123
|
-
fullAllDataRowIdData[rowid] = rest
|
|
124
|
-
})
|
|
125
|
-
} else {
|
|
126
|
-
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
127
|
-
warnLog('vxe.error.unableInsert')
|
|
128
|
-
}
|
|
129
|
-
insertTreeRow(this, newRecords, true)
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
if (treeConfig) {
|
|
133
|
-
throw new Error(getLog('vxe.error.noTree', ['insert']))
|
|
134
|
-
}
|
|
135
|
-
let afIndex = -1
|
|
136
|
-
// 如果是可视索引
|
|
137
|
-
if (XEUtils.isNumber(row)) {
|
|
138
|
-
if (row < afterFullData.length) {
|
|
139
|
-
afIndex = row
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
afIndex = this.findRowIndexOf(afterFullData, row)
|
|
143
|
-
}
|
|
144
|
-
if (afIndex === -1) {
|
|
145
|
-
throw new Error(errLog('vxe.error.unableInsert'))
|
|
146
|
-
}
|
|
147
|
-
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
148
|
-
tableFullData.splice(this.findRowIndexOf(tableFullData, row), 0, ...newRecords)
|
|
149
|
-
// 刷新单元格合并
|
|
150
|
-
mergeList.forEach(mergeItem => {
|
|
151
|
-
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
152
|
-
if (mergeRowIndex > afIndex) {
|
|
153
|
-
mergeItem.row = mergeRowIndex + newRecords.length
|
|
154
|
-
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
155
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const { insertList, insertMaps } = editStore
|
|
162
|
-
newRecords.forEach(newRow => {
|
|
163
|
-
const rowid = getRowid(this, newRow)
|
|
164
|
-
insertMaps[rowid] = newRow
|
|
165
|
-
})
|
|
166
|
-
insertList.unshift(...newRecords)
|
|
167
|
-
this.cacheRowMap()
|
|
168
|
-
this.updateScrollYStatus()
|
|
169
|
-
this.handleTableData(treeConfig && transform)
|
|
170
|
-
if (!(treeConfig && transform)) {
|
|
171
|
-
this.updateAfterDataIndex()
|
|
172
|
-
}
|
|
173
|
-
this.updateFooter()
|
|
174
|
-
this.checkSelectionStatus()
|
|
175
|
-
if (this.scrollYLoad) {
|
|
176
|
-
this.updateScrollYSpace()
|
|
177
|
-
}
|
|
178
|
-
return this.$nextTick().then(() => {
|
|
179
|
-
this.updateCellAreas()
|
|
180
|
-
return this.recalculate()
|
|
181
|
-
}).then(() => {
|
|
182
|
-
return {
|
|
183
|
-
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
184
|
-
rows: newRecords
|
|
185
|
-
}
|
|
186
|
-
})
|
|
219
|
+
return handleInsertRowAt(this, records, row)
|
|
220
|
+
},
|
|
221
|
+
_insertNextAt (records, row) {
|
|
222
|
+
return handleInsertRowAt(this, records, row, true)
|
|
187
223
|
},
|
|
188
224
|
/**
|
|
189
225
|
* 删除指定行数据
|
|
@@ -192,11 +228,12 @@ export default {
|
|
|
192
228
|
* 如果为空则删除所有
|
|
193
229
|
*/
|
|
194
230
|
_remove (rows) {
|
|
195
|
-
const { afterFullData, tableFullData, tableFullTreeData, treeConfig, mergeList, editStore, checkboxOpts,
|
|
196
|
-
const { transform } = treeOpts
|
|
231
|
+
const { afterFullData, tableFullData, tableFullTreeData, treeConfig, mergeList, editStore, checkboxOpts, selectCheckboxMaps, isInsertByRow, treeOpts } = this
|
|
232
|
+
const { transform, mapChildrenField } = treeOpts
|
|
233
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
197
234
|
const { actived, removeList, insertList, insertMaps } = editStore
|
|
198
235
|
const { checkField } = checkboxOpts
|
|
199
|
-
let
|
|
236
|
+
let delList = []
|
|
200
237
|
if (!rows) {
|
|
201
238
|
rows = tableFullData
|
|
202
239
|
} else if (!XEUtils.isArray(rows)) {
|
|
@@ -210,16 +247,18 @@ export default {
|
|
|
210
247
|
})
|
|
211
248
|
// 如果绑定了多选属性,则更新状态
|
|
212
249
|
if (!checkField) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
250
|
+
const selectRowMaps = { ...selectCheckboxMaps }
|
|
251
|
+
rows.forEach((row) => {
|
|
252
|
+
const rowid = getRowid(this, row)
|
|
253
|
+
if (selectRowMaps[rowid]) {
|
|
254
|
+
delete selectRowMaps[rowid]
|
|
217
255
|
}
|
|
218
256
|
})
|
|
257
|
+
this.selectCheckboxMaps = selectRowMaps
|
|
219
258
|
}
|
|
220
259
|
// 从数据源中移除
|
|
221
260
|
if (tableFullData === rows) {
|
|
222
|
-
rows =
|
|
261
|
+
rows = delList = tableFullData.slice(0)
|
|
223
262
|
this.tableFullData = []
|
|
224
263
|
this.afterFullData = []
|
|
225
264
|
this.clearMergeCells()
|
|
@@ -228,10 +267,14 @@ export default {
|
|
|
228
267
|
if (treeConfig && transform) {
|
|
229
268
|
rows.forEach((row) => {
|
|
230
269
|
const rowid = getRowid(this, row)
|
|
231
|
-
const
|
|
270
|
+
const matchMapObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid(this, item), { children: mapChildrenField })
|
|
271
|
+
if (matchMapObj) {
|
|
272
|
+
const rItems = matchMapObj.items.splice(matchMapObj.index, 1)
|
|
273
|
+
delList.push(rItems[0])
|
|
274
|
+
}
|
|
275
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid(this, item), { children: childrenField })
|
|
232
276
|
if (matchObj) {
|
|
233
|
-
|
|
234
|
-
rest.push(rItems[0])
|
|
277
|
+
matchObj.items.splice(matchObj.index, 1)
|
|
235
278
|
}
|
|
236
279
|
const afIndex = this.findRowIndexOf(afterFullData, row)
|
|
237
280
|
if (afIndex > -1) {
|
|
@@ -243,7 +286,7 @@ export default {
|
|
|
243
286
|
const tfIndex = this.findRowIndexOf(tableFullData, row)
|
|
244
287
|
if (tfIndex > -1) {
|
|
245
288
|
const rItems = tableFullData.splice(tfIndex, 1)
|
|
246
|
-
|
|
289
|
+
delList.push(rItems[0])
|
|
247
290
|
}
|
|
248
291
|
const afIndex = this.findRowIndexOf(afterFullData, row)
|
|
249
292
|
if (afIndex > -1) {
|
|
@@ -288,7 +331,7 @@ export default {
|
|
|
288
331
|
this.updateCellAreas()
|
|
289
332
|
return this.recalculate()
|
|
290
333
|
}).then(() => {
|
|
291
|
-
return { row:
|
|
334
|
+
return { row: delList.length ? delList[delList.length - 1] : null, rows: delList }
|
|
292
335
|
})
|
|
293
336
|
},
|
|
294
337
|
/**
|
|
@@ -38,7 +38,8 @@ function getExportBlobByContent (content, options) {
|
|
|
38
38
|
|
|
39
39
|
function hasTreeChildren ($xetable, row) {
|
|
40
40
|
const treeOpts = $xetable.treeOpts
|
|
41
|
-
|
|
41
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
42
|
+
return row[childrenField] && row[childrenField].length > 0
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function getSeq ($xetable, row, $rowIndex, column, $columnIndex) {
|
|
@@ -78,6 +79,7 @@ function toBooleanValue (cellValue) {
|
|
|
78
79
|
function getLabelData ($xetable, opts, columns, datas) {
|
|
79
80
|
const { isAllExpand, mode } = opts
|
|
80
81
|
const { treeConfig, treeOpts, radioOpts, checkboxOpts, columnOpts } = $xetable
|
|
82
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
81
83
|
if (!htmlCellElem) {
|
|
82
84
|
htmlCellElem = document.createElement('div')
|
|
83
85
|
}
|
|
@@ -148,7 +150,7 @@ function getLabelData ($xetable, opts, columns, datas) {
|
|
|
148
150
|
expandMaps.set(row, 1)
|
|
149
151
|
rest.push(Object.assign(item, row))
|
|
150
152
|
}
|
|
151
|
-
},
|
|
153
|
+
}, { children: childrenField })
|
|
152
154
|
return rest
|
|
153
155
|
}
|
|
154
156
|
return datas.map((row, $rowIndex) => {
|
|
@@ -856,7 +858,7 @@ function handleFileImport ($xetable, file, opts) {
|
|
|
856
858
|
const { type, filename } = UtilTools.parseFile(file)
|
|
857
859
|
|
|
858
860
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
859
|
-
if (!importMethod && !XEUtils.includes(VXETable.
|
|
861
|
+
if (!importMethod && !XEUtils.includes(VXETable.globalConfs.importTypes, type)) {
|
|
860
862
|
if (opts.message !== false) {
|
|
861
863
|
// 检测弹窗模块
|
|
862
864
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
@@ -1040,7 +1042,7 @@ function handleExportAndPrint ($xetable, options, isPrint) {
|
|
|
1040
1042
|
const hasTree = treeConfig
|
|
1041
1043
|
const hasMerge = !hasTree && mergeList.length
|
|
1042
1044
|
const defOpts = Object.assign({ message: true, isHeader: true }, options)
|
|
1043
|
-
const types = defOpts.types || VXETable.
|
|
1045
|
+
const types = defOpts.types || VXETable.globalConfs.exportTypes
|
|
1044
1046
|
const modes = defOpts.modes
|
|
1045
1047
|
const checkMethod = customOpts.checkMethod
|
|
1046
1048
|
const exportColumns = collectColumn.slice(0)
|
|
@@ -1272,7 +1274,7 @@ export default {
|
|
|
1272
1274
|
}
|
|
1273
1275
|
|
|
1274
1276
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1275
|
-
if (!opts.exportMethod && !XEUtils.includes(VXETable.
|
|
1277
|
+
if (!opts.exportMethod && !XEUtils.includes(VXETable.globalConfs.exportTypes, type)) {
|
|
1276
1278
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
1277
1279
|
errLog('vxe.error.notType', [type])
|
|
1278
1280
|
}
|
|
@@ -1347,7 +1349,7 @@ export default {
|
|
|
1347
1349
|
},
|
|
1348
1350
|
_importData (options) {
|
|
1349
1351
|
const opts = Object.assign({
|
|
1350
|
-
types: VXETable.
|
|
1352
|
+
types: VXETable.globalConfs.importTypes
|
|
1351
1353
|
// beforeImportMethod: null,
|
|
1352
1354
|
// afterImportMethod: null
|
|
1353
1355
|
}, this.importOpts, options)
|
|
@@ -1397,7 +1399,7 @@ export default {
|
|
|
1397
1399
|
})
|
|
1398
1400
|
},
|
|
1399
1401
|
_openImport (options) {
|
|
1400
|
-
const defOpts = Object.assign({ mode: 'insert', message: true, types: VXETable.
|
|
1402
|
+
const defOpts = Object.assign({ mode: 'insert', message: true, types: VXETable.globalConfs.importTypes }, options, this.importOpts)
|
|
1401
1403
|
const { types } = defOpts
|
|
1402
1404
|
const isTree = !!this.getTreeStatus()
|
|
1403
1405
|
if (isTree) {
|
|
@@ -27,8 +27,8 @@ const VxeFormConfigItem = {
|
|
|
27
27
|
},
|
|
28
28
|
render (h) {
|
|
29
29
|
const { _e, $xeform, itemConfig: item } = this
|
|
30
|
-
const { rules, data, collapseAll, validOpts, titleAlign: allTitleAlign, titleWidth: allTitleWidth, titleColon: allTitleColon, titleAsterisk: allTitleAsterisk, titleOverflow: allTitleOverflow } = $xeform
|
|
31
|
-
const { slots, title, folding, visible, field, collapseNode, itemRender, showError, errRule, className, titleOverflow, children, showTitle, contentClassName, contentStyle, titleClassName, titleStyle } = item
|
|
30
|
+
const { rules, data, collapseAll, validOpts, titleAlign: allTitleAlign, titleWidth: allTitleWidth, titleColon: allTitleColon, titleAsterisk: allTitleAsterisk, titleOverflow: allTitleOverflow, vertical: allVertical } = $xeform
|
|
31
|
+
const { slots, title, folding, visible, field, collapseNode, itemRender, showError, errRule, className, titleOverflow, vertical, children, showTitle, contentClassName, contentStyle, titleClassName, titleStyle } = item
|
|
32
32
|
const compConf = isEnableConf(itemRender) ? VXETable.renderer.get(itemRender.name) : null
|
|
33
33
|
const itemClassName = compConf ? compConf.itemClassName : ''
|
|
34
34
|
const itemStyle = compConf ? compConf.itemStyle : null
|
|
@@ -43,6 +43,7 @@ const VxeFormConfigItem = {
|
|
|
43
43
|
const titleColon = XEUtils.eqNull(item.titleColon) ? allTitleColon : item.titleColon
|
|
44
44
|
const titleAsterisk = XEUtils.eqNull(item.titleAsterisk) ? allTitleAsterisk : item.titleAsterisk
|
|
45
45
|
const itemOverflow = (XEUtils.isUndefined(titleOverflow) || XEUtils.isNull(titleOverflow)) ? allTitleOverflow : titleOverflow
|
|
46
|
+
const itemVertical = (XEUtils.isUndefined(vertical) || XEUtils.isNull(vertical)) ? allVertical : vertical
|
|
46
47
|
const ovEllipsis = itemOverflow === 'ellipsis'
|
|
47
48
|
const ovTitle = itemOverflow === 'title'
|
|
48
49
|
const ovTooltip = itemOverflow === true || itemOverflow === 'tooltip'
|
|
@@ -99,6 +100,7 @@ const VxeFormConfigItem = {
|
|
|
99
100
|
{
|
|
100
101
|
'is--title': title,
|
|
101
102
|
'is--colon': titleColon,
|
|
103
|
+
'is--vertical': itemVertical,
|
|
102
104
|
'is--asterisk': titleAsterisk,
|
|
103
105
|
'is--required': isRequired,
|
|
104
106
|
'is--hidden': folding && collapseAll,
|
|
@@ -32,6 +32,10 @@ const props = {
|
|
|
32
32
|
type: Boolean,
|
|
33
33
|
default: true
|
|
34
34
|
},
|
|
35
|
+
vertical: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: null
|
|
38
|
+
},
|
|
35
39
|
className: [String, Function],
|
|
36
40
|
contentClassName: [String, Function],
|
|
37
41
|
contentStyle: [Object, Function],
|
|
@@ -59,8 +63,8 @@ Object.keys(props).forEach(name => {
|
|
|
59
63
|
})
|
|
60
64
|
|
|
61
65
|
const renderItem = (h, _vm, item, slots) => {
|
|
62
|
-
const { _e, rules, data, collapseAll, validOpts, titleAlign: allTitleAlign, titleWidth: allTitleWidth, titleColon: allTitleColon, titleAsterisk: allTitleAsterisk, titleOverflow: allTitleOverflow } = _vm
|
|
63
|
-
const { title, folding, visible, field, collapseNode, itemRender, showError, errRule, className, titleOverflow, showTitle, contentClassName, contentStyle, titleClassName, titleStyle } = item
|
|
66
|
+
const { _e, rules, data, collapseAll, validOpts, titleAlign: allTitleAlign, titleWidth: allTitleWidth, titleColon: allTitleColon, titleAsterisk: allTitleAsterisk, titleOverflow: allTitleOverflow, vertical: allVertical } = _vm
|
|
67
|
+
const { title, folding, visible, field, collapseNode, itemRender, showError, errRule, className, titleOverflow, vertical, showTitle, contentClassName, contentStyle, titleClassName, titleStyle } = item
|
|
64
68
|
const compConf = isEnableConf(itemRender) ? VXETable.renderer.get(itemRender.name) : null
|
|
65
69
|
const itemClassName = compConf ? compConf.itemClassName : ''
|
|
66
70
|
const itemStyle = compConf ? compConf.itemStyle : null
|
|
@@ -75,6 +79,7 @@ const renderItem = (h, _vm, item, slots) => {
|
|
|
75
79
|
const titleColon = XEUtils.eqNull(item.titleColon) ? allTitleColon : item.titleColon
|
|
76
80
|
const titleAsterisk = XEUtils.eqNull(item.titleAsterisk) ? allTitleAsterisk : item.titleAsterisk
|
|
77
81
|
const itemOverflow = (XEUtils.isUndefined(titleOverflow) || XEUtils.isNull(titleOverflow)) ? allTitleOverflow : titleOverflow
|
|
82
|
+
const itemVertical = (XEUtils.isUndefined(vertical) || XEUtils.isNull(vertical)) ? allVertical : vertical
|
|
78
83
|
const ovEllipsis = itemOverflow === 'ellipsis'
|
|
79
84
|
const ovTitle = itemOverflow === 'title'
|
|
80
85
|
const ovTooltip = itemOverflow === true || itemOverflow === 'tooltip'
|
|
@@ -116,6 +121,7 @@ const renderItem = (h, _vm, item, slots) => {
|
|
|
116
121
|
{
|
|
117
122
|
'is--title': title,
|
|
118
123
|
'is--colon': titleColon,
|
|
124
|
+
'is--vertical': itemVertical,
|
|
119
125
|
'is--asterisk': titleAsterisk,
|
|
120
126
|
'is--required': isRequired,
|
|
121
127
|
'is--hidden': folding && collapseAll,
|
|
@@ -79,6 +79,10 @@ export default {
|
|
|
79
79
|
titleColon: { type: Boolean, default: () => GlobalConfig.form.titleColon },
|
|
80
80
|
titleAsterisk: { type: Boolean, default: () => GlobalConfig.form.titleAsterisk },
|
|
81
81
|
titleOverflow: { type: [Boolean, String], default: null },
|
|
82
|
+
vertical: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: null
|
|
85
|
+
},
|
|
82
86
|
className: [String, Function],
|
|
83
87
|
readonly: Boolean,
|
|
84
88
|
items: Array,
|
|
@@ -636,6 +636,10 @@ export default {
|
|
|
636
636
|
size: { type: String, default: () => GlobalConfig.input.size || GlobalConfig.size },
|
|
637
637
|
multiple: Boolean,
|
|
638
638
|
|
|
639
|
+
// text
|
|
640
|
+
showWordCount: Boolean,
|
|
641
|
+
countMethod: Function,
|
|
642
|
+
|
|
639
643
|
// number、integer、float
|
|
640
644
|
min: { type: [String, Number], default: null },
|
|
641
645
|
max: { type: [String, Number], default: null },
|
|
@@ -714,6 +718,12 @@ export default {
|
|
|
714
718
|
isSearch () {
|
|
715
719
|
return this.type === 'search'
|
|
716
720
|
},
|
|
721
|
+
inputCount () {
|
|
722
|
+
return XEUtils.getSize(this.inputValue)
|
|
723
|
+
},
|
|
724
|
+
isCountError () {
|
|
725
|
+
return this.maxlength && this.inputCount > XEUtils.toNumber(this.maxlength)
|
|
726
|
+
},
|
|
717
727
|
stepValue () {
|
|
718
728
|
const { type, step } = this
|
|
719
729
|
if (type === 'integer') {
|
|
@@ -1125,7 +1135,7 @@ export default {
|
|
|
1125
1135
|
GlobalEvent.off(this, 'blur')
|
|
1126
1136
|
},
|
|
1127
1137
|
render (h) {
|
|
1128
|
-
const { name, form, inputType, inpPlaceholder, inpMaxlength, inpReadonly, className, controls, inputValue, isDatePickerType, visiblePanel, isActivated, vSize, type, align, readonly, disabled, autocomplete } = this
|
|
1138
|
+
const { name, form, inputType, inpPlaceholder, inpMaxlength, inpReadonly, className, controls, showWordCount, countMethod, inputValue, isDatePickerType, visiblePanel, isActivated, vSize, type, align, readonly, disabled, autocomplete } = this
|
|
1129
1139
|
const childs = []
|
|
1130
1140
|
const prefix = rendePrefixIcon(h, this)
|
|
1131
1141
|
const suffix = renderSuffixIcon(h, this)
|
|
@@ -1173,6 +1183,18 @@ export default {
|
|
|
1173
1183
|
if (isDatePickerType) {
|
|
1174
1184
|
childs.push(renderPanel(h, this))
|
|
1175
1185
|
}
|
|
1186
|
+
let isWordCount = false
|
|
1187
|
+
// 统计字数
|
|
1188
|
+
if (showWordCount && ['text', 'search'].includes(type)) {
|
|
1189
|
+
isWordCount = true
|
|
1190
|
+
childs.push(
|
|
1191
|
+
h('span', {
|
|
1192
|
+
class: ['vxe-input--count', {
|
|
1193
|
+
'is--error': this.isCountError
|
|
1194
|
+
}]
|
|
1195
|
+
}, countMethod ? `${countMethod({ value: inputValue })}` : `${this.inputCount}${inpMaxlength ? `/${inpMaxlength}` : ''}`)
|
|
1196
|
+
)
|
|
1197
|
+
}
|
|
1176
1198
|
return h('div', {
|
|
1177
1199
|
class: ['vxe-input', `type--${type}`, className, {
|
|
1178
1200
|
[`size--${vSize}`]: vSize,
|
|
@@ -1182,6 +1204,7 @@ export default {
|
|
|
1182
1204
|
'is--suffix': !!suffix,
|
|
1183
1205
|
'is--readonly': readonly,
|
|
1184
1206
|
'is--visivle': visiblePanel,
|
|
1207
|
+
'is--count': isWordCount,
|
|
1185
1208
|
'is--disabled': disabled,
|
|
1186
1209
|
'is--active': isActivated
|
|
1187
1210
|
}]
|
|
@@ -112,11 +112,12 @@ export default {
|
|
|
112
112
|
// 处理当前行方向键移动
|
|
113
113
|
moveCurrentRow (isUpArrow, isDwArrow, evnt) {
|
|
114
114
|
const { currentRow, treeConfig, treeOpts, afterFullData } = this
|
|
115
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
115
116
|
let targetRow
|
|
116
117
|
evnt.preventDefault()
|
|
117
118
|
if (currentRow) {
|
|
118
119
|
if (treeConfig) {
|
|
119
|
-
const { index, items } = XEUtils.findTree(afterFullData, item => item === currentRow,
|
|
120
|
+
const { index, items } = XEUtils.findTree(afterFullData, item => item === currentRow, { children: childrenField })
|
|
120
121
|
if (isUpArrow && index > 0) {
|
|
121
122
|
targetRow = items[index - 1]
|
|
122
123
|
} else if (isDwArrow && index < items.length - 1) {
|