vxe-table 3.4.6 → 3.4.7

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.
Files changed (43) hide show
  1. package/lib/button/src/button.js +15 -14
  2. package/lib/button/src/button.min.js +1 -1
  3. package/lib/edit/src/mixin.js +19 -25
  4. package/lib/edit/src/mixin.min.js +1 -1
  5. package/lib/export/src/mixin.js +4 -10
  6. package/lib/export/src/mixin.min.js +1 -1
  7. package/lib/filter/src/mixin.js +25 -1
  8. package/lib/filter/src/mixin.min.js +1 -1
  9. package/lib/index.umd.js +734 -445
  10. package/lib/index.umd.min.js +1 -1
  11. package/lib/select/src/select.js +1 -1
  12. package/lib/select/src/select.min.js +1 -1
  13. package/lib/table/src/body.js +9 -17
  14. package/lib/table/src/body.min.js +1 -1
  15. package/lib/table/src/cell.js +16 -17
  16. package/lib/table/src/cell.min.js +1 -1
  17. package/lib/table/src/methods.js +567 -346
  18. package/lib/table/src/methods.min.js +1 -1
  19. package/lib/table/src/util.js +7 -0
  20. package/lib/table/src/util.min.js +1 -1
  21. package/lib/tools/src/dom.js +2 -9
  22. package/lib/tools/src/dom.min.js +1 -1
  23. package/lib/tools/src/utils.js +1 -1
  24. package/lib/tools/src/utils.min.js +1 -1
  25. package/lib/v-x-e-table/src/conf.js +2 -1
  26. package/lib/v-x-e-table/src/conf.min.js +1 -1
  27. package/lib/validator/src/mixin.js +1 -1
  28. package/lib/validator/src/mixin.min.js +1 -1
  29. package/package.json +3 -4
  30. package/packages/button/src/button.js +14 -14
  31. package/packages/edit/src/mixin.js +18 -21
  32. package/packages/export/src/mixin.js +4 -7
  33. package/packages/filter/src/mixin.js +20 -1
  34. package/packages/select/src/select.js +1 -1
  35. package/packages/table/src/body.js +12 -16
  36. package/packages/table/src/cell.js +15 -15
  37. package/packages/table/src/methods.js +173 -51
  38. package/packages/table/src/util.js +4 -0
  39. package/packages/tools/src/dom.js +2 -7
  40. package/packages/tools/src/utils.js +1 -1
  41. package/packages/v-x-e-table/src/conf.js +2 -1
  42. package/packages/validator/src/mixin.js +1 -1
  43. package/types/table.d.ts +1 -0
@@ -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 validRest[ruleProps[0]][0];
219
+ return Promise.reject(validRest[ruleProps[0]][0]);
220
220
  }
221
221
 
222
222
  if (cb) {
@@ -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 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;
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 i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}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,i=e.min,l=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(i)&&r<_xeUtils.default.toNumber(i)||(!_xeUtils.default.eqNull(l)&&r>_xeUtils.default.toNumber(l)||!(!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,i){var u=this,a={},l=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(),l){var d=this.getColumns(),e=function(r){var e;!i&&u.validRuleErr||(e=[],d.forEach(function(t){!i&&u.validRuleErr||!_xeUtils.default.has(l,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),!i)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?Promise.reject(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 i=n.row,l=s.indexOf(i),i=0<l?s[l-1]:i;!1===u.validOpts.autoPos?t():(c?u.scrollToTreeRow(i):u.scrollToRow(i)).then(r)})})}return this.$nextTick().then(function(){o&&o()})},hasCellRules:function(t,e,r){var i=this.editRules,r=r.property;if(r&&i){r=_xeUtils.default.get(i,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,i=t.trigger,l=t.required;"all"!==n&&i&&n!==i||(_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:i,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:i,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),(l?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,i=this.editStore,l=this.editRules,n=this.validStore,i=i.actived;if(i.row&&l){var i=i.args,o=i.row,u=i.column,a=i.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,i=this.height,l=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&&!i&&l.length<2))return c.open(s,d)})}}};exports.default=_default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vxe-table",
3
- "version": "3.4.6",
3
+ "version": "3.4.7",
4
4
  "description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -66,12 +66,11 @@
66
66
  "vuex": "^3.4.0",
67
67
  "xe-ajax": "^4.0.5",
68
68
  "xe-clipboard": "^1.10.1",
69
- "xe-utils": "^3.4.0",
70
- "xlsx": "^0.17.0"
69
+ "xe-utils": "^3.4.3"
71
70
  },
72
71
  "peerDependencies": {
73
72
  "vue": "^2.6.0",
74
- "xe-utils": "^3.2.0"
73
+ "xe-utils": "^3.4.2"
75
74
  },
76
75
  "vetur": {
77
76
  "tags": "helper/vetur/tags.json",
@@ -264,38 +264,38 @@ export default {
264
264
  const panelStyle = {
265
265
  zIndex: panelIndex
266
266
  }
267
- const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = DomTools.getAbsolutePos(targetElem)
267
+ const { top, left, boundingTop, visibleHeight, visibleWidth } = DomTools.getAbsolutePos(targetElem)
268
268
  let panelPlacement = 'bottom'
269
269
  if (transfer) {
270
- let left = boundingLeft + targetWidth - panelWidth
271
- let top = boundingTop + targetHeight
270
+ let btnLeft = left + targetWidth - panelWidth
271
+ let btnTop = top + targetHeight
272
272
  if (placement === 'top') {
273
273
  panelPlacement = 'top'
274
- top = boundingTop - panelHeight
274
+ btnTop = top - panelHeight
275
275
  } else if (!placement) {
276
276
  // 如果下面不够放,则向上
277
- if (top + panelHeight + marginSize > visibleHeight) {
277
+ if (boundingTop + targetHeight + panelHeight + marginSize > visibleHeight) {
278
278
  panelPlacement = 'top'
279
- top = boundingTop - panelHeight
279
+ btnTop = top - panelHeight
280
280
  }
281
281
  // 如果上面不够放,则向下(优先)
282
- if (top < marginSize) {
282
+ if (btnTop < marginSize) {
283
283
  panelPlacement = 'bottom'
284
- top = boundingTop + targetHeight
284
+ btnTop = top + targetHeight
285
285
  }
286
286
  }
287
287
  // 如果溢出右边
288
- if (left + panelWidth + marginSize > visibleWidth) {
289
- left -= left + panelWidth + marginSize - visibleWidth
288
+ if (btnLeft + panelWidth + marginSize > visibleWidth) {
289
+ btnLeft -= btnLeft + panelWidth + marginSize - visibleWidth
290
290
  }
291
291
  // 如果溢出左边
292
- if (left < marginSize) {
293
- left = marginSize
292
+ if (btnLeft < marginSize) {
293
+ btnLeft = marginSize
294
294
  }
295
295
  Object.assign(panelStyle, {
296
- left: `${left}px`,
296
+ left: `${btnLeft}px`,
297
297
  right: 'auto',
298
- top: `${top}px`,
298
+ top: `${btnTop}px`,
299
299
  minWidth: `${targetWidth}px`
300
300
  })
301
301
  } else {
@@ -6,12 +6,12 @@ import { browse } from '../../tools/src/dom'
6
6
  const { getRowid } = UtilTools
7
7
 
8
8
  function insertTreeRow (_vm, newRecords, isAppend) {
9
- const { treeFullData, afterFullData, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm
9
+ const { tableFullTreeData, afterFullData, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm
10
10
  const funcName = isAppend ? 'push' : 'unshift'
11
11
  newRecords.forEach(item => {
12
12
  const parentRowId = item[treeOpts.parentField]
13
13
  const rowid = getRowid(_vm, item)
14
- const matchObj = parentRowId ? XEUtils.findTree(treeFullData, item => parentRowId === item[treeOpts.rowField], treeOpts) : null
14
+ const matchObj = parentRowId ? XEUtils.findTree(tableFullTreeData, item => parentRowId === item[treeOpts.rowField], treeOpts) : null
15
15
  if (matchObj) {
16
16
  const { item: parentRow } = matchObj
17
17
  const parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)]
@@ -21,7 +21,7 @@ function insertTreeRow (_vm, newRecords, isAppend) {
21
21
  parentChilds = parentRow[treeOpts.children] = []
22
22
  }
23
23
  parentChilds[funcName](item)
24
- const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
24
+ const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
25
25
  fullDataRowIdData[rowid] = rest
26
26
  fullAllDataRowIdData[rowid] = rest
27
27
  } else {
@@ -31,13 +31,12 @@ function insertTreeRow (_vm, newRecords, isAppend) {
31
31
  }
32
32
  }
33
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 }
34
+ tableFullTreeData[funcName](item)
35
+ const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: tableFullTreeData, parent: null, level: 0 }
36
36
  fullDataRowIdData[rowid] = rest
37
37
  fullAllDataRowIdData[rowid] = rest
38
38
  }
39
39
  })
40
- _vm.updateVirtualTreeData()
41
40
  }
42
41
 
43
42
  export default {
@@ -59,7 +58,7 @@ export default {
59
58
  * @param {Row} row 指定行
60
59
  */
61
60
  _insertAt (records, row) {
62
- const { treeFullData, mergeList, afterFullData, editStore, sYOpts, scrollYLoad, tableFullData, treeConfig, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = this
61
+ const { tableFullTreeData, mergeList, afterFullData, editStore, tableFullData, treeConfig, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = this
63
62
  const { transform } = treeOpts
64
63
  if (!XEUtils.isArray(records)) {
65
64
  records = [records]
@@ -99,7 +98,7 @@ export default {
99
98
  } else {
100
99
  // 如果为虚拟树
101
100
  if (treeConfig && transform) {
102
- const matchObj = XEUtils.findTree(treeFullData, item => row[treeOpts.rowField] === item[treeOpts.rowField], treeOpts)
101
+ const matchObj = XEUtils.findTree(tableFullTreeData, item => row[treeOpts.rowField] === item[treeOpts.rowField], treeOpts)
103
102
  if (matchObj) {
104
103
  const { parent: parentRow } = matchObj
105
104
  const parentChilds = matchObj.items
@@ -118,11 +117,10 @@ export default {
118
117
  item[treeOpts.parentField] = parentRow[treeOpts.rowField]
119
118
  }
120
119
  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 }
120
+ const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1 }
122
121
  fullDataRowIdData[rowid] = rest
123
122
  fullAllDataRowIdData[rowid] = rest
124
123
  })
125
- this.updateVirtualTreeData()
126
124
  } else {
127
125
  if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
128
126
  UtilTools.warn('vxe.error.unableInsert')
@@ -152,12 +150,12 @@ export default {
152
150
  }
153
151
  }
154
152
  editStore.insertList.unshift(...newRecords)
155
- this.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
156
- this.handleTableData(transform)
153
+ this.handleTableData(treeConfig && treeOpts.transform)
157
154
  this.updateFooter()
158
155
  this.cacheRowMap()
156
+ this.updateAfterDataIndex()
159
157
  this.checkSelectionStatus()
160
- if (scrollYLoad) {
158
+ if (this.scrollYLoad) {
161
159
  this.updateScrollYSpace()
162
160
  }
163
161
  return this.$nextTick().then(() => {
@@ -177,7 +175,7 @@ export default {
177
175
  * 如果为空则删除所有
178
176
  */
179
177
  _remove (rows) {
180
- const { afterFullData, tableFullData, treeFullData, treeConfig, mergeList, editStore, checkboxOpts, selection, isInsertByRow, sYOpts, scrollYLoad, treeOpts } = this
178
+ const { afterFullData, tableFullData, tableFullTreeData, treeConfig, mergeList, editStore, checkboxOpts, selection, isInsertByRow, treeOpts } = this
181
179
  const { transform } = treeOpts
182
180
  const { actived, removeList, insertList } = editStore
183
181
  const { checkField: property } = checkboxOpts
@@ -213,7 +211,7 @@ export default {
213
211
  if (treeConfig && transform) {
214
212
  rows.forEach((row) => {
215
213
  const rowid = getRowid(this, row)
216
- const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid(this, item), treeOpts)
214
+ const matchObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid(this, item), treeOpts)
217
215
  if (matchObj) {
218
216
  const rItems = matchObj.items.splice(matchObj.index, 1)
219
217
  rest.push(rItems[0])
@@ -222,7 +220,6 @@ export default {
222
220
  if (afIndex > -1) {
223
221
  afterFullData.splice(afIndex, 1)
224
222
  }
225
- this.updateVirtualTreeData()
226
223
  })
227
224
  } else {
228
225
  rows.forEach(row => {
@@ -258,12 +255,12 @@ export default {
258
255
  insertList.splice(iIndex, 1)
259
256
  }
260
257
  })
261
- this.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
262
- this.handleTableData(transform)
258
+ this.handleTableData(treeConfig && treeOpts.transform)
263
259
  this.updateFooter()
264
260
  this.cacheRowMap()
261
+ this.updateAfterDataIndex()
265
262
  this.checkSelectionStatus()
266
- if (scrollYLoad) {
263
+ if (this.scrollYLoad) {
267
264
  this.updateScrollYSpace()
268
265
  }
269
266
  return this.$nextTick().then(() => {
@@ -316,7 +313,7 @@ export default {
316
313
  * 获取新增的临时数据
317
314
  */
318
315
  _getInsertRecords () {
319
- const { treeConfig, treeFullData, tableFullData, treeOpts } = this
316
+ const { treeConfig, tableFullTreeData, tableFullData, treeOpts } = this
320
317
  const insertList = this.editStore.insertList
321
318
  const insertRecords = []
322
319
  if (insertList.length) {
@@ -324,7 +321,7 @@ export default {
324
321
  if (treeConfig && treeOpts.transform) {
325
322
  insertList.forEach(row => {
326
323
  const rowid = getRowid(this, row)
327
- const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid(this, item), treeOpts)
324
+ const matchObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid(this, item), treeOpts)
328
325
  if (matchObj) {
329
326
  insertRecords.push(row)
330
327
  }
@@ -40,16 +40,13 @@ function hasTreeChildren ($xetable, row) {
40
40
  return row[treeOpts.children] && row[treeOpts.children].length > 0
41
41
  }
42
42
 
43
- function getSeq ($xetable, row, rowIndex, column, columnIndex, paths) {
43
+ function getSeq ($xetable, row, rowIndex, column, columnIndex) {
44
44
  const seqOpts = $xetable.seqOpts
45
45
  const seqMethod = seqOpts.seqMethod || column.seqMethod
46
46
  if (seqMethod) {
47
47
  return seqMethod({ row, rowIndex, column, columnIndex })
48
48
  }
49
- if (paths) {
50
- return paths.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
51
- }
52
- return seqOpts.startIndex + rowIndex + 1
49
+ return $xetable.getRowSeq(row)
53
50
  }
54
51
 
55
52
  function defaultFilterExportColumn (column) {
@@ -106,7 +103,7 @@ function getLabelData ($xetable, opts, columns, datas) {
106
103
  } else {
107
104
  switch (column.type) {
108
105
  case 'seq':
109
- cellValue = getSeq($xetable, row, rowIndex, column, columnIndex, path)
106
+ cellValue = getSeq($xetable, row, rowIndex, column, columnIndex)
110
107
  break
111
108
  case 'checkbox':
112
109
  cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row))
@@ -162,7 +159,7 @@ function getLabelData ($xetable, opts, columns, datas) {
162
159
  } else {
163
160
  switch (column.type) {
164
161
  case 'seq':
165
- cellValue = getSeq($xetable, row, rowIndex, column, columnIndex, null)
162
+ cellValue = getSeq($xetable, row, rowIndex, column, columnIndex)
166
163
  break
167
164
  case 'checkbox':
168
165
  cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row))
@@ -5,6 +5,25 @@ import VXETable from '../../v-x-e-table'
5
5
 
6
6
  export default {
7
7
  methods: {
8
+ /**
9
+ * 手动弹出筛选面板
10
+ * @param column
11
+ */
12
+ _openFilter (fieldOrColumn) {
13
+ const column = handleFieldOrColumn(this, fieldOrColumn)
14
+ if (column && column.filters) {
15
+ const { elemStore } = this
16
+ const { fixed } = column
17
+ return this.scrollToColumn(column).then(() => {
18
+ const headerWrapperElem = elemStore[`${fixed || 'main'}-header-wrapper`] || elemStore['main-header-wrapper']
19
+ if (headerWrapperElem) {
20
+ const filterBtnElem = headerWrapperElem.querySelector(`.vxe-header--column.${column.id} .vxe-filter--btn`)
21
+ DomTools.triggerEvent(filterBtnElem, 'click')
22
+ }
23
+ })
24
+ }
25
+ return this.$nextTick()
26
+ },
8
27
  /**
9
28
  * 修改筛选条件列表
10
29
  * @param {ColumnInfo} fieldOrColumn 列
@@ -85,7 +104,7 @@ export default {
85
104
  // 判断面板不能大于表格高度
86
105
  let maxHeight = null
87
106
  if (filterHeight >= bodyElem.clientHeight) {
88
- maxHeight = Math.max(40, bodyElem.clientHeight - (filterFootElem ? filterFootElem.offsetHeight : 0) - (filterHeadElem ? filterHeadElem.offsetHeight : 0))
107
+ maxHeight = Math.max(60, bodyElem.clientHeight - (filterFootElem ? filterFootElem.offsetHeight : 0) - (filterHeadElem ? filterHeadElem.offsetHeight : 0))
89
108
  }
90
109
  if (column.fixed === 'left') {
91
110
  left = targetElem.offsetLeft + targetElem.offsetParent.offsetLeft - centerWidth
@@ -13,7 +13,7 @@ function getOptUniqueId () {
13
13
  }
14
14
 
15
15
  function getOptkey (_vm) {
16
- return _vm.optionId || '_XID'
16
+ return _vm.optionId || '_X_ID'
17
17
  }
18
18
 
19
19
  function getOptid (_vm, option) {
@@ -40,7 +40,7 @@ function renderLine (h, _vm, $xetable, rowLevel, items, params) {
40
40
  /**
41
41
  * 渲染列
42
42
  */
43
- function renderColumn (h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, columns, items) {
43
+ function renderColumn (h, _vm, $xetable, seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, columns, items) {
44
44
  const {
45
45
  $listeners: tableListeners,
46
46
  afterFullData,
@@ -98,7 +98,7 @@ function renderColumn (h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel,
98
98
  const bindMouseenter = tableListeners['cell-mouseenter']
99
99
  const bindMouseleave = tableListeners['cell-mouseleave']
100
100
  const triggerDblclick = (editRender && editConfig && editOpts.trigger === 'dblclick')
101
- const params = { $table: $xetable, $seq, seq, rowid, row, rowIndex, $rowIndex, _rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, level: rowLevel, visibleData: afterFullData, data: tableData, items }
101
+ const params = { $table: $xetable, seq, rowid, row, rowIndex, $rowIndex, _rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, level: rowLevel, visibleData: afterFullData, data: tableData, items }
102
102
  // 虚拟滚动不支持动态高度
103
103
  if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
104
104
  showEllipsis = hasEllipsis = true
@@ -266,7 +266,7 @@ function renderColumn (h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel,
266
266
  }, tdVNs)
267
267
  }
268
268
 
269
- function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn) {
269
+ function renderRows (h, _vm, $xetable, fixedType, tableData, tableColumn) {
270
270
  const {
271
271
  stripe,
272
272
  rowKey,
@@ -280,24 +280,19 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
280
280
  editOpts,
281
281
  treeExpandeds,
282
282
  scrollYLoad,
283
- scrollYStore,
284
283
  editStore,
285
284
  rowExpandeds,
286
285
  radioOpts,
287
286
  checkboxOpts,
288
287
  expandColumn,
289
288
  hasFixedColumn,
290
- fullAllDataRowIdData,
289
+ fullDataRowIdData,
291
290
  rowOpts
292
291
  } = $xetable
293
292
  const rows = []
294
293
  tableData.forEach((row, $rowIndex) => {
295
294
  const trOn = {}
296
295
  let rowIndex = $rowIndex
297
- let seq = rowIndex + 1
298
- if (scrollYLoad) {
299
- seq += scrollYStore.startIndex
300
- }
301
296
  const _rowIndex = $xetable.getVTRowIndex(row)
302
297
  // 确保任何情况下 rowIndex 都精准指向真实 data 索引
303
298
  rowIndex = $xetable.getRowIndex(row)
@@ -317,9 +312,10 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
317
312
  }
318
313
  }
319
314
  const rowid = UtilTools.getRowid($xetable, row)
320
- const rest = fullAllDataRowIdData[rowid]
315
+ const rest = fullDataRowIdData[rowid]
321
316
  const rowLevel = rest ? rest.level : 0
322
- const params = { $table: $xetable, $seq, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
317
+ const seq = rest ? rest.seq : -1
318
+ const params = { $table: $xetable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
323
319
  let isNewRow = false
324
320
  if (editConfig) {
325
321
  isNewRow = editStore.insertList.indexOf(row) > -1
@@ -340,7 +336,7 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
340
336
  key: rowKey || treeConfig ? rowid : $rowIndex,
341
337
  on: trOn
342
338
  }, tableColumn.map((column, $columnIndex) => {
343
- return renderColumn(h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
339
+ return renderColumn(h, _vm, $xetable, seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
344
340
  }))
345
341
  )
346
342
  // 如果行被展开了
@@ -353,7 +349,7 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
353
349
  }
354
350
  const { showOverflow } = expandColumn
355
351
  const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? allColumnOverflow : showOverflow
356
- const expandParams = { $table: $xetable, $seq, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
352
+ const expandParams = { $table: $xetable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
357
353
  rows.push(
358
354
  h('tr', {
359
355
  class: 'vxe-body--expanded-row',
@@ -381,10 +377,10 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
381
377
  )
382
378
  }
383
379
  // 如果是树形表格
384
- if (treeConfig && !scrollYLoad && treeExpandeds.length) {
380
+ if (treeConfig && !scrollYLoad && !treeOpts.transform && treeExpandeds.length) {
385
381
  const rowChildren = row[treeOpts.children]
386
382
  if (rowChildren && rowChildren.length && treeExpandeds.indexOf(row) > -1) {
387
- rows.push(...renderRows(h, _vm, $xetable, $seq ? `${$seq}.${seq}` : `${seq}`, fixedType, rowChildren, tableColumn))
383
+ rows.push(...renderRows(h, _vm, $xetable, fixedType, rowChildren, tableColumn))
388
384
  }
389
385
  }
390
386
  })
@@ -529,7 +525,7 @@ export default {
529
525
  */
530
526
  h('tbody', {
531
527
  ref: 'tbody'
532
- }, renderRows(h, this, $xetable, '', fixedType, tableData, tableColumn))
528
+ }, renderRows(h, this, $xetable, fixedType, tableData, tableColumn))
533
529
  ]),
534
530
  h('div', {
535
531
  class: 'vxe-table--checkbox-range'
@@ -99,16 +99,16 @@ export const Cell = {
99
99
  }
100
100
  switch (type) {
101
101
  case 'seq':
102
- renMaps.renderHeader = this.renderIndexHeader
103
- renMaps.renderCell = treeNode ? this.renderTreeIndexCell : this.renderIndexCell
102
+ renMaps.renderHeader = this.renderSeqHeader
103
+ renMaps.renderCell = treeNode ? this.renderTreeIndexCell : this.renderSeqCell
104
104
  break
105
105
  case 'radio':
106
106
  renMaps.renderHeader = this.renderRadioHeader
107
107
  renMaps.renderCell = treeNode ? this.renderTreeRadioCell : this.renderRadioCell
108
108
  break
109
109
  case 'checkbox':
110
- renMaps.renderHeader = this.renderSelectionHeader
111
- renMaps.renderCell = checkboxOpts.checkField ? (treeNode ? this.renderTreeSelectionCellByProp : this.renderSelectionCellByProp) : (treeNode ? this.renderTreeSelectionCell : this.renderSelectionCell)
110
+ renMaps.renderHeader = this.renderCheckboxHeader
111
+ renMaps.renderCell = checkboxOpts.checkField ? (treeNode ? this.renderTreeSelectionCellByProp : this.renderCheckboxCellByProp) : (treeNode ? this.renderTreeSelectionCell : this.renderCheckboxCell)
112
112
  break
113
113
  case 'expand':
114
114
  renMaps.renderCell = this.renderExpandCell
@@ -253,24 +253,24 @@ export const Cell = {
253
253
  /**
254
254
  * 索引
255
255
  */
256
- renderIndexHeader (h, params) {
256
+ renderSeqHeader (h, params) {
257
257
  const { $table, column } = params
258
258
  const { slots } = column
259
259
  return renderTitleContent(h, params, slots && slots.header ? $table.callSlot(slots.header, params, h) : UtilTools.formatText(column.getTitle(), 1))
260
260
  },
261
- renderIndexCell (h, params) {
261
+ renderSeqCell (h, params) {
262
262
  const { $table, column } = params
263
- const { seqOpts } = $table
263
+ const { treeConfig, seqOpts } = $table
264
264
  const { slots } = column
265
265
  if (slots && slots.default) {
266
266
  return $table.callSlot(slots.default, params, h)
267
267
  }
268
- const { $seq, seq, level } = params
268
+ const { seq } = params
269
269
  const seqMethod = seqOpts.seqMethod
270
- return [UtilTools.formatText(seqMethod ? seqMethod(params) : level ? `${$seq}.${seq}` : (seqOpts.startIndex) + seq, 1)]
270
+ return [UtilTools.formatText(seqMethod ? seqMethod(params) : treeConfig ? seq : (seqOpts.startIndex || 0) + seq, 1)]
271
271
  },
272
272
  renderTreeIndexCell (h, params) {
273
- return Cell.renderTreeIcon(h, params, Cell.renderIndexCell(h, params))
273
+ return Cell.renderTreeIcon(h, params, Cell.renderSeqCell(h, params))
274
274
  },
275
275
 
276
276
  /**
@@ -350,7 +350,7 @@ export const Cell = {
350
350
  /**
351
351
  * 多选
352
352
  */
353
- renderSelectionHeader (h, params) {
353
+ renderCheckboxHeader (h, params) {
354
354
  const { $table, column, isHidden } = params
355
355
  const { isIndeterminate: isAllCheckboxIndeterminate, isAllCheckboxDisabled } = $table
356
356
  const { slots } = column
@@ -409,7 +409,7 @@ export const Cell = {
409
409
  ] : []))
410
410
  ])
411
411
  },
412
- renderSelectionCell (h, params) {
412
+ renderCheckboxCell (h, params) {
413
413
  const { $table, row, column, isHidden } = params
414
414
  const { treeConfig, treeIndeterminates } = $table
415
415
  const { labelField, checkMethod, visibleMethod } = $table.checkboxOpts
@@ -474,9 +474,9 @@ export const Cell = {
474
474
  ]
475
475
  },
476
476
  renderTreeSelectionCell (h, params) {
477
- return Cell.renderTreeIcon(h, params, Cell.renderSelectionCell(h, params))
477
+ return Cell.renderTreeIcon(h, params, Cell.renderCheckboxCell(h, params))
478
478
  },
479
- renderSelectionCellByProp (h, params) {
479
+ renderCheckboxCellByProp (h, params) {
480
480
  const { $table, row, column, isHidden } = params
481
481
  const { treeConfig, treeIndeterminates } = $table
482
482
  const { labelField, checkField: property, halfField, checkMethod, visibleMethod } = $table.checkboxOpts
@@ -541,7 +541,7 @@ export const Cell = {
541
541
  ]
542
542
  },
543
543
  renderTreeSelectionCellByProp (h, params) {
544
- return Cell.renderTreeIcon(h, params, Cell.renderSelectionCellByProp(h, params))
544
+ return Cell.renderTreeIcon(h, params, Cell.renderCheckboxCellByProp(h, params))
545
545
  },
546
546
 
547
547
  /**