|
|
@ -136,7 +136,7 @@ export function useAuthorize() { |
|
|
|
state.fileResources = fileResources |
|
|
|
state.fileResources = fileResources |
|
|
|
state.udfResources = udfResources |
|
|
|
state.udfResources = udfResources |
|
|
|
state.authorizedFileResources = fileTargets |
|
|
|
state.authorizedFileResources = fileTargets |
|
|
|
state.authorizedUdfResources = fileTargets |
|
|
|
state.authorizedUdfResources = udfTargets |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onInit = (type: TAuthType, userId: number) => { |
|
|
|
const onInit = (type: TAuthType, userId: number) => { |
|
|
@ -154,6 +154,36 @@ export function useAuthorize() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
getParent |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const getParent = (data2: Array<number>, nodeId2: number) => { |
|
|
|
|
|
|
|
let arrRes: Array<any> = [] |
|
|
|
|
|
|
|
if (data2.length === 0) { |
|
|
|
|
|
|
|
if (nodeId2) { |
|
|
|
|
|
|
|
arrRes.unshift(data2) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return arrRes |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const rev = (data: Array<any>, nodeId: number) => { |
|
|
|
|
|
|
|
for (let i = 0, length = data.length; i < length; i++) { |
|
|
|
|
|
|
|
const node = data[i] |
|
|
|
|
|
|
|
if (node.id === nodeId) { |
|
|
|
|
|
|
|
arrRes.unshift(node) |
|
|
|
|
|
|
|
rev(data2, node.pid) |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (node.children) { |
|
|
|
|
|
|
|
rev(node.children, nodeId) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return arrRes |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
arrRes = rev(data2, nodeId2) |
|
|
|
|
|
|
|
return arrRes |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onSave = async (type: TAuthType, userId: number) => { |
|
|
|
const onSave = async (type: TAuthType, userId: number) => { |
|
|
|
if (state.saving) return false |
|
|
|
if (state.saving) return false |
|
|
|
state.saving = true |
|
|
|
state.saving = true |
|
|
@ -176,12 +206,40 @@ export function useAuthorize() { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
if (type === 'authorize_resource') { |
|
|
|
if (type === 'authorize_resource') { |
|
|
|
|
|
|
|
let fullPathFileId = [] |
|
|
|
|
|
|
|
const pathFileId: Array<string> = [] |
|
|
|
|
|
|
|
state.authorizedFileResources.forEach((v: number) => { |
|
|
|
|
|
|
|
state.fileResources.forEach((v1: any) => { |
|
|
|
|
|
|
|
const arr = [] |
|
|
|
|
|
|
|
arr[0] = v1 |
|
|
|
|
|
|
|
if (getParent(arr, v).length > 0) { |
|
|
|
|
|
|
|
fullPathFileId = getParent(arr, v).map((v2: any) => { |
|
|
|
|
|
|
|
return v2.id |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
pathFileId.push(fullPathFileId.join('-')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let fullPathUdfId = [] |
|
|
|
|
|
|
|
const pathUdfId: Array<string> = [] |
|
|
|
|
|
|
|
state.authorizedUdfResources.forEach((v: number) => { |
|
|
|
|
|
|
|
state.udfResources.forEach((v1: any) => { |
|
|
|
|
|
|
|
const arr = [] |
|
|
|
|
|
|
|
arr[0] = v1 |
|
|
|
|
|
|
|
if (getParent(arr, v).length > 0) { |
|
|
|
|
|
|
|
fullPathUdfId = getParent(arr, v).map((v2: any) => { |
|
|
|
|
|
|
|
return v2.id |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
pathUdfId.push(fullPathUdfId.join('-')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const allPathId = pathFileId.concat(pathUdfId) |
|
|
|
await grantResource({ |
|
|
|
await grantResource({ |
|
|
|
userId, |
|
|
|
userId, |
|
|
|
resourceIds: |
|
|
|
resourceIds: allPathId.join(',') |
|
|
|
state.resourceType === 'file' |
|
|
|
|
|
|
|
? state.authorizedFileResources.join(',') |
|
|
|
|
|
|
|
: state.authorizedUdfResources.join(',') |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
state.saving = false |
|
|
|
state.saving = false |
|
|
|