mooho-base-admin-plus 2.10.48 → 2.10.50
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/history.md +2 -0
- package/package/mooho-base-admin-plus.min.esm.js +9389 -8916
- package/package/mooho-base-admin-plus.min.js +29 -29
- package/package.json +1 -1
- package/src/components/view/view-table-excel.vue +116 -40
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { mapActions } from 'vuex';
|
|
26
26
|
import dateFormat from 'date-fns/format';
|
|
27
27
|
|
|
28
|
+
import Handsontable from 'handsontable';
|
|
28
29
|
import { HotTable } from '@handsontable/vue3';
|
|
29
30
|
import { ContextMenu } from 'handsontable/plugins/contextMenu';
|
|
30
31
|
import { registerAllModules } from 'handsontable/registry';
|
|
@@ -208,6 +209,46 @@
|
|
|
208
209
|
this.tableView = view.dataView;
|
|
209
210
|
this.tableView.columns = view.viewColumns;
|
|
210
211
|
|
|
212
|
+
console.log('this.$refs.table.hotInstance', this.$refs.table.hotInstance);
|
|
213
|
+
|
|
214
|
+
// 文本必填
|
|
215
|
+
Handsontable.validators.registerValidator('text-required', (value, callback) => {
|
|
216
|
+
if (!(value || '').trim()) {
|
|
217
|
+
callback(false);
|
|
218
|
+
} else {
|
|
219
|
+
callback(true);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// 数字必填
|
|
224
|
+
Handsontable.validators.registerValidator('numeric-required', (value, callback) => {
|
|
225
|
+
if (value === null || value === void 0) {
|
|
226
|
+
callback(false);
|
|
227
|
+
} else {
|
|
228
|
+
Handsontable.validators.NumericValidator(value, callback);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
console.log('Handsontable.validators.NumericValidator', Handsontable.validators.DateValidator);
|
|
233
|
+
|
|
234
|
+
// 日期必填
|
|
235
|
+
Handsontable.validators.registerValidator('date-required', (value, callback) => {
|
|
236
|
+
if (!(value || '').trim()) {
|
|
237
|
+
callback(false);
|
|
238
|
+
} else {
|
|
239
|
+
Handsontable.validators.DateValidator.apply({ instance: this.$refs.table.hotInstance }, [value, callback]);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// 选择必填
|
|
244
|
+
Handsontable.validators.registerValidator('select-required', (value, callback) => {
|
|
245
|
+
if (!(value || '').trim()) {
|
|
246
|
+
callback(false);
|
|
247
|
+
} else {
|
|
248
|
+
Handsontable.validators.AutocompleteValidator(value, callback);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
211
252
|
// 初始化数据源
|
|
212
253
|
// this.initDataSource();
|
|
213
254
|
|
|
@@ -225,13 +266,25 @@
|
|
|
225
266
|
if (!this.readonly) {
|
|
226
267
|
if (item.controlType === 'Label' || item.isReadonly == true) {
|
|
227
268
|
column.readOnly = true;
|
|
269
|
+
} else if (item.controlType === 'TextInput') {
|
|
270
|
+
column.type = 'text';
|
|
271
|
+
|
|
272
|
+
if (column.isRequired) {
|
|
273
|
+
column.validator = 'text-required';
|
|
274
|
+
}
|
|
228
275
|
} else if (item.controlType === 'NumberInput') {
|
|
229
276
|
column.type = 'numeric';
|
|
277
|
+
if (column.isRequired) {
|
|
278
|
+
column.validator = 'numeric-required';
|
|
279
|
+
}
|
|
230
280
|
// column.validator = 'numeric';
|
|
231
281
|
} else if (item.controlType === 'Check') {
|
|
232
282
|
column.type = 'checkbox';
|
|
233
283
|
} else if (item.controlType === 'Select') {
|
|
234
284
|
column.editor = 'select';
|
|
285
|
+
if (column.isRequired) {
|
|
286
|
+
column.validator = 'select-required';
|
|
287
|
+
}
|
|
235
288
|
|
|
236
289
|
let dataSource = [];
|
|
237
290
|
|
|
@@ -321,6 +374,9 @@
|
|
|
321
374
|
});
|
|
322
375
|
} else if (item.controlType === 'Date') {
|
|
323
376
|
column.type = 'date';
|
|
377
|
+
if (column.isRequired) {
|
|
378
|
+
column.validator = 'date-required';
|
|
379
|
+
}
|
|
324
380
|
column.dateFormat = 'YYYY-MM-DD';
|
|
325
381
|
column.correctFormat = true;
|
|
326
382
|
// column.renderer = function (instance, td, row, col, prop, value, cellProperties) {
|
|
@@ -668,50 +724,68 @@
|
|
|
668
724
|
* @public
|
|
669
725
|
*/
|
|
670
726
|
validate() {
|
|
671
|
-
|
|
672
|
-
let row = this.staticData[i];
|
|
673
|
-
|
|
674
|
-
for (let j = 0; j < this.columns.length; j++) {
|
|
675
|
-
let column = this.columns[j];
|
|
676
|
-
let value = this.parseData(row, column.code);
|
|
677
|
-
|
|
678
|
-
// 不显示的不验证
|
|
679
|
-
if (column.isShow == false) {
|
|
680
|
-
continue;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
//let name = column.name.replaceAll('<font style="color: red">*</font>', '');
|
|
684
|
-
|
|
685
|
-
if (column.isRequired) {
|
|
686
|
-
if (value == null || !(String(value) || '').trim()) {
|
|
687
|
-
this.error('Front_Msg_Row_Column_Required|' + (i + 1) + '|' + column.name);
|
|
688
|
-
return false;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
// if (column.maxLength != null && value != null && String(value).length > column.maxLength) {
|
|
693
|
-
// this.error('Front_Msg_Row_Validation_Max_Length|' + (i + 1) + '|' + column.name + '|' + column.maxLength.toString());
|
|
694
|
-
// return false;
|
|
695
|
-
// }
|
|
727
|
+
let rows = [];
|
|
696
728
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
729
|
+
for (let i = 0; i < this.staticData.length - 1; i++) {
|
|
730
|
+
rows.push(i);
|
|
731
|
+
}
|
|
732
|
+
console.log('rows', rows);
|
|
701
733
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}
|
|
734
|
+
let valid = this.$refs.table.hotInstance.validateRows(rows, valid => {
|
|
735
|
+
console.log('valid', valid);
|
|
736
|
+
});
|
|
706
737
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
738
|
+
if (!valid) {
|
|
739
|
+
this.error('Front_Msg_Form_Validate_Fail');
|
|
740
|
+
return false;
|
|
741
|
+
} else {
|
|
742
|
+
return true;
|
|
712
743
|
}
|
|
713
744
|
|
|
714
|
-
|
|
745
|
+
// for (let i = 0; i < this.staticData.length - 1; i++) {
|
|
746
|
+
// let row = this.staticData[i];
|
|
747
|
+
|
|
748
|
+
// for (let j = 0; j < this.columns.length; j++) {
|
|
749
|
+
// let column = this.columns[j];
|
|
750
|
+
// let value = this.parseData(row, column.code);
|
|
751
|
+
|
|
752
|
+
// // 不显示的不验证
|
|
753
|
+
// if (column.isShow == false) {
|
|
754
|
+
// continue;
|
|
755
|
+
// }
|
|
756
|
+
|
|
757
|
+
// //let name = column.name.replaceAll('<font style="color: red">*</font>', '');
|
|
758
|
+
|
|
759
|
+
// if (column.isRequired) {
|
|
760
|
+
// if (value == null || !(String(value) || '').trim()) {
|
|
761
|
+
// this.error('Front_Msg_Row_Column_Required|' + (i + 1) + '|' + column.name);
|
|
762
|
+
// return false;
|
|
763
|
+
// }
|
|
764
|
+
// }
|
|
765
|
+
|
|
766
|
+
// // if (column.maxLength != null && value != null && String(value).length > column.maxLength) {
|
|
767
|
+
// // this.error('Front_Msg_Row_Validation_Max_Length|' + (i + 1) + '|' + column.name + '|' + column.maxLength.toString());
|
|
768
|
+
// // return false;
|
|
769
|
+
// // }
|
|
770
|
+
|
|
771
|
+
// if (column.maxValue != null && !isNaN(value) && value > column.maxValue) {
|
|
772
|
+
// this.error('Front_Msg_Row_Validation_Max_Value|' + (i + 1) + '|' + column.name + '|' + column.maxValue.toString());
|
|
773
|
+
// return false;
|
|
774
|
+
// }
|
|
775
|
+
|
|
776
|
+
// if (column.minValue != null && !isNaN(value) && value < column.minValue) {
|
|
777
|
+
// this.error('Front_Msg_Row_Validation_Min_Value|' + (i + 1) + '|' + column.name + '|' + column.minValue.toString());
|
|
778
|
+
// return false;
|
|
779
|
+
// }
|
|
780
|
+
|
|
781
|
+
// if (!!(column.pattern || '').trim() && value != null && new RegExp(column.pattern).test(value) == false) {
|
|
782
|
+
// this.error('Front_Msg_Row_Validation_Pattern|' + (i + 1) + '|' + column.name + '|' + column.pattern);
|
|
783
|
+
// return false;
|
|
784
|
+
// }
|
|
785
|
+
// }
|
|
786
|
+
// }
|
|
787
|
+
|
|
788
|
+
//return true;
|
|
715
789
|
},
|
|
716
790
|
/**
|
|
717
791
|
* 获取数据
|
|
@@ -721,7 +795,9 @@
|
|
|
721
795
|
getData() {
|
|
722
796
|
let data = this.copy(this.staticData);
|
|
723
797
|
|
|
724
|
-
|
|
798
|
+
if (!this.readonly && this.tableView.createEnable) {
|
|
799
|
+
data.pop();
|
|
800
|
+
}
|
|
725
801
|
|
|
726
802
|
data.forEach(item => {
|
|
727
803
|
for (let key in item) {
|