Commit 08fe06be by zhaochengxiang

资产权限

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