mooho-base-admin-plus 2.10.45 → 2.10.47

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,7 +1,7 @@
1
1
  {
2
2
  "name": "mooho-base-admin-plus",
3
3
  "description": "MOOHO basic framework for admin by Vue3",
4
- "version": "2.10.45",
4
+ "version": "2.10.47",
5
5
  "author": "jinyifan <jinyifan@mooho.com.cn>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -1335,8 +1335,6 @@
1335
1335
  },
1336
1336
  // 数据变化事件
1337
1337
  async onDataChange(sender, selected, tableRow, tableSender, tableSelected) {
1338
- console.log('onDataChange', sender, selected, tableRow, tableSender, tableSelected);
1339
-
1340
1338
  for (let column of this.columns) {
1341
1339
  // 判断是否需要显示
1342
1340
  if (!!(column.showJson || '').trim()) {
@@ -109,7 +109,7 @@
109
109
 
110
110
  if (column.controlType === 'DialogSelect' && !column.readonly) {
111
111
  this.$refs.dialogTable.init(column.source, () => {
112
- this.$refs.dialogTable.open(this.getParam(data[coords.row], column));
112
+ this.$refs.dialogTable.open(this.getParam(data[coords.row], column, this.parentData));
113
113
  });
114
114
  }
115
115
  }
@@ -227,7 +227,7 @@
227
227
  column.readOnly = true;
228
228
  } else if (item.controlType === 'NumberInput') {
229
229
  column.type = 'numeric';
230
- column.numericFormat = '0%';
230
+ // column.validator = 'numeric';
231
231
  } else if (item.controlType === 'Check') {
232
232
  column.type = 'checkbox';
233
233
  } else if (item.controlType === 'Select') {
@@ -505,7 +505,7 @@
505
505
  this.$emit('on-remove', rows, val => {
506
506
  b = val;
507
507
  });
508
- console.log(b);
508
+
509
509
  if (b) {
510
510
  this.$refs.table.hotInstance.alter('remove_row', delArr);
511
511
  }
@@ -517,21 +517,62 @@
517
517
 
518
518
  // 变更事件
519
519
  this.$refs.table.hotInstance.addHook('afterChange', changes => {
520
+ //console.log('afterChange', changes);
520
521
  if (changes) {
521
522
  changes.forEach(([row, property, oldValue, newValue]) => {
522
523
  if (!this.readonly && this.tableView.createEnable && row == this.data.length - 1 && (oldValue ?? '') != (newValue ?? '')) {
523
524
  this.data.push(this.getDefaultData());
524
- this.$refs.table.hotInstance.loadData(this.data);
525
525
  }
526
526
 
527
- this.onDataChange(
528
- this.data[row],
529
- this.columns.find(item => item.code == property)
530
- );
527
+ let column = this.columns.find(item => item.code == property);
528
+
529
+ if (column.controlType != 'DialogSelect') {
530
+ // 弹出框控件不触发数据变更事件,此处手动触发
531
+ this.onDataChange(this.data[row], column);
532
+ }
533
+
534
+ if (column.controlType == 'Select') {
535
+ // 校验下拉框选项是否在列表中
536
+ if (!column.selectOptions.some(item => item == newValue)) {
537
+ this.data[row][column.code] = null;
538
+ }
539
+ }
540
+
541
+ this.calc(this.data[row]);
542
+ this.$refs.table.hotInstance.updateData(this.data);
531
543
  });
544
+ }
545
+ });
532
546
 
533
- this.loadData();
547
+ // 粘贴事件
548
+ this.$refs.table.hotInstance.addHook('beforePaste', (data, coords) => {
549
+ //console.log('beforePaste', data, coords);
550
+ // 不含父级表头
551
+ let columns = this.columns.filter(item => {
552
+ return (
553
+ !!(item.parentCode || '').trim() ||
554
+ this.columns.filter(i => {
555
+ return i.parentCode == item.code;
556
+ }).length == 0
557
+ );
558
+ });
559
+
560
+ for (let col = coords[0].startCol; col < coords[0].startCol + data[0].length; col++) {
561
+ for (let row = coords[0].startRow; row < coords[0].startRow + data.length; row++) {
562
+ if (data[row - coords[0].startRow][col - coords[0].startCol] != null) {
563
+ // 去除前后空格
564
+ data[row - coords[0].startRow][col - coords[0].startCol] = data[row - coords[0].startRow][col - coords[0].startCol].trim();
565
+
566
+ if (columns[col].controlType == 'NumberInput') {
567
+ // 数字类型,去掉逗号
568
+ data[row - coords[0].startRow][col - coords[0].startCol] = data[row - coords[0].startRow][col - coords[0].startCol].replace(/,/g, '');
569
+ // this.$refs.table.hotInstance.updateData(this.data);
570
+ }
571
+ }
572
+ }
534
573
  }
574
+
575
+ // return data;
535
576
  });
536
577
 
537
578
  this.loadData([]);
@@ -627,27 +668,23 @@
627
668
  * @public
628
669
  */
629
670
  validate() {
630
- for (let i = 0; i < this.staticData.length; i++) {
671
+ for (let i = 0; i < this.staticData.length - 1; i++) {
631
672
  let row = this.staticData[i];
632
673
 
633
674
  for (let j = 0; j < this.columns.length; j++) {
634
675
  let column = this.columns[j];
635
676
  let value = this.parseData(row, column.code);
636
677
 
637
- if (column.slot != 'normal') {
638
- continue;
639
- }
640
-
641
678
  // 不显示的不验证
642
- if (row._isShow && row._isShow[column.code] == false) {
643
- continue;
644
- } else if (column.isShow == false) {
679
+ if (column.isShow == false) {
645
680
  continue;
646
681
  }
647
682
 
683
+ //let name = column.name.replaceAll('<font style="color: red">*</font>', '');
684
+
648
685
  if (column.isRequired) {
649
686
  if (value == null || !(String(value) || '').trim()) {
650
- this.error('Front_Msg_Row_Column_Required|' + (i + 1) + '|' + name);
687
+ this.error('Front_Msg_Row_Column_Required|' + (i + 1) + '|' + column.name);
651
688
  return false;
652
689
  }
653
690
  }
@@ -658,17 +695,17 @@
658
695
  // }
659
696
 
660
697
  if (column.maxValue != null && !isNaN(value) && value > column.maxValue) {
661
- this.error('Front_Msg_Row_Validation_Max_Value|' + (i + 1) + '|' + name + '|' + column.maxValue.toString());
698
+ this.error('Front_Msg_Row_Validation_Max_Value|' + (i + 1) + '|' + column.name + '|' + column.maxValue.toString());
662
699
  return false;
663
700
  }
664
701
 
665
702
  if (column.minValue != null && !isNaN(value) && value < column.minValue) {
666
- this.error('Front_Msg_Row_Validation_Min_Value|' + (i + 1) + '|' + name + '|' + column.minValue.toString());
703
+ this.error('Front_Msg_Row_Validation_Min_Value|' + (i + 1) + '|' + column.name + '|' + column.minValue.toString());
667
704
  return false;
668
705
  }
669
706
 
670
707
  if (!!(column.pattern || '').trim() && value != null && new RegExp(column.pattern).test(value) == false) {
671
- this.error('Front_Msg_Row_Validation_Pattern|' + (i + 1) + '|' + name + '|' + column.pattern);
708
+ this.error('Front_Msg_Row_Validation_Pattern|' + (i + 1) + '|' + column.name + '|' + column.pattern);
672
709
  return false;
673
710
  }
674
711
  }