|
|
@@ -531,30 +531,22 @@ export default {
|
|
531
|
531
|
}
|
|
532
|
532
|
},
|
|
533
|
533
|
formRules() {
|
|
534
|
|
- const phoneRule = [{ required: true, message: this.dtT("ruleContactPhone"), trigger: "blur" }, { validator: this.validatePhone, trigger: "blur" }]
|
|
|
534
|
+ const phoneRuleRequired = [{ required: true, message: this.dtT("ruleContactPhone"), trigger: "blur" }, { validator: this.validatePhone, trigger: "blur" }]
|
|
|
535
|
+ const phoneRuleOptional = [{ validator: this.validatePhoneOptional, trigger: "blur" }]
|
|
535
|
536
|
const rules = {
|
|
536
|
537
|
resourceType: [{ required: true, message: this.dtT("ruleResourceType"), trigger: "change" }],
|
|
537
|
538
|
resourceName: [
|
|
538
|
539
|
{ required: true, message: this.dtT("ruleResourceName"), trigger: "blur" },
|
|
539
|
540
|
{ min: 1, max: 10, message: this.dtCommon("ruleLen110"), trigger: "blur" }
|
|
540
|
|
- ],
|
|
541
|
|
- photoFilePath: [{ required: true, message: this.dtT("rulePhoto"), trigger: "change" }],
|
|
542
|
|
- introduction: [
|
|
543
|
|
- { required: true, message: this.dtT("ruleIntroduction"), trigger: "blur" },
|
|
544
|
|
- { min: 1, max: 500, message: this.dtCommon("ruleLen1500"), trigger: "blur" }
|
|
545
|
541
|
]
|
|
546
|
542
|
}
|
|
547
|
543
|
const t = this.normalizeResourceType(this.form.resourceType)
|
|
548
|
544
|
if (this.isVetType(t)) {
|
|
549
|
|
- rules.contactPhone = phoneRule
|
|
550
|
|
- rules.affiliatedUnit = [
|
|
551
|
|
- { required: true, message: this.dtT("ruleAffiliatedUnit"), trigger: "blur" },
|
|
552
|
|
- { min: 1, max: 20, message: this.dtCommon("ruleLen120"), trigger: "blur" }
|
|
553
|
|
- ]
|
|
554
|
|
- rules.detailAddress = [
|
|
555
|
|
- { required: true, message: this.dtT("ruleDetailAddress"), trigger: "blur" },
|
|
556
|
|
- { min: 1, max: 100, message: this.dtCommon("ruleLen1100"), trigger: "blur" }
|
|
557
|
|
- ]
|
|
|
545
|
+ rules.photoFilePath = []
|
|
|
546
|
+ rules.introduction = [{ max: 500, message: this.dtCommon("ruleLen1500"), trigger: "blur" }]
|
|
|
547
|
+ rules.contactPhone = phoneRuleOptional
|
|
|
548
|
+ rules.affiliatedUnit = [{ max: 20, message: this.dtCommon("ruleLen120"), trigger: "blur" }]
|
|
|
549
|
+ rules.detailAddress = [{ max: 100, message: this.dtCommon("ruleLen1100"), trigger: "blur" }]
|
|
558
|
550
|
rules.consultModesList = [{ validator: this.validateConsultModes, trigger: "change" }]
|
|
559
|
551
|
rules.serviceArea = [
|
|
560
|
552
|
{ required: true, message: this.dtT("ruleServiceArea"), trigger: "blur" },
|
|
|
@@ -563,8 +555,15 @@ export default {
|
|
563
|
555
|
rules.feeStandard = [{ required: true, message: this.dtT("ruleFeeStandard"), trigger: "change" }]
|
|
564
|
556
|
rules.serviceStartTime = [{ validator: this.validateServiceTime, trigger: "change" }]
|
|
565
|
557
|
rules.serviceWeekdaysList = [{ validator: this.validateWeekdays, trigger: "change" }]
|
|
566
|
|
- } else if (this.isTeamType(t)) {
|
|
567
|
|
- rules.contactPhone = phoneRule
|
|
|
558
|
+ } else {
|
|
|
559
|
+ rules.photoFilePath = [{ required: true, message: this.dtT("rulePhoto"), trigger: "change" }]
|
|
|
560
|
+ rules.introduction = [
|
|
|
561
|
+ { required: true, message: this.dtT("ruleIntroduction"), trigger: "blur" },
|
|
|
562
|
+ { min: 1, max: 500, message: this.dtCommon("ruleLen1500"), trigger: "blur" }
|
|
|
563
|
+ ]
|
|
|
564
|
+ }
|
|
|
565
|
+ if (this.isTeamType(t)) {
|
|
|
566
|
+ rules.contactPhone = phoneRuleRequired
|
|
568
|
567
|
rules.affiliatedUnit = [
|
|
569
|
568
|
{ required: true, message: this.dtT("ruleAffiliatedUnit"), trigger: "blur" },
|
|
570
|
569
|
{ min: 1, max: 20, message: this.dtCommon("ruleLen120"), trigger: "blur" }
|
|
|
@@ -585,7 +584,7 @@ export default {
|
|
585
|
584
|
{ required: true, message: this.dtT("rulePersonInCharge"), trigger: "blur" },
|
|
586
|
585
|
{ min: 1, max: 10, message: this.dtCommon("ruleLen110"), trigger: "blur" }
|
|
587
|
586
|
]
|
|
588
|
|
- rules.contactPhone = phoneRule
|
|
|
587
|
+ rules.contactPhone = phoneRuleRequired
|
|
589
|
588
|
rules.serviceStartTime = [{ validator: this.validateServiceTime, trigger: "change" }]
|
|
590
|
589
|
rules.serviceWeekdaysList = [{ validator: this.validateWeekdays, trigger: "change" }]
|
|
591
|
590
|
rules.maxDailyAppointments = [{ required: true, message: this.dtT("ruleMaxDaily"), trigger: "change" }]
|
|
|
@@ -695,6 +694,17 @@ export default {
|
|
695
|
694
|
}
|
|
696
|
695
|
callback()
|
|
697
|
696
|
},
|
|
|
697
|
+ validatePhoneOptional(rule, value, callback) {
|
|
|
698
|
+ if (!value || !String(value).trim()) {
|
|
|
699
|
+ callback()
|
|
|
700
|
+ return
|
|
|
701
|
+ }
|
|
|
702
|
+ if (!PHONE_REG.test(String(value).trim())) {
|
|
|
703
|
+ callback(new Error(this.dtCommon("rulePhone")))
|
|
|
704
|
+ return
|
|
|
705
|
+ }
|
|
|
706
|
+ callback()
|
|
|
707
|
+ },
|
|
698
|
708
|
validateConsultModes(rule, value, callback) {
|
|
699
|
709
|
if (!value || !value.length) {
|
|
700
|
710
|
callback(new Error(this.dtCommon("ruleConsultOne")))
|