imatrix-ui 2.9.46-dw → 2.9.48-dw

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imatrix-ui",
3
- "version": "2.9.46-dw",
3
+ "version": "2.9.48-dw",
4
4
  "description": "前端组件库:表格、表单、组织结构树等",
5
5
  "main": "lib/super-ui.umd.min.js",
6
6
  "private": false,
@@ -21,6 +21,7 @@
21
21
  @blur="blurEvent($event)"
22
22
  @focus="focus"
23
23
  >
24
+ <el-option v-if="baseProps.multiple !== undefined && baseProps.multiple === true && optionItems && optionItems.length > 0 " :label="$t('superGrid.selectAll')" value="saveAll" />
24
25
  <el-option
25
26
  v-for="item in optionItems"
26
27
  :key="item.value"
@@ -224,11 +225,28 @@ export default {
224
225
  },
225
226
  // 必须有该方法,否则无法给字段赋值
226
227
  inputValue(newValue) {
228
+ let isClickSaveAll = false
229
+ if (this.baseProps.multiple !== undefined && this.baseProps.multiple === true && newValue && newValue.indexOf('saveAll') >= 0) {
230
+ // 表示点击了全选选项
231
+ isClickSaveAll = true
232
+ if (newValue.length - 1 >= this.optionItems.length) {
233
+ // 表示需要取消全选
234
+ newValue = []
235
+ } else {
236
+ // 表示需要全选
237
+ const allValues = []
238
+ for (let i = 0; i < this.optionItems.length; i++) {
239
+ const item = this.optionItems[i]
240
+ allValues.push(item[this.valueAttribute])
241
+ }
242
+ newValue = allValues
243
+ }
244
+ }
227
245
  this.$emit('input', newValue)
228
246
  if (newValue === null || newValue === undefined || newValue === '') {
229
247
  this.remoteQueryMethod(newValue)
230
248
  }
231
- this.setValues(newValue)
249
+ this.setValues(newValue, isClickSaveAll)
232
250
  },
233
251
  packageDynamicDataSourceInfo(dynamicDataSourceCode, param) {
234
252
  return new Promise((resolve, reject) => {
@@ -373,11 +391,11 @@ export default {
373
391
  ? '_label_'
374
392
  : this.valueAttribute
375
393
  },
376
- setValues(newValue) {
394
+ setValues(newValue, isClickSaveAll) {
377
395
  if (this.valueSetOptions && this.valueSetOptions.length > 0) {
378
396
  if (this.baseProps.multiple !== undefined && this.baseProps.multiple === true) {
379
397
  // 多选时
380
- this.setColumnValueWhenMulti(newValue)
398
+ this.setColumnValueWhenMulti(newValue, isClickSaveAll)
381
399
  } else {
382
400
  // 单选时
383
401
  this.valueSetOptions.forEach(columnInfo => {
@@ -423,7 +441,7 @@ export default {
423
441
  })
424
442
  },
425
443
  // 多选下拉框时处理增加tag、减少tag时,映射字段赋值问题
426
- setColumnValueWhenMulti(newValue) {
444
+ setColumnValueWhenMulti(newValue, isClickSaveAll) {
427
445
  // 是否添加tag
428
446
  let isAddTag = false
429
447
  let removeTag
@@ -459,18 +477,88 @@ export default {
459
477
  if (isAddTag) {
460
478
  // 表示是增加tag
461
479
  const isRemove = false
462
- const lastSelectTag = newValue[newValue.length - 1]
463
- const items = this.optionItems.filter(
464
- item => item[this.valueAttribute] === lastSelectTag
465
- )
466
- if (items && items.length > 0) {
467
- this.setTagValue(null, isRemove, items[0])
480
+ if (isClickSaveAll) {
481
+ // 全选
482
+ this.setAllTagValue(isRemove)
483
+ } else {
484
+ const lastSelectTag = newValue[newValue.length - 1]
485
+ const items = this.optionItems.filter(
486
+ item => item[this.valueAttribute] === lastSelectTag
487
+ )
488
+ if (items && items.length > 0) {
489
+ this.setTagValue(null, isRemove, items[0])
490
+ }
468
491
  }
469
492
  } else {
470
493
  // 表示是减少tag
471
494
  const isRemove = true
472
- this.setTagValue(removeTag, isRemove)
495
+ if (isClickSaveAll) {
496
+ this.setAllTagValue(isRemove)
497
+ } else {
498
+ this.setTagValue(removeTag, isRemove)
499
+ }
500
+ }
501
+ },
502
+ setAllTagValue(isRemove) {
503
+ if (this.valueSetOptions && this.valueSetOptions.length > 0) {
504
+ this.valueSetOptions.forEach(columnInfo => {
505
+ const sourceColumnName = columnInfo.columnName
506
+ if (sourceColumnName !== this.valueAttribute) {
507
+ let targetColumnName = null
508
+ const targetColumnInfo = columnInfo.valueColumn
509
+ if (targetColumnInfo) {
510
+ targetColumnName = targetColumnInfo.name
511
+ if (this.isSql === true) {
512
+ targetColumnName = targetColumnInfo.dbColumnName
513
+ targetColumnName = getPropNameWhenJoinTable(
514
+ targetColumnName,
515
+ this.isJoinTable,
516
+ this.tableName
517
+ )
518
+ }
519
+ }
520
+ let value
521
+ if (targetColumnName) {
522
+ if (isRemove) {
523
+ // 移除tag
524
+ value = null
525
+ } else {
526
+ // 添加tag
527
+ let originalValue = ''
528
+ if (this.optionItems && this.optionItems.length > 0) {
529
+ this.optionItems.forEach(selectItem => {
530
+ const addValue = selectItem[sourceColumnName]
531
+ if (originalValue !== undefined && originalValue !== null && originalValue !== '') {
532
+ originalValue = originalValue + ',' + addValue
533
+ } else {
534
+ originalValue = addValue
535
+ }
536
+ })
537
+ value = originalValue
538
+ }
539
+ }
540
+ }
541
+ this.setTargetColumnValue(sourceColumnName, targetColumnName, value)
542
+ }
543
+ })
544
+ }
545
+ },
546
+ setTargetColumnValue(sourceColumnName, targetColumnName, value) {
547
+ if (
548
+ this.entity &&
549
+ targetColumnName &&
550
+ targetColumnName !== null &&
551
+ targetColumnName !== ''
552
+ ) {
553
+ setEntityFieldValue(this.entity, targetColumnName, value)
473
554
  }
555
+ this.$emit('set-value', {
556
+ value: value,
557
+ sourceColumnName: sourceColumnName,
558
+ targetColumnName: targetColumnName,
559
+ options: this.optionItems,
560
+ valueAttribute: this.valueAttribute
561
+ })
474
562
  },
475
563
  // 根据tag参数设置映射字段的值
476
564
  setTagValue(tag, isRemove, selectItem) {
@@ -515,21 +603,7 @@ export default {
515
603
  }
516
604
  }
517
605
  }
518
- if (
519
- this.entity &&
520
- targetColumnName &&
521
- targetColumnName !== null &&
522
- targetColumnName !== ''
523
- ) {
524
- setEntityFieldValue(this.entity, targetColumnName, value)
525
- }
526
- this.$emit('set-value', {
527
- value: value,
528
- sourceColumnName: sourceColumnName,
529
- targetColumnName: targetColumnName,
530
- options: this.optionItems,
531
- valueAttribute: this.valueAttribute
532
- })
606
+ this.setTargetColumnValue(sourceColumnName, targetColumnName, value)
533
607
  }
534
608
  })
535
609
  }
@@ -463,8 +463,7 @@ export default {
463
463
  if (!isDynamic) {
464
464
  // 选项组保存时将数组处理为字符串
465
465
  const beforeColumnValue = param.row[this.column.prop]
466
- console.log('un-edit---beforeColumnValue=', beforeColumnValue, 'this.column.prop=', this.column.prop)
467
- if (beforeColumnValue && Array.isArray(beforeColumnValue)) {
466
+ if (beforeColumnValue && Object.prototype.toString.apply(beforeColumnValue) === '[object Array]') {
468
467
  // 如果是数组才需要转换
469
468
  this.$set(param.row, this.column.prop, beforeColumnValue.join(','))
470
469
  }
@@ -510,7 +509,7 @@ export default {
510
509
  }
511
510
  } else {
512
511
  const beforeColumnValue = param.row[this.column.prop]
513
- if (beforeColumnValue && Array.isArray(beforeColumnValue)) {
512
+ if (beforeColumnValue && Object.prototype.toString.apply(beforeColumnValue) === '[object Array]') {
514
513
  // 如果是数组才需要转换
515
514
  this.$set(param.row, this.column.prop, beforeColumnValue.join(','))
516
515
  }