vxe-table 4.16.17 → 4.16.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/colgroup/style.css +0 -0
- package/es/colgroup/style.min.css +0 -0
- package/es/column/style.css +0 -0
- package/es/column/style.min.css +0 -0
- package/es/grid/style.css +86 -0
- package/es/grid/style.min.css +1 -0
- package/es/iconfont.1758510533325.ttf +0 -0
- package/es/iconfont.1758510533325.woff +0 -0
- package/es/iconfont.1758510533325.woff2 +0 -0
- package/es/index.esm.js +3 -0
- package/es/locale/lang/ar-EG.d.ts +2 -0
- package/es/locale/lang/de-DE.d.ts +2 -0
- package/es/locale/lang/en-US.d.ts +2 -0
- package/es/locale/lang/es-ES.d.ts +2 -0
- package/es/locale/lang/fr-FR.d.ts +2 -0
- package/es/locale/lang/hu-HU.d.ts +2 -0
- package/es/locale/lang/hy-AM.d.ts +2 -0
- package/es/locale/lang/id-ID.d.ts +2 -0
- package/es/locale/lang/it-IT.d.ts +2 -0
- package/es/locale/lang/ja-JP.d.ts +2 -0
- package/es/locale/lang/ko-KR.d.ts +2 -0
- package/es/locale/lang/ms-MY.d.ts +2 -0
- package/es/locale/lang/nb-NO.d.ts +2 -0
- package/es/locale/lang/pt-BR.d.ts +2 -0
- package/es/locale/lang/ru-RU.d.ts +2 -0
- package/es/locale/lang/th-TH.d.ts +2 -0
- package/es/locale/lang/ug-CN.d.ts +2 -0
- package/es/locale/lang/uk-UA.d.ts +2 -0
- package/es/locale/lang/uz-UZ.d.ts +2 -0
- package/es/locale/lang/vi-VN.d.ts +2 -0
- package/es/locale/lang/zh-CHT.d.ts +2 -0
- package/es/locale/lang/zh-CN.d.ts +2 -0
- package/es/locale/lang/zh-HK.d.ts +2 -0
- package/es/locale/lang/zh-MO.d.ts +2 -0
- package/es/locale/lang/zh-TW.d.ts +2 -0
- package/es/style.css +1 -1
- package/es/table/style.css +3657 -0
- package/es/table/style.min.css +1 -0
- package/es/toolbar/style.css +90 -0
- package/es/toolbar/style.min.css +1 -0
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/ui/style.css +0 -0
- package/es/ui/style.min.css +0 -0
- package/es/v-x-e-table/style.css +0 -0
- package/es/v-x-e-table/style.min.css +0 -0
- package/es/vxe-colgroup/style.css +0 -0
- package/es/vxe-colgroup/style.min.css +0 -0
- package/es/vxe-column/style.css +0 -0
- package/es/vxe-column/style.min.css +0 -0
- package/es/vxe-grid/style.css +86 -0
- package/es/vxe-grid/style.min.css +1 -0
- package/es/vxe-table/style.css +3657 -0
- package/es/vxe-table/style.min.css +1 -0
- package/es/vxe-toolbar/style.css +90 -0
- package/es/vxe-toolbar/style.min.css +1 -0
- package/es/vxe-ui/style.css +0 -0
- package/es/vxe-ui/style.min.css +0 -0
- package/es/vxe-v-x-e-table/style.css +0 -0
- package/es/vxe-v-x-e-table/style.min.css +0 -0
- package/lib/colgroup/style/index.js +1 -0
- package/lib/colgroup/style/style.css +0 -0
- package/lib/colgroup/style/style.min.css +0 -0
- package/lib/column/style/index.js +1 -0
- package/lib/column/style/style.css +0 -0
- package/lib/column/style/style.min.css +0 -0
- package/lib/grid/style/index.js +1 -0
- package/lib/grid/style/style.css +86 -0
- package/lib/grid/style/style.min.css +1 -0
- package/lib/iconfont.1758510533325.ttf +0 -0
- package/lib/iconfont.1758510533325.woff +0 -0
- package/lib/iconfont.1758510533325.woff2 +0 -0
- package/lib/index.common.js +22 -0
- package/lib/index.umd.js +2 -2
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/ar-EG.d.ts +2 -0
- package/lib/locale/lang/ar-EG.min.js +1 -1
- package/lib/locale/lang/ar-EG.umd.js +806 -0
- package/lib/locale/lang/de-DE.d.ts +2 -0
- package/lib/locale/lang/de-DE.min.js +1 -1
- package/lib/locale/lang/de-DE.umd.js +806 -0
- package/lib/locale/lang/en-US.d.ts +2 -0
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +806 -0
- package/lib/locale/lang/es-ES.d.ts +2 -0
- package/lib/locale/lang/es-ES.min.js +1 -1
- package/lib/locale/lang/es-ES.umd.js +806 -0
- package/lib/locale/lang/fr-FR.d.ts +2 -0
- package/lib/locale/lang/fr-FR.min.js +1 -1
- package/lib/locale/lang/fr-FR.umd.js +806 -0
- package/lib/locale/lang/hu-HU.d.ts +2 -0
- package/lib/locale/lang/hu-HU.min.js +1 -1
- package/lib/locale/lang/hu-HU.umd.js +806 -0
- package/lib/locale/lang/hy-AM.d.ts +2 -0
- package/lib/locale/lang/hy-AM.min.js +1 -1
- package/lib/locale/lang/hy-AM.umd.js +806 -0
- package/lib/locale/lang/id-ID.d.ts +2 -0
- package/lib/locale/lang/id-ID.min.js +1 -1
- package/lib/locale/lang/id-ID.umd.js +806 -0
- package/lib/locale/lang/it-IT.d.ts +2 -0
- package/lib/locale/lang/it-IT.min.js +1 -1
- package/lib/locale/lang/it-IT.umd.js +806 -0
- package/lib/locale/lang/ja-JP.d.ts +2 -0
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +806 -0
- package/lib/locale/lang/ko-KR.d.ts +2 -0
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +806 -0
- package/lib/locale/lang/ms-MY.d.ts +2 -0
- package/lib/locale/lang/ms-MY.min.js +1 -1
- package/lib/locale/lang/ms-MY.umd.js +806 -0
- package/lib/locale/lang/nb-NO.d.ts +2 -0
- package/lib/locale/lang/nb-NO.min.js +1 -1
- package/lib/locale/lang/nb-NO.umd.js +806 -0
- package/lib/locale/lang/pt-BR.d.ts +2 -0
- package/lib/locale/lang/pt-BR.min.js +1 -1
- package/lib/locale/lang/pt-BR.umd.js +806 -0
- package/lib/locale/lang/ru-RU.d.ts +2 -0
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +806 -0
- package/lib/locale/lang/th-TH.d.ts +2 -0
- package/lib/locale/lang/th-TH.min.js +1 -1
- package/lib/locale/lang/th-TH.umd.js +806 -0
- package/lib/locale/lang/ug-CN.d.ts +2 -0
- package/lib/locale/lang/ug-CN.min.js +1 -1
- package/lib/locale/lang/ug-CN.umd.js +806 -0
- package/lib/locale/lang/uk-UA.d.ts +2 -0
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +806 -0
- package/lib/locale/lang/uz-UZ.d.ts +2 -0
- package/lib/locale/lang/uz-UZ.min.js +1 -1
- package/lib/locale/lang/uz-UZ.umd.js +806 -0
- package/lib/locale/lang/vi-VN.d.ts +2 -0
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/vi-VN.umd.js +806 -0
- package/lib/locale/lang/zh-CHT.d.ts +2 -0
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +806 -0
- package/lib/locale/lang/zh-CN.d.ts +2 -0
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +808 -0
- package/lib/locale/lang/zh-HK.d.ts +2 -0
- package/lib/locale/lang/zh-HK.min.js +1 -1
- package/lib/locale/lang/zh-HK.umd.js +23 -0
- package/lib/locale/lang/zh-MO.d.ts +2 -0
- package/lib/locale/lang/zh-MO.min.js +1 -1
- package/lib/locale/lang/zh-MO.umd.js +23 -0
- package/lib/locale/lang/zh-TW.d.ts +2 -0
- package/lib/locale/lang/zh-TW.min.js +1 -1
- package/lib/locale/lang/zh-TW.umd.js +23 -0
- package/lib/style.css +1 -1
- package/lib/table/module/custom/hook.js +430 -0
- package/lib/table/module/custom/hook.min.js +1 -0
- package/lib/table/module/custom/panel.js +1193 -0
- package/lib/table/module/custom/panel.min.js +1 -0
- package/lib/table/module/edit/hook.js +1308 -0
- package/lib/table/module/edit/hook.min.js +1 -0
- package/lib/table/module/export/export-panel.js +467 -0
- package/lib/table/module/export/export-panel.min.js +1 -0
- package/lib/table/module/export/hook.js +1888 -0
- package/lib/table/module/export/hook.min.js +1 -0
- package/lib/table/module/export/import-panel.js +226 -0
- package/lib/table/module/export/import-panel.min.js +1 -0
- package/lib/table/module/export/util.js +20 -0
- package/lib/table/module/export/util.min.js +1 -0
- package/lib/table/module/filter/hook.js +442 -0
- package/lib/table/module/filter/hook.min.js +1 -0
- package/lib/table/module/filter/panel.js +265 -0
- package/lib/table/module/filter/panel.min.js +1 -0
- package/lib/table/module/keyboard/hook.js +579 -0
- package/lib/table/module/keyboard/hook.min.js +1 -0
- package/lib/table/module/menu/hook.js +392 -0
- package/lib/table/module/menu/hook.min.js +1 -0
- package/lib/table/module/menu/panel.js +145 -0
- package/lib/table/module/menu/panel.min.js +1 -0
- package/lib/table/module/validator/hook.js +681 -0
- package/lib/table/module/validator/hook.min.js +1 -0
- package/lib/table/src/header.min.js +1 -0
- package/lib/table/src/props.js +318 -0
- package/lib/table/src/props.min.js +1 -0
- package/lib/table/src/store.js +15 -0
- package/lib/table/src/store.min.js +1 -0
- package/lib/table/src/table.js +902 -0
- package/lib/table/src/table.min.js +1 -0
- package/lib/table/src/use/cell-view.js +57 -0
- package/lib/table/src/use/cell-view.min.js +1 -0
- package/lib/table/src/use/index.js +16 -0
- package/lib/table/src/use/index.min.js +1 -0
- package/lib/table/src/util.js +916 -0
- package/lib/table/src/util.min.js +1 -0
- package/lib/table/style/index.js +1 -0
- package/lib/table/style/style.css +3657 -0
- package/lib/table/style/style.min.css +1 -0
- package/lib/toolbar/style/index.js +1 -0
- package/lib/toolbar/style/style.css +90 -0
- package/lib/toolbar/style/style.min.css +1 -0
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/ui/style/index.js +1 -0
- package/lib/ui/style/style.css +0 -0
- package/lib/ui/style/style.min.css +0 -0
- package/lib/v-x-e-table/style/index.js +1 -0
- package/lib/v-x-e-table/style/style.css +0 -0
- package/lib/v-x-e-table/style/style.min.css +0 -0
- package/lib/vxe-colgroup/style/index.js +1 -0
- package/lib/vxe-colgroup/style/style.css +0 -0
- package/lib/vxe-colgroup/style/style.min.css +0 -0
- package/lib/vxe-column/style/index.js +1 -0
- package/lib/vxe-column/style/style.css +0 -0
- package/lib/vxe-column/style/style.min.css +0 -0
- package/lib/vxe-grid/style/index.js +1 -0
- package/lib/vxe-grid/style/style.css +86 -0
- package/lib/vxe-grid/style/style.min.css +1 -0
- package/lib/vxe-table/style/index.js +1 -0
- package/lib/vxe-table/style/style.css +3657 -0
- package/lib/vxe-table/style/style.min.css +1 -0
- package/lib/vxe-toolbar/style/index.js +1 -0
- package/lib/vxe-toolbar/style/style.css +90 -0
- package/lib/vxe-toolbar/style/style.min.css +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/lib/vxe-v-x-e-table/style/index.js +1 -0
- package/lib/vxe-v-x-e-table/style/style.css +0 -0
- package/lib/vxe-v-x-e-table/style/style.min.css +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vue = require("vue");
|
|
4
|
+
var _xeUtils = _interopRequireDefault(require("xe-utils"));
|
|
5
|
+
var _ui = require("../../../ui");
|
|
6
|
+
var _utils = require("../../../ui/src/utils");
|
|
7
|
+
var _util = require("../../src/util");
|
|
8
|
+
var _dom = require("../../../ui/src/dom");
|
|
9
|
+
var _log = require("../../../ui/src/log");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const {
|
|
12
|
+
getConfig,
|
|
13
|
+
renderer,
|
|
14
|
+
hooks,
|
|
15
|
+
getI18n
|
|
16
|
+
} = _ui.VxeUI;
|
|
17
|
+
const tableEditMethodKeys = ['insert', 'insertAt', 'insertNextAt', 'insertChild', 'insertChildAt', 'insertChildNextAt', 'remove', 'removeCheckboxRow', 'removeRadioRow', 'removeCurrentRow', 'getRecordset', 'getInsertRecords', 'getRemoveRecords', 'getUpdateRecords', 'getEditRecord', 'getActiveRecord', 'getEditCell', 'getSelectedCell', 'clearEdit', 'clearActived', 'clearSelected', 'isEditByRow', 'isActiveByRow', 'setEditRow', 'setActiveRow', 'setEditCell', 'setActiveCell', 'setSelectCell'];
|
|
18
|
+
hooks.add('tableEditModule', {
|
|
19
|
+
setupTable($xeTable) {
|
|
20
|
+
const {
|
|
21
|
+
props,
|
|
22
|
+
reactData,
|
|
23
|
+
internalData
|
|
24
|
+
} = $xeTable;
|
|
25
|
+
const {
|
|
26
|
+
refElem
|
|
27
|
+
} = $xeTable.getRefMaps();
|
|
28
|
+
const {
|
|
29
|
+
computeMouseOpts,
|
|
30
|
+
computeEditOpts,
|
|
31
|
+
computeCheckboxOpts,
|
|
32
|
+
computeTreeOpts,
|
|
33
|
+
computeValidOpts
|
|
34
|
+
} = $xeTable.getComputeMaps();
|
|
35
|
+
const browseObj = _xeUtils.default.browse();
|
|
36
|
+
let editMethods = {};
|
|
37
|
+
let editPrivateMethods = {};
|
|
38
|
+
const getEditColumnModel = (row, column) => {
|
|
39
|
+
const {
|
|
40
|
+
model,
|
|
41
|
+
editRender
|
|
42
|
+
} = column;
|
|
43
|
+
if (editRender) {
|
|
44
|
+
model.value = (0, _util.getCellValue)(row, column);
|
|
45
|
+
model.update = false;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const setEditColumnModel = (row, column) => {
|
|
49
|
+
const {
|
|
50
|
+
model,
|
|
51
|
+
editRender
|
|
52
|
+
} = column;
|
|
53
|
+
if (editRender && model.update) {
|
|
54
|
+
(0, _util.setCellValue)(row, column, model.value);
|
|
55
|
+
model.update = false;
|
|
56
|
+
model.value = null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const removeCellSelectedClass = () => {
|
|
60
|
+
const el = refElem.value;
|
|
61
|
+
if (el) {
|
|
62
|
+
const cell = el.querySelector('.col--selected');
|
|
63
|
+
if (cell) {
|
|
64
|
+
(0, _dom.removeClass)(cell, 'col--selected');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const syncActivedCell = () => {
|
|
69
|
+
const {
|
|
70
|
+
editStore,
|
|
71
|
+
tableColumn
|
|
72
|
+
} = reactData;
|
|
73
|
+
const editOpts = computeEditOpts.value;
|
|
74
|
+
const {
|
|
75
|
+
actived
|
|
76
|
+
} = editStore;
|
|
77
|
+
const {
|
|
78
|
+
row,
|
|
79
|
+
column
|
|
80
|
+
} = actived;
|
|
81
|
+
if (row || column) {
|
|
82
|
+
if (editOpts.mode === 'row') {
|
|
83
|
+
tableColumn.forEach(column => setEditColumnModel(row, column));
|
|
84
|
+
} else {
|
|
85
|
+
setEditColumnModel(row, column);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const insertTreeRow = (newRecords, isAppend) => {
|
|
90
|
+
const {
|
|
91
|
+
tableFullTreeData,
|
|
92
|
+
afterFullData,
|
|
93
|
+
fullDataRowIdData,
|
|
94
|
+
fullAllDataRowIdData
|
|
95
|
+
} = internalData;
|
|
96
|
+
const treeOpts = computeTreeOpts.value;
|
|
97
|
+
const {
|
|
98
|
+
rowField,
|
|
99
|
+
parentField,
|
|
100
|
+
mapChildrenField
|
|
101
|
+
} = treeOpts;
|
|
102
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
103
|
+
const funcName = isAppend ? 'push' : 'unshift';
|
|
104
|
+
newRecords.forEach(item => {
|
|
105
|
+
const parentRowId = item[parentField];
|
|
106
|
+
const rowid = (0, _util.getRowid)($xeTable, item);
|
|
107
|
+
const matchObj = parentRowId ? _xeUtils.default.findTree(tableFullTreeData, item => parentRowId === item[rowField], {
|
|
108
|
+
children: mapChildrenField
|
|
109
|
+
}) : null;
|
|
110
|
+
if (matchObj) {
|
|
111
|
+
const {
|
|
112
|
+
item: parentRow
|
|
113
|
+
} = matchObj;
|
|
114
|
+
const parentRest = fullAllDataRowIdData[(0, _util.getRowid)($xeTable, parentRow)];
|
|
115
|
+
const parentLevel = parentRest ? parentRest.level : 0;
|
|
116
|
+
let parentChilds = parentRow[childrenField];
|
|
117
|
+
let mapChilds = parentRow[mapChildrenField];
|
|
118
|
+
if (!_xeUtils.default.isArray(parentChilds)) {
|
|
119
|
+
parentChilds = parentRow[childrenField] = [];
|
|
120
|
+
}
|
|
121
|
+
if (!_xeUtils.default.isArray(mapChilds)) {
|
|
122
|
+
mapChilds = parentRow[childrenField] = [];
|
|
123
|
+
}
|
|
124
|
+
parentChilds[funcName](item);
|
|
125
|
+
mapChilds[funcName](item);
|
|
126
|
+
const rest = {
|
|
127
|
+
row: item,
|
|
128
|
+
rowid,
|
|
129
|
+
seq: -1,
|
|
130
|
+
index: -1,
|
|
131
|
+
_index: -1,
|
|
132
|
+
$index: -1,
|
|
133
|
+
treeIndex: -1,
|
|
134
|
+
_tIndex: -1,
|
|
135
|
+
items: parentChilds,
|
|
136
|
+
parent: parentRow,
|
|
137
|
+
level: parentLevel + 1,
|
|
138
|
+
height: 0,
|
|
139
|
+
resizeHeight: 0,
|
|
140
|
+
oTop: 0,
|
|
141
|
+
expandHeight: 0
|
|
142
|
+
};
|
|
143
|
+
fullDataRowIdData[rowid] = rest;
|
|
144
|
+
fullAllDataRowIdData[rowid] = rest;
|
|
145
|
+
} else {
|
|
146
|
+
if (parentRowId) {
|
|
147
|
+
(0, _log.warnLog)('vxe.error.unableInsert');
|
|
148
|
+
}
|
|
149
|
+
afterFullData[funcName](item);
|
|
150
|
+
tableFullTreeData[funcName](item);
|
|
151
|
+
const rest = {
|
|
152
|
+
row: item,
|
|
153
|
+
rowid,
|
|
154
|
+
seq: -1,
|
|
155
|
+
index: -1,
|
|
156
|
+
_index: -1,
|
|
157
|
+
$index: -1,
|
|
158
|
+
treeIndex: -1,
|
|
159
|
+
_tIndex: -1,
|
|
160
|
+
items: tableFullTreeData,
|
|
161
|
+
parent: null,
|
|
162
|
+
level: 0,
|
|
163
|
+
height: 0,
|
|
164
|
+
resizeHeight: 0,
|
|
165
|
+
oTop: 0,
|
|
166
|
+
expandHeight: 0
|
|
167
|
+
};
|
|
168
|
+
fullDataRowIdData[rowid] = rest;
|
|
169
|
+
fullAllDataRowIdData[rowid] = rest;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
// const insertGroupRow = (newRecords: any[], isAppend: boolean) => {
|
|
174
|
+
// }
|
|
175
|
+
const handleInsertRowAt = (records, targetRow, isInsertNextRow) => {
|
|
176
|
+
const {
|
|
177
|
+
treeConfig
|
|
178
|
+
} = props;
|
|
179
|
+
const {
|
|
180
|
+
isRowGroupStatus
|
|
181
|
+
} = reactData;
|
|
182
|
+
const {
|
|
183
|
+
tableFullTreeData,
|
|
184
|
+
afterFullData,
|
|
185
|
+
mergeBodyList,
|
|
186
|
+
tableFullData,
|
|
187
|
+
fullDataRowIdData,
|
|
188
|
+
fullAllDataRowIdData,
|
|
189
|
+
insertRowMaps,
|
|
190
|
+
removeRowMaps
|
|
191
|
+
} = internalData;
|
|
192
|
+
const treeOpts = computeTreeOpts.value;
|
|
193
|
+
const {
|
|
194
|
+
transform,
|
|
195
|
+
parentField,
|
|
196
|
+
rowField,
|
|
197
|
+
mapChildrenField
|
|
198
|
+
} = treeOpts;
|
|
199
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
200
|
+
if (!_xeUtils.default.isArray(records)) {
|
|
201
|
+
records = [records];
|
|
202
|
+
}
|
|
203
|
+
const newRecords = (0, _vue.reactive)($xeTable.defineField(records.map(record => Object.assign(treeConfig && transform ? {
|
|
204
|
+
[mapChildrenField]: [],
|
|
205
|
+
[childrenField]: []
|
|
206
|
+
} : {}, record))));
|
|
207
|
+
let treeRecords = [];
|
|
208
|
+
if (treeConfig && transform) {
|
|
209
|
+
treeRecords = _xeUtils.default.toArrayTree(newRecords, {
|
|
210
|
+
key: rowField,
|
|
211
|
+
parentKey: parentField,
|
|
212
|
+
children: childrenField
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (_xeUtils.default.eqNull(targetRow)) {
|
|
216
|
+
// 如果为虚拟树
|
|
217
|
+
if (treeConfig && transform) {
|
|
218
|
+
insertTreeRow(newRecords, false);
|
|
219
|
+
} else if (isRowGroupStatus) {
|
|
220
|
+
// 如果分组
|
|
221
|
+
if (treeConfig) {
|
|
222
|
+
throw new Error(getI18n('vxe.error.noTree', ['insert']));
|
|
223
|
+
}
|
|
224
|
+
(0, _log.warnLog)(getI18n('vxe.error.noGroup', ['remove']));
|
|
225
|
+
// insertGroupRow(newRecords, false)
|
|
226
|
+
} else {
|
|
227
|
+
newRecords.forEach(item => {
|
|
228
|
+
const rowid = (0, _util.getRowid)($xeTable, item);
|
|
229
|
+
const rest = {
|
|
230
|
+
row: item,
|
|
231
|
+
rowid,
|
|
232
|
+
seq: -1,
|
|
233
|
+
index: -1,
|
|
234
|
+
_index: -1,
|
|
235
|
+
$index: -1,
|
|
236
|
+
treeIndex: -1,
|
|
237
|
+
_tIndex: -1,
|
|
238
|
+
items: afterFullData,
|
|
239
|
+
parent: null,
|
|
240
|
+
level: 0,
|
|
241
|
+
height: 0,
|
|
242
|
+
resizeHeight: 0,
|
|
243
|
+
oTop: 0,
|
|
244
|
+
expandHeight: 0
|
|
245
|
+
};
|
|
246
|
+
fullDataRowIdData[rowid] = rest;
|
|
247
|
+
fullAllDataRowIdData[rowid] = rest;
|
|
248
|
+
afterFullData.unshift(item);
|
|
249
|
+
tableFullData.unshift(item);
|
|
250
|
+
});
|
|
251
|
+
// 刷新单元格合并
|
|
252
|
+
mergeBodyList.forEach(mergeItem => {
|
|
253
|
+
const {
|
|
254
|
+
row: mergeRowIndex
|
|
255
|
+
} = mergeItem;
|
|
256
|
+
if (mergeRowIndex >= 0) {
|
|
257
|
+
mergeItem.row = mergeRowIndex + newRecords.length;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
if (targetRow === -1) {
|
|
263
|
+
// 如果为虚拟树
|
|
264
|
+
if (treeConfig && transform) {
|
|
265
|
+
insertTreeRow(newRecords, true);
|
|
266
|
+
} else if (isRowGroupStatus) {
|
|
267
|
+
// 如果分组
|
|
268
|
+
if (treeConfig) {
|
|
269
|
+
throw new Error(getI18n('vxe.error.noTree', ['insert']));
|
|
270
|
+
}
|
|
271
|
+
(0, _log.warnLog)(getI18n('vxe.error.noGroup', ['remove']));
|
|
272
|
+
// insertGroupRow(newRecords, true)
|
|
273
|
+
} else {
|
|
274
|
+
newRecords.forEach(item => {
|
|
275
|
+
const rowid = (0, _util.getRowid)($xeTable, item);
|
|
276
|
+
const rest = {
|
|
277
|
+
row: item,
|
|
278
|
+
rowid,
|
|
279
|
+
seq: -1,
|
|
280
|
+
index: -1,
|
|
281
|
+
_index: -1,
|
|
282
|
+
treeIndex: -1,
|
|
283
|
+
_tIndex: -1,
|
|
284
|
+
$index: -1,
|
|
285
|
+
items: afterFullData,
|
|
286
|
+
parent: null,
|
|
287
|
+
level: 0,
|
|
288
|
+
height: 0,
|
|
289
|
+
resizeHeight: 0,
|
|
290
|
+
oTop: 0,
|
|
291
|
+
expandHeight: 0
|
|
292
|
+
};
|
|
293
|
+
fullDataRowIdData[rowid] = rest;
|
|
294
|
+
fullAllDataRowIdData[rowid] = rest;
|
|
295
|
+
afterFullData.push(item);
|
|
296
|
+
tableFullData.push(item);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
// 如果为虚拟树
|
|
301
|
+
if (treeConfig && transform) {
|
|
302
|
+
const matchMapObj = _xeUtils.default.findTree(tableFullTreeData, item => targetRow[rowField] === item[rowField], {
|
|
303
|
+
children: mapChildrenField
|
|
304
|
+
});
|
|
305
|
+
if (matchMapObj) {
|
|
306
|
+
const {
|
|
307
|
+
parent: parentRow
|
|
308
|
+
} = matchMapObj;
|
|
309
|
+
const parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData;
|
|
310
|
+
const parentRest = fullAllDataRowIdData[(0, _util.getRowid)($xeTable, parentRow)];
|
|
311
|
+
const parentLevel = parentRest ? parentRest.level : 0;
|
|
312
|
+
treeRecords.forEach((row, i) => {
|
|
313
|
+
if (parentRow) {
|
|
314
|
+
if (row[parentField] !== parentRow[rowField]) {
|
|
315
|
+
row[parentField] = parentRow[rowField];
|
|
316
|
+
(0, _log.errLog)('vxe.error.errProp', [`${parentField}=${row[parentField]}`, `${parentField}=${parentRow[rowField]}`]);
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
if (row[parentField] !== null) {
|
|
320
|
+
row[parentField] = null;
|
|
321
|
+
(0, _log.errLog)('vxe.error.errProp', [`${parentField}=${row[parentField]}`, 'null']);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
let targetIndex = matchMapObj.index + i;
|
|
325
|
+
if (isInsertNextRow) {
|
|
326
|
+
targetIndex = targetIndex + 1;
|
|
327
|
+
}
|
|
328
|
+
parentMapChilds.splice(targetIndex, 0, row);
|
|
329
|
+
});
|
|
330
|
+
_xeUtils.default.eachTree(treeRecords, item => {
|
|
331
|
+
const rowid = (0, _util.getRowid)($xeTable, item);
|
|
332
|
+
const rest = {
|
|
333
|
+
row: item,
|
|
334
|
+
rowid,
|
|
335
|
+
seq: -1,
|
|
336
|
+
index: -1,
|
|
337
|
+
_index: -1,
|
|
338
|
+
$index: -1,
|
|
339
|
+
treeIndex: -1,
|
|
340
|
+
_tIndex: -1,
|
|
341
|
+
items: parentMapChilds,
|
|
342
|
+
parent: parentRow,
|
|
343
|
+
level: parentLevel + 1,
|
|
344
|
+
height: 0,
|
|
345
|
+
resizeHeight: 0,
|
|
346
|
+
oTop: 0,
|
|
347
|
+
expandHeight: 0
|
|
348
|
+
};
|
|
349
|
+
if (item[childrenField]) {
|
|
350
|
+
item[mapChildrenField] = item[childrenField];
|
|
351
|
+
}
|
|
352
|
+
fullDataRowIdData[rowid] = rest;
|
|
353
|
+
fullAllDataRowIdData[rowid] = rest;
|
|
354
|
+
}, {
|
|
355
|
+
children: childrenField
|
|
356
|
+
});
|
|
357
|
+
// 源
|
|
358
|
+
if (parentRow) {
|
|
359
|
+
const matchObj = _xeUtils.default.findTree(tableFullTreeData, item => targetRow[rowField] === item[rowField], {
|
|
360
|
+
children: childrenField
|
|
361
|
+
});
|
|
362
|
+
if (matchObj) {
|
|
363
|
+
const parentChilds = matchObj.items;
|
|
364
|
+
let targetIndex = matchObj.index;
|
|
365
|
+
if (isInsertNextRow) {
|
|
366
|
+
targetIndex = targetIndex + 1;
|
|
367
|
+
}
|
|
368
|
+
parentChilds.splice(targetIndex, 0, ...treeRecords);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
} else {
|
|
372
|
+
(0, _log.warnLog)('vxe.error.unableInsert');
|
|
373
|
+
insertTreeRow(newRecords, true);
|
|
374
|
+
}
|
|
375
|
+
} else if (isRowGroupStatus) {
|
|
376
|
+
// 如果分组
|
|
377
|
+
if (treeConfig) {
|
|
378
|
+
throw new Error(getI18n('vxe.error.noTree', ['insert']));
|
|
379
|
+
}
|
|
380
|
+
(0, _log.warnLog)(getI18n('vxe.error.noGroup', ['remove']));
|
|
381
|
+
} else {
|
|
382
|
+
if (treeConfig) {
|
|
383
|
+
throw new Error(getI18n('vxe.error.noTree', ['insert']));
|
|
384
|
+
}
|
|
385
|
+
let afIndex = -1;
|
|
386
|
+
// 如果是可视索引
|
|
387
|
+
if (_xeUtils.default.isNumber(targetRow)) {
|
|
388
|
+
if (targetRow < afterFullData.length) {
|
|
389
|
+
afIndex = targetRow;
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
afIndex = $xeTable.findRowIndexOf(afterFullData, targetRow);
|
|
393
|
+
}
|
|
394
|
+
// 如果是插入指定行的下一行
|
|
395
|
+
if (isInsertNextRow) {
|
|
396
|
+
afIndex = Math.min(afterFullData.length, afIndex + 1);
|
|
397
|
+
}
|
|
398
|
+
if (afIndex === -1) {
|
|
399
|
+
throw new Error(getI18n('vxe.error.unableInsert'));
|
|
400
|
+
}
|
|
401
|
+
afterFullData.splice(afIndex, 0, ...newRecords);
|
|
402
|
+
const tfIndex = $xeTable.findRowIndexOf(tableFullData, targetRow);
|
|
403
|
+
if (tfIndex > -1) {
|
|
404
|
+
tableFullData.splice(tfIndex + (isInsertNextRow ? 1 : 0), 0, ...newRecords);
|
|
405
|
+
} else {
|
|
406
|
+
tableFullData.push(...newRecords);
|
|
407
|
+
}
|
|
408
|
+
// 刷新单元格合并
|
|
409
|
+
mergeBodyList.forEach(mergeItem => {
|
|
410
|
+
const {
|
|
411
|
+
row: mergeRowIndex,
|
|
412
|
+
rowspan: mergeRowspan
|
|
413
|
+
} = mergeItem;
|
|
414
|
+
if (mergeRowIndex >= afIndex) {
|
|
415
|
+
mergeItem.row = mergeRowIndex + newRecords.length;
|
|
416
|
+
} else if (isInsertNextRow ? mergeRowIndex + mergeRowspan >= afIndex : mergeRowIndex + mergeRowspan > afIndex) {
|
|
417
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length;
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
const handleStatus = newRow => {
|
|
424
|
+
const rowid = (0, _util.getRowid)($xeTable, newRow);
|
|
425
|
+
// 如果是被删除的数据,则还原状态
|
|
426
|
+
if (removeRowMaps[rowid]) {
|
|
427
|
+
delete removeRowMaps[rowid];
|
|
428
|
+
if (insertRowMaps[rowid]) {
|
|
429
|
+
delete insertRowMaps[rowid];
|
|
430
|
+
}
|
|
431
|
+
} else {
|
|
432
|
+
insertRowMaps[rowid] = newRow;
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
// 如果为虚拟树
|
|
436
|
+
if (treeConfig && transform) {
|
|
437
|
+
_xeUtils.default.eachTree(treeRecords, handleStatus, {
|
|
438
|
+
children: mapChildrenField
|
|
439
|
+
});
|
|
440
|
+
} else {
|
|
441
|
+
newRecords.forEach(handleStatus);
|
|
442
|
+
}
|
|
443
|
+
reactData.removeRowFlag++;
|
|
444
|
+
reactData.insertRowFlag++;
|
|
445
|
+
$xeTable.cacheRowMap(false);
|
|
446
|
+
$xeTable.updateScrollYStatus();
|
|
447
|
+
$xeTable.handleTableData(treeConfig && transform);
|
|
448
|
+
if (!(treeConfig && transform)) {
|
|
449
|
+
$xeTable.updateAfterDataIndex();
|
|
450
|
+
}
|
|
451
|
+
$xeTable.updateFooter();
|
|
452
|
+
$xeTable.handleUpdateBodyMerge();
|
|
453
|
+
$xeTable.checkSelectionStatus();
|
|
454
|
+
if (reactData.scrollYLoad) {
|
|
455
|
+
$xeTable.updateScrollYSpace();
|
|
456
|
+
}
|
|
457
|
+
return (0, _vue.nextTick)().then(() => {
|
|
458
|
+
$xeTable.updateCellAreas();
|
|
459
|
+
return $xeTable.recalculate(true);
|
|
460
|
+
}).then(() => {
|
|
461
|
+
return {
|
|
462
|
+
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
463
|
+
rows: newRecords
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
const handleInsertChildRowAt = (records, parentRow, targetRow, isInsertNextRow) => {
|
|
468
|
+
const {
|
|
469
|
+
treeConfig
|
|
470
|
+
} = props;
|
|
471
|
+
const treeOpts = computeTreeOpts.value;
|
|
472
|
+
const {
|
|
473
|
+
transform,
|
|
474
|
+
rowField,
|
|
475
|
+
parentField
|
|
476
|
+
} = treeOpts;
|
|
477
|
+
if (treeConfig && transform) {
|
|
478
|
+
if (!_xeUtils.default.isArray(records)) {
|
|
479
|
+
records = [records];
|
|
480
|
+
}
|
|
481
|
+
return handleInsertRowAt(records.map(item => Object.assign({}, item, {
|
|
482
|
+
[parentField]: parentRow[rowField]
|
|
483
|
+
})), targetRow, isInsertNextRow);
|
|
484
|
+
} else {
|
|
485
|
+
(0, _log.errLog)('vxe.error.errProp', ['tree-config.transform=false', 'tree-config.transform=true']);
|
|
486
|
+
}
|
|
487
|
+
return Promise.resolve({
|
|
488
|
+
row: null,
|
|
489
|
+
rows: []
|
|
490
|
+
});
|
|
491
|
+
};
|
|
492
|
+
const handleClearEdit = (evnt, targetRow) => {
|
|
493
|
+
const {
|
|
494
|
+
editStore
|
|
495
|
+
} = reactData;
|
|
496
|
+
const {
|
|
497
|
+
actived,
|
|
498
|
+
focused
|
|
499
|
+
} = editStore;
|
|
500
|
+
const {
|
|
501
|
+
row,
|
|
502
|
+
column
|
|
503
|
+
} = actived;
|
|
504
|
+
const validOpts = computeValidOpts.value;
|
|
505
|
+
if (row || column) {
|
|
506
|
+
if (targetRow && (0, _util.getRowid)($xeTable, targetRow) !== (0, _util.getRowid)($xeTable, row)) {
|
|
507
|
+
return (0, _vue.nextTick)();
|
|
508
|
+
}
|
|
509
|
+
syncActivedCell();
|
|
510
|
+
actived.args = null;
|
|
511
|
+
actived.row = null;
|
|
512
|
+
actived.column = null;
|
|
513
|
+
$xeTable.updateFooter();
|
|
514
|
+
$xeTable.dispatchEvent('edit-closed', {
|
|
515
|
+
row,
|
|
516
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
517
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
518
|
+
column,
|
|
519
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
520
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
521
|
+
}, evnt || null);
|
|
522
|
+
}
|
|
523
|
+
focused.row = null;
|
|
524
|
+
focused.column = null;
|
|
525
|
+
if (validOpts.autoClear) {
|
|
526
|
+
if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
|
|
527
|
+
if ($xeTable.clearValidate) {
|
|
528
|
+
return $xeTable.clearValidate();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return (0, _vue.nextTick)().then(() => $xeTable.updateCellAreas());
|
|
533
|
+
};
|
|
534
|
+
const handleEditActive = (params, evnt, isFocus, isPos) => {
|
|
535
|
+
const $xeGrid = $xeTable.xeGrid;
|
|
536
|
+
const $xeGantt = $xeTable.xeGantt;
|
|
537
|
+
const {
|
|
538
|
+
editConfig,
|
|
539
|
+
mouseConfig
|
|
540
|
+
} = props;
|
|
541
|
+
const {
|
|
542
|
+
editStore,
|
|
543
|
+
tableColumn
|
|
544
|
+
} = reactData;
|
|
545
|
+
const editOpts = computeEditOpts.value;
|
|
546
|
+
const {
|
|
547
|
+
mode
|
|
548
|
+
} = editOpts;
|
|
549
|
+
const {
|
|
550
|
+
actived,
|
|
551
|
+
focused
|
|
552
|
+
} = editStore;
|
|
553
|
+
const {
|
|
554
|
+
row,
|
|
555
|
+
column
|
|
556
|
+
} = params;
|
|
557
|
+
const {
|
|
558
|
+
editRender
|
|
559
|
+
} = column;
|
|
560
|
+
const cell = params.cell || $xeTable.getCellElement(row, column);
|
|
561
|
+
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
|
|
562
|
+
params.cell = cell;
|
|
563
|
+
if (cell && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(editRender)) {
|
|
564
|
+
// 激活编辑
|
|
565
|
+
if (!$xeTable.isPendingByRow(row) && !$xeTable.isAggregateRecord(row)) {
|
|
566
|
+
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
|
|
567
|
+
// 判断是否禁用编辑
|
|
568
|
+
let type = 'edit-disabled';
|
|
569
|
+
if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), {
|
|
570
|
+
$table: $xeTable,
|
|
571
|
+
$grid: $xeGrid,
|
|
572
|
+
$gantt: $xeGantt
|
|
573
|
+
}))) {
|
|
574
|
+
if (mouseConfig) {
|
|
575
|
+
$xeTable.clearSelected();
|
|
576
|
+
if ($xeTable.clearCellAreas) {
|
|
577
|
+
$xeTable.clearCellAreas();
|
|
578
|
+
$xeTable.clearCopyCellArea();
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
$xeTable.closeTooltip();
|
|
582
|
+
if (actived.column) {
|
|
583
|
+
handleClearEdit(evnt);
|
|
584
|
+
}
|
|
585
|
+
type = 'edit-activated';
|
|
586
|
+
column.renderHeight = cell.offsetHeight;
|
|
587
|
+
actived.args = params;
|
|
588
|
+
actived.row = row;
|
|
589
|
+
actived.column = column;
|
|
590
|
+
if (mode === 'row') {
|
|
591
|
+
tableColumn.forEach(column => getEditColumnModel(row, column));
|
|
592
|
+
} else {
|
|
593
|
+
getEditColumnModel(row, column);
|
|
594
|
+
}
|
|
595
|
+
const afterEditMethod = editOpts.afterEditMethod;
|
|
596
|
+
(0, _vue.nextTick)(() => {
|
|
597
|
+
if (isFocus) {
|
|
598
|
+
$xeTable.handleFocus(params, evnt);
|
|
599
|
+
}
|
|
600
|
+
if (afterEditMethod) {
|
|
601
|
+
afterEditMethod(Object.assign(Object.assign({}, params), {
|
|
602
|
+
$table: $xeTable,
|
|
603
|
+
$grid: $xeGrid,
|
|
604
|
+
$gantt: $xeGantt
|
|
605
|
+
}));
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
$xeTable.dispatchEvent(type, {
|
|
610
|
+
row,
|
|
611
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
612
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
613
|
+
column,
|
|
614
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
615
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
616
|
+
}, evnt);
|
|
617
|
+
// v4已废弃
|
|
618
|
+
if (type === 'edit-activated') {
|
|
619
|
+
$xeTable.dispatchEvent('edit-actived', {
|
|
620
|
+
row,
|
|
621
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
622
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
623
|
+
column,
|
|
624
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
625
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
626
|
+
}, evnt);
|
|
627
|
+
}
|
|
628
|
+
} else {
|
|
629
|
+
const {
|
|
630
|
+
column: oldColumn
|
|
631
|
+
} = actived;
|
|
632
|
+
if (mouseConfig) {
|
|
633
|
+
$xeTable.clearSelected();
|
|
634
|
+
if ($xeTable.clearCellAreas) {
|
|
635
|
+
$xeTable.clearCellAreas();
|
|
636
|
+
$xeTable.clearCopyCellArea();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (oldColumn !== column) {
|
|
640
|
+
const {
|
|
641
|
+
model: oldModel
|
|
642
|
+
} = oldColumn;
|
|
643
|
+
if (oldModel.update) {
|
|
644
|
+
(0, _util.setCellValue)(row, oldColumn, oldModel.value);
|
|
645
|
+
}
|
|
646
|
+
if ($xeTable.clearValidate) {
|
|
647
|
+
$xeTable.clearValidate(row, column);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
column.renderHeight = cell.offsetHeight;
|
|
651
|
+
actived.args = params;
|
|
652
|
+
actived.column = column;
|
|
653
|
+
if (isPos) {
|
|
654
|
+
setTimeout(() => {
|
|
655
|
+
$xeTable.handleFocus(params, evnt);
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
focused.column = null;
|
|
660
|
+
focused.row = null;
|
|
661
|
+
$xeTable.focus();
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return (0, _vue.nextTick)();
|
|
665
|
+
};
|
|
666
|
+
const handleEditCell = (row, fieldOrColumn, isPos) => {
|
|
667
|
+
const {
|
|
668
|
+
editConfig
|
|
669
|
+
} = props;
|
|
670
|
+
const column = _xeUtils.default.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
671
|
+
if (row && column && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(column.editRender) && !$xeTable.isAggregateRecord(row)) {
|
|
672
|
+
return Promise.resolve(isPos ? $xeTable.scrollToRow(row, column) : null).then(() => {
|
|
673
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
674
|
+
if (cell) {
|
|
675
|
+
handleEditActive({
|
|
676
|
+
row,
|
|
677
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
678
|
+
column,
|
|
679
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
680
|
+
cell,
|
|
681
|
+
$table: $xeTable
|
|
682
|
+
}, null, isPos, isPos);
|
|
683
|
+
internalData._lastCallTime = Date.now();
|
|
684
|
+
}
|
|
685
|
+
return (0, _vue.nextTick)();
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
return (0, _vue.nextTick)();
|
|
689
|
+
};
|
|
690
|
+
editMethods = {
|
|
691
|
+
/**
|
|
692
|
+
* 往表格中插入临时数据
|
|
693
|
+
*
|
|
694
|
+
* @param {*} records
|
|
695
|
+
*/
|
|
696
|
+
insert(records) {
|
|
697
|
+
return handleInsertRowAt(records, null);
|
|
698
|
+
},
|
|
699
|
+
/**
|
|
700
|
+
* 往表格指定行中插入临时数据
|
|
701
|
+
* 如果 row 为空则从插入到顶部,如果为树结构,则插入到目标节点顶部
|
|
702
|
+
* 如果 row 为 -1 则从插入到底部,如果为树结构,则插入到目标节点底部
|
|
703
|
+
* 如果 row 为有效行则插入到该行的位置,如果为树结构,则有插入到效的目标节点该行的位置
|
|
704
|
+
* @param {Object/Array} records 新的数据
|
|
705
|
+
* @param {Row} targetRow 指定行
|
|
706
|
+
*/
|
|
707
|
+
insertAt(records, targetRow) {
|
|
708
|
+
return handleInsertRowAt(records, targetRow);
|
|
709
|
+
},
|
|
710
|
+
insertNextAt(records, targetRow) {
|
|
711
|
+
return handleInsertRowAt(records, targetRow, true);
|
|
712
|
+
},
|
|
713
|
+
insertChild(records, parentRow) {
|
|
714
|
+
return handleInsertChildRowAt(records, parentRow, null);
|
|
715
|
+
},
|
|
716
|
+
insertChildAt(records, parentRow, targetRow) {
|
|
717
|
+
return handleInsertChildRowAt(records, parentRow, targetRow);
|
|
718
|
+
},
|
|
719
|
+
insertChildNextAt(records, parentRow, targetRow) {
|
|
720
|
+
return handleInsertChildRowAt(records, parentRow, targetRow, true);
|
|
721
|
+
},
|
|
722
|
+
/**
|
|
723
|
+
* 删除指定行数据
|
|
724
|
+
* 如果传 row 则删除一行
|
|
725
|
+
* 如果传 rows 则删除多行
|
|
726
|
+
* 如果为空则删除所有
|
|
727
|
+
*/
|
|
728
|
+
remove(rows) {
|
|
729
|
+
const {
|
|
730
|
+
treeConfig
|
|
731
|
+
} = props;
|
|
732
|
+
const {
|
|
733
|
+
editStore,
|
|
734
|
+
isRowGroupStatus
|
|
735
|
+
} = reactData;
|
|
736
|
+
const {
|
|
737
|
+
tableFullTreeData,
|
|
738
|
+
selectCheckboxMaps,
|
|
739
|
+
afterFullData,
|
|
740
|
+
mergeBodyList,
|
|
741
|
+
tableFullData,
|
|
742
|
+
pendingRowMaps,
|
|
743
|
+
insertRowMaps,
|
|
744
|
+
removeRowMaps
|
|
745
|
+
} = internalData;
|
|
746
|
+
const checkboxOpts = computeCheckboxOpts.value;
|
|
747
|
+
const treeOpts = computeTreeOpts.value;
|
|
748
|
+
const {
|
|
749
|
+
transform,
|
|
750
|
+
mapChildrenField
|
|
751
|
+
} = treeOpts;
|
|
752
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
753
|
+
const {
|
|
754
|
+
actived
|
|
755
|
+
} = editStore;
|
|
756
|
+
const {
|
|
757
|
+
checkField
|
|
758
|
+
} = checkboxOpts;
|
|
759
|
+
let delList = [];
|
|
760
|
+
if (!rows) {
|
|
761
|
+
rows = tableFullData;
|
|
762
|
+
} else if (!_xeUtils.default.isArray(rows)) {
|
|
763
|
+
rows = [rows];
|
|
764
|
+
}
|
|
765
|
+
// 如果是新增,则保存记录
|
|
766
|
+
rows.forEach(row => {
|
|
767
|
+
if (!$xeTable.isInsertByRow(row)) {
|
|
768
|
+
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
769
|
+
removeRowMaps[rowid] = row;
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
// 如果绑定了多选属性,则更新状态
|
|
773
|
+
if (!checkField) {
|
|
774
|
+
rows.forEach(row => {
|
|
775
|
+
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
776
|
+
if (selectCheckboxMaps[rowid]) {
|
|
777
|
+
delete selectCheckboxMaps[rowid];
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
reactData.updateCheckboxFlag++;
|
|
781
|
+
}
|
|
782
|
+
// 从数据源中移除
|
|
783
|
+
if (tableFullData === rows) {
|
|
784
|
+
rows = delList = tableFullData.slice(0);
|
|
785
|
+
internalData.tableFullData = [];
|
|
786
|
+
internalData.afterFullData = [];
|
|
787
|
+
$xeTable.clearMergeCells();
|
|
788
|
+
} else {
|
|
789
|
+
// 如果为虚拟树
|
|
790
|
+
if (treeConfig && transform) {
|
|
791
|
+
rows.forEach(row => {
|
|
792
|
+
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
793
|
+
const matchMapObj = _xeUtils.default.findTree(tableFullTreeData, item => rowid === (0, _util.getRowid)($xeTable, item), {
|
|
794
|
+
children: mapChildrenField
|
|
795
|
+
});
|
|
796
|
+
if (matchMapObj) {
|
|
797
|
+
const rItems = matchMapObj.items.splice(matchMapObj.index, 1);
|
|
798
|
+
delList.push(rItems[0]);
|
|
799
|
+
}
|
|
800
|
+
const matchObj = _xeUtils.default.findTree(tableFullTreeData, item => rowid === (0, _util.getRowid)($xeTable, item), {
|
|
801
|
+
children: childrenField
|
|
802
|
+
});
|
|
803
|
+
if (matchObj) {
|
|
804
|
+
matchObj.items.splice(matchObj.index, 1);
|
|
805
|
+
}
|
|
806
|
+
const afIndex = $xeTable.findRowIndexOf(afterFullData, row);
|
|
807
|
+
if (afIndex > -1) {
|
|
808
|
+
afterFullData.splice(afIndex, 1);
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
} else if (isRowGroupStatus) {
|
|
812
|
+
// 如果分组
|
|
813
|
+
(0, _log.warnLog)(getI18n('vxe.error.noGroup', ['remove']));
|
|
814
|
+
} else {
|
|
815
|
+
rows.forEach(row => {
|
|
816
|
+
const tfIndex = $xeTable.findRowIndexOf(tableFullData, row);
|
|
817
|
+
if (tfIndex > -1) {
|
|
818
|
+
const rItems = tableFullData.splice(tfIndex, 1);
|
|
819
|
+
delList.push(rItems[0]);
|
|
820
|
+
}
|
|
821
|
+
const afIndex = $xeTable.findRowIndexOf(afterFullData, row);
|
|
822
|
+
if (afIndex > -1) {
|
|
823
|
+
// 刷新单元格合并
|
|
824
|
+
mergeBodyList.forEach(mergeItem => {
|
|
825
|
+
const {
|
|
826
|
+
row: mergeRowIndex,
|
|
827
|
+
rowspan: mergeRowspan
|
|
828
|
+
} = mergeItem;
|
|
829
|
+
if (mergeRowIndex > afIndex) {
|
|
830
|
+
mergeItem.row = mergeRowIndex - 1;
|
|
831
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
832
|
+
mergeItem.rowspan = mergeRowspan - 1;
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
afterFullData.splice(afIndex, 1);
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
// 如果当前行被激活编辑,则清除激活状态
|
|
841
|
+
if (actived.row && $xeTable.findRowIndexOf(rows, actived.row) > -1) {
|
|
842
|
+
editMethods.clearEdit();
|
|
843
|
+
}
|
|
844
|
+
// 从新增中移除已删除的数据
|
|
845
|
+
rows.forEach(row => {
|
|
846
|
+
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
847
|
+
if (insertRowMaps[rowid]) {
|
|
848
|
+
delete insertRowMaps[rowid];
|
|
849
|
+
}
|
|
850
|
+
if (pendingRowMaps[rowid]) {
|
|
851
|
+
delete pendingRowMaps[rowid];
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
reactData.removeRowFlag++;
|
|
855
|
+
reactData.insertRowFlag++;
|
|
856
|
+
reactData.pendingRowFlag++;
|
|
857
|
+
$xeTable.cacheRowMap(false);
|
|
858
|
+
$xeTable.handleTableData(treeConfig && transform);
|
|
859
|
+
$xeTable.updateFooter();
|
|
860
|
+
$xeTable.handleUpdateBodyMerge();
|
|
861
|
+
if (!(treeConfig && transform)) {
|
|
862
|
+
$xeTable.updateAfterDataIndex();
|
|
863
|
+
}
|
|
864
|
+
$xeTable.checkSelectionStatus();
|
|
865
|
+
if (reactData.scrollYLoad) {
|
|
866
|
+
$xeTable.updateScrollYSpace();
|
|
867
|
+
}
|
|
868
|
+
return (0, _vue.nextTick)().then(() => {
|
|
869
|
+
$xeTable.updateCellAreas();
|
|
870
|
+
return $xeTable.recalculate(true);
|
|
871
|
+
}).then(() => {
|
|
872
|
+
return {
|
|
873
|
+
row: delList.length ? delList[delList.length - 1] : null,
|
|
874
|
+
rows: delList
|
|
875
|
+
};
|
|
876
|
+
});
|
|
877
|
+
},
|
|
878
|
+
/**
|
|
879
|
+
* 删除复选框选中的数据
|
|
880
|
+
*/
|
|
881
|
+
removeCheckboxRow() {
|
|
882
|
+
return editMethods.remove($xeTable.getCheckboxRecords()).then(params => {
|
|
883
|
+
$xeTable.clearCheckboxRow();
|
|
884
|
+
return params;
|
|
885
|
+
});
|
|
886
|
+
},
|
|
887
|
+
/**
|
|
888
|
+
* 删除单选框选中的数据
|
|
889
|
+
*/
|
|
890
|
+
removeRadioRow() {
|
|
891
|
+
const radioRecord = $xeTable.getRadioRecord();
|
|
892
|
+
return editMethods.remove(radioRecord || []).then(params => {
|
|
893
|
+
$xeTable.clearRadioRow();
|
|
894
|
+
return params;
|
|
895
|
+
});
|
|
896
|
+
},
|
|
897
|
+
/**
|
|
898
|
+
* 删除当前行选中的数据
|
|
899
|
+
*/
|
|
900
|
+
removeCurrentRow() {
|
|
901
|
+
const currentRecord = $xeTable.getCurrentRecord();
|
|
902
|
+
return editMethods.remove(currentRecord || []).then(params => {
|
|
903
|
+
$xeTable.clearCurrentRow();
|
|
904
|
+
return params;
|
|
905
|
+
});
|
|
906
|
+
},
|
|
907
|
+
/**
|
|
908
|
+
* 获取表格数据集,包含新增、删除、修改、标记
|
|
909
|
+
*/
|
|
910
|
+
getRecordset() {
|
|
911
|
+
const removeRecords = editMethods.getRemoveRecords();
|
|
912
|
+
const pendingRecords = $xeTable.getPendingRecords();
|
|
913
|
+
const delRecords = removeRecords.concat(pendingRecords);
|
|
914
|
+
// 如果已经被删除,则无需放到更新数组
|
|
915
|
+
const updateRecords = editMethods.getUpdateRecords().filter(row => {
|
|
916
|
+
return !delRecords.some(item => $xeTable.eqRow(item, row));
|
|
917
|
+
});
|
|
918
|
+
return {
|
|
919
|
+
insertRecords: editMethods.getInsertRecords(),
|
|
920
|
+
removeRecords,
|
|
921
|
+
updateRecords,
|
|
922
|
+
pendingRecords
|
|
923
|
+
};
|
|
924
|
+
},
|
|
925
|
+
/**
|
|
926
|
+
* 获取新增的临时数据
|
|
927
|
+
*/
|
|
928
|
+
getInsertRecords() {
|
|
929
|
+
const {
|
|
930
|
+
fullAllDataRowIdData,
|
|
931
|
+
insertRowMaps
|
|
932
|
+
} = internalData;
|
|
933
|
+
const insertRecords = [];
|
|
934
|
+
_xeUtils.default.each(insertRowMaps, (row, rowid) => {
|
|
935
|
+
if (fullAllDataRowIdData[rowid]) {
|
|
936
|
+
insertRecords.push(row);
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
return insertRecords;
|
|
940
|
+
},
|
|
941
|
+
/**
|
|
942
|
+
* 获取已删除的数据
|
|
943
|
+
*/
|
|
944
|
+
getRemoveRecords() {
|
|
945
|
+
const {
|
|
946
|
+
removeRowMaps
|
|
947
|
+
} = internalData;
|
|
948
|
+
const removeRecords = [];
|
|
949
|
+
_xeUtils.default.each(removeRowMaps, row => {
|
|
950
|
+
removeRecords.push(row);
|
|
951
|
+
});
|
|
952
|
+
return removeRecords;
|
|
953
|
+
},
|
|
954
|
+
/**
|
|
955
|
+
* 获取更新数据
|
|
956
|
+
* 只精准匹配 row 的更改
|
|
957
|
+
* 如果是树表格,子节点更改状态不会影响父节点的更新状态
|
|
958
|
+
*/
|
|
959
|
+
getUpdateRecords() {
|
|
960
|
+
const {
|
|
961
|
+
keepSource,
|
|
962
|
+
treeConfig
|
|
963
|
+
} = props;
|
|
964
|
+
const {
|
|
965
|
+
tableFullData
|
|
966
|
+
} = internalData;
|
|
967
|
+
const treeOpts = computeTreeOpts.value;
|
|
968
|
+
if (keepSource) {
|
|
969
|
+
syncActivedCell();
|
|
970
|
+
if (treeConfig) {
|
|
971
|
+
return _xeUtils.default.filterTree(tableFullData, row => $xeTable.isUpdateByRow(row), treeOpts);
|
|
972
|
+
}
|
|
973
|
+
return tableFullData.filter(row => $xeTable.isUpdateByRow(row));
|
|
974
|
+
}
|
|
975
|
+
return [];
|
|
976
|
+
},
|
|
977
|
+
getActiveRecord() {
|
|
978
|
+
(0, _log.warnLog)('vxe.error.delFunc', ['getActiveRecord', 'getEditCell']);
|
|
979
|
+
const {
|
|
980
|
+
editStore
|
|
981
|
+
} = reactData;
|
|
982
|
+
const {
|
|
983
|
+
fullAllDataRowIdData
|
|
984
|
+
} = internalData;
|
|
985
|
+
const {
|
|
986
|
+
args,
|
|
987
|
+
row
|
|
988
|
+
} = editStore.actived;
|
|
989
|
+
if (args && row && fullAllDataRowIdData[(0, _util.getRowid)($xeTable, row)]) {
|
|
990
|
+
return Object.assign({}, args, {
|
|
991
|
+
row
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
return null;
|
|
995
|
+
},
|
|
996
|
+
getEditRecord() {
|
|
997
|
+
(0, _log.warnLog)('vxe.error.delFunc', ['getEditRecord', 'getEditCell']);
|
|
998
|
+
const {
|
|
999
|
+
editStore
|
|
1000
|
+
} = reactData;
|
|
1001
|
+
const {
|
|
1002
|
+
fullAllDataRowIdData
|
|
1003
|
+
} = internalData;
|
|
1004
|
+
const {
|
|
1005
|
+
args,
|
|
1006
|
+
row
|
|
1007
|
+
} = editStore.actived;
|
|
1008
|
+
if (args && row && fullAllDataRowIdData[(0, _util.getRowid)($xeTable, row)]) {
|
|
1009
|
+
return Object.assign({}, args, {
|
|
1010
|
+
row
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
return null;
|
|
1014
|
+
},
|
|
1015
|
+
getEditCell() {
|
|
1016
|
+
const {
|
|
1017
|
+
editStore
|
|
1018
|
+
} = reactData;
|
|
1019
|
+
const {
|
|
1020
|
+
row,
|
|
1021
|
+
column
|
|
1022
|
+
} = editStore.actived;
|
|
1023
|
+
if (column && row) {
|
|
1024
|
+
return {
|
|
1025
|
+
row,
|
|
1026
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
1027
|
+
column,
|
|
1028
|
+
columnIndex: $xeTable.getColumnIndex(column)
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
return null;
|
|
1032
|
+
},
|
|
1033
|
+
/**
|
|
1034
|
+
* 获取选中的单元格
|
|
1035
|
+
*/
|
|
1036
|
+
getSelectedCell() {
|
|
1037
|
+
const {
|
|
1038
|
+
editStore
|
|
1039
|
+
} = reactData;
|
|
1040
|
+
const {
|
|
1041
|
+
row,
|
|
1042
|
+
column
|
|
1043
|
+
} = editStore.selected;
|
|
1044
|
+
if (row && column) {
|
|
1045
|
+
return {
|
|
1046
|
+
row,
|
|
1047
|
+
column
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
return null;
|
|
1051
|
+
},
|
|
1052
|
+
clearActived(row) {
|
|
1053
|
+
// 即将废弃
|
|
1054
|
+
(0, _log.warnLog)('vxe.error.delFunc', ['clearActived', 'clearEdit']);
|
|
1055
|
+
return $xeTable.clearEdit(row);
|
|
1056
|
+
},
|
|
1057
|
+
/**
|
|
1058
|
+
* 清除激活的编辑
|
|
1059
|
+
*/
|
|
1060
|
+
clearEdit(row) {
|
|
1061
|
+
return handleClearEdit(null, row);
|
|
1062
|
+
},
|
|
1063
|
+
/**
|
|
1064
|
+
* 清除所选中源状态
|
|
1065
|
+
*/
|
|
1066
|
+
clearSelected() {
|
|
1067
|
+
const {
|
|
1068
|
+
editStore
|
|
1069
|
+
} = reactData;
|
|
1070
|
+
const {
|
|
1071
|
+
selected
|
|
1072
|
+
} = editStore;
|
|
1073
|
+
selected.row = null;
|
|
1074
|
+
selected.column = null;
|
|
1075
|
+
removeCellSelectedClass();
|
|
1076
|
+
return (0, _vue.nextTick)();
|
|
1077
|
+
},
|
|
1078
|
+
isActiveByRow(row) {
|
|
1079
|
+
(0, _log.warnLog)('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow']);
|
|
1080
|
+
// 即将废弃
|
|
1081
|
+
return $xeTable.isEditByRow(row);
|
|
1082
|
+
},
|
|
1083
|
+
/**
|
|
1084
|
+
* 判断行是否为激活编辑状态
|
|
1085
|
+
* @param {Row} row 行对象
|
|
1086
|
+
*/
|
|
1087
|
+
isEditByRow(row) {
|
|
1088
|
+
const {
|
|
1089
|
+
editStore
|
|
1090
|
+
} = reactData;
|
|
1091
|
+
return editStore.actived.row === row;
|
|
1092
|
+
},
|
|
1093
|
+
setActiveRow(row) {
|
|
1094
|
+
(0, _log.warnLog)('vxe.error.delFunc', ['setActiveRow', 'setEditRow']);
|
|
1095
|
+
// 即将废弃
|
|
1096
|
+
return editMethods.setEditRow(row);
|
|
1097
|
+
},
|
|
1098
|
+
/**
|
|
1099
|
+
* 激活行编辑
|
|
1100
|
+
*/
|
|
1101
|
+
setEditRow(row, fieldOrColumn) {
|
|
1102
|
+
const {
|
|
1103
|
+
visibleColumn
|
|
1104
|
+
} = internalData;
|
|
1105
|
+
let column = _xeUtils.default.find(visibleColumn, column => (0, _utils.isEnableConf)(column.editRender));
|
|
1106
|
+
let isPos = false;
|
|
1107
|
+
if (fieldOrColumn) {
|
|
1108
|
+
isPos = true;
|
|
1109
|
+
if (fieldOrColumn !== true) {
|
|
1110
|
+
column = _xeUtils.default.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
return handleEditCell(row, column, isPos);
|
|
1114
|
+
},
|
|
1115
|
+
setActiveCell(row, fieldOrColumn) {
|
|
1116
|
+
(0, _log.warnLog)('vxe.error.delFunc', ['setActiveCell', 'setEditCell']);
|
|
1117
|
+
// 即将废弃
|
|
1118
|
+
return editMethods.setEditCell(row, fieldOrColumn);
|
|
1119
|
+
},
|
|
1120
|
+
/**
|
|
1121
|
+
* 激活单元格编辑
|
|
1122
|
+
*/
|
|
1123
|
+
setEditCell(row, fieldOrColumn) {
|
|
1124
|
+
return handleEditCell(row, fieldOrColumn, true);
|
|
1125
|
+
},
|
|
1126
|
+
/**
|
|
1127
|
+
* 只对 trigger=dblclick 有效,选中单元格
|
|
1128
|
+
*/
|
|
1129
|
+
setSelectCell(row, fieldOrColumn) {
|
|
1130
|
+
const {
|
|
1131
|
+
tableData
|
|
1132
|
+
} = reactData;
|
|
1133
|
+
const editOpts = computeEditOpts.value;
|
|
1134
|
+
const column = _xeUtils.default.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
1135
|
+
if (row && column && editOpts.trigger !== 'manual') {
|
|
1136
|
+
const rowIndex = $xeTable.findRowIndexOf(tableData, row);
|
|
1137
|
+
if (rowIndex > -1 && column) {
|
|
1138
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
1139
|
+
const params = {
|
|
1140
|
+
row,
|
|
1141
|
+
rowIndex,
|
|
1142
|
+
column,
|
|
1143
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
1144
|
+
cell
|
|
1145
|
+
};
|
|
1146
|
+
$xeTable.handleSelected(params, {});
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
return (0, _vue.nextTick)();
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
editPrivateMethods = {
|
|
1153
|
+
/**
|
|
1154
|
+
* 处理激活编辑
|
|
1155
|
+
*/
|
|
1156
|
+
handleEdit(params, evnt) {
|
|
1157
|
+
return handleEditActive(params, evnt, true, true);
|
|
1158
|
+
},
|
|
1159
|
+
/**
|
|
1160
|
+
* @deprecated
|
|
1161
|
+
*/
|
|
1162
|
+
handleActived(params, evnt) {
|
|
1163
|
+
return editPrivateMethods.handleEdit(params, evnt);
|
|
1164
|
+
},
|
|
1165
|
+
/**
|
|
1166
|
+
* 处理取消编辑
|
|
1167
|
+
* @param evnt
|
|
1168
|
+
* @returns
|
|
1169
|
+
*/
|
|
1170
|
+
handleClearEdit,
|
|
1171
|
+
/**
|
|
1172
|
+
* 处理聚焦
|
|
1173
|
+
*/
|
|
1174
|
+
handleFocus(params) {
|
|
1175
|
+
const {
|
|
1176
|
+
row,
|
|
1177
|
+
column,
|
|
1178
|
+
cell
|
|
1179
|
+
} = params;
|
|
1180
|
+
const {
|
|
1181
|
+
editRender
|
|
1182
|
+
} = column;
|
|
1183
|
+
const editOpts = computeEditOpts.value;
|
|
1184
|
+
if ((0, _utils.isEnableConf)(editRender)) {
|
|
1185
|
+
const compRender = renderer.get(editRender.name);
|
|
1186
|
+
let autoFocus = editRender.autofocus || editRender.autoFocus;
|
|
1187
|
+
let autoSelect = editRender.autoSelect || editRender.autoselect;
|
|
1188
|
+
let inputElem;
|
|
1189
|
+
// 是否启用聚焦
|
|
1190
|
+
if (editOpts.autoFocus) {
|
|
1191
|
+
if (!autoFocus && compRender) {
|
|
1192
|
+
autoFocus = compRender.tableAutoFocus || compRender.tableAutofocus || compRender.autofocus;
|
|
1193
|
+
}
|
|
1194
|
+
if (!autoSelect && compRender) {
|
|
1195
|
+
autoSelect = compRender.tableAutoSelect || compRender.autoselect;
|
|
1196
|
+
}
|
|
1197
|
+
// 如果指定了聚焦 class
|
|
1198
|
+
if (_xeUtils.default.isFunction(autoFocus)) {
|
|
1199
|
+
inputElem = autoFocus(params);
|
|
1200
|
+
} else if (autoFocus) {
|
|
1201
|
+
if (autoFocus === true) {
|
|
1202
|
+
// 自动匹配模式,会自动匹配第一个可输入元素
|
|
1203
|
+
inputElem = cell.querySelector('input,textarea');
|
|
1204
|
+
} else {
|
|
1205
|
+
inputElem = cell.querySelector(autoFocus);
|
|
1206
|
+
}
|
|
1207
|
+
if (inputElem) {
|
|
1208
|
+
inputElem.focus();
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
if (inputElem) {
|
|
1213
|
+
if (autoSelect) {
|
|
1214
|
+
inputElem.select();
|
|
1215
|
+
} else {
|
|
1216
|
+
// 保持一致行为,光标移到末端
|
|
1217
|
+
if (browseObj.msie) {
|
|
1218
|
+
const textRange = inputElem.createTextRange();
|
|
1219
|
+
textRange.collapse(false);
|
|
1220
|
+
textRange.select();
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
} else {
|
|
1224
|
+
// 是否自动定位
|
|
1225
|
+
if (editOpts.autoPos) {
|
|
1226
|
+
if (!column.fixed) {
|
|
1227
|
+
// 显示到可视区中
|
|
1228
|
+
$xeTable.scrollToRow(row, column);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
},
|
|
1234
|
+
/**
|
|
1235
|
+
* 处理选中源
|
|
1236
|
+
*/
|
|
1237
|
+
handleSelected(params, evnt) {
|
|
1238
|
+
const {
|
|
1239
|
+
mouseConfig
|
|
1240
|
+
} = props;
|
|
1241
|
+
const {
|
|
1242
|
+
editStore
|
|
1243
|
+
} = reactData;
|
|
1244
|
+
const mouseOpts = computeMouseOpts.value;
|
|
1245
|
+
const editOpts = computeEditOpts.value;
|
|
1246
|
+
const {
|
|
1247
|
+
actived,
|
|
1248
|
+
selected
|
|
1249
|
+
} = editStore;
|
|
1250
|
+
const {
|
|
1251
|
+
row,
|
|
1252
|
+
column
|
|
1253
|
+
} = params;
|
|
1254
|
+
const isMouseSelected = mouseConfig && mouseOpts.selected;
|
|
1255
|
+
const selectMethod = () => {
|
|
1256
|
+
if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
|
|
1257
|
+
if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
|
|
1258
|
+
handleClearEdit(evnt);
|
|
1259
|
+
$xeTable.clearSelected();
|
|
1260
|
+
if ($xeTable.clearCellAreas) {
|
|
1261
|
+
$xeTable.clearCellAreas();
|
|
1262
|
+
$xeTable.clearCopyCellArea();
|
|
1263
|
+
}
|
|
1264
|
+
selected.args = params;
|
|
1265
|
+
selected.row = row;
|
|
1266
|
+
selected.column = column;
|
|
1267
|
+
if (isMouseSelected) {
|
|
1268
|
+
editPrivateMethods.addCellSelectedClass();
|
|
1269
|
+
}
|
|
1270
|
+
$xeTable.focus();
|
|
1271
|
+
if (evnt) {
|
|
1272
|
+
$xeTable.dispatchEvent('cell-selected', params, evnt);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
return (0, _vue.nextTick)();
|
|
1277
|
+
};
|
|
1278
|
+
return selectMethod();
|
|
1279
|
+
},
|
|
1280
|
+
addCellSelectedClass() {
|
|
1281
|
+
const {
|
|
1282
|
+
editStore
|
|
1283
|
+
} = reactData;
|
|
1284
|
+
const {
|
|
1285
|
+
selected
|
|
1286
|
+
} = editStore;
|
|
1287
|
+
const {
|
|
1288
|
+
row,
|
|
1289
|
+
column
|
|
1290
|
+
} = selected;
|
|
1291
|
+
removeCellSelectedClass();
|
|
1292
|
+
if (row && column) {
|
|
1293
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
1294
|
+
if (cell) {
|
|
1295
|
+
(0, _dom.addClass)(cell, 'col--selected');
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
return Object.assign(Object.assign({}, editMethods), editPrivateMethods);
|
|
1301
|
+
},
|
|
1302
|
+
setupGrid($xeGrid) {
|
|
1303
|
+
return $xeGrid.extendTableMethods(tableEditMethodKeys);
|
|
1304
|
+
},
|
|
1305
|
+
setupGantt($xeGantt) {
|
|
1306
|
+
return $xeGantt.extendTableMethods(tableEditMethodKeys);
|
|
1307
|
+
}
|
|
1308
|
+
});
|