vxe-table 3.4.8 → 3.4.10

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.
@@ -462,7 +462,7 @@ export default {
462
462
  * @param {String/Object} code 字符串或对象
463
463
  */
464
464
  commitProxy (proxyTarget, ...args) {
465
- const { $refs, toolbar, toolbarConfig, toolbarOpts, proxyOpts, tablePage, pagerConfig, formData, isMsg } = this
465
+ const { $refs, toolbar, toolbarConfig, toolbarOpts, proxyOpts, tablePage, pagerConfig, editRules, formData, isMsg } = this
466
466
  const { beforeQuery, afterQuery, beforeDelete, afterDelete, beforeSave, afterSave, ajax = {}, props: proxyProps = {} } = proxyOpts
467
467
  const $xetable = $refs.xTable
468
468
  let button
@@ -669,8 +669,12 @@ export default {
669
669
  if (pendingRecords.length) {
670
670
  body.insertRecords = insertRecords.filter(row => pendingRecords.indexOf(row) === -1)
671
671
  }
672
- // 只校验新增和修改的数据
673
- return this.validate(body.insertRecords.concat(updateRecords)).then((errMap) => {
672
+ let restPromise = Promise.resolve()
673
+ if (editRules) {
674
+ // 只校验新增和修改的数据
675
+ restPromise = this.validate(body.insertRecords.concat(updateRecords))
676
+ }
677
+ return restPromise.then((errMap) => {
674
678
  if (errMap) {
675
679
  // 如果校验不通过
676
680
  return
@@ -1031,6 +1031,19 @@ export default {
1031
1031
  this.inputValue = val
1032
1032
  this.changeValue()
1033
1033
  },
1034
+ type () {
1035
+ // 切换类型是重置内置变量
1036
+ Object.assign(this, {
1037
+ inputValue: this.value,
1038
+ datetimePanelValue: null,
1039
+ datePanelValue: null,
1040
+ datePanelLabel: '',
1041
+ datePanelType: 'day',
1042
+ selectMonth: null,
1043
+ currentDate: null
1044
+ })
1045
+ this.initValue()
1046
+ },
1034
1047
  dateLabelFormat () {
1035
1048
  this.dateParseValue(this.datePanelValue)
1036
1049
  this.inputValue = this.datePanelLabel
@@ -12,10 +12,20 @@ function isOperateMouse ($xetable) {
12
12
  return $xetable._isResize || ($xetable.lastScrollTime && Date.now() < $xetable.lastScrollTime + $xetable.delayHover)
13
13
  }
14
14
 
15
- function renderLine (h, _vm, $xetable, rowLevel, items, params) {
16
- const column = params.column
17
- const { treeOpts, treeConfig } = $xetable
15
+ function renderLine (h, _vm, $xetable, params) {
16
+ const { row, column } = params
17
+ const { treeOpts, treeConfig, fullAllDataRowIdData } = $xetable
18
18
  const { slots, treeNode } = column
19
+ const rowid = UtilTools.getRowid($xetable, row)
20
+ const rest = fullAllDataRowIdData[rowid]
21
+ let rLevel = 0
22
+ let rIndex = 0
23
+ let items = []
24
+ if (rest) {
25
+ rLevel = rest.level
26
+ rIndex = rest._index
27
+ items = rest.items
28
+ }
19
29
  if (slots && slots.line) {
20
30
  return $xetable.callSlot(slots.line, params, h)
21
31
  }
@@ -27,8 +37,8 @@ function renderLine (h, _vm, $xetable, rowLevel, items, params) {
27
37
  h('div', {
28
38
  class: 'vxe-tree--line',
29
39
  style: {
30
- height: `${calcTreeLine(params, items)}px`,
31
- left: `${(rowLevel * treeOpts.indent) + (rowLevel ? 2 - getOffsetSize($xetable) : 0) + 16}px`
40
+ height: `${calcTreeLine(params, items, rIndex)}px`,
41
+ left: `${(rLevel * treeOpts.indent) + (rLevel ? 2 - getOffsetSize($xetable) : 0) + 16}px`
32
42
  }
33
43
  })
34
44
  ])
@@ -213,7 +223,7 @@ function renderColumn (h, _vm, $xetable, seq, rowid, fixedType, rowLevel, row, r
213
223
  } else {
214
224
  // 渲染单元格
215
225
  tdVNs.push(
216
- ...renderLine(h, _vm, $xetable, rowLevel, items, params),
226
+ ...renderLine(h, _vm, $xetable, params),
217
227
  h('div', {
218
228
  class: ['vxe-cell', {
219
229
  'c--title': showTitle,
@@ -286,7 +296,7 @@ function renderRows (h, _vm, $xetable, fixedType, tableData, tableColumn) {
286
296
  checkboxOpts,
287
297
  expandColumn,
288
298
  hasFixedColumn,
289
- fullDataRowIdData,
299
+ fullAllDataRowIdData,
290
300
  rowOpts
291
301
  } = $xetable
292
302
  const rows = []
@@ -312,7 +322,7 @@ function renderRows (h, _vm, $xetable, fixedType, tableData, tableColumn) {
312
322
  }
313
323
  }
314
324
  const rowid = UtilTools.getRowid($xetable, row)
315
- const rest = fullDataRowIdData[rowid]
325
+ const rest = fullAllDataRowIdData[rowid]
316
326
  const rowLevel = rest ? rest.level : 0
317
327
  const seq = rest ? rest.seq : -1
318
328
  const params = { $table: $xetable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
@@ -1241,36 +1241,28 @@ const Methods = {
1241
1241
  XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
1242
1242
  const rowid = getRowid(this, row)
1243
1243
  const allrest = fullAllDataRowIdData[rowid]
1244
- const fullrest = fullDataRowIdData[rowid]
1245
1244
  const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
1246
1245
  if (allrest) {
1247
1246
  allrest.seq = seq
1248
1247
  allrest._index = index
1249
- }
1250
- if (fullrest) {
1251
- fullrest.seq = seq
1252
- fullrest._index = index
1253
1248
  } else {
1254
- fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1255
- fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1249
+ const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1250
+ fullAllDataRowIdData[rowid] = rest
1251
+ fullDataRowIdData[rowid] = rest
1256
1252
  }
1257
1253
  }, { children: treeOpts.mapChildren })
1258
1254
  } else {
1259
1255
  afterFullData.forEach((row, index) => {
1260
1256
  const rowid = getRowid(this, row)
1261
1257
  const allrest = fullAllDataRowIdData[rowid]
1262
- const fullrest = fullDataRowIdData[rowid]
1263
1258
  const seq = index + 1
1264
1259
  if (allrest) {
1265
1260
  allrest.seq = seq
1266
1261
  allrest._index = index
1267
- }
1268
- if (fullrest) {
1269
- fullrest.seq = seq
1270
- fullrest._index = index
1271
1262
  } else {
1272
- fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1273
- fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1263
+ const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1264
+ fullAllDataRowIdData[rowid] = rest
1265
+ fullDataRowIdData[rowid] = rest
1274
1266
  }
1275
1267
  })
1276
1268
  }
@@ -3843,6 +3835,7 @@ const Methods = {
3843
3835
  return this.handleAsyncTreeExpandChilds(row)
3844
3836
  }).then(() => {
3845
3837
  if (transform) {
3838
+ this.handleVirtualTreeToList()
3846
3839
  return this.handleTableData()
3847
3840
  }
3848
3841
  }).then(() => {
@@ -4057,7 +4050,9 @@ const Methods = {
4057
4050
  return this.handleTableData().then(() => {
4058
4051
  if (transform) {
4059
4052
  this.handleVirtualTreeToList()
4053
+ return this.handleTableData()
4060
4054
  }
4055
+ }).then(() => {
4061
4056
  if (isExists) {
4062
4057
  this.recalculate()
4063
4058
  }
@@ -4559,10 +4554,14 @@ const Methods = {
4559
4554
  }
4560
4555
  }
4561
4556
  return cellLabel
4562
- }
4557
+ },
4563
4558
  /*************************
4564
4559
  * Publish methods
4565
4560
  *************************/
4561
+
4562
+ getSetupOptions () {
4563
+ return GlobalConfig
4564
+ }
4566
4565
  }
4567
4566
 
4568
4567
  // Module methods
@@ -115,9 +115,12 @@ export function getColMinWidth (params) {
115
115
  }
116
116
 
117
117
  function countTreeExpand (prevRow, params) {
118
+ let count = 1
119
+ if (!prevRow) {
120
+ return count
121
+ }
118
122
  const { $table } = params
119
123
  const rowChildren = prevRow[$table.treeOpts.children]
120
- let count = 1
121
124
  if ($table.isTreeExpandByRow(prevRow)) {
122
125
  for (let index = 0; index < rowChildren.length; index++) {
123
126
  count += countTreeExpand(rowChildren[index], params)
@@ -130,13 +133,13 @@ export function getOffsetSize ($xetable) {
130
133
  return lineOffsetSizes[$xetable.vSize] || 0
131
134
  }
132
135
 
133
- export function calcTreeLine (params, items) {
134
- const { $table, $rowIndex } = params
136
+ export function calcTreeLine (params, items, rIndex) {
137
+ const { $table } = params
135
138
  let expandSize = 1
136
- if ($rowIndex) {
137
- expandSize = countTreeExpand(items[$rowIndex - 1], params)
139
+ if (rIndex) {
140
+ expandSize = countTreeExpand(items[rIndex - 1], params)
138
141
  }
139
- return $table.rowHeight * expandSize - ($rowIndex ? 1 : (12 - getOffsetSize($table)))
142
+ return $table.rowHeight * expandSize - (rIndex ? 1 : (12 - getOffsetSize($table)))
140
143
  }
141
144
 
142
145
  export function mergeBodyMethod (mergeList, _rowIndex, _columnIndex) {
@@ -1,4 +1,5 @@
1
1
  import XEUtils from 'xe-utils'
2
+ import GlobalConfig from '../../v-x-e-table/src/conf'
2
3
  import { UtilTools, DomTools } from '../../tools'
3
4
  import { eqEmptyValue } from '../../tools/src/utils'
4
5
 
@@ -158,14 +159,19 @@ export default {
158
159
  }
159
160
  })
160
161
  }).catch(firstErrParams => {
161
- return new Promise((resolve) => {
162
+ return new Promise((resolve, reject) => {
162
163
  const finish = () => {
163
164
  this.$nextTick(() => {
164
165
  if (cb) {
165
166
  cb(validRest)
166
167
  resolve()
167
168
  } else {
168
- resolve(validRest)
169
+ if (GlobalConfig.validToReject === 'obsolete') {
170
+ // 已废弃,校验失败将不会执行catch
171
+ reject(validRest)
172
+ } else {
173
+ resolve(validRest)
174
+ }
169
175
  }
170
176
  })
171
177
  }