ソースを参照

客户信息添加验证

lizhenhao 2 年 前
コミット
72841e00fd

+ 2 - 0
src/main.js

@@ -12,6 +12,7 @@ import utils from '@/utils'
 import sortUtils from '@/utils/sortUtils'
 import '@/utils/filter'
 import validator from '@/utils/validator'
+import validate from '@/utils/validate'
 import validatorXG from '@/utils/validatorXG'
 import validateXG from '@/utils/validateXG'
 import commonJS from '@/utils/common'
@@ -152,6 +153,7 @@ Vue.prototype.recover = utils.recover
 Vue.prototype.recoverNotNull = utils.recoverNotNull
 Vue.prototype.$axios = axios
 Vue.prototype.validator = validator
+Vue.prototype.validate = validate
 Vue.prototype.validatorXG = validatorXG
 Vue.prototype.validateXG = validateXG
 Vue.prototype.commonJS = commonJS

+ 22 - 2
src/utils/validateXG.js

@@ -14,7 +14,17 @@ export function isMobile (str) {
  * @returns {boolean}
  */
 export function isPhone (str) {
-  const phone = /(^(\d{3,4}-)?\d{6,8}$)|(^(\d{3,4}-)?\d{6,8}(-\d{1,5})?$)|(\d{6,20})/
+  const phone = /(^(\d{3,4}-)?\d{6,8}$)|(^(\d{3,4}-)?\d{6,8}(-\d{1,5})?$)/
+  return phone.test(str)
+}
+
+/**
+ * 固定电话或移动电话号码验证
+ * @param str
+ * @returns {boolean}
+ */
+export function isPhoneOrMobile (str) {
+  const phone = /(^(\d{3,4}-)?\d{6,8}$)|(^(\d{3,4}-)?\d{6,8}(-\d{1,5})?$)|(^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(19[0-9]{1}))+\d{8})$)/
   return phone.test(str)
 }
 
@@ -51,4 +61,14 @@ export function isBankNum (str) {
   return bankNumber.test(str)
 }
 
-export default {isMobile, isPhone, isBankNumber, isLinkMobile, isBankNum}
+/**
+ * 邮箱验证
+ * @param str
+ * @returns {boolean}
+ */
+export function isEmail (str) {
+  const email = /^((https|http|ftp|rtsp|mms)?:\/\/)?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+\/?)$/
+  return email.test(str)
+}
+
+export default {isMobile, isPhone, isBankNumber, isLinkMobile, isBankNum, isPhoneOrMobile, isEmail}

+ 17 - 1
src/utils/validatorXG.js

@@ -17,6 +17,14 @@ var isPhone = (rule, value, callback) => {
   }
 }
 
+var isPhoneOrMobile = (rule, value, callback) => {
+  if (value && !validateXG.isPhoneOrMobile(value)) {
+    callback(new Error('请输入正确的电话号码'))
+  } else {
+    callback()
+  }
+}
+
 var isBankNumber = (rule, value, callback) => {
   if (value && !validateXG.isBankNumber(value)) {
     callback(new Error('请输入正确的开户行账号'))
@@ -49,4 +57,12 @@ var isBankNum = (rule, value, callback) => {
   }
 }
 
-export default {isMobile, isPhone, isBankNumber, isLinkMobile, isIntGtZero, isBankNum}
+var isEmail = (rule, value, callback) => {
+  if (value && !validateXG.isEmail(value)) {
+    callback(new Error('请输入正确的邮箱地址'))
+  } else {
+    callback()
+  }
+}
+
+export default {isMobile, isPhone, isBankNumber, isLinkMobile, isIntGtZero, isBankNum, isPhoneOrMobile, isEmail}

+ 1 - 1
src/views/common/UpLoadComponent.vue

@@ -12,7 +12,7 @@
                :on-change="changes"
                :on-progress="uploadVideoProcess"
                :file-list="fileList">
-      <el-button type="info" size="mini" :disabled="auth==='view'">点击上传</el-button>
+      <el-button type="info" size="mini" :slot="auth==='view'?'tip':'trigger'" :disabled="auth==='view'">点击上传</el-button>
     </el-upload>
     <div style="height: calc(100% - 80px);margin-top: 10px">
       <!-- 进度条 -->

+ 46 - 26
src/views/modules/sys/workClient/WorkClientForm.vue

@@ -15,7 +15,7 @@
             <el-form-item label="客户名称" prop="workClientInfo.name" :rules="[
                   {required: true, message:'请输入客户名称', trigger:'blur'}
                 ]">
-              <el-input @blur="isExistByName" v-model="inputForm.workClientInfo.name" placeholder="请输入客户名称"></el-input>
+              <el-input maxlength="64" @blur="isExistByName" v-model="inputForm.workClientInfo.name" placeholder="请输入客户名称"></el-input>
             </el-form-item>
           </el-col>
             <el-col :span="2">
@@ -88,7 +88,7 @@
                           :rules="[
                    {required: true, message:'请输入统一社会信用代码', trigger:'blur'}
                  ]">
-              <el-input @blur="isExistByUscCode" v-model="inputForm.workClientInfo.uscCode" placeholder="请输入统一社会信用代码"></el-input>
+              <el-input maxlength="64" @blur="isExistByUscCode" v-model="inputForm.workClientInfo.uscCode" placeholder="请输入统一社会信用代码"></el-input>
             </el-form-item>
           </el-col>
 
@@ -158,26 +158,27 @@
 
           <el-col :span="12">
             <el-form-item label="法人代表" prop="workClientInfo.lawerPresint">
-              <el-input v-model="inputForm.workClientInfo.lawerPresint" placeholder="请填写法人代表"></el-input>
+              <el-input maxlength="64" v-model="inputForm.workClientInfo.lawerPresint" placeholder="请填写法人代表"></el-input>
             </el-form-item>
           </el-col>
 
           <el-col :span="12">
             <el-form-item label="邮政编码" prop="workClientInfo.zipCode">
-              <el-input v-model="inputForm.workClientInfo.zipCode" placeholder="请填写邮政编码"></el-input>
+              <el-input maxlength="64" v-model="inputForm.workClientInfo.zipCode" placeholder="请填写邮政编码"></el-input>
             </el-form-item>
           </el-col>
 
           <el-col :span="12">
             <el-form-item label="传真" prop="workClientInfo.fax">
-              <el-input v-model="inputForm.workClientInfo.fax" placeholder="请填写传真"></el-input>
+              <el-input maxlength="64" v-model="inputForm.workClientInfo.fax" placeholder="请填写传真"></el-input>
             </el-form-item>
           </el-col>
 
           <el-col :span="12">
             <el-form-item label="公司电话" prop="workClientInfo.telephone"
                           :rules="[
-                   {validator: this.validatorXG.isMobile, trigger: 'blur'}
+                   {validator: validatorXG.isPhoneOrMobile, trigger: 'change'},
+                   {validator: validatorXG.isPhoneOrMobile, trigger: 'blur'}
                  ]">
               <el-input v-model="inputForm.workClientInfo.telephone" placeholder="请填写公司电话"></el-input>
             </el-form-item>
@@ -185,7 +186,7 @@
 
           <el-col :span="12">
             <el-form-item label="公司网址" prop="workClientInfo.companyUrl">
-              <el-input v-model="inputForm.workClientInfo.companyUrl" placeholder="请填写公司网址"></el-input>
+              <el-input maxlength="64" v-model="inputForm.workClientInfo.companyUrl" placeholder="请填写公司网址"></el-input>
             </el-form-item>
           </el-col>
 
@@ -193,13 +194,13 @@
 
           <el-col :span="24">
             <el-form-item label="注册地址" prop="workClientInfo.registerAddress">
-              <el-input v-model="inputForm.workClientInfo.registerAddress" placeholder="请填写注册地址"></el-input>
+              <el-input maxlength="128" v-model="inputForm.workClientInfo.registerAddress" placeholder="请填写注册地址"></el-input>
             </el-form-item>
           </el-col>
 
           <el-col :span="24">
             <el-form-item label="详细地址" prop="workClientInfo.address">
-              <el-input v-model="inputForm.workClientInfo.address" placeholder="请填写详细地址"></el-input>
+              <el-input maxlength="128" v-model="inputForm.workClientInfo.address" placeholder="请填写详细地址"></el-input>
             </el-form-item>
           </el-col>
         </el-row>
@@ -237,7 +238,7 @@
 
           <vxe-table-column field="ourBank" title="开户银行" :edit-render="{}">
             <template v-slot:edit="scope" >
-              <el-input v-model="scope.row.ourBank" ></el-input>
+              <el-input maxlength="64" v-model="scope.row.ourBank" ></el-input>
             </template>
           </vxe-table-column>
           <vxe-table-column field="bankNumber" title="开户账号" :edit-render="{}">
@@ -247,7 +248,7 @@
           </vxe-table-column>
           <vxe-table-column field="remarks" title="备注信息" :edit-render="{}">
             <template v-slot:edit="scope" >
-              <el-input v-model="scope.row.remarks" ></el-input>
+              <el-input maxlength="64" v-model="scope.row.remarks" ></el-input>
             </template>
           </vxe-table-column>
           <vxe-table-column title="操作" width="100">
@@ -280,17 +281,17 @@
 
         <vxe-table-column field="name" title="联系人姓名" :edit-render="{}">
           <template v-slot:edit="scope">
-            <el-input v-model="scope.row.name" ></el-input>
+            <el-input maxlength="10" v-model="scope.row.name" ></el-input>
           </template>
         </vxe-table-column>
         <vxe-table-column field="office" title="部门" :edit-render="{}">
           <template v-slot:edit="scope">
-            <el-input v-model="scope.row.office" ></el-input>
+            <el-input maxlength="10" v-model="scope.row.office" ></el-input>
           </template>
         </vxe-table-column>
         <vxe-table-column field="position" title="职务" :edit-render="{}">
           <template v-slot:edit="scope">
-            <el-input v-model="scope.row.position" ></el-input>
+            <el-input maxlength="10" v-model="scope.row.position" ></el-input>
           </template>
         </vxe-table-column>
         <vxe-table-column field="qq" title="QQ" :edit-render="{}">
@@ -330,7 +331,7 @@
         zIndex="9999"/>
       <span slot="footer" class="dialog-footer">
       <el-button size="small" @click="close(),closeXTable()" icon="el-icon-circle-close">关闭</el-button>
-      <el-button size="small" type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick :disabled="isSubmit">确定</el-button>
+      <el-button size="small" type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick >确定</el-button>
     </span>
     </el-dialog>
   </div>
@@ -353,7 +354,6 @@
         dataListNew: [],
         title: '',
         method: '',
-        isSubmit: false,
         visible: false,
         loading: false,
         returnForm: {
@@ -482,12 +482,8 @@
         let value = this.inputForm.workClientInfo.name
         if (value !== null && value !== undefined && value !== '') {
           this.workClientService.isExist(value).then((data) => {
-            console.log('data', data.data)
             if (data.data !== 0) {
               this.$message.error('该客户名称已存在')
-              this.isSubmit = true
-            } else {
-              this.isSubmit = false
             }
           })
         }
@@ -496,12 +492,8 @@
         let value = this.inputForm.workClientInfo.uscCode
         if (value !== null && value !== undefined && value !== '') {
           this.workClientService.isExist(value).then((data) => {
-            console.log('data', data.data)
             if (data.data !== 0) {
               this.$message.error('该统一社会信用代码已存在')
-              this.isSubmit = true
-            } else {
-              this.isSubmit = false
             }
           })
         }
@@ -644,6 +636,9 @@
       },
       // 表单提交
       doSubmit () {
+        if (this.isExistByName() === undefined) {
+          return
+        }
         if (this.$refs.uploadComponent.checkProgress()) {
           this.loading = false
           return
@@ -712,13 +707,13 @@
                   flag = false
                   return
                 }
-                if (!this.validateXG.isMobile(item.linkPhone)) {
+                if (!this.validateXG.isPhoneOrMobile(item.linkPhone)) {
                   this.$message.error('联系人联系方式1填写不正确')
                   this.loading = false
                   flag = false
                   return
                 }
-                if (!this.validateXG.isMobile(item.linkMobile)) {
+                if (!this.validateXG.isPhoneOrMobile(item.linkMobile)) {
                   this.$message.error('联系人联系方式2填写不正确')
                   this.loading = false
                   flag = false
@@ -728,6 +723,31 @@
                 return
               }
             }
+            if (this.inputForm.workClientLinkman.length !== 0) {
+              let flag = true
+              this.inputForm.workClientLinkman.forEach(item => {
+                if (!this.commonJS.isEmpty(item.email)) {
+                  if (!this.validateXG.isEmail(item.email)) {
+                    this.$message.error('联系人信息-Email填写不正确')
+                    this.loading = false
+                    flag = false
+                    return
+                  }
+                }
+                if (!this.commonJS.isEmpty(item.qq)) {
+                  if (!this.validate.isQq(item.qq)) {
+                    this.$message.error('联系人信息-qq填写不正确')
+                    this.loading = false
+                    flag = false
+                    return
+                  }
+                }
+                flag = true
+              })
+              if (flag === false) {
+                return
+              }
+            }
 
             this.inputForm.workClientInfo.deputy = this.inputForm.workClientInfo.deputyList.join(',')