vxe-table 3.10.15 → 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.
@@ -5,6 +5,8 @@ import { scrollToView } from '../../../ui/src/dom'
5
5
  import { handleFieldOrColumn, getRowid } from '../../src/util'
6
6
  import { warnLog, errLog } from '../../../ui/src/log'
7
7
 
8
+ import type { VxeTableDefines } from '../../../../types'
9
+
8
10
  const { getConfig, validators } = VxeUI
9
11
 
10
12
  /**
@@ -73,7 +75,7 @@ export default {
73
75
  warnLog('vxe.error.notValidators', ['fullValidate(rows, callback)', 'fullValidate(rows)'])
74
76
  }
75
77
  }
76
- return this.beginValidate(rows, cb, true)
78
+ return this.beginValidate(rows, null, cb, true)
77
79
  },
78
80
  /**
79
81
  * 快速校验,如果存在记录不通过的记录,则返回不再继续校验(异步校验除外)
@@ -84,7 +86,27 @@ export default {
84
86
  warnLog('vxe.error.notValidators', ['validate(rows, callback)', 'validate(rows)'])
85
87
  }
86
88
  }
87
- return this.beginValidate(rows, cb)
89
+ return this.beginValidate(rows, null, cb)
90
+ },
91
+ /**
92
+ * 完整校验单元格,和 validateField 的区别就是会给有效数据中的每一行进行校验
93
+ */
94
+ _fullValidateField (rows: any, fieldOrColumn: any) {
95
+ const colList = (XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : (fieldOrColumn ? [fieldOrColumn] : [])).map(column => handleFieldOrColumn(this, column))
96
+ if (colList.length) {
97
+ return this.beginValidate(rows, colList, null, true)
98
+ }
99
+ return this.$nextTick()
100
+ },
101
+ /**
102
+ * 快速校验单元格,如果存在记录不通过的记录,则返回不再继续校验(异步校验除外)
103
+ */
104
+ _validateField (rows: any, fieldOrColumn: any) {
105
+ const colList = (XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : (fieldOrColumn ? [fieldOrColumn] : [])).map(column => handleFieldOrColumn(this, column))
106
+ if (colList.length) {
107
+ return this.beginValidate(rows, colList, null)
108
+ }
109
+ return this.$nextTick()
88
110
  },
89
111
  /**
90
112
  * 聚焦到校验通过的单元格并弹出校验错误提示
@@ -131,7 +153,7 @@ export default {
131
153
  * 如果只传 callback 否则默认验证整个表格数据
132
154
  * 返回 Promise 对象,或者使用回调方式
133
155
  */
134
- beginValidate (rows: any, cb: any, isFull: any) {
156
+ beginValidate (rows: any, cols: VxeTableDefines.ColumnInfo[] | null, cb: any, isFull: any) {
135
157
  const validRest: any = {}
136
158
  const { editRules, afterFullData, visibleColumn, treeConfig, treeOpts } = this
137
159
  const childrenField = treeOpts.children || treeOpts.childrenField
@@ -154,12 +176,13 @@ export default {
154
176
  this.clearValidate()
155
177
  const validErrMaps: any = {}
156
178
  if (editRules) {
157
- const columns = this.getColumns()
179
+ const columns = cols && cols.length ? cols : this.getColumns()
158
180
  const handleVaild = (row: any) => {
159
181
  if (isFull || !this.validRuleErr) {
160
182
  const colVailds: any[] = []
161
183
  columns.forEach((column: any) => {
162
- if ((isFull || !this.validRuleErr) && XEUtils.has(editRules, column.property)) {
184
+ const field = XEUtils.isString(column) ? column : column.field
185
+ if ((isFull || !this.validRuleErr) && XEUtils.has(editRules, field)) {
163
186
  colVailds.push(
164
187
  this.validCellRules('all', row, column)
165
188
  .catch(({ rule, rules }: any) => {
@@ -170,11 +193,11 @@ export default {
170
193
  row,
171
194
  columnIndex: this.getColumnIndex(column),
172
195
  column,
173
- field: column.property,
196
+ field,
174
197
  $table: this
175
198
  }
176
- if (!validRest[column.property]) {
177
- validRest[column.property] = []
199
+ if (!validRest[field]) {
200
+ validRest[field] = []
178
201
  }
179
202
  validErrMaps[`${getRowid(this, row)}:${column.id}`] = {
180
203
  column,
@@ -182,7 +205,7 @@ export default {
182
205
  rule,
183
206
  content: rule.content
184
207
  }
185
- validRest[column.property].push(rest)
208
+ validRest[field].push(rest)
186
209
  if (!isFull) {
187
210
  this.validRuleErr = true
188
211
  return Promise.reject(rest)
@@ -371,7 +394,7 @@ export default {
371
394
  const { validOpts, validErrorMaps } = this
372
395
  const validTip = this.$refs.validTip
373
396
  const rowList = XEUtils.isArray(rows) ? rows : (rows ? [rows] : [])
374
- const colList = (XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : (fieldOrColumn ? [fieldOrColumn] : []).map(column => handleFieldOrColumn(this, column)))
397
+ const colList = (XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : (fieldOrColumn ? [fieldOrColumn] : [])).map(column => handleFieldOrColumn(this, column))
375
398
  let validErrMaps: any = {}
376
399
  if (validTip && validTip.visible) {
377
400
  validTip.close()
@@ -3041,7 +3041,14 @@ const Methods = {
3041
3041
  // 如果点击了当前表格之外
3042
3042
  !getEventTargetNode(evnt, $el).flag
3043
3043
  ) {
3044
- setTimeout(() => this.clearEdit(evnt))
3044
+ setTimeout(() => {
3045
+ this.clearEdit(evnt).then(() => {
3046
+ // 如果存在校验,点击了表格之外则清除
3047
+ if (!this.isActivated && editRules && validOpts.autoClear) {
3048
+ this.validErrorMaps = {}
3049
+ }
3050
+ })
3051
+ })
3045
3052
  }
3046
3053
  })
3047
3054
  }
@@ -6370,7 +6377,7 @@ const Methods = {
6370
6377
  } as any
6371
6378
 
6372
6379
  // Module methods
6373
- 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(',')
6380
+ 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(',')
6374
6381
 
6375
6382
  funcs.forEach(name => {
6376
6383
  Methods[name] = function (...args: any[]) {