Commit 0867498b by zhaochengxiang

资源权限

parent 7b5fd0d3
......@@ -35,6 +35,8 @@ const operationMap = {
addAsAsset: '新增为资产',
distribute: '分配',
reDistribute: '转分配',
autoDistribute: '自动分配',
batchEdit: '批量编辑',
check: '复核',
changeToNotAsset: '转为非资产',
changeToUncombed: '转为未梳理',
......@@ -223,8 +225,8 @@ const FC = (props) => {
}
}, [data])
const [addAble, addAsAssetAble, distributeAble, checkAble, importAble, exportAble, changeDirectoryAble, deleteAble] = React.useMemo(() => {
let [_addAble, _addAsAssetAble, _distributeAble, _checkAble, _importAble, _exportAble, _changeDiretoryAble, _deleteAble] = [false, false, false, false, false, false, false, false]
const [addAble, addAsAssetAble, distributeAble, autoDistributeAble, batchEditAble,checkAble, importAble, exportAble, changeDirectoryAble, deleteAble] = React.useMemo(() => {
let [_addAble, _addAsAssetAble, _distributeAble, _autoDistributeAble, _batchEditAble, _checkAble, _importAble, _exportAble, _changeDiretoryAble, _deleteAble] = [false, false, false, false, false, false, false, false, false, false]
_addAble = (permissions??[]).findIndex(item => item==='add') !== -1
......@@ -248,10 +250,12 @@ const FC = (props) => {
_exportAble = allowExport
}
let [allowAddAsAsset, allowDistribute, allowCheck, allowChangeDirectory, allowDelete] = [true, true, true, true, true]
let [allowAddAsAsset, allowDistribute, allowAutoDistribute, allowBatchEdit, allowCheck, allowChangeDirectory, allowDelete] = [true, true, true, true, true, true, true]
for (const row of selectedRows) {
const addAsAssetIndex = (row.allowButtons??[]).findIndex(item => item==='addAsAsset')
const distributeIndex = (row.allowButtons??[]).findIndex(item => item==='distribute')
const autoDistributeIndex = (row.allowButtons??[]).findIndex(item => item==='autoDistribute')
const batchEditIndex = (row.allowButtons??[]).findIndex(item => item==='batchEdit')
const checkIndex = (row.allowButtons??[]).findIndex(item => item==='check')
const changeDirecotoryIndex = (row.allowButtons??[]).findIndex(item => item==='changeDir')
const deleteIndex = (row.allowButtons??[]).findIndex(item => item==='delete')
......@@ -261,6 +265,12 @@ const FC = (props) => {
if (distributeIndex === -1) {
allowDistribute = false
}
if (autoDistributeIndex === -1) {
allowAutoDistribute = false
}
if (batchEditIndex === -1) {
allowBatchEdit = false
}
if (checkIndex === -1) {
allowCheck = false
}
......@@ -274,11 +284,13 @@ const FC = (props) => {
_addAsAssetAble = allowAddAsAsset
_distributeAble = allowDistribute
_autoDistributeAble = allowAutoDistribute
_batchEditAble = allowBatchEdit
_checkAble = allowCheck
_changeDiretoryAble = allowChangeDirectory
_deleteAble = allowDelete
return [_addAble, _addAsAssetAble, _distributeAble, _checkAble, _importAble, _exportAble, _changeDiretoryAble, _deleteAble]
return [_addAble, _addAsAssetAble, _distributeAble, _autoDistributeAble, _batchEditAble, _checkAble, _importAble, _exportAble, _changeDiretoryAble, _deleteAble]
}, [permissions, selectedRows])
const menuData = React.useMemo(() => {
......@@ -619,7 +631,7 @@ const FC = (props) => {
})
}
const onTaskAutoAllocationClick = () => {
const onAutoDistributeTaskClick = () => {
}
......@@ -859,8 +871,8 @@ const FC = (props) => {
onAddToAssetClick()
} else if (key === 'distribute') {
onDistributeTaskClick()
} else if (key === 'taskAutoAllocation') {
onTaskAutoAllocationClick()
} else if (key === 'autoDistribute') {
onAutoDistributeTaskClick()
} else if (key === 'batchEdit') {
onBatchEditClick()
}else if (key === 'check') {
......@@ -923,8 +935,8 @@ const FC = (props) => {
</div>
</PermissionMenuItem>
<PermissionMenuItem
key='taskAutoAllocation'
defaultPermission={true}
key='autoDistribute'
defaultPermission={autoDistributeAble}
disabled={(selectedRows??[]).length===0}
tip={(selectedRows??[]).length===0?'请先选择资源':''}
>
......@@ -934,7 +946,7 @@ const FC = (props) => {
</PermissionMenuItem>
<PermissionMenuItem
key='batchEdit'
defaultPermission={true}
defaultPermission={batchEditAble}
disabled={(selectedRows??[]).length===0}
tip={(selectedRows??[]).length===0?'请先选择资源':''}
>
......@@ -1038,15 +1050,15 @@ const FC = (props) => {
任务分配
</PermissionButton>
<PermissionButton
defaultPermission={true}
onClick={onTaskAutoAllocationClick}
defaultPermission={autoDistributeAble}
onClick={onAutoDistributeTaskClick}
disabled={(selectedRows??[]).length===0}
tip={(selectedRows??[]).length===0?'请先选择资源':''}
>
自动分配
</PermissionButton>
<PermissionButton
defaultPermission={true}
defaultPermission={batchEditAble}
onClick={onBatchEditClick}
disabled={(selectedRows??[]).length===0}
tip={(selectedRows??[]).length===0?'请先选择资源':''}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment