Commit b576806e by 胡悦

提交账户权限

1 parent e6b5b58c
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
v-model="accountRuleForm.requestList" v-model="accountRuleForm.requestList"
value-key="dictValue" value-key="dictValue"
@change="authChange" @change="authChange"
@visible-change="authVisibleChange"
:size="btn_size" :size="btn_size"
multiple multiple
placeholder="请选择" placeholder="请选择"
...@@ -95,9 +94,10 @@ ...@@ -95,9 +94,10 @@
show-checkbox show-checkbox
node-key="id" node-key="id"
default-expand-all default-expand-all
:check-strictly="true"
:expand-on-click-node="false" :expand-on-click-node="false"
:render-content="renderContent" :render-content="renderContent"
@node-expand="nodeExpand" @check="getCurrentNode"
> >
</el-tree> </el-tree>
</el-card> </el-card>
...@@ -142,7 +142,8 @@ export default { ...@@ -142,7 +142,8 @@ export default {
responseList: [], responseList: [],
changeList: [], changeList: [],
lastList: [], lastList: [],
checkStrictly: true checkStrictly: true,
flag: true
} }
}, },
mounted() { mounted() {
...@@ -177,20 +178,17 @@ export default { ...@@ -177,20 +178,17 @@ export default {
getAllId(data, arr = []) { getAllId(data, arr = []) {
if (data) { if (data) {
data.forEach(item => { data.forEach(item => {
arr.push(item.id)
if (item.children && item.children.length != 0) { if (item.children && item.children.length != 0) {
item.children.forEach(i => { item.children.forEach(i => {
this.getAllId(i.children)
arr.push(i.id) arr.push(i.id)
this.getAllId(i.children, arr)
}) })
} }
arr.push(item.id)
}) })
} }
return arr return arr
}, },
// 展开节点
nodeExpand(a, node, c) {
},
addStyle() { addStyle() {
const nodes = document.getElementsByClassName('fun-tree-node') const nodes = document.getElementsByClassName('fun-tree-node')
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
...@@ -198,53 +196,6 @@ export default { ...@@ -198,53 +196,6 @@ export default {
parentNode.style.float = 'left' parentNode.style.float = 'left'
} }
}, },
authVisibleChange(val) {
// if (!val && this.accountRuleForm.requestList.length !== 0) {
// this.activeName = this.accountRuleForm.requestList[0].dictLabel
// // const arr = this.accountRuleForm.requestList
// // const productId = arr.map(item => item.dictValue)
// const productId = []
// const arr = this.accountRuleForm.requestList.map(item => item.dictValue)
// arr.forEach(item => {
// if (!this.changeList.includes(item)) {
// productId.push(item)
// }
// })
// const params = { productId }
// console.log(productId)
// // { productId, accountTypeId: 1 }
// if (this.$Common.getParams().id) params.accountTypeId = this.$Common.getParams().id
// accountApi.findProductById(params).then(res => {
// if (res.code == '0') {
// this.changeList = arr
// this.treeData.push(_.cloneDeep(res.data[0]))
// // this.treeData = _.cloneDeep(res.data)
// if (this.$Common.getParams().id && this.responseList.length != 0) {
// // 编辑
// this.$nextTick(() => {
// this.responseList.forEach((item, index) => {
// if (this.$refs[`tree${index}`][0]) {
// this.$refs[`tree${index}`][0].setCheckedKeys(item.idList)
// // this.$refs[`tree${index}`][0].setCheckedKeys([98])
// }
// })
// this.addStyle()
// })
// } else {
// // 新增
// this.$nextTick(() => {
// this.treeData.forEach((i, idx) => {
// if (this.$refs[`tree${idx}`][0]) { // 可能被删除了
// this.$refs[`tree${idx}`][0].setCheckedKeys(this.getAllId(i.children))
// }
// })
// this.addStyle()
// })
// }
// }
// })
// }
},
authChange(val) { authChange(val) {
console.log(val) console.log(val)
if (val.length != 0) { if (val.length != 0) {
...@@ -258,14 +209,12 @@ export default { ...@@ -258,14 +209,12 @@ export default {
if (this.accountParams.id) params.accountTypeId = this.accountParams.id if (this.accountParams.id) params.accountTypeId = this.accountParams.id
accountApi.findProductById(params).then(res => { accountApi.findProductById(params).then(res => {
if (res.code == '0') { if (res.code == '0') {
// this.changeList = arr
this.treeData.push(_.cloneDeep(res.data[0])) this.treeData.push(_.cloneDeep(res.data[0]))
// if (this.responseList.length != 0) {
// 新增默认全选 // 新增默认全选
const len = this.treeData.length - 1 const len = this.treeData.length - 1
console.log(len, this.$refs[`tree${len}`], this.treeData[len].children)
this.$nextTick(() => { this.$nextTick(() => {
this.$refs[`tree${len}`][0].setCheckedNodes(this.treeData[len].children) // this.$refs[`tree${len}`][0].setCheckedNodes(this.treeData[len].children)
this.$refs[`tree${len}`][0].setCheckedKeys(this.getAllId(this.treeData[len].children))
}) })
// } // }
} }
...@@ -273,28 +222,29 @@ export default { ...@@ -273,28 +222,29 @@ export default {
} else { } else {
// 删除 // 删除
const arr = val.map(item => item.dictValue) const arr = val.map(item => item.dictValue)
console.log(this.lastList, arr, 'shanchu')
for (let i = 0; i < this.lastList.length; i++) { for (let i = 0; i < this.lastList.length; i++) {
console.log(arr.includes(this.lastList[i].dictValue), this.treeData[i])
if (!arr.includes(this.lastList[i].dictValue)) { if (!arr.includes(this.lastList[i].dictValue)) {
this.treeData.splice(i, 1) this.treeData.splice(i, 1)
break break
} }
} }
this.lastList = val this.lastList = val
console.log(this.treeData)
} }
} else { } else {
this.treeData = [] this.treeData = []
} }
}, },
getCurrentNode(data) {
console.log(data)
},
btnClick(type, index) { btnClick(type, index) {
switch (type) { switch (type) {
case 'allTree': case 'allTree':
this.$refs[`tree${index}`][0].setCheckedNodes(this.treeData[index].children) // this.$refs[`tree${index}`][0].setCheckedNodes(this.treeData[index].children)
this.$refs[`tree${index}`][0].setCheckedKeys(this.getAllId(this.treeData[index].children))
break break
case 'cancelAllTree': case 'cancelAllTree':
this.$refs[`tree${index}`][0].setCheckedNodes([]) this.$refs[`tree${index}`][0].setCheckedKeys([])
break break
// eslint-disable-next-line no-case-declarations // eslint-disable-next-line no-case-declarations
case 'resetTree': case 'resetTree':
...@@ -336,6 +286,10 @@ export default { ...@@ -336,6 +286,10 @@ export default {
const requestList = this.getRequestList() const requestList = this.getRequestList()
this.$refs.accountRuleForm.validate(valid => { this.$refs.accountRuleForm.validate(valid => {
if (valid) { if (valid) {
if (!this.flag) {
this.notice.errorTips('有节点的父节点未选中')
return
}
const params = { const params = {
accounttypeName: this.accountRuleForm.accounttypeName, accounttypeName: this.accountRuleForm.accounttypeName,
requestList, requestList,
...@@ -369,15 +323,26 @@ export default { ...@@ -369,15 +323,26 @@ export default {
getRequestList() { getRequestList() {
const requestList = [] const requestList = []
console.log(this.accountRuleForm.requestList) console.log(this.accountRuleForm.requestList)
this.flag = true
this.accountRuleForm.requestList.forEach((item, index) => { this.accountRuleForm.requestList.forEach((item, index) => {
const checkedNodes = this.$refs[`tree${index}`][0].getCheckedNodes() const checkedNodes = this.$refs[`tree${index}`][0].getCheckedNodes()
const halfCheckedNodes = this.$refs[`tree${index}`][0].getHalfCheckedNodes() const checkedKeys = this.$refs[`tree${index}`][0].getCheckedKeys()
const nodes = checkedNodes.concat(halfCheckedNodes) // const halfCheckedNodes = this.$refs[`tree${index}`][0].getHalfCheckedNodes()
console.log(nodes) // const nodes = checkedNodes
// .concat(halfCheckedNodes)
checkedNodes.forEach(i => {
if (i.parentId) {
if (!checkedKeys.includes(i.parentId)) {
this.flag = false
return false
}
}
})
if (!this.flag) return
const menuIdList = checkedNodes.filter(item => item.logo === 'menu').map(i => i.id) // 全选菜单idlist const menuIdList = checkedNodes.filter(item => item.logo === 'menu').map(i => i.id) // 全选菜单idlist
const partSelectList = halfCheckedNodes.filter(item => item.logo === 'menu').map(i => i.id) // 半选菜单idlist // const partSelectList = halfCheckedNodes.filter(item => item.logo === 'menu').map(i => i.id) // 半选菜单idlist
const functionIdList = nodes.filter(item => item.logo === 'function') const functionIdList = checkedNodes.filter(item => item.logo === 'function')
const functionValueIdLists = nodes.filter(item => item.logo === 'functionValue') const functionValueIdLists = checkedNodes.filter(item => item.logo === 'functionValue')
var list = [] var list = []
/** { menuId, id, functionValue} */ /** { menuId, id, functionValue} */
if (functionValueIdLists.length !== 0) { if (functionValueIdLists.length !== 0) {
...@@ -406,7 +371,7 @@ export default { ...@@ -406,7 +371,7 @@ export default {
const obj = { const obj = {
productId: item.dictValue, productId: item.dictValue,
menuIdList: menuIdList, menuIdList: menuIdList,
partSelectList: partSelectList, partSelectList: [],
functionIdList: list functionIdList: list
} }
requestList.push(obj) requestList.push(obj)
...@@ -441,7 +406,6 @@ export default { ...@@ -441,7 +406,6 @@ export default {
requestList: requestList requestList: requestList
} }
if (requestList.length != 0) { if (requestList.length != 0) {
// this.authVisibleChange(false)
this.activeName = requestList[0].dictLabel this.activeName = requestList[0].dictLabel
const productId = requestList.map(item => item.dictValue) const productId = requestList.map(item => item.dictValue)
const params = { productId } const params = { productId }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!