Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
70221c38
Commit
70221c38
authored
Jun 15, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
操作优化
parent
5f903da3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
183 additions
and
99 deletions
+183
-99
ModelTable.jsx
src/view/Manage/Model/Component/ModelTable.jsx
+181
-97
index.jsx
src/view/Manage/Model/index.jsx
+2
-2
No files found.
src/view/Manage/Model/Component/ModelTable.jsx
View file @
70221c38
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
,
useMemo
}
from
"react"
;
import
{
Tooltip
,
Modal
,
Pagination
,
Typography
}
from
'antd'
;
import
{
DownOutlined
,
UpOutlined
}
from
'@ant-design/icons'
;
import
{
Tooltip
,
Modal
,
Pagination
,
Typography
,
Space
,
Menu
,
Dropdown
,
Row
,
Col
,
Divider
}
from
'antd'
;
import
{
DownOutlined
,
UpOutlined
,
UnorderedListOutlined
}
from
'@ant-design/icons'
;
import
copy
from
"copy-to-clipboard"
;
import
SmoothScroll
from
'smooth-scroll'
;
import
classnames
from
'classnames'
;
import
{
Resizable
}
from
'react-resizable'
;
...
...
@@ -23,6 +24,19 @@ import 'react-contexify/dist/ReactContexify.css';
const
{
Text
}
=
Typography
;
const
{
Column
}
=
Table
;
const
actions
=
[
{
title
:
'编辑'
,
key
:
'edit'
},
{
title
:
'删除'
,
key
:
'delete'
},
{
title
:
'URI复制'
,
key
:
'copyUri'
},
{
title
:
'样本数据'
,
key
:
'sample'
},
{
title
:
'历史版本'
,
key
:
'history'
},
{
title
:
'授权'
,
key
:
'admit'
},
{
title
:
'申请'
,
key
:
'startFlow'
},
{
title
:
'下载Tableau tds'
,
key
:
'downloadTds'
},
{
title
:
'跳转至电子表格'
,
key
:
'smart'
},
{
title
:
'更换管理人'
,
key
:
'exchangeOwner'
},
]
const
ModelNameColumn
=
(
props
)
=>
{
const
{
text
,
record
,
detailItem
}
=
props
;
const
[
data
,
setData
]
=
useState
(
record
);
...
...
@@ -308,6 +322,93 @@ const ModelTable = (props) => {
);
}
},
{
title
:
'操作'
,
dataIndex
:
'action'
,
width
:
240
,
fixed
:
'right'
,
render
:
(
_
,
record
)
=>
{
const
authActionTitles
=
[];
if
((
getDataModelerRole
(
user
)
!==
DataModelerRoleReader
)
&&
view
!==
'grant'
&&
!
isOnlyEnding
&&
(
record
.
editable
||
record
.
permitCheckOut
))
{
authActionTitles
.
push
(
'编辑'
);
}
if
((
getDataModelerRole
(
user
)
!==
DataModelerRoleReader
)
&&
view
!==
'grant'
&&
!
isOnlyEnding
&&
record
.
deletable
)
{
authActionTitles
.
push
(
'删除'
);
}
if
(
record
.
odata
)
{
authActionTitles
.
push
(
'URI复制'
);
}
authActionTitles
.
push
(
'样本数据'
);
authActionTitles
.
push
(
'历史版本'
);
if
(
getDataModelerRole
(
user
)
!==
DataModelerRoleReader
&&
view
!==
'grant'
&&
record
.
grantable
)
{
authActionTitles
.
push
(
'授权'
);
}
if
(
getDataModelerRole
(
user
)
!==
DataModelerRoleReader
&&
view
!==
'grant'
&&
isOnlyEnding
&&
!
currentItem
?.
grantable
)
{
authActionTitles
.
push
(
'申请'
);
}
if
(
getDataModelerRole
(
user
)
!==
DataModelerRoleReader
&&
view
!==
'grant'
&&
!
isOnlyEnding
&&
record
.
supportODataDisable
)
{
authActionTitles
.
push
(
'下载Tableau tds'
);
}
if
(
getDataModelerRole
(
user
)
!==
DataModelerRoleReader
&&
view
!==
'grant'
&&
record
.
supportSmartBIWebSpreadSheet
)
{
authActionTitles
.
push
(
'跳转至电子表格'
);
}
if
(
getDataModelerRole
(
user
)
!==
DataModelerRoleReader
&&
view
!==
'grant'
&&
record
.
supportChangeOwn
)
{
authActionTitles
.
push
(
'更换管理人'
);
}
const
authActions
=
actions
.
filter
(
item
=>
authActionTitles
.
indexOf
(
item
.
title
)
!==
-
1
);
const
haveMore
=
authActions
.
length
>
3
;
const
showActions
=
authActions
.
slice
(
0
,
3
);
const
hiddenActions
=
authActions
.
slice
(
3
,
authActions
.
length
);
console
.
log
(
'hiddenActions'
,
hiddenActions
);
return
(
<
Row
gutter=
{
20
}
>
{
showActions
.
map
((
item
,
index
)
=>
{
return
(
<
Col
key=
{
index
}
span=
{
6
}
>
<
a
onClick=
{
()
=>
{
handleItemClick
(
item
.
key
,
record
)}
}
>
{
item
.
title
}
</
a
>
</
Col
>
)
})
}
{
haveMore
?
<
Dropdown
overlay=
{
<
Menu
onClick=
{
({
key
})
=>
{
handleItemClick
(
key
,
record
);
}
}
>
{
hiddenActions
.
map
((
item
,
index
)
=>
{
return
(
<
Menu
.
Item
key=
{
index
}
value=
{
item
.
key
}
>
<
div
style=
{
{
textAlign
:
'center'
}
}
>
{
item
.
title
}
</
div
>
</
Menu
.
Item
>
)
})
}
</
Menu
>
}
placement=
"bottomLeft"
>
<
Col
span=
{
4
}
>
<
UnorderedListOutlined
className=
'default'
style=
{
{
fontSize
:
16
,
cursor
:
'pointer'
,
marginLeft
:
10
}
}
/>
</
Col
>
</
Dropdown
>
:
<
Col
span=
{
4
}
/>
}
</
Row
>
)
}
}
];
// const [ columns, setColumns ] = useState([]);
...
...
@@ -423,17 +524,92 @@ const ModelTable = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
data
,
pagination
,
sortRule
])
const
handleItemClick
=
(
id
,
record
)
=>
{
if
(
id
===
'edit'
)
{
if
(
record
?.
editable
)
{
editItem
(
record
);
}
else
if
(
record
?.
permitCheckOut
)
{
dispatch
({
type
:
'pds.checkoutService'
,
payload
:
{
params
:
{
id
:
record
?.
id
}
},
callback
:
data
=>
{
onChange
&&
onChange
();
editItem
(
data
);
}
})
}
}
else
if
(
id
===
'delete'
)
{
deleteItem
(
record
);
}
else
if
(
id
===
'sample'
)
{
setSampleParams
({
visible
:
true
,
service
:
record
})
}
else
if
(
id
===
'history'
)
{
historyItem
(
record
);
}
else
if
(
id
===
'copy'
)
{
window
.
open
(
`/data-govern/data-model-action?
${
Action
}
=add&
${
CatalogId
}
=
${(
view
===
'dir'
)?(
catalogId
||
''
):
''
}
&
${
ModelerId
}
=
${
record
.
id
}
`
);
}
else
if
(
id
===
'createTable'
)
{
deployAction
(
record
);
}
else
if
(
id
.
indexOf
(
'action'
)
!==
-
1
)
{
const
index
=
(
id
.
split
(
'-'
))[
1
];
const
action
=
record
?.
state
?.
supportedActions
[
index
];
stateAction
(
record
,
action
);
}
else
if
(
id
===
'admit'
)
{
app
.
openAdmit
?.({
dirId
:
catalogId
,
service
:
record
})
}
else
if
(
id
===
'enableOData'
)
{
startODataItem
(
record
);
}
else
if
(
id
===
'disableOData'
)
{
disableODataItem
(
record
);
}
else
if
(
id
===
'startFlow'
)
{
app
.
applyServer
?.({
service
:
record
});
}
else
if
(
id
===
'downloadTds'
)
{
window
.
open
(
`/api/pdataservice/pdsCURD/genTDS?id=
${
record
?.
id
}
`);
} else if (id === 'checkout') {
dispatch({
type: 'pds.checkoutService',
payload: {
params: {
id: record?.id
}
},
callback: () => {
showMessage('success', '检出成功');
onChange && onChange();
}
})
} else if (id === 'smart') {
dispatch({
type: 'pds.getSmartBiUrl',
payload: {
url: record?.smartBiWebSpreadSheetEntry
},
callback: (data) => {
window.open(data)
}
})
} else if (id === 'exchangeOwner') {
setExchangeOwnerParams({ visible: true, id: record?.id });
} else if (id === 'offline') {
offlineService(record);
} else if (id === 'copyUri') {
copy(record.odata);
showMessage('success', 'URI复制成功');
}
}
const columns = useMemo(() => {
let newCols = [...cols];
if ((visibleColNames||[]).length > 0) {
newCols
=
newCols
.
filter
(
col
=>
visibleColNames
.
indexOf
(
col
.
title
)
!==-
1
||
col
.
title
===
'序号'
);
newCols = newCols.filter(col => visibleColNames.indexOf(col.title)!==-1 || col.title==='序号'
|| col.title==='操作'
);
}
if (modelId) {
newCols.filter(col => col.title !=='序号');
}
return newCols;
},
[
visibleColNames
,
modelId
])
}, [visibleColNames, modelId
, handleItemClick, view, user, isOnlyEnding
])
const modelEventChange = (e) => {
if (e.key === 'modelChange') {
...
...
@@ -709,78 +885,6 @@ const ModelTable = (props) => {
})
}
const
handleItemClick
=
({
id
,
event
,
props
})
=>
{
if
(
id
===
'edit'
)
{
if
(
currentItem
?.
editable
)
{
editItem
(
currentItem
);
}
else
if
(
currentItem
?.
permitCheckOut
)
{
dispatch
({
type
:
'pds.checkoutService'
,
payload
:
{
params
:
{
id
:
currentItem
?.
id
}
},
callback
:
data
=>
{
onChange
&&
onChange
();
editItem
(
data
);
}
})
}
}
else
if
(
id
===
'delete'
)
{
deleteItem
(
currentItem
);
}
else
if
(
id
===
'sample'
)
{
setSampleParams
({
visible
:
true
,
service
:
currentItem
})
}
else
if
(
id
===
'history'
)
{
historyItem
(
currentItem
);
}
else
if
(
id
===
'copy'
)
{
window
.
open
(
`/data-govern/data-model-action?
${
Action
}
=add&
${
CatalogId
}
=
${(
view
===
'dir'
)?(
catalogId
||
''
):
''
}
&
${
ModelerId
}
=
${
currentItem
.
id
}
`
);
}
else
if
(
id
===
'createTable'
)
{
deployAction
(
currentItem
);
}
else
if
(
id
.
indexOf
(
'action'
)
!==
-
1
)
{
const
index
=
(
id
.
split
(
'-'
))[
1
];
const
action
=
currentItem
?.
state
?.
supportedActions
[
index
];
stateAction
(
currentItem
,
action
);
}
else
if
(
id
===
'admit'
)
{
app
.
openAdmit
?.({
dirId
:
catalogId
,
service
:
currentItem
})
}
else
if
(
id
===
'enableOData'
)
{
startODataItem
(
currentItem
);
}
else
if
(
id
===
'disableOData'
)
{
disableODataItem
(
currentItem
);
}
else
if
(
id
===
'startFlow'
)
{
app
.
applyServer
?.({
service
:
currentItem
});
}
else
if
(
id
===
'downloadTds'
)
{
window
.
open
(
`/api/pdataservice/pdsCURD/genTDS?id=
${
currentItem
?.
id
}
`);
} else if (id === 'checkout') {
dispatch({
type: 'pds.checkoutService',
payload: {
params: {
id: currentItem?.id
}
},
callback: () => {
showMessage('success', '检出成功');
onChange && onChange();
}
})
} else if (id === 'smart') {
dispatch({
type: 'pds.getSmartBiUrl',
payload: {
url: currentItem?.smartBiWebSpreadSheetEntry
},
callback: (data) => {
window.open(data)
}
})
} else if (id === 'exchangeOwner') {
setExchangeOwnerParams({ visible: true, id: currentItem?.id });
} else if (id === 'offline') {
offlineService(currentItem);
}
}
const onServiceDetailClose = () => {
setServiceDetailParams({ visible: false, id: '' })
}
...
...
@@ -865,17 +969,12 @@ const ModelTable = (props) => {
/>
}
<RcMenu id={MENU_ID}>
{
{
/* {
(getDataModelerRole(user)!==DataModelerRoleReader) && view!=='grant' && !isOnlyEnding && <RcItem id="edit" disabled={!currentItem?.editable&&!currentItem?.permitCheckOut} onClick={handleItemClick}>
编辑
</RcItem>
}
{
// getDataModelerRole(user)!==DataModelerRoleReader && view!=='grant' && !isOnlyEnding && currentItem?.permitCheckOut && <RcItem id="checkout" onClick={handleItemClick}>
// 检出
// </RcItem>
}
{
(getDataModelerRole(user)!==DataModelerRoleReader) && view!=='grant'&& !isOnlyEnding && <RcItem id="delete" disabled={!currentItem?.deletable} onClick={handleItemClick}>
<Tooltip title={deleteTip}>
删除
...
...
@@ -888,11 +987,6 @@ const ModelTable = (props) => {
<RcItem id="history" onClick={handleItemClick}>
历史版本
</RcItem>
{/* {
(getDataModelerRole(user)!==DataModelerRoleReader) && <RcItem id="copy" onClick={handleItemClick}>
复制服务
</RcItem>
} */}
{
getDataModelerRole(user)!==DataModelerRoleReader && view!=='grant' && (currentItem?.state?.supportedActions||[]).length>0 && currentItem?.state?.supportedActions.map((item, index) => {
return (
...
...
@@ -913,11 +1007,6 @@ const ModelTable = (props) => {
</RcItem>
}
{
// getDataModelerRole(user)!==DataModelerRoleReader && view!=='grant' && currentItem?.supportOffline && <RcItem id="offline" onClick={handleItemClick} >
// 下线
// </RcItem>
}
{
getDataModelerRole(user)!==DataModelerRoleReader && view!=='grant' && !isOnlyEnding && currentItem?.supportODataEnable && <RcItem id="enableOData" onClick={handleItemClick}>
启动OData
</RcItem>
...
...
@@ -941,11 +1030,6 @@ const ModelTable = (props) => {
getDataModelerRole(user)!==DataModelerRoleReader && view!=='grant' && currentItem?.supportChangeOwn && <RcItem id="exchangeOwner" onClick={handleItemClick}>
更换管理人
</RcItem>
}
{/* {
getDataModelerRole(user)!==DataModelerRoleReader &¤tItem?.deployable && <RcItem id='createTable' onClick={handleItemClick}>
建表
</RcItem>
} */}
</RcMenu>
...
...
src/view/Manage/Model/index.jsx
View file @
70221c38
...
...
@@ -654,11 +654,11 @@ class Model extends React.Component {
</Tooltip>
</Space> */}
<Space>
{/*
<Space>
<Tooltip title={(selectModelerIds||[]).length===0?'请先选择服务':''}>
<Button onClick={this.onRecatalogBtnClick} disabled={(selectModelerIds||[]).length===0}>变更目录</Button>
</Tooltip>
</Space>
</Space>
*/}
{/* <Space>
<Tooltip title={(selectModelerIds||[]).length===0?'请先选择服务':''}>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment