vxe-table 3.10.14 → 3.10.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/style.css +1 -1
- package/es/table/module/keyboard/mixin.js +29 -9
- package/es/table/module/validator/mixin.js +31 -10
- package/es/table/src/methods.js +9 -2
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +72 -25
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/keyboard/mixin.js +30 -11
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +31 -10
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/methods.js +9 -2
- package/lib/table/src/methods.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/table/module/keyboard/mixin.ts +29 -10
- package/packages/table/module/validator/mixin.ts +33 -10
- package/packages/table/src/methods.ts +9 -2
- /package/es/{iconfont.1731469272922.ttf → iconfont.1731633464058.ttf} +0 -0
- /package/es/{iconfont.1731469272922.woff → iconfont.1731633464058.woff} +0 -0
- /package/es/{iconfont.1731469272922.woff2 → iconfont.1731633464058.woff2} +0 -0
- /package/lib/{iconfont.1731469272922.ttf → iconfont.1731633464058.ttf} +0 -0
- /package/lib/{iconfont.1731469272922.woff → iconfont.1731633464058.woff} +0 -0
- /package/lib/{iconfont.1731469272922.woff2 → iconfont.1731633464058.woff2} +0 -0
|
@@ -87,7 +87,7 @@ var _default = exports.default = {
|
|
|
87
87
|
(0, _log.warnLog)('vxe.error.notValidators', ['fullValidate(rows, callback)', 'fullValidate(rows)']);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
return this.beginValidate(rows, cb, true);
|
|
90
|
+
return this.beginValidate(rows, null, cb, true);
|
|
91
91
|
},
|
|
92
92
|
/**
|
|
93
93
|
* 快速校验,如果存在记录不通过的记录,则返回不再继续校验(异步校验除外)
|
|
@@ -98,7 +98,27 @@ var _default = exports.default = {
|
|
|
98
98
|
(0, _log.warnLog)('vxe.error.notValidators', ['validate(rows, callback)', 'validate(rows)']);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
return this.beginValidate(rows, cb);
|
|
101
|
+
return this.beginValidate(rows, null, cb);
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* 完整校验单元格,和 validateField 的区别就是会给有效数据中的每一行进行校验
|
|
105
|
+
*/
|
|
106
|
+
_fullValidateField(rows, fieldOrColumn) {
|
|
107
|
+
const colList = (_xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn : fieldOrColumn ? [fieldOrColumn] : []).map(column => (0, _util.handleFieldOrColumn)(this, column));
|
|
108
|
+
if (colList.length) {
|
|
109
|
+
return this.beginValidate(rows, colList, null, true);
|
|
110
|
+
}
|
|
111
|
+
return this.$nextTick();
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* 快速校验单元格,如果存在记录不通过的记录,则返回不再继续校验(异步校验除外)
|
|
115
|
+
*/
|
|
116
|
+
_validateField(rows, fieldOrColumn) {
|
|
117
|
+
const colList = (_xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn : fieldOrColumn ? [fieldOrColumn] : []).map(column => (0, _util.handleFieldOrColumn)(this, column));
|
|
118
|
+
if (colList.length) {
|
|
119
|
+
return this.beginValidate(rows, colList, null);
|
|
120
|
+
}
|
|
121
|
+
return this.$nextTick();
|
|
102
122
|
},
|
|
103
123
|
/**
|
|
104
124
|
* 聚焦到校验通过的单元格并弹出校验错误提示
|
|
@@ -147,7 +167,7 @@ var _default = exports.default = {
|
|
|
147
167
|
* 如果只传 callback 否则默认验证整个表格数据
|
|
148
168
|
* 返回 Promise 对象,或者使用回调方式
|
|
149
169
|
*/
|
|
150
|
-
beginValidate(rows, cb, isFull) {
|
|
170
|
+
beginValidate(rows, cols, cb, isFull) {
|
|
151
171
|
const validRest = {};
|
|
152
172
|
const {
|
|
153
173
|
editRules,
|
|
@@ -176,12 +196,13 @@ var _default = exports.default = {
|
|
|
176
196
|
this.clearValidate();
|
|
177
197
|
const validErrMaps = {};
|
|
178
198
|
if (editRules) {
|
|
179
|
-
const columns = this.getColumns();
|
|
199
|
+
const columns = cols && cols.length ? cols : this.getColumns();
|
|
180
200
|
const handleVaild = row => {
|
|
181
201
|
if (isFull || !this.validRuleErr) {
|
|
182
202
|
const colVailds = [];
|
|
183
203
|
columns.forEach(column => {
|
|
184
|
-
|
|
204
|
+
const field = _xeUtils.default.isString(column) ? column : column.field;
|
|
205
|
+
if ((isFull || !this.validRuleErr) && _xeUtils.default.has(editRules, field)) {
|
|
185
206
|
colVailds.push(this.validCellRules('all', row, column).catch(({
|
|
186
207
|
rule,
|
|
187
208
|
rules
|
|
@@ -193,11 +214,11 @@ var _default = exports.default = {
|
|
|
193
214
|
row,
|
|
194
215
|
columnIndex: this.getColumnIndex(column),
|
|
195
216
|
column,
|
|
196
|
-
field
|
|
217
|
+
field,
|
|
197
218
|
$table: this
|
|
198
219
|
};
|
|
199
|
-
if (!validRest[
|
|
200
|
-
validRest[
|
|
220
|
+
if (!validRest[field]) {
|
|
221
|
+
validRest[field] = [];
|
|
201
222
|
}
|
|
202
223
|
validErrMaps[`${(0, _util.getRowid)(this, row)}:${column.id}`] = {
|
|
203
224
|
column,
|
|
@@ -205,7 +226,7 @@ var _default = exports.default = {
|
|
|
205
226
|
rule,
|
|
206
227
|
content: rule.content
|
|
207
228
|
};
|
|
208
|
-
validRest[
|
|
229
|
+
validRest[field].push(rest);
|
|
209
230
|
if (!isFull) {
|
|
210
231
|
this.validRuleErr = true;
|
|
211
232
|
return Promise.reject(rest);
|
|
@@ -422,7 +443,7 @@ var _default = exports.default = {
|
|
|
422
443
|
} = this;
|
|
423
444
|
const validTip = this.$refs.validTip;
|
|
424
445
|
const rowList = _xeUtils.default.isArray(rows) ? rows : rows ? [rows] : [];
|
|
425
|
-
const colList = _xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn :
|
|
446
|
+
const colList = (_xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn : fieldOrColumn ? [fieldOrColumn] : []).map(column => (0, _util.handleFieldOrColumn)(this, column));
|
|
426
447
|
let validErrMaps = {};
|
|
427
448
|
if (validTip && validTip.visible) {
|
|
428
449
|
validTip.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../../ui"),_utils=require("../../../ui/src/utils"),_dom=require("../../../ui/src/dom"),_util=require("../../src/util"),_log=require("../../../ui/src/log");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let{getConfig,validators}=_ui.VxeUI;class Rule{constructor(e){Object.defineProperty(this,"$options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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})}get content(){return(0,_utils.getFuncText)(this.$options.content||this.$options.message)}get message(){return this.content}}function validErrorRuleValue(e,t){var{type:e,min:l,max:i,pattern:r}=e,e="number"===e,s=e?_xeUtils.default.toNumber(t):_xeUtils.default.getSize(t);return!(!e||!isNaN(t))||!_xeUtils.default.eqNull(l)&&s<_xeUtils.default.toNumber(l)||!_xeUtils.default.eqNull(i)&&s>_xeUtils.default.toNumber(i)||!(!r||(_xeUtils.default.isRegExp(r)?r:new RegExp(r)).test(t))}var _default=exports.default={methods:{_fullValidate(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(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(t){let l=this.validOpts;return new Promise(e=>{!1===l.autoPos?(this.emitEvent("valid-error",t),e()):this.handleEdit(t,{type:"valid-error",trigger:"call"}).then(()=>{setTimeout(()=>{e(this.showValidTooltip(t))},10)})})},handleErrMsgMode(e){var t,l=this.validOpts;return"single"===l.msgMode?(l={},(t=Object.keys(e)).length&&(l[t=t[0]]=e[t]),l):e},beginValidate(e,
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../../ui"),_utils=require("../../../ui/src/utils"),_dom=require("../../../ui/src/dom"),_util=require("../../src/util"),_log=require("../../../ui/src/log");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let{getConfig,validators}=_ui.VxeUI;class Rule{constructor(e){Object.defineProperty(this,"$options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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})}get content(){return(0,_utils.getFuncText)(this.$options.content||this.$options.message)}get message(){return this.content}}function validErrorRuleValue(e,t){var{type:e,min:l,max:i,pattern:r}=e,e="number"===e,s=e?_xeUtils.default.toNumber(t):_xeUtils.default.getSize(t);return!(!e||!isNaN(t))||!_xeUtils.default.eqNull(l)&&s<_xeUtils.default.toNumber(l)||!_xeUtils.default.eqNull(i)&&s>_xeUtils.default.toNumber(i)||!(!r||(_xeUtils.default.isRegExp(r)?r:new RegExp(r)).test(t))}var _default=exports.default={methods:{_fullValidate(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,null,t,!0)},_validate(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,null,t)},_fullValidateField(e,t){t=(_xeUtils.default.isArray(t)?t:t?[t]:[]).map(e=>(0,_util.handleFieldOrColumn)(this,e));return t.length?this.beginValidate(e,t,null,!0):this.$nextTick()},_validateField(e,t){t=(_xeUtils.default.isArray(t)?t:t?[t]:[]).map(e=>(0,_util.handleFieldOrColumn)(this,e));return t.length?this.beginValidate(e,t,null):this.$nextTick()},handleValidError(t){let l=this.validOpts;return new Promise(e=>{!1===l.autoPos?(this.emitEvent("valid-error",t),e()):this.handleEdit(t,{type:"valid-error",trigger:"call"}).then(()=>{setTimeout(()=>{e(this.showValidTooltip(t))},10)})})},handleErrMsgMode(e){var t,l=this.validOpts;return"single"===l.msgMode?(l={},(t=Object.keys(e)).length&&(l[t=t[0]]=e[t]),l):e},beginValidate(e,l,u,s){let d={},{editRules:a,afterFullData:h,visibleColumn:c,treeConfig:i,treeOpts:t}=this;var r=t.children||t.childrenField;let o,n=(!0===e?o=h:e&&(_xeUtils.default.isFunction(e)?u=e:o=_xeUtils.default.isArray(e)?e:[e]),o=o||this.getInsertRecords().concat(this.getUpdateRecords()),[]),g=(this.lastCallTime=Date.now(),this.validRuleErr=!1,this.clearValidate(),{});if(a){let t=l&&l.length?l:this.getColumns();e=r=>{if(s||!this.validRuleErr){let e=[];t.forEach(l=>{let i=_xeUtils.default.isString(l)?l:l.field;!s&&this.validRuleErr||!_xeUtils.default.has(a,i)||e.push(this.validCellRules("all",r,l).catch(({rule:e,rules:t})=>{t={rule:e,rules:t,rowIndex:this.getRowIndex(r),row:r,columnIndex:this.getColumnIndex(l),column:l,field:i,$table:this};if(d[i]||(d[i]=[]),g[(0,_util.getRowid)(this,r)+":"+l.id]={column:l,row:r,rule:e,content:e.content},d[i].push(t),!s)return this.validRuleErr=!0,Promise.reject(t)}))}),n.push(Promise.all(e))}};return i?_xeUtils.default.eachTree(o,e,{children:r}):o.forEach(e),Promise.all(n).then(()=>{let e=Object.keys(d);return this.validErrorMaps=this.handleErrMsgMode(g),this.$nextTick().then(()=>{if(e.length)return Promise.reject(d[e[0]][0]);u&&u()})}).catch(n=>new Promise((e,t)=>{let l=()=>{this.$nextTick(()=>{u?(u(d),e()):("obsolete"===getConfig().validToReject?t:e)(d)})};var i,r,s,a,o=()=>{n.cell=this.getCellElement(n.row,n.column),(0,_dom.scrollToView)(n.cell),this.handleValidError(n).then(l)};!1===this.validOpts.autoPos?l():(a=n.row,i=n.column,s=h.indexOf(a),r=c.indexOf(i),s=0<s?h[s-1]:a,a=0<r?c[r-1]:i,this.scrollToRow(s,a).then(o))}))}return this.validErrorMaps={},this.$nextTick().then(()=>{u&&u()})},hasCellRules(t,e,l){var i=this.editRules,l=l.property;return!(!l||!i)&&(i=_xeUtils.default.get(i,l))&&_xeUtils.default.find(i,e=>"all"===t||!e.trigger||t===e.trigger)},validCellRules(e,d,h,t){var l=this.editRules,i=h.property;let c=[],g=[];if(i&&l){let u=_xeUtils.default.get(l,i);if(u){let n=_xeUtils.default.isUndefined(t)?_xeUtils.default.get(d,i):t;u.forEach(t=>{let{type:l,trigger:i,required:r,validator:s}=t;if("all"===e||!i||e===i)if(s){var a={cellValue:n,rule:t,rules:u,row:d,rowIndex:this.getRowIndex(d),column:h,columnIndex:this.getColumnIndex(h),field:h.property,$table:this};let e;_xeUtils.default.isString(s)?(o=validators.get(s))?(o=o.tableCellValidatorMethod||o.cellValidatorMethod)?e=o(a):"development"===process.env.NODE_ENV&&(0,_log.warnLog)("vxe.error.notValidators",[s]):"development"===process.env.NODE_ENV&&(0,_log.errLog)("vxe.error.notValidators",[s]):e=s(a),e&&(_xeUtils.default.isError(e)?(this.validRuleErr=!0,c.push(new Rule({type:"custom",trigger:i,content:e.message,rule:new Rule(t)}))):e.catch&&g.push(e.catch(e=>{this.validRuleErr=!0,c.push(new Rule({type:"custom",trigger:i,content:e&&e.message?e.message:t.content||t.message,rule:new Rule(t)}))})))}else{var o="array"===l,a=_xeUtils.default.isArray(n);let e=!0;e=o||a?!a||!n.length:_xeUtils.default.isString(n)?(0,_utils.eqEmptyValue)(n.trim()):(0,_utils.eqEmptyValue)(n),(r?e||validErrorRuleValue(t,n):!e&&validErrorRuleValue(t,n))&&(this.validRuleErr=!0,c.push(new Rule(t)))}})}}return Promise.all(g).then(()=>{var e;if(c.length)return e={rules:c,rule:c[0]},Promise.reject(e)})},_clearValidate(e,t){var{validOpts:l,validErrorMaps:i}=this,r=this.$refs.validTip,e=_xeUtils.default.isArray(e)?e:e?[e]:[];let s=(_xeUtils.default.isArray(t)?t:t?[t]:[]).map(e=>(0,_util.handleFieldOrColumn)(this,e)),a={};if(r&&r.visible&&r.close(),"single"===l.msgMode)this.validErrorMaps={};else{if(e.length&&s.length)a=Object.assign({},i),e.forEach(t=>{s.forEach(e=>{e=(0,_util.getRowid)(this,t)+":"+e.id;a[e]&&delete a[e]})});else if(e.length){let l=e.map(e=>""+(0,_util.getRowid)(this,e));_xeUtils.default.each(i,(e,t)=>{-1<l.indexOf(t.split(":")[0])&&(a[t]=e)})}else if(s.length){let l=s.map(e=>""+e.id);_xeUtils.default.each(i,(e,t)=>{-1<l.indexOf(t.split(":")[1])&&(a[t]=e)})}this.validErrorMaps=a}return this.$nextTick()},triggerValidate(r){let{editConfig:e,editStore:t,editRules:l,editOpts:s,validOpts:i}=this;var a=t.actived;if(l&&"single"===i.msgMode&&(this.validErrorMaps={}),e&&l&&a.row){let{row:t,column:l,cell:i}=a.args;if(this.hasCellRules(r,t,l))return this.validCellRules(r,t,l).then(()=>{"row"===s.mode&&this.clearValidate(t,l)}).catch(({rule:e})=>e.trigger&&r!==e.trigger?Promise.resolve():(e={rule:e,row:t,column:l,cell:i},this.showValidTooltip(e),Promise.reject(e)))}return Promise.resolve()},showValidTooltip(e){var{$refs:t,height:l,validStore:i,validErrorMaps:r,tableData:s,validOpts:a}=this,{rule:o,row:n,column:u,cell:d}=e,t=t.validTip,h=o.content;return i.visible=!0,"single"===a.msgMode?this.validErrorMaps={[(0,_util.getRowid)(this,n)+":"+u.id]:{column:u,row:n,rule:o,content:h}}:this.validErrorMaps=Object.assign({},r,{[(0,_util.getRowid)(this,n)+":"+u.id]:{column:u,row:n,rule:o,content:h}}),this.emitEvent("valid-error",e,null),t&&("tooltip"===a.message||"default"===a.message&&!l&&s.length<2)?t.open(d,h):this.$nextTick()}}};
|
package/lib/table/src/methods.js
CHANGED
|
@@ -3523,7 +3523,14 @@ const Methods = {
|
|
|
3523
3523
|
if (isClear ||
|
|
3524
3524
|
// 如果点击了当前表格之外
|
|
3525
3525
|
!(0, _dom.getEventTargetNode)(evnt, $el).flag) {
|
|
3526
|
-
setTimeout(() =>
|
|
3526
|
+
setTimeout(() => {
|
|
3527
|
+
this.clearEdit(evnt).then(() => {
|
|
3528
|
+
// 如果存在校验,点击了表格之外则清除
|
|
3529
|
+
if (!this.isActivated && editRules && validOpts.autoClear) {
|
|
3530
|
+
this.validErrorMaps = {};
|
|
3531
|
+
}
|
|
3532
|
+
});
|
|
3533
|
+
});
|
|
3527
3534
|
}
|
|
3528
3535
|
});
|
|
3529
3536
|
}
|
|
@@ -7617,7 +7624,7 @@ const Methods = {
|
|
|
7617
7624
|
}
|
|
7618
7625
|
};
|
|
7619
7626
|
// Module methods
|
|
7620
|
-
const funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,openCustom,closeCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',');
|
|
7627
|
+
const funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,fullValidateField,validateField,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,openCustom,closeCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',');
|
|
7621
7628
|
funcs.forEach(name => {
|
|
7622
7629
|
Methods[name] = function (...args) {
|
|
7623
7630
|
if (process.env.NODE_ENV === 'development') {
|