vxe-table 3.9.0-rc.9 → 3.9.1
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 +80 -9
- package/es/grid/src/grid.js +116 -62
- package/es/grid/style.css +0 -1
- package/es/grid/style.min.css +1 -1
- package/es/index.esm.js +22 -3
- package/es/locale/lang/en-US.js +6 -2
- package/es/locale/lang/es-ES.js +5 -1
- package/es/locale/lang/hu-HU.js +5 -1
- package/es/locale/lang/ja-JP.js +5 -1
- package/es/locale/lang/ko-KR.js +5 -1
- package/es/locale/lang/pt-BR.js +5 -1
- package/es/locale/lang/ru-RU.js +5 -1
- package/es/locale/lang/uk-UA.js +5 -1
- package/es/locale/lang/vi-VN.js +5 -1
- package/es/locale/lang/zh-CHT.js +5 -1
- package/es/locale/lang/zh-CN.js +5 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/custom/panel.js +183 -173
- package/es/table/module/edit/mixin.js +35 -40
- package/es/table/module/export/export-panel.js +32 -4
- package/es/table/module/export/import-panel.js +25 -6
- package/es/table/module/export/mixin.js +11 -11
- package/es/table/module/menu/mixin.js +2 -2
- package/es/table/module/validator/mixin.js +4 -4
- package/es/table/render/index.js +17 -11
- package/es/table/src/body.js +1 -0
- package/es/table/src/columnInfo.js +3 -3
- package/es/table/src/methods.js +69 -55
- package/es/table/src/props.js +65 -15
- package/es/table/src/table.js +63 -29
- package/es/table/src/util.js +3 -2
- package/es/table/style.css +37 -48
- package/es/table/style.min.css +1 -1
- package/es/toolbar/src/toolbar.js +21 -7
- package/es/toolbar/style.css +0 -1
- package/es/toolbar/style.min.css +1 -1
- package/es/ui/index.js +5 -3
- package/es/ui/src/log.js +1 -1
- package/es/vxe-grid/style.css +0 -1
- package/es/vxe-grid/style.min.css +1 -1
- package/es/vxe-table/style.css +37 -48
- package/es/vxe-table/style.min.css +1 -1
- package/es/vxe-toolbar/style.css +0 -1
- package/es/vxe-toolbar/style.min.css +1 -1
- package/lib/colgroup/index.js +3 -3
- package/lib/colgroup/index.min.js +1 -1
- package/lib/column/index.js +3 -3
- package/lib/column/index.min.js +1 -1
- package/lib/components.js +9 -11
- package/lib/components.min.js +1 -1
- package/lib/grid/index.js +3 -3
- package/lib/grid/index.min.js +1 -1
- package/lib/grid/src/grid.js +577 -487
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/grid/style/style.css +0 -1
- package/lib/grid/style/style.min.css +1 -1
- package/lib/index.common.js +3 -4
- package/lib/index.umd.js +9148 -17246
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/en-US.js +6 -2
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +6 -2
- package/lib/locale/lang/es-ES.js +5 -1
- package/lib/locale/lang/es-ES.min.js +1 -1
- package/lib/locale/lang/es-ES.umd.js +5 -1
- package/lib/locale/lang/hu-HU.js +5 -1
- package/lib/locale/lang/hu-HU.min.js +1 -1
- package/lib/locale/lang/hu-HU.umd.js +5 -1
- package/lib/locale/lang/ja-JP.js +5 -1
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +5 -1
- package/lib/locale/lang/ko-KR.js +5 -1
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +5 -1
- package/lib/locale/lang/pt-BR.js +5 -1
- package/lib/locale/lang/pt-BR.min.js +1 -1
- package/lib/locale/lang/pt-BR.umd.js +5 -1
- package/lib/locale/lang/ru-RU.js +5 -1
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +5 -1
- package/lib/locale/lang/uk-UA.js +5 -1
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +5 -1
- package/lib/locale/lang/vi-VN.js +5 -1
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/zh-CHT.js +5 -1
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +5 -1
- package/lib/locale/lang/zh-CN.js +5 -1
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +5 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/index.js +4 -4
- package/lib/table/index.min.js +1 -1
- package/lib/table/module/custom/mixin.js +53 -44
- package/lib/table/module/custom/mixin.min.js +1 -1
- package/lib/table/module/custom/panel.js +310 -239
- package/lib/table/module/custom/panel.min.js +1 -1
- package/lib/table/module/edit/mixin.js +434 -383
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/export-panel.js +136 -106
- package/lib/table/module/export/export-panel.min.js +1 -1
- package/lib/table/module/export/import-panel.js +75 -54
- package/lib/table/module/export/import-panel.min.js +1 -1
- package/lib/table/module/export/mixin.js +592 -597
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/export/util.js +6 -4
- package/lib/table/module/export/util.min.js +1 -1
- package/lib/table/module/filter/mixin.js +147 -118
- package/lib/table/module/filter/mixin.min.js +1 -1
- package/lib/table/module/filter/panel.js +86 -65
- package/lib/table/module/filter/panel.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +163 -151
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +125 -114
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/menu/panel.js +36 -34
- package/lib/table/module/menu/panel.min.js +1 -1
- package/lib/table/module/validator/mixin.js +225 -214
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/render/index.js +401 -297
- package/lib/table/render/index.min.js +1 -1
- package/lib/table/src/body.js +411 -349
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +470 -344
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/column.js +10 -10
- package/lib/table/src/column.min.js +1 -1
- package/lib/table/src/columnInfo.js +46 -55
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/footer.js +157 -132
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/group.js +1 -1
- package/lib/table/src/group.min.js +1 -1
- package/lib/table/src/header.js +170 -153
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +2770 -2491
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +33 -74
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +436 -395
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +143 -131
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +37 -48
- package/lib/table/style/style.min.css +1 -1
- package/lib/toolbar/index.js +3 -3
- package/lib/toolbar/index.min.js +1 -1
- package/lib/toolbar/src/toolbar.js +332 -284
- package/lib/toolbar/src/toolbar.min.js +1 -1
- package/lib/toolbar/style/style.css +0 -1
- package/lib/toolbar/style/style.min.css +1 -1
- package/lib/ui/index.js +50 -41
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/comp.js +2 -3
- package/lib/ui/src/comp.min.js +1 -1
- package/lib/ui/src/dom.js +29 -28
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +6 -4
- package/lib/ui/src/log.min.js +1 -1
- package/lib/ui/src/utils.js +7 -7
- package/lib/v-x-e-table/index.js +3 -4
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/vxe-colgroup/index.js +3 -4
- package/lib/vxe-colgroup/index.min.js +1 -1
- package/lib/vxe-column/index.js +3 -4
- package/lib/vxe-column/index.min.js +1 -1
- package/lib/vxe-grid/index.js +3 -4
- package/lib/vxe-grid/index.min.js +1 -1
- package/lib/vxe-grid/style/style.css +0 -1
- package/lib/vxe-grid/style/style.min.css +1 -1
- package/lib/vxe-table/index.js +3 -4
- package/lib/vxe-table/index.min.js +1 -1
- package/lib/vxe-table/style/style.css +37 -48
- package/lib/vxe-table/style/style.min.css +1 -1
- package/lib/vxe-toolbar/index.js +3 -4
- package/lib/vxe-toolbar/index.min.js +1 -1
- package/lib/vxe-toolbar/style/style.css +0 -1
- package/lib/vxe-toolbar/style/style.min.css +1 -1
- package/lib/vxe-ui/index.js +3 -4
- package/lib/vxe-ui/index.min.js +1 -1
- package/lib/vxe-v-x-e-table/index.js +3 -4
- package/lib/vxe-v-x-e-table/index.min.js +1 -1
- package/package.json +5 -4
- package/packages/grid/src/grid.ts +123 -61
- package/packages/locale/lang/en-US.ts +6 -2
- package/packages/locale/lang/es-ES.ts +5 -1
- package/packages/locale/lang/hu-HU.ts +5 -1
- package/packages/locale/lang/ja-JP.ts +5 -1
- package/packages/locale/lang/ko-KR.ts +5 -1
- package/packages/locale/lang/pt-BR.ts +5 -1
- package/packages/locale/lang/ru-RU.ts +5 -1
- package/packages/locale/lang/uk-UA.ts +5 -1
- package/packages/locale/lang/vi-VN.ts +5 -1
- package/packages/locale/lang/zh-CHT.ts +5 -1
- package/packages/locale/lang/zh-CN.ts +5 -1
- package/packages/table/module/custom/panel.ts +186 -175
- package/packages/table/module/edit/mixin.ts +34 -39
- package/packages/table/module/export/export-panel.ts +36 -4
- package/packages/table/module/export/import-panel.ts +29 -6
- package/packages/table/module/export/mixin.ts +11 -11
- package/packages/table/module/menu/mixin.ts +2 -2
- package/packages/table/module/validator/mixin.ts +4 -4
- package/packages/table/render/index.ts +20 -11
- package/packages/table/src/body.ts +1 -0
- package/packages/table/src/columnInfo.ts +3 -3
- package/packages/table/src/methods.ts +70 -55
- package/packages/table/src/props.ts +68 -15
- package/packages/table/src/table.ts +71 -26
- package/packages/table/src/util.ts +3 -2
- package/packages/toolbar/src/toolbar.ts +21 -7
- package/packages/ui/index.ts +3 -1
- package/styles/components/table.scss +82 -17
- package/types/all.d.ts +1 -0
- /package/es/{iconfont.1726453742001.ttf → iconfont.1728483486168.ttf} +0 -0
- /package/es/{iconfont.1726453742001.woff → iconfont.1728483486168.woff} +0 -0
- /package/es/{iconfont.1726453742001.woff2 → iconfont.1728483486168.woff2} +0 -0
- /package/lib/{iconfont.1726453742001.ttf → iconfont.1728483486168.ttf} +0 -0
- /package/lib/{iconfont.1726453742001.woff → iconfont.1728483486168.woff} +0 -0
- /package/lib/{iconfont.1726453742001.woff2 → iconfont.1728483486168.woff2} +0 -0
|
@@ -11,44 +11,40 @@ var _util = require("../../src/util");
|
|
|
11
11
|
var _dom = require("../../../ui/src/dom");
|
|
12
12
|
var _log = require("../../../ui/src/log");
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
20
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
21
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
22
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
|
-
var getConfig = _ui.VxeUI.getConfig,
|
|
25
|
-
renderer = _ui.VxeUI.renderer,
|
|
26
|
-
getI18n = _ui.VxeUI.getI18n;
|
|
14
|
+
const {
|
|
15
|
+
getConfig,
|
|
16
|
+
renderer,
|
|
17
|
+
getI18n
|
|
18
|
+
} = _ui.VxeUI;
|
|
27
19
|
function insertTreeRow(_vm, newRecords, isAppend) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
20
|
+
const {
|
|
21
|
+
tableFullTreeData,
|
|
22
|
+
afterFullData,
|
|
23
|
+
fullDataRowIdData,
|
|
24
|
+
fullAllDataRowIdData,
|
|
25
|
+
treeOpts
|
|
26
|
+
} = _vm;
|
|
27
|
+
const {
|
|
28
|
+
rowField,
|
|
29
|
+
parentField,
|
|
30
|
+
mapChildrenField
|
|
31
|
+
} = treeOpts;
|
|
32
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
33
|
+
const funcName = isAppend ? 'push' : 'unshift';
|
|
34
|
+
newRecords.forEach(item => {
|
|
35
|
+
const parentRowId = item[parentField];
|
|
36
|
+
const rowid = (0, _util.getRowid)(_vm, item);
|
|
37
|
+
const matchObj = parentRowId ? _xeUtils.default.findTree(tableFullTreeData, item => parentRowId === item[rowField], {
|
|
44
38
|
children: mapChildrenField
|
|
45
39
|
}) : null;
|
|
46
40
|
if (matchObj) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
const {
|
|
42
|
+
item: parentRow
|
|
43
|
+
} = matchObj;
|
|
44
|
+
const parentRest = fullAllDataRowIdData[(0, _util.getRowid)(_vm, parentRow)];
|
|
45
|
+
const parentLevel = parentRest ? parentRest.level : 0;
|
|
46
|
+
let parentChilds = parentRow[childrenField];
|
|
47
|
+
let mapChilds = parentRow[mapChildrenField];
|
|
52
48
|
if (!_xeUtils.default.isArray(parentChilds)) {
|
|
53
49
|
parentChilds = parentRow[childrenField] = [];
|
|
54
50
|
}
|
|
@@ -57,9 +53,9 @@ function insertTreeRow(_vm, newRecords, isAppend) {
|
|
|
57
53
|
}
|
|
58
54
|
parentChilds[funcName](item);
|
|
59
55
|
mapChilds[funcName](item);
|
|
60
|
-
|
|
56
|
+
const rest = {
|
|
61
57
|
row: item,
|
|
62
|
-
rowid
|
|
58
|
+
rowid,
|
|
63
59
|
seq: -1,
|
|
64
60
|
index: -1,
|
|
65
61
|
_index: -1,
|
|
@@ -71,16 +67,16 @@ function insertTreeRow(_vm, newRecords, isAppend) {
|
|
|
71
67
|
fullDataRowIdData[rowid] = rest;
|
|
72
68
|
fullAllDataRowIdData[rowid] = rest;
|
|
73
69
|
} else {
|
|
74
|
-
if (process.env.
|
|
70
|
+
if (process.env.NODE_ENV === 'development') {
|
|
75
71
|
if (parentRowId) {
|
|
76
72
|
(0, _log.warnLog)('vxe.error.unableInsert');
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
75
|
afterFullData[funcName](item);
|
|
80
76
|
tableFullTreeData[funcName](item);
|
|
81
|
-
|
|
77
|
+
const rest = {
|
|
82
78
|
row: item,
|
|
83
|
-
rowid
|
|
79
|
+
rowid,
|
|
84
80
|
seq: -1,
|
|
85
81
|
index: -1,
|
|
86
82
|
_index: -1,
|
|
@@ -89,41 +85,48 @@ function insertTreeRow(_vm, newRecords, isAppend) {
|
|
|
89
85
|
parent: null,
|
|
90
86
|
level: 0
|
|
91
87
|
};
|
|
92
|
-
fullDataRowIdData[rowid] =
|
|
93
|
-
fullAllDataRowIdData[rowid] =
|
|
88
|
+
fullDataRowIdData[rowid] = rest;
|
|
89
|
+
fullAllDataRowIdData[rowid] = rest;
|
|
94
90
|
}
|
|
95
91
|
});
|
|
96
92
|
}
|
|
97
93
|
function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
94
|
+
const {
|
|
95
|
+
tableFullTreeData,
|
|
96
|
+
mergeList,
|
|
97
|
+
afterFullData,
|
|
98
|
+
editStore,
|
|
99
|
+
tableFullData,
|
|
100
|
+
treeConfig,
|
|
101
|
+
fullDataRowIdData,
|
|
102
|
+
fullAllDataRowIdData,
|
|
103
|
+
treeOpts
|
|
104
|
+
} = _vm;
|
|
105
|
+
const {
|
|
106
|
+
transform,
|
|
107
|
+
rowField,
|
|
108
|
+
mapChildrenField
|
|
109
|
+
} = treeOpts;
|
|
110
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
111
111
|
if (!_xeUtils.default.isArray(records)) {
|
|
112
112
|
records = [records];
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
const newRecords = _vm.defineField(records.map(record => Object.assign(treeConfig && transform ? {
|
|
115
|
+
[mapChildrenField]: [],
|
|
116
|
+
[childrenField]: []
|
|
117
|
+
} : {}, record)));
|
|
117
118
|
if (_xeUtils.default.eqNull(row)) {
|
|
118
119
|
// 如果为虚拟树
|
|
119
120
|
if (treeConfig && transform) {
|
|
120
121
|
insertTreeRow(_vm, newRecords, false);
|
|
121
122
|
} else {
|
|
122
|
-
afterFullData.unshift
|
|
123
|
-
tableFullData.unshift
|
|
123
|
+
afterFullData.unshift(...newRecords);
|
|
124
|
+
tableFullData.unshift(...newRecords);
|
|
124
125
|
// 刷新单元格合并
|
|
125
|
-
mergeList.forEach(
|
|
126
|
-
|
|
126
|
+
mergeList.forEach(mergeItem => {
|
|
127
|
+
const {
|
|
128
|
+
row: mergeRowIndex
|
|
129
|
+
} = mergeItem;
|
|
127
130
|
if (mergeRowIndex > 0) {
|
|
128
131
|
mergeItem.row = mergeRowIndex + newRecords.length;
|
|
129
132
|
}
|
|
@@ -135,12 +138,14 @@ function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
|
|
|
135
138
|
if (treeConfig && transform) {
|
|
136
139
|
insertTreeRow(_vm, newRecords, true);
|
|
137
140
|
} else {
|
|
138
|
-
afterFullData.push
|
|
139
|
-
tableFullData.push
|
|
141
|
+
afterFullData.push(...newRecords);
|
|
142
|
+
tableFullData.push(...newRecords);
|
|
140
143
|
// 刷新单元格合并
|
|
141
|
-
mergeList.forEach(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
mergeList.forEach(mergeItem => {
|
|
145
|
+
const {
|
|
146
|
+
row: mergeRowIndex,
|
|
147
|
+
rowspan: mergeRowspan
|
|
148
|
+
} = mergeItem;
|
|
144
149
|
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
145
150
|
mergeItem.rowspan = mergeRowspan + newRecords.length;
|
|
146
151
|
}
|
|
@@ -149,36 +154,36 @@ function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
|
|
|
149
154
|
} else {
|
|
150
155
|
// 如果为虚拟树
|
|
151
156
|
if (treeConfig && transform) {
|
|
152
|
-
|
|
153
|
-
return row[rowField] === item[rowField];
|
|
154
|
-
}, {
|
|
157
|
+
const matchMapObj = _xeUtils.default.findTree(tableFullTreeData, item => row[rowField] === item[rowField], {
|
|
155
158
|
children: mapChildrenField
|
|
156
159
|
});
|
|
157
160
|
if (matchMapObj) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
const {
|
|
162
|
+
parent: parentRow
|
|
163
|
+
} = matchMapObj;
|
|
164
|
+
const parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData;
|
|
165
|
+
const parentRest = fullAllDataRowIdData[(0, _util.getRowid)(_vm, parentRow)];
|
|
166
|
+
const parentLevel = parentRest ? parentRest.level : 0;
|
|
167
|
+
newRecords.forEach((item, i) => {
|
|
168
|
+
const rowid = (0, _util.getRowid)(_vm, item);
|
|
169
|
+
if (process.env.NODE_ENV === 'development') {
|
|
165
170
|
if (item[treeOpts.parentField]) {
|
|
166
171
|
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
|
|
167
|
-
(0, _log.errLog)('vxe.error.errProp', [
|
|
172
|
+
(0, _log.errLog)('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`]);
|
|
168
173
|
}
|
|
169
174
|
}
|
|
170
175
|
}
|
|
171
176
|
if (parentRow) {
|
|
172
177
|
item[treeOpts.parentField] = parentRow[rowField];
|
|
173
178
|
}
|
|
174
|
-
|
|
179
|
+
let targetIndex = matchMapObj.index + i;
|
|
175
180
|
if (isInsertNextRow) {
|
|
176
181
|
targetIndex = targetIndex + 1;
|
|
177
182
|
}
|
|
178
183
|
parentMapChilds.splice(targetIndex, 0, item);
|
|
179
|
-
|
|
184
|
+
const rest = {
|
|
180
185
|
row: item,
|
|
181
|
-
rowid
|
|
186
|
+
rowid,
|
|
182
187
|
seq: -1,
|
|
183
188
|
index: -1,
|
|
184
189
|
_index: -1,
|
|
@@ -192,22 +197,20 @@ function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
|
|
|
192
197
|
});
|
|
193
198
|
// 源
|
|
194
199
|
if (parentRow) {
|
|
195
|
-
|
|
196
|
-
return row[rowField] === item[rowField];
|
|
197
|
-
}, {
|
|
200
|
+
const matchObj = _xeUtils.default.findTree(tableFullTreeData, item => row[rowField] === item[rowField], {
|
|
198
201
|
children: childrenField
|
|
199
202
|
});
|
|
200
203
|
if (matchObj) {
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
const parentChilds = matchObj.items;
|
|
205
|
+
let targetIndex = matchObj.index;
|
|
203
206
|
if (isInsertNextRow) {
|
|
204
207
|
targetIndex = targetIndex + 1;
|
|
205
208
|
}
|
|
206
|
-
parentChilds.splice
|
|
209
|
+
parentChilds.splice(targetIndex, 0, ...newRecords);
|
|
207
210
|
}
|
|
208
211
|
}
|
|
209
212
|
} else {
|
|
210
|
-
if (process.env.
|
|
213
|
+
if (process.env.NODE_ENV === 'development') {
|
|
211
214
|
(0, _log.warnLog)('vxe.error.unableInsert');
|
|
212
215
|
}
|
|
213
216
|
insertTreeRow(_vm, newRecords, true);
|
|
@@ -216,7 +219,7 @@ function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
|
|
|
216
219
|
if (treeConfig) {
|
|
217
220
|
throw new Error(getI18n('vxe.error.noTree', ['insert']));
|
|
218
221
|
}
|
|
219
|
-
|
|
222
|
+
let afIndex = -1;
|
|
220
223
|
// 如果是可视索引
|
|
221
224
|
if (_xeUtils.default.isNumber(row)) {
|
|
222
225
|
if (row < afterFullData.length) {
|
|
@@ -232,12 +235,14 @@ function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
|
|
|
232
235
|
if (afIndex === -1) {
|
|
233
236
|
throw new Error((0, _log.errLog)('vxe.error.unableInsert'));
|
|
234
237
|
}
|
|
235
|
-
afterFullData.splice
|
|
236
|
-
tableFullData.splice
|
|
238
|
+
afterFullData.splice(afIndex, 0, ...newRecords);
|
|
239
|
+
tableFullData.splice(_vm.findRowIndexOf(tableFullData, row), 0, ...newRecords);
|
|
237
240
|
// 刷新单元格合并
|
|
238
|
-
mergeList.forEach(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
mergeList.forEach(mergeItem => {
|
|
242
|
+
const {
|
|
243
|
+
row: mergeRowIndex,
|
|
244
|
+
rowspan: mergeRowspan
|
|
245
|
+
} = mergeItem;
|
|
241
246
|
if (mergeRowIndex > afIndex) {
|
|
242
247
|
mergeItem.row = mergeRowIndex + newRecords.length;
|
|
243
248
|
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
@@ -247,13 +252,15 @@ function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
|
|
|
247
252
|
}
|
|
248
253
|
}
|
|
249
254
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
255
|
+
const {
|
|
256
|
+
insertList,
|
|
257
|
+
insertMaps
|
|
258
|
+
} = editStore;
|
|
259
|
+
newRecords.forEach(newRow => {
|
|
260
|
+
const rowid = (0, _util.getRowid)(_vm, newRow);
|
|
254
261
|
insertMaps[rowid] = newRow;
|
|
255
262
|
});
|
|
256
|
-
insertList.unshift
|
|
263
|
+
insertList.unshift(...newRecords);
|
|
257
264
|
_vm.cacheRowMap();
|
|
258
265
|
_vm.updateScrollYStatus();
|
|
259
266
|
_vm.handleTableData(treeConfig && transform);
|
|
@@ -265,10 +272,10 @@ function handleInsertRowAt(_vm, records, row, isInsertNextRow) {
|
|
|
265
272
|
if (_vm.scrollYLoad) {
|
|
266
273
|
_vm.updateScrollYSpace();
|
|
267
274
|
}
|
|
268
|
-
return _vm.$nextTick().then(
|
|
275
|
+
return _vm.$nextTick().then(() => {
|
|
269
276
|
_vm.updateCellAreas();
|
|
270
277
|
return _vm.recalculate();
|
|
271
|
-
}).then(
|
|
278
|
+
}).then(() => {
|
|
272
279
|
return {
|
|
273
280
|
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
274
281
|
rows: newRecords
|
|
@@ -282,7 +289,7 @@ var _default = exports.default = {
|
|
|
282
289
|
*
|
|
283
290
|
* @param {*} records
|
|
284
291
|
*/
|
|
285
|
-
_insert
|
|
292
|
+
_insert(records) {
|
|
286
293
|
return handleInsertRowAt(this, records, null);
|
|
287
294
|
},
|
|
288
295
|
/**
|
|
@@ -294,10 +301,10 @@ var _default = exports.default = {
|
|
|
294
301
|
* @param {Row} row 指定行
|
|
295
302
|
* @returns
|
|
296
303
|
*/
|
|
297
|
-
_insertAt
|
|
304
|
+
_insertAt(records, row) {
|
|
298
305
|
return handleInsertRowAt(this, records, row);
|
|
299
306
|
},
|
|
300
|
-
_insertNextAt
|
|
307
|
+
_insertNextAt(records, row) {
|
|
301
308
|
return handleInsertRowAt(this, records, row, true);
|
|
302
309
|
},
|
|
303
310
|
/**
|
|
@@ -306,43 +313,50 @@ var _default = exports.default = {
|
|
|
306
313
|
* 如果传 rows 则删除多行
|
|
307
314
|
* 如果为空则删除所有
|
|
308
315
|
*/
|
|
309
|
-
_remove
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
tableFullData
|
|
313
|
-
tableFullTreeData
|
|
314
|
-
treeConfig
|
|
315
|
-
mergeList
|
|
316
|
-
editStore
|
|
317
|
-
checkboxOpts
|
|
318
|
-
selectCheckboxMaps
|
|
319
|
-
isInsertByRow
|
|
320
|
-
treeOpts
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
316
|
+
_remove(rows) {
|
|
317
|
+
const {
|
|
318
|
+
afterFullData,
|
|
319
|
+
tableFullData,
|
|
320
|
+
tableFullTreeData,
|
|
321
|
+
treeConfig,
|
|
322
|
+
mergeList,
|
|
323
|
+
editStore,
|
|
324
|
+
checkboxOpts,
|
|
325
|
+
selectCheckboxMaps,
|
|
326
|
+
isInsertByRow,
|
|
327
|
+
treeOpts
|
|
328
|
+
} = this;
|
|
329
|
+
const {
|
|
330
|
+
transform,
|
|
331
|
+
mapChildrenField
|
|
332
|
+
} = treeOpts;
|
|
333
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
334
|
+
const {
|
|
335
|
+
actived,
|
|
336
|
+
removeList,
|
|
337
|
+
insertList,
|
|
338
|
+
insertMaps
|
|
339
|
+
} = editStore;
|
|
340
|
+
const {
|
|
341
|
+
checkField
|
|
342
|
+
} = checkboxOpts;
|
|
343
|
+
let delList = [];
|
|
330
344
|
if (!rows) {
|
|
331
345
|
rows = tableFullData;
|
|
332
346
|
} else if (!_xeUtils.default.isArray(rows)) {
|
|
333
347
|
rows = [rows];
|
|
334
348
|
}
|
|
335
349
|
// 如果是新增,则保存记录
|
|
336
|
-
rows.forEach(
|
|
350
|
+
rows.forEach(row => {
|
|
337
351
|
if (!isInsertByRow(row)) {
|
|
338
352
|
removeList.push(row);
|
|
339
353
|
}
|
|
340
354
|
});
|
|
341
355
|
// 如果绑定了多选属性,则更新状态
|
|
342
356
|
if (!checkField) {
|
|
343
|
-
|
|
344
|
-
rows.forEach(
|
|
345
|
-
|
|
357
|
+
const selectRowMaps = Object.assign({}, selectCheckboxMaps);
|
|
358
|
+
rows.forEach(row => {
|
|
359
|
+
const rowid = (0, _util.getRowid)(this, row);
|
|
346
360
|
if (selectRowMaps[rowid]) {
|
|
347
361
|
delete selectRowMaps[rowid];
|
|
348
362
|
}
|
|
@@ -358,43 +372,41 @@ var _default = exports.default = {
|
|
|
358
372
|
} else {
|
|
359
373
|
// 如果为虚拟树
|
|
360
374
|
if (treeConfig && transform) {
|
|
361
|
-
rows.forEach(
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return rowid === (0, _util.getRowid)(_this, item);
|
|
365
|
-
}, {
|
|
375
|
+
rows.forEach(row => {
|
|
376
|
+
const rowid = (0, _util.getRowid)(this, row);
|
|
377
|
+
const matchMapObj = _xeUtils.default.findTree(tableFullTreeData, item => rowid === (0, _util.getRowid)(this, item), {
|
|
366
378
|
children: mapChildrenField
|
|
367
379
|
});
|
|
368
380
|
if (matchMapObj) {
|
|
369
|
-
|
|
381
|
+
const rItems = matchMapObj.items.splice(matchMapObj.index, 1);
|
|
370
382
|
delList.push(rItems[0]);
|
|
371
383
|
}
|
|
372
|
-
|
|
373
|
-
return rowid === (0, _util.getRowid)(_this, item);
|
|
374
|
-
}, {
|
|
384
|
+
const matchObj = _xeUtils.default.findTree(tableFullTreeData, item => rowid === (0, _util.getRowid)(this, item), {
|
|
375
385
|
children: childrenField
|
|
376
386
|
});
|
|
377
387
|
if (matchObj) {
|
|
378
388
|
matchObj.items.splice(matchObj.index, 1);
|
|
379
389
|
}
|
|
380
|
-
|
|
390
|
+
const afIndex = this.findRowIndexOf(afterFullData, row);
|
|
381
391
|
if (afIndex > -1) {
|
|
382
392
|
afterFullData.splice(afIndex, 1);
|
|
383
393
|
}
|
|
384
394
|
});
|
|
385
395
|
} else {
|
|
386
|
-
rows.forEach(
|
|
387
|
-
|
|
396
|
+
rows.forEach(row => {
|
|
397
|
+
const tfIndex = this.findRowIndexOf(tableFullData, row);
|
|
388
398
|
if (tfIndex > -1) {
|
|
389
|
-
|
|
399
|
+
const rItems = tableFullData.splice(tfIndex, 1);
|
|
390
400
|
delList.push(rItems[0]);
|
|
391
401
|
}
|
|
392
|
-
|
|
402
|
+
const afIndex = this.findRowIndexOf(afterFullData, row);
|
|
393
403
|
if (afIndex > -1) {
|
|
394
404
|
// 刷新单元格合并
|
|
395
|
-
mergeList.forEach(
|
|
396
|
-
|
|
397
|
-
|
|
405
|
+
mergeList.forEach(mergeItem => {
|
|
406
|
+
const {
|
|
407
|
+
row: mergeRowIndex,
|
|
408
|
+
rowspan: mergeRowspan
|
|
409
|
+
} = mergeItem;
|
|
398
410
|
if (mergeRowIndex > afIndex) {
|
|
399
411
|
mergeItem.row = mergeRowIndex - 1;
|
|
400
412
|
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
@@ -411,9 +423,9 @@ var _default = exports.default = {
|
|
|
411
423
|
this.clearEdit();
|
|
412
424
|
}
|
|
413
425
|
// 从新增中移除已删除的数据
|
|
414
|
-
rows.forEach(
|
|
415
|
-
|
|
416
|
-
|
|
426
|
+
rows.forEach(row => {
|
|
427
|
+
const rowid = (0, _util.getRowid)(this, row);
|
|
428
|
+
const iIndex = this.findRowIndexOf(insertList, row);
|
|
417
429
|
if (iIndex > -1) {
|
|
418
430
|
insertList.splice(iIndex, 1);
|
|
419
431
|
}
|
|
@@ -429,10 +441,10 @@ var _default = exports.default = {
|
|
|
429
441
|
if (this.scrollYLoad) {
|
|
430
442
|
this.updateScrollYSpace();
|
|
431
443
|
}
|
|
432
|
-
return this.$nextTick().then(
|
|
433
|
-
|
|
434
|
-
return
|
|
435
|
-
}).then(
|
|
444
|
+
return this.$nextTick().then(() => {
|
|
445
|
+
this.updateCellAreas();
|
|
446
|
+
return this.recalculate();
|
|
447
|
+
}).then(() => {
|
|
436
448
|
return {
|
|
437
449
|
row: delList.length ? delList[delList.length - 1] : null,
|
|
438
450
|
rows: delList
|
|
@@ -442,66 +454,61 @@ var _default = exports.default = {
|
|
|
442
454
|
/**
|
|
443
455
|
* 删除复选框选中的数据
|
|
444
456
|
*/
|
|
445
|
-
_removeCheckboxRow
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
_this2.clearCheckboxRow();
|
|
457
|
+
_removeCheckboxRow() {
|
|
458
|
+
return this.remove(this.getCheckboxRecords()).then(params => {
|
|
459
|
+
this.clearCheckboxRow();
|
|
449
460
|
return params;
|
|
450
461
|
});
|
|
451
462
|
},
|
|
452
463
|
/**
|
|
453
464
|
* 删除单选框选中的数据
|
|
454
465
|
*/
|
|
455
|
-
_removeRadioRow
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
_this3.clearRadioRow();
|
|
466
|
+
_removeRadioRow() {
|
|
467
|
+
const radioRecord = this.getRadioRecord();
|
|
468
|
+
return this.remove(radioRecord || []).then(params => {
|
|
469
|
+
this.clearRadioRow();
|
|
460
470
|
return params;
|
|
461
471
|
});
|
|
462
472
|
},
|
|
463
473
|
/**
|
|
464
474
|
* 删除当前行选中的数据
|
|
465
475
|
*/
|
|
466
|
-
_removeCurrentRow
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
_this4.clearCurrentRow();
|
|
476
|
+
_removeCurrentRow() {
|
|
477
|
+
const currentRecord = this.getCurrentRecord();
|
|
478
|
+
return this.remove(currentRecord || []).then(params => {
|
|
479
|
+
this.clearCurrentRow();
|
|
471
480
|
return params;
|
|
472
481
|
});
|
|
473
482
|
},
|
|
474
483
|
/**
|
|
475
484
|
* 获取表格数据集,包含新增、删除、修改
|
|
476
485
|
*/
|
|
477
|
-
_getRecordset
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
var delRecords = removeRecords.concat(pendingRecords);
|
|
486
|
+
_getRecordset() {
|
|
487
|
+
const removeRecords = this.getRemoveRecords();
|
|
488
|
+
const pendingRecords = this.getPendingRecords();
|
|
489
|
+
const delRecords = removeRecords.concat(pendingRecords);
|
|
482
490
|
// 如果已经被删除,则无需放到更新数组
|
|
483
|
-
|
|
484
|
-
return !delRecords.some(
|
|
485
|
-
return _this5.eqRow(item, row);
|
|
486
|
-
});
|
|
491
|
+
const updateRecords = this.getUpdateRecords().filter(row => {
|
|
492
|
+
return !delRecords.some(item => this.eqRow(item, row));
|
|
487
493
|
});
|
|
488
494
|
return {
|
|
489
495
|
insertRecords: this.getInsertRecords(),
|
|
490
|
-
removeRecords
|
|
491
|
-
updateRecords
|
|
492
|
-
pendingRecords
|
|
496
|
+
removeRecords,
|
|
497
|
+
updateRecords,
|
|
498
|
+
pendingRecords
|
|
493
499
|
};
|
|
494
500
|
},
|
|
495
501
|
/**
|
|
496
502
|
* 获取新增的临时数据
|
|
497
503
|
*/
|
|
498
|
-
_getInsertRecords
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
504
|
+
_getInsertRecords() {
|
|
505
|
+
const {
|
|
506
|
+
fullAllDataRowIdData
|
|
507
|
+
} = this;
|
|
508
|
+
const insertList = this.editStore.insertList;
|
|
509
|
+
const insertRecords = [];
|
|
510
|
+
insertList.forEach(row => {
|
|
511
|
+
const rowid = (0, _util.getRowid)(this, row);
|
|
505
512
|
if (fullAllDataRowIdData[rowid]) {
|
|
506
513
|
insertRecords.push(row);
|
|
507
514
|
}
|
|
@@ -511,7 +518,7 @@ var _default = exports.default = {
|
|
|
511
518
|
/**
|
|
512
519
|
* 获取已删除的数据
|
|
513
520
|
*/
|
|
514
|
-
_getRemoveRecords
|
|
521
|
+
_getRemoveRecords() {
|
|
515
522
|
return this.editStore.removeList;
|
|
516
523
|
},
|
|
517
524
|
/**
|
|
@@ -519,55 +526,66 @@ var _default = exports.default = {
|
|
|
519
526
|
* 只精准匹配 row 的更改
|
|
520
527
|
* 如果是树表格,子节点更改状态不会影响父节点的更新状态
|
|
521
528
|
*/
|
|
522
|
-
_getUpdateRecords
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
+
_getUpdateRecords() {
|
|
530
|
+
const {
|
|
531
|
+
keepSource,
|
|
532
|
+
tableFullData,
|
|
533
|
+
isUpdateByRow,
|
|
534
|
+
treeConfig,
|
|
535
|
+
treeOpts,
|
|
536
|
+
editStore
|
|
537
|
+
} = this;
|
|
529
538
|
if (keepSource) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
539
|
+
const {
|
|
540
|
+
actived
|
|
541
|
+
} = editStore;
|
|
542
|
+
const {
|
|
543
|
+
row,
|
|
544
|
+
column
|
|
545
|
+
} = actived;
|
|
533
546
|
if (row || column) {
|
|
534
547
|
this._syncActivedCell();
|
|
535
548
|
}
|
|
536
549
|
if (treeConfig) {
|
|
537
|
-
return _xeUtils.default.filterTree(tableFullData,
|
|
538
|
-
return isUpdateByRow(row);
|
|
539
|
-
}, treeOpts);
|
|
550
|
+
return _xeUtils.default.filterTree(tableFullData, row => isUpdateByRow(row), treeOpts);
|
|
540
551
|
}
|
|
541
|
-
return tableFullData.filter(
|
|
542
|
-
return isUpdateByRow(row);
|
|
543
|
-
});
|
|
552
|
+
return tableFullData.filter(row => isUpdateByRow(row));
|
|
544
553
|
}
|
|
545
554
|
return [];
|
|
546
555
|
},
|
|
547
556
|
/**
|
|
548
557
|
* 处理激活编辑
|
|
549
558
|
*/
|
|
550
|
-
handleEdit
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
editOpts
|
|
554
|
-
tableColumn
|
|
555
|
-
editConfig
|
|
556
|
-
mouseConfig
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
559
|
+
handleEdit(params, evnt) {
|
|
560
|
+
const {
|
|
561
|
+
editStore,
|
|
562
|
+
editOpts,
|
|
563
|
+
tableColumn,
|
|
564
|
+
editConfig,
|
|
565
|
+
mouseConfig
|
|
566
|
+
} = this;
|
|
567
|
+
const {
|
|
568
|
+
mode
|
|
569
|
+
} = editOpts;
|
|
570
|
+
const {
|
|
571
|
+
actived,
|
|
572
|
+
focused
|
|
573
|
+
} = editStore;
|
|
574
|
+
const {
|
|
575
|
+
row,
|
|
576
|
+
column
|
|
577
|
+
} = params;
|
|
578
|
+
const {
|
|
579
|
+
editRender
|
|
580
|
+
} = column;
|
|
581
|
+
const cell = params.cell = params.cell || this.getCellElement(row, column);
|
|
582
|
+
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
|
|
565
583
|
if (cell && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(editRender)) {
|
|
566
584
|
// 激活编辑
|
|
567
585
|
if (!this.hasPendingByRow(row)) {
|
|
568
586
|
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
|
|
569
587
|
// 判断是否禁用编辑
|
|
570
|
-
|
|
588
|
+
let type = 'edit-disabled';
|
|
571
589
|
if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), {
|
|
572
590
|
$table: this,
|
|
573
591
|
$grid: this.$xegrid
|
|
@@ -587,51 +605,39 @@ var _default = exports.default = {
|
|
|
587
605
|
actived.row = row;
|
|
588
606
|
actived.column = column;
|
|
589
607
|
if (mode === 'row') {
|
|
590
|
-
tableColumn.forEach(
|
|
591
|
-
return _this7._getColumnModel(row, column);
|
|
592
|
-
});
|
|
608
|
+
tableColumn.forEach(column => this._getColumnModel(row, column));
|
|
593
609
|
} else {
|
|
594
610
|
this._getColumnModel(row, column);
|
|
595
611
|
}
|
|
596
|
-
|
|
597
|
-
this.$nextTick(
|
|
598
|
-
|
|
612
|
+
const afterEditMethod = editOpts.afterEditMethod;
|
|
613
|
+
this.$nextTick(() => {
|
|
614
|
+
this.handleFocus(params, evnt);
|
|
599
615
|
if (afterEditMethod) {
|
|
600
616
|
afterEditMethod(Object.assign(Object.assign({}, params), {
|
|
601
|
-
$table:
|
|
602
|
-
$grid:
|
|
617
|
+
$table: this,
|
|
618
|
+
$grid: this.$xegrid
|
|
603
619
|
}));
|
|
604
620
|
}
|
|
605
621
|
});
|
|
606
622
|
}
|
|
607
|
-
this.emitEvent(type,
|
|
608
|
-
row: row,
|
|
609
|
-
rowIndex: this.getRowIndex(row),
|
|
610
|
-
$rowIndex: this.getVMRowIndex(row),
|
|
611
|
-
column: column,
|
|
612
|
-
columnIndex: this.getColumnIndex(column),
|
|
613
|
-
$columnIndex: this.getVMColumnIndex(column)
|
|
614
|
-
}, evnt);
|
|
623
|
+
this.emitEvent(type, params, evnt);
|
|
615
624
|
// v4已废弃
|
|
616
625
|
if (type === 'edit-activated') {
|
|
617
|
-
this.emitEvent('edit-actived',
|
|
618
|
-
row: row,
|
|
619
|
-
rowIndex: this.getRowIndex(row),
|
|
620
|
-
$rowIndex: this.getVMRowIndex(row),
|
|
621
|
-
column: column,
|
|
622
|
-
columnIndex: this.getColumnIndex(column),
|
|
623
|
-
$columnIndex: this.getVMColumnIndex(column)
|
|
624
|
-
}, evnt);
|
|
626
|
+
this.emitEvent('edit-actived', params, evnt);
|
|
625
627
|
}
|
|
626
628
|
} else {
|
|
627
|
-
|
|
629
|
+
const {
|
|
630
|
+
column: oldColumn
|
|
631
|
+
} = actived;
|
|
628
632
|
if (mouseConfig) {
|
|
629
633
|
this.clearSelected(evnt);
|
|
630
634
|
this.clearCellAreas(evnt);
|
|
631
635
|
this.clearCopyCellArea(evnt);
|
|
632
636
|
}
|
|
633
637
|
if (oldColumn !== column) {
|
|
634
|
-
|
|
638
|
+
const {
|
|
639
|
+
model: oldModel
|
|
640
|
+
} = oldColumn;
|
|
635
641
|
if (oldModel.update) {
|
|
636
642
|
(0, _util.setCellValue)(row, oldColumn, oldModel.value);
|
|
637
643
|
}
|
|
@@ -640,8 +646,8 @@ var _default = exports.default = {
|
|
|
640
646
|
column.renderHeight = cell.offsetHeight;
|
|
641
647
|
actived.args = params;
|
|
642
648
|
actived.column = column;
|
|
643
|
-
setTimeout(
|
|
644
|
-
|
|
649
|
+
setTimeout(() => {
|
|
650
|
+
this.handleFocus(params, evnt);
|
|
645
651
|
});
|
|
646
652
|
}
|
|
647
653
|
focused.column = null;
|
|
@@ -654,46 +660,53 @@ var _default = exports.default = {
|
|
|
654
660
|
/**
|
|
655
661
|
* @deprecated
|
|
656
662
|
*/
|
|
657
|
-
handleActived
|
|
663
|
+
handleActived(params, evnt) {
|
|
658
664
|
return this.handleEdit(params, evnt);
|
|
659
665
|
},
|
|
660
|
-
_getColumnModel
|
|
661
|
-
|
|
662
|
-
|
|
666
|
+
_getColumnModel(row, column) {
|
|
667
|
+
const {
|
|
668
|
+
model,
|
|
669
|
+
editRender
|
|
670
|
+
} = column;
|
|
663
671
|
if (editRender) {
|
|
664
672
|
model.value = (0, _util.getCellValue)(row, column);
|
|
665
673
|
model.update = false;
|
|
666
674
|
}
|
|
667
675
|
},
|
|
668
|
-
_setColumnModel
|
|
669
|
-
|
|
670
|
-
|
|
676
|
+
_setColumnModel(row, column) {
|
|
677
|
+
const {
|
|
678
|
+
model,
|
|
679
|
+
editRender
|
|
680
|
+
} = column;
|
|
671
681
|
if (editRender && model.update) {
|
|
672
682
|
(0, _util.setCellValue)(row, column, model.value);
|
|
673
683
|
model.update = false;
|
|
674
684
|
model.value = null;
|
|
675
685
|
}
|
|
676
686
|
},
|
|
677
|
-
_syncActivedCell
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
editStore
|
|
681
|
-
editOpts
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
687
|
+
_syncActivedCell() {
|
|
688
|
+
const {
|
|
689
|
+
tableColumn,
|
|
690
|
+
editStore,
|
|
691
|
+
editOpts
|
|
692
|
+
} = this;
|
|
693
|
+
const {
|
|
694
|
+
actived
|
|
695
|
+
} = editStore;
|
|
696
|
+
const {
|
|
697
|
+
row,
|
|
698
|
+
column
|
|
699
|
+
} = actived;
|
|
685
700
|
if (row || column) {
|
|
686
701
|
if (editOpts.mode === 'row') {
|
|
687
|
-
tableColumn.forEach(
|
|
688
|
-
return _this8._setColumnModel(row, column);
|
|
689
|
-
});
|
|
702
|
+
tableColumn.forEach(column => this._setColumnModel(row, column));
|
|
690
703
|
} else {
|
|
691
704
|
this._setColumnModel(row, column);
|
|
692
705
|
}
|
|
693
706
|
}
|
|
694
707
|
},
|
|
695
|
-
_clearActived
|
|
696
|
-
if (process.env.
|
|
708
|
+
_clearActived(evnt) {
|
|
709
|
+
if (process.env.NODE_ENV === 'development') {
|
|
697
710
|
(0, _log.warnLog)('vxe.error.delFunc', ['clearActived', 'clearEdit']);
|
|
698
711
|
}
|
|
699
712
|
// 即将废弃
|
|
@@ -702,12 +715,18 @@ var _default = exports.default = {
|
|
|
702
715
|
/**
|
|
703
716
|
* 清除激活的编辑
|
|
704
717
|
*/
|
|
705
|
-
_clearEdit
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
718
|
+
_clearEdit(evnt) {
|
|
719
|
+
const {
|
|
720
|
+
editStore
|
|
721
|
+
} = this;
|
|
722
|
+
const {
|
|
723
|
+
actived,
|
|
724
|
+
focused
|
|
725
|
+
} = editStore;
|
|
726
|
+
const {
|
|
727
|
+
row,
|
|
728
|
+
column
|
|
729
|
+
} = actived;
|
|
711
730
|
if (row || column) {
|
|
712
731
|
this._syncActivedCell();
|
|
713
732
|
actived.args = null;
|
|
@@ -715,10 +734,10 @@ var _default = exports.default = {
|
|
|
715
734
|
actived.column = null;
|
|
716
735
|
this.updateFooter();
|
|
717
736
|
this.emitEvent('edit-closed', {
|
|
718
|
-
row
|
|
737
|
+
row,
|
|
719
738
|
rowIndex: this.getRowIndex(row),
|
|
720
739
|
$rowIndex: this.getVMRowIndex(row),
|
|
721
|
-
column
|
|
740
|
+
column,
|
|
722
741
|
columnIndex: this.getColumnIndex(column),
|
|
723
742
|
$columnIndex: this.getVMColumnIndex(column)
|
|
724
743
|
}, evnt);
|
|
@@ -732,27 +751,33 @@ var _default = exports.default = {
|
|
|
732
751
|
}
|
|
733
752
|
return this.$nextTick();
|
|
734
753
|
},
|
|
735
|
-
_getActiveRecord
|
|
736
|
-
if (process.env.
|
|
754
|
+
_getActiveRecord() {
|
|
755
|
+
if (process.env.NODE_ENV === 'development') {
|
|
737
756
|
(0, _log.warnLog)('vxe.error.delFunc', ['getActiveRecord', 'getEditRecord']);
|
|
738
757
|
}
|
|
739
758
|
// 即将废弃
|
|
740
759
|
return this.getEditRecord();
|
|
741
760
|
},
|
|
742
|
-
_getEditRecord
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
761
|
+
_getEditRecord() {
|
|
762
|
+
const {
|
|
763
|
+
$el,
|
|
764
|
+
editStore,
|
|
765
|
+
afterFullData
|
|
766
|
+
} = this;
|
|
767
|
+
const {
|
|
768
|
+
actived
|
|
769
|
+
} = editStore;
|
|
770
|
+
const {
|
|
771
|
+
args,
|
|
772
|
+
row
|
|
773
|
+
} = actived;
|
|
749
774
|
if (args && this.findRowIndexOf(afterFullData, row) > -1 && $el.querySelectorAll('.vxe-body--column.col--active').length) {
|
|
750
775
|
return Object.assign({}, args);
|
|
751
776
|
}
|
|
752
777
|
return null;
|
|
753
778
|
},
|
|
754
|
-
_isActiveByRow
|
|
755
|
-
if (process.env.
|
|
779
|
+
_isActiveByRow(row) {
|
|
780
|
+
if (process.env.NODE_ENV === 'development') {
|
|
756
781
|
(0, _log.warnLog)('vxe.error.delFunc', ['isActiveByRow', 'isEditByRow']);
|
|
757
782
|
}
|
|
758
783
|
// 即将废弃
|
|
@@ -762,35 +787,45 @@ var _default = exports.default = {
|
|
|
762
787
|
* 判断行是否为激活编辑状态
|
|
763
788
|
* @param {Row} row 行对象
|
|
764
789
|
*/
|
|
765
|
-
_isEditByRow
|
|
790
|
+
_isEditByRow(row) {
|
|
766
791
|
return this.editStore.actived.row === row;
|
|
767
792
|
},
|
|
768
793
|
/**
|
|
769
794
|
* 处理聚焦
|
|
770
795
|
*/
|
|
771
|
-
handleFocus
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
796
|
+
handleFocus(params) {
|
|
797
|
+
const {
|
|
798
|
+
editOpts
|
|
799
|
+
} = this;
|
|
800
|
+
const {
|
|
801
|
+
row,
|
|
802
|
+
column,
|
|
803
|
+
cell
|
|
804
|
+
} = params;
|
|
805
|
+
const {
|
|
806
|
+
editRender
|
|
807
|
+
} = column;
|
|
776
808
|
if ((0, _utils.isEnableConf)(editRender)) {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
if (
|
|
793
|
-
inputElem.
|
|
809
|
+
const compRender = renderer.get(editRender.name);
|
|
810
|
+
let autoFocus = editRender.autofocus || editRender.autoFocus;
|
|
811
|
+
let autoSelect = editRender.autoSelect || editRender.autoselect;
|
|
812
|
+
let inputElem;
|
|
813
|
+
// 是否启用聚焦
|
|
814
|
+
if (editOpts.autoFocus) {
|
|
815
|
+
if (!autoFocus && compRender) {
|
|
816
|
+
autoFocus = compRender.tableAutoFocus || compRender.tableAutofocus || compRender.autoFocus || compRender.autofocus;
|
|
817
|
+
}
|
|
818
|
+
if (!autoSelect && compRender) {
|
|
819
|
+
autoSelect = compRender.tableAutoSelect || compRender.autoSelect || compRender.autoselect;
|
|
820
|
+
}
|
|
821
|
+
// 如果指定了聚焦 class
|
|
822
|
+
if (_xeUtils.default.isFunction(autoFocus)) {
|
|
823
|
+
inputElem = autoFocus.call(this, params);
|
|
824
|
+
} else if (autoFocus) {
|
|
825
|
+
inputElem = cell.querySelector(autoFocus);
|
|
826
|
+
if (inputElem) {
|
|
827
|
+
inputElem.focus();
|
|
828
|
+
}
|
|
794
829
|
}
|
|
795
830
|
}
|
|
796
831
|
if (inputElem) {
|
|
@@ -799,19 +834,24 @@ var _default = exports.default = {
|
|
|
799
834
|
} else {
|
|
800
835
|
// 保持一致行为,光标移到末端
|
|
801
836
|
if (_dom.browse.msie) {
|
|
802
|
-
|
|
837
|
+
const textRange = inputElem.createTextRange();
|
|
803
838
|
textRange.collapse(false);
|
|
804
839
|
textRange.select();
|
|
805
840
|
}
|
|
806
841
|
}
|
|
807
842
|
} else {
|
|
808
|
-
//
|
|
809
|
-
|
|
843
|
+
// 是否自动定位
|
|
844
|
+
if (editOpts.autoPos) {
|
|
845
|
+
if (!column.fixed) {
|
|
846
|
+
// 显示到可视区中
|
|
847
|
+
this.scrollToRow(row, column);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
810
850
|
}
|
|
811
851
|
}
|
|
812
852
|
},
|
|
813
|
-
_setActiveRow
|
|
814
|
-
if (process.env.
|
|
853
|
+
_setActiveRow(row) {
|
|
854
|
+
if (process.env.NODE_ENV === 'development') {
|
|
815
855
|
(0, _log.warnLog)('vxe.error.delFunc', ['setActiveRow', 'setEditRow']);
|
|
816
856
|
}
|
|
817
857
|
// 即将废弃
|
|
@@ -820,17 +860,15 @@ var _default = exports.default = {
|
|
|
820
860
|
/**
|
|
821
861
|
* 激活行编辑
|
|
822
862
|
*/
|
|
823
|
-
_setEditRow
|
|
824
|
-
|
|
825
|
-
return (0, _utils.isEnableConf)(column.editRender);
|
|
826
|
-
});
|
|
863
|
+
_setEditRow(row, fieldOrColumn) {
|
|
864
|
+
let column = _xeUtils.default.find(this.visibleColumn, column => (0, _utils.isEnableConf)(column.editRender));
|
|
827
865
|
if (fieldOrColumn) {
|
|
828
866
|
column = _xeUtils.default.isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
829
867
|
}
|
|
830
868
|
return this.setEditCell(row, column);
|
|
831
869
|
},
|
|
832
|
-
_setActiveCell
|
|
833
|
-
if (process.env.
|
|
870
|
+
_setActiveCell(row, fieldOrColumn) {
|
|
871
|
+
if (process.env.NODE_ENV === 'development') {
|
|
834
872
|
(0, _log.warnLog)('vxe.error.delFunc', ['setActiveCell', 'setEditCell']);
|
|
835
873
|
}
|
|
836
874
|
// 即将废弃
|
|
@@ -839,23 +877,24 @@ var _default = exports.default = {
|
|
|
839
877
|
/**
|
|
840
878
|
* 激活单元格编辑
|
|
841
879
|
*/
|
|
842
|
-
_setEditCell
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
880
|
+
_setEditCell(row, fieldOrColumn) {
|
|
881
|
+
const {
|
|
882
|
+
editConfig
|
|
883
|
+
} = this;
|
|
884
|
+
const column = _xeUtils.default.isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
846
885
|
if (row && column && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(column.editRender)) {
|
|
847
|
-
return this.scrollToRow(row, true).then(
|
|
848
|
-
|
|
886
|
+
return this.scrollToRow(row, true).then(() => {
|
|
887
|
+
const cell = this.getCellElement(row, column);
|
|
849
888
|
if (cell) {
|
|
850
|
-
|
|
851
|
-
row
|
|
852
|
-
rowIndex:
|
|
853
|
-
column
|
|
854
|
-
columnIndex:
|
|
855
|
-
cell
|
|
856
|
-
$table:
|
|
889
|
+
this.handleEdit({
|
|
890
|
+
row,
|
|
891
|
+
rowIndex: this.getRowIndex(row),
|
|
892
|
+
column,
|
|
893
|
+
columnIndex: this.getColumnIndex(column),
|
|
894
|
+
cell,
|
|
895
|
+
$table: this
|
|
857
896
|
});
|
|
858
|
-
|
|
897
|
+
this.lastCallTime = Date.now();
|
|
859
898
|
}
|
|
860
899
|
});
|
|
861
900
|
}
|
|
@@ -864,21 +903,23 @@ var _default = exports.default = {
|
|
|
864
903
|
/**
|
|
865
904
|
* 只对 trigger=dblclick 有效,选中单元格
|
|
866
905
|
*/
|
|
867
|
-
_setSelectCell
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
906
|
+
_setSelectCell(row, fieldOrColumn) {
|
|
907
|
+
const {
|
|
908
|
+
tableData,
|
|
909
|
+
editOpts,
|
|
910
|
+
visibleColumn
|
|
911
|
+
} = this;
|
|
912
|
+
const column = _xeUtils.default.isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
872
913
|
if (row && column && editOpts.trigger !== 'manual') {
|
|
873
|
-
|
|
914
|
+
const rowIndex = this.findRowIndexOf(tableData, row);
|
|
874
915
|
if (rowIndex > -1) {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
row
|
|
878
|
-
rowIndex
|
|
879
|
-
column
|
|
916
|
+
const cell = this.getCellElement(row, column);
|
|
917
|
+
const params = {
|
|
918
|
+
row,
|
|
919
|
+
rowIndex,
|
|
920
|
+
column,
|
|
880
921
|
columnIndex: visibleColumn.indexOf(column),
|
|
881
|
-
cell
|
|
922
|
+
cell
|
|
882
923
|
};
|
|
883
924
|
this.handleSelected(params, {});
|
|
884
925
|
}
|
|
@@ -888,47 +929,53 @@ var _default = exports.default = {
|
|
|
888
929
|
/**
|
|
889
930
|
* 处理选中源
|
|
890
931
|
*/
|
|
891
|
-
handleSelected
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
mouseOpts
|
|
895
|
-
editOpts
|
|
896
|
-
editStore
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
932
|
+
handleSelected(params, evnt) {
|
|
933
|
+
const {
|
|
934
|
+
mouseConfig,
|
|
935
|
+
mouseOpts,
|
|
936
|
+
editOpts,
|
|
937
|
+
editStore
|
|
938
|
+
} = this;
|
|
939
|
+
const {
|
|
940
|
+
actived,
|
|
941
|
+
selected
|
|
942
|
+
} = editStore;
|
|
943
|
+
const {
|
|
944
|
+
row,
|
|
945
|
+
column
|
|
946
|
+
} = params;
|
|
947
|
+
const isMouseSelected = mouseConfig && mouseOpts.selected;
|
|
948
|
+
const selectMethod = () => {
|
|
903
949
|
if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
|
|
904
950
|
if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
951
|
+
this.clearEdit(evnt);
|
|
952
|
+
this.clearSelected(evnt);
|
|
953
|
+
this.clearCellAreas(evnt);
|
|
954
|
+
this.clearCopyCellArea(evnt);
|
|
909
955
|
selected.args = params;
|
|
910
956
|
selected.row = row;
|
|
911
957
|
selected.column = column;
|
|
912
958
|
if (isMouseSelected) {
|
|
913
|
-
|
|
959
|
+
this.addColSdCls();
|
|
914
960
|
}
|
|
915
|
-
|
|
961
|
+
this.focus();
|
|
916
962
|
if (evnt) {
|
|
917
|
-
|
|
963
|
+
this.emitEvent('cell-selected', params, evnt);
|
|
918
964
|
}
|
|
919
965
|
}
|
|
920
966
|
}
|
|
921
|
-
return
|
|
967
|
+
return this.$nextTick();
|
|
922
968
|
};
|
|
923
969
|
return selectMethod();
|
|
924
970
|
},
|
|
925
971
|
/**
|
|
926
972
|
* 获取选中的单元格
|
|
927
973
|
*/
|
|
928
|
-
_getSelectedCell
|
|
929
|
-
|
|
930
|
-
args
|
|
931
|
-
column
|
|
974
|
+
_getSelectedCell() {
|
|
975
|
+
const {
|
|
976
|
+
args,
|
|
977
|
+
column
|
|
978
|
+
} = this.editStore.selected;
|
|
932
979
|
if (args && column) {
|
|
933
980
|
return Object.assign({}, args);
|
|
934
981
|
}
|
|
@@ -937,35 +984,39 @@ var _default = exports.default = {
|
|
|
937
984
|
/**
|
|
938
985
|
* 清除所选中源状态
|
|
939
986
|
*/
|
|
940
|
-
_clearSelected
|
|
941
|
-
|
|
987
|
+
_clearSelected() {
|
|
988
|
+
const {
|
|
989
|
+
selected
|
|
990
|
+
} = this.editStore;
|
|
942
991
|
selected.row = null;
|
|
943
992
|
selected.column = null;
|
|
944
993
|
this.reColTitleSdCls();
|
|
945
994
|
this.reColSdCls();
|
|
946
995
|
return this.$nextTick();
|
|
947
996
|
},
|
|
948
|
-
reColTitleSdCls
|
|
949
|
-
|
|
997
|
+
reColTitleSdCls() {
|
|
998
|
+
const headerElem = this.elemStore['main-header-list'];
|
|
950
999
|
if (headerElem) {
|
|
951
|
-
_xeUtils.default.arrayEach(headerElem.querySelectorAll('.col--title-selected'),
|
|
952
|
-
return (0, _dom.removeClass)(elem, 'col--title-selected');
|
|
953
|
-
});
|
|
1000
|
+
_xeUtils.default.arrayEach(headerElem.querySelectorAll('.col--title-selected'), elem => (0, _dom.removeClass)(elem, 'col--title-selected'));
|
|
954
1001
|
}
|
|
955
1002
|
},
|
|
956
|
-
reColSdCls
|
|
957
|
-
|
|
1003
|
+
reColSdCls() {
|
|
1004
|
+
const cell = this.$el.querySelector('.col--selected');
|
|
958
1005
|
if (cell) {
|
|
959
1006
|
(0, _dom.removeClass)(cell, 'col--selected');
|
|
960
1007
|
}
|
|
961
1008
|
},
|
|
962
|
-
addColSdCls
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1009
|
+
addColSdCls() {
|
|
1010
|
+
const {
|
|
1011
|
+
selected
|
|
1012
|
+
} = this.editStore;
|
|
1013
|
+
const {
|
|
1014
|
+
row,
|
|
1015
|
+
column
|
|
1016
|
+
} = selected;
|
|
966
1017
|
this.reColSdCls();
|
|
967
1018
|
if (row && column) {
|
|
968
|
-
|
|
1019
|
+
const cell = this.getCellElement(row, column);
|
|
969
1020
|
if (cell) {
|
|
970
1021
|
(0, _dom.addClass)(cell, 'col--selected');
|
|
971
1022
|
}
|