Browse Source

条件组件 - 校验 容错处理

hare8999@163.com 3 years ago
parent
commit
1514bd9102

+ 15 - 4
src/components/MxCondition/condition-mixins-data.js

@@ -480,10 +480,21 @@ export default {
       }
       // return formRef.validate() 这种方式没有外抛异常明细
       return new Promise((resolve, reject) => {
-        formRef.validate((valid, errors) => {
-          if (valid) resolve(valid)
-          else reject(errors) // 经这一步转化,可以外抛errors
-        })
+        const localFields = Object.keys(this.finalRules)
+        const formFields = formRef.fields
+        const shouldDelay = localFields.length > 0 && formFields.length == 0
+
+        const invoker = function(){
+          formRef.validate((valid, errors) => {
+            //debugger
+            if (valid) resolve(valid)
+            else reject(errors) // 经这一步转化,可以外抛errors
+          })
+        }
+
+        // NOTE: 5.14 hht 这里因为form组件的校验要在子组件加载好之后才能生效
+        if (shouldDelay) this.$nextTick(()=> invoker())
+        else invoker()
       })
     }
   }

+ 2 - 2
src/views/elective/generation/index.vue

@@ -65,11 +65,11 @@ export default {
       return this.activeOpt?.value
     },
     roundGroups() {
-      return this.electiveStatus?.roundGroups.map(rg => ({
+      return this.electiveStatus?.roundGroups?.map(rg => ({
         groupId: rg.groupId,
         groupName: this.translateGroup(rg.groupId),
         expectedCount: rg.personCount
-      }))
+      })) || []
     },
     generation() {
       return {