|
@@ -1,40 +1,40 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <a-spin :spinning="spinning" tip="Loading...">
|
|
|
- <a-modal
|
|
|
+ <a-modal
|
|
|
centered
|
|
|
class="modalBox"
|
|
|
:title="roleName"
|
|
|
v-model="isshow"
|
|
|
@cancel="cancel"
|
|
|
:maskClosable="false">
|
|
|
- <a-form class="form-box" style="max-height: 600px;" :form="form" @submit="handleSubmit">
|
|
|
- <a-tree
|
|
|
- checkable
|
|
|
- @check="onCheck"
|
|
|
- @expand="onExpand"
|
|
|
- :expandedKeys="expandedKeys"
|
|
|
- :autoExpandParent="autoExpandParent"
|
|
|
- v-model="checkedKeys"
|
|
|
- :treeData="treeData"
|
|
|
- />
|
|
|
- </a-form>
|
|
|
- <a-form-item :wrapper-col="{ offset: 15 }">
|
|
|
- <a-button type="primary" @click="handleSubmit()" id="menuModal-handleSubmit">
|
|
|
- 保存
|
|
|
- </a-button>
|
|
|
- <a-button :style="{ marginLeft: '8px' }" @click="cancel" id="menuModal-handleCancel">
|
|
|
- 取消
|
|
|
- </a-button>
|
|
|
- </a-form-item>
|
|
|
+ <div style="min-height: 100px;">
|
|
|
+ <a-spin :spinning="spinning" tip="Loading...">
|
|
|
+ <a-form class="form-box" style="max-height: 600px;" :form="form" @submit="handleSubmit">
|
|
|
+ <a-tree
|
|
|
+ checkable
|
|
|
+ @check="onCheck"
|
|
|
+ @expand="onExpand"
|
|
|
+ :expandedKeys="expandedKeys"
|
|
|
+ :autoExpandParent="autoExpandParent"
|
|
|
+ v-model="checkedKeys"
|
|
|
+ :treeData="treeData"
|
|
|
+ />
|
|
|
+ </a-form>
|
|
|
+ <a-form-item :wrapper-col="{ offset: 15 }">
|
|
|
+ <a-button type="primary" @click="handleSubmit()" id="menuModal-handleSubmit">
|
|
|
+ 保存
|
|
|
+ </a-button>
|
|
|
+ <a-button :style="{ marginLeft: '8px' }" @click="cancel" id="menuModal-handleCancel">
|
|
|
+ 取消
|
|
|
+ </a-button>
|
|
|
+ </a-form-item>
|
|
|
+ </a-spin>
|
|
|
+ </div>
|
|
|
</a-modal>
|
|
|
- </a-spin>
|
|
|
- </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { STable, VSelect } from '@/components'
|
|
|
-import { addMenuPower } from '@/api/powerRole-md.js'
|
|
|
+import { addMenuPower, getMenuList } from '@/api/powerRole-md.js'
|
|
|
export default {
|
|
|
name: 'RoleModal',
|
|
|
components: {
|
|
@@ -45,17 +45,12 @@ export default {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
},
|
|
|
- data: {
|
|
|
- type: Object,
|
|
|
- default: function () {
|
|
|
- return {}
|
|
|
- }
|
|
|
- }
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
spinning: false,
|
|
|
treeData: [],
|
|
|
+ menuData: null,
|
|
|
roleName: '',
|
|
|
expandedKeys: [],
|
|
|
autoExpandParent: true,
|
|
@@ -130,7 +125,38 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ getmenuData(id){
|
|
|
+ this.spinning = true
|
|
|
+ getMenuList({
|
|
|
+ id: id
|
|
|
+ }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ if(res.data.role){
|
|
|
+ this.setmenuData(res.data)
|
|
|
+ }else{
|
|
|
+ this.$message.error("获取数据失败,请重试!")
|
|
|
+ this.isshow = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.spinning = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setmenuData(newValue){
|
|
|
+ this.menuData = newValue
|
|
|
+ console.log(this.menuData)
|
|
|
+ if (newValue) { // 编辑
|
|
|
+ this.treeData = this.menuData.allMenuList
|
|
|
+ this.id = this.menuData.role.id
|
|
|
+ this.roleName = '分配权限' + '(' + this.menuData.role.name + ')'
|
|
|
+ if (this.menuData.role.menuIds) {
|
|
|
+ const arr = this.menuData.role.menuIds.split(',')
|
|
|
+ this.checkedData = arr
|
|
|
+ // 找出叶子节点
|
|
|
+ this.findLeaf(this.treeData, arr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
beforeCreate () {
|
|
|
this.form = this.$form.createForm(this, { name: 'menuModal' })
|
|
@@ -140,19 +166,7 @@ export default {
|
|
|
this.isshow = newValue
|
|
|
},
|
|
|
isshow (newValue, oldValue) {
|
|
|
- if (newValue) {
|
|
|
- if (this.data) { // 编辑
|
|
|
- this.treeData = this.data.allMenuList
|
|
|
- this.id = this.data.role.id
|
|
|
- this.roleName = '分配权限' + '(' + this.data.role.name + ')'
|
|
|
- if (this.data.role.menuIds) {
|
|
|
- const arr = this.data.role.menuIds.split(',')
|
|
|
- this.checkedData = arr
|
|
|
- // 找出叶子节点
|
|
|
- this.findLeaf(this.treeData, arr)
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (!newValue) {
|
|
|
this.cancel()
|
|
|
}
|
|
|
}
|