vxe-table 4.1.3 → 4.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -3
- package/README.md +3 -3
- package/README.zh-TW.md +2 -3
- package/es/edit/src/hook.js +189 -69
- package/es/form/src/form.js +2 -2
- package/es/input/src/input.js +8 -2
- package/es/table/src/body.js +6 -3
- package/es/table/src/table.js +44 -34
- package/es/v-x-e-table/src/conf.js +1 -1
- package/es/validator/src/hook.js +3 -3
- package/lib/edit/src/hook.js +243 -70
- package/lib/edit/src/hook.min.js +1 -1
- package/lib/form/src/form.js +2 -2
- package/lib/form/src/form.min.js +1 -1
- package/lib/index.umd.js +772 -209
- package/lib/index.umd.min.js +2 -1
- package/lib/input/src/input.js +10 -2
- package/lib/input/src/input.min.js +1 -1
- package/lib/table/src/body.js +6 -3
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/table.js +46 -36
- package/lib/table/src/table.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +1 -1
- package/lib/v-x-e-table/src/conf.min.js +1 -1
- package/lib/validator/src/hook.js +3 -3
- package/lib/validator/src/hook.min.js +1 -1
- package/package.json +4 -27
- package/packages/edit/src/hook.ts +183 -69
- package/packages/form/src/form.ts +2 -2
- package/packages/input/src/input.ts +9 -2
- package/packages/table/src/body.ts +6 -3
- package/packages/table/src/table.ts +43 -32
- package/packages/v-x-e-table/src/conf.ts +1 -1
- package/packages/v-x-e-table/src/renderer.ts +1 -1
- package/packages/validator/src/hook.ts +3 -3
- package/types/edit.d.ts +6 -3
- package/types/index.d.ts +1 -1
- package/types/plugins/pro.d.ts +6 -6
- package/types/table.d.ts +5 -0
- package/types/v-x-e-table/renderer.d.ts +4 -2
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vxe-table",
|
|
3
|
-
"version": "4.1.
|
|
4
|
-
"description": "一个基于 vue 的 PC
|
|
3
|
+
"version": "4.1.6",
|
|
4
|
+
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
7
7
|
"lint": "vue-cli-service lint",
|
|
8
|
-
"build": "
|
|
9
|
-
"build:examples": "vue-cli-service build",
|
|
10
|
-
"build:docs": "gulp update_docs",
|
|
8
|
+
"build": "vue-cli-service build",
|
|
11
9
|
"lib:modules": "gulp build",
|
|
12
10
|
"lib:pack": "vue-cli-service build --target lib --name index --dest lib_temp index.ts",
|
|
13
11
|
"lib": "npm run lib:pack && npm run lib:modules",
|
|
@@ -29,9 +27,7 @@
|
|
|
29
27
|
"style": "lib/style.css",
|
|
30
28
|
"typings": "types/index.d.ts",
|
|
31
29
|
"devDependencies": {
|
|
32
|
-
"@types/qrcode": "^1.4.1",
|
|
33
30
|
"@types/resize-observer-browser": "^0.1.6",
|
|
34
|
-
"@types/sortablejs": "^1.10.7",
|
|
35
31
|
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
|
36
32
|
"@typescript-eslint/parser": "^4.18.0",
|
|
37
33
|
"@vue/cli-plugin-babel": "~4.5.0",
|
|
@@ -43,18 +39,13 @@
|
|
|
43
39
|
"@vue/compiler-sfc": "^3.2.18",
|
|
44
40
|
"@vue/eslint-config-standard": "^5.1.2",
|
|
45
41
|
"@vue/eslint-config-typescript": "^7.0.0",
|
|
46
|
-
"ant-design-vue": "^2.2.8",
|
|
47
42
|
"core-js": "^3.6.5",
|
|
48
|
-
"dayjs": "^1.10.7",
|
|
49
|
-
"element-plus": "^1.1.0-beta.24",
|
|
50
43
|
"eslint": "^6.7.2",
|
|
51
44
|
"eslint-plugin-import": "^2.20.2",
|
|
52
45
|
"eslint-plugin-node": "^11.1.0",
|
|
53
46
|
"eslint-plugin-promise": "^4.2.1",
|
|
54
47
|
"eslint-plugin-standard": "^4.0.0",
|
|
55
48
|
"eslint-plugin-vue": "^7.0.0",
|
|
56
|
-
"exceljs": "^4.3.0",
|
|
57
|
-
"font-awesome": "^4.7.0",
|
|
58
49
|
"gulp": "^4.0.2",
|
|
59
50
|
"gulp-autoprefixer": "^6.1.0",
|
|
60
51
|
"gulp-babel": "^8.0.0",
|
|
@@ -67,29 +58,15 @@
|
|
|
67
58
|
"gulp-sourcemaps": "^2.6.5",
|
|
68
59
|
"gulp-typescript": "^5.0.1",
|
|
69
60
|
"gulp-uglify": "^3.0.2",
|
|
70
|
-
"highlight.js": "^11.2.0",
|
|
71
|
-
"jsbarcode": "^3.11.0",
|
|
72
|
-
"jspdf": "^2.4.0",
|
|
73
61
|
"node-sass": "^6.0.1",
|
|
74
|
-
"qrcode": "^1.4.4",
|
|
75
62
|
"sass-loader": "^10.0.5",
|
|
76
|
-
"sortablejs": "^1.14.0",
|
|
77
63
|
"typescript": "~4.3.5",
|
|
78
64
|
"vue": "^3.2.21",
|
|
79
65
|
"vue-i18n": "^9.1.7",
|
|
80
66
|
"vue-router": "^4.0.11",
|
|
81
67
|
"vuex": "^4.0.2",
|
|
82
|
-
"vxe-table-plugin-antd": "^3.0.5",
|
|
83
|
-
"vxe-table-plugin-element": "^3.0.5",
|
|
84
|
-
"vxe-table-plugin-export-pdf": "^3.0.2",
|
|
85
|
-
"vxe-table-plugin-export-xlsx": "^3.0.3",
|
|
86
|
-
"vxe-table-plugin-menus": "^3.0.6",
|
|
87
|
-
"vxe-table-plugin-renderer": "^3.0.2",
|
|
88
|
-
"vxe-table-plugin-shortcut-key": "^3.0.2",
|
|
89
68
|
"xe-ajax": "^4.0.5",
|
|
90
|
-
"xe-
|
|
91
|
-
"xe-utils": "^3.4.0",
|
|
92
|
-
"xlsx": "^0.17.2"
|
|
69
|
+
"xe-utils": "^3.4.0"
|
|
93
70
|
},
|
|
94
71
|
"peerDependencies": {
|
|
95
72
|
"vue": "^3.2.2",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { nextTick } from 'vue'
|
|
2
2
|
import XEUtils from 'xe-utils'
|
|
3
3
|
import { renderer } from '../../v-x-e-table'
|
|
4
|
-
import { errLog, getLog, isEnableConf } from '../../tools/utils'
|
|
5
|
-
import { getCellValue, setCellValue } from '../../table/src/util'
|
|
4
|
+
import { errLog, getLog, isEnableConf, warnLog } from '../../tools/utils'
|
|
5
|
+
import { getCellValue, setCellValue, getRowid } from '../../table/src/util'
|
|
6
6
|
import { browse, removeClass, addClass } from '../../tools/dom'
|
|
7
7
|
|
|
8
8
|
import { VxeGlobalHooksHandles, TableEditMethods, TableEditPrivateMethods } from '../../../types/all'
|
|
@@ -59,6 +59,42 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
function insertTreeRow (newRecords: any[], isAppend: boolean) {
|
|
63
|
+
const { treeFullData, afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
64
|
+
const treeOpts = computeTreeOpts.value
|
|
65
|
+
const funcName = isAppend ? 'push' : 'unshift'
|
|
66
|
+
newRecords.forEach(item => {
|
|
67
|
+
const parentRowId = item[treeOpts.parentField]
|
|
68
|
+
const rowid = getRowid($xetable, item)
|
|
69
|
+
const matchObj = parentRowId ? XEUtils.findTree(treeFullData, item => parentRowId === item[treeOpts.rowField], treeOpts) : null
|
|
70
|
+
if (matchObj) {
|
|
71
|
+
const { item: parentRow } = matchObj
|
|
72
|
+
const parentRest = fullAllDataRowIdData[getRowid($xetable, parentRow)]
|
|
73
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
74
|
+
let parentChilds = parentRow[treeOpts.children]
|
|
75
|
+
if (!XEUtils.isArray(parentChilds)) {
|
|
76
|
+
parentChilds = parentRow[treeOpts.children] = []
|
|
77
|
+
}
|
|
78
|
+
parentChilds[funcName](item)
|
|
79
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
|
|
80
|
+
fullDataRowIdData[rowid] = rest
|
|
81
|
+
fullAllDataRowIdData[rowid] = rest
|
|
82
|
+
} else {
|
|
83
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
84
|
+
if (parentRowId) {
|
|
85
|
+
warnLog('vxe.error.unableInsert')
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
afterFullData[funcName](item)
|
|
89
|
+
treeFullData[funcName](item)
|
|
90
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: treeFullData, parent: null, level: 0 }
|
|
91
|
+
fullDataRowIdData[rowid] = rest
|
|
92
|
+
fullAllDataRowIdData[rowid] = rest
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
$xetable.updateVirtualTreeData()
|
|
96
|
+
}
|
|
97
|
+
|
|
62
98
|
editMethods = {
|
|
63
99
|
/**
|
|
64
100
|
* 往表格中插入临时数据
|
|
@@ -70,68 +106,114 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
70
106
|
},
|
|
71
107
|
/**
|
|
72
108
|
* 往表格指定行中插入临时数据
|
|
73
|
-
* 如果 row
|
|
74
|
-
* 如果 row 为 -1
|
|
75
|
-
* 如果 row
|
|
109
|
+
* 如果 row 为空则从插入到顶部,如果为树结构,则插入到目标节点顶部
|
|
110
|
+
* 如果 row 为 -1 则从插入到底部,如果为树结构,则插入到目标节点底部
|
|
111
|
+
* 如果 row 为有效行则插入到该行的位置,如果为树结构,则有插入到效的目标节点该行的位置
|
|
76
112
|
* @param {Object/Array} records 新的数据
|
|
77
113
|
* @param {Row} row 指定行
|
|
78
114
|
*/
|
|
79
115
|
insertAt (records: any, row: any) {
|
|
80
116
|
const { treeConfig } = props
|
|
81
117
|
const { mergeList, editStore, scrollYLoad } = reactData
|
|
82
|
-
const { afterFullData, tableFullData } = internalData
|
|
118
|
+
const { treeFullData, afterFullData, tableFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
83
119
|
const sYOpts = computeSYOpts.value
|
|
120
|
+
const treeOpts = computeTreeOpts.value
|
|
121
|
+
const { transform } = treeOpts
|
|
84
122
|
if (!XEUtils.isArray(records)) {
|
|
85
123
|
records = [records]
|
|
86
124
|
}
|
|
87
|
-
const newRecords = records.map((record: any) => $xetable.defineField(Object.assign({}, record)))
|
|
125
|
+
const newRecords: any[] = records.map((record: any) => $xetable.defineField(Object.assign({}, record)))
|
|
88
126
|
if (!row) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
mergeList.forEach((mergeItem: any) => {
|
|
93
|
-
const { row: mergeRowIndex } = mergeItem
|
|
94
|
-
if (mergeRowIndex > 0) {
|
|
95
|
-
mergeItem.row = mergeRowIndex + newRecords.length
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
} else {
|
|
99
|
-
if (row === -1) {
|
|
100
|
-
afterFullData.push(...newRecords)
|
|
101
|
-
tableFullData.push(...newRecords)
|
|
102
|
-
// 刷新单元格合并
|
|
103
|
-
mergeList.forEach((mergeItem: any) => {
|
|
104
|
-
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
105
|
-
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
106
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
107
|
-
}
|
|
108
|
-
})
|
|
127
|
+
// 如果为虚拟树
|
|
128
|
+
if (treeConfig && transform) {
|
|
129
|
+
insertTreeRow(newRecords, false)
|
|
109
130
|
} else {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
const afIndex = $xetable.findRowIndexOf(afterFullData, row)
|
|
114
|
-
if (afIndex === -1) {
|
|
115
|
-
throw new Error(errLog('vxe.error.unableInsert'))
|
|
116
|
-
}
|
|
117
|
-
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
118
|
-
tableFullData.splice($xetable.findRowIndexOf(tableFullData, row), 0, ...newRecords)
|
|
131
|
+
afterFullData.unshift(...newRecords)
|
|
132
|
+
tableFullData.unshift(...newRecords)
|
|
119
133
|
// 刷新单元格合并
|
|
120
134
|
mergeList.forEach((mergeItem: any) => {
|
|
121
|
-
const { row: mergeRowIndex
|
|
122
|
-
if (mergeRowIndex >
|
|
135
|
+
const { row: mergeRowIndex } = mergeItem
|
|
136
|
+
if (mergeRowIndex > 0) {
|
|
123
137
|
mergeItem.row = mergeRowIndex + newRecords.length
|
|
124
|
-
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
125
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
126
138
|
}
|
|
127
139
|
})
|
|
128
140
|
}
|
|
141
|
+
} else {
|
|
142
|
+
if (row === -1) {
|
|
143
|
+
// 如果为虚拟树
|
|
144
|
+
if (treeConfig && transform) {
|
|
145
|
+
insertTreeRow(newRecords, true)
|
|
146
|
+
} else {
|
|
147
|
+
afterFullData.push(...newRecords)
|
|
148
|
+
tableFullData.push(...newRecords)
|
|
149
|
+
// 刷新单元格合并
|
|
150
|
+
mergeList.forEach((mergeItem: any) => {
|
|
151
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
152
|
+
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
153
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
// 如果为虚拟树
|
|
159
|
+
if (treeConfig && transform) {
|
|
160
|
+
const matchObj = XEUtils.findTree(treeFullData, item => row[treeOpts.rowField] === item[treeOpts.rowField], treeOpts)
|
|
161
|
+
if (matchObj) {
|
|
162
|
+
const { parent: parentRow } = matchObj
|
|
163
|
+
const parentChilds = matchObj.items
|
|
164
|
+
const parentRest = fullAllDataRowIdData[getRowid($xetable, parentRow)]
|
|
165
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
166
|
+
newRecords.forEach((item, i) => {
|
|
167
|
+
const rowid = getRowid($xetable, item)
|
|
168
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
169
|
+
if (item[treeOpts.parentField]) {
|
|
170
|
+
if (parentRow && item[treeOpts.parentField] !== parentRow[treeOpts.rowField]) {
|
|
171
|
+
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[treeOpts.rowField]}`])
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (parentRow) {
|
|
176
|
+
item[treeOpts.parentField] = parentRow[treeOpts.rowField]
|
|
177
|
+
}
|
|
178
|
+
parentChilds.splice(matchObj.index + i, 0, item)
|
|
179
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1 }
|
|
180
|
+
fullDataRowIdData[rowid] = rest
|
|
181
|
+
fullAllDataRowIdData[rowid] = rest
|
|
182
|
+
})
|
|
183
|
+
$xetable.updateVirtualTreeData()
|
|
184
|
+
} else {
|
|
185
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
186
|
+
warnLog('vxe.error.unableInsert')
|
|
187
|
+
}
|
|
188
|
+
insertTreeRow(newRecords, true)
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
if (treeConfig) {
|
|
192
|
+
throw new Error(getLog('vxe.error.noTree', ['insert']))
|
|
193
|
+
}
|
|
194
|
+
const afIndex = $xetable.findRowIndexOf(afterFullData, row)
|
|
195
|
+
if (afIndex === -1) {
|
|
196
|
+
throw new Error(errLog('vxe.error.unableInsert'))
|
|
197
|
+
}
|
|
198
|
+
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
199
|
+
tableFullData.splice($xetable.findRowIndexOf(tableFullData, row), 0, ...newRecords)
|
|
200
|
+
// 刷新单元格合并
|
|
201
|
+
mergeList.forEach((mergeItem: any) => {
|
|
202
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
203
|
+
if (mergeRowIndex > afIndex) {
|
|
204
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
205
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
206
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
}
|
|
129
211
|
}
|
|
130
212
|
editStore.insertList.unshift(...newRecords)
|
|
131
213
|
reactData.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
|
|
132
214
|
$xetable.updateFooter()
|
|
133
215
|
$xetable.cacheRowMap()
|
|
134
|
-
$xetable.handleTableData()
|
|
216
|
+
$xetable.handleTableData(transform)
|
|
135
217
|
$xetable.updateAfterDataIndex()
|
|
136
218
|
$xetable.checkSelectionStatus()
|
|
137
219
|
if (scrollYLoad) {
|
|
@@ -156,9 +238,11 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
156
238
|
remove (rows: any) {
|
|
157
239
|
const { treeConfig } = props
|
|
158
240
|
const { mergeList, editStore, selection, scrollYLoad } = reactData
|
|
159
|
-
const { afterFullData, tableFullData } = internalData
|
|
241
|
+
const { treeFullData, afterFullData, tableFullData } = internalData
|
|
160
242
|
const checkboxOpts = computeCheckboxOpts.value
|
|
161
243
|
const sYOpts = computeSYOpts.value
|
|
244
|
+
const treeOpts = computeTreeOpts.value
|
|
245
|
+
const { transform } = treeOpts
|
|
162
246
|
const { actived, removeList, insertList } = editStore
|
|
163
247
|
const { checkField: property } = checkboxOpts
|
|
164
248
|
let rest: any[] = []
|
|
@@ -189,26 +273,43 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
189
273
|
internalData.afterFullData = []
|
|
190
274
|
$xetable.clearMergeCells()
|
|
191
275
|
} else {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
276
|
+
// 如果为虚拟树
|
|
277
|
+
if (treeConfig && transform) {
|
|
278
|
+
rows.forEach((row: any) => {
|
|
279
|
+
const rowid = getRowid($xetable, row)
|
|
280
|
+
const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid($xetable, item), treeOpts)
|
|
281
|
+
if (matchObj) {
|
|
282
|
+
const rItems = matchObj.items.splice(matchObj.index, 1)
|
|
283
|
+
rest.push(rItems[0])
|
|
284
|
+
}
|
|
285
|
+
const afIndex = $xetable.findRowIndexOf(afterFullData, row)
|
|
286
|
+
if (afIndex > -1) {
|
|
287
|
+
afterFullData.splice(afIndex, 1)
|
|
288
|
+
}
|
|
289
|
+
$xetable.updateVirtualTreeData()
|
|
290
|
+
})
|
|
291
|
+
} else {
|
|
292
|
+
rows.forEach((row: any) => {
|
|
293
|
+
const tfIndex = $xetable.findRowIndexOf(tableFullData, row)
|
|
294
|
+
if (tfIndex > -1) {
|
|
295
|
+
const rItems = tableFullData.splice(tfIndex, 1)
|
|
296
|
+
rest.push(rItems[0])
|
|
297
|
+
}
|
|
298
|
+
const afIndex = $xetable.findRowIndexOf(afterFullData, row)
|
|
299
|
+
if (afIndex > -1) {
|
|
300
|
+
// 刷新单元格合并
|
|
301
|
+
mergeList.forEach((mergeItem: any) => {
|
|
302
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
303
|
+
if (mergeRowIndex > afIndex) {
|
|
304
|
+
mergeItem.row = mergeRowIndex - 1
|
|
305
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
306
|
+
mergeItem.rowspan = mergeRowspan - 1
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
afterFullData.splice(afIndex, 1)
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
}
|
|
212
313
|
}
|
|
213
314
|
// 如果当前行被激活编辑,则清除激活状态
|
|
214
315
|
if (actived.row && $xetable.findRowIndexOf(rows, actived.row) > -1) {
|
|
@@ -224,7 +325,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
224
325
|
reactData.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
|
|
225
326
|
$xetable.updateFooter()
|
|
226
327
|
$xetable.cacheRowMap()
|
|
227
|
-
$xetable.handleTableData()
|
|
328
|
+
$xetable.handleTableData(transform)
|
|
228
329
|
$xetable.updateAfterDataIndex()
|
|
229
330
|
$xetable.checkSelectionStatus()
|
|
230
331
|
if (scrollYLoad) {
|
|
@@ -280,16 +381,29 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
280
381
|
* 获取新增的临时数据
|
|
281
382
|
*/
|
|
282
383
|
getInsertRecords () {
|
|
384
|
+
const { treeConfig } = props
|
|
283
385
|
const { editStore } = reactData
|
|
284
|
-
const { tableFullData } = internalData
|
|
386
|
+
const { treeFullData, tableFullData } = internalData
|
|
387
|
+
const treeOpts = computeTreeOpts.value
|
|
285
388
|
const insertList = editStore.insertList
|
|
286
389
|
const insertRecords: any[] = []
|
|
287
390
|
if (insertList.length) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
391
|
+
// 如果为虚拟树
|
|
392
|
+
if (treeConfig && treeOpts.transform) {
|
|
393
|
+
insertList.forEach(row => {
|
|
394
|
+
const rowid = getRowid($xetable, row)
|
|
395
|
+
const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid($xetable, item), treeOpts)
|
|
396
|
+
if (matchObj) {
|
|
397
|
+
insertRecords.push(row)
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
} else {
|
|
401
|
+
insertList.forEach(row => {
|
|
402
|
+
if ($xetable.findRowIndexOf(tableFullData, row) > -1) {
|
|
403
|
+
insertRecords.push(row)
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
}
|
|
293
407
|
}
|
|
294
408
|
return insertRecords
|
|
295
409
|
},
|
|
@@ -395,7 +395,7 @@ export default defineComponent({
|
|
|
395
395
|
callback()
|
|
396
396
|
}
|
|
397
397
|
}).catch(() => {
|
|
398
|
-
return new Promise<void>((resolve
|
|
398
|
+
return new Promise<void>((resolve) => {
|
|
399
399
|
showErrTime = window.setTimeout(() => {
|
|
400
400
|
itemList.forEach((item) => {
|
|
401
401
|
if (item.errRule) {
|
|
@@ -412,7 +412,7 @@ export default defineComponent({
|
|
|
412
412
|
callback(validRest)
|
|
413
413
|
resolve()
|
|
414
414
|
} else {
|
|
415
|
-
|
|
415
|
+
resolve(validRest)
|
|
416
416
|
}
|
|
417
417
|
})
|
|
418
418
|
})
|
|
@@ -601,11 +601,18 @@ export default defineComponent({
|
|
|
601
601
|
return immediate || !(type === 'text' || type === 'number' || type === 'integer' || type === 'float')
|
|
602
602
|
})
|
|
603
603
|
|
|
604
|
+
function toFloatValueFixed (inputValue: string | number, digitsValue: number) {
|
|
605
|
+
if (/^-/.test('' + inputValue)) {
|
|
606
|
+
return XEUtils.toFixed(XEUtils.ceil(inputValue, digitsValue), digitsValue)
|
|
607
|
+
}
|
|
608
|
+
return XEUtils.toFixed(XEUtils.floor(inputValue, digitsValue), digitsValue)
|
|
609
|
+
}
|
|
610
|
+
|
|
604
611
|
function getNumberValue (val: any) {
|
|
605
612
|
const { type, exponential } = props
|
|
606
613
|
const inpMaxlength = computeInpMaxlength.value
|
|
607
614
|
const digitsValue = computeDigitsValue.value
|
|
608
|
-
const restVal = (type === 'float' ?
|
|
615
|
+
const restVal = (type === 'float' ? toFloatValueFixed(val, digitsValue) : XEUtils.toValueString(val))
|
|
609
616
|
if (exponential && (val === restVal || XEUtils.toValueString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
|
|
610
617
|
return val
|
|
611
618
|
}
|
|
@@ -746,7 +753,7 @@ export default defineComponent({
|
|
|
746
753
|
changeValue()
|
|
747
754
|
} else if (type === 'float') {
|
|
748
755
|
if (inputValue) {
|
|
749
|
-
const validValue =
|
|
756
|
+
const validValue = toFloatValueFixed(inputValue, digitsValue)
|
|
750
757
|
if (inputValue !== validValue) {
|
|
751
758
|
emitModel(validValue, { type: 'init' })
|
|
752
759
|
}
|
|
@@ -299,6 +299,7 @@ export default defineComponent({
|
|
|
299
299
|
const radioOpts = computeRadioOpts.value
|
|
300
300
|
const treeOpts = computeTreeOpts.value
|
|
301
301
|
const editOpts = computeEditOpts.value
|
|
302
|
+
const rowOpts = computeRowOpts.value
|
|
302
303
|
const rows: any[] = []
|
|
303
304
|
tableData.forEach((row: any, $rowIndex: any) => {
|
|
304
305
|
const trOn: any = {}
|
|
@@ -311,7 +312,7 @@ export default defineComponent({
|
|
|
311
312
|
// 确保任何情况下 rowIndex 都精准指向真实 data 索引
|
|
312
313
|
rowIndex = $xetable.getRowIndex(row)
|
|
313
314
|
// 事件绑定
|
|
314
|
-
if (highlightHoverRow) {
|
|
315
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
315
316
|
trOn.onMouseenter = (evnt: any) => {
|
|
316
317
|
if (isOperateMouse()) {
|
|
317
318
|
return
|
|
@@ -428,6 +429,7 @@ export default defineComponent({
|
|
|
428
429
|
const { highlightHoverRow } = tableProps
|
|
429
430
|
const { scrollXLoad, scrollYLoad } = tableReactData
|
|
430
431
|
const { elemStore, lastScrollTop, lastScrollLeft } = tableInternalData
|
|
432
|
+
const rowOpts = computeRowOpts.value
|
|
431
433
|
const tableHeader = refTableHeader.value
|
|
432
434
|
const tableBody = refTableBody.value
|
|
433
435
|
const tableFooter = refTableFooter.value
|
|
@@ -451,7 +453,7 @@ export default defineComponent({
|
|
|
451
453
|
tableInternalData.lastScrollTop = scrollTop
|
|
452
454
|
tableInternalData.lastScrollLeft = scrollLeft
|
|
453
455
|
tableInternalData.lastScrollTime = Date.now()
|
|
454
|
-
if (highlightHoverRow) {
|
|
456
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
455
457
|
$xetable.clearHoverRow()
|
|
456
458
|
}
|
|
457
459
|
if (leftElem && fixedType === 'left') {
|
|
@@ -546,6 +548,7 @@ export default defineComponent({
|
|
|
546
548
|
const { highlightHoverRow } = tableProps
|
|
547
549
|
const { scrollYLoad } = tableReactData
|
|
548
550
|
const { lastScrollTop, lastScrollLeft } = tableInternalData
|
|
551
|
+
const rowOpts = computeRowOpts.value
|
|
549
552
|
const tableBody = refTableBody.value
|
|
550
553
|
const scrollBodyElem = refElem.value
|
|
551
554
|
const bodyElem = tableBody.$el as HTMLDivElement
|
|
@@ -569,7 +572,7 @@ export default defineComponent({
|
|
|
569
572
|
tableInternalData.lastScrollTop = scrollTop
|
|
570
573
|
tableInternalData.lastScrollLeft = scrollLeft
|
|
571
574
|
tableInternalData.lastScrollTime = Date.now()
|
|
572
|
-
if (highlightHoverRow) {
|
|
575
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
573
576
|
$xetable.clearHoverRow()
|
|
574
577
|
}
|
|
575
578
|
handleWheel(evnt, isTopWheel, deltaTop, isRollX, isRollY)
|