Merge branch 'codex/xuxiake-sabc-sync-20260929' into codex/xuxiake-mainline
部门数据分类数据权限支持「全部」授权写法。
This commit is contained in:
commit
f94c86bcc8
@ -406,7 +406,7 @@ export function DepartmentDistributionView({
|
||||
<textarea value={draft.profitCenterAlias} onChange={(event) => setDraft((current) => ({ ...current, profitCenterAlias: event.target.value }))} />
|
||||
</label>
|
||||
<label className={styles.deptConfigField}>
|
||||
数据权限例外(一行一条:花名=范围,范围支持 利润中心:xx / 事业部:xx / 品类部:xx / 负责人:xx,多个用逗号)
|
||||
数据权限例外(一行一条:花名=范围;范围支持 全部(看所有利润中心)/ 利润中心:xx / 事业部:xx / 品类部:xx / 负责人:xx,多个用逗号)
|
||||
<textarea value={draft.dataScopeGrants} onChange={(event) => setDraft((current) => ({ ...current, dataScopeGrants: event.target.value }))} />
|
||||
</label>
|
||||
<div className={styles.deptConfigField} style={{ gridColumn: '1 / -1' }}>
|
||||
|
||||
@ -410,6 +410,14 @@ export async function resolveDepartmentViewerScope(
|
||||
if (grant.user !== nickname) continue
|
||||
for (const scope of grant.scopes) scopes.add(scope)
|
||||
}
|
||||
// 支持「全部」授权:scope 写 全部 / 所有 / * 即可看全部利润中心(不需要逐条列利润中心)
|
||||
const grantsAllData = [...scopes].some((scope) => {
|
||||
const normalized = scope.replace(/\s/g, '')
|
||||
return normalized === '全部' || normalized === '所有' || normalized === '*' || normalized === '全公司'
|
||||
})
|
||||
if (grantsAllData) {
|
||||
return { nickname, isAdmin: false, allowedOwners: null, scopeLabel: nickname ? `全部数据(授权给 ${nickname})` : '全部数据' }
|
||||
}
|
||||
for (const scope of scopes) {
|
||||
const [kind, rawValue] = scope.split(':')
|
||||
const value = String(rawValue ?? '').trim()
|
||||
|
||||
@ -121,6 +121,15 @@ describe('supply-chain department distribution', () => {
|
||||
normalizeDepartmentSettings({ dataScopeGrants: [{ user: '香茗', scopes: ['利润中心:运营中心A'] }] }),
|
||||
)
|
||||
expect([...(granted.allowedOwners ?? [])].sort()).toEqual(['香茗', '比干', '玄女', '西门吹雪'].sort())
|
||||
|
||||
// 「全部」授权:不限制利润中心
|
||||
const full = await resolveDepartmentViewerScope(
|
||||
{ id: 'u', email: '', name: '望舒', role: 'USER', status: 'ACTIVE' },
|
||||
configs,
|
||||
normalizeDepartmentSettings({ dataScopeGrants: [{ user: '望舒', scopes: ['全部'] }] }),
|
||||
)
|
||||
expect(full.allowedOwners).toBeNull()
|
||||
expect(full.scopeLabel).toContain('全部数据')
|
||||
})
|
||||
|
||||
it('aggregates rows by profit center, department and owner with the manual-table metrics', async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user