1.7版本发布,详情查看版本说明
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
<eHeader :query="query"/>
|
||||
<!--表格渲染-->
|
||||
<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 v-loading="loading" :data="data" highlight-current-row size="small" style="width: 100%;" @current-change="handleCurrentChange">
|
||||
<el-table-column prop="name" label="名称"/>
|
||||
<el-table-column prop="dataScope" label="数据权限"/>
|
||||
<el-table-column prop="remark" label="描述"/>
|
||||
<el-table-column prop="createTime" label="创建日期">
|
||||
<template slot-scope="scope">
|
||||
@@ -53,7 +54,7 @@
|
||||
type="info"
|
||||
@click="savePermission">保存</el-button>
|
||||
</div>
|
||||
<div :style="'min-height: 200px;max-height:' + height + 'overflow-y: auto;'">
|
||||
<div style="min-height: 320px;max-height:500px;overflow-y: auto;">
|
||||
<el-tree
|
||||
ref="permission"
|
||||
:data="permissions"
|
||||
@@ -78,7 +79,7 @@
|
||||
type="info"
|
||||
@click="saveMenu">保存</el-button>
|
||||
</div>
|
||||
<div :style="'min-height: 207px;max-height:' + height + 'overflow-y: auto;'">
|
||||
<div style="min-height: 320px;max-height:500px;overflow-y: auto;">
|
||||
<el-tree
|
||||
ref="menu"
|
||||
:data="menus"
|
||||
@@ -124,6 +125,12 @@ export default {
|
||||
this.init()
|
||||
})
|
||||
},
|
||||
mounted: function() {
|
||||
const that = this
|
||||
window.onresize = function temp() {
|
||||
that.height = document.documentElement.clientHeight - 94.5 - 260 + 'px;'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
parseTime,
|
||||
checkPermission,
|
||||
@@ -167,34 +174,36 @@ export default {
|
||||
})
|
||||
},
|
||||
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 (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)
|
||||
})
|
||||
if (add) {
|
||||
_this.menuIds.push(data.id)
|
||||
}
|
||||
})
|
||||
// 处理权限数据
|
||||
val.permissions.forEach(function(data, index) {
|
||||
_this.permissionIds.push(data.id)
|
||||
})
|
||||
}
|
||||
},
|
||||
savePermission() {
|
||||
this.permissionLoading = true
|
||||
|
||||
@@ -21,7 +21,14 @@ export default {
|
||||
methods: {
|
||||
to() {
|
||||
const _this = this.$refs.form
|
||||
_this.form = { id: this.data.id, name: this.data.name, remark: this.data.remark, permissions: [] }
|
||||
_this.deptIds = []
|
||||
_this.form = { id: this.data.id, name: this.data.name, remark: this.data.remark, depts: this.data.depts, dataScope: this.data.dataScope }
|
||||
if (_this.form.dataScope === '自定义') {
|
||||
_this.getDepts()
|
||||
}
|
||||
for (let i = 0; i < _this.form.depts.length; i++) {
|
||||
_this.deptIds[i] = _this.form.depts[i].id
|
||||
}
|
||||
_this.dialog = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
<template>
|
||||
<el-dialog :visible.sync="dialog" :title="isAdd ? '新增角色' : '编辑角色'" append-to-body width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="66px">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
||||
<el-form-item label="角色名称" prop="name">
|
||||
<el-input v-model="form.name" style="width: 370px;"/>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-top: -10px;" label="描述">
|
||||
<el-form-item label="数据范围">
|
||||
<el-select v-model="form.dataScope" style="width: 370px" placeholder="请选择数据范围" @change="changeScope">
|
||||
<el-option
|
||||
v-for="item in dateScopes"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.dataScope === '自定义'" label="数据权限">
|
||||
<treeselect v-model="deptIds" :options="depts" multiple style="width: 370px" placeholder="请选择" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述信息">
|
||||
<el-input v-model="form.remark" style="width: 370px;" rows="5" type="textarea"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -16,8 +28,12 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getDepts } from '@/api/dept'
|
||||
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: {
|
||||
isAdd: {
|
||||
type: Boolean,
|
||||
@@ -30,8 +46,9 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false, dialog: false,
|
||||
form: { name: '', permissions: [], remark: '' },
|
||||
dateScopes: ['全部', '本级', '自定义'],
|
||||
loading: false, dialog: false, depts: [], deptIds: [],
|
||||
form: { name: '', depts: [], remark: '', dataScope: '本级' },
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '请输入名称', trigger: 'blur' }
|
||||
@@ -44,16 +61,31 @@ export default {
|
||||
this.resetForm()
|
||||
},
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
if (this.isAdd) {
|
||||
this.doAdd()
|
||||
} else this.doEdit()
|
||||
} else {
|
||||
return false
|
||||
if (this.form.dataScope === '自定义' && this.deptIds.length === 0) {
|
||||
this.$message({
|
||||
message: '自定义数据权限不能为空',
|
||||
type: 'warning'
|
||||
})
|
||||
} else {
|
||||
this.form.depts = []
|
||||
if (this.form.dataScope === '自定义') {
|
||||
for (let i = 0; i < this.deptIds.length; i++) {
|
||||
this.form.depts.push({
|
||||
id: this.deptIds[i]
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
if (this.isAdd) {
|
||||
this.doAdd()
|
||||
} else this.doEdit()
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
doAdd() {
|
||||
add(this.form).then(res => {
|
||||
@@ -88,7 +120,17 @@ export default {
|
||||
resetForm() {
|
||||
this.dialog = false
|
||||
this.$refs['form'].resetFields()
|
||||
this.form = { name: '', permissions: [], remark: '' }
|
||||
this.form = { name: '', depts: [], remark: '', dataScope: '本级' }
|
||||
},
|
||||
getDepts() {
|
||||
getDepts({ enabled: true }).then(res => {
|
||||
this.depts = res.content
|
||||
})
|
||||
},
|
||||
changeScope() {
|
||||
if (this.form.dataScope === '自定义') {
|
||||
this.getDepts()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user