vxe-table 3.3.11 → 3.3.14-beta.0

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 (41) hide show
  1. package/helper/vetur/attributes.json +8 -0
  2. package/helper/vetur/tags.json +2 -0
  3. package/lib/form/src/form.js +22 -10
  4. package/lib/form/src/form.min.js +1 -1
  5. package/lib/form/style/style.css +41 -14
  6. package/lib/form/style/style.min.css +1 -1
  7. package/lib/grid/src/grid.js +20 -6
  8. package/lib/grid/src/grid.min.js +1 -1
  9. package/lib/index.css +1 -1
  10. package/lib/index.umd.js +903 -51
  11. package/lib/index.umd.min.js +1 -1
  12. package/lib/modal/src/modal.js +16 -4
  13. package/lib/modal/src/modal.min.js +1 -1
  14. package/lib/modal/style/style.css +2 -2
  15. package/lib/modal/style/style.min.css +1 -1
  16. package/lib/select/src/util.js +5 -1
  17. package/lib/select/src/util.min.js +1 -1
  18. package/lib/select/style/style.css +2 -1
  19. package/lib/select/style/style.min.css +1 -1
  20. package/lib/style.css +1 -1
  21. package/lib/style.min.css +1 -1
  22. package/lib/table/src/methods.js +45 -30
  23. package/lib/table/src/methods.min.js +1 -1
  24. package/lib/tooltip/style/style.css +1 -1
  25. package/lib/tooltip/style/style.min.css +1 -1
  26. package/lib/v-x-e-table/src/conf.js +1 -0
  27. package/lib/v-x-e-table/src/conf.min.js +1 -1
  28. package/package.json +5 -5
  29. package/packages/form/src/form.js +24 -10
  30. package/packages/grid/src/grid.js +12 -2
  31. package/packages/modal/src/modal.js +9 -4
  32. package/packages/select/src/util.js +3 -2
  33. package/packages/table/src/methods.js +19 -9
  34. package/packages/v-x-e-table/src/conf.js +1 -0
  35. package/styles/form.scss +38 -18
  36. package/styles/input.scss +4 -4
  37. package/styles/modal.scss +3 -3
  38. package/styles/select.scss +1 -0
  39. package/styles/tooltip.scss +1 -1
  40. package/styles/variable.scss +1 -0
  41. package/types/form.d.ts +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vxe-table",
3
- "version": "3.3.11",
3
+ "version": "3.3.14-beta.0",
4
4
  "description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟滚动、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、虚拟列表、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -35,12 +35,12 @@
35
35
  "@vue/cli-service": "~4.4.0",
36
36
  "@vue/eslint-config-standard": "^5.1.2",
37
37
  "@vue/eslint-config-typescript": "^5.0.2",
38
- "ant-design-vue": "^1.7.5",
38
+ "ant-design-vue": "^1.7.8",
39
39
  "codemirror": "^5.53.2",
40
40
  "core-js": "^3.6.5",
41
41
  "dayjs": "^1.10.4",
42
42
  "del": "^5.1.0",
43
- "element-ui": "^2.15.2",
43
+ "element-ui": "^2.15.6",
44
44
  "eslint": "^6.7.2",
45
45
  "eslint-plugin-import": "^2.20.2",
46
46
  "eslint-plugin-node": "^11.1.0",
@@ -68,7 +68,7 @@
68
68
  "sass-loader": "^8.0.2",
69
69
  "sortablejs": "^1.10.2",
70
70
  "typescript": "~3.9.3",
71
- "view-design": "^4.4.0",
71
+ "view-design": "^4.6.1",
72
72
  "vue": "^2.6.14",
73
73
  "vue-class-component": "^7.2.3",
74
74
  "vue-i18n": "^8.18.1",
@@ -88,7 +88,7 @@
88
88
  "vxe-table-plugin-virtual-tree": "0.6.10",
89
89
  "xe-ajax": "^4.0.5",
90
90
  "xe-clipboard": "^1.10.1",
91
- "xe-utils": "^3.3.1",
91
+ "xe-utils": "^3.3.4",
92
92
  "xlsx": "^0.17.0"
93
93
  },
94
94
  "peerDependencies": {
@@ -95,9 +95,10 @@ function renderTitle (h, _vm, item) {
95
95
  const { slots, field, itemRender, titlePrefix, titleSuffix } = item
96
96
  const compConf = isEnableConf(itemRender) ? VXETable.renderer.get(itemRender.name) : null
97
97
  const params = { data, property: field, item, $form: _vm }
98
- const tss = []
98
+ const contVNs = []
99
+ const titVNs = []
99
100
  if (titlePrefix) {
100
- tss.push(
101
+ titVNs.push(
101
102
  titlePrefix.message
102
103
  ? h('vxe-tooltip', {
103
104
  props: {
@@ -111,13 +112,19 @@ function renderTitle (h, _vm, item) {
111
112
  : renderPrefixIcon(h, titlePrefix)
112
113
  )
113
114
  }
114
- tss.push(
115
+ titVNs.push(
115
116
  h('span', {
116
117
  class: 'vxe-form--item-title-label'
117
118
  }, compConf && compConf.renderItemTitle ? compConf.renderItemTitle(itemRender, params) : (slots && slots.title ? callSlot(_vm, slots.title, params, h) : UtilTools.getFuncText(item.title)))
118
119
  )
120
+ contVNs.push(
121
+ h('div', {
122
+ class: 'vxe-form--item-title-content'
123
+ }, titVNs)
124
+ )
125
+ const fixVNs = []
119
126
  if (titleSuffix) {
120
- tss.push(
127
+ fixVNs.push(
121
128
  titleSuffix.message
122
129
  ? h('vxe-tooltip', {
123
130
  props: {
@@ -131,7 +138,12 @@ function renderTitle (h, _vm, item) {
131
138
  : renderSuffixIcon(h, titleSuffix)
132
139
  )
133
140
  }
134
- return tss
141
+ contVNs.push(
142
+ h('div', {
143
+ class: 'vxe-form--item-title-postfix'
144
+ }, fixVNs)
145
+ )
146
+ return contVNs
135
147
  }
136
148
 
137
149
  function renderItems (h, _vm, itemList) {
@@ -386,7 +398,7 @@ export default {
386
398
  submitEvent (evnt) {
387
399
  evnt.preventDefault()
388
400
  if (!this.preventSubmit) {
389
- this.beginValidate().then(() => {
401
+ this.beginValidate(this.getItems()).then(() => {
390
402
  this.$emit('submit', { data: this.data, $form: this, $event: evnt })
391
403
  }).catch(errMap => {
392
404
  this.$emit('submit-invalid', { data: this.data, errMap, $form: this, $event: evnt })
@@ -443,7 +455,7 @@ export default {
443
455
  const { item } = params
444
456
  const { tooltipStore } = this
445
457
  const $tooltip = this.$refs.tooltip
446
- const overflowElem = evnt.currentTarget
458
+ const overflowElem = evnt.currentTarget.children[0]
447
459
  const content = (overflowElem.textContent || '').trim()
448
460
  const isCellOverflow = overflowElem.scrollWidth > overflowElem.clientWidth
449
461
  clearTimeout(this.tooltipTimeout)
@@ -488,14 +500,16 @@ export default {
488
500
  return this.$nextTick()
489
501
  },
490
502
  validate (callback) {
491
- return this.beginValidate('', callback)
503
+ return this.beginValidate(this.getItems(), '', callback)
492
504
  },
493
- beginValidate (type, callback) {
505
+ validateField (field, callback) {
506
+ return this.beginValidate(this.getItems().filter(item => item.field === field), '', callback)
507
+ },
508
+ beginValidate (itemList, type, callback) {
494
509
  const { data, rules: formRules, validOpts } = this
495
510
  const validRest = {}
496
511
  const validFields = []
497
512
  const itemValids = []
498
- const itemList = this.getItems()
499
513
  this.clearValidate()
500
514
  clearTimeout(this.showErrTime)
501
515
  if (data && formRules) {
@@ -428,9 +428,19 @@ export default {
428
428
  if (proxyConfig) {
429
429
  if (isEnableConf(formConfig) && proxyOpts.form && formOpts.items) {
430
430
  const formData = {}
431
- formOpts.items.forEach(({ field, itemRender }) => {
431
+ formOpts.items.forEach(item => {
432
+ const { field, itemRender } = item
432
433
  if (field) {
433
- formData[field] = itemRender && !XEUtils.isUndefined(itemRender.defaultValue) ? itemRender.defaultValue : undefined
434
+ let itemValue = null
435
+ if (itemRender) {
436
+ const { defaultValue } = itemRender
437
+ if (XEUtils.isFunction(defaultValue)) {
438
+ itemValue = defaultValue({ item })
439
+ } else if (!XEUtils.isUndefined(defaultValue)) {
440
+ itemValue = defaultValue
441
+ }
442
+ }
443
+ formData[field] = itemValue
434
444
  }
435
445
  })
436
446
  this.formData = formData
@@ -44,6 +44,7 @@ export default {
44
44
  zIndex: Number,
45
45
  marginSize: { type: [Number, String], default: () => GlobalConfig.modal.marginSize },
46
46
  fullscreen: Boolean,
47
+ draggable: { type: Boolean, default: () => GlobalConfig.modal.draggable },
47
48
  remember: { type: Boolean, default: () => GlobalConfig.modal.remember },
48
49
  destroyOnClose: { type: Boolean, default: () => GlobalConfig.modal.destroyOnClose },
49
50
  showTitleOverflow: { type: Boolean, default: () => GlobalConfig.modal.showTitleOverflow },
@@ -115,14 +116,15 @@ export default {
115
116
  }
116
117
  },
117
118
  render (h) {
118
- const { _e, $scopedSlots, slots = {}, inited, vSize, className, type, resize, showClose, showZoom, animat, loading, status, iconStatus, showFooter, zoomLocat, modalTop, dblclickZoom, contentVisible, visible, title, lockScroll, lockView, mask, isMsg, showTitleOverflow, destroyOnClose } = this
119
+ const { _e, $scopedSlots, slots = {}, inited, vSize, className, type, resize, showClose, showZoom, animat, draggable, loading, status, iconStatus, showFooter, zoomLocat, modalTop, dblclickZoom, contentVisible, visible, title, lockScroll, lockView, mask, isMsg, showTitleOverflow, destroyOnClose } = this
119
120
  const content = this.content || this.message
120
121
  const defaultSlot = $scopedSlots.default || slots.default
121
122
  const footerSlot = $scopedSlots.footer || slots.footer
122
123
  const headerSlot = $scopedSlots.header || slots.header
123
124
  const titleSlot = $scopedSlots.title || slots.title
124
- const headerOns = {
125
- mousedown: this.mousedownEvent
125
+ const headerOns = {}
126
+ if (draggable) {
127
+ headerOns.mousedown = this.mousedownEvent
126
128
  }
127
129
  if (showZoom && dblclickZoom && type === 'modal') {
128
130
  headerOns.dblclick = this.toggleZoomEvent
@@ -157,7 +159,10 @@ export default {
157
159
  ref: 'modalBox'
158
160
  }, [
159
161
  this.showHeader ? h('div', {
160
- class: ['vxe-modal--header', !isMsg && showTitleOverflow ? 'is--ellipsis' : ''],
162
+ class: ['vxe-modal--header', {
163
+ 'is--drag': draggable,
164
+ 'is--ellipsis': !isMsg && showTitleOverflow
165
+ }],
161
166
  on: headerOns
162
167
  }, headerSlot ? (!inited || (destroyOnClose && !visible) ? [] : headerSlot.call(this, { $modal: this }, h)) : [
163
168
  titleSlot ? titleSlot.call(this, { $modal: this }, h) : h('span', {
@@ -30,7 +30,7 @@ export function createOption ($xeselect, _vm) {
30
30
 
31
31
  export function destroyOption (_vm) {
32
32
  const { $xeselect, optionConfig } = _vm
33
- const matchObj = XEUtils.findTree($xeselect.collectOption, option => option === optionConfig)
33
+ const matchObj = XEUtils.findTree($xeselect.collectOption, option => option === optionConfig, { children: 'options' })
34
34
  if (matchObj) {
35
35
  matchObj.items.splice(matchObj.index, 1)
36
36
  }
@@ -39,8 +39,9 @@ export function destroyOption (_vm) {
39
39
  export function assemOption (_vm) {
40
40
  const { $el, $xeselect, $xeoptgroup, optionConfig } = _vm
41
41
  const groupConfig = $xeoptgroup ? $xeoptgroup.optionConfig : null
42
- optionConfig.slots = _vm.$scopedSlots
43
42
  if (groupConfig) {
43
+ // 子选项才允许自定义插槽
44
+ optionConfig.slots = _vm.$slots
44
45
  if (!groupConfig.options) {
45
46
  groupConfig.options = []
46
47
  }
@@ -456,8 +456,7 @@ const Methods = {
456
456
  */
457
457
  loadColumn (columns) {
458
458
  const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn(this, column), { children: 'children' })
459
- this.handleColumn(collectColumn)
460
- return this.$nextTick()
459
+ return this.handleColumn(collectColumn)
461
460
  },
462
461
  /**
463
462
  * 加载列配置并恢复到初始状态
@@ -488,10 +487,11 @@ const Methods = {
488
487
  UtilTools.warn('vxe.error.scrollErrProp', ['column.type=expand'])
489
488
  }
490
489
  }
491
- this.$nextTick(() => {
490
+ return this.$nextTick().then(() => {
492
491
  if (this.$toolbar) {
493
492
  this.$toolbar.syncUpdate({ collectColumn, $table: this })
494
493
  }
494
+ return this.recalculate()
495
495
  })
496
496
  },
497
497
  /**
@@ -775,13 +775,23 @@ const Methods = {
775
775
  defineField (record) {
776
776
  const { radioOpts, checkboxOpts, treeConfig, treeOpts, expandOpts } = this
777
777
  const rowkey = getRowkey(this)
778
- this.visibleColumn.forEach(({ property, editRender }) => {
778
+ this.tableFullColumn.forEach(column => {
779
+ const { property, editRender } = column
779
780
  if (property && !XEUtils.has(record, property)) {
780
- XEUtils.set(record, property, editRender && !XEUtils.isUndefined(editRender.defaultValue) ? editRender.defaultValue : null)
781
+ let cellValue = null
782
+ if (editRender) {
783
+ const { defaultValue } = editRender
784
+ if (XEUtils.isFunction(defaultValue)) {
785
+ cellValue = defaultValue({ column })
786
+ } else if (!XEUtils.isUndefined(defaultValue)) {
787
+ cellValue = defaultValue
788
+ }
789
+ }
790
+ XEUtils.set(record, property, cellValue)
781
791
  }
782
792
  })
783
- const ohterFields = [radioOpts.labelField, checkboxOpts.checkField, checkboxOpts.labelField, expandOpts.labelField]
784
- ohterFields.forEach((key) => {
793
+ const otherFields = [radioOpts.labelField, checkboxOpts.checkField, checkboxOpts.labelField, expandOpts.labelField]
794
+ otherFields.forEach((key) => {
785
795
  if (key && eqEmptyValue(XEUtils.get(record, key))) {
786
796
  XEUtils.set(record, key, null)
787
797
  }
@@ -3351,9 +3361,9 @@ const Methods = {
3351
3361
  clearAllSort(this)
3352
3362
  }
3353
3363
  if (!sortOpts.remote) {
3354
- return this.handleTableData(true)
3364
+ this.handleTableData(true)
3355
3365
  }
3356
- return this.$nextTick()
3366
+ return this.$nextTick().then(this.updateStyle)
3357
3367
  },
3358
3368
  // 在 v3 中废弃
3359
3369
  getSortColumn () {
@@ -308,6 +308,7 @@ export default {
308
308
  showTitleOverflow: true,
309
309
  animat: true,
310
310
  showClose: true,
311
+ draggable: true,
311
312
  // storage: false,
312
313
  storageKey: 'VXE_MODAL_POSITION'
313
314
  },
package/styles/form.scss CHANGED
@@ -11,22 +11,12 @@
11
11
  font-family: $vxe-font-family;
12
12
  background-color: $vxe-form-background-color;
13
13
  text-align: left;
14
- &.is--colon {
15
- .vxe-form--item-title {
16
- &:after {
17
- content: ":";
18
- font-size: 1.2em;
19
- font-family: SimSun, sans-serif;
20
- }
21
- }
22
- }
23
14
  }
24
15
 
25
16
  .vxe-form-slots {
26
17
  display: none;
27
18
  }
28
19
 
29
- .vxe-form--item-title,
30
20
  .vxe-form--item-content,
31
21
  .vxe-form--item-trigger-node {
32
22
  display: inline-block;
@@ -34,25 +24,45 @@
34
24
  }
35
25
 
36
26
  .vxe-form--item-title {
27
+ display: flex;
28
+ flex-direction: row;
37
29
  max-width: 320px;
38
30
  padding-right: 0.8em;
39
31
  &.is--ellipsis {
40
- overflow: hidden;
41
- text-overflow: ellipsis;
42
- white-space: nowrap;
32
+ .vxe-form--item-title-content {
33
+ overflow: hidden;
34
+ text-overflow: ellipsis;
35
+ white-space: nowrap;
36
+ }
37
+ }
38
+ .vxe-form--item-title-prefix,
39
+ .vxe-form--item-title-suffix,
40
+ .vxe-form--item-title-postfix {
41
+ flex-shrink: 0;
43
42
  }
44
43
  .vxe-form--item-title-prefix,
45
44
  .vxe-form--item-title-suffix {
46
45
  cursor: help;
47
- & > [class*="vxe-icon--"] {
48
- margin-top: -0.2em;
46
+ vertical-align: middle;
47
+ & > i {
48
+ vertical-align: middle;
49
49
  }
50
50
  }
51
51
  .vxe-form--item-title-prefix {
52
52
  margin-right: 0.25em;
53
53
  }
54
54
  .vxe-form--item-title-suffix {
55
- margin-left: 0.25em;
55
+ margin-left: 0.2em;
56
+ }
57
+ .vxe-form--item-title-postfix {
58
+ display: flex;
59
+ align-items: center;
60
+ }
61
+ .vxe-form--item-title-content {
62
+ flex-grow: 1;
63
+ }
64
+ .vxe-form--item-title-label {
65
+ vertical-align: middle;
56
66
  }
57
67
  }
58
68
 
@@ -99,18 +109,28 @@
99
109
  &.is--asterisk {
100
110
  .vxe-form--item {
101
111
  &.is--required {
102
- .vxe-form--item-title {
112
+ .vxe-form--item-title-content {
103
113
  &:before {
104
114
  content: "*";
105
115
  color: $vxe-form-validate-error-color;
116
+ font-family: Verdana,Arial,Tahoma;
106
117
  margin-right: 0.2em;
107
- font-family: $vxe-icon-font-family;
108
118
  font-weight: normal;
119
+ vertical-align: middle;
109
120
  }
110
121
  }
111
122
  }
112
123
  }
113
124
  }
125
+ &.is--colon {
126
+ .vxe-form--item-title-postfix {
127
+ &:after {
128
+ content: ":";
129
+ font-weight: normal;
130
+ margin-left: 0.2em;
131
+ }
132
+ }
133
+ }
114
134
  }
115
135
 
116
136
  .vxe-form--item {
package/styles/input.scss CHANGED
@@ -88,7 +88,7 @@ $iconWidth: 1.6em;
88
88
  }
89
89
  &.is--prefix {
90
90
  .vxe-input--inner {
91
- padding-left: #{$iconWidth + 0.2em};
91
+ padding-left: $iconWidth + 0.2em;
92
92
  }
93
93
  }
94
94
  }
@@ -104,7 +104,7 @@ $iconWidth: 1.6em;
104
104
  }
105
105
  &.is--suffix {
106
106
  .vxe-input--inner {
107
- padding-right: #{$iconWidth + 0.2em};
107
+ padding-right: $iconWidth + 0.2em;
108
108
  }
109
109
  }
110
110
  &.is--left {
@@ -136,7 +136,7 @@ $iconWidth: 1.6em;
136
136
  &.type--year,
137
137
  &.type--time {
138
138
  .vxe-input--inner {
139
- padding-right: #{$iconWidth + 0.2em};
139
+ padding-right: $iconWidth + 0.2em;
140
140
  }
141
141
  .vxe-input--suffix {
142
142
  right: $iconWidth;
@@ -158,7 +158,7 @@ $iconWidth: 1.6em;
158
158
  &.type--year,
159
159
  &.type--time {
160
160
  .vxe-input--inner {
161
- padding-right: #{$iconWidth * 2};
161
+ padding-right: $iconWidth * 2;
162
162
  }
163
163
  }
164
164
  }
package/styles/modal.scss CHANGED
@@ -141,9 +141,6 @@
141
141
  left: 50%;
142
142
  top: 0;
143
143
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
144
- .vxe-modal--header {
145
- cursor: move;
146
- }
147
144
  }
148
145
  .vxe-modal--body {
149
146
  overflow: auto;
@@ -249,6 +246,9 @@
249
246
  background-color: $vxe-modal-header-background-color;
250
247
  border-radius: $vxe-border-radius $vxe-border-radius 0 0;
251
248
  user-select: none;
249
+ &.is--drag {
250
+ cursor: move;
251
+ }
252
252
  &.is--ellipsis {
253
253
  overflow: hidden;
254
254
  text-overflow: ellipsis;
@@ -129,6 +129,7 @@
129
129
  .vxe-select--empty-placeholder {
130
130
  padding: 0 10px;
131
131
  text-align: center;
132
+ color: $vxe-select-empty-color;
132
133
  }
133
134
 
134
135
  .vxe-select,
@@ -7,7 +7,7 @@
7
7
  top: -100%;
8
8
  left: -100%;
9
9
  font-size: 12px;
10
- max-width: 400px;
10
+ max-width: 500px;
11
11
  border-radius: $vxe-border-radius;
12
12
  padding: 8px 12px;
13
13
  white-space: normal;
@@ -233,6 +233,7 @@ $vxe-select-option-height-small: 26px;
233
233
  $vxe-select-option-height-mini: 24px;
234
234
  $vxe-select-option-hover-background-color: #f5f7fa;
235
235
  $vxe-select-panel-background-color: #fff;
236
+ $vxe-select-empty-color: #C0C4CC;
236
237
  $vxe-optgroup-title-color:#909399;
237
238
 
238
239
  /*switch*/
package/types/form.d.ts CHANGED
@@ -29,6 +29,11 @@ export declare class Form extends VXETableComponent {
29
29
  * @param callback 回调函数
30
30
  */
31
31
  validate(callback?: (errMap?: FormValidErrMapParams) => void): Promise<any>;
32
+ /**
33
+ * 对表单执行项进行校验,参数为一个回调函数。该回调函数会在校验结束后被调用 callback(errMap)。若不传入回调函数,则会返回一个 promise
34
+ * @param callback 回调函数
35
+ */
36
+ validateField(callback?: (errMap?: FormValidErrMapParams) => void): Promise<any>;
32
37
  /**
33
38
  * 手动清除校验状态,如果指定 field 则清除指定的项,否则清除整个表单
34
39
  * @param field 字段名