zhujindu 1 anno fa
parent
commit
2a4129b630

+ 15 - 2
src/views/clew/complaintDetail/index.vue

@@ -387,13 +387,26 @@ export default {
     },
     isRequiredFlag(optionList) {
       // console.log(optionList);
-      // 必填类型
       for (let i = 0; i < optionList.length; i++) {
-        if (optionList[i].answerType == 'wb' && optionList[i].isMust == 0) {
+        if (
+          (optionList[i].answerType == 'wb' || optionList[i].answerType == 'wb') &&
+          optionList[i].isMust == 0
+        ) {
           if (!optionList[i].answerValue) {
+            // 必填类型
             this.requiredFlag = false;
             this.requiredMessage = optionList[i].remark;
             return;
+          } else {
+            // 条件校验
+            if (optionList[i].minTextLength) {
+              // 输入内容长度校验
+              if (optionList[i].answerValue.length < optionList[i].minTextLength) {
+                this.requiredFlag = false;
+                this.requiredMessage = optionList[i].remark;
+                return;
+              }
+            }
           }
         }
       }

+ 42 - 7
src/views/clew/complaintDetail/radioGroup.vue

@@ -19,11 +19,28 @@
           </template>
         </van-radio-group>
       </template>
+      <!-- 回答类型:wb-文本,sz-数字,rq-日期,zp-照片,dx -->
       <template v-if="val.answerType == 'wb'">
         <template v-if="parentOptionList.searchValue == val.itemOptionParentId">
-          <van-field v-model="val.answerValue" :placeholder="val.remark" />
+          <van-field
+            class="fieldInput"
+            v-model="val.answerValue"
+            :placeholder="val.remark"
+            :minTextLength="val.minTextLength"
+            :error-message="val.remark"
+            @blur="onBlur" />
         </template>
       </template>
+      <template v-if="val.answerType == 'sz'">
+        <van-field
+          class="fieldInput"
+          v-model="val.answerValue"
+          :placeholder="val.remark"
+          :minTextLength="val.minTextLength"
+          :error-message="val.remark"
+          type="number"
+          @blur="onBlur"></van-field>
+      </template>
     </template>
   </div>
 </template>
@@ -90,6 +107,21 @@ export default {
         }
       });
     },
+    // 失去焦点时校验 rules
+    onBlur(event) {
+      // console.log(event);
+      // let classValue = event.target.attributes.class.value;
+      // event.target.attributes.class.value = 'van-field__control';
+      let minTextLength = event.target.attributes.minTextLength;
+      let value = event.target.value;
+      // 输入内容长度校验
+      if (event && minTextLength && minTextLength.value) {
+        if (!value.length || value.length < minTextLength.value) {
+          // event.target.attributes.class.value = classValue + ' rulesClass';
+          this.$toast(event.target.placeholder);
+        }
+      }
+    },
     radioClick(event) {
       // console.log(event);
     },
@@ -113,7 +145,6 @@ export default {
     border: 0;
   }
   .van-field {
-    border: 1px solid #cdc8c8;
     padding: 0;
     width: 100%;
     border-radius: 4px;
@@ -121,13 +152,11 @@ export default {
     background-color: unset;
     height: 30px;
     line-height: 30px;
-    margin: 5px 0;
   }
   .van-field__control {
-    padding: 0 10px;
-  }
-  .van-field__control {
-    padding: 0 10px;
+    /* padding: 0 10px; */
+    border: 1px solid #cdc8c8;
+    margin: 5px 0;
   }
   .van-radio__label {
     /* font-size: 14px; */
@@ -135,5 +164,11 @@ export default {
   .van-f-red {
     font-size: 14px;
   }
+  .rulesClass {
+    border: 1px solid #ff0505;
+  }
+  .fieldInput {
+    height: 38px;
+  }
 }
 </style>