瀏覽代碼

非邮箱用户新增

yuhan 2 月之前
父節點
當前提交
594a143b71
共有 1 個文件被更改,包括 57 次插入6 次删除
  1. 57 6
      src/views/module_interLock/systemUser/modules/SystemUserForm.vue

+ 57 - 6
src/views/module_interLock/systemUser/modules/SystemUserForm.vue

@@ -7,13 +7,25 @@
             <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="username">
               <span slot="label">
                 用户名称&nbsp;
-                <a-tooltip title="用户名称为邮箱格式">
+                <a-tooltip title="用户名称为邮箱格式且sso中无当前用户时需设置密码">
                   <a-icon type="question-circle-o" />
                 </a-tooltip>
               </span>
-              <a-input v-model="model.username" placeholder="请输入用户名称" :disabled="userDisabled" ></a-input>
+              <a-input v-model="model.username" placeholder="请输入用户名称" :disabled="userDisabled" @blur="handleBlur"></a-input>
             </a-form-model-item>
           </a-col>
+          <template v-if="!isEmail">
+            <a-col :span="24">
+              <a-form-model-item label="登录密码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="password">
+                <a-input-password autocomplete="new-password" v-model="model.password" placeholder="请输入登录密码" />
+              </a-form-model-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-model-item label="确认密码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="confirmpassword" >
+                <a-input-password autocomplete="new-password" v-model="model.confirmpassword" @blur="handleConfirmBlur" placeholder="请再次输入登录密码"/>
+              </a-form-model-item>
+            </a-col>
+          </template>
           <a-col :span="24">
             <a-form-model-item label="描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
               <a-input v-model="model.remark" placeholder="请输入描述"  ></a-input>
@@ -105,10 +117,20 @@
           username: [
             { required: true, message: '请输入用户名称!', },
             { validator: (rule, value, callback) => validateDuplicateValue('interlock_user', 'username', value, this.model.id, callback)},
-            {
-              pattern: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/,
-              message: '邮箱格式不正确'
-            },
+            // {
+            //   pattern: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/,
+            //   message: '邮箱格式不正确'
+            // },
+          ],
+          password: [
+            { required: true,
+              // pattern:/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
+              message: '密码由8位数字、大小写字母和特殊符号组成!' },
+            { validator: this.validateToNextPassword,trigger: 'change' }
+          ],
+          confirmpassword: [
+            { required: true, message: '请重新输入登录密码!',},
+            { validator: this.compareToFirstPassword,}
           ],
         },
         url: {
@@ -148,6 +170,7 @@
         indeterminateManageHeader: false,
         viewHeader: false,
         indeterminateViewHeader: false,
+        isEmail: true, // 用户是否为邮箱格式
       }
     },
     computed: {
@@ -164,6 +187,34 @@
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
     },
     methods: {
+      validateToNextPassword (rule, value, callback) {
+        const confirmpassword=this.model.confirmpassword;
+        if (value && confirmpassword && value !== confirmpassword) {
+          callback('两次输入的密码不一样!');
+        }
+        if (value && this.confirmDirty) {
+          this.$refs.form.validateField(['confirmpassword']);
+        }
+        callback();
+      },
+      compareToFirstPassword (rule, value, callback) {
+        if (value && value !== this.model.password) {
+          callback('两次输入的密码不一样!');
+        } else {
+          callback()
+        }
+      },
+      handleConfirmBlur(e) {
+        const value = e.target.value;
+        this.confirmDirty = this.confirmDirty || !!value
+      },
+      handleBlur(){
+        const emailRegExp = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/
+        if(emailRegExp.test(this.model.username)){
+          // 判断sso中是否有当前账户
+        }
+        this.isEmail = emailRegExp.test(this.model.username)
+      },
       // 新增
       async add () {
         this.confirmLoading = true