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
195484da
Commit
195484da
authored
Nov 29, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
右键
parent
eb9cb921
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
125 additions
and
155 deletions
+125
-155
ImportActionTable.jsx
src/view/Manage/Model/Component/ImportActionTable.jsx
+125
-155
No files found.
src/view/Manage/Model/Component/ImportActionTable.jsx
View file @
195484da
import
React
,
{
useState
,
useCallback
,
useRef
,
useEffect
,
useContext
}
from
'react'
;
import
React
,
{
useState
,
useCallback
,
useRef
,
useEffect
,
useContext
,
useMemo
}
from
'react'
;
import
{
Input
,
Form
,
Typography
,
Button
,
Select
,
Row
,
Col
,
Popover
,
Checkbox
,
Tooltip
,
Table
,
Pagination
,
Space
}
from
'antd'
;
import
{
Input
,
Form
,
Typography
,
Button
,
Select
,
Row
,
Col
,
Popover
,
Checkbox
,
Tooltip
,
Table
,
Pagination
,
Space
}
from
'antd'
;
import
{
CheckOutlined
,
PlusOutlined
,
QuestionCircleOutlined
,
DeleteOutlined
}
from
'@ant-design/icons'
;
import
{
CheckOutlined
,
PlusOutlined
,
QuestionCircleOutlined
,
DeleteOutlined
}
from
'@ant-design/icons'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
...
@@ -290,6 +290,8 @@ export const ImportActionTable = (props) => {
...
@@ -290,6 +290,8 @@ export const ImportActionTable = (props) => {
const
termsRef
=
useRef
(
null
);
const
termsRef
=
useRef
(
null
);
const
autoTranslateRef
=
useRef
(
false
);
const
autoTranslateRef
=
useRef
(
false
);
const
app
=
useContext
(
AppContext
)
const
{
show
}
=
useContextMenu
({
const
{
show
}
=
useContextMenu
({
id
:
MENU_ID
,
id
:
MENU_ID
,
});
});
...
@@ -417,23 +419,6 @@ export const ImportActionTable = (props) => {
...
@@ -417,23 +419,6 @@ export const ImportActionTable = (props) => {
return '';
return '';
}
}
},
},
// {
// title: '重点关注',
// width: 75,
// dataIndex: 'needAttention',
// editable: (type==='model'?true:false),
// render: (needAttention, record, index) => {
// if (!needAttention) {
// return '-';
// } else if (needAttention === true) {
// return (
// <CheckOutlined />
// )
// }
// return '';
// }
// },
{
{
title: '业务含义',
title: '业务含义',
dataIndex: 'remark',
dataIndex: 'remark',
...
@@ -567,6 +552,41 @@ export const ImportActionTable = (props) => {
...
@@ -567,6 +552,41 @@ export const ImportActionTable = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [validateReports, editable, editingKey])
}, [validateReports, editable, editingKey])
const menuData = useMemo(() => {
let newMenuData = []
if (action === 'flow') {
if (currentItem?.isPossibleNewRecommendedDefinition?.possible) {
newMenuData.push({
title: '加入标准',
key: 'addToStandard',
})
}
if (currentItem?.isPossibleNewTerm?.possible) {
newMenuData.push({
title: '加入词汇',
key: 'addToWord',
})
}
}
if (editable) {
newMenuData = [...newMenuData, ...[
{ title: '在上方插入行', key: 'up' },
{ title: '在下方插入行', key: 'down' },
{ title: '删除', key: 'delete' },
]]
if (originAction !== 'flow') {
newMenuData.push({
title: currentItem?.needAttention ? '取消送审关注': '送审关注',
key: 'attention'
})
}
}
return newMenuData;
}, [currentItem, action, originAction, editable])
const isEditing = (record) => record?.iid === editingKey;
const isEditing = (record) => record?.iid === editingKey;
const onAddClick = (event) => {
const onAddClick = (event) => {
...
@@ -600,7 +620,7 @@ export const ImportActionTable = (props) => {
...
@@ -600,7 +620,7 @@ export const ImportActionTable = (props) => {
})
})
}
}
const
insertToFront
= (record) => {
const
onInsertToFrontClick
= (record) => {
save().then(result => {
save().then(result => {
if (result) {
if (result) {
setKeywordCondition({ keyword: '', needFilter: false });
setKeywordCondition({ keyword: '', needFilter: false });
...
@@ -631,7 +651,7 @@ export const ImportActionTable = (props) => {
...
@@ -631,7 +651,7 @@ export const ImportActionTable = (props) => {
})
})
}
}
const
insertToBa
ck = (record) => {
const
onInsertToBackCli
ck = (record) => {
save().then(result => {
save().then(result => {
if (result) {
if (result) {
setKeywordCondition({ keyword: '', needFilter: false });
setKeywordCondition({ keyword: '', needFilter: false });
...
@@ -693,7 +713,7 @@ export const ImportActionTable = (props) => {
...
@@ -693,7 +713,7 @@ export const ImportActionTable = (props) => {
onChange && onChange(newData);
onChange && onChange(newData);
}
}
const
remove
= (record) => {
const
onRemoveClick
= (record) => {
if (record.iid !== editingKey) {
if (record.iid !== editingKey) {
save().then(result => {
save().then(result => {
if (result) {
if (result) {
...
@@ -705,6 +725,50 @@ export const ImportActionTable = (props) => {
...
@@ -705,6 +725,50 @@ export const ImportActionTable = (props) => {
}
}
}
}
const onAttentionClick = (record) => {
if (record.needAttention === null) {
record.needAttention = true;
} else {
record.needAttention = !record.needAttention;
}
const newData = [...moveRowRef.current.data];
const index = newData.findIndex((item) => record.iid === item.iid);
if (index !== -1) {
newData.splice(index, 1, {...record});
setData(newData);
moveRowRef.current.data = newData;
onChange && onChange(newData, false);
if (!record.needAttention) {
preSaveDataModel(record);
}
}
}
const onAddToStandardClick = (record) => {
app.setGlobalState?.({
message: 'data-govern-show-standard-create',
data: {
column: {...record, ...{ modelName: modelerData?.name, modelCnName: modelerData?.cnName }},
type: record?.isPossibleNewRecommendedDefinition?.type
}
});
}
const onAddToWordClick = (record) => {
app.setGlobalState?.({
message: 'data-govern-show-standard-create',
data: {
column: record,
type: record?.isPossibleNewTerm?.type
}
})
}
const preSaveDataModel = (attribute) => {
const preSaveDataModel = (attribute) => {
dispatch({
dispatch({
type: 'datamodel.preSaveDataModel',
type: 'datamodel.preSaveDataModel',
...
@@ -916,129 +980,9 @@ export const ImportActionTable = (props) => {
...
@@ -916,129 +980,9 @@ export const ImportActionTable = (props) => {
setSuggests([]);
setSuggests([]);
};
};
const editableColumn = [
...cols,
{
title: '操作',
dataIndex: 'action',
width: (action==='flow')?220: ((originAction==='flow')?90:130),
fixed: 'right',
render: (_, record) => {
return (
<AppContext.Consumer>
{
value => <React.Fragment>
{
(action==='flow') && <React.Fragment>
{
record?.isPossibleNewRecommendedDefinition?.possible && <Typography.Link className='mr-3' onClick={(event) => {
event.stopPropagation();
value?.setGlobalState && value?.setGlobalState({
message: 'data-govern-show-standard-create',
data: {
column: {...record, ...{ modelName: modelerData?.name, modelCnName: modelerData?.cnName }},
type: record?.isPossibleNewRecommendedDefinition?.type
}
});
}}>
加入标准
</Typography.Link>
}
{
record?.isPossibleNewTerm?.possible && <Typography.Link className='mr-3' onClick={(event) => {
event.stopPropagation();
value?.setGlobalState && value?.setGlobalState({
message: 'data-govern-show-standard-create',
data: {
column: record,
type: record?.isPossibleNewTerm?.type
}
})
}}>
加入词汇
</Typography.Link>
}
</React.Fragment>
}
{
editable && <React.Fragment>
{
<React.Fragment>
{
(originAction!=='flow') && <Tooltip title={record.needAttention ? '取消送审关注': '送审关注'}>
<Button
className='mr-3'
size='small'
type='text'
icon={record.needAttention ? <AttentionSvg style={{ width: 15, height: 15 }} /> : <UnAttentionSvg style={{ width: 15, height: 15 }} />}
onClick={(event) => {
event.stopPropagation();
if (record.needAttention === null) {
record.needAttention = true;
} else {
record.needAttention = !record.needAttention;
}
const newData = [...moveRowRef.current.data];
const index = newData.findIndex((item) => record.iid === item.iid);
if (index !== -1) {
newData.splice(index, 1, {...record});
setData(newData);
moveRowRef.current.data = newData;
onChange && onChange(newData, false);
if (!record.needAttention) {
preSaveDataModel(record);
}
}
}}
/>
</Tooltip>
}
<Button
className='mr-3'
size='small'
type='text'
icon={<PlusOutlined className='default' />}
onClick={(event) => {
event.stopPropagation();
insertToFront(record);
}}
/>
<Button
className='mr-3'
size='small'
type='text'
icon={<DeleteOutlined style={{ color: 'red' }} />}
onClick={(event) => {
event.stopPropagation();
remove(record);
}}
/>
</React.Fragment>
}
</React.Fragment>
}
</React.Fragment>
}
</AppContext.Consumer>
)
},
},
]
const mergedColumns = () => {
const mergedColumns = () => {
if (editable) {
if (editable) {
let _columns = editableColumn;
const _columns = cols.map((col) => {
_columns = _columns.map((col) => {
if (!col.editable) {
if (!col.editable) {
return col;
return col;
}
}
...
@@ -1078,15 +1022,7 @@ export const ImportActionTable = (props) => {
...
@@ -1078,15 +1022,7 @@ export const ImportActionTable = (props) => {
setColumns(_columns);
setColumns(_columns);
} else {
} else {
let _columns = cols;
setColumns(cols);
if (action === 'flow') {
_columns = editableColumn;
}
// _columns = _columns.filter((col) => col.dataIndex!=='needAttention');
setColumns(_columns);
}
}
}
}
...
@@ -1146,9 +1082,17 @@ export const ImportActionTable = (props) => {
...
@@ -1146,9 +1082,17 @@ export const ImportActionTable = (props) => {
const key = event.currentTarget.id;
const key = event.currentTarget.id;
if (key === 'up') {
if (key === 'up') {
insertToFront
(currentItem);
onInsertToFrontClick
(currentItem);
} else if (key === 'down') {
} else if (key === 'down') {
insertToBack(currentItem);
onInsertToBackClick(currentItem);
} else if (key === 'delete') {
onRemoveClick(currentItem);
} else if (key === 'attention') {
onAttentionClick(currentItem);
} else if (key === 'addToStandard') {
onAddToStandardClick(currentItem);
} else if (key === 'addToWord') {
onAddToWordClick(currentItem);
}
}
}
}
...
@@ -1245,19 +1189,30 @@ export const ImportActionTable = (props) => {
...
@@ -1245,19 +1189,30 @@ export const ImportActionTable = (props) => {
return 'editable-row';
return 'editable-row';
}}
}}
onRow={(record, index) => {
onRow={(record, index) => {
let rowParams = {
let rowParams = {
index,
index,
id: `
field
-
$
{
record
.
iid
}
`,
id: `
field
-
$
{
record
.
iid
}
`,
}
}
let shouldRowContextMenu = false
if (action==='flow') {
if (record?.isPossibleNewRecommendedDefinition?.possible || record?.isPossibleNewTerm?.possible) {
shouldRowContextMenu = true
}
}
if (editable) {
if (editable) {
shouldRowContextMenu = true
}
if (shouldRowContextMenu) {
rowParams = {...rowParams, onContextMenu: event => {
rowParams = {...rowParams, onContextMenu: event => {
setCurrentItem(record);
setCurrentItem(record);
displayMenu(event);
displayMenu(event);
}
}
};
};
}
if (editable) {
if (!isEditing(record)) {
if (!isEditing(record)) {
rowParams = {...rowParams, onClick: (event) => {
rowParams = {...rowParams, onClick: (event) => {
event.stopPropagation();
event.stopPropagation();
...
@@ -1341,12 +1296,27 @@ export const ImportActionTable = (props) => {
...
@@ -1341,12 +1296,27 @@ export const ImportActionTable = (props) => {
}
}
<RcMenu id={MENU_ID} >
<RcMenu id={MENU_ID} >
<RcItem id="up" onClick={handleItemClick}>
{
(menuData??[]).map(item => (
<RcItem key={item.key} id={item.key} onClick={handleItemClick}>
{item.title}
</RcItem>
))
}
{/* <RcItem id="up" onClick={handleItemClick}>
在上方插入行
在上方插入行
</RcItem>
</RcItem>
<RcItem id="down" onClick={handleItemClick}>
<RcItem id="down" onClick={handleItemClick}>
在下方插入行
在下方插入行
</RcItem>
</RcItem>
{
(originAction!=='flow') && <RcItem id="attention" onClick={handleItemClick}>
{currentItem?.needAttention ? '取消送审关注': '送审关注'}
</RcItem>
}
<RcItem id="delete" onClick={handleItemClick}>
删除
</RcItem> */}
</RcMenu>
</RcMenu>
</div>
</div>
...
...
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