Commit 3638feac by zhaochengxiang

资产权限

parent ed86c059
......@@ -61,10 +61,11 @@ export class App extends React.Component {
const { setGlobalState, onGlobalStateChange } = this.props;
const { hostParams } = this.state;
let message = '', id = '', terms = [];
let message = '', id = '', terms = [], dirId = '';
if (hostParams) {
message = hostParams.message||'';
id = hostParams.id||'';
dirId = hostParams.dirId||'';
terms = hostParams.terms||[];
}
......@@ -92,6 +93,7 @@ export class App extends React.Component {
<AssetDetail
reference='full-search'
id={id}
dirId={dirId}
terms={terms}
/>
</AppContext.Provider>
......
......@@ -227,4 +227,8 @@ export function* getPrivilegeByRange(payload) {
export function* getPrivilegeByRangeAndDirId(payload) {
return yield call(service.getPrivilegeByRangeAndDirId, payload);
}
export function* getPreviewRangeByDirId(payload) {
return yield call(service.getPreviewRangeByDirId, payload);
}
\ No newline at end of file
import { PostJSON, GetJSON, PostFile, Post } from "../util/axios"
import { PostJSON, GetJSON, PostFile, Post, Get } from "../util/axios"
export function importElement(payload) {
return PostFile("/dataassetmanager/elementApi/import", payload);
......@@ -234,4 +234,8 @@ export function getPrivilegeByRange(payload) {
export function getPrivilegeByRangeAndDirId(payload) {
return GetJSON("/dataassetmanager/AuthorityApi/listAllowButtonsByRangeAndOptionId", payload);
}
export function getPreviewRangeByDirId(payload) {
return Get("/dataassetmanager/dataAssetApi/getPreviewRangeByDirId", payload);
}
\ No newline at end of file
import React, { useEffect, useState } from "react";
import React, { useEffect, useMemo, useState } from "react";
import { Spin, Descriptions, Divider } from "antd";
import MetadataInfo from './MetadataInfo';
......@@ -8,24 +8,72 @@ import { dispatch } from '../../../../model';
const AssetDetail = (props)=>{
const { id, dirId, terms, reference = '' } = props;
const [ asset, setAsset ] = useState('');
const [ asset, setAsset ] = useState(undefined);
const [ types, setTypes ] = useState([]);
const [ loading, setLoading ] = useState(false);
const [ userElements, setUserElements ] = useState(undefined);
useEffect(() => {
if ((id||'') !== '') {
getUserElements();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ id ])
useEffect(() => {
if (dirId) {
getPreviewRangeByDirIdThenGetAsset();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ dirId ])
const _asset = useMemo(() => {
let newAsset = {};
if (asset) {
const userElementIds = [];
userElements?.forEach(element => {
userElementIds.push(element?.id);
})
const filterElements = (asset?.elements||[]).filter(element => userElementIds.indexOf(element?.id) !== -1);
newAsset = { ...asset, elements: filterElements }
}
return newAsset;
}, [asset, userElements])
const havePreviewPermission = useMemo(() => {
return ((asset||{}).allowButtons||[]).findIndex(item => item === 'preview') !== -1
}, [asset])
const getPreviewRangeByDirIdThenGetAsset = () => {
dispatch({
type: 'assetmanage.getPreviewRangeByDirId',
payload: {
dirId
},
callback: data => {
getAsset(data);
}
});
}
const getUserElements = () => {
setLoading(true);
dispatch({
type: 'assetmanage.listUserElements',
callback: data => {
getAsset(data||[]);
setUserElements(data||[]);
const _types = [];
(data||[]).forEach(element => {
if (_types.indexOf(element.type) === -1) {
_types.push(element.type);
}
})
setTypes(_types);
},
error: () => {
setLoading(false);
......@@ -33,36 +81,18 @@ const AssetDetail = (props)=>{
})
}
const getAsset = (userElements) => {
const getAsset = (range) => {
dispatch({
type: 'assetmanage.getDataAssetDetail',
payload: {
range,
dataAssetId: id,
dirId: dirId||'',
checkPermission: true
},
callback: data => {
setLoading(false);
const userElementIds = [];
(userElements||[]).forEach(element => {
userElementIds.push(element?.id);
})
const filterElements = (data?.elements||[]).filter(element => userElementIds.indexOf(element?.id) !== -1);
data = { ...data, elements: filterElements }
setAsset(data);
const _types = [];
(data?.elements||[]).forEach(element => {
if (_types.indexOf(element.type) === -1) {
_types.push(element.type);
}
})
setTypes(_types);
},
error: () => {
setLoading(false);
......@@ -73,45 +103,49 @@ const AssetDetail = (props)=>{
return(
<Spin spinning={loading}>
{
((dirId||'')!=='') && <React.Fragment>
<Descriptions column={2}>
<Descriptions.Item label='路径'>
{asset.currentPath||''}
</Descriptions.Item>
</Descriptions>
<Divider style={{ margin: '10px 0' }} />
</React.Fragment>
}
{
(types||[]).map((type, index) => {
const _currentValues = (asset.elements||[]).filter(element => element.type===type);
return (
<div key={index}>
<div className='flex' style={{ alignItems: 'center', padding: (reference==='full-search'&&index===0)?'0 0 15px':'15px 0' }}>
<div style={{ width: 3, height: 14, backgroundColor: '#0069AC', marginRight: 5 }} />
<span style={{ fontWeight: 'bold', color: '#464646' }}>{type||''}</span>
</div>
havePreviewPermission ? <React.Fragment>
{
((dirId||'')!=='') && <React.Fragment>
<Descriptions column={2}>
{
(_currentValues||[]).map((item, index) => {
return (
<Descriptions.Item label={item.name||''} key={index}>
{
item.name==='资产项' ? <MetadataInfo config={false} value={item.value||''} terms={terms} /> : <span>{highlightSearchContentByTerms(item.value||'', terms)}</span>
}
</Descriptions.Item>
);
})
}
<Descriptions.Item label='路径'>
{_asset?.currentPath||''}
</Descriptions.Item>
</Descriptions>
<Divider style={{ margin: '10px 0' }} />
</div>
)
})
</React.Fragment>
}
{
(types||[]).map((type, index) => {
const _currentValues = (_asset?.elements||[]).filter(element => element.type===type);
return (
<div key={index}>
<div className='flex' style={{ alignItems: 'center', padding: (reference==='full-search'&&index===0)?'0 0 15px':'15px 0' }}>
<div style={{ width: 3, height: 14, backgroundColor: '#0069AC', marginRight: 5 }} />
<span style={{ fontWeight: 'bold', color: '#464646' }}>{type||''}</span>
</div>
<Descriptions column={2}>
{
(_currentValues||[]).map((item, index) => {
return (
<Descriptions.Item label={item.name||''} key={index}>
{
item.name==='资产项' ? <MetadataInfo config={false} value={item.value||''} terms={terms} /> : <span>{highlightSearchContentByTerms(item.value||'', terms)}</span>
}
</Descriptions.Item>
);
})
}
</Descriptions>
<Divider style={{ margin: '10px 0' }} />
</div>
)
})
}
</React.Fragment> : <div className='pb-4'>{loading?'':'暂无权限'}</div>
}
</Spin>
)
......
......@@ -543,7 +543,7 @@ const ImportAction = React.forwardRef((props, ref) => {
<Spin spinning={loading}>
{
(action==='detail' && ((modelerData||{}).optionList||[]).findIndex(item => item.enabled && item.name==='查看') === -1) ? <span>
暂无权限
{loading?'':'暂无权限'}
</span> : <React.Fragment>
<ImportActionHeader
form={form}
......
......@@ -565,7 +565,12 @@ const ModelTable = (props) => {
历史版本
</PermissionRcItem>
{
(getDataModelerRole(user)!==DataModelerRoleReader) && <PermissionRcItem id="copy" onClick={handleItemClick}>
(getDataModelerRole(user)!==DataModelerRoleReader) && <PermissionRcItem
id="copy"
onClick={handleItemClick}
permissionKey='新增'
permissions={currentItem?.optionList?.filter(item => item.enabled).map(item => item.name)}
>
复制模型
</PermissionRcItem>
}
......
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