Browse Source

优化

master
陈裕财 4 years ago
parent
commit
1393d1b526
  1. 8
      src/api/branch.js
  2. 38
      src/api/login.js
  3. 146
      src/views/login/BranchAdd.vue
  4. 121
      src/views/login/index.vue
  5. 56
      src/views/login/register.vue
  6. 81
      src/views/login/resetPassword.vue

8
src/api/branch.js

@ -9,11 +9,11 @@ let base=config.getSysBasePath();
*1 默认只开放普通查询所有查询只要上传 分页参数 {currentPage:当前页码从1开始,pageSize:每页记录数,total:总记录数如果是0后台会自动计算总记录数非0不会自动计算}后台都会自动按分页查询 其它 api用到再打开没用到的api请注释掉
*2 查询新增修改的参数格式 params={id:'机构编号 主键',branchName:'机构名称',enabled:'是否可用',industryCategory:'行业分类',cuserid:'创建人编号',cdate:'创建日期',cusername:'创建人姓名',phoneNo:'联系电话',emaill:'邮件'}
**/
//普通查询 条件之间and关系
//普通查询 条件之间and关系
export const listBranchNoAuth = params => { return axios.get(`${base}/mdp/sys/branch/listBranchNoAuth`, { params: params }); };
//模糊查询管理端机构表(机构下面若干部门) 条件之间or关系
//模糊查询管理端机构表(机构下面若干部门) 条件之间or关系
//export const listBranchKey = params => { return axios.get(`${base}/mdp/sys/branch/listKey`, { params: params }); };
//删除一条管理端机构表(机构下面若干部门) params={id:'机构编号 主键'}
@ -30,4 +30,4 @@ export const addBranchNoAuth = params => { return axios.post(`${base}/mdp/sys/br
//新增一条企业入驻审核流程
export const addUserJoinBranchRequire = params => { return axios.post(`${base}/mdp/sys/userJoinBranchRequire/add`, params); };
export const addUserJoinBranchRequire = params => { return axios.post(`${base}/mdp/sys/userJoinBranchRequire/add`, params); };

38
src/api/login.js

@ -7,13 +7,14 @@ import config from '@/common/config'
let base=config.getOauth2LoginBasePath();
//let base='';
export function doLoginByUserloginid(userloginid, password,grantType,authType,deptid) {
export function doLoginByUserloginid(userloginid, password,grantType,authType,deptid,userid) {
removeToken();
const data = {
userloginid: userloginid,
password: password,
authType:authType,
deptid:deptid
deptid:deptid,
userid:userid,
}
return axios({
url: base+'/login/token?grantType='+grantType,
@ -55,6 +56,14 @@ export function checkPhoneno(phoneno ) {
data
})
}
export function queryByUserloginid( params ) {
return axios({
url: base+'/user/queryByUserloginid',
method: 'get',
params:params
})
}
export function doRegister( userInfo ) {
removeToken();
const data = {
@ -79,6 +88,7 @@ export function resetPasswordByPhoneno( userInfo ) {
newPassword:userInfo.newPassword,
phoneno:userInfo.phoneno,
smsCode:userInfo.smsCode,
userid:userInfo.userid
}
return axios({
url: base+'/user/password/reset?type=sms',
@ -109,3 +119,27 @@ export function getUserInfo(params) {
data
})
}
/**
* 发送邮件
*/
export function sendEmail(params) {
const data=params;
return axios({
url: base+'/user/sendEmail',
method: 'post',
data
})
}
/**
* 验证邮箱
*/
export function validEmailCode(params) {
return axios({
url: base+'/user/validEmailCode',
method: 'get',
params:params
})
}

146
src/views/login/BranchAdd.vue

@ -7,16 +7,16 @@
<el-row class="app-container">
<el-radio v-model="addOrJoinBranch" label="add" >创建新公司</el-radio><el-radio v-model="addOrJoinBranch" label="join" ></el-radio>
</el-row>
<!--新增界面 Branch 管理端机构表机构下面若干部门-->
<!--新增界面 Branch 管理端机构表机构下面若干部门-->
<el-form :model="addForm" v-show="addOrJoinBranch=='add'" label-width="100px" :rules="addFormRules" ref="addForm">
<el-form-item label="公司名称" prop="branchName">
<el-input v-model="addForm.branchName" auto-complete="off">
<el-button slot="append" round type="primary" plain @click="checkBranchExists">查询机构是否存在</el-button>
<el-button slot="append" round type="primary" plain @click="checkBranchExists">查询机构是否存在</el-button>
</el-input>
</el-form-item>
<el-form-item label="行业分类" prop="industryCategory">
</el-form-item>
<el-form-item label="行业分类" prop="industryCategory">
<el-select
v-model="addForm.industryCategory"
v-model="addForm.industryCategory"
filterable
allow-create
default-first-option
@ -28,29 +28,29 @@
:value="item.optionValue">
</el-option>
</el-select>
</el-form-item>
</el-form-item>
<el-form-item label="联系人姓名" prop="cusername">
<el-input v-model="addForm.cusername" auto-complete="off"></el-input>
</el-form-item>
</el-form-item>
<el-form-item label="联系电话" prop="phoneNo">
<el-input v-model="addForm.phoneNo" auto-complete="off"></el-input>
</el-form-item>
</el-form-item>
<el-form-item label="邮件" prop="emaill">
<el-input v-model="addForm.emaill" auto-complete="off"></el-input>
</el-form-item>
<el-form-item>
<el-button @click.native="handleCancel">取消</el-button>
<el-button v-loading="load.add" type="primary" round @click.native="addSubmit" >创建新公司</el-button>
</el-form-item>
</el-form-item>
<el-form-item>
<el-button @click.native="handleCancel">取消</el-button>
<el-button v-loading="load.add" type="primary" round @click.native="addSubmit" >创建新公司</el-button>
</el-form-item>
</el-form>
<!--新增界面 Branch 管理端机构表机构下面若干部门-->
<!--新增界面 Branch 管理端机构表机构下面若干部门-->
<el-form :model="joinForm" v-show="addOrJoinBranch=='join'" label-width="100px" :rules="joinFormRules" ref="joinForm">
<el-form-item label="公司查询" prop="joinBranchId">
<el-select
v-model="joinForm.joinBranchId"
v-model="joinForm.joinBranchId"
filterable
remote
remote
clearable
placeholder="请输入2个关键词查询"
:remote-method="searchBranchs"
@ -61,23 +61,23 @@
:key="item.id"
:label="item.branchName"
:value="item.id">
</el-option>
</el-select>
</el-option>
</el-select>
<el-tag>选择已有公司-申请加入</el-tag>
</el-form-item>
</el-form-item>
<el-form-item label="加入理由" prop="joinReason">
<el-input type="textarea" rows="4" v-model="joinForm.joinReason" auto-complete="off"></el-input>
</el-form-item>
</el-form-item>
<el-form-item label="联系人姓名" prop="joinUsername" >
<el-input v-model="joinForm.joinUsername" auto-complete="off"></el-input>
</el-form-item>
</el-form-item>
<el-form-item label="联系电话" prop="joinUserPhoneno" >
<el-input v-model="joinForm.joinUserPhoneno" auto-complete="off"></el-input>
</el-form-item>
<el-form-item>
<el-button @click.native="handleCancel">取消</el-button>
<el-button v-loading="load.add" type="warning" round @click.native="joinBranch" >加入公司</el-button>
</el-form-item>
</el-form-item>
<el-form-item>
<el-button @click.native="handleCancel">取消</el-button>
<el-button v-loading="load.add" type="warning" round @click.native="joinBranch" >加入公司</el-button>
</el-form-item>
</el-form>
</el-row>
</section>
@ -88,49 +88,49 @@
import { listOption } from '@/api/itemOption';//
import { addBranchNoAuth,listBranchNoAuth,addUserJoinBranchRequire } from '@/api/branch';
import { mapGetters } from 'vuex'
export default {
props:['branch','visible'],
watch: {
'branch':function( branch ) {
this.addForm = branch;
},
'visible':function(visible) {
'visible':function(visible) {
if(visible==true){
//
}
}
},
}
},
data() {
const validateBranchName = (rule, value, callback) => {
const validateBranchName = (rule, value, callback) => {
if( !value || value.length<=6){
callback(new Error('请输入6位以上公司名称'))
}else{
callback()
}
}
}
const validatePhoneNo = (rule, value, callback) => {
const validatePhoneNo = (rule, value, callback) => {
if( !value || value.length !=11 ){
callback(new Error('手机号码必须为11位号码'))
}else{
callback()
}
}
const validateCusername = (rule, value, callback) => {
}
}
const validateCusername = (rule, value, callback) => {
if( !value || value.length <2 ){
callback(new Error('请输入联系人名称'))
}else{
callback()
}
}
}
}
return {
options:{},// params=[{categoryId:'0001',itemCode:'sex'}] {'sex':[{optionValue:'1',optionName:'',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'',seqOrder:'2',fp:'',isDefault:'0'}]}
options:{},// params=[{categoryId:'0001',itemCode:'sex'}] {'sex':[{optionValue:'1',optionName:'',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'',seqOrder:'2',fp:'',isDefault:'0'}]}
load:{ list: false, edit: false, del: false, add: false },//...
addFormRules: {
branchName: [{ required: true, trigger: 'blur', validator: validateBranchName }],
cusername: [{ required: true, trigger: 'blur', validator: validateCusername }],
phoneNo: [{ required: true, trigger: 'blur', validator: validatePhoneNo }],
phoneNo: [{ required: true, trigger: 'blur', validator: validatePhoneNo }],
},
//
addForm: {
@ -139,18 +139,18 @@
joinFormRules: {
//branchName: [{ required: true, trigger: 'blur', validator: validateBranchName }],
joinUsername: [{ required: true, trigger: 'blur', validator: validateCusername }],
joinUserPhoneno: [{ required: true, trigger: 'blur', validator: validatePhoneNo }],
joinUserPhoneno: [{ required: true, trigger: 'blur', validator: validatePhoneNo }],
joinBranchId:[{ required: true, message: '要加入的公司不能为空', trigger: 'blur' }],
joinReason:[{ required: true, message: '加入理由不能为空', trigger: 'blur' }],
},
//
joinForm: {
id:'',joinBranchId:'',joinUserPhoneno:'',joinUserid:'',joinUsername:'',joinDeptid:'',joinReason:''
},
},
branchs:[],
addOrJoinBranch:'join'
/**begin 在下面加自定义属性,记得补上面的一个逗号**/
/**end 在上面加自定义属性**/
}//end return
},//end data
@ -161,10 +161,10 @@
},
//Branch @submit="afterAddSubmit"
addSubmit: function () {
this.$refs.addForm.validate((valid) => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
if(this.addForm.branchName.length>=6){
var params={
key:"%"+this.addForm.branchName+"%"
@ -173,32 +173,32 @@
if(res.data.tips.isOk){
if(res.data.data.length<=0){
this.load.add=true
let params = Object.assign({}, this.addForm);
let params = Object.assign({}, this.addForm);
params.cuserid=this.userInfo.userid
addBranchNoAuth(params).then((res) => {
this.load.add=false
var tips=res.data.tips;
if(tips.isOk){
if(tips.isOk){
this.$emit('submit',res.data.data );// @submit="afterAddSubmit"
}
this.$notify({position:'bottom-left',showClose:true,message: tips.msg, type: tips.isOk?'success':'error' });
this.$notify({position:'bottom-left',showClose:true,message: tips.msg, type: tips.isOk?'success':'error' });
}).catch(() => this.load.add=false);
}else{
this.$notify({position:'bottom-left',showClose:true,message: "该公司名已注册,不可以使用", type: 'error' });
this.$notify({position:'bottom-left',showClose:true,message: "该公司名已注册,不可以使用", type: 'error' });
return;
}
}
})
}else{
this.$notify({position:'bottom-left',showClose:true,message: "公司名必须6个字以上", type: 'error' });
this.$notify({position:'bottom-left',showClose:true,message: "公司名必须6个字以上", type: 'error' });
return;
}
});
}
});
},
searchBranchs:function(query){
this.load.list=true;
if(query.length>=2){
@ -219,29 +219,29 @@
})
}else{
this.load.list=false;
this.$notify({position:'bottom-left',showClose:true,message: "最少输入两个字", type: 'info' });
this.$notify({position:'bottom-left',showClose:true,message: "最少输入两个字", type: 'info' });
return;
}
},
joinBranch:function(){
joinBranch:function(){
this.$refs.joinForm.validate((valid) => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
var params= this.joinForm
addUserJoinBranchRequire(params).then(res=>{
addUserJoinBranchRequire(params).then(res=>{
var tips = res.data.tips;
if(tips.isOk){
this.$notify({position:'bottom-left',showClose:true,message:tips.msg, type: 'success' });
//this.$emit('submit',res.data.data );// @submit="afterAddSubmit"
return;
}else{
this.$notify({position:'bottom-left',showClose:true,message: tips.msg, type: 'error' });
if(tips.isOk){
this.$notify({position:'bottom-left',showClose:true,message:tips.msg, type: 'success' });
//this.$emit('submit',res.data.data );// @submit="afterAddSubmit"
return;
}else{
this.$notify({position:'bottom-left',showClose:true,message: tips.msg, type: 'error' });
return;
}
})
});
}
});
});
},
checkBranchExists:function(){
if(this.addForm.branchName.length>=2){
@ -251,25 +251,25 @@
listBranchNoAuth(params).then(res=>{
if(res.data.tips.isOk){
if(res.data.data.length<=0){
this.$notify({position:'bottom-left',showClose:true,message: "该公司名未注册,可以使用", type: 'success' });
this.$notify({position:'bottom-left',showClose:true,message: "该公司名未注册,可以使用", type: 'success' });
return;
}else{
this.$notify({position:'bottom-left',showClose:true,message: "该公司名已注册,不可以使用", type: 'error' });
this.$notify({position:'bottom-left',showClose:true,message: "该公司名已注册,不可以使用", type: 'error' });
return;
}
}
})
}else{
this.$notify({position:'bottom-left',showClose:true,message: "最少输入两个字", type: 'error' });
this.$notify({position:'bottom-left',showClose:true,message: "最少输入两个字", type: 'error' });
return;
}
}
/**begin 在下面加自定义方法,记得补上面的一个逗号**/
/**end 在上面加自定义方法**/
},//end method
components: {
components: {
// 'branch-edit':BranchEdit
},
computed: {
@ -278,7 +278,7 @@
])
},
mounted() {
this.addForm=Object.assign(this.addForm, this.branch);
this.addForm=Object.assign(this.addForm, this.branch);
this.addForm.cusername=this.userInfo.username
this.addForm.phoneNo=this.userInfo.phoneno;
this.addForm.cuserid=this.userInfo.userid;
@ -299,4 +299,4 @@
<style scoped>
</style>
</style>

121
src/views/login/index.vue

@ -13,14 +13,14 @@
</div>
<el-form-item prop="authType">
<el-radio-group v-model="loginForm.authType">
<el-radio label="password_display_userid">账户密码登录</el-radio>
<el-radio label="password_display_userid">账户密码</el-radio>
<el-radio label="sms">短信验证码快速登录</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item prop="displayUserid" v-show="loginForm.authType=='password_display_userid'">
<el-input name="displayUserid" type="text" v-model="loginForm.displayUserid" autoComplete="on" placeholder="用户编号" >
<el-form-item prop="userloginid" v-show="loginForm.authType=='password_display_userid'">
<el-input title="登陆账号" name="userloginid" type="text" v-model="loginForm.userloginid" autoComplete="on" placeholder="用户编号" >
<template slot="prepend">账号</template>
</el-input>
</el-input>
</el-form-item>
<el-form-item prop="password" v-show="loginForm.authType=='password_display_userid'">
@ -34,8 +34,13 @@
<el-form-item prop="phoneno" v-show="loginForm.authType=='sms'">
<el-input name="phoneno" type="text" v-model="loginForm.phoneno" autoComplete="on" placeholder="手机号码">
<template slot="prepend">手机号码&nbsp;&nbsp;&nbsp;</template>
<el-button slot="append" @click.prevent="sendPhonenoSmsCode">发送验证码</el-button>
<el-button slot="append" @click.prevent="sendPhonenoSmsCode" v-loading="load.sendSmsCode">发送验证码</el-button>
</el-input>
<span v-if="users!=null && users.length>0"> 该手机号有{{users.length}}个账户,请选择需要登录的账户<font color="blue"></font>
<br>
<el-tag v-if="selectUser && selectUser.userid">已选择:{{selectUser.username}}</el-tag> <el-button type="text" @click="phonenoUsersVisible=true">选择账户</el-button>
</span>
</el-form-item>
<el-form-item prop="smsCode" v-show="loginForm.authType=='sms'">
<el-input name="smsCode" type="text" v-model="loginForm.smsCode" autoComplete="on" placeholder="短信验证码">
@ -87,6 +92,27 @@
<el-dialog title="新增机构" :visible.sync="addBranchFormVisible" width="50%" :close-on-click-modal="false" append-to-body>
<branch-add :visible="addBranchFormVisible" @cancel="addBranchFormVisible=false" @submit="afterAddBranchSubmit"></branch-add>
</el-dialog>
<el-dialog
title="查看已有账户"
:visible.sync="phonenoUsersVisible"
width="600" append-to-body>
<el-table :data="users">
<el-table-column prop="userid" label="编号">
</el-table-column>
<el-table-column prop="displayUserid" label="登录账号">
</el-table-column>
<el-table-column prop="username" label="姓名">
</el-table-column>
<el-table-column prop="branchName" label="企业">
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="primary" @click="onUserSelect(scope.row)">选中</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
</template>
@ -96,6 +122,7 @@ import LangSelect from '@/components/LangSelect';
import SocialSign from './socialsignin';
import Register from './register';
import ResetPassword from './resetPassword';
import { queryByUserloginid } from '@/api/login';
import BranchAdd from './BranchAdd';
import { mapGetters } from 'vuex';
@ -151,14 +178,14 @@ export default {
}
return {
loginForm: {
displayUserid: '',
userloginid: '',
password: '',
authType:'password_display_userid',//password/sms/password_display_userid
phoneno:'',//
smsCode:'',//
},
loginRules: {
displayUserid: [{ required: true, trigger: 'blur', validator: validateDisplayUserid }],
userloginid: [{ required: true, trigger: 'blur', validator: validateDisplayUserid }],
password: [{ required: true, trigger: 'blur', validator: validatePassword }],
phoneno: [{ required: true, trigger: 'blur', validator: validatePhoneno }],
smsCode: [{ required: true, trigger: 'blur', validator: validateSmsCode }],
@ -166,13 +193,16 @@ export default {
passwordType: 'password',
loading: false,
load:{sendSmsCode:false,},
showResetPasswordDialog:false,//
showTpLoginDialog: false, //
showRegisterDialog: false,//
deptSelectVisible:false,//
userDeptid:'',//
userBranchId:'',//
addBranchFormVisible:false, //
users:[],
phonenoUsersVisible:false,
selectUser:null,
}
},
methods: {
@ -184,17 +214,30 @@ export default {
}
},
sendPhonenoSmsCode(){
var params={
phoneno:this.loginForm.phoneno,
scene:"login"
}
sendSmsCode(params).then(res=>{
if(res.data.tips.isOk){
this.$message.info(res.data.tips.msg);
this.load.sendSmsCode=true;
this.$refs.loginForm.validateField("phoneno",(err)=>{
if(err){
this.$message.error(err);
this.load.sendSmsCode=false;
return;
}else{
this.$message.error(res.data.tips.msg);
var params={
phoneno:this.loginForm.phoneno,
scene:"login"
}
sendSmsCode(params).then(res=>{
this.load.sendSmsCode=false;
if(res.data.tips.isOk){
this.$message.success(res.data.tips.msg);
this.queryByUserloginid();
}else{
this.$message.error(res.data.tips.msg);
}
}).catch(()=>this.load.sendSmsCode=false)
}
})
});
},
handleLogin() {
@ -202,29 +245,29 @@ export default {
if (valid) {
this.loading = true
let params={
displayUserid:this.loginForm.displayUserid,
userloginid:this.loginForm.userloginid,
password:md5(this.loginForm.password),
deptid:this.userDeptid,
authType:this.loginForm.authType,
phoneno:this.loginForm.phoneno,
smsCode:this.loginForm.smsCode,
branchId:this.userBranchId,
smsCode:this.loginForm.smsCode
}
var loginParams={ }
if(params.authType=='password_display_userid'){
loginParams.userloginid=params.displayUserid
loginParams.userloginid=params.userloginid
loginParams.password=params.password
loginParams.grantType="password"
loginParams.authType='password_display_userid'
//loginParams.deptid=params.deptid
loginParams.branchId=params.branchId
loginParams.deptid=params.deptid
}else if(params.authType=='sms'){
loginParams.userloginid=params.phoneno
loginParams.password=params.smsCode
loginParams.grantType="password"
loginParams.authType="sms"
//loginParams.deptid=params.deptid
loginParams.branchId=params.branchId
loginParams.deptid=params.deptid
}
if(this.selectUser){
loginParams.userid=this.selectUser.userid
}
this.$store.dispatch("LoginByUserloginid",loginParams).then(res => {
this.loading = false
@ -235,11 +278,7 @@ export default {
//this.userDeptid=res2.data.userInfo.deptid
this.loading = false
if(res2.data.tips.isOk==true){
if(this.$store.state.user.myBranchs==null ||this.$store.state.user.myBranchs.length==0||this.$store.state.user.myDepts==null || this.$store.state.user.myDepts.length<=0){
//if(1==1){
//this.$message.error("\n ");
this.addBranchFormVisible=true;
}else if(this.$store.state.user.myDepts.length>1 ){
if(this.$store.state.user.myDepts.length>1 ){
//this.$message.info("");
if( !this.userDeptid ){
this.userDeptid=res2.data.userInfo.deptid
@ -283,10 +322,8 @@ export default {
return
}
let depts=this.myDepts.filter(d=>d.deptid==this.userDeptid)
if(this.$store.state.user.userInfo.deptid!=this.userDeptid){
let depts=this.myDepts.filter(d=>d.deptid==this.userDeptid)
this.userBranchId=depts[0].branchId
this.handleLogin();
return;
}else{
@ -329,6 +366,24 @@ export default {
// this.$router.push({ path: '/' })
// })
// }
},
queryByUserloginid(){
var params={userloginid:this.loginForm.userloginid}
if(this.loginForm.authType=='sms'){
params.idType="phoneno"
}else{
params.idType='all'
}
queryByUserloginid(params).then(res=>{
var tips = res.data.tips;
if(tips.isOk){
this.users=res.data.data
}
})
},
onUserSelect(user){
this.selectUser=user
this.phonenoUsersVisible=false;
}
},
created() {

56
src/views/login/register.vue

@ -11,8 +11,11 @@
</div>
<el-form-item prop="phoneno" label="手机号码">
<el-input name="phoneno" type="text" v-model="loginForm.phoneno" autoComplete="on" placeholder="手机号码">
<el-button slot="append" @click.prevent="sendPhonenoSmsCode">发送验证码</el-button>
<span slot="append"> <el-button @click.prevent="sendPhonenoSmsCode" v-loading="load.sendSmsCode">发送验证码</el-button> </span>
</el-input>
<span v-if="phonenoUsers!=null && phonenoUsers.length>0"> 该手机号已注册有{{phonenoUsers.length}}个账户<font color="blue"></font>
<el-button type="text" @click="phonenoUsersVisible=true">查看明细</el-button>
</span>
</el-form-item>
<el-form-item prop="smsCode" label="短信验证码">
<el-input name="smsCode" type="text" v-model="loginForm.smsCode" autoComplete="on" placeholder="短信验证码">
@ -54,7 +57,22 @@
</el-col>
</el-row >
</el-dialog>
<el-dialog
title="查看已有账户"
:visible.sync="phonenoUsersVisible"
width="600" append-to-body>
<el-table :data="phonenoUsers">
<el-table-column prop="userid" label="编号">
</el-table-column>
<el-table-column prop="displayUserid" label="登录账号">
</el-table-column>
<el-table-column prop="username" label="姓名">
</el-table-column>
<el-table-column prop="branchName" label="企业">
</el-table-column>
</el-table>
</el-dialog>
<!-- 第三方登陆窗口 -->
<el-dialog :title="$t('login.thirdparty')" :visible.sync="showTpLoginDialog" append-to-body>
{{$t('login.thirdpartyTips')}}
@ -73,7 +91,7 @@
<script>
import { sendSmsCode } from '@/api/sms/sms';
import { checkPhoneno,checkDisplayUserid,doRegister } from '@/api/login';
import { checkPhoneno,checkDisplayUserid,doRegister,queryByUserloginid } from '@/api/login';
import LangSelect from '@/components/LangSelect';
import SocialSign from './socialsignin';
@ -140,10 +158,13 @@ export default {
passwordType: 'password',
loading: false,
load:{sendSmsCode:false,},
showTpLoginDialog: false, //
deptSelectVisible:false,//
userDeptid:'',//
addBranchFormVisible:false, //
phonenoUsers:[],//
phonenoUsersVisible:false,
}
},
methods: {
@ -155,18 +176,35 @@ export default {
}
},
sendPhonenoSmsCode(){
this.load.sendSmsCode=true;
if(!this.loginForm.phoneno){
this.$message.error("手机号码不能为空");
this.$message.error("手机号码不能为空");
this.load.sendSmsCode=false;
return;
}
if(this.loginForm.phoneno.length !=11 ){
this.$message.error("手机号码必须为11位");
this.load.sendSmsCode=false;
return;
}
var params={
phoneno:this.loginForm.phoneno,
scene:"register"
}
}
queryByUserloginid({userloginid:this.loginForm.phoneno,idType:"phoneno"}).then(res0=>{
this.load.sendSmsCode=false;
if(res0.data.tips.isOk){
this.phonenoUsers=res0.data.data;
sendSmsCode(params).then(res=>{
if(res.data.tips.isOk){
this.$message.success(res.data.tips.msg);
}else{
this.$message.error(res.data.tips.msg);
}
})
}
}).catch(err=> this.load.sendSmsCode=false)
/**
checkPhoneno(this.loginForm.phoneno).then(res0=>{
if(res0.data.tips.isOk){
sendSmsCode(params).then(res=>{
@ -180,8 +218,16 @@ export default {
this.$message.error("手机号码已存在,不允许注册,请直接登录");
}
})
*/
},
checkPhonenoUsers(){
queryByUserloginid({userloginid:this.loginForm.phoneno,idType:"phoneno",atype:'1'}).then(res0=>{
if(res0.data.tips.isOk){
this.phonenoUsers=res0.data.data;
}
})
},
checkDisplayUserid(){
if(!this.loginForm.displayUserid){
this.$message.error("账号不能为空");

81
src/views/login/resetPassword.vue

@ -13,6 +13,11 @@
<el-input name="phoneno" type="text" v-model="loginForm.phoneno" autoComplete="on" placeholder="手机号码">
<el-button slot="append" @click.prevent="sendPhonenoSmsCode">发送验证码</el-button>
</el-input>
<span v-if="phonenoUsers!=null && phonenoUsers.length>0"> 该手机号有{{phonenoUsers.length}}个账户,请选择需要重置密码的账户<font color="blue"></font>
<br>
<el-tag v-if="selectUser && selectUser.userid">已选择:{{selectUser.username}}</el-tag> <el-button type="text" @click="phonenoUsersVisible=true">选择账户</el-button>
</span>
</el-form-item>
<el-form-item prop="smsCode" label="短信验证码">
<el-input name="smsCode" type="text" v-model="loginForm.smsCode" autoComplete="on" placeholder="短信验证码">
@ -28,6 +33,27 @@
</el-form-item>
<el-button type="primary" style="width:100%;margin-bottom:30px;" :loading="loading" @click.native.prevent="handleResetPasswordByPhoneno">重置密码</el-button>
</el-form>
<el-dialog
title="查看已有账户"
:visible.sync="phonenoUsersVisible"
width="600" append-to-body>
<el-table :data="phonenoUsers">
<el-table-column prop="userid" label="编号">
</el-table-column>
<el-table-column prop="displayUserid" label="登录账号">
</el-table-column>
<el-table-column prop="username" label="姓名">
</el-table-column>
<el-table-column prop="branchName" label="企业">
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="primary" @click="onUserSelect(scope.row)">选中</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
<el-dialog
title="请选择一个部门进行登陆"
:visible.sync="deptSelectVisible"
@ -63,13 +89,13 @@
<script>
import { sendSmsCode } from '@/api/sms/sms';
import { checkPhoneno,resetPasswordByPhoneno } from '@/api/login';
import { checkPhoneno,resetPasswordByPhoneno,queryByUserloginid } from '@/api/login';
import LangSelect from '@/components/LangSelect';
import SocialSign from './socialsignin';
import BranchAdd from './BranchAdd';
import { mapGetters } from 'vuex';
import md5 from 'js-md5';
import md5 from 'js-md5';
export default {
components: { LangSelect, SocialSign, BranchAdd },
@ -114,6 +140,9 @@ export default {
deptSelectVisible:false,//
userDeptid:'',//
addBranchFormVisible:false, //
phonenoUsersVisible:false,
phonenoUsers:[],
selectUser:null,//
}
},
methods: {
@ -137,24 +166,22 @@ export default {
phoneno:this.loginForm.phoneno,
scene:"changePassword"
}
checkPhoneno(this.loginForm.phoneno).then(res0=>{
if(res0.data.tips.isOk==false){
sendSmsCode(params).then(res=>{
if(res.data.tips.isOk){
this.$message.success(res.data.tips.msg);
}else{
this.$message.error(res.data.tips.msg);
}
})
}else{
this.$message.error("手机号码不存在");
}
})
queryByUserloginid({userloginid:this.loginForm.phoneno,idType:"phoneno"}).then(res0=>{
if(res0.data.tips.isOk){
this.phonenoUsers=res0.data.data;
sendSmsCode(params).then(res=>{
if(res.data.tips.isOk){
this.$message.success(res.data.tips.msg);
}else{
this.$message.error(res.data.tips.msg);
}
})
}
})
},
handleResetPasswordByPhoneno() {
this.loading = true
this.$refs.loginForm.validate(valid => {
if (valid) {
let params={
@ -162,6 +189,22 @@ export default {
phoneno:this.loginForm.phoneno,
smsCode:this.loginForm.smsCode
}
if(this.phonenoUsers && this.phonenoUsers.length>0){
if(!this.selectUser || !this.selectUser.userid){
if(this.phonenoUsers.length==1){
this.selectUser=this.phonenoUsers[0]
}else{
this.$notify({position:'bottom-left',showClose:true,message:'请选一个账户进行重置密码',type:'warning'})
return;
}
}
}
if(this.selectUser && this.selectUser.userid){
params.userid=this.selectUser.userid
}
this.loading = true
resetPasswordByPhoneno(params).then(res=>{
this.loading = false
if(res.data.tips.isOk){
@ -232,6 +275,10 @@ export default {
// this.$router.push({ path: '/' })
// })
// }
},
onUserSelect(user){
this.selectUser=user
this.phonenoUsersVisible=false;
}
},
created() {

Loading…
Cancel
Save