vxe-table 3.4.2 → 3.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -3
- package/README.md +2 -2
- package/README.zh-TW.md +2 -2
- package/lib/edit/src/mixin.js +267 -88
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/header/src/header.js +1 -1
- package/lib/header/src/header.min.js +1 -1
- package/lib/index.umd.js +1098 -140
- package/lib/index.umd.min.js +2 -1
- package/lib/input/src/input.js +10 -2
- package/lib/input/src/input.min.js +1 -1
- package/lib/table/src/body.js +10 -7
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/methods.js +40 -36
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +5 -3
- package/lib/table/src/table.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +1 -1
- package/lib/v-x-e-table/src/conf.min.js +1 -1
- package/lib/validator/src/mixin.js +3 -3
- package/lib/validator/src/mixin.min.js +1 -1
- package/package.json +2 -23
- package/packages/edit/src/mixin.js +174 -62
- package/packages/header/src/header.js +1 -1
- package/packages/input/src/input.js +9 -2
- package/packages/table/src/body.js +8 -7
- package/packages/table/src/methods.js +33 -31
- package/packages/table/src/table.js +5 -3
- package/packages/v-x-e-table/src/conf.js +1 -1
- package/packages/validator/src/mixin.js +3 -3
- package/types/index.d.ts +1 -1
- package/types/table.d.ts +13 -10
- package/types/v-x-e-table/renderer.d.ts +3 -1
|
@@ -216,7 +216,7 @@ var _default = {
|
|
|
216
216
|
var ruleProps = Object.keys(validRest);
|
|
217
217
|
return _this2.$nextTick().then(function () {
|
|
218
218
|
if (ruleProps.length) {
|
|
219
|
-
return
|
|
219
|
+
return validRest[ruleProps[0]][0];
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
if (cb) {
|
|
@@ -224,14 +224,14 @@ var _default = {
|
|
|
224
224
|
}
|
|
225
225
|
});
|
|
226
226
|
}).catch(function (firstErrParams) {
|
|
227
|
-
return new Promise(function (resolve
|
|
227
|
+
return new Promise(function (resolve) {
|
|
228
228
|
var finish = function finish() {
|
|
229
229
|
_this2.$nextTick(function () {
|
|
230
230
|
if (cb) {
|
|
231
231
|
cb(validRest);
|
|
232
232
|
resolve();
|
|
233
233
|
} else {
|
|
234
|
-
|
|
234
|
+
resolve(validRest);
|
|
235
235
|
}
|
|
236
236
|
});
|
|
237
237
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_tools=require("../../tools"),_utils=require("../../tools/src/utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_tools=require("../../tools"),_utils=require("../../tools/src/utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var l=t[r];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}var Rule=function(){function t(e){_classCallCheck(this,t),Object.assign(this,{$options:e,required:e.required,min:e.min,max:e.max,type:e.type,pattern:e.pattern,validator:e.validator,trigger:e.trigger,maxWidth:e.maxWidth})}return _createClass(t,[{key:"content",get:function(){return _tools.UtilTools.getFuncText(this.$options.content||this.$options.message)}},{key:"message",get:function(){return this.content}}]),t}();function validErrorRuleValue(e,t){var r=e.type,l=e.min,i=e.max,n=e.pattern,e="number"===r,r=e?_xeUtils.default.toNumber(t):_xeUtils.default.getSize(t);return!(!e||!isNaN(t))||(!_xeUtils.default.eqNull(l)&&r<_xeUtils.default.toNumber(l)||(!_xeUtils.default.eqNull(i)&&r>_xeUtils.default.toNumber(i)||!(!n||(_xeUtils.default.isRegExp(n)?n:new RegExp(n)).test(t))))}var _default={methods:{_fullValidate:function(e,t){return this.beginValidate(e,t,!0)},_validate:function(e,t){return this.beginValidate(e,t)},handleValidError:function(t){var r=this;return new Promise(function(e){!1===r.validOpts.autoPos?(r.emitEvent("valid-error",t),e()):r.handleActived(t,{type:"valid-error",trigger:"call"}).then(function(){setTimeout(function(){e(r.showValidTooltip(t))},10)})})},beginValidate:function(e,o,l){var u=this,a={},i=this.editRules,s=this.afterFullData,c=this.treeConfig,t=this.treeOpts;!0===e?r=s:e&&(_xeUtils.default.isFunction(e)?o=e:r=_xeUtils.default.isArray(e)?e:[e]);var r=r||this.getInsertRecords().concat(this.getUpdateRecords()),n=[];if(this.lastCallTime=Date.now(),this.validRuleErr=!1,this.clearValidate(),i){var d=this.getColumns(),e=function(r){var e;!l&&u.validRuleErr||(e=[],d.forEach(function(t){!l&&u.validRuleErr||!_xeUtils.default.has(i,t.property)||e.push(u.validCellRules("all",r,t).catch(function(e){e={rule:e.rule,rules:e.rules,rowIndex:u.getRowIndex(r),row:r,columnIndex:u.getColumnIndex(t),column:t,$table:u};if(a[t.property]||(a[t.property]=[]),a[t.property].push(e),!l)return u.validRuleErr=!0,Promise.reject(e)}))}),n.push(Promise.all(e)))};return c?_xeUtils.default.eachTree(r,e,t):r.forEach(e),Promise.all(n).then(function(){var e=Object.keys(a);return u.$nextTick().then(function(){return e.length?a[e[0]][0]:void(o&&o())})}).catch(function(n){return new Promise(function(e){function t(){u.$nextTick(function(){o?(o(a),e()):e(a)})}function r(){n.cell=u.getCell(n.row,n.column),_tools.DomTools.scrollToView(n.cell),u.handleValidError(n).then(t)}var l=n.row,i=s.indexOf(l),l=0<i?s[i-1]:l;!1===u.validOpts.autoPos?t():(c?u.scrollToTreeRow(l):u.scrollToRow(l)).then(r)})})}return this.$nextTick().then(function(){o&&o()})},hasCellRules:function(t,e,r){var l=this.editRules,r=r.property;if(r&&l){r=_xeUtils.default.get(l,r);return r&&_xeUtils.default.find(r,function(e){return"all"===t||!e.trigger||t===e.trigger})}return!1},validCellRules:function(n,o,u,e){var a,s,c=this,t=this.editRules,r=u.property,d=[],f=[];return r&&t&&((a=_xeUtils.default.get(t,r))&&(s=_xeUtils.default.isUndefined(e)?_xeUtils.default.get(o,r):e,a.forEach(function(t){var e,r=t.type,l=t.trigger,i=t.required;"all"!==n&&l&&n!==l||(_xeUtils.default.isFunction(t.validator)?(e=t.validator({cellValue:s,rule:t,rules:a,row:o,rowIndex:c.getRowIndex(o),column:u,columnIndex:c.getColumnIndex(u),$table:c}))&&(_xeUtils.default.isError(e)?(c.validRuleErr=!0,d.push(new Rule({type:"custom",trigger:l,content:e.message,rule:new Rule(t)}))):e.catch&&f.push(e.catch(function(e){c.validRuleErr=!0,d.push(new Rule({type:"custom",trigger:l,content:e&&e.message?e.message:t.content||t.message,rule:new Rule(t)}))}))):(r="array"===r?!_xeUtils.default.isArray(s)||!s.length:(0,_utils.eqEmptyValue)(s),(i?r||validErrorRuleValue(t,s):!r&&validErrorRuleValue(t,s))&&(c.validRuleErr=!0,d.push(new Rule(t)))))}))),Promise.all(f).then(function(){if(d.length){var e={rules:d,rule:d[0]};return Promise.reject(e)}})},_clearValidate:function(){var e=this.$refs.validTip;return Object.assign(this.validStore,{visible:!1,row:null,column:null,content:"",rule:null}),e&&e.visible&&e.close(),this.$nextTick()},triggerValidate:function(t){var r=this,e=this.editConfig,l=this.editStore,i=this.editRules,n=this.validStore,l=l.actived;if(l.row&&i){var l=l.args,o=l.row,u=l.column,a=l.cell;if(this.hasCellRules(t,o,u))return this.validCellRules(t,o,u).then(function(){"row"===e.mode&&n.visible&&n.row===o&&n.column===u&&r.clearValidate()}).catch(function(e){e=e.rule;if(e.trigger&&t!==e.trigger)return Promise.resolve();e={rule:e,row:o,column:u,cell:a};return r.showValidTooltip(e),Promise.reject(e)})}return Promise.resolve()},showValidTooltip:function(e){var t=this,r=this.$refs,l=this.height,i=this.tableData,n=this.validOpts,o=e.rule,u=e.row,a=e.column,s=e.cell,c=r.validTip,d=o.content;return this.$nextTick(function(){if(Object.assign(t.validStore,{row:u,column:a,rule:o,content:d,visible:!0}),t.emitEvent("valid-error",e),c&&("tooltip"===n.message||"default"===n.message&&!l&&i.length<2))return c.open(s,d)})}}};exports.default=_default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vxe-table",
|
|
3
|
-
"version": "3.4.
|
|
4
|
-
"description": "一个基于 vue 的 PC
|
|
3
|
+
"version": "3.4.5",
|
|
4
|
+
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
7
7
|
"lint": "vue-cli-service lint",
|
|
@@ -35,20 +35,14 @@
|
|
|
35
35
|
"@vue/cli-service": "~4.4.0",
|
|
36
36
|
"@vue/eslint-config-standard": "^5.1.2",
|
|
37
37
|
"@vue/eslint-config-typescript": "^5.0.2",
|
|
38
|
-
"ant-design-vue": "^1.7.8",
|
|
39
|
-
"codemirror": "^5.53.2",
|
|
40
38
|
"core-js": "^3.6.5",
|
|
41
|
-
"dayjs": "^1.10.4",
|
|
42
39
|
"del": "^5.1.0",
|
|
43
|
-
"element-ui": "^2.15.6",
|
|
44
40
|
"eslint": "^6.7.2",
|
|
45
41
|
"eslint-plugin-import": "^2.20.2",
|
|
46
42
|
"eslint-plugin-node": "^11.1.0",
|
|
47
43
|
"eslint-plugin-promise": "^4.2.1",
|
|
48
44
|
"eslint-plugin-standard": "^4.0.0",
|
|
49
45
|
"eslint-plugin-vue": "^6.2.2",
|
|
50
|
-
"exceljs": "^4.2.1",
|
|
51
|
-
"font-awesome": "^4.7.0",
|
|
52
46
|
"gulp": "^4.0.2",
|
|
53
47
|
"gulp-autoprefixer": "^6.1.0",
|
|
54
48
|
"gulp-babel": "^8.0.0",
|
|
@@ -60,15 +54,9 @@
|
|
|
60
54
|
"gulp-sass": "^4.1.0",
|
|
61
55
|
"gulp-sourcemaps": "^2.6.5",
|
|
62
56
|
"gulp-uglify": "^3.0.2",
|
|
63
|
-
"highlight.js": "^10.5.0",
|
|
64
|
-
"jsbarcode": "^3.11.0",
|
|
65
|
-
"jspdf": "^2.3.1",
|
|
66
57
|
"node-sass": "^4.14.0",
|
|
67
|
-
"qrcode": "^1.4.4",
|
|
68
58
|
"sass-loader": "^8.0.2",
|
|
69
|
-
"sortablejs": "^1.10.2",
|
|
70
59
|
"typescript": "~3.9.3",
|
|
71
|
-
"view-design": "^4.6.1",
|
|
72
60
|
"vue": "^2.6.14",
|
|
73
61
|
"vue-class-component": "^7.2.3",
|
|
74
62
|
"vue-i18n": "^8.18.1",
|
|
@@ -76,15 +64,6 @@
|
|
|
76
64
|
"vue-router": "^3.2.0",
|
|
77
65
|
"vue-template-compiler": "^2.6.14",
|
|
78
66
|
"vuex": "^3.4.0",
|
|
79
|
-
"vxe-table-plugin-antd": "^1.11.3",
|
|
80
|
-
"vxe-table-plugin-charts": "^1.7.1",
|
|
81
|
-
"vxe-table-plugin-element": "^1.11.3",
|
|
82
|
-
"vxe-table-plugin-export-pdf": "^1.9.2",
|
|
83
|
-
"vxe-table-plugin-export-xlsx": "^2.2.1",
|
|
84
|
-
"vxe-table-plugin-iview": "^1.11.4",
|
|
85
|
-
"vxe-table-plugin-menus": "^2.0.2",
|
|
86
|
-
"vxe-table-plugin-renderer": "^1.3.5",
|
|
87
|
-
"vxe-table-plugin-shortcut-key": "^1.5.1",
|
|
88
67
|
"xe-ajax": "^4.0.5",
|
|
89
68
|
"xe-clipboard": "^1.10.1",
|
|
90
69
|
"xe-utils": "^3.4.0",
|
|
@@ -3,6 +3,43 @@ import VXETable from '../../v-x-e-table'
|
|
|
3
3
|
import { UtilTools, DomTools, isEnableConf } from '../../tools'
|
|
4
4
|
import { browse } from '../../tools/src/dom'
|
|
5
5
|
|
|
6
|
+
const { getRowid } = UtilTools
|
|
7
|
+
|
|
8
|
+
function insertTreeRow (_vm, newRecords, isAppend) {
|
|
9
|
+
const { treeFullData, afterFullData, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm
|
|
10
|
+
const funcName = isAppend ? 'push' : 'unshift'
|
|
11
|
+
newRecords.forEach(item => {
|
|
12
|
+
const parentRowId = item[treeOpts.parentField]
|
|
13
|
+
const rowid = getRowid(_vm, item)
|
|
14
|
+
const matchObj = parentRowId ? XEUtils.findTree(treeFullData, item => parentRowId === item[treeOpts.rowField], treeOpts) : null
|
|
15
|
+
if (matchObj) {
|
|
16
|
+
const { item: parentRow } = matchObj
|
|
17
|
+
const parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)]
|
|
18
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
19
|
+
let parentChilds = parentRow[treeOpts.children]
|
|
20
|
+
if (!XEUtils.isArray(parentChilds)) {
|
|
21
|
+
parentChilds = parentRow[treeOpts.children] = []
|
|
22
|
+
}
|
|
23
|
+
parentChilds[funcName](item)
|
|
24
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
|
|
25
|
+
fullDataRowIdData[rowid] = rest
|
|
26
|
+
fullAllDataRowIdData[rowid] = rest
|
|
27
|
+
} else {
|
|
28
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
29
|
+
if (parentRowId) {
|
|
30
|
+
UtilTools.warn('vxe.error.unableInsert')
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
afterFullData[funcName](item)
|
|
34
|
+
treeFullData[funcName](item)
|
|
35
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: treeFullData, parent: null, level: 0 }
|
|
36
|
+
fullDataRowIdData[rowid] = rest
|
|
37
|
+
fullAllDataRowIdData[rowid] = rest
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
_vm.updateVirtualTreeData()
|
|
41
|
+
}
|
|
42
|
+
|
|
6
43
|
export default {
|
|
7
44
|
methods: {
|
|
8
45
|
/**
|
|
@@ -22,56 +59,101 @@ export default {
|
|
|
22
59
|
* @param {Row} row 指定行
|
|
23
60
|
*/
|
|
24
61
|
_insertAt (records, row) {
|
|
25
|
-
const { mergeList, afterFullData, editStore, sYOpts, scrollYLoad, tableFullData, treeConfig } = this
|
|
62
|
+
const { treeFullData, mergeList, afterFullData, editStore, sYOpts, scrollYLoad, tableFullData, treeConfig, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = this
|
|
63
|
+
const { transform } = treeOpts
|
|
26
64
|
if (!XEUtils.isArray(records)) {
|
|
27
65
|
records = [records]
|
|
28
66
|
}
|
|
29
67
|
const newRecords = records.map(record => this.defineField(Object.assign({}, record)))
|
|
30
68
|
if (!row) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
mergeList.forEach(mergeItem => {
|
|
35
|
-
const { row: mergeRowIndex } = mergeItem
|
|
36
|
-
if (mergeRowIndex > 0) {
|
|
37
|
-
mergeItem.row = mergeRowIndex + newRecords.length
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
} else {
|
|
41
|
-
if (row === -1) {
|
|
42
|
-
afterFullData.push(...newRecords)
|
|
43
|
-
tableFullData.push(...newRecords)
|
|
44
|
-
// 刷新单元格合并
|
|
45
|
-
mergeList.forEach(mergeItem => {
|
|
46
|
-
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
47
|
-
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
48
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
49
|
-
}
|
|
50
|
-
})
|
|
69
|
+
// 如果为虚拟树
|
|
70
|
+
if (treeConfig && transform) {
|
|
71
|
+
insertTreeRow(this, newRecords, false)
|
|
51
72
|
} else {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
const afIndex = afterFullData.indexOf(row)
|
|
56
|
-
if (afIndex === -1) {
|
|
57
|
-
throw new Error(UtilTools.error('vxe.error.unableInsert'))
|
|
58
|
-
}
|
|
59
|
-
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
60
|
-
tableFullData.splice(tableFullData.indexOf(row), 0, ...newRecords)
|
|
73
|
+
afterFullData.unshift(...newRecords)
|
|
74
|
+
tableFullData.unshift(...newRecords)
|
|
61
75
|
// 刷新单元格合并
|
|
62
76
|
mergeList.forEach(mergeItem => {
|
|
63
|
-
const { row: mergeRowIndex
|
|
64
|
-
if (mergeRowIndex >
|
|
77
|
+
const { row: mergeRowIndex } = mergeItem
|
|
78
|
+
if (mergeRowIndex > 0) {
|
|
65
79
|
mergeItem.row = mergeRowIndex + newRecords.length
|
|
66
|
-
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
67
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
68
80
|
}
|
|
69
81
|
})
|
|
70
82
|
}
|
|
83
|
+
} else {
|
|
84
|
+
if (row === -1) {
|
|
85
|
+
// 如果为虚拟树
|
|
86
|
+
if (treeConfig && transform) {
|
|
87
|
+
insertTreeRow(this, newRecords, true)
|
|
88
|
+
} else {
|
|
89
|
+
afterFullData.push(...newRecords)
|
|
90
|
+
tableFullData.push(...newRecords)
|
|
91
|
+
// 刷新单元格合并
|
|
92
|
+
mergeList.forEach(mergeItem => {
|
|
93
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
94
|
+
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
95
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
// 如果为虚拟树
|
|
101
|
+
if (treeConfig && transform) {
|
|
102
|
+
const matchObj = XEUtils.findTree(treeFullData, item => row[treeOpts.rowField] === item[treeOpts.rowField], treeOpts)
|
|
103
|
+
if (matchObj) {
|
|
104
|
+
const { parent: parentRow } = matchObj
|
|
105
|
+
const parentChilds = matchObj.items
|
|
106
|
+
const parentRest = fullAllDataRowIdData[getRowid(this, parentRow)]
|
|
107
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
108
|
+
newRecords.forEach((item, i) => {
|
|
109
|
+
const rowid = getRowid(this, item)
|
|
110
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
111
|
+
if (item[treeOpts.parentField]) {
|
|
112
|
+
if (parentRow && item[treeOpts.parentField] !== parentRow[treeOpts.rowField]) {
|
|
113
|
+
UtilTools.error('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[treeOpts.rowField]}`])
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (parentRow) {
|
|
118
|
+
item[treeOpts.parentField] = parentRow[treeOpts.rowField]
|
|
119
|
+
}
|
|
120
|
+
parentChilds.splice(matchObj.index + i, 0, item)
|
|
121
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1 }
|
|
122
|
+
fullDataRowIdData[rowid] = rest
|
|
123
|
+
fullAllDataRowIdData[rowid] = rest
|
|
124
|
+
})
|
|
125
|
+
this.updateVirtualTreeData()
|
|
126
|
+
} else {
|
|
127
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
128
|
+
UtilTools.warn('vxe.error.unableInsert')
|
|
129
|
+
}
|
|
130
|
+
insertTreeRow(this, newRecords, true)
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
if (treeConfig) {
|
|
134
|
+
throw new Error(UtilTools.getLog('vxe.error.noTree', ['insert']))
|
|
135
|
+
}
|
|
136
|
+
const afIndex = afterFullData.indexOf(row)
|
|
137
|
+
if (afIndex === -1) {
|
|
138
|
+
throw new Error(UtilTools.error('vxe.error.unableInsert'))
|
|
139
|
+
}
|
|
140
|
+
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
141
|
+
tableFullData.splice(tableFullData.indexOf(row), 0, ...newRecords)
|
|
142
|
+
// 刷新单元格合并
|
|
143
|
+
mergeList.forEach(mergeItem => {
|
|
144
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
145
|
+
if (mergeRowIndex > afIndex) {
|
|
146
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
147
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
148
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
}
|
|
71
153
|
}
|
|
72
154
|
editStore.insertList.unshift(...newRecords)
|
|
73
155
|
this.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
|
|
74
|
-
this.handleTableData()
|
|
156
|
+
this.handleTableData(transform)
|
|
75
157
|
this.updateFooter()
|
|
76
158
|
this.cacheRowMap()
|
|
77
159
|
this.checkSelectionStatus()
|
|
@@ -95,7 +177,8 @@ export default {
|
|
|
95
177
|
* 如果为空则删除所有
|
|
96
178
|
*/
|
|
97
179
|
_remove (rows) {
|
|
98
|
-
const { afterFullData, tableFullData, treeConfig, mergeList, editStore, checkboxOpts, selection, isInsertByRow, sYOpts, scrollYLoad } = this
|
|
180
|
+
const { afterFullData, tableFullData, treeFullData, treeConfig, mergeList, editStore, checkboxOpts, selection, isInsertByRow, sYOpts, scrollYLoad, treeOpts } = this
|
|
181
|
+
const { transform } = treeOpts
|
|
99
182
|
const { actived, removeList, insertList } = editStore
|
|
100
183
|
const { checkField: property } = checkboxOpts
|
|
101
184
|
let rest = []
|
|
@@ -126,26 +209,43 @@ export default {
|
|
|
126
209
|
this.afterFullData = []
|
|
127
210
|
this.clearMergeCells()
|
|
128
211
|
} else {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
212
|
+
// 如果为虚拟树
|
|
213
|
+
if (treeConfig && transform) {
|
|
214
|
+
rows.forEach((row) => {
|
|
215
|
+
const rowid = getRowid(this, row)
|
|
216
|
+
const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid(this, item), treeOpts)
|
|
217
|
+
if (matchObj) {
|
|
218
|
+
const rItems = matchObj.items.splice(matchObj.index, 1)
|
|
219
|
+
rest.push(rItems[0])
|
|
220
|
+
}
|
|
221
|
+
const afIndex = afterFullData.indexOf(row)
|
|
222
|
+
if (afIndex > -1) {
|
|
223
|
+
afterFullData.splice(afIndex, 1)
|
|
224
|
+
}
|
|
225
|
+
this.updateVirtualTreeData()
|
|
226
|
+
})
|
|
227
|
+
} else {
|
|
228
|
+
rows.forEach(row => {
|
|
229
|
+
const tfIndex = tableFullData.indexOf(row)
|
|
230
|
+
if (tfIndex > -1) {
|
|
231
|
+
const rItems = tableFullData.splice(tfIndex, 1)
|
|
232
|
+
rest.push(rItems[0])
|
|
233
|
+
}
|
|
234
|
+
const afIndex = afterFullData.indexOf(row)
|
|
235
|
+
if (afIndex > -1) {
|
|
236
|
+
// 刷新单元格合并
|
|
237
|
+
mergeList.forEach(mergeItem => {
|
|
238
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
239
|
+
if (mergeRowIndex > afIndex) {
|
|
240
|
+
mergeItem.row = mergeRowIndex - 1
|
|
241
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
242
|
+
mergeItem.rowspan = mergeRowspan - 1
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
afterFullData.splice(afIndex, 1)
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
}
|
|
149
249
|
}
|
|
150
250
|
// 如果当前行被激活编辑,则清除激活状态
|
|
151
251
|
if (actived.row && rows.indexOf(actived.row) > -1) {
|
|
@@ -159,7 +259,7 @@ export default {
|
|
|
159
259
|
}
|
|
160
260
|
})
|
|
161
261
|
this.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
|
|
162
|
-
this.handleTableData()
|
|
262
|
+
this.handleTableData(transform)
|
|
163
263
|
this.updateFooter()
|
|
164
264
|
this.cacheRowMap()
|
|
165
265
|
this.checkSelectionStatus()
|
|
@@ -216,14 +316,26 @@ export default {
|
|
|
216
316
|
* 获取新增的临时数据
|
|
217
317
|
*/
|
|
218
318
|
_getInsertRecords () {
|
|
319
|
+
const { treeConfig, treeFullData, tableFullData, treeOpts } = this
|
|
219
320
|
const insertList = this.editStore.insertList
|
|
220
321
|
const insertRecords = []
|
|
221
322
|
if (insertList.length) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
323
|
+
// 如果为虚拟树
|
|
324
|
+
if (treeConfig && treeOpts.transform) {
|
|
325
|
+
insertList.forEach(row => {
|
|
326
|
+
const rowid = getRowid(this, row)
|
|
327
|
+
const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid(this, item), treeOpts)
|
|
328
|
+
if (matchObj) {
|
|
329
|
+
insertRecords.push(row)
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
} else {
|
|
333
|
+
insertList.forEach(row => {
|
|
334
|
+
if (tableFullData.indexOf(row) > -1) {
|
|
335
|
+
insertRecords.push(row)
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
}
|
|
227
339
|
}
|
|
228
340
|
return insertRecords
|
|
229
341
|
},
|
|
@@ -121,7 +121,7 @@ export default {
|
|
|
121
121
|
if (scrollXLoad && !hasEllipsis) {
|
|
122
122
|
showEllipsis = hasEllipsis = true
|
|
123
123
|
}
|
|
124
|
-
if (highlightCurrentColumn || tableListeners['header-cell-click'] || sortOpts.trigger === 'cell') {
|
|
124
|
+
if (columnOpts.isCurrent || highlightCurrentColumn || tableListeners['header-cell-click'] || sortOpts.trigger === 'cell') {
|
|
125
125
|
thOns.click = evnt => $xetable.triggerHeaderCellClickEvent(evnt, params)
|
|
126
126
|
}
|
|
127
127
|
if (tableListeners['header-cell-dblclick']) {
|
|
@@ -44,9 +44,16 @@ function getDateQuarter (date) {
|
|
|
44
44
|
return 4
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
function toFloatValueFixed (inputValue, digitsValue) {
|
|
48
|
+
if (/^-/.test('' + inputValue)) {
|
|
49
|
+
return XEUtils.toFixed(XEUtils.ceil(inputValue, digitsValue), digitsValue)
|
|
50
|
+
}
|
|
51
|
+
return XEUtils.toFixed(XEUtils.floor(inputValue, digitsValue), digitsValue)
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
function getNumberValue (_vm, val) {
|
|
48
55
|
const { type, exponential, digitsValue, inpMaxlength } = _vm
|
|
49
|
-
const restVal = (type === 'float' ?
|
|
56
|
+
const restVal = (type === 'float' ? toFloatValueFixed(val, digitsValue) : XEUtils.toValueString(val))
|
|
50
57
|
if (exponential && (val === restVal || XEUtils.toValueString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
|
|
51
58
|
return val
|
|
52
59
|
}
|
|
@@ -1255,7 +1262,7 @@ export default {
|
|
|
1255
1262
|
this.changeValue()
|
|
1256
1263
|
} else if (type === 'float') {
|
|
1257
1264
|
if (inputValue) {
|
|
1258
|
-
const validValue =
|
|
1265
|
+
const validValue = toFloatValueFixed(inputValue, digitsValue)
|
|
1259
1266
|
if (inputValue !== validValue) {
|
|
1260
1267
|
this.emitModel(validValue, { type: 'init' })
|
|
1261
1268
|
}
|
|
@@ -141,7 +141,7 @@ function renderColumn (h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel,
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
// 点击事件处理
|
|
144
|
-
if (highlightCurrentRow ||
|
|
144
|
+
if ((rowOpts.isCurrent || highlightCurrentRow) ||
|
|
145
145
|
tableListeners['cell-click'] ||
|
|
146
146
|
(editRender && editConfig) ||
|
|
147
147
|
(expandOpts.trigger === 'row' || (expandOpts.trigger === 'cell')) ||
|
|
@@ -287,7 +287,8 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
|
|
|
287
287
|
checkboxOpts,
|
|
288
288
|
expandColumn,
|
|
289
289
|
hasFixedColumn,
|
|
290
|
-
fullAllDataRowIdData
|
|
290
|
+
fullAllDataRowIdData,
|
|
291
|
+
rowOpts
|
|
291
292
|
} = $xetable
|
|
292
293
|
const rows = []
|
|
293
294
|
tableData.forEach((row, $rowIndex) => {
|
|
@@ -301,7 +302,7 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
|
|
|
301
302
|
// 确保任何情况下 rowIndex 都精准指向真实 data 索引
|
|
302
303
|
rowIndex = $xetable.getRowIndex(row)
|
|
303
304
|
// 事件绑定
|
|
304
|
-
if (highlightHoverRow) {
|
|
305
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
305
306
|
trOn.mouseenter = evnt => {
|
|
306
307
|
if (isOperateMouse($xetable)) {
|
|
307
308
|
return
|
|
@@ -579,7 +580,7 @@ export default {
|
|
|
579
580
|
*/
|
|
580
581
|
scrollEvent (evnt) {
|
|
581
582
|
const { $el: scrollBodyElem, $parent: $xetable, fixedType } = this
|
|
582
|
-
const { $refs, elemStore, highlightHoverRow, scrollXLoad, scrollYLoad, lastScrollTop, lastScrollLeft } = $xetable
|
|
583
|
+
const { $refs, elemStore, highlightHoverRow, scrollXLoad, scrollYLoad, lastScrollTop, lastScrollLeft, rowOpts } = $xetable
|
|
583
584
|
const { tableHeader, tableBody, leftBody, rightBody, tableFooter, validTip } = $refs
|
|
584
585
|
const headerElem = tableHeader ? tableHeader.$el : null
|
|
585
586
|
const footerElem = tableFooter ? tableFooter.$el : null
|
|
@@ -597,7 +598,7 @@ export default {
|
|
|
597
598
|
$xetable.lastScrollTop = scrollTop
|
|
598
599
|
$xetable.lastScrollLeft = scrollLeft
|
|
599
600
|
$xetable.lastScrollTime = Date.now()
|
|
600
|
-
if (highlightHoverRow) {
|
|
601
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
601
602
|
$xetable.clearHoverRow()
|
|
602
603
|
}
|
|
603
604
|
if (leftElem && fixedType === 'left') {
|
|
@@ -683,7 +684,7 @@ export default {
|
|
|
683
684
|
wheelEvent (evnt) {
|
|
684
685
|
const { deltaY, deltaX } = evnt
|
|
685
686
|
const { $el: scrollBodyElem, $parent: $xetable } = this
|
|
686
|
-
const { $refs, highlightHoverRow, scrollYLoad, lastScrollTop, lastScrollLeft } = $xetable
|
|
687
|
+
const { $refs, highlightHoverRow, scrollYLoad, lastScrollTop, lastScrollLeft, rowOpts } = $xetable
|
|
687
688
|
const { tableBody } = $refs
|
|
688
689
|
const bodyElem = tableBody.$el
|
|
689
690
|
|
|
@@ -706,7 +707,7 @@ export default {
|
|
|
706
707
|
$xetable.lastScrollTop = scrollTop
|
|
707
708
|
$xetable.lastScrollLeft = scrollLeft
|
|
708
709
|
$xetable.lastScrollTime = Date.now()
|
|
709
|
-
if (highlightHoverRow) {
|
|
710
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
710
711
|
$xetable.clearHoverRow()
|
|
711
712
|
}
|
|
712
713
|
this.handleWheel(evnt, isTopWheel, deltaTop, isRollX, isRollY)
|