角色授权

This commit is contained in:
wang-liang0615
2023-07-19 19:09:08 +08:00
committed by pycook
parent 9ec590664b
commit 60aec1f9ef
8 changed files with 240 additions and 20 deletions

View File

@@ -299,7 +299,6 @@ export default {
if (rtypeId) {
this.currentType = this.allResourceTypes.find((item) => item.id === rtypeId)
}
p
this.searchData()
},
handlePerm(record) {

View File

@@ -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>

View File

@@ -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 }) => {

View File

@@ -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

View File

@@ -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>

View File

@@ -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>