|
|
@@ -31,8 +31,8 @@
|
|
|
<!-- 全选 -->
|
|
|
<b>{{ item.name }}</b>
|
|
|
<el-checkbox
|
|
|
- :indeterminate="isIndeterminate[item.code]"
|
|
|
- v-model="checkAll[item.code]"
|
|
|
+ :indeterminate="isIndeterminate[item.id]"
|
|
|
+ v-model="checkAll[item.id]"
|
|
|
@change="handleCheckAllChange($event,item)"
|
|
|
>
|
|
|
</el-checkbox>
|
|
|
@@ -82,7 +82,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { cloneDeep } from 'lodash'
|
|
|
+import { cloneDeep, map } from 'lodash'
|
|
|
import { getPermissionTree, editRole } from '@/api/systemSetting/role'
|
|
|
|
|
|
export default {
|
|
|
@@ -168,8 +168,8 @@ export default {
|
|
|
this.isIndeterminateAll = false
|
|
|
|
|
|
this.permissionList.forEach(item => {
|
|
|
- this.isIndeterminate[item.code] = false
|
|
|
- this.checkAll[item.code] = val
|
|
|
+ this.isIndeterminate[item.id] = false
|
|
|
+ this.checkAll[item.id] = val
|
|
|
})
|
|
|
},
|
|
|
// 单模块全选
|
|
|
@@ -191,7 +191,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- this.isIndeterminate[module.code] = false
|
|
|
+ this.isIndeterminate[module.id] = false
|
|
|
|
|
|
this.checkAllStatus()
|
|
|
},
|
|
|
@@ -205,9 +205,9 @@ export default {
|
|
|
})
|
|
|
let checkedCount = intersection.length
|
|
|
// 单模块全选
|
|
|
- this.checkAll[module.code] = checkedCount === module.permissions.length
|
|
|
+ this.checkAll[module.id] = checkedCount === module.permissions.length
|
|
|
// 单模块不确定状态
|
|
|
- this.isIndeterminate[module.code] = checkedCount > 0 && checkedCount < module.permissions.length
|
|
|
+ this.isIndeterminate[module.id] = checkedCount > 0 && checkedCount < module.permissions.length
|
|
|
|
|
|
this.checkAllStatus()
|
|
|
},
|
|
|
@@ -229,26 +229,22 @@ export default {
|
|
|
if (val && this.roleItem) {
|
|
|
this.form = cloneDeep(this.roleItem)
|
|
|
const { resourceList } = this.roleItem
|
|
|
- this.selectPermission = []
|
|
|
+ this.selectPermission = map(resourceList, 'id')
|
|
|
|
|
|
- resourceList.forEach(item => {
|
|
|
- this.selectPermission.push(item)
|
|
|
+ this.permissionList.forEach(item => {
|
|
|
+ const cLength = item.children ? item.children.length : 0
|
|
|
|
|
|
- if (item.children) {
|
|
|
- this.selectPermission.push(...item.children)
|
|
|
+ if (cLength > 0) {
|
|
|
+ // 交集
|
|
|
+ const hasOne = item.children.some(i => this.selectPermission.includes(i.id))
|
|
|
+ const hasAll = item.children.every(i => this.selectPermission.includes(i.id))
|
|
|
+ // 单模块全选
|
|
|
+ this.checkAll[item.id] = !!hasAll
|
|
|
+ // 单模块不确定状态
|
|
|
+ this.isIndeterminate[item.id] = !hasAll && hasOne
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- this.permissionList.forEach(item => {
|
|
|
- // 交集
|
|
|
- const intersection = this.selectPermission.find(val => val.id === item.id)
|
|
|
- const checkedCount = intersection && intersection.children ? intersection.children.length : 0
|
|
|
- // 单模块全选
|
|
|
- this.checkAll[item.code] = checkedCount === item.permissions.length
|
|
|
- // 单模块不确定状态
|
|
|
- this.isIndeterminate[item.code] = checkedCount > 0 && checkedCount < item.permissions.length
|
|
|
- })
|
|
|
-
|
|
|
this.checkAllStatus()
|
|
|
}
|
|
|
}
|