修BUG,加入master的新功能

This commit is contained in:
寻欢·李 2018-01-04 14:09:28 +08:00
parent baba1ffc34
commit 53c4c7da51
12 changed files with 144 additions and 27 deletions

View File

@ -3,5 +3,6 @@
["env", { "modules": false }],
"stage-2"
],
"plugins": ["transform-runtime"]
"plugins": ["transform-runtime"],
"comments": false
}

View File

@ -13,7 +13,7 @@
"dependencies": {
"axios": "0.17.1",
"clipboard": "1.7.1",
"element-ui": "2.0.8",
"element-ui": "2.0.10",
"js-cookie": "2.2.0",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",

View File

@ -38,3 +38,9 @@ export function putObj(obj) {
})
}
export function remote(type) {
return fetch({
url: '/admin/dict/type/' + type,
method: 'get'
})
}

View File

@ -1,6 +1,6 @@
import request from '@/utils/request'
export function login(username, password) {
export function login(username, password, randomStr, code) {
var grant_type = 'password'
var scope = 'server'
return request({
@ -9,7 +9,7 @@ export function login(username, password) {
'Authorization': 'Basic cGlnOnBpZw=='
},
method: 'post',
params: { username, password, grant_type, scope }
params: { username, password, randomStr, code, grant_type, scope }
})
}

View File

@ -1,7 +1,6 @@
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en'
import locale from 'element-ui/lib/locale/lang/zh-CN'
import App from './App'
import router from './router'

View File

@ -22,12 +22,12 @@ router.beforeEach((to, from, next) => { // 开启Progress
} else {
if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(res => { // 拉取用户信息
const roles = res.data.roles
const roles = res.data.data.roles
store.dispatch('GenerateRoutes', { roles }).then(() => { // 生成可访问的路由表
router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
next({ ...to }) // hack方法 确保addRoutes已完成
})
}).catch(() => {
}).catch((e) => {
store.dispatch('FedLogOut').then(() => {
Message.error('验证失败,请重新登录')
next({ path: '/login' })

View File

@ -6,6 +6,7 @@ const user = {
token: getToken(),
name: '',
avatar: '',
permissions: [],
roles: []
},
@ -38,7 +39,7 @@ const user = {
Login({ commit }, userInfo) {
const username = userInfo.username.trim()
return new Promise((resolve, reject) => {
login(username, userInfo.password).then(response => {
login(username, userInfo.password, userInfo.randomStr, userInfo.code).then(response => {
const data = response.data
setToken(data.access_token)
commit('SET_TOKEN', data.access_token)
@ -54,7 +55,7 @@ const user = {
GetInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getInfo(state.token).then(response => {
const data = response.data
const data = response.data.data
commit('SET_ROLES', data.roles)
commit('SET_NAME', data.sysUser.username)
commit('SET_AVATAR', data.sysUser.avatar)
@ -93,7 +94,25 @@ const user = {
removeToken()
resolve()
})
},
// 动态修改权限
ChangeRole({ commit }, role) {
return new Promise(resolve => {
commit('SET_TOKEN', role)
setToken(role)
getUserInfo(role).then(response => {
const data = response.data.data
commit('SET_ROLES', data.role)
commit('SET_NAME', data.name)
commit('SET_AVATAR', data.avatar)
commit('SET_INTRODUCTION', data.introduction)
resolve()
})
})
}
}
}

View File

@ -22,16 +22,37 @@ service.interceptors.request.use(config => {
// respone拦截器
service.interceptors.response.use(
response => response,
response => {
const res = response.data
console.log(res)
if (res.code == 1) {
message(res.msg, 'error')
return Promise.reject(res)
}
return response
},
error => {
const res = error.response
Message({
message: res.status + ' ' + res.data.error,
type: 'error',
duration: 5 * 1000
})
console.log(res.status)
if (res.status == 478 || res.status == 403) {
message(res.status + " " + res.data.msg, 'error')
} else if (res.status == 400) {
message(res.status + " " + res.data.error_description, 'error')
} else {
message(res.status + " " + res.data.message, 'error')
}
return Promise.reject(error)
}
)
export function message(text, type) {
Message({
message: text,
type: type,
duration: 5 * 1000
})
}
export default service

View File

@ -1,6 +1,15 @@
<template>
<div class="app-container calendar-list-container">
<div class="filter-container">
<el-select v-model="listQuery.type" filterable placeholder="请选择">
<el-option
v-for="item in dicts"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-button class="filter-item" type="primary" v-waves icon="search" @click="handleFilter">搜索</el-button>
</div>
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit
highlight-current-row style="width: 100%">
@ -11,6 +20,15 @@
</template>
</el-table-column>
<el-table-column label="类型" align="center">
<template scope="scope">
<span>
<el-button type="success" v-if="scope.row.type == 0">{{ scope.row.type | typeFilter }}</el-button>
<el-button type="danger" v-if="scope.row.type ==9">{{ scope.row.type | typeFilter }}</el-button>
</span>
</template>
</el-table-column>
<el-table-column label="请求接口" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.requestUri}}</span>
@ -49,7 +67,7 @@
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="mini" type="danger" v-if="sys_dict_add"
<el-button size="mini" type="danger" v-if="sys_dict_del"
@click="handleDelete(scope.row)">删除
</el-button>
</template>
@ -66,7 +84,8 @@
</template>
<script>
import { fetchList, delObj } from '@/api/log'
import { delObj, fetchList } from '@/api/log'
import { remote } from '@/api/dict'
import waves from '@/directive/waves/index.js' //
import { mapGetters } from 'vuex'
@ -81,9 +100,11 @@
total: null,
sys_dict_add: false,
listLoading: true,
dicts:[],
listQuery: {
page: 1,
limit: 20
limit: 20,
type: undefined
},
tableKey: 0
}
@ -93,7 +114,20 @@
'permissions'
])
},
filters: {
typeFilter(type) {
const typeMap = {
0: '正常',
9: '异常'
}
return typeMap[type]
}
},
created() {
remote('log_type').then(response => {
this.dicts = response.data
})
console.log(this.dicts)
this.getList()
this.sys_log_del = this.permissions['sys_log_del']
},
@ -128,7 +162,13 @@
duration: 2000
})
})
},
handleFilter() {
this.listQuery.page = 1
this.getList()
}
}
}
</script>

View File

@ -35,7 +35,7 @@
<el-input v-model="form.name" :disabled="formEdit" placeholder="请输入标题"></el-input>
</el-form-item>
<el-form-item label="权限标识" prop="permission">
<el-input v-model="form.permission" :disabled="formEdit" placeholder="请输入权限表示"></el-input>
<el-input v-model="form.permission" :disabled="formEdit" placeholder="请输入权限标识"></el-input>
</el-form-item>
<el-form-item label="图标" prop="icon">
<el-input v-model="form.icon" :disabled="formEdit" placeholder="请输入图标"></el-input>

View File

@ -81,7 +81,7 @@
</el-form-item>
<el-form-item label="角色" prop="role">
<el-select class="filter-item" v-model="form.role" placeholder="请选择">
<el-select class="filter-item" v-model="role" placeholder="请选择">
<el-option v-for="item in rolesOptions" :key="item.roleId" :label="item.roleDesc" :value="item.roleId" :disabled="isDisabled[item.delFlag]">
<span style="float: left">{{ item.roleDesc }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.roleCode }}</span>
@ -133,11 +133,11 @@
page: 1,
limit: 20
},
role: undefined,
form: {
username: undefined,
password: undefined,
delFlag: undefined,
role: undefined
delFlag: undefined
},
rules: {
username: [
@ -194,7 +194,8 @@
statusFilter(status) {
const statusMap = {
0: '有效',
1: '无效'
1: '无效',
9: '锁定'
}
return statusMap[status]
}
@ -241,7 +242,7 @@
getObj(row.userId)
.then(response => {
this.form = response.data
this.form.role = row.roleList[0].roleId
this.role = row.roleList[0].roleId
this.dialogFormVisible = true
this.dialogStatus = 'update'
})
@ -254,6 +255,7 @@
const set = this.$refs
set[formName].validate(valid => {
if (valid) {
this.form.role = this.role
addObj(this.form)
.then(() => {
this.dialogFormVisible = false
@ -280,6 +282,7 @@
if (valid) {
this.dialogFormVisible = false
this.form.password = undefined
this.form.role = this.role
putObj(this.form).then(() => {
this.dialogFormVisible = false
this.getList()

View File

@ -17,6 +17,22 @@
placeholder="密码"></el-input>
<span class="show-pwd" @click="showPwd"><svg-icon icon-class="eye" /></span>
</el-form-item>
<input name="randomStr" type="hidden" v-model="loginForm.randomStr" />
<el-form-item>
<el-col :span="2">
<span class="svg-container">
<icon-svg icon-class="form"/>
</span>
</el-col>
<el-col :span="11">
<el-input name="code" type="text" v-model="loginForm.code" autoComplete="on" placeholder="验证码"/>
</el-col>
<el-col :span="10" align="right">
<img :src="src" style="padding-bottom: 1px" @click="refreshCode"/>
</el-col>
</el-form-item>
<el-form-item>
<el-button type="primary" style="width:100%;" :loading="loading" @click.native.prevent="handleLogin">
登陆
@ -40,19 +56,27 @@ export default {
}
}
return {
src: '',
loginForm: {
username: null,
password: null
password: null,
code: '',
randomStr: Math.ceil(Math.random() * 100000) + "_" + Date.now()
},
loginRules: {
username: [{ required: true, trigger: 'blur' }],
password: [{ required: true, trigger: 'blur', validator: validatePass }]
password: [{ required: true, trigger: 'blur', validator: validatePass }],
code: [{ required: true, trigger: 'blur' }],
},
loading: false,
pwdType: 'password'
}
},
methods: {
refreshCode: function() {
this.loginForm.randomStr = Math.ceil(Math.random() * 100000) + Date.now()
this.src = '/admin/code/' + this.loginForm.randomStr
},
showPwd() {
if (this.pwdType === 'password') {
this.pwdType = ''
@ -69,13 +93,17 @@ export default {
this.$router.push({ path: '/' })
}).catch(() => {
this.loading = false
this.refreshCode()
})
} else {
console.log('error submit!!')
console.log('想搞事情??')
return false
}
})
}
},
created() {
this.src = '/admin/code/' + this.loginForm.randomStr
}
}
</script>