菜单栏

This commit is contained in:
姚亚男
2021-09-16 17:24:48 +08:00
parent b51f393843
commit 2a66edab06
18 changed files with 63 additions and 1216 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
@primary-color: #1890ff;
@primary-color: #069F99;
/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */
/* stylelint-disable no-duplicate-selectors */
/* stylelint-disable */
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

+7 -6
View File
@@ -368,19 +368,17 @@
/*美化弹出Tab样式*/
.ant-tabs-nav-container {
margin-top: 4px;
margin: 0 !important;
}
/* 修改 ant-tabs 样式 */
.tab-layout-tabs.ant-tabs {
border-bottom: 1px solid #ccc;
border-left: 1px solid #ccc;
background-color: white;
padding: 0 20px;
height: 40px !important;
.ant-tabs-bar {
margin: 4px 0 0;
border: none;
margin: 0;
}
}
@@ -419,7 +417,10 @@
border-bottom: 1px solid transparent !important;
}
.ant-tabs-tab-active {
border-color: @primary-color!important;
border-color: #069F99 !important;
color: #069F99;
background: rgba(6,159,153,0.1) !important;
border-radius: 0 !important;
}
}
+12 -7
View File
@@ -79,7 +79,7 @@
@scrollBarSize: 10px;
ul.ant-menu {
background: #069F99;
/* 定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
&::-webkit-scrollbar {
width: @scrollBarSize;
@@ -137,7 +137,6 @@
}
}
}
}
/* update_end author:sunjianlei date:20190509 for: 修改侧边导航栏滚动条的样式 */
@@ -149,25 +148,31 @@
& > .ant-menu-item:first-child {
background-color: transparent;
& > a, & > a:hover {
color: rgba(0, 0, 0, 0.65);
& > a {
color: #fff !important;
}
& > a:hover {
color: #fff !important;
font-weight: 600;
}
&.ant-menu-item-selected {
& > a, & > a:hover {
color: @primary-color;
color: #fff !important;
font-weight: 600;
}
}
}
&.ant-menu-dark > .ant-menu-item:first-child {
& > a, & > a:hover {
color: rgba(255, 255, 255, 0.65);
color:#fff !important;
}
&.ant-menu-item-selected {
& > a, & > a:hover {
color: rgba(255, 255, 255, 1);
color: #fff !important;
}
}
}
+8 -22
View File
@@ -4,32 +4,15 @@
v-if="!headerBarFixed"
:class="[fixedHeader && 'ant-header-fixedHeader', sidebarOpened ? 'ant-header-side-opened' : 'ant-header-side-closed', ]"
:style="{ padding: '0' }">
<div v-if="mode === 'sidemenu'" class="header" :class="theme">
<a-icon
v-if="device==='mobile'"
class="trigger"
:type="collapsed ? 'menu-fold' : 'menu-unfold'"
@click="toggle"></a-icon>
<a-icon
v-else
class="trigger"
:type="collapsed ? 'menu-unfold' : 'menu-fold'"
@click="toggle"/>
<span v-if="device === 'desktop'">欢迎进入 Jero-Boot 平台</span>
<span v-else>Jero-Boot</span>
<user-menu :theme="theme"/>
</div>
<!-- 顶部导航栏模式 -->
<div v-else :class="['top-nav-header-index', theme]">
<div :class="['top-nav-header-index']">
<div class="header-index-wide">
<div class="header-index-left" :style="topMenuStyle.headerIndexLeft">
<logo class="top-nav-header" :show-title="device !== 'mobile'" :style="topMenuStyle.topNavHeader"/>
<logo class="top-nav-header" :show-title="device !== 'mobile'" title='标准所来款管理系统'/>
<div v-if="device !== 'mobile'" :style="topMenuStyle.topSmenuStyle">
<s-menu
mode="horizontal"
style='background: #069F99; text-align: right;'
:menu="menus"
:theme="theme"></s-menu>
</div>
@@ -39,7 +22,7 @@
:type="collapsed ? 'menu-fold' : 'menu-unfold'"
@click="toggle"></a-icon>
</div>
<user-menu class="header-index-right" :theme="theme" :style="topMenuStyle.headerIndexRight"/>
<user-menu class="header-index-right"/>
</div>
</div>
@@ -170,9 +153,12 @@
.layout {
.top-nav-header-index {
background: #069F99 !important;
.header-index-wide {
margin-left: 10px;
.header-index-left{
background: #069F99;
}
.ant-menu.ant-menu-horizontal {
height: @height;
+12 -1
View File
@@ -445,6 +445,17 @@
border: none;
height: 64px;
line-height: 64px;
a{
color: #fff;
}
a:hover{
font-weight: 600;
}
.ant-menu-item-selected {
a {
font-weight: 600;
}
}
}
.header-index-left {
@@ -452,7 +463,7 @@
display: flex;
.logo.top-nav-header {
width: 165px;
width: 250px;
height: 64px;
position: relative;
line-height: 64px;
-323
View File
@@ -1,323 +0,0 @@
<template>
<div class="setting-drawer">
<a-drawer
width="300"
placement="right"
:closable="false"
@close="onClose"
:visible="visible"
style="height: 100%;overflow: auto;"
>
<div class="setting-drawer-index-content">
<div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">整体风格设置</h3>
<div class="setting-drawer-index-blockChecbox">
<a-tooltip>
<template slot="title">
暗色菜单风格
</template>
<div class="setting-drawer-index-item" @click="handleMenuTheme('dark')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/LCkqqYNmvBEbokSDscrm.svg" alt="dark">
<div class="setting-drawer-index-selectIcon" v-if="navTheme === 'dark'">
<a-icon type="check"/>
</div>
</div>
</a-tooltip>
<a-tooltip>
<template slot="title">
亮色菜单风格
</template>
<div class="setting-drawer-index-item" @click="handleMenuTheme('light')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/jpRkZQMyYRryryPNtyIC.svg" alt="light">
<div class="setting-drawer-index-selectIcon" v-if="navTheme !== 'dark'">
<a-icon type="check"/>
</div>
</div>
</a-tooltip>
</div>
</div>
<div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">主题色</h3>
<div style="height: 20px">
<a-tooltip class="setting-drawer-theme-color-colorBlock" v-for="(item, index) in colorList" :key="index">
<template slot="title">
{{ item.key }}
</template>
<a-tag :color="item.color" @click="changeColor(item.color)">
<a-icon type="check" v-if="item.color === primaryColor"></a-icon>
</a-tag>
</a-tooltip>
</div>
</div>
<a-divider />
<div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">导航模式</h3>
<div class="setting-drawer-index-blockChecbox">
<a-tooltip>
<template slot="title">
侧边栏导航
</template>
<div class="setting-drawer-index-item" @click="handleLayout('sidemenu')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/JopDzEhOqwOjeNTXkoje.svg" alt="sidemenu">
<div class="setting-drawer-index-selectIcon" v-if="layoutMode === 'sidemenu'">
<a-icon type="check"/>
</div>
</div>
</a-tooltip>
<a-tooltip>
<template slot="title">
顶部栏导航
</template>
<div class="setting-drawer-index-item" @click="handleLayout('topmenu')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDNDBbriJhLwuqMoxcAr.svg" alt="topmenu">
<div class="setting-drawer-index-selectIcon" v-if="layoutMode !== 'sidemenu'">
<a-icon type="check"/>
</div>
</div>
</a-tooltip>
</div>
<div :style="{ marginTop: '24px' }">
<a-list :split="false">
<a-list-item>
<a-tooltip slot="actions">
<template slot="title">
该设定仅 [顶部栏导航] 时有效
</template>
<a-select size="small" style="width: 80px;" :defaultValue="contentWidth" @change="handleContentWidthChange">
<a-select-option value="Fixed">固定</a-select-option>
<a-select-option value="Fluid" v-if="layoutMode !== 'sidemenu'">流式</a-select-option>
</a-select>
</a-tooltip>
<a-list-item-meta>
<div slot="title">内容区域宽度</div>
</a-list-item-meta>
</a-list-item>
<a-list-item>
<a-switch slot="actions" size="small" :defaultChecked="fixedHeader" @change="handleFixedHeader" />
<a-list-item-meta>
<div slot="title">固定 Header</div>
</a-list-item-meta>
</a-list-item>
<a-list-item>
<a-switch slot="actions" size="small" :disabled="!fixedHeader" :defaultChecked="autoHideHeader" @change="handleFixedHeaderHidden" />
<a-list-item-meta>
<div slot="title" :style="{ textDecoration: !fixedHeader ? 'line-through' : 'unset' }">下滑时隐藏 Header</div>
</a-list-item-meta>
</a-list-item>
<a-list-item>
<a-switch slot="actions" size="small" :disabled="(layoutMode === 'topmenu')" :checked="dataFixSiderbar" @change="handleFixSiderbar" />
<a-list-item-meta>
<div slot="title" :style="{ textDecoration: layoutMode === 'topmenu' ? 'line-through' : 'unset' }">固定侧边菜单</div>
</a-list-item-meta>
</a-list-item>
</a-list>
</div>
</div>
<a-divider />
<div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">其他设置</h3>
<div>
<a-list :split="false">
<a-list-item>
<a-switch slot="actions" size="small" :defaultChecked="colorWeak" @change="onColorWeak" />
<a-list-item-meta>
<div slot="title">色弱模式</div>
</a-list-item-meta>
</a-list-item>
<a-list-item>
<a-switch slot="actions" size="small" :defaultChecked="multipage" @change="onMultipageWeak" />
<a-list-item-meta>
<div slot="title">多页签模式</div>
</a-list-item-meta>
</a-list-item>
</a-list>
</div>
</div>
<a-divider />
<div :style="{ marginBottom: '24px' }">
<a-alert type="warning">
<span slot="message">
配置栏只在开发环境用于预览生产环境不会展现请手动修改配置文件
<a href="https://github.com/sendya/ant-design-pro-vue/blob/master/src/defaultSettings.js" target="_blank">src/defaultSettings.js</a>
</span>
</a-alert>
</div>
</div>
<div class="setting-drawer-index-handle" @click="toggle" v-if="visible">
<!-- <a-icon type="setting" v-if="!visible"/>-->
<!-- <a-icon type="close" v-else/>-->
<a-icon type="close" />
</div>
</a-drawer>
</div>
</template>
<script>
import DetailList from '@/components/tools/DetailList'
import SettingItem from '@/components/setting/SettingItem'
import config from '@/defaultSettings'
import { updateTheme, updateColorWeak, colorList } from '@/components/tools/setting'
import { mixin, mixinDevice } from '@/utils/mixin.js'
import { triggerWindowResizeEvent } from '@/utils/util'
export default {
components: {
DetailList,
SettingItem
},
mixins: [mixin, mixinDevice],
data() {
return {
visible: false,
colorList,
dataFixSiderbar: false
}
},
mounted () {
// 当主题色不是默认色时,才进行主题编译
if (this.primaryColor !== config.primaryColor) {
updateTheme(this.primaryColor)
}
if (this.colorWeak !== config.colorWeak) {
updateColorWeak(this.colorWeak)
}
if (this.multipage !== config.multipage) {
this.$store.dispatch('ToggleMultipage', this.multipage)
}
},
methods: {
showDrawer() {
this.visible = true
},
onClose() {
this.visible = false
},
toggle() {
this.visible = !this.visible
},
onColorWeak (checked) {
this.$store.dispatch('ToggleWeak', checked)
updateColorWeak(checked)
},
onMultipageWeak (checked) {
this.$store.dispatch('ToggleMultipage', checked)
},
handleMenuTheme (theme) {
this.$store.dispatch('ToggleTheme', theme)
},
handleLayout (mode) {
this.$store.dispatch('ToggleLayoutMode', mode)
// 因为顶部菜单不能固定左侧菜单栏,所以强制关闭
this.handleFixSiderbar(false)
// 触发窗口resize事件
triggerWindowResizeEvent()
},
handleContentWidthChange (type) {
this.$store.dispatch('ToggleContentWidth', type)
},
changeColor (color) {
if (this.primaryColor !== color) {
this.$store.dispatch('ToggleColor', color)
updateTheme(color)
}
},
handleFixedHeader (fixed) {
this.$store.dispatch('ToggleFixedHeader', fixed)
},
handleFixedHeaderHidden (autoHidden) {
this.$store.dispatch('ToggleFixedHeaderHidden', autoHidden)
},
handleFixSiderbar (fixed) {
if (this.layoutMode === 'topmenu') {
fixed = false
}
this.dataFixSiderbar = fixed
this.$store.dispatch('ToggleFixSiderbar', fixed)
}
},
}
</script>
<style lang="less" scoped>
.setting-drawer-index-content {
.setting-drawer-index-blockChecbox {
display: flex;
.setting-drawer-index-item {
margin-right: 16px;
position: relative;
border-radius: 4px;
cursor: pointer;
img {
width: 48px;
}
.setting-drawer-index-selectIcon {
position: absolute;
top: 0;
right: 0;
width: 100%;
padding-top: 15px;
padding-left: 24px;
height: 100%;
color: #1890ff;
font-size: 14px;
font-weight: 700;
}
}
}
.setting-drawer-theme-color-colorBlock {
width: 20px;
height: 20px;
border-radius: 2px;
float: left;
cursor: pointer;
margin-right: 8px;
padding-left: 0px;
padding-right: 0px;
text-align: center;
color: #fff;
font-weight: 700;
i {
font-size: 14px;
}
}
}
.setting-drawer-index-handle {
position: absolute;
top: 240px;
background: #1890ff;
width: 48px;
height: 48px;
right: 300px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
pointer-events: auto;
z-index: 1001;
text-align: center;
font-size: 16px;
border-radius: 4px 0 0 4px;
i {
color: rgb(255, 255, 255);
font-size: 20px;
}
}
</style>
-38
View File
@@ -1,38 +0,0 @@
<template>
<div class="setting-drawer-index-item">
<h3 class="setting-drawer-index-title">{{ title }}</h3>
<slot></slot>
<a-divider v-if="divider"/>
</div>
</template>
<script>
export default {
name: "SettingItem",
props: {
title: {
type: String,
default: ''
},
divider: {
type: Boolean,
default: false
}
}
}
</script>
<style lang="less" scoped>
.setting-drawer-index-item {
margin-bottom: 24px;
.setting-drawer-index-title {
font-size: 14px;
color: rgba(0, 0, 0, .85);
line-height: 22px;
margin-bottom: 12px;
}
}
</style>
-162
View File
@@ -1,162 +0,0 @@
<template>
<a-modal
:title="currTitle"
:width="450"
:visible="visible"
:closable="false"
:maskClosable="closable">
<template slot="footer">
<a-button v-if="closable" @click="close">关闭</a-button>
<a-button type="primary" @click="departOk">确认</a-button>
</template>
<a-form>
<a-form-item
:labelCol="{span:4}"
:wrapperCol="{span:20}"
style="margin-bottom:10px"
:validate-status="validate_status">
<a-tooltip placement="topLeft" >
<template slot="title">
<span>您隶属于多部门请选择当前所在部门</span>
</template>
<a-avatar style="backgroundColor:#87d068" icon="gold" />
</a-tooltip>
<a-select v-model="departSelected" :class="{'valid-error':validate_status=='error'}" placeholder="请选择登录部门" style="margin-left:10px;width: 80%">
<a-icon slot="suffixIcon" type="gold" />
<a-select-option
v-for="d in departList"
:key="d.id"
:value="d.orgCode">
{{ d.departName }}
</a-select-option>
</a-select>
</a-form-item>
</a-form>
</a-modal>
</template>
<script>
import { getAction,putAction } from '@/api/manage'
import Vue from 'vue'
import store from '@/store/'
import { USER_INFO } from "@/store/mutation-types"
export default {
name: 'DepartSelect',
props:{
title:{
type:String,
default:"部门选择",
required:false
},
closable:{
type:Boolean,
default:false,
required:false
},
username:{
type:String,
default:"",
required:false
}
},
watch:{
username(val){
if(val){
this.loadDepartList()
}
}
},
data(){
return {
currTitle:this.title,
visible:false,
departList:[],
departSelected:"",
validate_status:"",
currDepartName:"",
}
},
created(){
//this.loadDepartList()
},
methods:{
loadDepartList(){
return new Promise(resolve => {
let url = "/sys/user/getCurrentUserDeparts"
this.currDepartName=''
getAction(url).then(res=>{
if(res.success){
let departs = res.result.list
let orgCode = res.result.orgCode
if(departs && departs.length>0){
for(let i of departs){
if(i.orgCode == orgCode){
this.currDepartName = i.departName
break
}
}
}
this.departSelected = orgCode
this.departList = departs
if(this.currDepartName){
this.currTitle ="部门切换(当前部门 : "+this.currDepartName+""
}
}
resolve()
})
})
},
close(){
this.departClear()
},
departOk(){
if(!this.departSelected){
this.validate_status='error'
return false
}
let obj = {
orgCode:this.departSelected,
username:this.username
}
putAction("/sys/selectDepart",obj).then(res=>{
if(res.success){
const userInfo = res.result.userInfo;
Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000);
store.commit('SET_INFO', userInfo);
//console.log("---切换组织机构---userInfo-------",store.getters.userInfo.orgCode);
this.departClear()
}
})
},
show(){
//如果组件传值username此处就不用loadDepartList了
this.loadDepartList().then(()=>{
this.visible=true
if(!this.departList || this.departList.length<=0){
this.$message.warning("您尚未设置部门信息!")
this.departClear()
}
})
},
departClear(){
this.departList=[]
this.departSelected=""
this.visible=false
this.validate_status=''
this.currDepartName=""
},
}
}
</script>
<style scoped>
.valid-error .ant-select-selection__placeholder{
color: #f5222d;
}
</style>
+1 -1
View File
@@ -68,7 +68,7 @@
</template>
<span @click="fetchNotice" class="header-notice">
<a-badge :count="msgTotal">
<a-icon style="font-size: 16px; padding: 4px" type="bell" />
<a-icon style="margin-right: 8px" type="bell" />通知消息
</a-badge>
</span>
<show-announcement ref="ShowAnnouncement" @ok="modalFormOk"></show-announcement>
-1
View File
@@ -43,7 +43,6 @@
line-height: @height !important;
box-shadow: none !important;
transition: background 300ms;
a {
color: white;
&:hover {
+8 -79
View File
@@ -1,39 +1,7 @@
<template>
<div class="user-wrapper" :class="theme">
<!-- update_begin author:zhaoxin date:20191129 for: 做头部菜单栏导航 -->
<!-- update-begin author:sunjianlei date:20191@20 for: 解决全局样式冲突的问题 -->
<span class="action" @click="showClick">
<a-icon type="search"></a-icon>
</span>
<!-- update-begin author:sunjianlei date:20200219 for: 菜单搜索改为动态组件在手机端呈现出弹出框 -->
<component :is="searchMenuComp" v-show="searchMenuVisible || isMobile()" class="borders" :visible="searchMenuVisible" title="搜索菜单" :footer="null" @cancel="searchMenuVisible=false">
<a-select
class="search-input"
showSearch
:showArrow="false"
placeholder="搜索菜单"
optionFilterProp="children"
:filterOption="filterOption"
:open="isMobile()?true:null"
:getPopupContainer="(node) => node.parentNode"
:style="isMobile()?{width: '100%',marginBottom:'50px'}:{}"
@change="searchMethods"
@blur="hiddenClick"
>
<a-select-option v-for="(site,index) in searchMenuOptions" :key="index" :value="site.id">{{site.meta.title}}</a-select-option>
</a-select>
</component>
<!-- update-end author:sunjianlei date:20200219 for: 菜单搜索改为动态组件在手机端呈现出弹出框 -->
<!-- update-end author:sunjianlei date:20191220 for: 解决全局样式冲突的问题 -->
<!-- update_end author:zhaoxin date:20191129 for: 做头部菜单栏导航 -->
<span class="action">
<a class="logout_title" target="_blank" href="http://doc.jeecg.com">
<a-icon type="question-circle-o"></a-icon>
</a>
</span>
<header-notice class="action"/>
<div class="user-wrapper">
<a-dropdown>
<span class="action action-full ant-dropdown-link user-dropdown-menu">
<span class="action action-full ant-dropdown-link user-dropdown-menu" style='color: #fff'>
<a-avatar class="avatar" size="small" :src="getAvatar()"/>
<span v-if="isDesktop()">欢迎您{{ nickname() }}</span>
</span>
@@ -44,58 +12,28 @@
<span>个人中心</span>
</router-link>
</a-menu-item>
<a-menu-item key="1">
<router-link :to="{ name: 'account-settings-base' }">
<a-icon type="setting"/>
<span>账户设置</span>
</router-link>
<a-menu-item key='1'>
<header-notice class="action"/>
</a-menu-item>
<a-menu-item key="3" @click="systemSetting">
<a-icon type="tool"/>
<span>系统设置</span>
</a-menu-item>
<a-menu-item key="4" @click="updatePassword">
<a-menu-item key="2" @click="updatePassword">
<a-icon type="setting"/>
<span>密码修改</span>
</a-menu-item>
<a-menu-item key="5" @click="updateCurrentDepart">
<a-icon type="cluster"/>
<span>切换部门</span>
</a-menu-item>
<a-menu-item key="6" @click="clearCache">
<a-icon type="sync"/>
<span>清理缓存</span>
</a-menu-item>
<!-- <a-menu-item key="2" disabled>
<a-icon type="setting"/>
<span>测试</span>
</a-menu-item>
<a-menu-divider/>
<a-menu-item key="3">
<a href="javascript:;" @click="handleLogout">
<a-icon type="logout"/>
<span>退出登录</span>
</a>
</a-menu-item>-->
</a-menu>
</a-dropdown>
<span class="action">
<span class="action" style='color: #fff'>
<a class="logout_title" href="javascript:;" @click="handleLogout">
<a-icon type="logout"/>
<span v-if="isDesktop()">&nbsp;退出登录</span>
<span v-if="isDesktop()">&nbsp;注销</span>
</a>
</span>
<user-password ref="userPassword"></user-password>
<depart-select ref="departSelect" :closable="true" title="部门切换"></depart-select>
<setting-drawer ref="settingDrawer" :closable="true" title="系统设置"></setting-drawer>
</div>
</template>
<script>
import HeaderNotice from './HeaderNotice'
import UserPassword from './UserPassword'
import SettingDrawer from "@/components/setting/SettingDrawer";
import DepartSelect from './DepartSelect'
import { mapActions, mapGetters,mapState } from 'vuex'
import { mixinDevice } from '@/utils/mixin.js'
import { getFileAccessHttpUrl,getAction } from "@/api/manage"
@@ -116,16 +54,7 @@
},
components: {
HeaderNotice,
UserPassword,
DepartSelect,
SettingDrawer
},
props: {
theme: {
type: String,
required: false,
default: 'dark'
}
UserPassword
},
/* update_begin author:zhaoxin date:20191129 for: 做头部菜单栏导航*/
created() {
+1 -1
View File
@@ -16,7 +16,7 @@
export default {
primaryColor: '#1890FF', // primary color of ant design
navTheme: 'light', // theme for nav menu
layout: 'sidemenu', // nav menu position: sidemenu or topmenu
layout: 'topmenu', // nav menu position: sidemenu or topmenu
contentWidth: 'Fixed', // layout of content: Fluid or Fixed, only works when layout is topmenu
fixedHeader: false, // sticky header
fixSiderbar: false, // sticky siderbar
+13
View File
@@ -131,6 +131,19 @@ const user = {
},
"name": "dashboard-analysis",
"id": "1"
},
{
"redirect": null,
"path": "",
"component": "",
"route": "1",
"meta": {
"icon": "home", // 菜单前图标
"componentName": "Analysis",
"title": "菜单2" // 菜单名称
},
"name": "dashboard-analysis",
"id": "2"
}
]
const authData = [];
-183
View File
@@ -1,183 +0,0 @@
<template>
<div class="main">
<a-form style="max-width: 500px; margin: 40px auto 0;" :form="form" @keyup.enter.native="nextStep">
<a-form-item>
<a-input
v-decorator="['username',validatorRules.username]"
size="large"
type="text"
autocomplete="false"
placeholder="请输入用户账号或手机号">
<a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/>
</a-input>
</a-form-item>
<a-row :gutter="0">
<a-col :span="14">
<a-form-item>
<a-input
v-decorator="['inputCode',validatorRules.inputCode]"
size="large"
type="text"
@change="inputCodeChange"
placeholder="请输入验证码">
<a-icon slot="prefix" v-if=" inputCodeContent==verifiedCode " type="smile"
:style="{ color: 'rgba(0,0,0,.25)' }"/>
<a-icon slot="prefix" v-else type="frown" :style="{ color: 'rgba(0,0,0,.25)' }"/>
</a-input>
</a-form-item>
</a-col>
<a-col :span="10" style="text-align: right">
<img v-if="requestCodeSuccess" style="margin-top: 2px;" :src="randCodeImage" @click="handleChangeCheckCode"/>
<img v-else style="margin-top: 2px;" src="../../../assets/checkcode.png" @click="handleChangeCheckCode"/>
</a-col>
</a-row>
<a-form-item :wrapperCol="{span: 19, offset: 5}">
<router-link style="float: left;line-height: 40px;" :to="{ name: 'login' }">使用已有账户登录</router-link>
<a-button type="primary" @click="nextStep">下一步</a-button>
</a-form-item>
</a-form>
</div>
</template>
<script>
import { getAction,postAction } from '@/api/manage'
import { checkOnlyUser } from '@/api/api'
export default {
name: "Step1",
data() {
return {
form: this.$form.createForm(this),
inputCodeContent: "",
inputCodeNull: true,
verifiedCode: "",
validatorRules: {
username: {rules: [{required: false}, {validator: this.validateInputUsername}]},
inputCode: {rules: [{required: true, message: '请输入验证码!'}]},
},
randCodeImage:'',
requestCodeSuccess:true,
currdatetime:''
}
},
created(){
this.handleChangeCheckCode();
},
methods: {
handleChangeCheckCode(){
this.currdatetime = new Date().getTime();
getAction(`/sys/randomImage/${this.currdatetime}`).then(res=>{
if(res.success){
this.randCodeImage = res.result
this.requestCodeSuccess=true
}else{
this.$message.error(res.message)
this.requestCodeSuccess=false
}
}).catch(()=>{
this.requestCodeSuccess=false
})
},
nextStep() {
let that = this
this.form.validateFields((err, values) => {
if (!err) {
let isPhone = false;
var params = {}
var reg = /^[1-9]\d*$|^0$/;
var username = values.username;
if (reg.test(username) == true) {
params.phone = username;
isPhone = true
} else {
params.username = username;
}
that.validateInputCode().then(()=>{
getAction("/sys/user/querySysUser", params).then((res) => {
if (res.success) {
var userList = {
username: res.result.username,
phone: res.result.phone,
isPhone: isPhone
};
setTimeout(function () {
that.$emit('nextStep', userList)
})
}
});
})
}
})
},
validateInputCode() {
return new Promise((resolve,reject)=>{
postAction("/sys/checkCaptcha",{
captcha:this.inputCodeContent,
checkKey:this.currdatetime
}).then(res=>{
if(res.success){
resolve();
}else{
this.$message.error(res.message)
reject();
}
});
})
},
inputCodeChange(e) {
this.inputCodeContent = e.target.value;
console.log(this.inputCodeContent)
if (!e.target.value || 0 == e.target.value) {
this.inputCodeNull = true
} else {
this.inputCodeContent = this.inputCodeContent.toLowerCase()
this.inputCodeNull = false
}
},
generateCode(value) {
this.verifiedCode = value.toLowerCase();
console.log(this.verifiedCode);
},
validateInputUsername(rule, value, callback) {
console.log(value);
var reg = /^[0-9]+.?[0-9]*/;
if (!value) {
callback("请输入用户名和手机号!");
}
//判断用户输入账号还是手机号码
if (reg.test(value)) {
var params = {
phone: value,
};
checkOnlyUser(params).then((res) => {
if (res.success) {
callback("用户名不存在!")
} else {
callback()
}
})
} else {
var params = {
username: value,
};
checkOnlyUser(params).then((res) => {
if (res.success) {
callback("用户名不存在!")
} else {
callback()
}
})
}
},
}
}
</script>
<style scoped>
</style>
-204
View File
@@ -1,204 +0,0 @@
<template>
<div>
<a-form :form="form" style="max-width: 500px; margin: 40px auto 0;" @keyup.enter.native="nextStep">
<a-form-item
label="手机"
:labelCol="{span: 5}"
:wrapperCol="{span: 16}"
style="text-align: left"
>
<a-input
type="text"
autocomplete="false"
v-decorator="['phone',{ rules: validatorRules.phone.rule}]"
placeholder="请输入手机号">
<a-icon slot="prefix" type="phone" :style="{ color: 'rgba(0,0,0,.25)'}"/>
</a-input>
<a-col :span="3"></a-col>
</a-form-item>
<a-form-item
label="验证码"
:labelCol="{span: 5}"
:wrapperCol="{span: 19}"
v-if="show">
<a-row :gutter="24">
<a-col :span="13">
<a-input
v-decorator="['captcha',validatorRules.captcha]"
type="text"
placeholder="手机短信验证码">
</a-input>
</a-col>
<a-col :span="8">
<a-button
tabindex="-1"
size="default"
:disabled="state.smsSendBtn"
@click.stop.prevent="getCaptcha"
v-text="!state.smsSendBtn && '获取验证码' || (state.time+' s')"></a-button>
</a-col>
</a-row>
</a-form-item>
<a-form-item :wrapperCol="{span: 19, offset: 5}">
<router-link style="float: left;line-height: 40px;" :to="{ name: 'login' }">使用已有账户登录</router-link>
<a-button type="primary" @click="nextStep" style="margin-left: 20px">下一步</a-button>
</a-form-item>
</a-form>
</div>
</template>
<script>
import {postAction} from '@/api/manage'
export default {
name: "Step2",
props: ['userList'],
data() {
return {
form: this.$form.createForm(this),
loading: false,
// accountName: this.userList.username,
dropList: "0",
captcha: "",
show: true,
state: {
time: 60,
smsSendBtn: false,
},
formLogin: {
captcha: "",
mobile: "",
},
validatorRules: {
captcha: {rule: [{required: true, message: '请输入短信验证码!'}, {validator: this.validateCaptcha}]},
phone: {rule: [{required: true, message: '请输入手机号码!'}, {validator: this.validatePhone}]},
},
}
},
computed: {
},
methods: {
nextStep() {
let that = this
that.loading = true
this.form.validateFields((err, values) => {
console.log(values);
if (!err) {
if (that.dropList == "0") {
if (values.captcha == undefined) {
this.cmsFailed("请输入短信验证码!");
} else {
var params = {}
params.phone = values.phone;
params.smscode = values.captcha;
postAction("/sys/user/phoneVerification", params).then((res) => {
if (res.success) {
console.log(res);
var userList = {
username: res.result.username,
phone: values.phone,
smscode: res.result.smscode
};
setTimeout(function () {
that.$emit('nextStep', userList)
}, 0)
} else {
this.cmsFailed(res.message);
}
})
}
}
}
})
},
getCaptcha(e) {
e.preventDefault();
let that = this;
let phone=that.form.getFieldValue("phone")
if(!phone){
this.cmsFailed("手机号不能为空!");
return;
}
this.state.smsSendBtn = true;
let interval = window.setInterval(() => {
if (that.state.time-- <= 0) {
that.state.time = 60;
that.state.smsSendBtn = false;
window.clearInterval(interval);
}
}, 1000);
const hide = this.$message.loading('验证码发送中..', 0);
let smsParams = {
mobile: phone,
smsmode: "2"
};
postAction("/sys/sms", smsParams).then(res => {
if (!res.success) {
setTimeout(hide, 1);
this.cmsFailed(res.message);
}
setTimeout(hide, 500);
})
},
cmsFailed(err) {
this.$notification['error']({
message: "验证错误",
description: err,
duration: 4,
});
},
handleChangeSelect(value) {
var that = this;
console.log(value);
if (value == 0) {
that.dropList = "0";
that.show = true;
} else {
that.dropList = "1";
that.show = false;
}
},
validatePhone(rule,value,callback){
if(value){
var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
if(!myreg.test(value)){
callback("请输入正确的手机号")
}else{
callback();
}
}else{
callback()
}
}
}
}
</script>
<style lang="less" scoped>
.stepFormText {
margin-bottom: 24px;
}
.ant-row{
margin-left: 0 !important;
margin-right: 0 !important;
}
.ant-col{
padding: 0 !important;
}
.ant-form-item-label,
.ant-form-item-control {
line-height: 22px;
}
.getCaptcha {
display: block;
width: 100%;
height: 40px;
}
</style>
-132
View File
@@ -1,132 +0,0 @@
<template>
<div>
<a-form :form="form" style="max-width: 500px; margin: 40px auto 0;">
<a-form-item
label="账号名"
:labelCol="{span: 5}"
:wrapperCol="{span: 19}"
>
<a-input
type="text"
autocomplete="false" :value="accountName" disabled>
</a-input>
</a-form-item>
<a-form-item
label="新密码"
:labelCol="{span: 5}"
:wrapperCol="{span: 19}"
class="stepFormText">
<a-input
v-decorator="['password',validatorRules.password]"
type="password"
autocomplete="false">
</a-input>
</a-form-item>
<a-form-item
label="确认密码"
:labelCol="{span: 5}"
:wrapperCol="{span: 19}"
class="stepFormText">
<a-input
v-decorator="['confirmPassword',validatorRules.confirmPassword]"
type="password"
autocomplete="false">
</a-input>
</a-form-item>
<a-form-item :wrapperCol="{span: 19, offset: 5}">
<a-button style="margin-left: 8px" @click="prevStep">上一步</a-button>
<a-button :loading="loading" type="primary" @click="nextStep" style="margin-left:20px">提交</a-button>
</a-form-item>
</a-form>
</div>
</template>
<script>
import { putAction,getAction } from '@/api/manage'
export default {
name: "Step3",
// components: {
// Result
// },
props: ['userList'],
data () {
return {
loading: false,
form: this.$form.createForm(this),
accountName: this.userList.username,
validatorRules: {
username: {rules: [{required: true, message: '用户名不能为空!'}]},
password: {
rules: [{
required: true,
pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{8,}$/,
message: '密码由8位数字、大小写字母和特殊符号组成!!'
}, {validator: this.handlePasswordLevel}]
},
confirmPassword: {rules: [{required: true, message: '密码不能为空!'}, {validator: this.handlePasswordCheck}]},
},
}
},
methods: {
nextStep () {
let that = this
that.loading = true
this.form.validateFields((err, values) => {
if ( !err ){
var params={}
params.username=this.userList.username;
params.password=values.password;
params.smscode=this.userList.smscode;
params.phone= this.userList.phone;
getAction("/sys/user/passwordChange", params).then((res) => {
if(res.success){
var userList = {
username: this.userList.username
}
console.log(userList);
setTimeout(function () {
that.$emit('nextStep', userList)
}, 1500)
}else{
this.passwordFailed(res.message);
that.loading = false
}
})
} else{
that.loading = false
}
})
},
prevStep () {
this.$emit('prevStep', this.userList)
},
handlePasswordCheck (rule, value, callback) {
let password = this.form.getFieldValue('password')
if (value && password && value.trim() !== password.trim()) {
callback(new Error('两次密码不一致'))
}
callback()
},
passwordFailed(err){
this.$notification[ 'error' ]({
message: "更改密码失败",
description:err,
duration: 4,
});
},
}
}
</script>
<style lang="less" scoped>
.stepFormText {
margin-bottom: 24px;
}
.ant-form-item-label,
.ant-form-item-control {
line-height: 22px;
}
</style>
-55
View File
@@ -1,55 +0,0 @@
<template>
<div>
<a-form style="margin: 40px auto 0;">
<result title="更改密码成功" :is-success="true">
<div class="toLogin">
<h3>将在<span>{{time}}</span>秒后返回登录页面.</h3>
</div>
</result>
</a-form>
</div>
</template>
<script>
import Result from '@/views/result/Result'
export default {
name: "Step4",
props:['userList'],
components: {
Result
},
data () {
return {
loading: false,
time: 0,
}
},
methods: {
countDown(){
let that = this;
that.time--;
}
},
mounted(){
let that = this;
that.time = 5;
setInterval(that.countDown, 1000);
},
watch: {
time: function (newVal,oldVal) {
if (newVal == 0) {
var params = {
username: this.userList.username
};
this.$router.push({name: 'login', params})
}
}
}
}
</script>
<style scoped>
.toLogin{
text-align: center;
}
</style>