Commit 5d4f9903 by zhengjie

v1.6 版本发布 ,详情查看版本说明

parent 685985ce
......@@ -51,14 +51,12 @@ module.exports = function() {
'To use this template, you must update following to modules:'
)
)
console.log()
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}
{
"name": "eladmin-qt",
"version": "1.2.0",
"version": "1.6.0",
"license": "Apache License 2.0",
"description": "eladmin 前端代码",
"author": "jie <zhengjie@tom.com>",
"author": "jie <elunez@qq.com>",
"scripts": {
"dev": "cross-env BABEL_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"build": "cross-env NODE_ENV=production env_config=prod node build/build.js",
......@@ -32,7 +32,7 @@
"vuex": "3.0.1",
"xlsx": "^0.11.16",
"jszip": "3.1.5",
"@riophae/vue-treeselect": "0.0.37",
"@riophae/vue-treeselect": "0.0.38",
"file-saver": "1.3.8",
"sockjs-client": "1.3.0",
"stompjs": "2.3.3",
......
......@@ -16,6 +16,13 @@ export function add(data) {
})
}
export function get(id) {
return request({
url: 'api/roles/' + id,
method: 'get'
})
}
export function del(id) {
return request({
url: 'api/roles/' + id,
......@@ -30,3 +37,19 @@ export function edit(data) {
data
})
}
export function editPermission(data) {
return request({
url: 'api/roles/permission',
method: 'put',
data
})
}
export function editMenu(data) {
return request({
url: 'api/roles/menu',
method: 'put',
data
})
}
......@@ -11,6 +11,9 @@ NProgress.configure({ showSpinner: false })// NProgress Configuration
const whiteList = ['/login']// no redirect whitelist
router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title + ' - eladmin'
}
NProgress.start() // start progress bar
if (getToken()) {
// 已登录且要跳转的页面是登录页
......@@ -20,20 +23,19 @@ router.beforeEach((to, from, next) => {
} else {
if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(res => { // 拉取user_info
buildMenus().then(res => {
const asyncRouter = filterAsyncRouter(res)
asyncRouter.push({ path: '*', redirect: '/404', hidden: true })
store.dispatch('GenerateRoutes', asyncRouter).then(() => { // 存储路由
router.addRoutes(asyncRouter) // 动态添加可访问路由表
next({ ...to, replace: true })// hack方法 确保addRoutes已完成
})
})
// 动态路由,拉取菜单
loadMenus(next, to)
}).catch((err) => {
console.log(err)
store.dispatch('LogOut').then(() => {
location.reload() // 为了重新实例化vue-router对象 避免bug
})
})
// 登录时未拉取 菜单,在此处拉取
} else if (store.getters.loadMenus) {
// 修改成false,防止死循环
store.dispatch('updateLoadMenus').then(res => {})
loadMenus(next, to)
} else {
next()
}
......@@ -49,6 +51,17 @@ router.beforeEach((to, from, next) => {
}
})
export const loadMenus = (next, to) => {
buildMenus().then(res => {
const asyncRouter = filterAsyncRouter(res)
asyncRouter.push({ path: '*', redirect: '/404', hidden: true })
store.dispatch('GenerateRoutes', asyncRouter).then(() => { // 存储路由
router.addRoutes(asyncRouter) // 动态添加可访问路由表
next({ ...to, replace: true })// hack方法 确保addRoutes已完成
})
})
}
router.afterEach(() => {
NProgress.done() // finish progress bar
})
......@@ -21,6 +21,7 @@ import Layout from '../views/layout/Layout'
export const constantRouterMap = [
{ path: '/login',
meta: { title: '登录', noCache: true },
component: () => import('@/views/login/index'),
hidden: true
},
......
......@@ -9,6 +9,7 @@ const getters = {
createTime: state => state.user.createTime,
email: state => state.user.email,
roles: state => state.user.roles,
loadMenus: state => state.user.loadMenus,
permission_routers: state => state.permission.routers,
addRouters: state => state.permission.addRouters,
socketApi: state => state.api.socketApi,
......
......@@ -9,7 +9,9 @@ const user = {
email: '',
avatar: '',
createTime: '',
roles: []
roles: [],
// 第一次加载菜单时用到
loadMenus: false
},
mutations: {
......@@ -30,6 +32,9 @@ const user = {
},
SET_EMAIL: (state, email) => {
state.email = email
},
SET_LOAD_MENUS: (state, loadMenus) => {
state.loadMenus = loadMenus
}
},
......@@ -43,6 +48,9 @@ const user = {
login(username, password).then(res => {
setToken(res.token, rememberMe)
commit('SET_TOKEN', res.token)
setUserInfo(res.user, commit)
// 第一次加载菜单时用到, 具体见 src 目录下的 permission.js
commit('SET_LOAD_MENUS', true)
resolve()
}).catch(error => {
reject(error)
......@@ -54,11 +62,7 @@ const user = {
GetInfo({ commit }) {
return new Promise((resolve, reject) => {
getInfo().then(res => {
commit('SET_ROLES', res.roles)
commit('SET_NAME', res.username)
commit('SET_AVATAR', res.avatar)
commit('SET_EMAIL', res.email)
commit('SET_CREATE_TIME', parseTime(res.createTime))
setUserInfo(res, commit)
resolve(res)
}).catch(error => {
reject(error)
......@@ -74,8 +78,27 @@ const user = {
removeToken()
resolve()
})
},
updateLoadMenus({ commit }) {
return new Promise((resolve, reject) => {
commit('SET_LOAD_MENUS', false)
})
}
}
}
export const setUserInfo = (res, commit) => {
// 如果没有任何权限,则赋予一个默认的权限,避免请求死循环
if (res.roles.length === 0) {
commit('SET_ROLES', ['ROLE_SYSTEM_DEFAULT'])
} else {
commit('SET_ROLES', res.roles)
}
commit('SET_NAME', res.username)
commit('SET_AVATAR', res.avatar)
commit('SET_EMAIL', res.email)
commit('SET_CREATE_TIME', parseTime(res.createTime))
}
export default user
......@@ -2,7 +2,7 @@
margin: 0px 0px 10px;
padding: 15px;
line-height: 22px;
border-left: 5px solid #409EFF;;
border-left: 5px solid #00437B;
border-radius: 0 2px 2px 0;
background-color: #f2f2f2;
}
......@@ -10,8 +10,7 @@
position: relative;
padding: 15px;
line-height: 20px;
border: 1px solid #ddd;
border-left-width: 6px;
border-left: 5px solid #ddd;
color: #333;
font-family: Courier New;
font-size: 12px
......
......@@ -15,7 +15,7 @@ export function parseTime(time) {
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
// 拼接
return year + '年' + month + '月' + day + '日 ' + hours + ':' + minutes + ':' + seconds
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
} else {
return ''
}
......
......@@ -54,7 +54,7 @@ service.interceptors.response.use(
}
if (code === 401) {
MessageBox.confirm(
'登录状态过期了哦,您可以继续留在该页面,或者重新登录',
'登录状态已过期,您可以继续留在该页面,或者重新登录',
'系统提示',
{
confirmButtonText: '重新登录',
......
......@@ -16,7 +16,6 @@
</router-link>
</scroll-pane>
<ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
<li @click="refreshSelectedTag(selectedTag)">刷新</li>
<li @click="closeSelectedTag(selectedTag)">关闭</li>
<li @click="closeOthersTags">关闭其他</li>
<li @click="closeAllTags">关闭所有</li>
......@@ -86,16 +85,6 @@ export default {
}
})
},
refreshSelectedTag(view) {
this.$store.dispatch('delCachedView', view).then(() => {
const { fullPath } = view
this.$nextTick(() => {
this.$router.replace({
path: '/redirect' + fullPath
})
})
})
},
closeSelectedTag(view) {
this.$store.dispatch('delView', view).then(({ visitedViews }) => {
if (this.isActive(view)) {
......
......@@ -8,7 +8,7 @@
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="密码">
<el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="密码" @keyup.enter.native="handleLogin">
<svg-icon slot="prefix" icon-class="password" class="el-input__icon" style="height: 39px;width: 13px;margin-left: 2px;" />
</el-input>
</el-form-item>
......
......@@ -30,7 +30,7 @@ export default {
ico: 'unlock', unlock: true, content: '锁定滚动条',
height: document.documentElement.clientHeight - 94.5 + 'px;',
width: document.documentElement.clientWidth - 185 + 'px;',
data: [{ name: 'elAdmin-', timestamp: new Date(), threadName: 'system-prompt-message', level: 'INFO', className: 'me.zhengjie.AppRun' + ' :', body: 'Welcome, no log output~' }],
data: [{ name: 'elAdmin-', timestamp: new Date(), threadName: 'system-prompt-message', level: 'INFO', className: 'me.zhengjie.AppRun' + ' :', body: 'Welcome, no log output' }],
// level
INFO: '#0000ff', WARN: '#FFFF00', ERROR: '#FF0000', DEBUG: '#DEA000'
}
......@@ -129,5 +129,29 @@ export default {
</script>
<style scoped>
button,input,textarea{outline:0}.container .buttons .closes,.container .buttons .maximize,.container .buttons .minimize{padding:0;margin:0;margin-right:6px;width:12px;height:12px;border:1px solid transparent;border-radius:6px}.container{width:100%;margin:5px}.container .console{font-family:consolas;overflow-y:scroll;background:#494949;color:#f7f7f7;padding:10px;font-size:14px} .lock {position: fixed;right: 45px;bottom: 6.8%;z-index: 100000}
button,input,textarea {
outline: 0
}
.container {
width: 100%;
margin: 5px
}
.container .console {
font-family: "Interstate", "Hind", -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
overflow-y: scroll;
background: #494949;
color: #f7f7f7;
padding: 10px;
font-size: 14px;
border-radius: 3px 1px 3px 3px;
}
.lock {
position: fixed;
right: 45px;
bottom: 6.8%;
z-index: 100000
}
</style>
<template>
<div class="app-container">
<eHeader :roles="roles" :menus="menus" :query="query"/>
<eHeader :menus="menus" :query="query"/>
<!--表格渲染-->
<tree-table v-loading="loading" :data="data" :expand-all="true" :columns="columns" border size="small">
<el-table-column prop="icon" label="图标" align="center" width="80px">
......@@ -28,7 +28,7 @@
</el-table-column>
<el-table-column label="操作" width="150px" align="center">
<template slot-scope="scope">
<edit v-if="checkPermission(['ADMIN','MENU_ALL','MENU_EDIT'])" :roles="roles" :menus="menus" :data="scope.row" :sup_this="sup_this"/>
<edit v-if="checkPermission(['ADMIN','MENU_ALL','MENU_EDIT'])" :menus="menus" :data="scope.row" :sup_this="sup_this"/>
<el-popover
v-if="checkPermission(['ADMIN','MENU_ALL','MENU_DELETE'])"
:ref="scope.row.id"
......@@ -49,7 +49,6 @@
<script>
import checkPermission from '@/utils/permission' // 权限判断函数
import { getRoleTree } from '@/api/role'
import treeTable from '@/components/TreeTable'
import initData from '@/mixins/initData'
import { del, getMenusTree } from '@/api/menu'
......@@ -67,11 +66,10 @@ export default {
value: 'name'
}
],
delLoading: false, sup_this: this, menus: [], roles: []
delLoading: false, sup_this: this, menus: []
}
},
created() {
this.getRoles()
this.getMenus()
this.$nextTick(() => {
this.init()
......@@ -113,12 +111,6 @@ export default {
menu.children = res
this.menus.push(menu)
})
},
getRoles() {
this.roles = []
getRoleTree().then(res => {
this.roles = res
})
}
}
}
......
<template>
<div>
<el-button size="mini" type="success" @click="to">编辑</el-button>
<eForm ref="form" :roles="roles" :menus="menus" :sup_this="sup_this" :is-add="false"/>
<eForm ref="form" :menus="menus" :sup_this="sup_this" :is-add="false"/>
</div>
</template>
<script>
......@@ -20,20 +20,12 @@ export default {
menus: {
type: Array,
required: true
},
roles: {
type: Array,
required: true
}
},
methods: {
to() {
const _this = this.$refs.form
_this.roleIds = []
_this.form = { id: this.data.id, component: this.data.component, name: this.data.name, sort: this.data.sort, pid: this.data.pid, path: this.data.path, iframe: this.data.iframe.toString(), roles: [], icon: this.data.icon }
this.data.roles.forEach(function(data, index) {
_this.roleIds.push(data.id)
})
_this.dialog = true
}
}
......
......@@ -33,9 +33,6 @@
<el-form-item label="上级类目">
<treeselect v-model="form.pid" :options="menus" style="width: 460px;" placeholder="选择上级类目" />
</el-form-item>
<el-form-item style="margin-top: -10px;margin-bottom: 0px;" label="选择角色">
<treeselect v-model="roleIds" :multiple="true" :options="roles" style="width: 460px;" placeholder="请选择角色" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
......@@ -56,10 +53,6 @@ export default {
type: Array,
required: true
},
roles: {
type: Array,
required: true
},
isAdd: {
type: Boolean,
required: true
......@@ -72,7 +65,7 @@ export default {
data() {
return {
loading: false, dialog: false,
form: { name: '', sort: 999, path: '', component: '', iframe: 'false', roles: [], pid: 0, icon: '' }, roleIds: [],
form: { name: '', sort: 999, path: '', component: '', iframe: 'false', roles: [], pid: 0, icon: '' },
rules: {
name: [
{ required: true, message: '请输入名称', trigger: 'blur' }
......@@ -94,12 +87,6 @@ export default {
this.$refs['form'].validate((valid) => {
if (valid) {
this.loading = true
this.form.roles = []
const _this = this
this.roleIds.forEach(function(data, index) {
const role = { id: data }
_this.form.roles.push(role)
})
if (this.isAdd) {
this.doAdd()
} else this.doEdit()
......@@ -144,7 +131,6 @@ export default {
this.dialog = false
this.$refs['form'].resetFields()
this.form = { name: '', sort: 999, path: '', component: '', iframe: 'false', roles: [], pid: 0, icon: '' }
this.roleIds = []
},
selected(name) {
this.form.icon = name
......
......@@ -12,7 +12,7 @@
type="primary"
icon="el-icon-plus"
@click="$refs.form.dialog = true">新增</el-button>
<eForm ref="form" :roles="roles" :menus="menus" :is-add="true"/>
<eForm ref="form" :menus="menus" :is-add="true"/>
</div>
</div>
</template>
......@@ -30,10 +30,6 @@ export default {
menus: {
type: Array,
required: true
},
roles: {
type: Array,
required: true
}
},
data() {
......@@ -44,7 +40,6 @@ export default {
methods: {
checkPermission,
toQuery() {
console.log(this.query)
this.$parent.page = 0
this.$parent.init()
}
......
......@@ -21,7 +21,7 @@
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" :disabled="scope.row.id === 1" type="danger" size="mini">删除</el-button>
<el-button slot="reference" type="danger" size="mini">删除</el-button>
</el-popover>
</template>
</el-table-column>
......
<template>
<div>
<el-button :disabled="data.id === 1" size="mini" type="success" @click="to">编辑</el-button>
<el-button size="mini" type="success" @click="to">编辑</el-button>
<eForm ref="form" :permissions="permissions" :sup_this="sup_this" :is-add="false"/>
</div>
</template>
......
......@@ -40,7 +40,6 @@ export default {
methods: {
checkPermission,
toQuery() {
console.log(this.query)
this.$parent.page = 0
this.$parent.init()
}
......
<template>
<div class="app-container">
<eHeader :permissions="permissions" :query="query"/>
<eHeader :query="query"/>
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" border style="width: 100%;">
<div :style="'height: auto;max-height:' + height + 'overflow-y: auto;'">
<el-table v-loading="loading" :data="data" highlight-current-row size="small" border style="width: 100%;" @current-change="handleCurrentChange">
<el-table-column prop="name" label="名称"/>
<el-table-column prop="remark" label="描述"/>
<el-table-column prop="createTime" label="创建日期">
......@@ -12,7 +13,7 @@
</el-table-column>
<el-table-column label="操作" width="150px" align="center">
<template slot-scope="scope">
<edit v-if="checkPermission(['ADMIN','ROLES_ALL','ROLES_EDIT'])" :permissions="permissions" :data="scope.row" :sup_this="sup_this"/>
<edit v-if="checkPermission(['ADMIN','ROLES_ALL','ROLES_EDIT'])" :data="scope.row" :sup_this="sup_this"/>
<el-popover
v-if="checkPermission(['ADMIN','ROLES_ALL','ROLES_DELETE'])"
:ref="scope.row.id"
......@@ -23,11 +24,12 @@
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" :disabled="scope.row.id === 1" type="danger" size="mini">删除</el-button>
<el-button slot="reference" type="danger" size="mini">删除</el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
</div>
<!--分页组件-->
<el-pagination
:total="total"
......@@ -35,6 +37,59 @@
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"/>
<!--这里是授权模块代码-->
<el-row :gutter="20" style="margin-top: 5px;">
<!--权限分配-->
<el-col :span="12">
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">权限分配</span>
<el-button
v-if="showButton && checkPermission(['ADMIN','ROLES_ALL','ROLES_EDIT'])"
:loading="permissionLoading"
icon="el-icon-check"
size="mini"
style="float: right; padding: 4px 10px"
type="info"
@click="savePermission">保存</el-button>
</div>
<div :style="'min-height: 200px;max-height:' + height + 'overflow-y: auto;'">
<el-tree
ref="permission"
:data="permissions"
:default-checked-keys="permissionIds"
:props="defaultProps"
show-checkbox
node-key="id"/>
</div>
</el-card>
</el-col>
<!--菜单分配-->
<el-col :span="12">
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">菜单分配</span>
<el-button
v-if="showButton && checkPermission(['ADMIN','ROLES_ALL','ROLES_EDIT'])"
:loading="menuLoading"
icon="el-icon-check"
size="mini"
style="float: right; padding: 4px 10px"
type="info"
@click="saveMenu">保存</el-button>
</div>
<div :style="'min-height: 207px;max-height:' + height + 'overflow-y: auto;'">
<el-tree
ref="menu"
:data="menus"
:default-checked-keys="menuIds"
:props="defaultProps"
show-checkbox
node-key="id"/>
</div>
</el-card>
</el-col>
</el-row>
</div>
</template>
......@@ -43,19 +98,28 @@ import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del } from '@/api/role'
import { getPermissionTree } from '@/api/permission'
import { getMenusTree } from '@/api/menu'
import { parseTime } from '@/utils/index'
import eHeader from './module/header'
import edit from './module/edit'
import { editPermission, editMenu, get } from '@/api/role'
export default {
components: { eHeader, edit },
mixins: [initData],
data() {
return {
delLoading: false, sup_this: this, permissions: []
defaultProps: {
children: 'children',
label: 'label'
},
currentId: 0, permissionLoading: false, menuLoading: false, showButton: false,
delLoading: false, sup_this: this, permissions: [], permissionIds: [], menus: [], menuIds: [],
height: document.documentElement.clientHeight - 94.5 - 260 + 'px;'
}
},
created() {
this.getPermissions()
this.getMenus()
this.$nextTick(() => {
this.init()
})
......@@ -64,6 +128,9 @@ export default {
parseTime,
checkPermission,
beforeInit() {
this.$refs.permission.setCheckedKeys([])
this.$refs.menu.setCheckedKeys([])
this.showButton = false
this.url = 'api/roles'
const sort = 'id,desc'
const query = this.query
......@@ -93,11 +160,106 @@ export default {
getPermissionTree().then(res => {
this.permissions = res
})
},
getMenus() {
getMenusTree().then(res => {
this.menus = res
})
},
handleCurrentChange(val) {
const _this = this
// 清空权限与菜单的选中
this.$refs.permission.setCheckedKeys([])
this.$refs.menu.setCheckedKeys([])
// 保存当前的角色id
this.currentId = val.id
// 点击后显示按钮
this.showButton = true
// 初始化
this.menuIds = []
this.permissionIds = []
// 菜单数据需要特殊处理
val.menus.forEach(function(data, index) {
let add = true
for (let i = 0; i < val.menus.length; i++) {
if (data.id === val.menus[i].pid) {
add = false
break
}
}
if (add) {
_this.menuIds.push(data.id)
}
})
// 处理权限数据
val.permissions.forEach(function(data, index) {
_this.permissionIds.push(data.id)
})
},
savePermission() {
this.permissionLoading = true
const role = { id: this.currentId, permissions: [] }
this.$refs.permission.getCheckedKeys().forEach(function(data, index) {
const permission = { id: data }
role.permissions.push(permission)
})
editPermission(role).then(res => {
this.$notify({
title: '保存成功',
type: 'success',
duration: 2500
})
this.permissionLoading = false
this.update()
}).catch(err => {
this.permissionLoading = false
console.log(err.response.data.message)
})
},
saveMenu() {
this.menuLoading = true
const role = { id: this.currentId, menus: [] }
// 得到半选的父节点数据,保存起来
this.$refs.menu.getHalfCheckedNodes().forEach(function(data, index) {
const permission = { id: data.id }
role.menus.push(permission)
})
// 得到已选中的 key 值
this.$refs.menu.getCheckedKeys().forEach(function(data, index) {
const permission = { id: data }
role.menus.push(permission)
})
editMenu(role).then(res => {
this.$notify({
title: '保存成功',
type: 'success',
duration: 2500
})
this.menuLoading = false
this.update()
}).catch(err => {
this.menuLoading = false
console.log(err.response.data.message)
})
},
update() {
// 无刷新更新 表格数据
get(this.currentId).then(res => {
for (let i = 0; i < this.data.length; i++) {
if (res.id === this.data[i].id) {
this.data[i] = res
break
}
}
})
}
}
}
</script>
<style scoped>
.role-span {
font-weight: bold;color: #303133;
font-size: 15px;
}
</style>
<template>
<div>
<el-button :disabled="data.id === 1" size="mini" type="success" @click="to">编辑</el-button>
<eForm ref="form" :permissions="permissions" :sup_this="sup_this" :is-add="false"/>
<el-button size="mini" type="success" @click="to">编辑</el-button>
<eForm ref="form" :sup_this="sup_this" :is-add="false"/>
</div>
</template>
<script>
......@@ -16,20 +16,12 @@ export default {
sup_this: {
type: Object,
required: true
},
permissions: {
type: Array,
required: true
}
},
methods: {
to() {
const _this = this.$refs.form
_this.permissionIds = []
_this.form = { id: this.data.id, name: this.data.name, remark: this.data.remark, permissions: [] }
this.data.permissions.forEach(function(data, index) {
_this.permissionIds.push(data.id)
})
_this.dialog = true
}
}
......
......@@ -4,9 +4,6 @@
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" style="width: 370px;"/>
</el-form-item>
<el-form-item label="权限">
<treeselect v-model="permissionIds" :multiple="true" :options="permissions" style="width: 370px;" placeholder="请选择权限" />
</el-form-item>
<el-form-item style="margin-top: -10px;" label="描述">
<el-input v-model="form.remark" style="width: 370px;" rows="5" type="textarea"/>
</el-form-item>
......@@ -20,15 +17,8 @@
<script>
import { add, edit } from '@/api/role'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default {
components: { Treeselect },
props: {
permissions: {
type: Array,
required: true
},
isAdd: {
type: Boolean,
required: true
......@@ -41,7 +31,7 @@ export default {
data() {
return {
loading: false, dialog: false,
form: { name: '', permissions: [], remark: '' }, permissionIds: [],
form: { name: '', permissions: [], remark: '' },
rules: {
name: [
{ required: true, message: '请输入名称', trigger: 'blur' }
......@@ -57,12 +47,6 @@ export default {
this.$refs['form'].validate((valid) => {
if (valid) {
this.loading = true
this.form.permissions = []
const _this = this
this.permissionIds.forEach(function(data, index) {
const permission = { id: data }
_this.form.permissions.push(permission)
})
if (this.isAdd) {
this.doAdd()
} else this.doEdit()
......@@ -104,7 +88,6 @@ export default {
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.permissionIds = []
this.form = { name: '', permissions: [], remark: '' }
}
}
......
......@@ -12,7 +12,7 @@
type="primary"
icon="el-icon-plus"
@click="$refs.form.dialog = true">新增</el-button>
<eForm ref="form" :permissions="permissions" :is-add="true"/>
<eForm ref="form" :is-add="true"/>
</div>
<!-- 导出 -->
<el-button v-if="checkPermission(['ADMIN'])" :loading="downloadLoading" size="mini" class="filter-item" type="primary" icon="el-icon-download" @click="download">导出</el-button>
......@@ -30,10 +30,6 @@ export default {
query: {
type: Object,
required: true
},
permissions: {
type: Array,
required: true
}
},
data() {
......
......@@ -11,11 +11,11 @@
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" border style="width: 100%;margin-top: -10px;">
<el-table-column :show-overflow-tooltip="true" prop="jobName" width="90px" label="任务名称"/>
<el-table-column :show-overflow-tooltip="true" prop="beanName" width="90px" label="Bean名称"/>
<el-table-column :show-overflow-tooltip="true" prop="methodName" width="80px" label="执行方法"/>
<el-table-column :show-overflow-tooltip="true" prop="params" width="80px" label="参数"/>
<el-table-column :show-overflow-tooltip="true" prop="cronExpression" width="100px" label="cron表达式"/>
<el-table-column prop="createTime" label="异常详情" width="90px">
<el-table-column :show-overflow-tooltip="true" prop="beanName" width="110px" label="Bean名称"/>
<el-table-column :show-overflow-tooltip="true" prop="methodName" width="110px" label="执行方法"/>
<el-table-column :show-overflow-tooltip="true" prop="params" width="120px" label="参数"/>
<el-table-column :show-overflow-tooltip="true" prop="cronExpression" width="120px" label="cron表达式"/>
<el-table-column prop="createTime" label="异常详情" width="100px">
<template slot-scope="scope">
<el-button v-show="scope.row.exceptionDetail" size="mini" type="text" @click="info(scope.row.exceptionDetail)">查看详情</el-button>
</template>
......@@ -26,7 +26,6 @@
<el-tag :type="scope.row.isSuccess ? 'success' : 'danger'">{{ scope.row.isSuccess ? '成功' : '失败' }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="remark" width="120px" label="描述"/>
<el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
......
......@@ -33,7 +33,7 @@
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" :disabled="scope.row.id === 1" type="danger" size="mini">删除</el-button>
<el-button slot="reference" type="danger" size="mini">删除</el-button>
</el-popover>
</template>
</el-table-column>
......
<template>
<div>
<el-button :disabled="data.id === 1" size="mini" type="success" @click="to">编辑</el-button>
<el-button size="mini" type="success" @click="to">编辑</el-button>
<eForm ref="form" :roles="roles" :sup_this="sup_this" :is-add="false"/>
</div>
</template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment