Commit 86058006 by 杨北旺

角色修改获取所以角色权限/查看详情树三级以上横向展示

1 parent e26ea395
......@@ -18,10 +18,10 @@
<el-input size="small" disabled style="width: 40%" v-model="ruleForm.merchantName"></el-input>
</el-form-item>
<el-form-item label="角色名称" prop="roleName">
<el-input size="small" maxlength="20" show-word-limit style="width: 40%" v-model="ruleForm.roleName" placeholder="请输入角色名称"></el-input>
<el-input size="small" maxlength="20" show-word-limit style="width: 40%;padding-right:50px" v-model="ruleForm.roleName" placeholder="请输入角色名称"></el-input>
</el-form-item>
<el-form-item label="角色说明" prop="roleDesc">
<el-input size="small" maxlength="50" show-word-limit style="width: 40%" v-model="ruleForm.roleDesc" placeholder="请输入角色说明"></el-input>
<el-input size="small" maxlength="50" show-word-limit style="width: 40%;padding-right:50px" v-model="ruleForm.roleDesc" placeholder="请输入角色说明"></el-input>
</el-form-item>
<!-- <el-form-item label="角色权限" prop="roleRoot">
<div class="custom_element">
......@@ -124,12 +124,13 @@ export default {
roleDesc: res.roleDescription,
merchantId: res.merchantId
}
this.getMerchantTree(id, res.responseList)
this.$refs.productFrom.accountTypeSearchRequest({ id: res.merchantId }, this.roleInfo.responseList)
this.selectMerchant(res.merchantId,res.responseList)
// this.getMerchantTree(id, res.responseList)
this.$refs.productFrom.accountTypeSearchRequest({ id: res.merchantId }, res.responseList)
this.rootList = res.responseList || []
if (res.delFlag == 1) {
this.selectMerchant(res.merchantId)
}
// if (res.delFlag == 1) {
// this.selectMerchant(res.merchantId,res.responseList)
// }
})
},
// 获取商户树
......@@ -169,12 +170,22 @@ export default {
// }
// },
// 选择商户----获取权限
async selectMerchant(id) {
async selectMerchant(id,list) {
let res = await this.$refs.productFrom.findMenuFunTreeByMerId({ id })
this.accountListSelect = res.map(item => {
item.select = false
return item
})
if(this.pageType=='edit'){
this.accountListSelect = this.accountListSelect.map(item=>{
list.forEach(key=>{
if( item.accounttypeId==key.accounttypeId){
item.select = true
}
})
return item
})
}
// this.rootList = this.accountListSelect
},
// 选择商户权限
......
......@@ -31,7 +31,7 @@
<div v-for="(item, index) in productList" :key="index" class="line_element_two" :class="curProductIndex == index ? 'line_element_two_active' : ''" @click="selectProductItem(index)">{{ item.productName }}</div>
</div>
<div class="tree_widget">
<el-tree v-if="productList.length" default-expand-all :data="newTreeList" :props="defaultProps"></el-tree>
<el-tree :render-content="renderContent" v-if="productList.length" default-expand-all :data="newTreeList" :props="defaultProps"></el-tree>
<div v-if="productList.length == 0" class="no_data_icon">
<div class="nodata_wrap">
<img class="icon" src="../../assets/img/empty.png" />
......@@ -98,8 +98,9 @@ export default {
this.$apis.role.roleTreeDataById({ id }).then(res => {
this.rootList = res
this.productList = this.rootList[0].products || []
if(this.productList.length){
this.newTreeList = this.productList[0].merchantProTreeResponses || []
if (this.productList.length) {
this.newTreeList = this.productList[0].merchantProTreeResponses || []
this.handlerTreeDom()
}
})
},
......@@ -107,17 +108,86 @@ export default {
this.curRootIndex = index
this.productList = this.rootList[index].products || []
this.curProductIndex = 0
if(this.productList.length){
this.newTreeList = this.productList[0].merchantProTreeResponses || []
if (this.productList.length) {
this.newTreeList = this.productList[0].merchantProTreeResponses || []
this.handlerTreeDom()
}
},
selectProductItem(index) {
this.curProductIndex = index
let productList = this.productList
this.newTreeList = productList[index].merchantProTreeResponses || []
this.handlerTreeDom()
},
toBack() {
history.go(-1)
},
// 递归:处理某个值
traverse(arr = [],count = 0) {
count++
arr.map(item => {
if (item.children && item.children instanceof Array) {
item.perms = false
this.traverse(item.children,count)
}else if(!item.children&&count>3){
item.perms = true
}
item.count = count
return item
})
return arr
},
// 调用此方法去重构树节点
handlerTreeDom() {
this.newTreeList = this.traverse(this.newTreeList)
// if (this.newTreeList.length) {
// this.newTreeList.map(item => {
// if (item.children) {
// item.children.map(el => {
// if (el.children) {
// el.children.map(ele => {
// if (ele.children) {
// ele.perms = false
// ele.children.map(elel => {
// elel.perms = true
// return elel
// })
// } else {
// ele.perms = true
// }
// return ele
// })
// }
// el.perms = false
// return el
// })
// }
// item.perms = false
// return item
// })
// }
console.log(this.newTreeList, '*******')
this.$nextTick(() => {
this.changeTreeClass()
})
},
// 处理树横向
renderContent(h, { node, data }) {
let className = ''
if (data.perms) {
className = 'especially'
}
return <div class={className}>{data.label}</div>
},
// 改变tree节点样式
changeTreeClass() {
var classDomList = document.getElementsByClassName('especially')
for (var i = 0; i < classDomList.length; i++) {
classDomList[i].parentNode.style.cssText = 'float:left'
classDomList[i].parentNode.className = 'el-tree-node__content option-wrapper'
classDomList[i].parentNode.parentNode.parentNode.style.marginLeft = '20px'
}
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!