初始化配置以及首页修改
This commit is contained in:
parent
667500bd63
commit
95504af9d2
|
|
@ -1,10 +1,10 @@
|
|||
# 页面标题
|
||||
VUE_APP_TITLE = 博诺思管理系统
|
||||
VUE_APP_TITLE = 华东实名制管理系统
|
||||
|
||||
# 开发环境配置
|
||||
ENV = 'development'
|
||||
|
||||
# 博诺思管理系统/开发环境
|
||||
# 华东实名制管理系统/开发环境
|
||||
VUE_APP_BASE_API = '/dev-api'
|
||||
|
||||
# 路由懒加载
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# 页面标题
|
||||
VUE_APP_TITLE = 博诺思管理系统
|
||||
VUE_APP_TITLE = 华东实名制管理系统
|
||||
|
||||
# 生产环境配置
|
||||
ENV = 'production'
|
||||
|
||||
# 博诺思管理系统/生产环境
|
||||
# 华东实名制管理系统/生产环境
|
||||
VUE_APP_BASE_API = '/prod-api'
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
# 页面标题
|
||||
VUE_APP_TITLE = 博诺思管理系统
|
||||
VUE_APP_TITLE = 华东实名制管理系统
|
||||
|
||||
NODE_ENV = production
|
||||
|
||||
# 测试环境配置
|
||||
ENV = 'staging'
|
||||
|
||||
# 博诺思管理系统/测试环境
|
||||
# 华东实名制管理系统/测试环境
|
||||
VUE_APP_BASE_API = '/stage-api'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "bonus",
|
||||
"version": "3.6.4",
|
||||
"description": "博诺思管理系统",
|
||||
"description": "华东实名制管理系统",
|
||||
"author": "博诺思",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
|
|
@ -1,10 +1,17 @@
|
|||
<template>
|
||||
<div class="title-tip">
|
||||
<div class="left">
|
||||
<div />
|
||||
<div>
|
||||
{{ titleText }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<!-- 给个默认插槽 用于后续放置一些按钮等内容 -->
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
@ -20,13 +27,22 @@ export default {
|
|||
|
||||
<style lang="scss" scoped>
|
||||
.title-tip {
|
||||
margin-bottom: 8px;
|
||||
padding: 12px 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
border-bottom: 1px solid #e6e6e6;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.title-tip .left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 16px;
|
||||
|
||||
& div:first-child {
|
||||
width: 4px;
|
||||
height: 16px;
|
||||
width: 6px;
|
||||
height: 18px;
|
||||
margin-right: 8px;
|
||||
background-color: #409eff;
|
||||
border-radius: 2px;
|
||||
|
|
|
|||
|
|
@ -1,29 +1,59 @@
|
|||
<template>
|
||||
<div :class="classObj" class="app-wrapper" :style="{'--current-color': theme}">
|
||||
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside"/>
|
||||
<sidebar v-if="!sidebar.hide" class="sidebar-container"/>
|
||||
<div :class="{hasTagsView:needTagsView,sidebarHide:sidebar.hide}" class="main-container">
|
||||
<div :class="{'fixed-header':fixedHeader}">
|
||||
<navbar/>
|
||||
<tags-view v-if="needTagsView"/>
|
||||
<div
|
||||
:class="classObj"
|
||||
class="app-wrapper"
|
||||
:style="{ '--current-color': theme }"
|
||||
>
|
||||
<div
|
||||
v-if="device === 'mobile' && sidebar.opened"
|
||||
class="drawer-bg"
|
||||
@click="handleClickOutside"
|
||||
/>
|
||||
<sidebar v-if="!sidebar.hide" class="sidebar-container" />
|
||||
<div
|
||||
:class="{ hasTagsView: needTagsView, sidebarHide: sidebar.hide }"
|
||||
class="main-container"
|
||||
>
|
||||
<div :class="{ 'fixed-header': fixedHeader }">
|
||||
<navbar />
|
||||
<tags-view v-if="needTagsView" />
|
||||
</div>
|
||||
<app-main/>
|
||||
<app-main />
|
||||
<right-panel>
|
||||
<settings/>
|
||||
<settings />
|
||||
</right-panel>
|
||||
</div>
|
||||
<el-dialog :title="title" :visible.sync="showChangePasswordDialog" width="30%" :close-on-click-modal="false"
|
||||
<el-dialog
|
||||
:title="title"
|
||||
:visible.sync="showChangePasswordDialog"
|
||||
width="30%"
|
||||
:close-on-click-modal="false"
|
||||
:show-close="false"
|
||||
>
|
||||
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
|
||||
<el-form-item label="旧密码" prop="oldPassword">
|
||||
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password/>
|
||||
<el-input
|
||||
v-model="user.oldPassword"
|
||||
placeholder="请输入旧密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password/>
|
||||
<el-input
|
||||
v-model="user.newPassword"
|
||||
placeholder="请输入新密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input v-model="user.confirmPassword" placeholder="请确认新密码" type="password" show-password/>
|
||||
<el-input
|
||||
v-model="user.confirmPassword"
|
||||
placeholder="请确认新密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
|
|
@ -43,7 +73,7 @@ import variables from '@/assets/styles/variables.scss'
|
|||
import { validateNewPassword } from '@/utils/validate'
|
||||
import { updateUserPwd, checkPasswordStatus } from '@/api/system/user'
|
||||
import { handleNoWarningLog } from '@/api/system/log'
|
||||
import {MessageBox} from "element-ui";
|
||||
import { MessageBox } from 'element-ui'
|
||||
|
||||
export default {
|
||||
name: 'Layout',
|
||||
|
|
@ -61,27 +91,42 @@ export default {
|
|||
user: {
|
||||
oldPassword: undefined,
|
||||
newPassword: undefined,
|
||||
confirmPassword: undefined
|
||||
confirmPassword: undefined,
|
||||
},
|
||||
// 表单校验规则
|
||||
rules: {
|
||||
oldPassword: [
|
||||
{ required: true, message: '旧密码不能为空', trigger: 'blur' }
|
||||
{
|
||||
required: true,
|
||||
message: '旧密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
newPassword: [
|
||||
{ required: true, message: '新密码不能为空', trigger: 'blur' },
|
||||
{ validator: validateNewPassword, trigger: 'blur' }
|
||||
{
|
||||
required: true,
|
||||
message: '新密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{ validator: validateNewPassword, trigger: 'blur' },
|
||||
],
|
||||
confirmPassword: [
|
||||
{ required: true, message: '确认密码不能为空', trigger: 'blur' },
|
||||
{ required: true, validator: equalToPassword, trigger: 'blur' }
|
||||
]
|
||||
{
|
||||
required: true,
|
||||
message: '确认密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: equalToPassword,
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
socket: null,
|
||||
wsUrl: JSON.parse(localStorage.getItem('systemConfig')).webSocketurl,//'ws://localhost:18082/ws', // WebSocket 端点
|
||||
wsUrl: '', //'ws://localhost:18082/ws', // WebSocket 端点
|
||||
isConnected: false, // 连接状态
|
||||
reconnectInterval: 5000 // 自动重连时间间隔(毫秒
|
||||
|
||||
reconnectInterval: 5000, // 自动重连时间间隔(毫秒
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
@ -90,41 +135,41 @@ export default {
|
|||
RightPanel,
|
||||
Settings,
|
||||
Sidebar,
|
||||
TagsView
|
||||
TagsView,
|
||||
},
|
||||
mixins: [ResizeMixin],
|
||||
computed: {
|
||||
...mapState({
|
||||
theme: state => state.settings.theme,
|
||||
sideTheme: state => state.settings.sideTheme,
|
||||
sidebar: state => state.app.sidebar,
|
||||
device: state => state.app.device,
|
||||
needTagsView: state => state.settings.tagsView,
|
||||
fixedHeader: state => state.settings.fixedHeader,
|
||||
roles: state => state.user.roles,
|
||||
theme: (state) => state.settings.theme,
|
||||
sideTheme: (state) => state.settings.sideTheme,
|
||||
sidebar: (state) => state.app.sidebar,
|
||||
device: (state) => state.app.device,
|
||||
needTagsView: (state) => state.settings.tagsView,
|
||||
fixedHeader: (state) => state.settings.fixedHeader,
|
||||
roles: (state) => state.user.roles,
|
||||
}),
|
||||
classObj() {
|
||||
return {
|
||||
hideSidebar: !this.sidebar.opened,
|
||||
openSidebar: this.sidebar.opened,
|
||||
withoutAnimation: this.sidebar.withoutAnimation,
|
||||
mobile: this.device === 'mobile'
|
||||
mobile: this.device === 'mobile',
|
||||
}
|
||||
},
|
||||
variables() {
|
||||
return variables
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.checkPasswordStatus()
|
||||
if (this.roles.includes("audit") || this.roles.includes("systemAdmin")) {
|
||||
this.connectWebSocket();
|
||||
}
|
||||
// if (this.roles.includes("audit") || this.roles.includes("systemAdmin")) {
|
||||
// this.connectWebSocket();
|
||||
// }
|
||||
this.handleNoWarningLog()
|
||||
},
|
||||
methods: {
|
||||
checkPasswordStatus() {
|
||||
checkPasswordStatus().then(response => {
|
||||
checkPasswordStatus().then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.showChangePasswordDialog = response.data
|
||||
this.title = response.msg
|
||||
|
|
@ -132,19 +177,22 @@ export default {
|
|||
})
|
||||
},
|
||||
|
||||
handleNoWarningLog(){
|
||||
handleNoWarningLog().then(response => {
|
||||
|
||||
})
|
||||
handleNoWarningLog() {
|
||||
handleNoWarningLog().then((response) => {})
|
||||
},
|
||||
|
||||
handleClickOutside() {
|
||||
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
||||
this.$store.dispatch('app/closeSideBar', {
|
||||
withoutAnimation: false,
|
||||
})
|
||||
},
|
||||
submit() {
|
||||
this.$refs['form'].validate(valid => {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
|
||||
updateUserPwd(
|
||||
this.user.oldPassword,
|
||||
this.user.newPassword,
|
||||
).then((response) => {
|
||||
this.showChangePasswordDialog = false
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
})
|
||||
|
|
@ -153,95 +201,90 @@ export default {
|
|||
},
|
||||
close() {
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
location.href = '/index';
|
||||
location.href = '/index'
|
||||
})
|
||||
},
|
||||
|
||||
// 连接 WebSocket
|
||||
connectWebSocket() {
|
||||
if (this.socket) {
|
||||
console.log("WebSocket 已连接");
|
||||
return;
|
||||
console.log('WebSocket 已连接')
|
||||
return
|
||||
}
|
||||
console.log("WebSocket URL:{}",this.wsUrl)
|
||||
this.socket = new WebSocket(this.wsUrl);
|
||||
console.log('WebSocket URL:{}', this.wsUrl)
|
||||
this.socket = new WebSocket(this.wsUrl)
|
||||
|
||||
// 监听 WebSocket 连接成功事件
|
||||
this.socket.onopen = () => {
|
||||
console.log("WebSocket 连接成功");
|
||||
this.isConnected = true;
|
||||
};
|
||||
console.log('WebSocket 连接成功')
|
||||
this.isConnected = true
|
||||
}
|
||||
|
||||
// 接收消息
|
||||
this.socket.onmessage = (event) => {
|
||||
console.log("收到消息:", event.data);
|
||||
const warning = JSON.parse(event.data);
|
||||
this.handleWarning(warning);
|
||||
};
|
||||
console.log('收到消息:', event.data)
|
||||
const warning = JSON.parse(event.data)
|
||||
this.handleWarning(warning)
|
||||
}
|
||||
|
||||
// 监听连接关闭事件
|
||||
this.socket.onclose = () => {
|
||||
console.log("WebSocket 连接已关闭");
|
||||
this.isConnected = false;
|
||||
this.socket = null;
|
||||
console.log('WebSocket 连接已关闭')
|
||||
this.isConnected = false
|
||||
this.socket = null
|
||||
// 自动重连
|
||||
this.reconnectWebSocket();
|
||||
};
|
||||
this.reconnectWebSocket()
|
||||
}
|
||||
|
||||
// 监听连接错误事件
|
||||
this.socket.onerror = (error) => {
|
||||
console.error("WebSocket 错误:", error);
|
||||
this.isConnected = false;
|
||||
this.socket = null;
|
||||
console.error('WebSocket 错误:', error)
|
||||
this.isConnected = false
|
||||
this.socket = null
|
||||
// 自动重连
|
||||
this.reconnectWebSocket();
|
||||
};
|
||||
this.reconnectWebSocket()
|
||||
}
|
||||
},
|
||||
|
||||
// 自动重连 WebSocket
|
||||
reconnectWebSocket() {
|
||||
console.log("尝试重新连接 WebSocket...");
|
||||
console.log('尝试重新连接 WebSocket...')
|
||||
setTimeout(() => {
|
||||
this.connectWebSocket();
|
||||
}, this.reconnectInterval);
|
||||
this.connectWebSocket()
|
||||
}, this.reconnectInterval)
|
||||
},
|
||||
|
||||
// 处理告警信息并显示弹窗
|
||||
handleWarning(warning) {
|
||||
console.log(warning)
|
||||
let warningContent = '';
|
||||
let warningContent = ''
|
||||
|
||||
if (warning.operaUserName) {
|
||||
warningContent += `<p><strong>操作人:</strong>${warning.operaUserName}</p>`;
|
||||
warningContent += `<p><strong>操作人:</strong>${warning.operaUserName}</p>`
|
||||
}
|
||||
|
||||
if (warning.warningEvent) {
|
||||
warningContent += `<p><strong>事件:</strong>${warning.warningEvent}</p>`;
|
||||
warningContent += `<p><strong>事件:</strong>${warning.warningEvent}</p>`
|
||||
}
|
||||
|
||||
if (warning.warningIp) {
|
||||
warningContent += `<p><strong>IP:</strong>${warning.warningIp}</p>`;
|
||||
warningContent += `<p><strong>IP:</strong>${warning.warningIp}</p>`
|
||||
}
|
||||
|
||||
if (warning.operaTime) {
|
||||
warningContent += `<p><strong>时间:</strong>${warning.operaTime}</p>`;
|
||||
warningContent += `<p><strong>时间:</strong>${warning.operaTime}</p>`
|
||||
}
|
||||
|
||||
if (warningContent) {
|
||||
MessageBox.alert(
|
||||
warningContent,
|
||||
'告警通知',
|
||||
{
|
||||
MessageBox.alert(warningContent, '告警通知', {
|
||||
dangerouslyUseHTMLString: true,
|
||||
confirmButtonText: '确认',
|
||||
customClass: 'custom-message-box',
|
||||
callback: () => {
|
||||
this.notifyBackend(warning.warningId);
|
||||
this.notifyBackend(warning.warningId)
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// 通知后端告警已处理
|
||||
|
|
@ -249,25 +292,24 @@ export default {
|
|||
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
||||
const message = {
|
||||
warningId,
|
||||
};
|
||||
this.socket.send(warningId);
|
||||
console.log(`已通知后端处理告警: ${warningId}`);
|
||||
}
|
||||
this.socket.send(warningId)
|
||||
console.log(`已通知后端处理告警: ${warningId}`)
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 页面销毁时关闭 WebSocket 连接
|
||||
if (this.socket) {
|
||||
this.socket.close();
|
||||
}
|
||||
|
||||
this.socket.close()
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "~@/assets/styles/mixin.scss";
|
||||
@import "~@/assets/styles/variables.scss";
|
||||
@import '~@/assets/styles/mixin.scss';
|
||||
@import '~@/assets/styles/variables.scss';
|
||||
|
||||
.app-wrapper {
|
||||
@include clearfix;
|
||||
|
|
|
|||
|
|
@ -37,29 +37,29 @@ export const constantRoutes = [
|
|||
children: [
|
||||
{
|
||||
path: '/redirect/:path(.*)',
|
||||
component: () => import('@/views/redirect')
|
||||
}
|
||||
]
|
||||
component: () => import('@/views/redirect'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
component: () => import('@/views/login1'),
|
||||
hidden: true
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
component: () => import('@/views/register1'),
|
||||
hidden: true
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
component: () => import('@/views/error/404'),
|
||||
hidden: true
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '/401',
|
||||
component: () => import('@/views/error/401'),
|
||||
hidden: true
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
|
|
@ -68,11 +68,11 @@ export const constantRoutes = [
|
|||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
component: () => import('@/views/index'),
|
||||
component: () => import('@/views/home-index/index'),
|
||||
name: 'Index',
|
||||
meta: { title: '首页', icon: 'dashboard', affix: true }
|
||||
}
|
||||
]
|
||||
meta: { title: '首页', icon: 'dashboard', affix: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
|
|
@ -84,10 +84,10 @@ export const constantRoutes = [
|
|||
path: 'profile',
|
||||
component: () => import('@/views/system/user/profile/index'),
|
||||
name: 'Profile',
|
||||
meta: { title: '个人中心', icon: 'user' }
|
||||
}
|
||||
]
|
||||
}
|
||||
meta: { title: '个人中心', icon: 'user' },
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
// 动态路由,基于用户权限动态去加载
|
||||
|
|
@ -102,9 +102,9 @@ export const dynamicRoutes = [
|
|||
path: 'role/:userId(\\d+)',
|
||||
component: () => import('@/views/system/user/authRole'),
|
||||
name: 'AuthRole',
|
||||
meta: { title: '分配角色', activeMenu: '/system/user' }
|
||||
}
|
||||
]
|
||||
meta: { title: '分配角色', activeMenu: '/system/user' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/system/role-auth',
|
||||
|
|
@ -116,9 +116,9 @@ export const dynamicRoutes = [
|
|||
path: 'user/:roleId(\\d+)',
|
||||
component: () => import('@/views/system/role/authUser'),
|
||||
name: 'AuthUser',
|
||||
meta: { title: '分配用户', activeMenu: '/system/role' }
|
||||
}
|
||||
]
|
||||
meta: { title: '分配用户', activeMenu: '/system/role' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/system/dict-data',
|
||||
|
|
@ -130,9 +130,9 @@ export const dynamicRoutes = [
|
|||
path: 'index/:dictId(\\d+)',
|
||||
component: () => import('@/views/system/dict/data'),
|
||||
name: 'Data',
|
||||
meta: { title: '字典数据', activeMenu: '/system/dict' }
|
||||
}
|
||||
]
|
||||
meta: { title: '字典数据', activeMenu: '/system/dict' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/face/face-data',
|
||||
|
|
@ -145,9 +145,9 @@ export const dynamicRoutes = [
|
|||
path: 'index/:groupCode',
|
||||
component: () => import('@/views/face/faceData/index'),
|
||||
name: 'Data',
|
||||
meta: { title: '人脸库', activeMenu: '/face/face-data' }
|
||||
}
|
||||
]
|
||||
meta: { title: '人脸库', activeMenu: '/face/face-data' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/monitor/job-log',
|
||||
|
|
@ -159,9 +159,9 @@ export const dynamicRoutes = [
|
|||
path: 'index/:jobId(\\d+)',
|
||||
component: () => import('@/views/monitor/job/log'),
|
||||
name: 'JobLog',
|
||||
meta: { title: '调度日志', activeMenu: '/monitor/job' }
|
||||
}
|
||||
]
|
||||
meta: { title: '调度日志', activeMenu: '/monitor/job' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/tool/gen-edit',
|
||||
|
|
@ -173,10 +173,10 @@ export const dynamicRoutes = [
|
|||
path: 'index/:tableId(\\d+)',
|
||||
component: () => import('@/views/tool/gen/editTable'),
|
||||
name: 'GenEdit',
|
||||
meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
|
||||
}
|
||||
]
|
||||
}
|
||||
meta: { title: '修改生成配置', activeMenu: '/tool/gen' },
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
// 防止连续点击多次路由报错
|
||||
|
|
@ -184,15 +184,15 @@ let routerPush = Router.prototype.push
|
|||
let routerReplace = Router.prototype.replace
|
||||
// push
|
||||
Router.prototype.push = function push(location) {
|
||||
return routerPush.call(this, location).catch(err => err)
|
||||
return routerPush.call(this, location).catch((err) => err)
|
||||
}
|
||||
// replace
|
||||
Router.prototype.replace = function push(location) {
|
||||
return routerReplace.call(this, location).catch(err => err)
|
||||
return routerReplace.call(this, location).catch((err) => err)
|
||||
}
|
||||
|
||||
export default new Router({
|
||||
mode: 'history', // 去掉url中的#
|
||||
scrollBehavior: () => ({ y: 0 }),
|
||||
routes: constantRoutes
|
||||
routes: constantRoutes,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
<template>
|
||||
<!-- 首页 数据概览 -->
|
||||
<div class="data-overview">
|
||||
<el-card>
|
||||
<h3>数据概览</h3>
|
||||
<div class="data-overview-content">
|
||||
<!-- 公司选择 -->
|
||||
<el-radio-group v-model="selectCompany" size="medium">
|
||||
<el-radio-button
|
||||
:key="item"
|
||||
:label="item"
|
||||
v-for="item in companyList"
|
||||
/>
|
||||
</el-radio-group>
|
||||
|
||||
<div class="data-overview-time">
|
||||
<div>
|
||||
数据更新时间:12:15:00
|
||||
<i
|
||||
class="el-icon-refresh"
|
||||
style="cursor: pointer; font-size: 18px"
|
||||
>
|
||||
</i>
|
||||
</div>
|
||||
<div class="user-help" @click="onHandleCheckOften">
|
||||
<i class="el-icon-s-help"> </i>
|
||||
<span> 常用功能 </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'DataOverview',
|
||||
data() {
|
||||
return {
|
||||
selectCompany: '全部',
|
||||
companyList: ['全部', '输一', '输二', '输三', '输四'],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onHandleCheckOften() {
|
||||
this.$emit('handleCheckOften')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
h3 {
|
||||
font-weight: bold;
|
||||
letter-spacing: 1px;
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 20px;
|
||||
}
|
||||
.data-overview-content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.data-overview-time,
|
||||
.user-help {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.user-help {
|
||||
margin-left: 40px;
|
||||
flex-direction: column;
|
||||
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transform: translateY(-15px);
|
||||
color: #409eff;
|
||||
|
||||
.el-icon-s-help {
|
||||
margin-bottom: 5px;
|
||||
font-size: 30px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<template>
|
||||
<!-- 常用功能 -->
|
||||
<div class="often-use">
|
||||
<el-card>
|
||||
<div>
|
||||
<TitleTip :titleText="'常用功能'">
|
||||
<i class="el-icon-setting" @click="onHandleSetting" />
|
||||
</TitleTip>
|
||||
</div>
|
||||
<div class="often-user-content">
|
||||
<div
|
||||
:key="item.name"
|
||||
class="often-user-item"
|
||||
v-for="item in oftenUseList"
|
||||
>
|
||||
<i :class="item.icon"> </i>
|
||||
<span> {{ item.name }} </span>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'OftenUse',
|
||||
data() {
|
||||
return {
|
||||
oftenUseList: [
|
||||
{
|
||||
name: '考勤统计',
|
||||
icon: 'el-icon-s-help',
|
||||
},
|
||||
{
|
||||
name: '人员库',
|
||||
icon: 'el-icon-s-help',
|
||||
},
|
||||
{
|
||||
name: '用户管理',
|
||||
icon: 'el-icon-s-help',
|
||||
},
|
||||
{
|
||||
name: '工资册审核',
|
||||
icon: 'el-icon-s-help',
|
||||
},
|
||||
{
|
||||
name: '分包合同管理',
|
||||
icon: 'el-icon-s-help',
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 打开配置页面
|
||||
onHandleSetting() {},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.often-use {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.often-user-content {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(10, 1fr);
|
||||
gap: 10px;
|
||||
|
||||
.often-user-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
cursor: pointer;
|
||||
|
||||
& i {
|
||||
margin-bottom: 10px;
|
||||
text-align: center;
|
||||
font-size: 28px;
|
||||
}
|
||||
& span {
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
font-family: 'PingFang SC';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.el-icon-setting {
|
||||
font-size: 26px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<template>
|
||||
<!-- 首页 -->
|
||||
<div class="app-container">
|
||||
<!-- 数据概览 -->
|
||||
<DataOverview @handleCheckOften="handleCheckOften" />
|
||||
<!-- 常用功能 -->
|
||||
|
||||
<el-collapse-transition>
|
||||
<OftenUse v-show="showOftenUse" />
|
||||
</el-collapse-transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DataOverview from './components/dataOverview.vue'
|
||||
import OftenUse from './components/oftenUse.vue'
|
||||
export default {
|
||||
components: {
|
||||
DataOverview,
|
||||
OftenUse,
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 常用功能按钮切换
|
||||
handleCheckOften() {
|
||||
console.log('常用功能')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
@ -1,7 +1,12 @@
|
|||
<template>
|
||||
<div class="login">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
||||
<h3 class="title">博诺思后台管理系统</h3>
|
||||
<el-form
|
||||
ref="loginForm"
|
||||
:model="loginForm"
|
||||
:rules="loginRules"
|
||||
class="login-form"
|
||||
>
|
||||
<h3 class="title">华东实名制管理系统</h3>
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
|
|
@ -9,7 +14,11 @@
|
|||
auto-complete="off"
|
||||
placeholder="账号"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="user"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
|
|
@ -20,7 +29,11 @@
|
|||
placeholder="密码"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="password"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code" v-if="captchaEnabled">
|
||||
|
|
@ -31,128 +44,175 @@
|
|||
style="width: 63%"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="validCode"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
<div class="login-code">
|
||||
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
||||
<img
|
||||
:src="codeUrl"
|
||||
@click="getCode"
|
||||
class="login-code-img"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
||||
<el-form-item style="width:100%;">
|
||||
<el-checkbox
|
||||
v-model="loginForm.rememberMe"
|
||||
style="margin: 0px 0px 25px 0px"
|
||||
>记住密码</el-checkbox
|
||||
>
|
||||
<el-form-item style="width: 100%">
|
||||
<el-button
|
||||
:loading="loading"
|
||||
size="medium"
|
||||
type="primary"
|
||||
style="width:100%;"
|
||||
style="width: 100%"
|
||||
@click.native.prevent="handleLogin"
|
||||
>
|
||||
<span v-if="!loading">登 录</span>
|
||||
<span v-else>登 录 中...</span>
|
||||
</el-button>
|
||||
<div style="float: right;" v-if="register">
|
||||
<router-link class="link-type" :to="'/register'">立即注册</router-link>
|
||||
<div style="float: right" v-if="register">
|
||||
<router-link class="link-type" :to="'/register'"
|
||||
>立即注册</router-link
|
||||
>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 底部 -->
|
||||
<div class="el-login-footer">
|
||||
<!-- <div class="el-login-footer">
|
||||
<span>Copyright © 2018-2024 bonus.vip All Rights Reserved.</span>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCodeImg } from "@/api/login";
|
||||
import Cookies from "js-cookie";
|
||||
import { getCodeImg } from '@/api/login'
|
||||
import Cookies from 'js-cookie'
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
|
||||
export default {
|
||||
name: "Login",
|
||||
name: 'Login',
|
||||
data() {
|
||||
return {
|
||||
codeUrl: "",
|
||||
codeUrl: '',
|
||||
loginForm: {
|
||||
username: "",
|
||||
password: "",
|
||||
username: '',
|
||||
password: '',
|
||||
rememberMe: false,
|
||||
code: "",
|
||||
uuid: ""
|
||||
code: '',
|
||||
uuid: '',
|
||||
},
|
||||
loginRules: {
|
||||
username: [
|
||||
{ required: true, trigger: "blur", message: "请输入您的账号" }
|
||||
{
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
message: '请输入您的账号',
|
||||
},
|
||||
],
|
||||
password: [
|
||||
{ required: true, trigger: "blur", message: "请输入您的密码" }
|
||||
{
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
message: '请输入您的密码',
|
||||
},
|
||||
],
|
||||
code: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'change',
|
||||
message: '请输入验证码',
|
||||
},
|
||||
],
|
||||
code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
||||
},
|
||||
loading: false,
|
||||
// 验证码开关
|
||||
captchaEnabled: true,
|
||||
// 注册开关
|
||||
register: false,
|
||||
redirect: undefined
|
||||
};
|
||||
redirect: undefined,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
$route: {
|
||||
handler: function(route) {
|
||||
this.redirect = route.query && route.query.redirect;
|
||||
handler: function (route) {
|
||||
this.redirect = route.query && route.query.redirect
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getCode();
|
||||
this.getCookie();
|
||||
this.getCode()
|
||||
this.getCookie()
|
||||
},
|
||||
methods: {
|
||||
getCode() {
|
||||
getCodeImg().then(res => {
|
||||
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
|
||||
getCodeImg().then((res) => {
|
||||
this.captchaEnabled =
|
||||
res.captchaEnabled === undefined ? true : res.captchaEnabled
|
||||
if (this.captchaEnabled) {
|
||||
this.codeUrl = "data:image/gif;base64," + res.img;
|
||||
this.loginForm.uuid = res.uuid;
|
||||
this.codeUrl = 'data:image/gif;base64,' + res.img
|
||||
this.loginForm.uuid = res.uuid
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
getCookie() {
|
||||
const username = Cookies.get("username");
|
||||
const password = Cookies.get("password");
|
||||
const username = Cookies.get('username')
|
||||
const password = Cookies.get('password')
|
||||
const rememberMe = Cookies.get('rememberMe')
|
||||
this.loginForm = {
|
||||
username: username === undefined ? this.loginForm.username : username,
|
||||
password: password === undefined ? this.loginForm.password : decrypt(password),
|
||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
||||
};
|
||||
username:
|
||||
username === undefined ? this.loginForm.username : username,
|
||||
password:
|
||||
password === undefined
|
||||
? this.loginForm.password
|
||||
: decrypt(password),
|
||||
rememberMe:
|
||||
rememberMe === undefined ? false : Boolean(rememberMe),
|
||||
}
|
||||
},
|
||||
handleLogin() {
|
||||
this.$refs.loginForm.validate(valid => {
|
||||
this.$refs.loginForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true;
|
||||
this.loading = true
|
||||
if (this.loginForm.rememberMe) {
|
||||
Cookies.set("username", this.loginForm.username, { expires: 30 });
|
||||
Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
|
||||
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
|
||||
Cookies.set('username', this.loginForm.username, {
|
||||
expires: 30,
|
||||
})
|
||||
Cookies.set(
|
||||
'password',
|
||||
encrypt(this.loginForm.password),
|
||||
{ expires: 30 },
|
||||
)
|
||||
Cookies.set('rememberMe', this.loginForm.rememberMe, {
|
||||
expires: 30,
|
||||
})
|
||||
} else {
|
||||
Cookies.remove("username");
|
||||
Cookies.remove("password");
|
||||
Cookies.remove('rememberMe');
|
||||
Cookies.remove('username')
|
||||
Cookies.remove('password')
|
||||
Cookies.remove('rememberMe')
|
||||
}
|
||||
this.$store.dispatch("Login", this.loginForm).then(() => {
|
||||
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
this.$store
|
||||
.dispatch('Login', this.loginForm)
|
||||
.then(() => {
|
||||
this.$router
|
||||
.push({ path: this.redirect || '/' })
|
||||
.catch(() => {})
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false
|
||||
if (this.captchaEnabled) {
|
||||
this.getCode();
|
||||
this.getCode()
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss">
|
||||
|
|
@ -161,7 +221,7 @@ export default {
|
|||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
background-image: url("../assets/images/login-background.jpg");
|
||||
background-image: url('../assets/images/login-background.jpg');
|
||||
background-size: cover;
|
||||
}
|
||||
.title {
|
||||
|
|
|
|||
|
|
@ -2,17 +2,34 @@
|
|||
<div class="container">
|
||||
<div class="login">
|
||||
<div class="login-form">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
||||
<h3 class="title">博诺思后台管理系统</h3>
|
||||
<el-form
|
||||
ref="loginForm"
|
||||
:model="loginForm"
|
||||
:rules="loginRules"
|
||||
class="login-form"
|
||||
>
|
||||
<h3 class="title">华东实名制管理系统</h3>
|
||||
<template v-if="loginMethod === 'password'">
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
type="text"
|
||||
auto-complete="off"
|
||||
:placeholder="`用户名${config.loginConfig.phonePassword ? '/手机号' : ''}${config.loginConfig.emailPassword ? '/邮箱' : ''}`"
|
||||
:placeholder="`用户名${
|
||||
config.loginConfig.phonePassword
|
||||
? '/手机号'
|
||||
: ''
|
||||
}${
|
||||
config.loginConfig.emailPassword
|
||||
? '/邮箱'
|
||||
: ''
|
||||
}`"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon"/>
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="user"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
|
|
@ -23,7 +40,11 @@
|
|||
placeholder="密码"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon"/>
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="password"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code" v-if="captchaEnabled">
|
||||
|
|
@ -34,25 +55,48 @@
|
|||
style="width: 63%"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon"/>
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="validCode"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
<div class="login-code">
|
||||
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
||||
<img
|
||||
:src="codeUrl"
|
||||
@click="getCode"
|
||||
class="login-code-img"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="isAdmin" prop="verificationCode">
|
||||
<el-input v-model="loginForm.verificationCode" placeholder="请输入验证码">
|
||||
<el-input
|
||||
v-model="loginForm.verificationCode"
|
||||
placeholder="请输入验证码"
|
||||
>
|
||||
<template slot="append">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="sendAdminCode"
|
||||
:disabled="isSendingCode || captchaEnabled?!loginForm.code:false"
|
||||
:disabled="
|
||||
isSendingCode || captchaEnabled
|
||||
? !loginForm.code
|
||||
: false
|
||||
"
|
||||
class="send-code-button"
|
||||
>
|
||||
{{ countdown === 0 ? '获取验证码' : `${countdown}s` }}
|
||||
{{
|
||||
countdown === 0
|
||||
? '获取验证码'
|
||||
: `${countdown}s`
|
||||
}}
|
||||
</el-button>
|
||||
</template>
|
||||
<svg-icon slot="prefix" icon-class="message" class="el-input__icon input-icon"/>
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="message"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
|
@ -62,9 +106,17 @@
|
|||
v-model="loginForm.mobile"
|
||||
type="text"
|
||||
auto-complete="off"
|
||||
:placeholder="`${config.loginConfig.phoneCode ? '手机号' : '/'}${config.loginConfig.emailCode ? '邮箱' : ''}`"
|
||||
:placeholder="`${
|
||||
config.loginConfig.phoneCode
|
||||
? '手机号'
|
||||
: '/'
|
||||
}${config.loginConfig.emailCode ? '邮箱' : ''}`"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon"/>
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="user"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code" v-if="captchaEnabled">
|
||||
|
|
@ -75,73 +127,120 @@
|
|||
style="width: 63%"
|
||||
@keyup.enter.native="handleLogin"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon"/>
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="validCode"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
<div class="login-code">
|
||||
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
||||
<img
|
||||
:src="codeUrl"
|
||||
@click="getCode"
|
||||
class="login-code-img"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item prop="verificationCode">
|
||||
<el-input v-model="loginForm.verificationCode" placeholder="请输入验证码">
|
||||
<el-input
|
||||
v-model="loginForm.verificationCode"
|
||||
placeholder="请输入验证码"
|
||||
>
|
||||
<template slot="append">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="sendCode"
|
||||
:disabled="isSendingCode || captchaEnabled?!loginForm.code:false"
|
||||
:disabled="
|
||||
isSendingCode || captchaEnabled
|
||||
? !loginForm.code
|
||||
: false
|
||||
"
|
||||
class="send-code-button"
|
||||
>
|
||||
{{ countdown === 0 ? '获取验证码' : `${countdown}s` }}
|
||||
{{
|
||||
countdown === 0
|
||||
? '获取验证码'
|
||||
: `${countdown}s`
|
||||
}}
|
||||
</el-button>
|
||||
</template>
|
||||
<svg-icon slot="prefix" icon-class="message" class="el-input__icon input-icon"/>
|
||||
<svg-icon
|
||||
slot="prefix"
|
||||
icon-class="message"
|
||||
class="el-input__icon input-icon"
|
||||
/>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<div class="login-form-center">
|
||||
<el-link v-if="config.loginConfig.emailCode ||config.loginConfig.phoneCode " @click="toggleLoginMethod">
|
||||
{{ loginMethod === 'password' ? '短信登录' : '密码登录' }}
|
||||
<el-link
|
||||
v-if="
|
||||
config.loginConfig.emailCode ||
|
||||
config.loginConfig.phoneCode
|
||||
"
|
||||
@click="toggleLoginMethod"
|
||||
>
|
||||
{{
|
||||
loginMethod === 'password'
|
||||
? '短信登录'
|
||||
: '密码登录'
|
||||
}}
|
||||
</el-link>
|
||||
<router-link v-if="config.registersConfig.emailRegisters || config.registersConfig.phoneRegisters" to="/register">
|
||||
<router-link
|
||||
v-if="
|
||||
config.registersConfig.emailRegisters ||
|
||||
config.registersConfig.phoneRegisters
|
||||
"
|
||||
to="/register"
|
||||
>
|
||||
<el-link>注册账号</el-link>
|
||||
</router-link>
|
||||
<el-checkbox v-model="loginForm.rememberMe">记住密码</el-checkbox>
|
||||
<el-checkbox v-model="loginForm.rememberMe"
|
||||
>记住密码</el-checkbox
|
||||
>
|
||||
</div>
|
||||
<el-form-item style="width: 100%;">
|
||||
<el-button v-if="!isAdmin"
|
||||
<el-form-item style="width: 100%">
|
||||
<el-button
|
||||
v-if="!isAdmin"
|
||||
:loading="loading"
|
||||
size="medium"
|
||||
type="primary"
|
||||
style="width: 100%;"
|
||||
@click="loginMethod === 'password' ?IsAdmin():handleLogin()"
|
||||
style="width: 100%"
|
||||
@click="
|
||||
loginMethod === 'password'
|
||||
? IsAdmin()
|
||||
: handleLogin()
|
||||
"
|
||||
>
|
||||
<span v-if="!loading">登 录</span>
|
||||
<span v-else>登 录 中...</span>
|
||||
</el-button>
|
||||
<el-button v-if="isAdmin"
|
||||
<el-button
|
||||
v-if="isAdmin"
|
||||
:loading="loading"
|
||||
size="medium"
|
||||
type="primary"
|
||||
style="width: 100%;"
|
||||
style="width: 100%"
|
||||
@click="handleLogin()"
|
||||
>
|
||||
<span v-if="!loading">登 录</span>
|
||||
<span v-else>登 录 中...</span>
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<!-- <el-form-item>
|
||||
<div class="login-divider">第三方登录</div>
|
||||
<div class="login-icons">
|
||||
<div class="login-icon">
|
||||
<img :src="dingding" alt="Weibo">
|
||||
<img :src="dingding" alt="Weibo" />
|
||||
</div>
|
||||
<div class="login-icon">
|
||||
<img :src="wx" alt="WeChat">
|
||||
<img :src="wx" alt="WeChat" />
|
||||
</div>
|
||||
<div class="login-icon">
|
||||
<img :src="qq" alt="QQ">
|
||||
<img :src="qq" alt="QQ" />
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -175,16 +274,46 @@ export default {
|
|||
uuid: '',
|
||||
loginType: '',
|
||||
phoneUuid: '',
|
||||
mobileCodeType: 'LOGIN'
|
||||
mobileCodeType: 'LOGIN',
|
||||
},
|
||||
passwordLoginRules: {
|
||||
username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }],
|
||||
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }],
|
||||
code: [{ required: true, trigger: 'change', message: '请输入验证码' }]
|
||||
username: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
message: '请输入您的账号',
|
||||
},
|
||||
],
|
||||
password: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
message: '请输入您的密码',
|
||||
},
|
||||
],
|
||||
code: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'change',
|
||||
message: '请输入验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
mobileLoginRules: {
|
||||
mobile: [{ required: true, trigger: 'blur', message: '请输入您的手机号' }],
|
||||
verificationCode: [{ required: true, trigger: 'blur', message: '请输入验证码' }]
|
||||
mobile: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
message: '请输入您的手机号',
|
||||
},
|
||||
],
|
||||
verificationCode: [
|
||||
{
|
||||
required: true,
|
||||
trigger: 'blur',
|
||||
message: '请输入验证码',
|
||||
},
|
||||
],
|
||||
},
|
||||
loading: false,
|
||||
captchaEnabled: true,
|
||||
|
|
@ -193,32 +322,39 @@ export default {
|
|||
countdown: 0,
|
||||
loginMethod: 'password', // 'password' or 'mobile'
|
||||
supportsPhoneLogin: false,
|
||||
supportsEmailLogin: false
|
||||
supportsEmailLogin: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
config() {
|
||||
return JSON.parse(localStorage.getItem('systemConfig')) || {loginConfig:{
|
||||
return (
|
||||
JSON.parse(localStorage.getItem('systemConfig')) || {
|
||||
loginConfig: {
|
||||
phonePassword: true,
|
||||
emailPassword: true,
|
||||
phoneCode: false,
|
||||
emailCode: false
|
||||
},registersConfig: {
|
||||
emailCode: false,
|
||||
},
|
||||
registersConfig: {
|
||||
phoneRegisters: true,
|
||||
emailRegisters: true
|
||||
}}; // 获取 JSON 对象
|
||||
emailRegisters: true,
|
||||
},
|
||||
}
|
||||
) // 获取 JSON 对象
|
||||
},
|
||||
loginRules() {
|
||||
return this.loginMethod === 'password' ? this.passwordLoginRules : this.mobileLoginRules
|
||||
}
|
||||
return this.loginMethod === 'password'
|
||||
? this.passwordLoginRules
|
||||
: this.mobileLoginRules
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
$route: {
|
||||
handler(route) {
|
||||
this.redirect = route.query && route.query.redirect
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getCode()
|
||||
|
|
@ -226,8 +362,9 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
getCode() {
|
||||
getCodeImg().then(res => {
|
||||
this.captchaEnabled = res.captchaEnabled !== undefined ? res.captchaEnabled : true
|
||||
getCodeImg().then((res) => {
|
||||
this.captchaEnabled =
|
||||
res.captchaEnabled !== undefined ? res.captchaEnabled : true
|
||||
if (this.captchaEnabled) {
|
||||
this.codeUrl = 'data:image/gif;base64,' + res.img
|
||||
this.loginForm.uuid = res.uuid
|
||||
|
|
@ -243,33 +380,52 @@ export default {
|
|||
this.loginForm.rememberMe = rememberMe === 'true'
|
||||
},
|
||||
handleLogin() {
|
||||
this.$refs.loginForm.validate(valid => {
|
||||
this.$refs.loginForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
if (this.loginForm.rememberMe) {
|
||||
Cookies.set('username', this.loginForm.username, { expires: 30 })
|
||||
Cookies.set('password', encrypt(this.loginForm.password), { expires: 30 })
|
||||
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 })
|
||||
Cookies.set('username', this.loginForm.username, {
|
||||
expires: 30,
|
||||
})
|
||||
Cookies.set(
|
||||
'password',
|
||||
encrypt(this.loginForm.password),
|
||||
{ expires: 30 },
|
||||
)
|
||||
Cookies.set('rememberMe', this.loginForm.rememberMe, {
|
||||
expires: 30,
|
||||
})
|
||||
} else {
|
||||
Cookies.remove('username')
|
||||
Cookies.remove('password')
|
||||
Cookies.remove('rememberMe')
|
||||
}
|
||||
this.loginForm.loginMethod = this.loginMethod
|
||||
this.$store.dispatch('Login', this.loginForm)
|
||||
.then(res => {
|
||||
this.$store
|
||||
.dispatch('Login', this.loginForm)
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
if (res.code===200){
|
||||
if (res.isLogin){
|
||||
this.$modal.confirm('账号已在其他地方登录是否继续登录!!!!').then(function() {
|
||||
return this.$router.push({ path: this.redirect || '/' });
|
||||
}).then(() => {
|
||||
this.loading = false
|
||||
}).catch(() => {
|
||||
if (res.code === 200) {
|
||||
if (res.isLogin) {
|
||||
this.$modal
|
||||
.confirm(
|
||||
'账号已在其他地方登录是否继续登录!!!!',
|
||||
)
|
||||
.then(function () {
|
||||
return this.$router.push({
|
||||
path: this.redirect || '/',
|
||||
})
|
||||
})
|
||||
.then(() => {
|
||||
this.loading = false
|
||||
})
|
||||
}else {
|
||||
this.$router.push({ path: this.redirect || '/' });
|
||||
.catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
} else {
|
||||
this.$router.push({
|
||||
path: this.redirect || '/',
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -282,29 +438,38 @@ export default {
|
|||
},
|
||||
IsAdmin() {
|
||||
this.loginForm.loginMethod = this.loginMethod
|
||||
this.$store.dispatch('IsAdmin', this.loginForm).then(res => {
|
||||
this.$store.dispatch('IsAdmin', this.loginForm).then((res) => {
|
||||
if (res.data) {
|
||||
this.isAdmin = res.data
|
||||
this.$message.success('检测到您是超级管理账号,需进行手机检验')
|
||||
this.$message.success(
|
||||
'检测到您是超级管理账号,需进行手机检验',
|
||||
)
|
||||
} else {
|
||||
this.handleLogin()
|
||||
}
|
||||
})
|
||||
},
|
||||
isLogin() {
|
||||
this.$refs.loginForm.validate(valid => {
|
||||
this.$refs.loginForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
let that = this
|
||||
this.loginForm.loginMethod = this.loginMethod
|
||||
this.$store.dispatch('IsLogin', this.loginForm)
|
||||
.then(res => {
|
||||
this.$store
|
||||
.dispatch('IsLogin', this.loginForm)
|
||||
.then((res) => {
|
||||
if (res.data) {
|
||||
this.$modal.confirm('账号已在其他地方登录是否继续登录!!!!').then(function() {
|
||||
this.$modal
|
||||
.confirm(
|
||||
'账号已在其他地方登录是否继续登录!!!!',
|
||||
)
|
||||
.then(function () {
|
||||
return that.handleLogin()
|
||||
}).then(() => {
|
||||
})
|
||||
.then(() => {
|
||||
this.loading = false
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
} else {
|
||||
|
|
@ -320,8 +485,9 @@ export default {
|
|||
},
|
||||
sendAdminCode() {
|
||||
this.loginForm.mobile = this.loginForm.username
|
||||
this.$store.dispatch('GetPhoneCode', this.loginForm)
|
||||
.then(res => {
|
||||
this.$store
|
||||
.dispatch('GetPhoneCode', this.loginForm)
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.loginForm.phoneUuid = res.data
|
||||
this.$message.success('验证码发送成功')
|
||||
|
|
@ -353,10 +519,17 @@ export default {
|
|||
return
|
||||
}
|
||||
if (!this.loginForm.mobile) {
|
||||
this.$message.error('请先填写'+this.config.loginConfig.phoneCode ? '手机号' : '/' + this.config.loginConfig.emailCode ? '邮箱' : '')
|
||||
this.$message.error(
|
||||
'请先填写' + this.config.loginConfig.phoneCode
|
||||
? '手机号'
|
||||
: '/' + this.config.loginConfig.emailCode
|
||||
? '邮箱'
|
||||
: '',
|
||||
)
|
||||
return
|
||||
}
|
||||
this.$store.dispatch('GetPhoneCode', this.loginForm)
|
||||
this.$store
|
||||
.dispatch('GetPhoneCode', this.loginForm)
|
||||
.then(() => {
|
||||
this.isSendingCode = true
|
||||
this.countdown = 60
|
||||
|
|
@ -380,7 +553,8 @@ export default {
|
|||
})
|
||||
},
|
||||
toggleLoginMethod() {
|
||||
this.loginMethod = this.loginMethod === 'password' ? 'mobile' : 'password'
|
||||
this.loginMethod =
|
||||
this.loginMethod === 'password' ? 'mobile' : 'password'
|
||||
this.loginForm.username = ''
|
||||
this.loginForm.password = ''
|
||||
this.loginForm.code = ''
|
||||
|
|
@ -388,8 +562,8 @@ export default {
|
|||
this.loginForm.loginMethod = ''
|
||||
this.isAdmin = false
|
||||
this.getCode()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -399,7 +573,7 @@ export default {
|
|||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
background-image: url("../assets/images/bg.png");
|
||||
background-image: url('../assets/images/bg.png');
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
|
|
@ -499,11 +673,11 @@ export default {
|
|||
}
|
||||
|
||||
.login-divider:not(:empty)::before {
|
||||
margin-right: .25em;
|
||||
margin-right: 0.25em;
|
||||
}
|
||||
|
||||
.login-divider:not(:empty)::after {
|
||||
margin-left: .25em;
|
||||
margin-left: 0.25em;
|
||||
}
|
||||
|
||||
.login-icons {
|
||||
|
|
|
|||
Loading…
Reference in New Issue