Commit 08fe06be by zhaochengxiang

资产权限

parent 444a3674
......@@ -529,3 +529,11 @@ export function* listDataAssetHistoryTimeline(payload) {
export function* queryCustomTypeRootDirectory() {
return yield call(service.queryCustomTypeRootDirectory);
}
export function* getPrivilegeByRange(payload) {
return yield call(service.getPrivilegeByRange, payload);
}
export function* getPrivilegeByRangeAndDirId(payload) {
return yield call(service.getPrivilegeByRangeAndDirId, payload);
}
\ No newline at end of file
......@@ -536,3 +536,11 @@ export function listDataAssetHistoryTimeline(payload) {
export function queryCustomTypeRootDirectory() {
return GetJSON("/dataassetmanager/directoryApi/queryCustomTypeRootDirectory");
}
export function getPrivilegeByRange(payload) {
return GetJSON("/dataassetmanager/AuthorityApi/listAllowButtonsByRange", payload);
}
export function getPrivilegeByRangeAndDirId(payload) {
return GetJSON("/dataassetmanager/AuthorityApi/listAllowButtonsByRangeAndOptionId", payload);
}
\ No newline at end of file
......@@ -26,9 +26,11 @@ export const DataModelerRoleUser = 'user';
export const DataModelerRoleReader = 'reader';
//资产
export const ResourceManageReference = 'resource-manage';
export const AssetManageReference = 'asset-manage';
export const AssetBrowseReference = 'asset-browse';
export const ResourceBrowseReference = 'resource-browse';
export const AssetRecycleReference = 'asset-recycle';
export const AssetMountReference = 'asset-mount';
export const AssetInventoryReference = 'asset-inventory';
export const AssetDraftReference = 'asset-draft';
\ No newline at end of file
......@@ -6,7 +6,7 @@ import { Subject } from 'rxjs';
import { dispatchLatest, action } from '../model';
import { set_sess_state } from "../model/reducer";
import { DataModelerRoleAdmin, DataModelerRoleUser, DataModelerRoleReader } from './constant';
import { DataModelerRoleAdmin, DataModelerRoleUser, DataModelerRoleReader, AssetManageReference, AssetBrowseReference, ResourceBrowseReference, AssetRecycleReference, ResourceManageReference, AssetInventoryReference } from './constant';
//内网深交所环境 isSzseEnv true
//元曜公网环境 isSzseEnv false
......@@ -424,3 +424,20 @@ export function getScrollbarWidth() {
return scrollbarWidth;
}
export function getAssetRange(menuName) {
if (menuName === ResourceManageReference ) {
return 'dataAsset_resourceManage';
} else if (menuName === AssetManageReference) {
return 'dataAsset_dataAssetManage';
} else if (menuName === AssetBrowseReference) {
return 'dataAsset_dataAssetBrowse';
} else if (menuName === ResourceBrowseReference) {
return 'dataAsset_resourceBrowse';
} else if (menuName === AssetRecycleReference) {
return 'dataAsset_unloadDataAsset';
} else if (menuName === AssetInventoryReference) {
return 'dataAsset_inventory';
}
return '';
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ import { dispatch } from '../../../../model';
import ImportDirectory from './ImportDirectory';
import UpdateDirectoryModal from './UpdateDirectoryModal';
import CustomDirectoryModal from './CustomDirectoryModal';
import { showMessage, getQueryParam } from '../../../../util';
import { showMessage, getQueryParam, getAssetRange } from '../../../../util';
import { AnchorTimestamp, AnchorId, AssetManageReference, AssetBrowseReference, ResourceBrowseReference, AssetMountReference, AnchorDirId, AnchorTemplateType } from '../../../../util/constant';
import { highlightSearchContentByTerms } from '../../../../util';
import { listSubject } from './AssetTable';
......@@ -308,6 +308,9 @@ const AssetManageTree = (props) => {
dispatch({
type: url,
payload: {
range: getAssetRange(AssetManageReference)
},
callback: data => {
let newData = [];
if (viewSelectedKeyRef.current==='dir') {
......
......@@ -15,7 +15,7 @@ import ImportBusinessColumn from './import-business-column';
import AddAsset from './add-asset';
import AssetDetailDrawer from "./AssetDetailDrawer";
import { dispatch, dispatchLatestHomepage } from '../../../../model';
import { showMessage, showNotifaction, getQueryParam, inputWidth, isSzseEnv, highlightSearchContentByTerms, isPostAsset } from '../../../../util';
import { showMessage, showNotifaction, getQueryParam, inputWidth, isSzseEnv, highlightSearchContentByTerms, isPostAsset, getAssetRange } from '../../../../util';
import { AnchorId, AnchorDirId, AnchorTimestamp, AssetBrowseReference, AssetManageReference, AssetRecycleReference, ResourceBrowseReference } from '../../../../util/constant';
import { FullScreenSvg, CancelFullScreenSvg } from './AssetSvg';
import AssetDeleteModal from './AssetDeleteModal';
......@@ -26,6 +26,7 @@ import WorksheetModal from "./WorksheetModal";
import WorkbookDrawer from "./WorkbookDrawer";
import TagCell, { TagSelectPopup } from './tag-help'
import HistoryAndVersionDrawer from "./HistoryAndVersionDrawer";
import PermissionButton from '../../../../util/Component/PermissionButton'
import "./AssetTable.less";
import 'react-contexify/dist/ReactContexify.css';
......@@ -114,6 +115,7 @@ const AssetTable = (props) => {
const [ contextMenuItem, setContextMenuItem ] = useState({});
const [ checkedKeys, setCheckedKeys ] = useState([]);
const [selectedRows, setSelectedRows] = React.useState([]);
const [ importAssetVisible, setImportAssetVisible ] = useState(false);
const [ filterElementVisible, setFilterElementVisible ] = useState(false);
const [addAssetParams, setAddAssetParams] = useState({
......@@ -143,7 +145,6 @@ const AssetTable = (props) => {
const [loadingElements, setLoadingElements] = useState(false)
const [elements, setElements] = useState()
const [currentElementId, setCurrentElementId] = useState()
const [isAdmin, setAdmin] = useState()
const [isDataKeyUser, setDataKeyUser] = useState()
const [reportTypes, setReportTypes] = useState()
const [currentReport, setReport] = useState()
......@@ -158,6 +159,7 @@ const AssetTable = (props) => {
visible: false,
id: undefined
})
const [permissions, setPermissions] = React.useState([])
const [ modal, contextHolder ] = Modal.useModal();
const anchorId = getQueryParam(AnchorId, props?.location?.search);
......@@ -234,7 +236,6 @@ const AssetTable = (props) => {
}
useEffect(() => {
getAdmin();
judgeDataKeyUser();
getUsers();
getReportTypes();
......@@ -259,6 +260,7 @@ const AssetTable = (props) => {
if (nodeId !== null && nodeId !== undefined) {
setSelectItem({});
setCheckedKeys([]);
setSelectedRows([]);
if (shouldScrollRef.current === true) {
if (remoteRelationRef.current) {
......@@ -309,6 +311,72 @@ const AssetTable = (props) => {
}
}, [assets])
React.useEffect(() => {
if (nodeId) {
if (nodeType !== 'custom') {
getPermissions()
}
}
}, [nodeId, nodeType])
const [addAble, importAble, exportAble, changeDirectoryAble, deleteAble, offlineAble, addTagAble, subscribeAble] = React.useMemo(() => {
let [_addAble, _importAble, _exportAble, _changeDirectoryAble, _deleteAble, _offlineAble, _addTagAble, _subscribeAble] = [false, false, false, false, false, false, false, false]
_addAble = (permissions??[]).findIndex(item => item==='add') !== -1
if ((selectedRows??[]).length === 0) {
_importAble = (permissions??[]).findIndex(item => item==='import') !== -1
_exportAble = (permissions??[]).findIndex(item => item==='export') !== -1
} else {
let [allowImport, allowExport] = [true, true]
for (const row of selectedRows??[]) {
const importIndex = (row.allowButtons??[]).findIndex(item => item==='import')
const exportIndex = (row.allowButtons??[]).findIndex(item => item==='export')
if (importIndex === -1) {
allowImport = false
}
if (exportIndex === -1) {
allowExport = false
}
}
_importAble = allowImport
_exportAble = allowExport
}
let [allowChangeDirectory, allowDelete, allowOffline, allowAddTag, allowSubscribe] = [true, true, true, true, true]
for (const row of selectedRows??[]) {
const changeDirecotoryIndex = (row.allowButtons??[]).findIndex(item => item==='changeDir')
const deleteIndex = (row.allowButtons??[]).findIndex(item => item==='delete')
const offlineIndex = (row.allowButtons??[]).findIndex(item => item==='offline')
const addTagIndex = (row.allowButtons??[]).findIndex(item => item==='addTag')
const subscribeIndex = (row.allowButtons??[]).findIndex(item => item==='subscribe')
if (changeDirecotoryIndex === -1) {
allowChangeDirectory = false
}
if (deleteIndex === -1) {
allowDelete = false
}
if (offlineIndex === -1) {
allowOffline = false
}
if (addTagIndex === -1) {
allowAddTag = false
}
if (subscribeIndex === -1) {
allowSubscribe = false
}
}
_changeDirectoryAble = allowChangeDirectory
_deleteAble = allowDelete
_offlineAble = allowOffline
_addTagAble = allowAddTag
_subscribeAble = allowSubscribe
return [_addAble, _importAble, _exportAble, _changeDirectoryAble, _deleteAble, _offlineAble, _addTagAble, _subscribeAble]
}, [permissions, selectedRows])
const realAssets = useMemo(() => {
const newAssets = [...assets];
// if (users?.length > 0 && assets?.length > 0 && columns?.length > 0) {
......@@ -347,11 +415,15 @@ const AssetTable = (props) => {
}
}
const getAdmin = () => {
const getPermissions = () => {
dispatch({
type: 'assetmanage.checkAdmin',
callback: (data) => {
setAdmin((data==='true')?true:false)
type: 'assetmanage.getPrivilegeByRangeAndDirId',
payload: {
range: getAssetRange(AssetManageReference),
optionId: nodeId
},
callback: data => {
setPermissions(data)
}
})
}
......@@ -449,6 +521,7 @@ const AssetTable = (props) => {
const changeCurrent = (page,size) => {
setCheckedKeys([]);
setSelectedRows([]);
setPagination({ pageNum: page, pageSize: size });
}
......@@ -694,6 +767,7 @@ const AssetTable = (props) => {
if (refresh) {
setCheckedKeys([]);
setSelectedRows([]);
getDataAssets();
}
}
......@@ -757,6 +831,7 @@ const AssetTable = (props) => {
showMessage("success","删除成功");
getDataAssets();
setCheckedKeys([]);
setSelectedRows([]);
},
error: () => {
}
......@@ -783,6 +858,7 @@ const AssetTable = (props) => {
showMessage("success","停用成功");
getDataAssets();
setCheckedKeys([]);
setSelectedRows([]);
},
error: () => {
}
......@@ -848,6 +924,7 @@ const AssetTable = (props) => {
showMessage("success","删除成功");
getDataAssets();
setCheckedKeys([]);
setSelectedRows([]);
}
})
}
......@@ -866,6 +943,7 @@ const AssetTable = (props) => {
showMessage("success","删除成功");
getDataAssets();
setCheckedKeys([]);
setSelectedRows([]);
}
})
}
......@@ -887,6 +965,7 @@ const AssetTable = (props) => {
showMessage("success","恢复成功");
getDataAssets();
setCheckedKeys([]);
setSelectedRows([]);
}
})
}
......@@ -896,8 +975,9 @@ const AssetTable = (props) => {
}
}
const onSelectChange = keys => {
setCheckedKeys(keys);
const onSelectChange = (selectedRowKeys, selectedRows) => {
setCheckedKeys(selectedRowKeys);
setSelectedRows(selectedRows);
};
const onFullScreenClick = () => {
......@@ -913,6 +993,7 @@ const AssetTable = (props) => {
setStartFlowModalVisible(false);
if (refresh) {
setCheckedKeys([]);
setSelectedRows([]);
}
}
......@@ -1037,38 +1118,76 @@ const AssetTable = (props) => {
>
<Space>
{
(((reference===AssetManageReference&&nodeType!=='custom')||isDataKeyUser) && template && template?.structedStateEnum!=='structured') && nodeId && <Button onClick={addAsset}>新增</Button>
(((reference===AssetManageReference&&nodeType!=='custom')||isDataKeyUser) && template && template?.structedStateEnum!=='structured') && nodeId && <PermissionButton
defaultPermission={addAble}
onClick={addAsset}
>
新增
</PermissionButton>
}
{
(reference===AssetManageReference && nodeType!=='custom') && <Button onClick={importAsset}>导入</Button>
(reference===AssetManageReference && nodeType!=='custom') && <PermissionButton
defaultPermission={importAble}
onClick={importAsset}
>
导入
</PermissionButton>
}
{
(reference===AssetManageReference && nodeType!=='custom' && template && template?.structedStateEnum!=='structured') && <Button onClick={importBusinessColumn}>导入字段</Button>
(reference===AssetManageReference && nodeType!=='custom' && template && template?.structedStateEnum!=='structured') && <PermissionButton
defaultPermission={importAble}
onClick={importBusinessColumn}
>
导入字段
</PermissionButton>
}
{
(reference===AssetManageReference) && <Tooltip>
<Button onClick={exportAsset} >导出</Button>
</Tooltip>
(reference===AssetManageReference) && <PermissionButton
defaultPermission={exportAble}
onClick={exportAsset}
>
导出
</PermissionButton>
}
{
reference===AssetManageReference && <Tooltip title={(checkedKeys||[]).length===0?'请先选择资产目录':''}>
<Button onClick={onBatchCatalogChangeBtnClick} disabled={(checkedKeys||[]).length===0} >变更目录</Button>
</Tooltip>
reference===AssetManageReference && <PermissionButton
defaultPermission={changeDirectoryAble}
tip={(checkedKeys||[]).length===0?'请先选择资产目录':''}
onClick={onBatchCatalogChangeBtnClick}
disabled={(checkedKeys||[]).length===0}
>
变更目录
</PermissionButton>
}
{
reference===AssetManageReference && isAdmin && <Tooltip title={(checkedKeys||[]).length===0?'请先选择资产目录':''}>
<Button onClick={deleteAssets} disabled={(checkedKeys||[]).length===0} >删除</Button>
</Tooltip>
reference===AssetManageReference && <PermissionButton
defaultPermission={deleteAble}
tip={(checkedKeys||[]).length===0?'请先选择资产目录':''}
onClick={deleteAssets}
disabled={(checkedKeys||[]).length===0}
>
删除
</PermissionButton>
}
{
reference===AssetManageReference && isAdmin && <Tooltip title={(checkedKeys||[]).length===0?'请先选择资产目录':''}>
<Button onClick={offlineAssets} disabled={(checkedKeys||[]).length===0} >停用</Button>
</Tooltip>
reference===AssetManageReference && <PermissionButton
defaultPermission={offlineAble}
tip={(checkedKeys||[]).length===0?'请先选择资产目录':''}
onClick={offlineAssets}
disabled={(checkedKeys||[]).length===0}
>
停用
</PermissionButton>
}
{
reference===AssetManageReference && <Tooltip title={(checkedKeys||[]).length===0?'请先选择资产目录':''}>
<Button onClick={onBatchAddTagClick} disabled={(checkedKeys||[]).length===0} >添加标签</Button>
</Tooltip>
reference===AssetManageReference && <PermissionButton
defaultPermission={addTagAble}
tip={(checkedKeys||[]).length===0?'请先选择资产目录':''}
onClick={onBatchAddTagClick}
disabled={(checkedKeys||[]).length===0}
>
添加标签
</PermissionButton>
}
<Button onClick={onFilterElementClick}>可见列设置</Button>
{
......
......@@ -6,7 +6,7 @@ import LocalStorage from 'local-storage';
import { dispatch } from '../../../../model';
import CustomDirectoryModal from './CustomDirectoryModal';
import { showMessage, getQueryParam } from '../../../../util';
import { showMessage, getQueryParam, getAssetRange } from '../../../../util';
import { AnchorTimestamp, AnchorId, AssetBrowseReference, ResourceBrowseReference, AnchorDirId, AnchorTemplateType } from '../../../../util/constant';
import { highlightSearchContentByTerms } from '../../../../util';
import UpdateDirectoryModal from './UpdateDirectoryModal';
......@@ -204,6 +204,9 @@ const AssetTree = (props) => {
dispatch({
type: url,
payload: {
range: getAssetRange(AssetBrowseReference)
},
callback: data => {
setLoading(false);
refresh && showMessage('success', '操作成功');
......
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