ソースを参照

校验输入信息

lifanagju_citu 6 ヶ月 前
コミット
c6f1d2772d

+ 4 - 3
src/utils/validate.js

@@ -81,7 +81,8 @@ export const checkBankName = (value) => {
 }
 }
 
 
 // 效验有效位置地址
 // 效验有效位置地址
-const AddressReg = /^[A-Za-z\u4e00-\u9fa5]+$/;  
-export const checkAddress = (value) => {  
-  return AddressReg.test(value)
+const AddressReg = /[\u4e00-\u9fa5]/g;  
+export const checkAddress = (value) => {
+  const bool = value ? (value.match(AddressReg)?.length || 0) >= 12 : false // 校验12个中文字符
+  return bool
 }
 }

+ 11 - 12
src/views/recruit/enterprise/invoiceManagement/index.vue

@@ -47,7 +47,7 @@ import { getInvoiceTitlePage, createInvoiceTitle, updateInvoiceTitle, deleteInvo
 import Snackbar from '@/plugins/snackbar'
 import Snackbar from '@/plugins/snackbar'
 import Confirm from '@/plugins/confirm'
 import Confirm from '@/plugins/confirm'
 import { useI18n } from '@/hooks/web/useI18n'
 import { useI18n } from '@/hooks/web/useI18n'
-import { checkUSCI, checkBankNo, checkBankName } from '@/utils/validate'
+import { checkUSCI, checkBankNo, checkBankName, checkAddress } from '@/utils/validate'
 
 
 const { t } = useI18n()
 const { t } = useI18n()
 const total = ref(0)
 const total = ref(0)
@@ -96,7 +96,6 @@ const handleChangeCategory = (categoryType) => { // 0: 个人, 1: 企业
     return optionsItem
     return optionsItem
   })
   })
   nextTick(() => {
   nextTick(() => {
-    console.log(1, '23456', arr)
     formItems.value.options = arr
     formItems.value.options = arr
   })
   })
 }
 }
@@ -170,7 +169,7 @@ const optionsBase = {
     outlined: true,
     outlined: true,
     rules: [
     rules: [
       value => {
       value => {
-        if (value && checkBankName(value)) return true
+        if (!value || (value && checkBankName(value))) return true
         return '请输入正确的开户银行'
         return '请输入正确的开户银行'
       }
       }
     ]
     ]
@@ -185,7 +184,7 @@ const optionsBase = {
     outlined: true,
     outlined: true,
     rules: [
     rules: [
       value => {
       value => {
-        if (value && checkBankNo(value)) return true
+        if (!value || (value && checkBankNo(value))) return true
         return '请输入正确的银行账号'
         return '请输入正确的银行账号'
       }
       }
     ]
     ]
@@ -197,7 +196,13 @@ const optionsBase = {
     label: '企业注册地址',
     label: '企业注册地址',
     placeholder: '请填写开户许可证上的企业注册地址',
     placeholder: '请填写开户许可证上的企业注册地址',
     rulesBaseLabel: '企业注册地址',
     rulesBaseLabel: '企业注册地址',
-    outlined: true
+    outlined: true,
+    rules: [
+      value => {
+        if (!value || (value && checkAddress(value))) return true
+        return '请输入正确的注册地址'
+      }
+    ]
   },
   },
   enterprisePhone: {
   enterprisePhone: {
     type: 'phoneNumber',
     type: 'phoneNumber',
@@ -207,12 +212,6 @@ const optionsBase = {
     placeholder: '请填写开户许可证上的企业注册电话',
     placeholder: '请填写开户许可证上的企业注册电话',
     rulesBaseLabel: '企业注册电话',
     rulesBaseLabel: '企业注册电话',
     outlined: true,
     outlined: true,
-    // rules: [
-    //   value => {
-    //     if (value && checkPhone(value)) return true
-    //     return '请填写正确的电话'
-    //   }
-    // ]
   },
   },
   certificationTip: {
   certificationTip: {
     slotName: 'certificationTip',
     slotName: 'certificationTip',
@@ -241,7 +240,7 @@ const business = ref({})
 const getEnterpriseBusinessInfo = async () => {
 const getEnterpriseBusinessInfo = async () => {
   const data = await getEnterpriseBusiness()
   const data = await getEnterpriseBusiness()
   if (!data || !Object.keys(data).length) return
   if (!data || !Object.keys(data).length) return
-  console.log(1, 'business', data)
+  // console.log(1, 'business', data)
   business.value = {
   business.value = {
     title: data.name,
     title: data.name,
     code: data.code,
     code: data.code,