From daa75e6594dc52669c752508a6ef3ff592104fb5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E8=AF=BA?= <1253070437@qq.com>
Date: Fri, 16 Apr 2021 13:26:44 +0800
Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E4=BF=AE?=
=?UTF-8?q?=E5=A4=8D=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
_web/src/views/system/role/roleMenuForm.vue | 258 ++++++++++----------
_web/src/views/system/role/roleOrgForm.vue | 66 ++---
2 files changed, 148 insertions(+), 176 deletions(-)
diff --git a/_web/src/views/system/role/roleMenuForm.vue b/_web/src/views/system/role/roleMenuForm.vue
index 0c66d85a..afef4dca 100644
--- a/_web/src/views/system/role/roleMenuForm.vue
+++ b/_web/src/views/system/role/roleMenuForm.vue
@@ -36,149 +36,149 @@
diff --git a/_web/src/views/system/role/roleOrgForm.vue b/_web/src/views/system/role/roleOrgForm.vue
index 7613ec59..e23e848c 100644
--- a/_web/src/views/system/role/roleOrgForm.vue
+++ b/_web/src/views/system/role/roleOrgForm.vue
@@ -28,13 +28,14 @@
@@ -75,9 +76,7 @@
replaceFields: {
key: 'id'
},
- form: this.$form.createForm(this),
- commitKeys: [],
- leastChilds: []
+ form: this.$form.createForm(this)
}
},
@@ -111,6 +110,8 @@
this.orgTreeShow = true
// 获取机构树
this.getOrgTree()
+ // 已关联数据
+ this.sysRoleOwnData(this.roleEntity)
} else {
this.orgTreeShow = false
// 清理已选中机构
@@ -122,20 +123,14 @@
* 获取机构树
*/
getOrgTree () {
- const _this = this
getOrgTree().then((res) => {
- if (res.success) {
- this.orgTreeData = res.data
-
- _this.getLeastChilds(res.data)
- // 默认展开
- this.orgTreeData.forEach(item => {
- this.expandedKeys.push(item.id)
- })
-
- // 已关联数据
- this.sysRoleOwnData(_this.roleEntity)
- }
+ if (res.success) {
+ this.orgTreeData = res.data
+ // 默认展开
+ this.orgTreeData.forEach(item => {
+ this.expandedKeys.push(item.id)
+ })
+ }
})
},
@@ -143,57 +138,34 @@
* 此角色已有数据列表
*/
sysRoleOwnData (record) {
- const _this = this
sysRoleOwnData({ id: record.id }).then((res) => {
if (res.success) {
- _this.pickCheckedKeys(res.data)
- _this.commitKeys = res.data
+ console.log(JSON.stringify(res.data))
+ this.checkedKeys = res.data
}
this.formLoading = false
})
},
- getLeastChilds(data){
- for (let i = 0; i < data.length; i++) {
- this.pushLeastChilds(data[i])
- }
- },
-
- pushLeastChilds(e) {
- if (e.children.length > 0) {
- this.getLeastChilds(e.children)
- return
- }
- this.leastChilds.push(e.id)
- },
-
- pickCheckedKeys(data){
- for (let i = 0; i < data.length; i++) {
- if (this.leastChilds.includes(data[i])) {
- this.checkedKeys.push(data[i])
- }
- }
- },
-
onExpand (expandedKeys) {
this.expandedKeys = expandedKeys
this.autoExpandParent = false
},
- onCheck (checkedKeys, info) {
+ onCheck (checkedKeys) {
+ console.log(JSON.stringify(checkedKeys))
this.checkedKeys = checkedKeys
- this.commitKeys = checkedKeys.concat(info.halfCheckedKeys);
},
onSelect (selectedKeys, info) {
this.selectedKeys = selectedKeys
},
handleSubmit () {
- const _this = this
const { form: { validateFields } } = this
this.confirmLoading = true
validateFields((errors, values) => {
if (!errors) {
- sysRoleGrantData({ id: this.roleEntity.id, grantOrgIdList: _this.commitKeys, dataScopeType: values.dataScopeType }).then((res) => {
+ const checkedKeys = this.checkedKeys.checked === undefined ? this.checkedKeys : this.checkedKeys.checked
+ sysRoleGrantData({ id: this.roleEntity.id, grantOrgIdList: checkedKeys, dataScopeType: values.dataScopeType }).then((res) => {
this.confirmLoading = false
if (res.success) {
this.$message.success('授权成功')
@@ -222,4 +194,4 @@
}
}
}
-
\ No newline at end of file
+