mirror of https://gitee.com/xiaonuobase/snowy
【更新】修复错误
parent
d42dfbc806
commit
daa75e6594
|
@ -36,20 +36,20 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {SysMenuTreeForGrant} from '@/api/modular/system/menuManage'
|
||||
import {sysRoleOwnMenu, sysRoleGrantMenu} from '@/api/modular/system/roleManage'
|
||||
import { SysMenuTreeForGrant } from '@/api/modular/system/menuManage'
|
||||
import { sysRoleOwnMenu, sysRoleGrantMenu } from '@/api/modular/system/roleManage'
|
||||
|
||||
export default {
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
labelCol: {
|
||||
style: {'padding-right': '20px'},
|
||||
xs: {span: 24},
|
||||
sm: {span: 5}
|
||||
style: { 'padding-right': '20px' },
|
||||
xs: { span: 24 },
|
||||
sm: { span: 5 }
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: {span: 24},
|
||||
sm: {span: 15}
|
||||
xs: { span: 24 },
|
||||
sm: { span: 15 }
|
||||
},
|
||||
menuTreeData: [],
|
||||
expandedKeys: [],
|
||||
|
@ -97,7 +97,7 @@ export default {
|
|||
})
|
||||
},
|
||||
|
||||
getLeastChilds(data){
|
||||
getLeastChilds(data) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
this.pushLeastChilds(data[i])
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ export default {
|
|||
*/
|
||||
expandedMenuKeys(record) {
|
||||
const _this = this
|
||||
sysRoleOwnMenu({id: record.id}).then((res) => {
|
||||
sysRoleOwnMenu({ id: record.id }).then((res) => {
|
||||
if (res.success) {
|
||||
_this.pickCheckedKeys(res.data)
|
||||
_this.commitKeys = res.data
|
||||
|
@ -125,7 +125,7 @@ export default {
|
|||
})
|
||||
},
|
||||
|
||||
pickCheckedKeys(data){
|
||||
pickCheckedKeys(data) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if (this.leastChilds.includes(data[i])) {
|
||||
this.checkedKeys.push(data[i])
|
||||
|
@ -140,7 +140,7 @@ export default {
|
|||
|
||||
onCheck(checkedKeys, info) {
|
||||
this.checkedKeys = checkedKeys
|
||||
this.commitKeys = checkedKeys.concat(info.halfCheckedKeys);
|
||||
this.commitKeys = checkedKeys.concat(info.halfCheckedKeys)
|
||||
},
|
||||
|
||||
onSelect(selectedKeys, info) {
|
||||
|
@ -150,12 +150,12 @@ export default {
|
|||
},
|
||||
|
||||
handleSubmit() {
|
||||
const _this = this;
|
||||
const {form: {validateFields}} = this
|
||||
const _this = this
|
||||
const { form: { validateFields } } = this
|
||||
this.confirmLoading = true
|
||||
validateFields((errors, values) => {
|
||||
if (!errors) {
|
||||
sysRoleGrantMenu({id: _this.roleEntity.id, grantMenuIdList: _this.commitKeys}).then((res) => {
|
||||
sysRoleGrantMenu({ id: _this.roleEntity.id, grantMenuIdList: _this.commitKeys }).then((res) => {
|
||||
if (res.success) {
|
||||
_this.$message.success('授权成功')
|
||||
_this.confirmLoading = false
|
||||
|
@ -180,5 +180,5 @@ export default {
|
|||
this.visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -28,13 +28,14 @@
|
|||
<a-tree
|
||||
v-model="checkedKeys"
|
||||
checkable
|
||||
checkStrictly
|
||||
:auto-expand-parent="autoExpandParent"
|
||||
:expanded-keys="expandedKeys"
|
||||
:tree-data="orgTreeData"
|
||||
:selected-keys="selectedKeys"
|
||||
:replaceFields="replaceFields"
|
||||
@expand="onExpand"
|
||||
@check="onCheck"
|
||||
@select="onSelect"
|
||||
/>
|
||||
</a-form-item>
|
||||
</div>
|
||||
|
@ -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,19 +123,13 @@
|
|||
* 获取机构树
|
||||
*/
|
||||
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)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -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('授权成功')
|
||||
|
|
Loading…
Reference in New Issue