Commit 1ccf618b by liimin

新增按钮权限

1 parent de4a8a9e
......@@ -7,7 +7,7 @@ VUE_APP_TITLE=tFIMS
VUE_APP_API=http://192.168.3.171:7300/mock/5d638b3b6fbe9a0ac59d872e/tFIMS
# 仓库地址
VUE_APP_REPO=https://github.com/d2-projects/d2-admin-start-kit
VUE_APP_REPO=
# 国际化配置
VUE_APP_I18N_LOCALE=zh-chs
......
......@@ -8,19 +8,19 @@
<title><%= VUE_APP_TITLE %></title>
<style>
html, body, #app { height: 100%; margin: 0px; padding: 0px; width: 100%; }
.d2-home { background-color: #303133; height: 100%; display: flex; flex-direction: column; }
.d2-home { background-color:#000; height: 100%; display: flex; flex-direction: column; }
.d2-home__main { user-select: none; width: 100%; flex-grow: 1; display: flex; justify-content: center; align-items: center; flex-direction: column; }
.d2-home__footer { width: 100%; flex-grow: 0; text-align: center; padding: 1em 0; }
.d2-home__footer > a { font-size: 12px; color: #ABABAB; text-decoration: none; }
.d2-home__footer > a { font-size: 12px; color: #fff; text-decoration: none; }
.d2-home__loading { height: 32px; width: 32px; margin-bottom: 20px; }
.d2-home__title { color: #FFF; font-size: 14px; margin-bottom: 10px; }
.d2-home__sub-title { color: #ABABAB; font-size: 12px; }
.d2-home__title { color: #FFF; font-size: 20px; margin-bottom: 10px; }
.d2-home__sub-title { color: #fff; font-size: 14px; }
</style>
<script>
<!-- <script>
var _hmt = _hmt || [];
var hmid = "1dfa88d0c8571eef2d383070cb3e5ca1";
(function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?" + hmid; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s);})();
</script>
</script> -->
</head>
<body>
<noscript>
......
......@@ -2,16 +2,16 @@ import request from './request'
const sysMonitorPath = 'fims.system.'
function getListApi (data) {
data.method = `${sysMonitorPath}list`
return request(data)
data.method = `${sysMonitorPath}list`
return request(data)
}
function reportApi (data) {
data.method = `${sysMonitorPath}report`
return request(data)
data.method = `${sysMonitorPath}report`
return request(data)
}
export {
getListApi,
reportApi
}
\ No newline at end of file
}
......@@ -25,5 +25,5 @@ export {
getListApi,
addApi,
editApi,
removeApi
}
\ No newline at end of file
removeApi
}
......@@ -7,4 +7,4 @@ const userMethods = {
export {
userMethods
}
\ No newline at end of file
}
......@@ -3,12 +3,13 @@
:size="size"
:type="type"
:loading="loading"
v-roles="['3']"
v-if="isInRole"
@click="handleClick"
>{{label}}</el-button>
</template>
<script>
import {mapGetters} from 'vuex'
export default {
name: 'AuthButton',
props: {
......@@ -32,16 +33,23 @@ export default {
type: Boolean,
default: false
},
perms: {
id: {
type: String,
default: null
}
},
computed: {
...mapGetters('d2admin/auth', ['curBtns'])
},
data () {
return {}
return {
isInRole:false
}
},
beforeCreate () {
this.$vrm.setRoles(['1', '2', '3'])
created () {
// this.$vrm.setRoles(this.btnIdAll)
const {action,operation} = this.curBtns
this.isInRole = [...action,...operation].find(obj=>obj.id===this.id||obj.label===this.label)
},
methods: {
handleClick: function () {
......
......@@ -27,11 +27,11 @@
<!-- 顶栏右侧 -->
<div class="d2-header-right" flex-box="0">
<!-- 如果你只想在开发环境显示这个按钮请添加 v-if="$env === 'development'" -->
<!-- <d2-header-search @click="handleSearchClick" v-if="$env === 'development'"/> -->
<!-- <d2-header-log v-if="$env === 'development'"/> -->
<d2-header-size/>
<d2-header-search @click="handleSearchClick"/>
<d2-header-log />
<!-- <d2-header-size /> -->
<d2-header-fullscreen/>
<!-- <d2-header-locales v-if="$env === 'development'"/> -->
<d2-header-locales />
<d2-header-theme/>
<d2-header-color/>
<d2-header-user/>
......
......@@ -76,42 +76,34 @@ util.deepFind = function (menus, id) {
return null
}
util.packRoutes = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aRouteInPermision = []
idsInPermision.forEach(obj => {
__aRouteInPermision.push(resources[obj.id])
})
return __aRouteInPermision
}
util.packAsideMenus = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aMenusInPermision = []
let __aSub = []
idsInPermision.forEach(obj => {
const { icon, path, meta } = resources[obj.id]
const { title, id, pid } = meta
if (obj.pid === '0') {
__aMenusInPermision.push({ title, icon, path, id, pid })
} else {
__aSub.push({ title, icon, path, id, pid })
}
})
let __parent = null
__aSub.forEach(obj => {
__parent = __aMenusInPermision.find(menu => menu.id === obj.pid)
if (__parent.children) {
__parent.children.push(obj)
} else {
__parent.children = [obj]
}
})
return __aMenusInPermision
/**
* 16进制颜色值 转换为 rgb
* @param {*} sColor 16进制颜色值
* @param {*} alpha 透明度
*/
util.colorToRgb = (sColor, alpha) => {
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
sColor = sColor.toLowerCase()
if (sColor && reg.test(sColor)) {
if (sColor.length === 4) {
var sColorNew = '#'
for (var i = 1; i < 4; i += 1) {
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1))
}
sColor = sColorNew
}
// 处理六位的颜色值
var sColorChange = []
for (let i = 1; i < 7; i += 2) {
sColorChange.push(parseInt('0x' + sColor.slice(i, i + 2)))
}
if (alpha || alpha === 0 || alpha === '0') {
return `rgba(${sColorChange.join(',')} ,${alpha})`
}
return `rgb(${sColorChange.join(',')})`
} else {
return sColor
}
}
export default util
......@@ -2,35 +2,65 @@
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 12:15:51
* @Last Modified time: 2019-08-28 23:05:36
*/
const permision = {
}
permision.packRoutes = function (resources, idsInPermision) {
const permision = {}
/**
* 打包如有与按钮
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packRoutesBtns = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aRouteInPermision = []
let __aRouteInPermision = [],
__oBtnInPermision = {},
// __aBtnIdAll=[],
__objResource = null
idsInPermision.forEach(obj => {
__aRouteInPermision.push(resources[obj.id])
__objResource = resources[obj.id]
if(__objResource){//直接能取到的为路由 (也可以在routes 中定标识变量)
__aRouteInPermision.push(resources[obj.id])//push 进 路由数组
}else{ //如果取不到 判断是否有父节点 并且父节点是否有auth属性 有 则视为按钮 (同样可以定义标识变量)
__objResource = resources[obj.pid]
if(__objResource && __objResource.auth && !__oBtnInPermision[obj.pid]){
__oBtnInPermision[obj.pid]=__objResource.auth
// __aBtnIdAll = __aBtnIdAll.concat([...__objResource.auth.action.map(o=>o.id),...__objResource.auth.operation.map(o=>o.id)])
}
}
})
return __aRouteInPermision
return {'route':__aRouteInPermision,'btn':__oBtnInPermision}
}
/**
* 打包菜单
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packAsideMenus = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aMenusInPermision = []
let __aSub = []
/**
* 第一次循环 分出一级菜单与所有子菜单
*/
idsInPermision.forEach(obj => {
const __oMenu = permision.format2Menu(resources[obj.id])
if (obj.pid === '0') {
if(!__oMenu){ //不存在 可能是 按钮 直接继续循环
return true
}
if (obj.pid === '0') {//取出1级菜单
__aMenusInPermision.push(__oMenu)
} else {
} else {//取出子菜单
__aSub.push(__oMenu)
}
})
/**
* 第二次循环所有子菜单 ,然后挂载到对应的一级菜单
*/
let __parent = null
__aSub.forEach(obj => {
__parent = __aMenusInPermision.find(menu => menu.id === obj.pid)
......@@ -47,6 +77,7 @@ permision.packAsideMenus = function (resources, idsInPermision) {
* 格式化菜单 封装成系统所需格式
*/
permision.format2Menu = function (oMenu) {
if(!oMenu) return null
const { icon, path, meta } = oMenu
const { title, id, pid } = meta
return { title, icon, path, id, pid }
......
......@@ -71,7 +71,8 @@ router.afterEach(to => {
store.dispatch('d2admin/page/open', to)
// 更改标题
util.title(to.meta.title)
// store.dispatch('d2admin/auth/set', to.meta.title)
// 保存当前页面meta信息
store.dispatch('d2admin/auth/setCurrentPageMeta', to.meta)
})
export default router
......@@ -28,6 +28,32 @@ export const home = {
},
component: _import('systemMonitor')
}
export const sys =[
// 系统 前端日志
{
path: 'log',
name: 'log',
meta: {
title: '前端日志',
auth: true
},
component: _import('system/log')
},
// 刷新页面 必须保留
{
path: 'refresh',
name: 'refresh',
hidden: true,
component: _import('system/function/refresh')
},
// 页面重定向 必须保留
{
path: 'redirect/:route*',
name: 'redirect',
hidden: true,
component: _import('system/function/redirect')
}
]
/**
* 所有需动态过滤的资源点
......@@ -67,11 +93,13 @@ export const resources = {
component: _import('demo/page2'),
auth: {
'operation': [{ // 列表操作
id: '1020101',
name: '查看'
id: '1020201',
pid:'10202',
label: '查看'
}, { //
id: '1020102',
name: '编辑'
id: '1020202',
pid:'10202',
label: '编辑'
}],
'action': [] // 按钮操作
}
......@@ -85,6 +113,18 @@ export const resources = {
id: '10203',
pid: '102'
},
auth: {
'operation': [{ // 列表操作
id: '1020301',
pid:'10203',
label: '查看'
}, { //
id: '1020302',
pid:'10203',
label: '编辑'
}],
'action': [] // 按钮操作
},
component: _import('demo/page3')
},
// '103': {
......@@ -110,7 +150,7 @@ export const resources = {
pid: '0'
},
component: _import('subSysManagement')
},
},
'104': {
path: 'trafficManagement',
icon: 'folder-o',
......@@ -122,7 +162,7 @@ export const resources = {
pid: '0'
},
component: _import('trafficManagement')
},
},
'105': {
path: 'bb',
icon: 'folder-o',
......@@ -132,8 +172,8 @@ export const resources = {
title: '单据管理',
id: '105',
pid: '0'
},
},
}
},
'10501': {
path: '/cc',
icon: 'folder-o',
......@@ -145,7 +185,7 @@ export const resources = {
pid: '105'
},
component: _import('trafficManagement')
},
},
'10502': {
path: '/dd',
icon: 'folder-o',
......@@ -157,9 +197,9 @@ export const resources = {
pid: '105'
},
component: _import('trafficManagement')
},
},
'107': {
path: 'page',
path: 'user',
icon: 'folder-o',
name: '用户管理',
meta: {
......
......@@ -2,15 +2,18 @@
* @Author: limin
* @Date: 2019-08-27 17:25:12
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 14:25:41
* @Last Modified time: 2019-08-29 00:53:59
*/
import util from '@/libs/util.js'
import router from '@/router'
import { resources as sources, home, frameInRoutes, errorPage } from '@/router/routes'
import { resources as sources, home, frameInRoutes,sys } from '@/router/routes'
export default {
namespaced: true,
state: {
source: ''
source:null,
meta:{},
btns:{},
btnIdAll:[]
},
getters: {
/**
......@@ -19,6 +22,34 @@ export default {
*/
source (state, dispatch) {
return state.source
},
/**
* @description 返回当前页面meta
* @param {Object} state state
*/
meta (state, dispatch) {
return state.meta
},
/**
* @description 当前角色拥有的所有按钮
* @param {Object} state state
*/
btns (state, dispatch) {
return state.btns
},
/**
* 返回当前页面的btn
* @param {*} state
*/
curBtns(state){
return state.btns[state.meta.id]
},
/**
* 返回当前页面的btn
* @param {*} state
*/
btnIdAll(state){
return state.btnIdAll
}
},
actions: {
......@@ -50,6 +81,17 @@ export default {
})
},
/**
* @description 保存当前角色权限资源
* @param {obj} source 需要保存的权限资源
*/
setCurrentPageMeta ({ state, commit, dispatch }, meta) {
return new Promise(async resolve => {
state.meta = meta
// end
resolve()
})
},
/**
* @description 从持久化数据加载资源数据
* @param {Object} context
*/
......@@ -61,13 +103,6 @@ export default {
path: 'source',
user: true
}, { root: true })
// console.log(document.querySelector('html').getAttribute('login')==='1');
// if( document.querySelector('html').getAttribute('login')==='1'){
// await dispatch('init')
// router.replace(router.currentRoute.path || '/')
// }
// 用户登录后从持久化数据加载一系列的设置
// await dispatch('d2admin/account/load', { root: true })
}
// end
resolve(state.source)
......@@ -79,33 +114,26 @@ export default {
*/
init ({ state, commit, dispatch }) {
return new Promise(async resolve => {
// 获取权限资源点
const __source = await dispatch('load')
// 过滤资源点 并动态添加到路由
const __aRoutesInPermisions = util.permision.packRoutes(sources, __source)
frameInRoutes[0].children = [home, ...__aRoutesInPermisions]
router.addRoutes(frameInRoutes)
// router.addRoutes(errorPage)
await commit('d2admin/page/init', frameInRoutes, { root: true })
// 过滤左侧菜单栏
const __aMenusInPermisions = util.permision.packAsideMenus(sources, __source)
const __oHome = util.permision.format2Menu(home)
await commit('d2admin/menu/asideSet', [__oHome, ...__aMenusInPermisions], { root: true })
// DB -> store 加载用户名
// await dispatch('d2admin/user/load', null, { root: true })
// // DB -> store 加载主题
// await dispatch('d2admin/theme/load', null, { root: true })
// // DB -> store 加载页面过渡效果设置
// await dispatch('d2admin/transition/load', null, { root: true })
// // DB -> store 持久化数据加载上次退出时的多页列表
// await dispatch('d2admin/page/openedLoad', null, { root: true })
// // DB -> store 持久化数据加载侧边栏折叠状态
// await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// // DB -> store 持久化数据加载全局尺寸
// await dispatch('d2admin/size/load', null, { root: true })
// 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true })
try {
// 获取权限资源点
const __source = await dispatch('load')
// 过滤资源点 并动态添加到路由
const { route,btn } = util.permision.packRoutesBtns(sources, __source)
frameInRoutes[0].children = [home, ...route,...sys]
router.addRoutes(frameInRoutes)
state.btns = btn
await commit('d2admin/page/init', frameInRoutes, { root: true })
const __aMenus = [util.permision.format2Menu(home), ...util.permision.packAsideMenus(sources, __source)]
// 过滤左侧菜单栏
await commit('d2admin/menu/asideSet', __aMenus, { root: true })
// 初始化页面搜索
await commit('d2admin/search/init', __aMenus, { root: true })
} catch (error) {
if (error.message === '参数错误' && !await dispatch('load')) {
router.replace('/login')
return false
}
}
// end
resolve(state.source)
})
......
......@@ -7,6 +7,15 @@ export default {
// 颜色
value: process.env.VUE_APP_ELEMENT_COLOR
},
getters: {
/**
* @description 返回当前颜色值
* @param {Object} state state
*/
color (state, dispatch) {
return state.value
}
},
actions: {
/**
* @description 设置颜色
......
import { get } from 'lodash'
import router from '@/router'
import setting from '@/setting.js'
// import setting from '@/setting.js'
import home from '@/router/routes'
// 判定是否需要缓存
const isKeepAlive = data => get(data, 'meta.cache', false)
......@@ -11,7 +12,7 @@ export default {
// 可以在多页 tab 模式下显示的页面
pool: [],
// 当前显示的多页面列表
opened: setting.page.opened,
opened: [home],
// 已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
openedLoaded: false,
// 当前页面
......@@ -45,7 +46,7 @@ export default {
const value = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'page.opened',
defaultValue: setting.page.opened,
defaultValue: [home],
user: true
}, { root: true })
// 在处理函数中进行数据优化 过滤掉现在已经失效的页签或者已经改变了信息的页签
......
......@@ -40,33 +40,26 @@
label="操作"
>
<template slot-scope="scope">
<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
<el-button type="text" size="small">编辑</el-button>
<auth-button label="测试" @e-auth-click="test(scope.row)"/>
<auth-button label="测试11" @e-auth-click="test(scope.row)"/>
<auth-button label="查看" @e-auth-click="handleClick(scope.row)"/>
<auth-button label="编辑" @e-auth-click="handleClick(scope.row)"/>
<auth-button label="看不见我" @e-auth-click="handleClick(scope.row)"/>
</template>
</el-table-column>
</el-table>
</d2-container>
</template>
<script>
export default {
methods: {
handleClick (row) {
console.log(row)
},
test (row) {
console.log(row)
alert(JSON.stringify(row))
}
},
components: {
},
mounted () {
this.$event.$on('e-auth-click', function () {
alert(1)
})
},
data () {
return {
......
import Bg from './src/main'
/* istanbul ignore next */
// Bg.install = function(Vue) {
// Vue.component(Bg.name, Bg)
// }
export default Bg
import axios from '@/plugin/axios'
// 默认配置
const defaults = {
format: 'js',
idx: 0,
n: 1,
token: 'wqdjkwl1e21FQlk1j2',
wallpaper_path: ''
}
/**
* 返回数组
*/
export const getBingImages = options => {
// const xhr = new XMLHttpRequest()
// const data = null
return new Promise((resolve, reject) => {
let config = null
if (typeof options === 'undefined') {
config = defaults
} else {
config = {}
Object.assign(config, defaults, options)
}
axios({ url: config.wallpaper_path }).then(res => {
// request({ url: 'http://localhost:3000/api/wallpaper' }).then(res => {
// console.log(JSON.parse(res.data).base64)
// if (res.status === 'success') {
resolve(res)
// } else {
// reject('ERROR.')
// }
})
})
}
<template>
<div :style="oBgStyle" :class="withAnimation?'img imgA':'img'"></div>
</template>
<script>
import { getBingImages } from './get_bing_image.js'
export default {
name: 'Bg',
props: {
opacity: [String],
refresh: Boolean,
withAnimation: Boolean
},
data() {
return {
oBgStyle: {
backgroundImage: '',
opacity: this.opacity || '.1'
}
}
},
beforeMount() {
// const oBg = this.$get_session('oBg')
// if (oBg && !this.refresh) {
// this.oBgStyle.backgroundImage = oBg.bgi
// this.$emit('update:oBg', oBg)
// return
// }
getBingImages({ 'wallpaper_path': 'http://oss-config.test.glsx.com.cn:7060/api/wallpaper' }).then(data => {
const { path, copyright, copyrightlink } = data
this.oBgStyle.backgroundImage = `url(${path})`
const oBg = { bgi: this.oBgStyle.backgroundImage, copyright, copyrightlink }
// this.$set_session('oBg', JSON.stringify(oBg))
this.$emit('update:oBg', oBg)
}).catch(err=>{
console.log(err);
})
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@keyframes img-action {
from{
transform: scale(1.1)
}
to{
transform: scale(1)
}
}
.img {
width: 100%;
height: 100%;
position: absolute;
}
.imgA {
animation: img-action 18s
}
</style>
<template>
<div class="page-login">
<!-- <bg opacity="1" :oBg.sync="bing" :refresh="true" :withAnimation="true"></bg> -->
<div class="page-login--layer page-login--layer-area">
<ul class="circles">
<li v-for="n in 10" :key="n"></li>
......@@ -81,7 +82,7 @@
</div>
</div>
<div class="page-login--content-footer">
<p class="page-login--content-footer-locales">
<!-- <p class="page-login--content-footer-locales">
<a
v-for="language in $languages"
:key="language.value"
......@@ -89,7 +90,7 @@
@click="$i18n.locale = language.value">
{{ language.label }}
</a>
</p>
</!-->
<p class="page-login--content-footer-copyright">
Copyright
<d2-icon name="copyright"/>
......@@ -98,11 +99,11 @@
@FairyEver
</a>
</p>
<p class="page-login--content-footer-options">
<!-- <p class="page-login--content-footer-options">
<a href="#">帮助</a>
<a href="#">隐私</a>
<a href="#">条款</a>
</p>
</p> -->
</div>
</div>
</div>
......@@ -126,8 +127,15 @@
import dayjs from 'dayjs'
import { mapActions } from 'vuex'
export default {
components: {
'Bg': () => import('./Bg')
},
data () {
return {
bing: {
copyright: '',
copyrightlink: ''
},
timeInterval: null,
time: dayjs().format('HH:mm:ss'),
// 快速选择用户
......
<template>
<div class="login-container">
<!-- <bg opacity="1" :oBg.sync="bing" :refresh="true" :withAnimation="true"></bg> -->
<div class="page-login--layer page-login--layer-area">
<ul class="circles">
<li v-for="n in 10" :key="n"></li>
</ul>
</div>
<div class="time">
<span class="time_time">{{time_time}}</span>
<span class="time_date">{{time_week}}</span>
<span class="time_date">{{time_date}}</span>
</div>
<el-form class="login-form" autoComplete="on" :model="loginForm" :rules="loginRules" ref="loginForm" label-position="left">
<div class="login-top" :style="oTopStyle">
<transition
appear
appear-class="title-appear"
appear-to-class="appear-to"
appear-active-class="appear-active">
<!-- <h3 class="title">车联网支撑平台</h3> -->
<img src="/static/logo.png" class="title" alt="广联赛讯,嘀嘀虎">
</transition>
<transition
appear
appear-class="password-appear"
appear-to-class="appear-to"
appear-active-class="appear-active">
<!-- <gl-app-theme-picker class="login-form-color-picker" :theme="theme.value" :predefineColors="theme.preDefineColors" /> -->
</transition>
</div>
<transition
appear
appear-class="username-appear"
appear-to-class="appear-to"
appear-active-class="appear-active">
<el-form-item prop="username">
<i class="fa fa-user-o" aria-hidden="true"></i>
<span class="svg-container svg-container_login">
<!-- <gl-svg-icon icon-class="user" /> -->
</span>
<el-input name="username" type="text" v-model="loginForm.username" placeholder="用户名" />
</el-form-item>
</transition>
<transition
appear
appear-class="password-appear"
appear-to-class="appear-to"
appear-active-class="appear-active">
<el-form-item prop="password" >
<span class="svg-container">
<!-- <gl-svg-icon icon-class="password" /> -->
</span>
<el-input name="password" :type="pwdType" @keyup.enter.native="handleLogin" v-model="loginForm.password" autoComplete="on" placeholder="密码" />
<span class="show-pwd" @click="pwdType= !pwdType ? 'password' : ''">
<i class="fa fa-user-o" aria-hidden="true"></i>
<!-- <gl-svg-icon icon-class="eye" /> -->
</span>
</el-form-item>
</transition>
<transition
appear
appear-class="username-appear"
appear-to-class="appear-to"
appear-active-class="appear-active">
<el-form-item prop="code" class="code" >
<el-col style="width:70%;">
<el-input name="code" type="text" v-model="loginForm.code" autoComplete="on" placeholder="验证码"/>
</el-col>
<el-col style="width:30%; height:47px;">
<img class="code-img" :src="code + rand" @click="handleCodeClick" >
</el-col>
</el-form-item>
</transition>
<transition
appear
appear-class="login-appear"
appear-to-class="appear-to"
appear-active-class="appear-active">
<el-form-item>
<el-button type="primary" :loading="loading" @keyup.enter="handleLogin" @click.native.prevent="handleLogin" :style="oStyle">
登 录
</el-button>
</el-form-item>
</transition>
<!-- <div class="tips">
<span style="margin-right:20px;">username: admin</span>
<span> password: admin</span>
</div> -->
</el-form>
<div class="fullscreen-by"><div>
<a :href="bing.copyrightlink" target="_blank">{{bing.copyright}}</a>
Photo by
<a href="https://cn.bing.com" target="_blank"><strong style="text-decoration: underline;color:blue;">Bing</strong></a>
</div></div>
</div>
</template>
<script>
import { mapActions,mapGetters } from 'vuex'
import util from '@/libs/util.js'
export default {
name: 'Login',
components: {
'Bg': () => import('./Bg')
},
data() {
const validateUsername = (rule, value, callback) => {
if (!value) {
// if (!isvalidUsername(value)) {
callback(new Error('请输入正确的用户名'))
} else if (value.length < 2) {
callback(new Error('用户名不能小于2位'))
} else {
callback()
}
}
const validatePass = (rule, value, callback) => {
if (!value) {
callback(new Error('请输入正确的密码'))
} else if (value.length < 2) {
callback(new Error('密码不能小于2位'))
} else {
callback()
}
}
const validateCode = (rule, value, callback) => {
if (!value) {
callback(new Error('请输入验证码'))
} else {
callback()
}
}
return {
code: '',
msg: '验证码错误',
rand: Date.now(),
loginForm: {
username: 'admin',
password: 'admin',
code: '8888'
},
time_date: '',
time_time: '',
time_week: '',
bing: {
copyright: '',
copyrightlink: ''
},
timer: null,
loginRules: {
username: [
{ required: true, trigger: 'blur', validator: validateUsername }
],
password: [
{ required: true, trigger: 'blur', validator: validatePass }
],
code: [
{ required: true, trigger: 'blur', validator: validateCode }
]
},
loading: false,
pwdType: 'password',
}
},
created() {
document.onkeydown = e => {
if (e.keyCode === 13) {
this.handleLogin()
}
}
this.timer = setInterval(() => {
this.getNowFormatDate()
}, 1000 / 60)
},
mounted() {
},
beforeDestroy() {
clearInterval(this.timer)
this.timer = null
},
computed: {
...mapGetters('d2admin/color', ['color']),
oTopStyle() {
return {
background: `linear-gradient(to bottom, ${util.colorToRgb(this.color, '.9')} , rgba(0,0,0,0))`
}
},
oStyle() {
return {
background: `linear-gradient(to top, ${util.colorToRgb(this.color , '.9')} , rgba(0,0,0,0))`
}
}
},
methods: {
...mapActions('d2admin/account', [
'login'
]),
getNowFormatDate() {
var date = new Date()
var year = date.getFullYear()
var month = date.getMonth() + 1
var strDate = date.getDate()
if (month >= 1 && month <= 9) {
month = '0' + month
}
if (strDate >= 0 && strDate <= 9) {
strDate = '0' + strDate
}
this.time_date = `${year}-${month}-${strDate}`
this.time_week = `星期${'日一二三四五六'.charAt(date.getDay())}`
this.time_time = date.toLocaleString('chinese', { hour12: false }).split(' ')[1]
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
// 登录
// 注意 这里的演示没有传验证码
// 具体需要传递的数据请自行修改代码
this.login(this.loginForm).then(() => {
this.$store.dispatch('d2admin/auth/init').then(_ => {
// 重定向对象不存在则返回顶层路径
this.$router.replace(this.$route.query.redirect || '/')
})
})
} else {
this.loading = false
return false
}
})
},
handleCodeClick() {
this.rand = Date.now()
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss">
$bg: #2d3a4b;
$light_gray: #eee;
/* reset element-ui css */
.login-container {
.el-input {
display: inline-block;
height: 47px;
width: 85%;
input {
background: transparent;
border: 0px;
-webkit-appearance: none;
border-radius: 0px;
padding: 12px 5px 12px 15px;
color: $light_gray;
height: 47px;
&:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px $bg inset !important;
-webkit-text-fill-color: #fff !important;
}
}
}
.el-button{
width:100%;
border:none;
border-radius: 0 0 5px 5px;
}
.el-form-item {
border: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(0, 0, 0, 0.1);
// border-radius: 5px;
color: #454545;
margin-bottom: 16px;
}
.el-form-item__error{
padding-top:0 !important;
}
.code {
border: 0px;
background: rgba(0,0,0,0);
// overflow: hidden;
height: 47px;
.el-input{
border: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(0, 0, 0, 0.1);
border-radius: 5px;
color: #454545;
width: 90%;
}
}
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
$bg: #2d3a4b;
$dark_gray: #889aa4;
$light_gray: #eee;
$step: 100px;
.login-container {
position: fixed;
height: 100%;
width: 100%;
background-color: $bg;
#star{
position: absolute;
}
.time{
position: absolute;
top: 90px;
left: 90px;
color: #fff;
font-family: '微软雅黑';
text-align: right;
// background-color: rgba(255,255,255,.3);
// border:1px solid rgba(255,255,255,.3);
padding: 10px;
border-radius: 4px;
display: flex;
flex-flow: column;
text-shadow: 0 0 1px #888,1px 1px 2px #666, 2px 2px 2px #333;
.time_time{
font-size: 38px;
font-weight: bold;
margin-bottom:5px;
}
}
.login-form {
position: absolute;
left: 0;
right: 0;
top:0;
bottom: 0;
// height: 310px;
width: 450px;
padding: 35px 35px 15px 35px;
margin: 120px auto;
.login-top{
line-height: 1px;
// background-color: rgba(0,0,0,.3);
border-radius: 5px 5px 0 0;
padding: 10px;
margin-bottom: 10px;
}
&-color-picker {
float: right;
margin-top: 10px;
}
}
.tips {
font-size: 14px;
color: #fff;
margin-bottom: 10px;
span {
&:first-of-type {
margin-right: 16px;
}
}
}
.svg-container {
padding: 6px 5px 6px 15px;
color: $dark_gray;
vertical-align: middle;
width: 30px;
display: inline-block;
&_login {
font-size: 20px;
}
}
.show-pwd {
position: absolute;
right: 10px;
top: 7px;
font-size: 16px;
color: $dark_gray;
cursor: pointer;
user-select: none;
}
.title-appear{
transform: translateY(-$step);
}
.login-appear{
transform: translateY($step);
}
.username-appear{
transform: translateX($step);
}
.password-appear{
transform: translateX(-$step);
}
.appear-active{
transition: all .6s ease;
}
.appear-to{
transform: translateY(0px);
transform: translateX(0px);
}
.code-img {
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 5px;
height: 100%;
width: 100%;
}
.fullscreen-by{
position: fixed;
bottom: 20px;
right: 20px;
color: #fff;
font-size: 14px;
}
}
// 背景
.circles {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
margin: 0px;
padding: 0px;
li {
position: absolute;
display: block;
list-style: none;
width: 20px;
height: 20px;
background: #FFF;
animation: animate 25s linear infinite;
bottom: -200px;
@keyframes animate {
0%{
transform: translateY(0) rotate(0deg);
opacity: 1;
border-radius: 0;
}
100%{
transform: translateY(-1000px) rotate(720deg);
opacity: 0;
border-radius: 50%;
}
}
&:nth-child(1) {
left: 15%;
width: 80px;
height: 80px;
animation-delay: 0s;
}
&:nth-child(2) {
left: 5%;
width: 20px;
height: 20px;
animation-delay: 2s;
animation-duration: 12s;
}
&:nth-child(3) {
left: 70%;
width: 20px;
height: 20px;
animation-delay: 4s;
}
&:nth-child(4) {
left: 40%;
width: 60px;
height: 60px;
animation-delay: 0s;
animation-duration: 18s;
}
&:nth-child(5) {
left: 65%;
width: 20px;
height: 20px;
animation-delay: 0s;
}
&:nth-child(6) {
left: 75%;
width: 150px;
height: 150px;
animation-delay: 3s;
}
&:nth-child(7) {
left: 35%;
width: 200px;
height: 200px;
animation-delay: 7s;
}
&:nth-child(8) {
left: 50%;
width: 25px;
height: 25px;
animation-delay: 15s;
animation-duration: 45s;
}
&:nth-child(9) {
left: 20%;
width: 15px;
height: 15px;
animation-delay: 2s;
animation-duration: 35s;
}
&:nth-child(10) {
left: 85%;
width: 150px;
height: 150px;
animation-delay: 0s;
animation-duration: 11s;
}
}
}
.page-login--layer {
@extend %full;
overflow: auto;
}
.page-login--layer-area {
overflow: hidden;
}
</style>
\ No newline at end of file
......@@ -17,7 +17,7 @@
prop="trafficCode">
<el-input
:disabled="disabled"
v-model="editForm.trafficCode"
v-model="editForm.trafficCode"
placeholder="请输入车辆编号"
></el-input>
</el-form-item>
......@@ -79,8 +79,8 @@ export default {
},
watch: {
isVisible(val) {
this.disabled = this.editForm.trafficCode ? true : false
isVisible (val) {
this.disabled = !!this.editForm.trafficCode
this.editForm.openType = this.editForm.trafficCode ? this.editForm.openType : '1'
this.$refs.editRuleForm.resetFields()
}
......
......@@ -101,7 +101,7 @@
<script>
import EditDialog from './editDialog'
import { getListApi, addApi, editApi, removeApi } from '@api/trafficManagement'
import { getListApi, addApi, editApi, removeApi } from '@api/trafficManagement'
import notice from '@/common/notice'
export default {
name: 'trafficManagement',
......@@ -141,7 +141,7 @@ export default {
label: '接口开放',
prop: 'openType',
formatter: (cellValue) => {
if(cellValue.openType) {
if (cellValue.openType) {
return {
1: '是',
2: '否'
......@@ -184,7 +184,7 @@ export default {
this.tableLoading = false
})
},
addTraffic(value) {
addTraffic (value) {
const params = value
addApi(params).then(res => {
this.handleEditClose()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!