parent
52f9049880
commit
27adac2ec4
5 changed files with 241 additions and 82 deletions
@ -0,0 +1,172 @@ |
|||||||
|
<template> |
||||||
|
<div class="wrap"> |
||||||
|
<el-form ref="form" :model="form" :rules="rules"> |
||||||
|
<el-form-item prop="userName" label="姓名"> |
||||||
|
<el-input v-model.trim="form.userName" placeholder="请输入姓名"></el-input> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item prop="account" label="账号"> |
||||||
|
<el-input v-model.trim="form.account" placeholder="请输入账号"></el-input> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item prop="phone" label="手机号"> |
||||||
|
<el-input v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11"></el-input> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item prop="email" label="邮箱"> |
||||||
|
<el-input v-model.trim="form.email" placeholder="请输入邮箱"></el-input> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
<div class="btn-wrap"> |
||||||
|
<el-button type="primary" @click="submit">确定</el-button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import util from "@/libs/util" |
||||||
|
import Setting from "@/setting" |
||||||
|
export default { |
||||||
|
data() { |
||||||
|
const accountPass = (rule, value, callback) => { |
||||||
|
if (value === '') { |
||||||
|
callback(new Error('请输入账号')) |
||||||
|
} else { |
||||||
|
const pattern = /^[A-Za-z0-9]*$/ |
||||||
|
if(pattern.test(value)){ |
||||||
|
this.accountChange() |
||||||
|
callback() |
||||||
|
}else{ |
||||||
|
callback(new Error('请输入正确账号格式')) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
const phonePass = (rule, value, callback) => { |
||||||
|
if (value) { |
||||||
|
const pattern = /^1[3456789]\d{9}$/ |
||||||
|
if(pattern.test(value)){ |
||||||
|
this.phoneChange() |
||||||
|
callback() |
||||||
|
}else{ |
||||||
|
callback(new Error('请输入正确手机号格式')) |
||||||
|
} |
||||||
|
} else { |
||||||
|
callback(new Error('请输入手机号')) |
||||||
|
} |
||||||
|
} |
||||||
|
const emailPass = (rule, value, callback) => { |
||||||
|
if (value) { |
||||||
|
const pattern = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/ |
||||||
|
if(pattern.test(value)){ |
||||||
|
// this.emailChange() |
||||||
|
callback() |
||||||
|
}else{ |
||||||
|
callback(new Error('请输入正确邮箱格式')) |
||||||
|
} |
||||||
|
} else { |
||||||
|
callback() |
||||||
|
} |
||||||
|
} |
||||||
|
return { |
||||||
|
token: window.atob(decodeURI(this.$route.query.token)), |
||||||
|
form: { |
||||||
|
partnerClassificationId: this.$route.query.id, |
||||||
|
isTeam: 0, |
||||||
|
account: '', |
||||||
|
email: '', |
||||||
|
phone: '', |
||||||
|
userName: '' |
||||||
|
}, |
||||||
|
rules: { |
||||||
|
account: [ |
||||||
|
{ required: true, validator: accountPass, trigger: 'blur' } |
||||||
|
], |
||||||
|
userName: [ |
||||||
|
{ required: true, message: "请输入姓名", trigger: "blur" } |
||||||
|
], |
||||||
|
phone: [ |
||||||
|
{ required: true, validator: phonePass, trigger: 'blur' } |
||||||
|
], |
||||||
|
email: [ |
||||||
|
{ validator: emailPass, trigger: 'blur' } |
||||||
|
] |
||||||
|
}, |
||||||
|
submiting: false // 新增编辑防抖标识 |
||||||
|
}; |
||||||
|
}, |
||||||
|
mounted() { |
||||||
|
sessionStorage.setItem('token', this.token) |
||||||
|
this.form.token = this.token |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
// 账号判重 |
||||||
|
accountChange() { |
||||||
|
const form = this.form |
||||||
|
const { account } = form |
||||||
|
if (account === this.originAccount) { |
||||||
|
this.accountReapeat = false |
||||||
|
} else { |
||||||
|
const { accountId } = form |
||||||
|
this.$post(`${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=2&account=${account}${accountId ? `&accountId=${accountId}` : ''}`).then(res => { |
||||||
|
this.accountReapeat = false |
||||||
|
}).catch(err => { |
||||||
|
this.accountReapeat = true |
||||||
|
}) |
||||||
|
} |
||||||
|
}, |
||||||
|
// 手机号判重 |
||||||
|
phoneChange() { |
||||||
|
const form = this.form |
||||||
|
const { phone } = form |
||||||
|
if (phone) { |
||||||
|
const { accountId } = form |
||||||
|
this.$post(`${this.api.checkEmailOrPhone}?phone=${phone}${accountId ? `&accountId=${accountId}` : ''}`).then(res => { |
||||||
|
this.phoneRepeat = false |
||||||
|
}).catch(err => { |
||||||
|
this.phoneRepeat = true |
||||||
|
}) |
||||||
|
} |
||||||
|
}, |
||||||
|
// 邮箱判重 |
||||||
|
emailChange() { |
||||||
|
const form = this.form |
||||||
|
const { email } = form |
||||||
|
if (email) { |
||||||
|
const { accountId } = form |
||||||
|
this.$post(`${this.api.checkEmailOrPhone}?email=${email}${accountId ? `&accountId=${accountId}` : ''}`).then(res => { |
||||||
|
this.emailRepeat = false |
||||||
|
}).catch(err => { |
||||||
|
this.emailRepeat = true |
||||||
|
}) |
||||||
|
} |
||||||
|
}, |
||||||
|
// 提交 |
||||||
|
submit() { |
||||||
|
this.$refs.form.validate((valid) => { |
||||||
|
if (valid) { |
||||||
|
if (this.submiting) return false |
||||||
|
if (this.accountReapeat) return util.warningMsg("该账号已存在") |
||||||
|
if (this.phoneRepeat) return util.warningMsg("该手机号已存在") |
||||||
|
if (this.emailRepeat) return util.warningMsg("该邮箱已存在") |
||||||
|
const { form } = this |
||||||
|
form.uniqueIdentification = Date.now() |
||||||
|
this.submiting = true |
||||||
|
this.$post(this.api.savePartnerAccount, form).then(res => { |
||||||
|
util.successMsg('加入成功!') |
||||||
|
setTimeout(location.reload, 1000) |
||||||
|
}).catch(res => { |
||||||
|
this.submiting = false |
||||||
|
}) |
||||||
|
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
} |
||||||
|
}; |
||||||
|
</script> |
||||||
|
|
||||||
|
<style lang="scss" scoped> |
||||||
|
.wrap { |
||||||
|
width: 500px; |
||||||
|
margin: 40px auto; |
||||||
|
} |
||||||
|
.btn-wrap { |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
</style> |
Loading…
Reference in new issue