vxe-table 3.8.8-beta.7 → 3.8.8-beta.8
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/lib/edit/src/mixin.js +4 -4
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/export/src/mixin.js +27 -21
- package/lib/export/src/mixin.min.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.umd.js +128 -99
- package/lib/index.umd.min.js +1 -1
- package/lib/keyboard/src/mixin.js +2 -2
- package/lib/keyboard/src/mixin.min.js +1 -1
- package/lib/menu/src/mixin.js +1 -1
- package/lib/menu/src/mixin.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/src/cell.js +0 -6
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/methods.js +96 -67
- package/lib/table/src/methods.min.js +1 -1
- package/lib/tools/log.js +1 -1
- package/lib/tools/log.min.js +1 -1
- package/lib/v-x-e-table/index.js +1 -1
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/validator/src/mixin.js +1 -1
- package/lib/validator/src/mixin.min.js +1 -1
- package/package.json +1 -1
- package/packages/edit/src/mixin.js +4 -4
- package/packages/export/src/mixin.js +19 -13
- package/packages/keyboard/src/mixin.js +2 -2
- package/packages/menu/src/mixin.js +1 -1
- package/packages/table/src/cell.js +0 -6
- package/packages/table/src/methods.js +82 -53
- package/packages/validator/src/mixin.js +1 -1
- package/types/table.d.ts +4 -0
- /package/lib/icon/style/{iconfont.1718470675024.ttf → iconfont.1719059955747.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1718470675024.woff → iconfont.1719059955747.woff} +0 -0
- /package/lib/icon/style/{iconfont.1718470675024.woff2 → iconfont.1719059955747.woff2} +0 -0
- /package/lib/{iconfont.1718470675024.ttf → iconfont.1719059955747.ttf} +0 -0
- /package/lib/{iconfont.1718470675024.woff → iconfont.1719059955747.woff} +0 -0
- /package/lib/{iconfont.1718470675024.woff2 → iconfont.1719059955747.woff2} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_vXETable=_interopRequireDefault(require("../../v-x-e-table")),_conf=_interopRequireDefault(require("../../v-x-e-table/src/conf")),_util=require("../../table/src/util"),_utils=require("../../tools/utils"),_log=require("../../tools/log"),_dom=_interopRequireDefault(require("../../tools/dom"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(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,_toPropertyKey(i.key),i)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}var Rule=function(){return _createClass(function e(t){_classCallCheck(this,e),Object.assign(this,{$options:t,required:t.required,min:t.min,max:t.max,type:t.type,pattern:t.pattern,validator:t.validator,trigger:t.trigger,maxWidth:t.maxWidth})},[{key:"content",get:function(){return(0,_utils.getFuncText)(this.$options.content||this.$options.message)}},{key:"message",get:function(){return this.content}}])}();function validErrorRuleValue(e,t){var r=e.type,i=e.min,l=e.max,e=e.pattern,r="number"===r,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_vXETable=_interopRequireDefault(require("../../v-x-e-table")),_conf=_interopRequireDefault(require("../../v-x-e-table/src/conf")),_util=require("../../table/src/util"),_utils=require("../../tools/utils"),_log=require("../../tools/log"),_dom=_interopRequireDefault(require("../../tools/dom"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(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,_toPropertyKey(i.key),i)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}var Rule=function(){return _createClass(function e(t){_classCallCheck(this,e),Object.assign(this,{$options:t,required:t.required,min:t.min,max:t.max,type:t.type,pattern:t.pattern,validator:t.validator,trigger:t.trigger,maxWidth:t.maxWidth})},[{key:"content",get:function(){return(0,_utils.getFuncText)(this.$options.content||this.$options.message)}},{key:"message",get:function(){return this.content}}])}();function validErrorRuleValue(e,t){var r=e.type,i=e.min,l=e.max,e=e.pattern,r="number"===r,n=r?_xeUtils.default.toNumber(t):_xeUtils.default.getSize(t);return!(!r||!isNaN(t))||!_xeUtils.default.eqNull(i)&&n<_xeUtils.default.toNumber(i)||!_xeUtils.default.eqNull(l)&&n>_xeUtils.default.toNumber(l)||!(!e||(_xeUtils.default.isRegExp(e)?e:new RegExp(e)).test(t))}var _default=exports.default={methods:{_fullValidate:function(e,t){return"development"===process.env.NODE_ENV&&_xeUtils.default.isFunction(t)&&(0,_log.warnLog)("vxe.error.notValidators",["fullValidate(rows, callback)","fullValidate(rows)"]),this.beginValidate(e,t,!0)},_validate:function(e,t){return"development"===process.env.NODE_ENV&&_xeUtils.default.isFunction(t)&&(0,_log.warnLog)("vxe.error.notValidators",["validate(rows, callback)","validate(rows)"]),this.beginValidate(e,t)},handleValidError:function(t){var r=this,i=this.validOpts;return new Promise(function(e){!1===i.autoPos?(r.emitEvent("valid-error",t),e()):r.handleActived(t,{type:"valid-error",trigger:"call"}).then(function(){setTimeout(function(){e(r.showValidTooltip(t))},10)})})},handleErrMsgMode:function(e){var t,r;return"single"===this.validOpts.msgMode?(t=e,(r=Object.keys(e)).length&&(t[r=r[0]]=e[r]),t):e},beginValidate:function(e,s,l){var t,r,u=this,c={},n=this.editRules,d=this.afterFullData,f=this.visibleColumn,i=this.treeConfig,o=this.treeOpts,o=o.children||o.childrenField,a=(!0===e?t=d:e&&(_xeUtils.default.isFunction(e)?s=e:t=_xeUtils.default.isArray(e)?e:[e]),t=t||this.getInsertRecords().concat(this.getUpdateRecords()),[]),h=(this.lastCallTime=Date.now(),this.validRuleErr=!1,this.clearValidate(),{});return n?(r=this.getColumns(),e=function(i){var e;!l&&u.validRuleErr||(e=[],r.forEach(function(r){!l&&u.validRuleErr||!_xeUtils.default.has(n,r.property)||e.push(u.validCellRules("all",i,r).catch(function(e){var t=e.rule,e={rule:t,rules:e.rules,rowIndex:u.getRowIndex(i),row:i,columnIndex:u.getColumnIndex(r),column:r,field:r.property,$table:u};if(c[r.property]||(c[r.property]=[]),h["".concat((0,_util.getRowid)(u,i),":").concat(r.id)]={column:r,row:i,rule:t,content:t.content},c[r.property].push(e),!l)return u.validRuleErr=!0,Promise.reject(e)}))}),a.push(Promise.all(e)))},i?_xeUtils.default.eachTree(t,e,{children:o}):t.forEach(e),Promise.all(a).then(function(){var e=Object.keys(c);return u.validErrorMaps=u.handleErrMsgMode(h),u.$nextTick().then(function(){if(e.length)return Promise.reject(c[e[0]][0]);s&&s()})}).catch(function(a){return new Promise(function(e,t){function r(){u.$nextTick(function(){s?(s(c),e()):("obsolete"===_conf.default.validToReject?t:e)(c)})}var i,l,n,o;!1===u.validOpts.autoPos?r():(o=a.row,i=a.column,n=d.indexOf(o),l=f.indexOf(i),n=0<n?d[n-1]:o,o=0<l?f[l-1]:i,u.scrollToRow(n,o).then(function(){a.cell=u.getCellElement(a.row,a.column),_dom.default.scrollToView(a.cell),u.handleValidError(a).then(r)}))})})):(this.validErrorMaps={},this.$nextTick().then(function(){s&&s()}))},hasCellRules:function(t,e,r){var i=this.editRules,r=r.property;return!(!r||!i)&&(i=_xeUtils.default.get(i,r))&&_xeUtils.default.find(i,function(e){return"all"===t||!e.trigger||t===e.trigger})},validCellRules:function(s,u,c,e){var d,f,h=this,t=this.editRules,r=c.property,p=[],g=[];return r&&t&&(d=_xeUtils.default.get(t,r))&&(f=_xeUtils.default.isUndefined(e)?_xeUtils.default.get(u,r):e,d.forEach(function(t){var e,r,i,l=t.type,n=t.trigger,o=t.required,a=t.validator;"all"!==s&&n&&s!==n||(a?(i={cellValue:f,rule:t,rules:d,row:u,rowIndex:h.getRowIndex(u),column:c,columnIndex:h.getColumnIndex(c),field:c.property,$table:h},_xeUtils.default.isString(a)?(r=_vXETable.default.validators.get(a))?r.cellValidatorMethod?e=r.cellValidatorMethod(i):"development"===process.env.NODE_ENV&&(0,_log.warnLog)("vxe.error.notValidators",[a]):"development"===process.env.NODE_ENV&&(0,_log.errLog)("vxe.error.notValidators",[a]):e=a(i),e&&(_xeUtils.default.isError(e)?(h.validRuleErr=!0,p.push(new Rule({type:"custom",trigger:n,content:e.message,rule:new Rule(t)}))):e.catch&&g.push(e.catch(function(e){h.validRuleErr=!0,p.push(new Rule({type:"custom",trigger:n,content:e&&e.message?e.message:t.content||t.message,rule:new Rule(t)}))})))):(r="array"===l,a=_xeUtils.default.isArray(f),i=!0,i=r||a?!a||!f.length:_xeUtils.default.isString(f)?(0,_utils.eqEmptyValue)(f.trim()):(0,_utils.eqEmptyValue)(f),(o?i||validErrorRuleValue(t,f):!i&&validErrorRuleValue(t,f))&&(h.validRuleErr=!0,p.push(new Rule(t)))))})),Promise.all(g).then(function(){if(p.length)return Promise.reject({rules:p,rule:p[0]})})},_clearValidate:function(e,t){var r,i,l=this,n=this.validOpts,o=this.validErrorMaps,a=this.$refs.validTip,e=_xeUtils.default.isArray(e)?e:e?[e]:[],s=_xeUtils.default.isArray(t)?t:(t?[t]:[]).map(function(e){return(0,_util.handleFieldOrColumn)(l,e)}),u={};return a&&a.visible&&a.close(),"single"===n.msgMode?this.validErrorMaps={}:(e.length&&s.length?(u=Object.assign({},o),e.forEach(function(t){s.forEach(function(e){e="".concat((0,_util.getRowid)(l,t),":").concat(e.id);u[e]&&delete u[e]})})):e.length?(r=e.map(function(e){return"".concat((0,_util.getRowid)(l,e))}),_xeUtils.default.each(o,function(e,t){-1<r.indexOf(t.split(":")[0])&&(u[t]=e)})):s.length&&(i=s.map(function(e){return"".concat(e.id)}),_xeUtils.default.each(o,function(e,t){-1<i.indexOf(t.split(":")[1])&&(u[t]=e)})),this.validErrorMaps=u),this.$nextTick()},triggerValidate:function(t){var r=this,e=this.editConfig,i=this.editStore,l=this.editRules,n=this.editOpts,o=this.validOpts,i=i.actived;if(l&&"single"===o.msgMode&&(this.validErrorMaps={}),e&&l&&i.row){var o=i.args,a=o.row,s=o.column,u=o.cell;if(this.hasCellRules(t,a,s))return this.validCellRules(t,a,s).then(function(){"row"===n.mode&&r.clearValidate(a,s)}).catch(function(e){var e=e.rule;return e.trigger&&t!==e.trigger?Promise.resolve():(r.showValidTooltip(e={rule:e,row:a,column:s,cell:u}),Promise.reject(e))})}return Promise.resolve()},showValidTooltip:function(e){var t=this.$refs,r=this.height,i=this.validStore,l=this.validErrorMaps,n=this.tableData,o=this.validOpts,a=e.rule,s=e.row,u=e.column,c=e.cell,t=t.validTip,d=a.content;return i.visible=!0,"single"===o.msgMode?this.validErrorMaps=_defineProperty({},"".concat((0,_util.getRowid)(this,s),":").concat(u.id),{column:u,row:s,rule:a,content:d}):this.validErrorMaps=Object.assign({},l,_defineProperty({},"".concat((0,_util.getRowid)(this,s),":").concat(u.id),{column:u,row:s,rule:a,content:d})),this.emitEvent("valid-error",e,null),t&&("tooltip"===o.message||"default"===o.message&&!r&&n.length<2)?t.open(c,d):this.$nextTick()}}};
|
package/package.json
CHANGED
|
@@ -425,7 +425,7 @@ export default {
|
|
|
425
425
|
const { actived, focused } = editStore
|
|
426
426
|
const { row, column } = params
|
|
427
427
|
const { editRender } = column
|
|
428
|
-
const cell = params.cell = (params.cell || this.
|
|
428
|
+
const cell = params.cell = (params.cell || this.getCellElement(row, column))
|
|
429
429
|
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod
|
|
430
430
|
if (cell && isEnableConf(editConfig) && isEnableConf(editRender)) {
|
|
431
431
|
// 激活编辑
|
|
@@ -678,7 +678,7 @@ export default {
|
|
|
678
678
|
const column = XEUtils.isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn
|
|
679
679
|
if (row && column && isEnableConf(editConfig) && isEnableConf(column.editRender)) {
|
|
680
680
|
return this.scrollToRow(row, true).then(() => {
|
|
681
|
-
const cell = this.
|
|
681
|
+
const cell = this.getCellElement(row, column)
|
|
682
682
|
if (cell) {
|
|
683
683
|
this.handleActived({ row, rowIndex: this.getRowIndex(row), column, columnIndex: this.getColumnIndex(column), cell, $table: this })
|
|
684
684
|
this.lastCallTime = Date.now()
|
|
@@ -696,7 +696,7 @@ export default {
|
|
|
696
696
|
if (row && column && editOpts.trigger !== 'manual') {
|
|
697
697
|
const rowIndex = this.findRowIndexOf(tableData, row)
|
|
698
698
|
if (rowIndex > -1) {
|
|
699
|
-
const cell = this.
|
|
699
|
+
const cell = this.getCellElement(row, column)
|
|
700
700
|
const params = { row, rowIndex, column, columnIndex: visibleColumn.indexOf(column), cell }
|
|
701
701
|
this.handleSelected(params, {})
|
|
702
702
|
}
|
|
@@ -772,7 +772,7 @@ export default {
|
|
|
772
772
|
const { row, column } = selected
|
|
773
773
|
this.reColSdCls()
|
|
774
774
|
if (row && column) {
|
|
775
|
-
const cell = this.
|
|
775
|
+
const cell = this.getCellElement(row, column)
|
|
776
776
|
if (cell) {
|
|
777
777
|
DomTools.addClass(cell, 'col--selected')
|
|
778
778
|
}
|
|
@@ -137,7 +137,7 @@ function getLabelData ($xetable, opts, columns, datas) {
|
|
|
137
137
|
htmlCellElem.innerHTML = cellValue
|
|
138
138
|
cellValue = htmlCellElem.innerText.trim()
|
|
139
139
|
} else {
|
|
140
|
-
const cell = $xetable.
|
|
140
|
+
const cell = $xetable.getCellElement(row, column)
|
|
141
141
|
if (cell) {
|
|
142
142
|
cellValue = cell.innerText.trim()
|
|
143
143
|
}
|
|
@@ -193,7 +193,7 @@ function getLabelData ($xetable, opts, columns, datas) {
|
|
|
193
193
|
htmlCellElem.innerHTML = cellValue
|
|
194
194
|
cellValue = htmlCellElem.innerText.trim()
|
|
195
195
|
} else {
|
|
196
|
-
const cell = $xetable.
|
|
196
|
+
const cell = $xetable.getCellElement(row, column)
|
|
197
197
|
if (cell) {
|
|
198
198
|
cellValue = cell.innerText.trim()
|
|
199
199
|
}
|
|
@@ -226,7 +226,7 @@ function getHeaderTitle ($xetable, opts, column) {
|
|
|
226
226
|
return headExportMethod ? headExportMethod({ column, options: opts, $table: $xetable }) : ((opts.original ? column.property : column.getTitle()) || '')
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
function getFooterCellValue ($xetable, opts,
|
|
229
|
+
function getFooterCellValue ($xetable, opts, row, column) {
|
|
230
230
|
const { columnOpts } = $xetable
|
|
231
231
|
const renderOpts = column.editRender || column.cellRender
|
|
232
232
|
let footLabelMethod = column.footerExportMethod
|
|
@@ -240,8 +240,14 @@ function getFooterCellValue ($xetable, opts, items, column) {
|
|
|
240
240
|
footLabelMethod = columnOpts.footerExportMethod
|
|
241
241
|
}
|
|
242
242
|
const _columnIndex = $xetable.getVTColumnIndex(column)
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
if (footLabelMethod) {
|
|
244
|
+
return footLabelMethod({ $table: $xetable, items: row, itemIndex: _columnIndex, row, _columnIndex, column, options: opts })
|
|
245
|
+
}
|
|
246
|
+
// 兼容老模式
|
|
247
|
+
if (XEUtils.isArray(row)) {
|
|
248
|
+
return XEUtils.toValueString(row[_columnIndex])
|
|
249
|
+
}
|
|
250
|
+
return XEUtils.get(row, column.field)
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
function getFooterData (opts, footerTableData) {
|
|
@@ -290,8 +296,8 @@ function toCsv ($xetable, opts, columns, datas) {
|
|
|
290
296
|
if (opts.isFooter) {
|
|
291
297
|
const footerTableData = $xetable.footerTableData
|
|
292
298
|
const footers = getFooterData(opts, footerTableData)
|
|
293
|
-
footers.forEach(
|
|
294
|
-
content += columns.map(column => toTxtCellLabel(getFooterCellValue($xetable, opts,
|
|
299
|
+
footers.forEach(row => {
|
|
300
|
+
content += columns.map(column => toTxtCellLabel(getFooterCellValue($xetable, opts, row, column))).join(',') + enterSymbol
|
|
295
301
|
})
|
|
296
302
|
}
|
|
297
303
|
return content
|
|
@@ -308,8 +314,8 @@ function toTxt ($xetable, opts, columns, datas) {
|
|
|
308
314
|
if (opts.isFooter) {
|
|
309
315
|
const footerTableData = $xetable.footerTableData
|
|
310
316
|
const footers = getFooterData(opts, footerTableData)
|
|
311
|
-
footers.forEach(
|
|
312
|
-
content += columns.map(column => toTxtCellLabel(getFooterCellValue($xetable, opts,
|
|
317
|
+
footers.forEach(row => {
|
|
318
|
+
content += columns.map(column => toTxtCellLabel(getFooterCellValue($xetable, opts, row, column))).join(',') + enterSymbol
|
|
313
319
|
})
|
|
314
320
|
}
|
|
315
321
|
return content
|
|
@@ -485,12 +491,12 @@ function toHtml ($xetable, opts, columns, datas) {
|
|
|
485
491
|
const footers = getFooterData(opts, footerTableData)
|
|
486
492
|
if (footers.length) {
|
|
487
493
|
tables.push('<tfoot>')
|
|
488
|
-
footers.forEach(
|
|
494
|
+
footers.forEach(row => {
|
|
489
495
|
tables.push(
|
|
490
496
|
`<tr>${columns.map(column => {
|
|
491
497
|
const footAlign = column.footerAlign || column.align || allFooterAlign || allAlign
|
|
492
498
|
const classNames = hasEllipsis($xetable, column, 'showOverflow', allColumnOverflow) ? ['col--ellipsis'] : []
|
|
493
|
-
const cellValue = getFooterCellValue($xetable, opts,
|
|
499
|
+
const cellValue = getFooterCellValue($xetable, opts, row, column)
|
|
494
500
|
if (footAlign) {
|
|
495
501
|
classNames.push(`col--${footAlign}`)
|
|
496
502
|
}
|
|
@@ -536,8 +542,8 @@ function toXML ($xetable, opts, columns, datas) {
|
|
|
536
542
|
if (opts.isFooter) {
|
|
537
543
|
const footerTableData = $xetable.footerTableData
|
|
538
544
|
const footers = getFooterData(opts, footerTableData)
|
|
539
|
-
footers.forEach(
|
|
540
|
-
xml += `<Row>${columns.map(column => `<Cell><Data ss:Type="String">${getFooterCellValue($xetable, opts,
|
|
545
|
+
footers.forEach(row => {
|
|
546
|
+
xml += `<Row>${columns.map(column => `<Cell><Data ss:Type="String">${getFooterCellValue($xetable, opts, row, column)}</Data></Cell>`).join('')}</Row>`
|
|
541
547
|
})
|
|
542
548
|
}
|
|
543
549
|
return `${xml}</Table></Worksheet></Workbook>`
|
|
@@ -93,7 +93,7 @@ export default {
|
|
|
93
93
|
}
|
|
94
94
|
params.columnIndex = targetColumnIndex
|
|
95
95
|
params.column = targetColumn
|
|
96
|
-
params.cell = this.
|
|
96
|
+
params.cell = this.getCellElement(params.row, params.column)
|
|
97
97
|
if (editConfig) {
|
|
98
98
|
if (editOpts.trigger === 'click' || editOpts.trigger === 'dblclick') {
|
|
99
99
|
if (editOpts.mode === 'row') {
|
|
@@ -165,7 +165,7 @@ export default {
|
|
|
165
165
|
params.column = visibleColumn[params.columnIndex]
|
|
166
166
|
}
|
|
167
167
|
this.scrollToRow(params.row, params.column).then(() => {
|
|
168
|
-
params.cell = this.
|
|
168
|
+
params.cell = this.getCellElement(params.row, params.column)
|
|
169
169
|
this.handleSelected(params, evnt)
|
|
170
170
|
})
|
|
171
171
|
},
|
|
@@ -180,7 +180,7 @@ export default {
|
|
|
180
180
|
const { keyboard, row, column } = params
|
|
181
181
|
if (keyboard && row && column) {
|
|
182
182
|
this.scrollToRow(row, column).then(() => {
|
|
183
|
-
const cell = this.
|
|
183
|
+
const cell = this.getCellElement(row, column)
|
|
184
184
|
const { boundingTop, boundingLeft } = DomTools.getAbsolutePos(cell)
|
|
185
185
|
top = boundingTop + scrollTop + Math.floor(cell.offsetHeight / 2)
|
|
186
186
|
left = boundingLeft + scrollLeft + Math.floor(cell.offsetWidth / 2)
|
|
@@ -254,7 +254,6 @@ export const Cell = {
|
|
|
254
254
|
}
|
|
255
255
|
if (!trigger || trigger === 'default') {
|
|
256
256
|
on.click = evnt => {
|
|
257
|
-
evnt.stopPropagation()
|
|
258
257
|
$table.triggerTreeExpandEvent(evnt, params)
|
|
259
258
|
}
|
|
260
259
|
}
|
|
@@ -337,7 +336,6 @@ export const Cell = {
|
|
|
337
336
|
on = {
|
|
338
337
|
click (evnt) {
|
|
339
338
|
if (!isDisabled && isVisible) {
|
|
340
|
-
evnt.stopPropagation()
|
|
341
339
|
$table.triggerRadioRowEvent(evnt, params)
|
|
342
340
|
}
|
|
343
341
|
}
|
|
@@ -395,7 +393,6 @@ export const Cell = {
|
|
|
395
393
|
on = {
|
|
396
394
|
click (evnt) {
|
|
397
395
|
if (!isAllCheckboxDisabled) {
|
|
398
|
-
evnt.stopPropagation()
|
|
399
396
|
$table.triggerCheckAllEvent(evnt, !isAllCheckboxSelected)
|
|
400
397
|
}
|
|
401
398
|
}
|
|
@@ -452,7 +449,6 @@ export const Cell = {
|
|
|
452
449
|
on = {
|
|
453
450
|
click (evnt) {
|
|
454
451
|
if (!isDisabled && isVisible) {
|
|
455
|
-
evnt.stopPropagation()
|
|
456
452
|
$table.triggerCheckRowEvent(evnt, params, !isChecked)
|
|
457
453
|
}
|
|
458
454
|
}
|
|
@@ -517,7 +513,6 @@ export const Cell = {
|
|
|
517
513
|
on = {
|
|
518
514
|
click (evnt) {
|
|
519
515
|
if (!isDisabled && isVisible) {
|
|
520
|
-
evnt.stopPropagation()
|
|
521
516
|
$table.triggerCheckRowEvent(evnt, params, !isChecked)
|
|
522
517
|
}
|
|
523
518
|
}
|
|
@@ -592,7 +587,6 @@ export const Cell = {
|
|
|
592
587
|
}],
|
|
593
588
|
on: {
|
|
594
589
|
click (evnt) {
|
|
595
|
-
evnt.stopPropagation()
|
|
596
590
|
$table.triggerRowExpandEvent(evnt, params)
|
|
597
591
|
}
|
|
598
592
|
}
|
|
@@ -1103,6 +1103,63 @@ const Methods = {
|
|
|
1103
1103
|
}
|
|
1104
1104
|
return this.$nextTick()
|
|
1105
1105
|
},
|
|
1106
|
+
getCellElement (row, fieldOrColumn) {
|
|
1107
|
+
const column = handleFieldOrColumn(this, fieldOrColumn)
|
|
1108
|
+
if (!column) {
|
|
1109
|
+
return null
|
|
1110
|
+
}
|
|
1111
|
+
const { $refs } = this
|
|
1112
|
+
const rowid = getRowid(this, row)
|
|
1113
|
+
let bodyElem = null
|
|
1114
|
+
if (column) {
|
|
1115
|
+
bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.tableBody
|
|
1116
|
+
}
|
|
1117
|
+
if (bodyElem && bodyElem.$el) {
|
|
1118
|
+
return bodyElem.$el.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`)
|
|
1119
|
+
}
|
|
1120
|
+
return null
|
|
1121
|
+
},
|
|
1122
|
+
getCellLabel (row, fieldOrColumn) {
|
|
1123
|
+
const column = handleFieldOrColumn(this, fieldOrColumn)
|
|
1124
|
+
if (!column) {
|
|
1125
|
+
return null
|
|
1126
|
+
}
|
|
1127
|
+
const formatter = column.formatter
|
|
1128
|
+
const cellValue = UtilTools.getCellValue(row, column)
|
|
1129
|
+
let cellLabel = cellValue
|
|
1130
|
+
if (formatter) {
|
|
1131
|
+
let rest, formatData
|
|
1132
|
+
const { fullAllDataRowMap } = this
|
|
1133
|
+
const colid = column.id
|
|
1134
|
+
const cacheFormat = fullAllDataRowMap.has(row)
|
|
1135
|
+
if (cacheFormat) {
|
|
1136
|
+
rest = fullAllDataRowMap.get(row)
|
|
1137
|
+
formatData = rest.formatData
|
|
1138
|
+
if (!formatData) {
|
|
1139
|
+
formatData = fullAllDataRowMap.get(row).formatData = {}
|
|
1140
|
+
}
|
|
1141
|
+
if (rest && formatData[colid]) {
|
|
1142
|
+
if (formatData[colid].value === cellValue) {
|
|
1143
|
+
return formatData[colid].label
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
const formatParams = { cellValue, row, rowIndex: this.getRowIndex(row), column, columnIndex: this.getColumnIndex(column) }
|
|
1148
|
+
if (XEUtils.isString(formatter)) {
|
|
1149
|
+
const gFormatOpts = formats.get(formatter)
|
|
1150
|
+
cellLabel = gFormatOpts && gFormatOpts.cellFormatMethod ? gFormatOpts.cellFormatMethod(formatParams) : ''
|
|
1151
|
+
} else if (XEUtils.isArray(formatter)) {
|
|
1152
|
+
const gFormatOpts = formats.get(formatter[0])
|
|
1153
|
+
cellLabel = gFormatOpts && gFormatOpts.cellFormatMethod ? gFormatOpts.cellFormatMethod(formatParams, ...formatter.slice(1)) : ''
|
|
1154
|
+
} else {
|
|
1155
|
+
cellLabel = formatter(formatParams)
|
|
1156
|
+
}
|
|
1157
|
+
if (formatData) {
|
|
1158
|
+
formatData[colid] = { value: cellValue, label: cellLabel }
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
return cellLabel
|
|
1162
|
+
},
|
|
1106
1163
|
/**
|
|
1107
1164
|
* 检查是否为临时行数据
|
|
1108
1165
|
* @param {Row} row 行对象
|
|
@@ -1156,6 +1213,13 @@ const Methods = {
|
|
|
1156
1213
|
const columns = this.visibleColumn
|
|
1157
1214
|
return XEUtils.isUndefined(columnIndex) ? columns.slice(0) : columns[columnIndex]
|
|
1158
1215
|
},
|
|
1216
|
+
/**
|
|
1217
|
+
* 根据列获取列的唯一主键
|
|
1218
|
+
*/
|
|
1219
|
+
getColid (fieldOrColumn) {
|
|
1220
|
+
const column = handleFieldOrColumn(this, fieldOrColumn)
|
|
1221
|
+
return column ? column.id : null
|
|
1222
|
+
},
|
|
1159
1223
|
/**
|
|
1160
1224
|
* 根据列的唯一主键获取列
|
|
1161
1225
|
* @param {String} colid 列主键
|
|
@@ -2734,7 +2798,7 @@ const Methods = {
|
|
|
2734
2798
|
const { filterStore, isCtxMenu, ctxMenuStore, editStore, editOpts, editConfig, mouseConfig, mouseOpts, keyboardConfig, keyboardOpts, treeConfig, treeOpts, highlightCurrentRow, currentRow, bodyCtxMenu, rowOpts } = this
|
|
2735
2799
|
const { selected, actived } = editStore
|
|
2736
2800
|
const { keyCode } = evnt
|
|
2737
|
-
const
|
|
2801
|
+
const hasBackspaceKey = keyCode === 8
|
|
2738
2802
|
const isTab = keyCode === 9
|
|
2739
2803
|
const isEnter = keyCode === 13
|
|
2740
2804
|
const isEsc = keyCode === 27
|
|
@@ -2854,11 +2918,11 @@ const Methods = {
|
|
|
2854
2918
|
} else if (actived.row || actived.column) {
|
|
2855
2919
|
this.moveTabSelected(actived.args, hasShiftKey, evnt)
|
|
2856
2920
|
}
|
|
2857
|
-
} else if (keyboardConfig && (isDel || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow ?
|
|
2921
|
+
} else if (keyboardConfig && (treeConfig || isEnableConf(editConfig)) && (isDel || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow ? hasBackspaceKey && keyboardOpts.isArrow : hasBackspaceKey))) {
|
|
2858
2922
|
if (!isEditStatus) {
|
|
2859
2923
|
const { delMethod, backMethod } = keyboardOpts
|
|
2860
2924
|
// 如果是删除键
|
|
2861
|
-
if (keyboardOpts.isDel && (selected.row || selected.column)) {
|
|
2925
|
+
if (keyboardOpts.isDel && isEnableConf(editConfig) && (selected.row || selected.column)) {
|
|
2862
2926
|
const delPaqrams = {
|
|
2863
2927
|
row: selected.row,
|
|
2864
2928
|
rowIndex: this.getRowIndex(selected.row),
|
|
@@ -2871,7 +2935,7 @@ const Methods = {
|
|
|
2871
2935
|
} else {
|
|
2872
2936
|
setCellValue(selected.row, selected.column, null)
|
|
2873
2937
|
}
|
|
2874
|
-
if (
|
|
2938
|
+
if (hasBackspaceKey) {
|
|
2875
2939
|
if (backMethod) {
|
|
2876
2940
|
backMethod({
|
|
2877
2941
|
row: selected.row,
|
|
@@ -2888,7 +2952,7 @@ const Methods = {
|
|
|
2888
2952
|
this.updateFooter()
|
|
2889
2953
|
}
|
|
2890
2954
|
this.emitEvent('cell-delete-value', delPaqrams, evnt)
|
|
2891
|
-
} else if (
|
|
2955
|
+
} else if (hasBackspaceKey && keyboardOpts.isArrow && treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
|
|
2892
2956
|
// 如果树形表格回退键关闭当前行返回父节点
|
|
2893
2957
|
const { parent: parentRow } = XEUtils.findTree(this.afterFullData, item => item === currentRow, { children: childrenField })
|
|
2894
2958
|
if (parentRow) {
|
|
@@ -3423,6 +3487,7 @@ const Methods = {
|
|
|
3423
3487
|
if (trigger === 'manual') {
|
|
3424
3488
|
return
|
|
3425
3489
|
}
|
|
3490
|
+
evnt.stopPropagation()
|
|
3426
3491
|
if (checkboxOpts.isShiftKey && evnt.shiftKey && !this.treeConfig) {
|
|
3427
3492
|
const checkboxRecords = this.getCheckboxRecords()
|
|
3428
3493
|
if (checkboxRecords.length) {
|
|
@@ -3797,6 +3862,9 @@ const Methods = {
|
|
|
3797
3862
|
if (trigger === 'manual') {
|
|
3798
3863
|
return
|
|
3799
3864
|
}
|
|
3865
|
+
if (evnt) {
|
|
3866
|
+
evnt.stopPropagation()
|
|
3867
|
+
}
|
|
3800
3868
|
this.handleCheckAllEvent(evnt, value)
|
|
3801
3869
|
},
|
|
3802
3870
|
/**
|
|
@@ -3863,6 +3931,7 @@ const Methods = {
|
|
|
3863
3931
|
if (trigger === 'manual') {
|
|
3864
3932
|
return
|
|
3865
3933
|
}
|
|
3934
|
+
evnt.stopPropagation()
|
|
3866
3935
|
let newValue = row
|
|
3867
3936
|
let isChange = oldValue !== newValue
|
|
3868
3937
|
if (isChange) {
|
|
@@ -4442,6 +4511,7 @@ const Methods = {
|
|
|
4442
4511
|
if (trigger === 'manual') {
|
|
4443
4512
|
return
|
|
4444
4513
|
}
|
|
4514
|
+
evnt.stopPropagation()
|
|
4445
4515
|
const rowid = getRowid(this, row)
|
|
4446
4516
|
if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
|
|
4447
4517
|
const expanded = !this.isRowExpandByRow(row)
|
|
@@ -4720,6 +4790,7 @@ const Methods = {
|
|
|
4720
4790
|
if (trigger === 'manual') {
|
|
4721
4791
|
return
|
|
4722
4792
|
}
|
|
4793
|
+
evnt.stopPropagation()
|
|
4723
4794
|
const rowid = getRowid(this, row)
|
|
4724
4795
|
if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
|
|
4725
4796
|
const expanded = !this.isTreeExpandByRow(row)
|
|
@@ -5290,7 +5361,7 @@ const Methods = {
|
|
|
5290
5361
|
const type = 'change'
|
|
5291
5362
|
if (this.hasCellRules) {
|
|
5292
5363
|
if (this.hasCellRules(type, row, column)) {
|
|
5293
|
-
const cell = this.
|
|
5364
|
+
const cell = this.getCellElement(row, column)
|
|
5294
5365
|
if (cell) {
|
|
5295
5366
|
return this.validCellRules(type, row, column, cellValue)
|
|
5296
5367
|
.then(() => {
|
|
@@ -5435,54 +5506,12 @@ const Methods = {
|
|
|
5435
5506
|
/*************************
|
|
5436
5507
|
* Publish methods
|
|
5437
5508
|
*************************/
|
|
5509
|
+
/**
|
|
5510
|
+
* 已废弃,被 getCellElement 替换
|
|
5511
|
+
* @deprecated
|
|
5512
|
+
*/
|
|
5438
5513
|
getCell (row, column) {
|
|
5439
|
-
|
|
5440
|
-
const rowid = getRowid(this, row)
|
|
5441
|
-
let bodyElem = null
|
|
5442
|
-
if (column) {
|
|
5443
|
-
bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.tableBody
|
|
5444
|
-
}
|
|
5445
|
-
if (bodyElem && bodyElem.$el) {
|
|
5446
|
-
return bodyElem.$el.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`)
|
|
5447
|
-
}
|
|
5448
|
-
return null
|
|
5449
|
-
},
|
|
5450
|
-
getCellLabel (row, column) {
|
|
5451
|
-
const formatter = column.formatter
|
|
5452
|
-
const cellValue = UtilTools.getCellValue(row, column)
|
|
5453
|
-
let cellLabel = cellValue
|
|
5454
|
-
if (formatter) {
|
|
5455
|
-
let rest, formatData
|
|
5456
|
-
const { fullAllDataRowMap } = this
|
|
5457
|
-
const colid = column.id
|
|
5458
|
-
const cacheFormat = fullAllDataRowMap.has(row)
|
|
5459
|
-
if (cacheFormat) {
|
|
5460
|
-
rest = fullAllDataRowMap.get(row)
|
|
5461
|
-
formatData = rest.formatData
|
|
5462
|
-
if (!formatData) {
|
|
5463
|
-
formatData = fullAllDataRowMap.get(row).formatData = {}
|
|
5464
|
-
}
|
|
5465
|
-
if (rest && formatData[colid]) {
|
|
5466
|
-
if (formatData[colid].value === cellValue) {
|
|
5467
|
-
return formatData[colid].label
|
|
5468
|
-
}
|
|
5469
|
-
}
|
|
5470
|
-
}
|
|
5471
|
-
const formatParams = { cellValue, row, rowIndex: this.getRowIndex(row), column, columnIndex: this.getColumnIndex(column) }
|
|
5472
|
-
if (XEUtils.isString(formatter)) {
|
|
5473
|
-
const gFormatOpts = formats.get(formatter)
|
|
5474
|
-
cellLabel = gFormatOpts && gFormatOpts.cellFormatMethod ? gFormatOpts.cellFormatMethod(formatParams) : ''
|
|
5475
|
-
} else if (XEUtils.isArray(formatter)) {
|
|
5476
|
-
const gFormatOpts = formats.get(formatter[0])
|
|
5477
|
-
cellLabel = gFormatOpts && gFormatOpts.cellFormatMethod ? gFormatOpts.cellFormatMethod(formatParams, ...formatter.slice(1)) : ''
|
|
5478
|
-
} else {
|
|
5479
|
-
cellLabel = formatter(formatParams)
|
|
5480
|
-
}
|
|
5481
|
-
if (formatData) {
|
|
5482
|
-
formatData[colid] = { value: cellValue, label: cellLabel }
|
|
5483
|
-
}
|
|
5484
|
-
}
|
|
5485
|
-
return cellLabel
|
|
5514
|
+
return this.getCellElement(row, column)
|
|
5486
5515
|
},
|
|
5487
5516
|
findRowIndexOf (list, row) {
|
|
5488
5517
|
return row ? XEUtils.findIndexOf(list, item => this.eqRow(item, row)) : -1
|
|
@@ -221,7 +221,7 @@ export default {
|
|
|
221
221
|
})
|
|
222
222
|
}
|
|
223
223
|
const posAndFinish = () => {
|
|
224
|
-
firstErrParams.cell = this.
|
|
224
|
+
firstErrParams.cell = this.getCellElement(firstErrParams.row, firstErrParams.column)
|
|
225
225
|
DomTools.scrollToView(firstErrParams.cell)
|
|
226
226
|
this.handleValidError(firstErrParams).then(finish)
|
|
227
227
|
}
|
package/types/table.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|