2 Commits 8f65057d82 ... 25890bcc0b

Author SHA1 Message Date
  changjiaming 25890bcc0b Merge branch 'dev1.0.1' of http://192.168.0.200:3000/suf/factoring-trade-front-end-v2 into chang1 7 months ago
  changjiaming bc6d2bffcb validate digit 7 months ago

+ 21 - 2
src/views/purchaseContractManagement/components/PurchaseContractReviewContent.vue

@@ -143,7 +143,9 @@
         </el-select>
       </el-form-item>
       <el-form-item label="税率" prop="approvalVatInfo.taxRate">
-        <el-input v-model="ruleForm.approvalVatInfo.taxRate" placeholder="请输入税率" style="width: 100%;" clearable :disabled="isView"></el-input>
+        <el-input v-model="ruleForm.approvalVatInfo.taxRate" placeholder="请输入税率" style="width: 100%;" clearable :disabled="isView">
+          <template slot="append">%</template>
+        </el-input>
       </el-form-item>
       <el-form-item label="发票开户行" prop="approvalVatInfo.openBank">
         <el-input v-model="ruleForm.approvalVatInfo.openBank" placeholder="请输入发票开户行" style="width: 100%;" clearable :disabled="isView"></el-input>
@@ -301,6 +303,22 @@ export default {
   },
   props: ["isView", "info"],
   data() {
+    const validateDigit = (rule, value, callback) => {
+      if (!value && value !== 0) {
+        callback(new Error('请输入税率'))
+      } else {
+        if(/^\d+(\.\d)?\d?$/g.test(value)) {
+          callback()
+          if(Number(value) > 100 || Number(value) < 0) {
+            callback(new Error('请输入0-100范围内的数字'))
+          } else {
+            callback()
+          }
+        } else {
+          callback(new Error('请输入保留两位小数的数字'))
+        }
+      }
+    }
     return {
       key: 0,
       ruleForm: {
@@ -360,7 +378,8 @@ export default {
           { required: true, message: '请选择发票类型', trigger: 'change' }
         ],
         'approvalVatInfo.taxRate': [
-          { required: true, message: '请输入税率', trigger: 'blur' }
+          { required: true, message: '请输入税率', trigger: 'blur' },
+          { validator: validateDigit, trigger: 'blur' }
         ],
         'approvalVatInfo.openBank': [
           { required: true, message: '请输入发票开户行', trigger: 'blur' }