Commit 8213b630 by zhaochengxiang

存量模型导入权限控制

parent e7d85537
import React, { useState, useEffect, useContext } from "react"; import React, { useState, useEffect, useContext, useMemo } from "react";
import { Tooltip, Tree, Modal, Spin, Dropdown, Menu, Button, AutoComplete } from "antd"; import { Tooltip, Tree, Modal, Spin, Dropdown, Menu, Button, AutoComplete } from "antd";
import { PlusOutlined, SyncOutlined, ImportOutlined, UnorderedListOutlined, ReloadOutlined } from '@ant-design/icons'; import { PlusOutlined, SyncOutlined, ImportOutlined, UnorderedListOutlined, ReloadOutlined } from '@ant-design/icons';
import classnames from 'classnames'; import classnames from 'classnames';
...@@ -107,6 +107,10 @@ const ModelTree = (props) => { ...@@ -107,6 +107,10 @@ const ModelTree = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ keyword ]) }, [ keyword ])
const haveStockImportPermission = useMemo(() => {
return (item?.optionList||[]).findIndex(option => option.name==='存量模型导入'&&option.enabled) !== -1
}, [item])
const getShowSyncAndDomains = () => { const getShowSyncAndDomains = () => {
dispatch({ dispatch({
type: 'datamodel.isSetRootDomainId', type: 'datamodel.isSetRootDomainId',
...@@ -517,7 +521,7 @@ const ModelTree = (props) => { ...@@ -517,7 +521,7 @@ const ModelTree = (props) => {
borderBottom: "1px solid #EFEFEF", borderBottom: "1px solid #EFEFEF",
height: 57, height: 57,
alignItems: 'center', alignItems: 'center',
justifyContent: (viewSelectedKey==='dir' && isAdmin)?'space-between':'', justifyContent: 'space-between',
}} }}
> >
<Dropdown overlay={exportMenu} placement="bottomLeft"> <Dropdown overlay={exportMenu} placement="bottomLeft">
...@@ -528,28 +532,28 @@ const ModelTree = (props) => { ...@@ -528,28 +532,28 @@ const ModelTree = (props) => {
{ {
(viewSelectedKey==='dir' && isAdmin) && ( (viewSelectedKey==='dir' && isAdmin) && (
<Tooltip title="新增目录" className='ml-2'> <Tooltip title="新增目录">
<PlusOutlined className='default' onClick={add} style={{ fontSize:16,cursor:'pointer' }} /> <PlusOutlined className='default' onClick={add} style={{ fontSize:16,cursor:'pointer' }} />
</Tooltip> </Tooltip>
) )
} }
{ {
(viewSelectedKey==='dir' && isAdmin) && ( (viewSelectedKey==='dir') && (
<Tooltip title="存量模型导入" className='ml-2'> <Tooltip title={haveStockImportPermission?'存量模型导入':'暂无权限'}>
<ImportOutlined className='default' onClick={() => { importStockModel && importStockModel() }} style={{ fontSize:16,cursor:'pointer' }} /> <ImportOutlined className={(!haveStockImportPermission)?'disable': 'default'} onClick={() => { haveStockImportPermission && importStockModel && importStockModel() }} style={{ fontSize:16,cursor:(!haveStockImportPermission)?'not-allowed':'pointer' }} />
</Tooltip> </Tooltip>
) )
} }
<Tooltip title="刷新目录" className='ml-2'> <Tooltip title="刷新目录">
<Button type='text' icon={<ReloadOutlined className='default' />} size='small' onClick={refresh} /> <ReloadOutlined className='default' onClick={refrence} style={{ fontSize:16,cursor:'pointer' }} />
</Tooltip> </Tooltip>
{ {
(viewSelectedKey==='dir' && isAdmin) && !isSetRootId && ( (viewSelectedKey==='dir' && isAdmin) && !isSetRootId && (
<Dropdown overlay={syncMenu} placement="bottomLeft"> <Dropdown overlay={syncMenu} placement="bottomLeft">
<Tooltip title="同步目录"> <Tooltip title="同步目录">
<SyncOutlined className='default ml-2' style={{ fontSize:16,cursor:'pointer' }} /> <SyncOutlined className='default' style={{ fontSize:16,cursor:'pointer' }} />
</Tooltip> </Tooltip>
</Dropdown> </Dropdown>
) )
...@@ -557,11 +561,25 @@ const ModelTree = (props) => { ...@@ -557,11 +561,25 @@ const ModelTree = (props) => {
{ {
(viewSelectedKey==='dir' && isAdmin) && isSetRootId && ( (viewSelectedKey==='dir' && isAdmin) && isSetRootId && (
<Tooltip title="同步目录" className='ml-2'> <Tooltip title="同步目录" className='ml-2'>
<Button type='text' icon={<SyncOutlined className='default' />} size='small' onClick={sync} /> <SyncOutlined className='default' style={{ fontSize:16,cursor:'pointer' }} onClick={sync} />
</Tooltip> </Tooltip>
) )
} }
{
(viewSelectedKey==='dir' && !isAdmin) && <React.Fragment>
<div style={{ width: 16 }}></div>
<div style={{ width: 16 }}></div>
</React.Fragment>
}
{
(viewSelectedKey!=='dir') && <React.Fragment>
<div style={{ width: 16 }}></div>
<div style={{ width: 16 }}></div>
<div style={{ width: 16 }}></div>
</React.Fragment>
}
</div> </div>
} }
<div className='p-3'> <div className='p-3'>
......
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