mirror of
https://github.com/veops/cmdb.git
synced 2025-08-08 20:07:16 +08:00
角色授权
This commit is contained in:
@@ -299,7 +299,6 @@ export default {
|
||||
if (rtypeId) {
|
||||
this.currentType = this.allResourceTypes.find((item) => item.id === rtypeId)
|
||||
}
|
||||
p
|
||||
this.searchData()
|
||||
},
|
||||
handlePerm(record) {
|
||||
|
@@ -27,7 +27,7 @@
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">授权用户/部门</span>
|
||||
<!-- <span class="grant-button" @click="grantRole">授权角色</span> -->
|
||||
<span class="grant-button" @click="grantRole">授权角色</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
@@ -199,24 +199,33 @@ export default {
|
||||
this.$refs.grantModal.open('depart')
|
||||
this.grantType = grantType
|
||||
},
|
||||
// 授权common-setting中的角色 从中拿到roleid
|
||||
// 授权最古老的角色权限
|
||||
grantRole(grantType) {
|
||||
this.$refs.grantModal.open('role')
|
||||
this.grantType = grantType
|
||||
},
|
||||
handleOk(params) {
|
||||
handleOk(params, type) {
|
||||
const { grantType } = this
|
||||
console.log(params)
|
||||
const rids = [
|
||||
...params.department.map((rid) => {
|
||||
const _find = this.allDepartments.find((dep) => dep.acl_rid === rid)
|
||||
return { rid, name: _find?.department_name ?? rid }
|
||||
}),
|
||||
...params.user.map((rid) => {
|
||||
const _find = this.allEmployees.find((dep) => dep.acl_rid === rid)
|
||||
return { rid, name: _find?.nickname ?? rid }
|
||||
}),
|
||||
]
|
||||
let rids
|
||||
if (type === 'depart') {
|
||||
rids = [
|
||||
...params.department.map((rid) => {
|
||||
const _find = this.allDepartments.find((dep) => dep.acl_rid === rid)
|
||||
return { rid, name: _find?.department_name ?? rid }
|
||||
}),
|
||||
...params.user.map((rid) => {
|
||||
const _find = this.allEmployees.find((dep) => dep.acl_rid === rid)
|
||||
return { rid, name: _find?.nickname ?? rid }
|
||||
}),
|
||||
]
|
||||
}
|
||||
if (type === 'role') {
|
||||
rids = [
|
||||
...params.map((role) => {
|
||||
return { rid: role.id, name: role.name }
|
||||
}),
|
||||
]
|
||||
}
|
||||
if (grantType === 'ci_type') {
|
||||
this.tableData.unshift(
|
||||
...rids.map(({ rid, name }) => {
|
||||
|
@@ -7,14 +7,16 @@
|
||||
ref="employeeTransfer"
|
||||
:height="350"
|
||||
/>
|
||||
<RoleTransfer app_id="cmdb" :height="350" ref="roleTransfer" v-if="type === 'role'" />
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import EmployeeTransfer from '@/components/EmployeeTransfer'
|
||||
import RoleTransfer from '@/components/RoleTransfer'
|
||||
export default {
|
||||
name: 'GrantModal',
|
||||
components: { EmployeeTransfer },
|
||||
components: { EmployeeTransfer, RoleTransfer },
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
@@ -35,9 +37,15 @@ export default {
|
||||
this.type = type
|
||||
},
|
||||
handleOk() {
|
||||
const params = this.$refs.employeeTransfer.getValues()
|
||||
let params
|
||||
if (this.type === 'depart') {
|
||||
params = this.$refs.employeeTransfer.getValues()
|
||||
}
|
||||
if (this.type === 'role') {
|
||||
params = this.$refs.roleTransfer.getValues()
|
||||
}
|
||||
this.handleCancel()
|
||||
this.$emit('handleOk', params)
|
||||
this.$emit('handleOk', params, this.type)
|
||||
},
|
||||
handleCancel() {
|
||||
this.visible = false
|
||||
|
@@ -10,7 +10,7 @@
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">授权用户/部门</span>
|
||||
<!-- <span class="grant-button" @click="grantRole">授权角色</span> -->
|
||||
<span class="grant-button" @click="grantRole">授权角色</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
@@ -10,7 +10,7 @@
|
||||
</vxe-table>
|
||||
<a-space>
|
||||
<span class="grant-button" @click="grantDepart">授权用户/部门</span>
|
||||
<!-- <span class="grant-button" @click="grantRole">授权角色</span> -->
|
||||
<span class="grant-button" @click="grantRole">授权角色</span>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user