feat: 全局跨域公司选择器 + 权限页crossDomain开关
- 新增CompanySelector组件: 仅crossDomain权限或SUPER_ADMIN可见 - 权限分配页: 全局系统特权下新增"允许全局跨域"操作权限checkbox - 入库汇总/出库记录搜索栏嵌入CompanySelector - PermissionConfig: transformData识别crossDomain为操作权限码
This commit is contained in:
@ -120,11 +120,13 @@
|
||||
<el-checkbox
|
||||
v-if="row.operationCode"
|
||||
v-model="row.hasWrite"
|
||||
:disabled="!row.hasRead"
|
||||
:disabled="!row.hasRead && row.operationCode !== 'crossDomain'"
|
||||
@change="(val) => handleWriteChange(val, row)"
|
||||
class="custom-checkbox"
|
||||
>
|
||||
<span :class="{ 'text-active': row.hasWrite, 'text-disabled': !row.hasRead }">可编辑 (Write)</span>
|
||||
<span :class="{ 'text-active': row.hasWrite, 'text-disabled': !row.hasRead && row.operationCode !== 'crossDomain' }">
|
||||
{{ row.operationCode === 'crossDomain' ? '允许全局跨域' : '可编辑 (Write)' }}
|
||||
</span>
|
||||
</el-checkbox>
|
||||
<span v-else class="text-gray">-</span>
|
||||
</div>
|
||||
@ -239,10 +241,16 @@ const fetchTree = async () => {
|
||||
code: 'global_privileges',
|
||||
type: 'menu',
|
||||
children: [
|
||||
{
|
||||
id: 999992,
|
||||
name: '全局跨域访问',
|
||||
code: 'crossDomain',
|
||||
type: 'element'
|
||||
},
|
||||
{
|
||||
id: 999991,
|
||||
name: '跨组织/跨区域数据查询',
|
||||
code: 'global:cross_company_op', // 加上 _op 让它显示在操作权限列
|
||||
code: 'global:cross_company_op',
|
||||
type: 'element'
|
||||
}
|
||||
]
|
||||
@ -265,12 +273,16 @@ const transformData = (nodes: any[]): PermissionNode[] => {
|
||||
// 找出所有子节点中的 element
|
||||
const allChildren = node.children || []
|
||||
|
||||
// 1. 找操作列 (作为 Write 权限)
|
||||
const opNode = allChildren.find((c: any) => c.type === 'element' && (c.code === 'operation' || c.code.endsWith(':operation') || c.code.endsWith('_op')))
|
||||
// 1. 找操作列 (作为 Write 权限) — 含 crossDomain 等全局权限码
|
||||
const opNode = allChildren.find((c: any) => c.type === 'element' && (
|
||||
c.code === 'operation' || c.code.endsWith(':operation') || c.code.endsWith('_op') || c.code === 'crossDomain'
|
||||
))
|
||||
const operationCode = opNode ? opNode.code : null
|
||||
|
||||
// 2. 找普通列 (作为字段权限)
|
||||
const columns = allChildren.filter((c: any) => c.type === 'element' && c.code !== 'operation' && !c.code.endsWith('_op') && !c.code.endsWith(':operation'))
|
||||
// 2. 找普通列 (作为字段权限) — 排除操作权限码
|
||||
const columns = allChildren.filter((c: any) => c.type === 'element'
|
||||
&& c.code !== 'operation' && !c.code.endsWith('_op') && !c.code.endsWith(':operation')
|
||||
&& c.code !== 'crossDomain')
|
||||
|
||||
// 3. 找子菜单 (如果有)
|
||||
const subMenus = allChildren.filter((c: any) => c.type === 'menu')
|
||||
@ -307,6 +319,7 @@ const handleRoleSelect = async (roleCode: string) => {
|
||||
const res: any = await getRolePermissions(roleCode)
|
||||
if (res.code === 200) {
|
||||
const perms = new Set([...(res.data.menus || []), ...(res.data.elements || [])])
|
||||
console.log('[权限加载] SUPERVISOR crossDomain 在权限中:', perms.has('crossDomain'))
|
||||
// 递归设置表格每一行的状态
|
||||
setRowStatus(tableData.value, perms)
|
||||
}
|
||||
@ -452,9 +465,11 @@ const handleSave = async () => {
|
||||
permissions.push(row.code)
|
||||
}
|
||||
|
||||
// 2. 操作权限 (只有当页面可读时才有效)
|
||||
if (row.hasRead && row.hasWrite && row.operationCode) {
|
||||
permissions.push(row.operationCode)
|
||||
// 2. 操作权限 (crossDomain 不依赖页面可读)
|
||||
if (row.hasWrite && row.operationCode) {
|
||||
if (row.operationCode === 'crossDomain' || row.hasRead) {
|
||||
permissions.push(row.operationCode)
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 字段权限 (只有当页面可读时才有效)
|
||||
@ -471,6 +486,11 @@ const handleSave = async () => {
|
||||
|
||||
collectPermissions(tableData.value)
|
||||
|
||||
// [调试] 打印 crossDomain 是否在提交列表中
|
||||
console.log('[权限保存] 总权限数:', permissions.length)
|
||||
console.log('[权限保存] crossDomain 在提交列表中:', permissions.includes('crossDomain'))
|
||||
console.log('[权限保存] global:cross_company_op 在提交列表中:', permissions.includes('global:cross_company_op'))
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
const res: any = await saveRolePermissions({
|
||||
|
||||
Reference in New Issue
Block a user