vue2-client 1.12.45 → 1.12.48
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 +1 -1
- package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +24 -14
- package/src/base-client/components/common/XForm/XForm.vue +404 -393
- package/src/base-client/components/common/XForm/XFormItem.vue +1310 -1265
- package/src/base-client/components/common/XForm/XTreeSelect.vue +263 -263
- package/src/base-client/components/common/XFormGroup/demo.vue +4 -2
- package/src/base-client/components/common/XFormTable/demo.vue +1 -1
- package/src/components/FilePreview/FilePreview.vue +28 -10
- package/src/components/FilePreview/FilePreviewDemo.vue +30 -0
- package/src/mixins/formValidationMixin.js +46 -0
- package/src/router/async/router.map.js +2 -1
package/package.json
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
:zIndex="1001"
|
|
7
7
|
:model="form"
|
|
8
8
|
v-bind="formItemLayoutGen"
|
|
9
|
-
:layout="layout"
|
|
10
|
-
:rules="rules">
|
|
9
|
+
:layout="layout">
|
|
11
10
|
<template v-for="(item, key) in childTableData">
|
|
12
11
|
<a-row
|
|
13
12
|
v-if="childTablePriority"
|
|
@@ -66,6 +65,7 @@
|
|
|
66
65
|
:service-name="serviceName"
|
|
67
66
|
mode="新增/修改"
|
|
68
67
|
:layout="layout"
|
|
68
|
+
:rules="rules[`${item.name}${item.model}`]"
|
|
69
69
|
:get-data-params="getDataParams"
|
|
70
70
|
:env="env"
|
|
71
71
|
@x-form-item-emit-func="emitFunc"
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
:images="images"
|
|
91
91
|
:service-name="serviceName"
|
|
92
92
|
mode="新增/修改"
|
|
93
|
+
:rules="rules[`${item.name}${item.model}`]"
|
|
93
94
|
:get-data-params="getDataParams"
|
|
94
95
|
:env="env"
|
|
95
96
|
:setForm="setForm"
|
|
@@ -120,6 +121,7 @@
|
|
|
120
121
|
:images="images"
|
|
121
122
|
:service-name="serviceName"
|
|
122
123
|
mode="新增/修改"
|
|
124
|
+
:rules="rules[`${item.name}${item.model}`]"
|
|
123
125
|
:get-data-params="getDataParams"
|
|
124
126
|
:env="env"
|
|
125
127
|
:setForm="setForm"
|
|
@@ -164,6 +166,7 @@ import { addOrModify, getConfigByName, getConfigByNameAsync, runLogic } from '@v
|
|
|
164
166
|
import { checkIdNumber, REG_EMAIL, REG_LANDLINE, REG_PHONE } from '@vue2-client/utils/reg'
|
|
165
167
|
import moment from 'moment/moment'
|
|
166
168
|
import { executeStrFunction, executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
|
|
169
|
+
import formValidationMixin from '@vue2-client/mixins/formValidationMixin'
|
|
167
170
|
|
|
168
171
|
const DEFAULT_GROUP_NAME = '__default__'
|
|
169
172
|
export default {
|
|
@@ -343,6 +346,11 @@ export default {
|
|
|
343
346
|
return {
|
|
344
347
|
getComponentByName: this.getComponentByName,
|
|
345
348
|
registerComponent: this.registerComponent,
|
|
349
|
+
XFormContext: this,
|
|
350
|
+
// 移除必填项
|
|
351
|
+
removeRequired: this.removeRequired,
|
|
352
|
+
// 设置必填项
|
|
353
|
+
setRequired: this.setRequired,
|
|
346
354
|
getSelf: () => this,
|
|
347
355
|
}
|
|
348
356
|
},
|
|
@@ -382,6 +390,7 @@ export default {
|
|
|
382
390
|
// deep: true
|
|
383
391
|
// }
|
|
384
392
|
// },
|
|
393
|
+
mixins: [formValidationMixin],
|
|
385
394
|
methods: {
|
|
386
395
|
runLogic,
|
|
387
396
|
getConfigByNameAsync,
|
|
@@ -544,6 +553,7 @@ export default {
|
|
|
544
553
|
return start
|
|
545
554
|
},
|
|
546
555
|
setFormProps (formData, item, groupItem) {
|
|
556
|
+
const rulesKey = `${item.name}${item.model}`
|
|
547
557
|
if (formData[item.model] === undefined || formData[item.model] === null) {
|
|
548
558
|
formData[item.model] = undefined
|
|
549
559
|
}
|
|
@@ -569,7 +579,7 @@ export default {
|
|
|
569
579
|
if (groupItem) {
|
|
570
580
|
this.rules[groupItem] = []
|
|
571
581
|
} else {
|
|
572
|
-
this.rules[
|
|
582
|
+
this.rules[rulesKey] = []
|
|
573
583
|
}
|
|
574
584
|
const required = item.rule.required ? item.rule.required === true || item.rule.required === 'true' : false
|
|
575
585
|
let trigger
|
|
@@ -603,7 +613,7 @@ export default {
|
|
|
603
613
|
trigger: trigger
|
|
604
614
|
})
|
|
605
615
|
} else {
|
|
606
|
-
this.rules[
|
|
616
|
+
this.rules[rulesKey].push({
|
|
607
617
|
required: true,
|
|
608
618
|
message: message,
|
|
609
619
|
trigger: trigger
|
|
@@ -650,7 +660,7 @@ export default {
|
|
|
650
660
|
trigger: 'blur'
|
|
651
661
|
})
|
|
652
662
|
} else {
|
|
653
|
-
this.rules[
|
|
663
|
+
this.rules[rulesKey].push({
|
|
654
664
|
type: item.rule.type,
|
|
655
665
|
message: item.name + '必须为' + message,
|
|
656
666
|
transform: (value) => {
|
|
@@ -672,7 +682,7 @@ export default {
|
|
|
672
682
|
callback()
|
|
673
683
|
}
|
|
674
684
|
}
|
|
675
|
-
this.rules[groupItem ||
|
|
685
|
+
this.rules[groupItem || rulesKey].push({
|
|
676
686
|
type: 'email',
|
|
677
687
|
validator: validator,
|
|
678
688
|
message: '请输入正确的邮箱地址',
|
|
@@ -681,7 +691,7 @@ export default {
|
|
|
681
691
|
break
|
|
682
692
|
}
|
|
683
693
|
case 'userPhone': {
|
|
684
|
-
this.rules[groupItem ||
|
|
694
|
+
this.rules[groupItem || rulesKey].push({
|
|
685
695
|
type: 'userPhone',
|
|
686
696
|
validator: (rule, value, callback) => {
|
|
687
697
|
if (value && !REG_PHONE.test(value)) {
|
|
@@ -696,7 +706,7 @@ export default {
|
|
|
696
706
|
break
|
|
697
707
|
}
|
|
698
708
|
case 'idNumber': {
|
|
699
|
-
this.rules[groupItem ||
|
|
709
|
+
this.rules[groupItem || rulesKey].push({
|
|
700
710
|
validator: (rule, value, callback) => {
|
|
701
711
|
if (value && !checkIdNumber(value)) {
|
|
702
712
|
callback(new Error('请输入正确的身份证号码'))
|
|
@@ -709,7 +719,7 @@ export default {
|
|
|
709
719
|
break
|
|
710
720
|
}
|
|
711
721
|
case 'landlineNumber': {
|
|
712
|
-
this.rules[
|
|
722
|
+
this.rules[rulesKey].push({
|
|
713
723
|
validator: (rule, value, callback) => {
|
|
714
724
|
if (value && !REG_LANDLINE.test(value)) {
|
|
715
725
|
callback(new Error('请输入正确的座机号码'))
|
|
@@ -724,7 +734,7 @@ export default {
|
|
|
724
734
|
// 大于0
|
|
725
735
|
case 'greaterThanZero': {
|
|
726
736
|
item.numberInput = true
|
|
727
|
-
this.rules[
|
|
737
|
+
this.rules[rulesKey].push({
|
|
728
738
|
validator: (rule, value, callback) => {
|
|
729
739
|
if (isNaN(value) || value <= 0) {
|
|
730
740
|
callback(new Error('请输入一个大于0的数字'))
|
|
@@ -739,7 +749,7 @@ export default {
|
|
|
739
749
|
// 大于等于0
|
|
740
750
|
case 'greaterThanOrEqualZero': {
|
|
741
751
|
item.numberInput = true
|
|
742
|
-
this.rules[
|
|
752
|
+
this.rules[rulesKey].push({
|
|
743
753
|
validator: (rule, value, callback) => {
|
|
744
754
|
if (isNaN(value) || value < 0) {
|
|
745
755
|
callback(new Error('请输入一个大于等于0的数字'))
|
|
@@ -752,7 +762,7 @@ export default {
|
|
|
752
762
|
break
|
|
753
763
|
}
|
|
754
764
|
case 'stringLength': {
|
|
755
|
-
this.rules[
|
|
765
|
+
this.rules[rulesKey].push({
|
|
756
766
|
validator: (rule, value, callback) => {
|
|
757
767
|
if (value && value.length < item.rule.minLen) {
|
|
758
768
|
callback(new Error('长度不能少于' + item.rule.minLen + '个字符'))
|
|
@@ -767,7 +777,7 @@ export default {
|
|
|
767
777
|
break
|
|
768
778
|
}
|
|
769
779
|
case 'customJs': {
|
|
770
|
-
this.rules[
|
|
780
|
+
this.rules[rulesKey].push({
|
|
771
781
|
validator: (rule, value, callback) => {
|
|
772
782
|
this.customJsValidate(rule, value, callback, item)
|
|
773
783
|
},
|
|
@@ -1125,7 +1135,7 @@ export default {
|
|
|
1125
1135
|
if (callback) {
|
|
1126
1136
|
callback()
|
|
1127
1137
|
}
|
|
1128
|
-
}
|
|
1138
|
+
},
|
|
1129
1139
|
}
|
|
1130
1140
|
}
|
|
1131
1141
|
</script>
|