Commit 01a04f2f authored by 拾柒's avatar 拾柒

修改树状列表默认显示几级的问题

parent 7ae43b29
import Vue from 'vue' import Vue from 'vue'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import moment from 'moment' import moment from 'moment'
import Element from "element-ui";
// import ElementUI from 'element-ui' // import ElementUI from 'element-ui'
// import './styles/element-variables.scss' // import './styles/element-variables.scss'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n // import locale from 'element-ui/lib/locale/lang/en' // lang i18n
...@@ -80,8 +81,8 @@ Vue.prototype.$parseDate = (value, format) => { ...@@ -80,8 +81,8 @@ Vue.prototype.$parseDate = (value, format) => {
Vue.config.productionTip = false Vue.config.productionTip = false
// 全局组件挂载 // 全局组件挂载
Vue.component('Pagination', Pagination) Vue.component('Pagination', Pagination)
Element.Dialog.props.closeOnClickModal.default = false
Vue.use(permission) Vue.use(permission,Element)
new Vue({ new Vue({
el: '#app', el: '#app',
......
...@@ -164,6 +164,7 @@ ...@@ -164,6 +164,7 @@
check-strictly check-strictly
empty-text="加载中,请稍后" empty-text="加载中,请稍后"
:props="defaultProps" :props="defaultProps"
:default-expanded-keys="updateMenu"
@check-change="handleMenuCheckChange" @check-change="handleMenuCheckChange"
/> />
</el-form-item> </el-form-item>
...@@ -178,7 +179,13 @@ ...@@ -178,7 +179,13 @@
</el-dialog> </el-dialog>
<!-- 分配角色数据权限对话框 --> <!-- 分配角色数据权限对话框 -->
<el-dialog class="roleDialog" @close='getList' title="数据权限信息" :visible.sync="openDataScope" width="900px" append-to-body> <el-dialog
class="roleDialog"
@close='getList'
title="数据权限信息"
:visible.sync="openDataScope"
width="900px"
append-to-body>
<el-row> <el-row>
<el-col style="width: 43%"> <el-col style="width: 43%">
<el-form ref="form" :model="form" :rules="rules" label-width="70px"> <el-form ref="form" :model="form" :rules="rules" label-width="70px">
...@@ -191,6 +198,7 @@ ...@@ -191,6 +198,7 @@
:data="menuList" :data="menuList"
row-key="businessId" row-key="businessId"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
default-expand-all
max-height="400px" max-height="400px"
> >
<!-- <el-form-item label="权限字符">--> <!-- <el-form-item label="权限字符">-->
...@@ -242,6 +250,7 @@ ...@@ -242,6 +250,7 @@
check-strictly check-strictly
empty-text="加载中,请稍后" empty-text="加载中,请稍后"
:props="defaultProps" :props="defaultProps"
:default-expanded-keys="customizetree"
@check-change="handleDeptCheckChange" @check-change="handleDeptCheckChange"
/> />
<!-- 修改 :check-strictly="!form.deptCheckStrictly" 改为 check-strictly --> <!-- 修改 :check-strictly="!form.deptCheckStrictly" 改为 check-strictly -->
...@@ -269,6 +278,10 @@ export default { ...@@ -269,6 +278,10 @@ export default {
components: { Coolbutton }, components: { Coolbutton },
data() { data() {
return { return {
// 修改页面默认打开的树壮菜单
updateMenu: [],
// 自定义页面默认打开的树状菜单
customizetree: [],
typeParent: 'text', typeParent: 'text',
typePrimary: 'primary', typePrimary: 'primary',
typeSuccess: 'success', typeSuccess: 'success',
...@@ -422,8 +435,8 @@ export default { ...@@ -422,8 +435,8 @@ export default {
/** 查询菜单树结构 */ /** 查询菜单树结构 */
getMenuTreeselect() { getMenuTreeselect() {
menuTreeselect().then(response => { menuTreeselect().then(response => {
console.info(response.data)
this.menuOptions = response.data this.menuOptions = response.data
this.updateMenu.push(this.menuOptions[0].id)
}) })
}, },
/** 查询菜单列表 */ /** 查询菜单列表 */
...@@ -457,8 +470,7 @@ export default { ...@@ -457,8 +470,7 @@ export default {
}) })
}, },
// 树状图节点点击选中事件 // 树状图节点点击选中事件
handleMenuCheckChange(data, check, subCheck) { handleMenuCheckChange(data, check, subCheck) {// data为选中节点信息,check选中状态
console.info(data.children)// data为选中节点信息,check选中状态
if (data.children !== undefined && data.children !== null) { // 是否包含子节点 if (data.children !== undefined && data.children !== null) { // 是否包含子节点
this.checkNode(data.children, check) // 调用checkNode方法 this.checkNode(data.children, check) // 调用checkNode方法
} }
...@@ -510,6 +522,10 @@ export default { ...@@ -510,6 +522,10 @@ export default {
return roleDeptTreeselect(roleId, menuId).then(response => { return roleDeptTreeselect(roleId, menuId).then(response => {
this.form.deptCheckStrictly = response.data.deptCheckStrictly this.form.deptCheckStrictly = response.data.deptCheckStrictly
this.deptOptions = response.data.depts this.deptOptions = response.data.depts
for(var i = 0; i<this.deptOptions[0].children.length; i++){
this.customizetree.push(this.deptOptions[0].children[0].id)
}
console.info(this.customizetree)
this.form.dataScope = this.dataScopeOptions[response.data.dataScope - 1].value this.form.dataScope = this.dataScopeOptions[response.data.dataScope - 1].value
return response return response
}) })
...@@ -536,12 +552,14 @@ export default { ...@@ -536,12 +552,14 @@ export default {
cancel() { cancel() {
this.open = false this.open = false
this.reset() this.reset()
this.updateMenu = []
}, },
// 取消按钮(数据权限) // 取消按钮(数据权限)
cancelDataScope() { cancelDataScope() {
this.openDataScope = false this.openDataScope = false
this.getList() this.getList()
this.reset() this.reset()
this.customizetree = []
}, },
// 表单重置 // 表单重置
reset() { reset() {
...@@ -667,6 +685,7 @@ export default { ...@@ -667,6 +685,7 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
this.updateMenu = []
this.$refs['form'].validate(valid => { this.$refs['form'].validate(valid => {
if (valid) { if (valid) {
this.form.menuCheckStrictly = 0 this.form.menuCheckStrictly = 0
...@@ -694,7 +713,7 @@ export default { ...@@ -694,7 +713,7 @@ export default {
this.form.deptIds = this.getDeptAllCheckedKeys() this.form.deptIds = this.getDeptAllCheckedKeys()
dataScope(this.form).then(response => { dataScope(this.form).then(response => {
this.msgSuccess('修改成功') this.msgSuccess('修改成功')
this.customizetree = []
}) })
} }
}, },
......
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