Merge remote-tracking branch 'origin/companyAdmin' into change0706

This commit is contained in:
lijiarao
2022-08-11 09:33:18 +08:00
6 changed files with 637 additions and 44 deletions
+17
View File
@@ -28,6 +28,23 @@ export function phoneLogin(parameter) {
})
}
// 管理员账号密码登录
export function companyAdminLogin(parameter) {
return axios({
url: '/companyManager/login',
method: 'post',
data: parameter
})
}
// 管理员手机号登录
export function companyAdminPhoneLogin(parameter) {
return axios({
url: '/companyManager/smsLogin',
method: 'post',
data: parameter
})
}
export function getSmsCaptcha(parameter) {
return axios({
url: api.SendSms,
+16
View File
@@ -382,6 +382,7 @@ export const routerData = [
id: '8'
},
// {
// redirect: null,
// path: '/dataDownload/DataDownload',
@@ -502,4 +503,19 @@ export const routerData = [
name: 'problem-collection-detail-list',
id: '15'
},
{
redirect: null,
path: '/companyUserList/CompanyUserList',
component: 'companyUserList/CompanyUserList',
route: '1',
meta: {
icon: 'team', // 菜单前图标
componentName: 'CompanyUserList',
keepAlive: false,
title: '人员信息' // 菜单名称
},
name: 'company-user-list',
id: '16'
},
]
+59 -1
View File
@@ -1,5 +1,5 @@
import Vue from 'vue'
import { login, logout, phoneLogin, thirdLogin } from '@/api/login'
import { login, logout, phoneLogin, thirdLogin,companyAdminLogin,companyAdminPhoneLogin } from '@/api/login'
import {
ACCESS_TOKEN,
USER_NAME,
@@ -127,6 +127,64 @@ const user = {
})
})
},
// 管理员账号密码登录
CompanyAdminLogin({ commit }, userInfo){
return new Promise((resolve, reject) => {
companyAdminLogin(userInfo).then(response => {
if (response.code == '200') {
// 初次登录需要跳转至修改密码,不存用户信息
if (response.message === 'updatePassword') {
resolve(response)
} else {
const result = response.result
const userInfo = result.userInfo
Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(UI_CACHE_DB_DICT_DATA, result.sysAllDictItems, 7 * 24 * 60 * 60 * 1000)
commit('SET_TOKEN', result.token)
commit('SET_INFO', userInfo)
commit('SET_NAME', { username: userInfo.username, realname: userInfo.realname, welcome: welcome() })
commit('SET_AVATAR', userInfo.avatar)
resolve(response)
}
} else {
reject(response)
}
}).catch(error => {
reject(error)
})
})
},
// 管理员手机验证码登录
CompanyAdminPhoneLogin({ commit }, userInfo) {
return new Promise((resolve, reject) => {
companyAdminPhoneLogin(userInfo).then(response => {
if (response.code == '200') {
// 初次登录需要跳转至修改密码,不存用户信息
if (response.message === 'updatePassword') {
resolve(response)
} else {
const result = response.result
const userInfo = result.userInfo
Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
Vue.ls.set(UI_CACHE_DB_DICT_DATA, result.sysAllDictItems, 7 * 24 * 60 * 60 * 1000)
commit('SET_TOKEN', result.token)
commit('SET_INFO', userInfo)
commit('SET_NAME', { username: userInfo.username, realname: userInfo.realname, welcome: welcome() })
commit('SET_AVATAR', userInfo.avatar)
resolve(response)
}
} else {
reject(response)
}
}).catch(error => {
reject(error)
})
})
},
/**
* 初次手机号登录,修改密码后再存用户信息
* @param commit
@@ -0,0 +1,122 @@
<template>
<div class="main-box">
<a-card :bordered="false">
<!--查询区域begin-->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :xl="6" :lg="8" :md="8" :sm="24">
<a-form-item label="用户名称">
<a-input placeholder="请输入用户名称" v-model="queryParam.name" :maxLength="50"></a-input>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="8" :md="8" :sm="24">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
<a-button class="reset-button" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!--查询区域end-->
<!-- 操作按钮区域-->
<div class="table-operator">
<a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
</div>
<!-- 操作按钮区域-end-->
<div>
<a-table
ref="table"
rowKey="id"
:scroll="{x: 1200}"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
@change="handleTableChange"
class="j-table-force-nowrap">
<template slot="text" slot-scope="text">
<j-ellipsis :value="text" :length="20"></j-ellipsis>
</template>
<!-- slot-scope="text,record"-->
<span slot="action" class="action-span-cell" >
<a @click="handleEdit(record)">编辑</a>
<a @click="handleDetail(record)">查看</a>
</span>
</a-table>
</div>
<company-user-modal ref="modalForm" @ok="modalFormOk"></company-user-modal>
</a-card>
</div>
</template>
<script>
import { JeroListMixin } from '@/mixins/JeroListMixin'
import JEllipsis from '@comp/jero/JEllipsis'
import CompanyUserModal from '@views/companyUserList/modules/CompanyUserModal'
export default {
name: 'CompanyUserList',
mixins: [JeroListMixin],
components:{
JEllipsis,
CompanyUserModal
},
data() {
return {
columns: [
{
title: '序号',
dataIndex: '',
key: 'rowIndex',
width: 60,
align: 'center',
customRender: function (t, r, index) {
return parseInt(index) + 1
}
}, {
title: '用户名',
align: 'center',
dataIndex: 'name',
scopedSlots: { customRender: 'text' }
},
{
title: '用户账号',
align: 'center',
dataIndex: 'username',
scopedSlots: { customRender: 'text' }
},
{
title: '手机号',
align: 'center',
dataIndex: 'phone',
scopedSlots: { customRender: 'text' }
},
{
title: '操作',
dataIndex: 'action',
align: 'center',
fixed: 'right',
width: 130,
scopedSlots: { customRender: 'action' }
}
],
url: {
list: '/payCaseCommitteeSubitem/payCaseCommitteeSubitem/findTwo'
}
}
},
methods: {
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
</style>
@@ -0,0 +1,332 @@
<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-row>
<a-col :xl="12" :sm="24">
<a-form-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入姓名"
v-decorator="['name',validatorRules.name]"
:maxLength='50'
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :xl="12" :sm="24">
<a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
<j-dict-select-tag v-decorator="['gender']" :triggerChange="true" placeholder="请选择性别"
dictCode="sex"/>
</a-form-item>
</a-col>
<a-col :xl="12" :sm="24">
<a-form-item label="职务" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入职务"
v-decorator="['post']"
:maxLength='50'
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :xl="12" :sm="24">
<a-form-item label="手机号" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入手机号"
v-decorator="['phone',validatorRules.phone]"
:maxLength='11'
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
</a-form-item>
</a-col>
<a-col :xl="12" :sm="24">
<a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入邮箱"
v-decorator="['email',validatorRules.email]"
:maxLength='50'
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :xl="12" :sm="24">
<a-form-item label="通讯地址" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入通讯地址"
:maxLength='50'
v-decorator="['contactAddress',validatorRules.contactAddress]"
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
</a-form-item>
</a-col>
<a-col :xl="12" :sm="24">
<a-form-item label="邮政编码" :labelCol="labelCol" :wrapperCol="wrapperCol" class="form-item-postcode">
<a-input placeholder="请输入邮政编码"
:maxLength='6'
v-decorator="['postalCode',validatorRules.postalCode]"
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
<a class="search-postcode" href="https://www.youbianku.com" target="_blank">查询邮编</a>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col>
<a-form-item label="备注" :labelCol="remarksLabelCol" :wrapperCol="remarksWrapperCol">
<a-textarea
placeholder="请输入备注"
:auto-size="{ minRows: 3, maxRows: 6 }"
v-decorator="['remarks']"
:maxLength='200'
@change="e => {e.target.value = (e.target.value + '').trim()}"/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-spin>
</j-modal>
</template>
<script>
import pick from 'lodash.pick'
import { httpAction } from '@api/manage'
import {getRSAPublicKey} from '@api/login'
import {JSEncrypt} from 'jsencrypt'
import JDictSelectTag from '@comp/dict/JDictSelectTag'
import {isEmail,postcode,phoneReg} from '@/utils/validate'
import {duplicateCheck} from '@api/api'
export default {
name: 'CompanyAdminModule',
data() {
return {
title: '操作',
width: 800,
visible: false,
confirmLoading: false,
form: this.$form.createForm(this),
c:'',// 加密公钥
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 }
},
remarksLabelCol: {
xs: { span: 24 },
sm: { span: 3 }
},
remarksWrapperCol: {
xs: { span: 24 },
sm: { span: 21 }
},
validatorRules: {
name: {
rules: [{ required: true, message:'请输入姓名' }],
validateTrigger: 'blur'
},
phone: {
rules: [{ required: true, validator: this.checkPhone }],
validateTrigger: 'blur'
},
email: {
rules: [{ required: true, validator: this.checkMail }],
validateTrigger: 'blur'
},
postalCode: {
rules: [{ required: true, validator: this.checkPostcode }],
validateTrigger: 'blur'
},
contactAddress: {
rules: [{ required: true, message: '请输入通讯地址' }],
validateTrigger: 'blur'
}
},
url: {
add: '/com.jero.payment/payManagerManagement/add',
edit: '/com.jero.payment/payManagerManagement/edit'
}
}
},
components:{
JDictSelectTag
},
methods: {
add() {
this.edit({})
},
edit(record) {
this.form.resetFields()
this.getRSAPublicKeyFunc()
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model))
})
},
/**
* 获取公钥
* */
getRSAPublicKeyFunc() {
getRSAPublicKey().then(res => {
this.rsaPublicKey = res.result
})
},
close() {
this.$emit('close')
this.visible = false
},
handleOk: function () {
if (this.confirmLoading) {
return
}
this.confirmLoading = true
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
let httpurl = ''
let method = 'post'
if (!this.model.id) {
httpurl += this.url.add
} else {
httpurl += this.url.edit
}
const formData = Object.assign(this.model, values)
formData.companyName = this.selectedCompany.companyName
formData.companyId = this.selectedCompany.companyId
let encrypt = new JSEncrypt()
encrypt.setPublicKey(this.rsaPublicKey)
formData.phone = encrypt.encrypt(values.phone)
formData.rsaPublicKey = this.rsaPublicKey
httpAction(httpurl, formData, method).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok', res.result)
that.close()
} else {
that.$message.warning(res.message)
}
}).finally(() => {
setTimeout(() => {
this.confirmLoading = false
}, 1000)
})
} else {
this.confirmLoading = false
}
})
},
handleCancel() {
this.close()
},
/**
* 联系人姓名重复校验
* @param rules
* @param value
* @param callback
*/
checkName(rules, value, callback) {
if (!value) {
callback('请输入姓名')
return
}
// 是否编辑
if (this.model.id) {
// 编辑前后姓名是否一致,一致则不进行验重
if (value === this.model.name) {
callback()
return
}
this.selectedCompanyId = this.model.company.id
}
},
/**
* 手机号校验
* @param rules
* @param value
* @param callback
*/
checkPhone(rules, value, callback) {
if (value) {
if (phoneReg(value)) {
// 是否编辑
if (this.model.id) {
// 编辑前后手机号是否一致,一致则不进行验重
if (value === this.model.phone) {
callback()
return
}
}
const param = {
confusionCode: 'pay_contacts_management_phone',
fieldVal: value,
encrypt: 1
}
// 唯一性校验
duplicateCheck(param).then(res => {
if (res.success) {
callback()
} else {
callback('手机号已存在')
}
})
return
}
callback('请输入正确的手机号')
}
callback('请输入手机号')
},
/**
* 邮箱校验
* @param rules
* @param value
* @param callback
*/
checkMail(rules, value, callback) {
if (value) {
if (isEmail(value)) {
callback()
} else {
callback('请输入正确格式的邮箱')
}
}
callback('请输入邮箱')
},
/**
* 邮政编码校验
* @param rules
* @param value
* @param callback
*/
checkPostcode(rules, value, callback) {
if (value) {
if (postcode(value)) {
callback()
} else {
callback('请输入正确格式的邮政编码')
}
}
callback('请输入邮政编码')
}
}
}
</script>
<style scoped lang="less">
.search-postcode {
color: #0090ff;
&:hover {
cursor: pointer;
}
}
</style>
+91 -43
View File
@@ -126,8 +126,9 @@
<a-row style="margin-bottom: 2%;">
<a-col :span="6"></a-col>
<!-- 切换登录方式-->
<!-- 企业管理员 去掉注册 去掉忘记密码 -->
<a-col :span="4">
<a-form-item>
<a-form-item v-if="loginType === 0">
<div @click="handleRegister" class="forget-password" style="margin-left: 5px;">注册</div>
</a-form-item>
</a-col>
@@ -139,33 +140,45 @@
</a-form-item>
</a-col>
<a-col :span="4" style="text-align: right;">
<a-form-item>
<a-form-item v-if="loginType === 0">
<span @click='forgetPassword' class="forget-password" style="float: right;">
忘记密码 <img style='height: 14px' src='../../assets/wenhao.png' alt=''>
</span>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="6"></a-col>
<a-col :span="10">
<div>
<span @click="toggleLoginType" class="company-admin-login">{{ loginTip }}</span>
</div>
</a-col>
</a-row>
</div>
</a-form>
</div>
</template>
<script>
import { mapActions } from 'vuex'
import { timeFix } from '@/utils/util'
import {mapActions} from 'vuex'
import {timeFix} from '@/utils/util'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getAction } from '@/api/manage'
import { getRSAPublicKey } from '@/api/login.js'
import { JSEncrypt } from 'jsencrypt'
import { phoneReg } from '@/utils/validate'
import {ACCESS_TOKEN} from '@/store/mutation-types'
import {getAction} from '@/api/manage'
import {getRSAPublicKey} from '@/api/login.js'
import {JSEncrypt} from 'jsencrypt'
import {phoneReg} from '@/utils/validate'
export default {
components: {},
data() {
return {
loginBtn: false,
loginType: 0,
loginType: 0, // 登录方式 0 普通用户登录 1企业管理员登录
loginTipObj: {
1: '普通用户登录',
0: '企业管理员登录'
},
stepCaptchaVisible: false,
form: this.$form.createForm(this),
state: {
@@ -173,12 +186,12 @@ export default {
smsSendBtn: false
},
validatorRules: {
username: { rules: [{ required: true, message: '请输入手机号!' }, { validator: this.checkPhone }] },
password: { rules: [{ required: true, message: '请输入密码!' }] },
mobile: { rules: [{ validator: this.validateMobile }] },
captcha: { rules: [{ required: true, message: '请输入验证码!' }] },
inputCode: { rules: [{ required: true, message: '请输入验证码!' }] },
phone: { rules: [{ required: true, message: '请输入手机号!' }, { validator: this.checkPhone }] }
username: {rules: [{required: true, message: '请输入手机号!'}, {validator: this.checkPhone}]},
password: {rules: [{required: true, message: '请输入密码!'}]},
mobile: {rules: [{validator: this.validateMobile}]},
captcha: {rules: [{required: true, message: '请输入验证码!'}]},
inputCode: {rules: [{required: true, message: '请输入验证码!'}]},
phone: {rules: [{required: true, message: '请输入手机号!'}, {validator: this.checkPhone}]}
},
velorifiedCode: '',
inputCodeContent: '',
@@ -192,6 +205,13 @@ export default {
needSetPassword: false // 是否需要设置密码
}
},
computed: {
// 底部提示的登录方式文字
loginTip() {
return this.loginTipObj[this.loginType]
}
},
created() {
document.title = '汽车标准化工作平台'
this.currdatetime = new Date().getTime()
@@ -200,17 +220,21 @@ export default {
this.handleChangeCheckCode()
},
methods: {
...mapActions(['Login', 'Logout', 'PhoneLogin']),
handleUsernameOrEmail(rule, value, callback) {
const regex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/
if (regex.test(value)) {
this.loginType = 0
} else {
this.loginType = 1
}
callback()
},
...mapActions(['Login', 'Logout', 'PhoneLogin','CompanyAdminLogin','CompanyAdminPhoneLogin']),
/**
* 切换登录方式
* */
toggleLoginType() {
if (this.loginType === 0) {
this.loginType = 1
} else if (this.loginType === 1) {
this.loginType = 0
}
// 清空表单
this.form.resetFields()
},
/**
* 验证手机号
* @param rule
@@ -232,7 +256,7 @@ export default {
let that = this
let loginParams = {}
that.loginBtn = true
that.form.validateFields(['username', 'password', 'inputCode', 'captcha', 'rememberMe'], { force: true }, (err, values) => {
that.form.validateFields(['username', 'password', 'inputCode', 'captcha', 'rememberMe'], {force: true}, (err, values) => {
if (!err) {
loginParams.remember_me = values.rememberMe
// 手机登录验证码
@@ -252,11 +276,18 @@ export default {
//登录
console.log(this.isVerificationCodeLogin)
let httpFunction = null
if (this.isVerificationCodeLogin) {
httpFunction = that.PhoneLogin
} else {
httpFunction = that.Login
const actionCollect = {
commonLogin: [that.Login,that.CompanyAdminLogin],
phoneLogin:[that.PhoneLogin,that.CompanyAdminPhoneLogin]
}
// userType 用户类型 0 是普通用户 1是企业管理员 loginType true 是短信登录 false 是账号登录
let actionFunc = function (userType,loginType){
return loginType ? actionCollect.phoneLogin[userType] : actionCollect.commonLogin[userType]
}
httpFunction = actionFunc(this.loginType,this.isVerificationCodeLogin)
httpFunction(loginParams).then((response) => {
if (response.message === 'updatePassword') {
this.$notification['error']({
@@ -289,7 +320,7 @@ export default {
getCaptcha(e) {
e.preventDefault()
let that = this
this.form.validateFields(['username'], { force: true }, (err, values) => {
this.form.validateFields(['username'], {force: true}, (err, values) => {
if (!values.username) {
that.cmsFailed('请输入手机号')
} else if (!err) {
@@ -299,7 +330,11 @@ export default {
// 登录--1
smsParams.codeType = 1
let interval
getAction('/company/sendVerificationCode', smsParams)
let sendCodeUrl = {
0:'/company/sendVerificationCode',
1:'/companyManager/sendVerificationCode'
}
getAction(sendCodeUrl[this.loginType], smsParams)
.then(res => {
// 验证码获取不成功就不倒计时
if (!res.success) {
@@ -317,12 +352,12 @@ export default {
}
setTimeout(hide, 500)
}).catch(err => {
setTimeout(hide, 1)
clearInterval(interval)
that.state.time = 60
that.state.smsSendBtn = false
this.requestFailed(err)
})
setTimeout(hide, 1)
clearInterval(interval)
that.state.time = 60
that.state.smsSendBtn = false
this.requestFailed(err)
})
}
}
)
@@ -335,11 +370,11 @@ export default {
},
// 忘记密码
forgetPassword() {
this.$router.push({ name: 'alteration' })
this.$router.push({name: 'alteration'})
},
handleChangeCheckCode() {
this.currdatetime = new Date().getTime()
getAction(`/sys/randomImage/${ this.currdatetime }`).then(res => {
getAction(`/sys/randomImage/${this.currdatetime}`).then(res => {
if (res.success) {
this.randCodeImage = res.result
this.requestCodeSuccess = true
@@ -362,11 +397,11 @@ export default {
loginSuccess() {
// this.$router.push({ path: "/dashboard/analysis" }).catch((res)=>{})
// 进入首页
this.$router.push({ path: '/' }).catch(() => {
this.$router.push({path: '/'}).catch(() => {
})
this.$notification.success({
message: '欢迎',
description: `${ timeFix() },欢迎回来`
description: `${timeFix()},欢迎回来`
})
},
cmsFailed(err) {
@@ -527,4 +562,17 @@ export default {
height: 60px;
border: 1px solid #E6E3E3;
}
// 企业管理员登录
.center {
display: flex;
justify-content: center;
align-items: center;
}
.company-admin-login {
user-select: none;
cursor: pointer;
color: #BFBFBF;
}
</style>