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
1e0e1b61
Commit
1e0e1b61
authored
Apr 22, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加模型索引
parent
5736f07a
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
432 additions
and
162 deletions
+432
-162
AssetBin.jsx
src/view/Manage/AssetManage/components/AssetBin.jsx
+0
-0
AssetTable.jsx
src/view/Manage/AssetManage/components/AssetTable.jsx
+6
-2
ImportElement.jsx
src/view/Manage/AssetManage/components/ImportElement.jsx
+1
-1
ImportAction.jsx
src/view/Manage/Model/Component/ImportAction.jsx
+48
-6
ImportActionIndex.jsx
src/view/Manage/Model/Component/ImportActionIndex.jsx
+361
-144
ImportActionTable.jsx
src/view/Manage/Model/Component/ImportActionTable.jsx
+15
-8
ImportModal.jsx
src/view/Manage/Model/Component/ImportModal.jsx
+1
-1
No files found.
src/view/Manage/AssetManage/components/AssetBin.jsx
deleted
100644 → 0
View file @
5736f07a
src/view/Manage/AssetManage/components/AssetTable.jsx
View file @
1e0e1b61
...
@@ -9,7 +9,7 @@ import AssetModal from "./AssetModal"
...
@@ -9,7 +9,7 @@ import AssetModal from "./AssetModal"
import
AssetDetail
from
"./AssetDetail"
import
AssetDetail
from
"./AssetDetail"
import
AssetItem
from
'./AssetItem'
;
import
AssetItem
from
'./AssetItem'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
showMessage
}
from
'../../../../util'
;
import
{
showMessage
,
showNotifaction
}
from
'../../../../util'
;
import
"./AssetTable.less"
;
import
"./AssetTable.less"
;
...
@@ -205,8 +205,12 @@ const AssetTable = (props) =>{
...
@@ -205,8 +205,12 @@ const AssetTable = (props) =>{
refresh
&&
getTable
();
refresh
&&
getTable
();
}
}
const
onImportElementVisibleChange
=
(
visible
=
false
)
=>
{
const
onImportElementVisibleChange
=
(
visible
=
false
,
tip
=
''
)
=>
{
setImportElementVisible
(
visible
);
setImportElementVisible
(
visible
);
if
(
tip
&&
tip
!==
''
)
{
showNotifaction
(
'导入提示'
,
tip
,
5
);
}
}
}
const
onFilterElementVisibleChange
=
(
visible
=
false
,
refresh
=
false
)
=>
{
const
onFilterElementVisibleChange
=
(
visible
=
false
,
refresh
=
false
)
=>
{
...
...
src/view/Manage/AssetManage/components/ImportElement.jsx
View file @
1e0e1b61
...
@@ -46,7 +46,7 @@ const ImportElement = (props) => {
...
@@ -46,7 +46,7 @@ const ImportElement = (props) => {
callback
:
data
=>
{
callback
:
data
=>
{
setConfirmLoading
(
false
);
setConfirmLoading
(
false
);
reset
();
reset
();
onCancel
&&
onCancel
();
onCancel
&&
onCancel
(
false
,
data
);
},
},
error
:
()
=>
{
error
:
()
=>
{
setConfirmLoading
(
false
);
setConfirmLoading
(
false
);
...
...
src/view/Manage/Model/Component/ImportAction.jsx
View file @
1e0e1b61
...
@@ -3,7 +3,7 @@ import { Select } from 'antd';
...
@@ -3,7 +3,7 @@ import { Select } from 'antd';
import
ImportActionHeader
from
'./ImportActionHeader'
;
import
ImportActionHeader
from
'./ImportActionHeader'
;
import
ImportActionTable
from
'./ImportActionTable'
;
import
ImportActionTable
from
'./ImportActionTable'
;
//
import ImportActionIndex from './ImportActionIndex';
import
ImportActionIndex
from
'./ImportActionIndex'
;
import
{
dispatchLatest
,
dispatch
}
from
'../../../../model'
;
import
{
dispatchLatest
,
dispatch
}
from
'../../../../model'
;
...
@@ -82,8 +82,11 @@ const ImportAction = (props) => {
...
@@ -82,8 +82,11 @@ const ImportAction = (props) => {
data
data
},
},
callback
:
data
=>
{
callback
:
data
=>
{
setModelerData
({...
modelerData
,
easyDataModelerDataModelAttributes
:
[...
data
.
easyDataModelerDataModelAttributes
]
})
let
newModelerData
=
{...(
data
||
{})};
onChange
&&
onChange
(
data
||
{});
newModelerData
=
{
...
newModelerData
,
easyDataModelerIndices
:
getIndicesWhenTableChange
(
newModelerData
)
}
setModelerData
(
newModelerData
)
onChange
&&
onChange
(
newModelerData
);
}
}
})
})
}
}
...
@@ -149,6 +152,7 @@ const ImportAction = (props) => {
...
@@ -149,6 +152,7 @@ const ImportAction = (props) => {
});
});
const
newModelerData
=
{...
modelerData
,
easyDataModelerModelingTemplate
:
currentTemplate
};
const
newModelerData
=
{...
modelerData
,
easyDataModelerModelingTemplate
:
currentTemplate
};
setModelerData
(
newModelerData
)
setModelerData
(
newModelerData
)
onChange
&&
onChange
(
newModelerData
);
onChange
&&
onChange
(
newModelerData
);
...
@@ -168,7 +172,9 @@ const ImportAction = (props) => {
...
@@ -168,7 +172,9 @@ const ImportAction = (props) => {
//validate 是否需要对字段进行校验
//validate 是否需要对字段进行校验
const
onTableChange
=
(
data
,
validate
=
false
)
=>
{
const
onTableChange
=
(
data
,
validate
=
false
)
=>
{
const
newModelerData
=
{...
modelerData
,
easyDataModelerDataModelAttributes
:
data
};
let
newModelerData
=
{...
modelerData
,
...{
easyDataModelerDataModelAttributes
:
data
}};
newModelerData
=
{
...
newModelerData
,
easyDataModelerIndices
:
getIndicesWhenTableChange
(
newModelerData
)
};
setModelerData
(
newModelerData
);
setModelerData
(
newModelerData
);
onChange
&&
onChange
(
newModelerData
);
onChange
&&
onChange
(
newModelerData
);
...
@@ -190,6 +196,35 @@ const ImportAction = (props) => {
...
@@ -190,6 +196,35 @@ const ImportAction = (props) => {
})
})
}
}
const
onIndexChange
=
(
data
)
=>
{
const
newModelerData
=
{...
modelerData
,
easyDataModelerIndices
:
data
};
setModelerData
(
newModelerData
);
onChange
&&
onChange
(
newModelerData
);
}
const
getIndicesWhenTableChange
=
(
newModelerData
)
=>
{
const
newEasyDataModelerIndices
=
[...(
newModelerData
.
easyDataModelerIndices
||
[])];
(
newModelerData
.
easyDataModelerIndices
||
[]).
forEach
((
easyDataModelerIndex
,
index
)
=>
{
const
newIndexedEasyDataModelAttributes
=
[],
newIndexedAttributeOrders
=
[];
(
easyDataModelerIndex
.
indexedEasyDataModelAttributes
||
[]).
forEach
((
indexedEasyDataModelAttribute
,
_index
)
=>
{
const
__index
=
(
newModelerData
.
easyDataModelerDataModelAttributes
||
[]).
findIndex
(
item
=>
item
.
iid
===
indexedEasyDataModelAttribute
.
iid
);
if
(
__index
!==
-
1
)
{
newIndexedEasyDataModelAttributes
.
push
({...
newModelerData
.
easyDataModelerDataModelAttributes
[
__index
]});
newIndexedAttributeOrders
.
push
(
easyDataModelerIndex
.
indexedAttributeOrders
[
_index
]);
}
})
const
item
=
newEasyDataModelerIndices
[
index
];
newEasyDataModelerIndices
.
splice
(
index
,
1
,
{...
item
,
...{
indexedEasyDataModelAttributes
:
newIndexedEasyDataModelAttributes
,
indexedAttributeOrders
:
newIndexedAttributeOrders
}}
)
})
return
newEasyDataModelerIndices
.
filter
(
item
=>
(
item
.
indexedEasyDataModelAttributes
||
[]).
length
>
0
);
}
return
(
return
(
<>
<>
{
{
...
@@ -219,8 +254,15 @@ const ImportAction = (props) => {
...
@@ -219,8 +254,15 @@ const ImportAction = (props) => {
validateReports=
{
validateReports
}
validateReports=
{
validateReports
}
supportedDatatypes=
{
supportedDatatypes
}
supportedDatatypes=
{
supportedDatatypes
}
onChange=
{
onTableChange
}
onChange=
{
onTableChange
}
editable=
{
action
!==
'detail'
}
/>
editable=
{
action
!==
'detail'
}
{
/* <ImportActionIndex data={indexData} fileds={fileds} onChange={onIndexChange} editable={action!=='detail'} /> */
}
/>
<
ImportActionIndex
modelerData=
{
modelerData
||
{}
}
constraint=
{
constraint
}
template=
{
template
}
onChange=
{
onIndexChange
}
editable=
{
action
!==
'detail'
}
/>
</>
</>
);
);
};
};
...
...
src/view/Manage/Model/Component/ImportActionIndex.jsx
View file @
1e0e1b61
import
React
,
{
useState
,
useCallback
,
useRef
}
from
'react'
;
import
React
,
{
useState
,
useCallback
,
useRef
,
useEffect
}
from
'react'
;
import
{
Table
,
Input
,
Form
,
Typography
,
Divider
,
Button
,
Select
}
from
'antd'
;
import
{
Table
,
Input
,
Form
,
Typography
,
Divider
,
Button
,
Select
,
Row
,
Col
,
Popover
,
Checkbox
,
Tooltip
}
from
'antd'
;
import
{
QuestionCircleOutlined
,
DeleteOutlined
}
from
'@ant-design/icons'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
import
{
DndProvider
,
useDrag
,
useDrop
}
from
'react-dnd'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
{
HTML5Backend
}
from
'react-dnd-html5-backend'
;
import
update
from
'immutability-helper'
;
import
update
from
'immutability-helper'
;
import
'./ImportActionTable.less'
;
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
const
type
=
'DragableIndexBodyRow'
;
const
type
=
'DragableIndexBodyRow'
;
const
modes
=
[
const
AttributesInputItem
=
({
indexedAttribute
=
null
,
indexedAttributeOrder
=
null
,
attributes
,
onAttributeChange
,
onOrderChange
,
onDelete
,
className
})
=>
{
'主键索引'
,
'唯一索引'
,
'普通索引'
,
'组合索引'
,
'全文索引'
];
const
EditableCell
=
({
editing
,
dataIndex
,
title
,
inputType
,
fileds
,
record
,
index
,
children
,
...
restProps
})
=>
{
let
inputNode
=
<
Input
/>;
return
(
if
(
inputType
===
'select'
)
{
<
Row
align=
'middle'
className=
{
className
}
>
inputNode
=
(
<
Col
span=
{
4
}
>
<
Select
>
<
span
>
字段名称:
</
span
>
</
Col
>
<
Col
span=
{
6
}
>
<
Select
onChange=
{
(
value
)
=>
{
onAttributeChange
&&
onAttributeChange
(
value
)
}
}
value=
{
indexedAttribute
?
(
indexedAttribute
.
name
||
''
)
:
''
}
placeholder=
'请选择字段名称'
>
{
{
modes
&&
modes
.
map
((
mod
e
,
index
)
=>
{
(
attributes
||
[]).
map
((
attribut
e
,
index
)
=>
{
return
(
return
(
<
Option
key=
{
mode
}
>
{
mode
}
</
Option
>
((
attribute
.
name
||
''
)
===
''
)
?
null
:
<
Option
key=
{
index
}
value=
{
attribute
.
iid
||
''
}
>
{
attribute
.
name
||
''
}
</
Option
>
);
);
})
})
}
}
</
Select
>
</
Select
>
)
</
Col
>
}
else
if
(
inputType
===
'select-multiple'
)
{
<
Col
span=
{
1
}
></
Col
>
inputNode
=
(
<
Col
span=
{
2
}
>
<
Select
mode=
"multiple"
>
<
span
>
排序:
</
span
>
</
Col
>
<
Col
span=
{
6
}
>
<
Select
onChange=
{
(
value
)
=>
{
onOrderChange
&&
onOrderChange
(
value
)
}
}
value=
{
indexedAttributeOrder
||
''
}
placeholder=
'请选择排序方式'
>
<
Option
value=
'DESC'
>
DESC
</
Option
>
<
Option
value=
'ASC'
>
ASC
</
Option
>
</
Select
>
</
Col
>
<
Col
span=
{
1
}
></
Col
>
<
Col
span=
{
2
}
>
<
Tooltip
title=
"删除"
>
<
Button
type=
"text"
icon=
{
<
DeleteOutlined
/>
}
onClick=
{
onDelete
}
/>
</
Tooltip
>
</
Col
>
</
Row
>
);
}
const
AttributesInput
=
({
value
=
{},
attributes
,
onChange
})
=>
{
const
{
indexedEasyDataModelAttributes
,
indexedAttributeOrders
}
=
value
;
const
onAttributeChange
=
(
value
,
index
)
=>
{
const
newIndexedEasyDataModelAttributes
=
[...
indexedEasyDataModelAttributes
];
const
_index
=
attributes
.
findIndex
(
item
=>
item
.
iid
===
value
);
newIndexedEasyDataModelAttributes
.
splice
(
index
,
1
,
{...
attributes
[
_index
]});
triggerChange
({
indexedEasyDataModelAttributes
:
newIndexedEasyDataModelAttributes
});
}
const
onOrderChange
=
(
value
,
index
)
=>
{
const
newIndexedAttributeOrders
=
[...
indexedAttributeOrders
];
newIndexedAttributeOrders
.
splice
(
index
,
1
,
value
);
triggerChange
({
indexedAttributeOrders
:
newIndexedAttributeOrders
})
}
const
onItemDelete
=
(
index
)
=>
{
const
newIndexedEasyDataModelAttributes
=
[...
indexedEasyDataModelAttributes
];
const
newIndexedAttributeOrders
=
[...
indexedAttributeOrders
];
newIndexedEasyDataModelAttributes
.
splice
(
index
,
1
);
newIndexedAttributeOrders
.
splice
(
index
,
1
);
if
(
newIndexedEasyDataModelAttributes
.
length
===
0
)
{
newIndexedEasyDataModelAttributes
.
push
({});
}
if
(
newIndexedAttributeOrders
.
length
===
0
)
{
newIndexedAttributeOrders
.
push
(
''
);
}
triggerChange
({
indexedEasyDataModelAttributes
:
newIndexedEasyDataModelAttributes
,
indexedAttributeOrders
:
newIndexedAttributeOrders
,
});
}
const
addAttribute
=
()
=>
{
triggerChange
({
indexedEasyDataModelAttributes
:
[...
indexedEasyDataModelAttributes
,
{}],
indexedAttributeOrders
:
[...
indexedAttributeOrders
,
''
],
})
}
const
triggerChange
=
(
changedValue
)
=>
{
onChange
&&
onChange
({
...
value
,
...
changedValue
,
});
};
return
(
<>
{
{
fileds
&&
fileds
.
map
((
filed
,
index
)
=>
{
(
indexedEasyDataModelAttributes
||
[]).
map
((
indexedAttribute
,
index
)
=>
{
return
(
return
(
<
Option
key=
{
filed
}
>
{
filed
}
</
Option
>
<
AttributesInputItem
)
key=
{
index
}
className=
'mb-2'
indexedAttribute=
{
indexedAttribute
}
indexedAttributeOrder=
{
indexedAttributeOrders
[
index
]
||
''
}
attributes=
{
attributes
}
onAttributeChange=
{
(
value
)
=>
{
onAttributeChange
(
value
,
index
)
}
}
onOrderChange=
{
(
value
)
=>
{
onOrderChange
(
value
,
index
)
}
}
onDelete=
{
()
=>
{
onItemDelete
(
index
)
}
}
/>
);
})
})
}
}
</
Select
>
<
Button
onClick=
{
addAttribute
}
>
新增字段
</
Button
>
</>
)
)
}
}
return
(
const
EditableCell
=
({
<
td
{
...
restProps
}
>
editing
,
{
editing
?
(
dataIndex
,
colTitle
,
inputType
,
record
,
index
,
attributes
,
children
,
...
restProps
})
=>
{
let
editingComponent
=
null
;
if
(
editing
)
{
if
(
dataIndex
!==
'attributesWithOrders'
)
{
const
inputNode
=
inputType
===
'check'
?
<
Checkbox
/>
:
<
Input
/>
editingComponent
=
(
<
Form
.
Item
name=
{
dataIndex
}
style=
{
{
margin
:
0
,
}
}
valuePropName=
{
(
inputType
===
'check'
)?
'checked'
:
'value'
}
rules=
{
[
{
required
:
(
inputType
===
'text'
),
message
:
`请输入${colTitle}!`
,
},
]
}
>
{
inputNode
}
</
Form
.
Item
>
);
}
else
{
editingComponent
=
(
<
Form
.
Item
<
Form
.
Item
name=
{
dataIndex
}
name=
{
dataIndex
}
style=
{
{
style=
{
{
margin
:
0
,
margin
:
0
,
}
}
}
}
valuePropName=
{
'value'
}
rules=
{
[
rules=
{
[
{
{
required
:
true
,
required
:
true
,
message
:
`请输入${
t
itle}!`
,
message
:
`请输入${
colT
itle}!`
,
},
},
]
}
]
}
>
>
{
inputNode
}
<
AttributesInput
attributes=
{
attributes
}
/>
</
Form
.
Item
>
</
Form
.
Item
>
)
}
}
return
(
<
td
{
...
restProps
}
>
{
editing
?
(
editingComponent
)
:
(
)
:
(
children
children
)
}
)
}
...
@@ -127,20 +252,48 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) =>
...
@@ -127,20 +252,48 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) =>
};
};
const
ImportActionIndex
=
(
props
)
=>
{
const
ImportActionIndex
=
(
props
)
=>
{
const
{
data
,
fileds
,
onChange
,
editable
}
=
props
;
const
{
modelerData
,
onChange
,
editable
,
constraint
,
template
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
const
[
editingKey
,
setEditingKey
]
=
useState
(
''
);
const
[
suggests
,
setSuggests
]
=
useState
([]);
const
isEditing
=
(
record
)
=>
record
.
key
===
editingKey
;
const
[
attributes
,
setAttributes
]
=
useState
([]);
const
[
data
,
setData
]
=
useState
([]);
const
onAddClick
=
()
=>
{
const
[
form
]
=
Form
.
useForm
();
const
newData
=
[{},
...
data
];
const
[
editingKey
,
setEditingKey
]
=
useState
(
null
);
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
filterData
,
setFilterData
]
=
useState
([]);
//规则改变的时候 数据表为可编辑状态
useEffect
(()
=>
{
setEditingKey
(
null
);
},
[
constraint
,
template
])
useEffect
(()
=>
{
setAttributes
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]);
setData
(
modelerData
.
easyDataModelerIndices
||
[]);
const
_filterData
=
(
modelerData
.
easyDataModelerIndices
||
[]).
filter
(
item
=>
(
item
.
name
||
''
).
indexOf
(
keyword
)
!==-
1
);
const
__filterData
=
[];
(
_filterData
||
[]).
forEach
(
item
=>
{
(
newData
||
[]).
forEach
((
item
,
index
)
=>
{
__filterData
.
push
({...
item
,
...{
attributesWithOrders
:
{
item
.
key
=
index
.
toString
();
indexedEasyDataModelAttributes
:
item
.
indexedEasyDataModelAttributes
||
[],
indexedAttributeOrders
:
item
.
indexedAttributeOrders
||
[],
}
}});
})
})
setFilterData
(
__filterData
);
},
[
modelerData
,
keyword
])
const
isEditing
=
(
record
)
=>
record
.
name
===
editingKey
;
const
onAddClick
=
()
=>
{
const
newData
=
[{
name
:
''
},
...
data
];
onChange
&&
onChange
(
newData
);
onChange
&&
onChange
(
newData
);
edit
(
newData
[
0
]);
edit
(
newData
[
0
]);
}
}
...
@@ -148,16 +301,19 @@ const ImportActionIndex = (props) => {
...
@@ -148,16 +301,19 @@ const ImportActionIndex = (props) => {
const
edit
=
(
record
)
=>
{
const
edit
=
(
record
)
=>
{
form
.
setFieldsValue
({
form
.
setFieldsValue
({
name
:
''
,
name
:
''
,
mode
:
''
,
attributesWithOrders
:
{
fileds
:
[],
indexedEasyDataModelAttributes
:
[{}],
indexedAttributeOrders
:
[
''
],
},
unique
:
false
,
...
record
,
...
record
,
});
});
setEditingKey
(
record
.
key
);
setEditingKey
(
record
.
name
);
};
};
const
remove
=
(
record
)
=>
{
const
remove
=
(
record
)
=>
{
const
newData
=
[...
data
];
const
newData
=
[...
data
];
const
index
=
newData
.
findIndex
((
item
)
=>
record
.
key
===
item
.
key
);
const
index
=
newData
.
findIndex
((
item
)
=>
record
.
name
===
item
.
name
);
newData
.
splice
(
index
,
1
);
newData
.
splice
(
index
,
1
);
onChange
&&
onChange
(
newData
);
onChange
&&
onChange
(
newData
);
}
}
...
@@ -165,113 +321,176 @@ const ImportActionIndex = (props) => {
...
@@ -165,113 +321,176 @@ const ImportActionIndex = (props) => {
const
cancel
=
()
=>
{
const
cancel
=
()
=>
{
const
newData
=
[...
data
];
const
newData
=
[...
data
];
const
item
=
newData
[
editingKey
];
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
name
);
const
item
=
newData
[
index
];
if
(
!
item
.
name
||
item
.
name
===
''
)
{
if
(
!
item
.
name
||
item
.
name
===
''
)
{
newData
.
splice
(
editingKey
,
1
);
newData
.
splice
(
index
,
1
);
onChange
&&
onChange
(
newData
);
onChange
&&
onChange
(
newData
);
}
}
setEditingKey
(
''
);
setEditingKey
(
null
);
};
};
const
save
=
async
()
=>
{
const
save
=
async
()
=>
{
try
{
try
{
await
form
.
validateFields
();
const
row
=
await
form
.
validateFields
();
const
_suggests
=
[
{
// console.log('row', row);
name
:
'建议1'
},
const
newData
=
[...
data
];
{
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
name
);
name
:
'建议2'
//判断索引名称是否唯一
const
newDataExcludeSelf
=
[...
data
];
newDataExcludeSelf
.
splice
(
index
,
1
);
const
_index
=
(
newDataExcludeSelf
||
[]).
findIndex
(
item
=>
item
.
name
===
row
.
name
);
if
(
_index
!==
-
1
)
{
form
.
setFields
([{
name
:
'name'
,
errors
:
[
'索引名称不能重复'
]
}]);
return
;
}
}
];
setSuggests
(
_suggests
)
if
(
_suggests
.
length
===
0
)
{
if
(
/^
[
a-zA-Z
]
+$/
.
test
(
row
.
name
)
===
false
)
{
constraintSave
();
form
.
setFields
([{
name
:
'name'
,
errors
:
[
'索引名称必须全是字母'
]
}]);
return
;
}
}
}
catch
(
errInfo
)
{
const
_indexedEasyDataModelAttributes
=
[],
_indexedAttributeOrders
=
[];
console
.
log
(
'Validate Failed:'
,
errInfo
);
row
.
attributesWithOrders
.
indexedEasyDataModelAttributes
.
forEach
((
item
,
index
)
=>
{
if
((
item
.
iid
||
''
)
!==
''
)
{
_indexedEasyDataModelAttributes
.
push
(
item
);
_indexedAttributeOrders
.
push
(
row
.
attributesWithOrders
.
indexedAttributeOrders
[
index
]);
}
}
};
})
const
constraintSave
=
async
()
=>
{
if
(
_indexedEasyDataModelAttributes
.
length
===
0
)
{
const
row
=
await
form
.
validateFields
();
form
.
setFields
([{
name
:
'attributesWithOrders'
,
errors
:
[
'必须选择字段'
]
}]);
return
;
}
//test
newData
.
splice
(
index
,
1
,
{...{
row
.
key
=
'-1'
;
name
:
row
.
name
,
unique
:
row
.
unique
,
indexedEasyDataModelAttributes
:
_indexedEasyDataModelAttributes
,
indexedAttributeOrders
:
_indexedAttributeOrders
,
}});
const
newData
=
[...
data
];
onChange
&&
onChange
(
newData
,
true
);
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
key
);
if
(
index
>
-
1
)
{
setEditingKey
(
null
);
const
item
=
newData
[
index
];
newData
.
splice
(
index
,
1
,
{
...
item
,
...
row
});
}
else
{
newData
.
push
(
row
);
}
onChange
&&
onChange
(
newData
);
}
catch
(
errInfo
)
{
setEditingKey
(
''
);
console
.
log
(
'Validate Failed:'
,
errInfo
);
setSuggests
([]);
}
}
};
const
onValuesChange
=
(
changedValues
,
allValues
)
=>
{
// console.log('changed values', changedValues);
// console.log('all values', allValues);
};
const
columns
=
[
const
columns
=
[
{
{
title
:
''
,
width
:
48
,
},
{
title
:
'序号'
,
title
:
'序号'
,
dataIndex
:
'key'
,
dataIndex
:
'key'
,
editable
:
false
,
editable
:
false
,
render
:
(
text
,
record
,
index
)
=>
{
width
:
50
,
render
:
(
_
,
__
,
index
)
=>
{
return
(
index
+
1
).
toString
();
return
(
index
+
1
).
toString
();
}
}
},
},
{
{
title
:
'索引名称'
,
title
:
'索引名称'
,
width
:
200
,
dataIndex
:
'name'
,
dataIndex
:
'name'
,
editable
:
true
,
editable
:
true
,
ellipsis
:
true
,
},
},
{
{
title
:
'索引类型'
,
title
:
'是否唯一索引'
,
dataIndex
:
'mode'
,
width
:
200
,
dataIndex
:
'unique'
,
editable
:
true
,
editable
:
true
,
render
:
(
unique
,
_
,
__
)
=>
{
if
(
unique
===
false
)
{
return
'否'
;
}
else
if
(
unique
===
true
)
{
return
'是'
;
}
return
''
;
}
},
},
{
{
title
:
'索引字段列表'
,
title
:
'索引字段列表'
,
dataIndex
:
'
filed
s'
,
dataIndex
:
'
attributesWithOrder
s'
,
editable
:
true
,
editable
:
true
,
ellipsis
:
true
,
render
:
(
_
,
record
,
index
)
=>
{
return
(
<
div
>
{
(
record
.
indexedEasyDataModelAttributes
||
[]).
map
((
item
,
index
)
=>
{
const
order
=
record
.
indexedAttributeOrders
[
index
]
||
''
;
const
_text
=
`字段: ${item.name||''} 排序: ${order||''}`
;
return
(
<
Row
key=
{
index
}
><
span
>
{
_text
}
</
span
></
Row
>
)
})
}
</
div
>
);
}
},
},
];
const
editableColumn
=
[
...
columns
,
{
{
title
:
'操作'
,
title
:
'操作'
,
dataIndex
:
'action'
,
dataIndex
:
'action'
,
width
:
100
,
render
:
(
_
,
record
)
=>
{
render
:
(
_
,
record
)
=>
{
if
(
!
editable
)
return
null
;
if
(
!
editable
)
return
null
;
return
isEditing
(
record
)
?
(
return
isEditing
(
record
)
?
(
<>
<>
<
Typography
.
Link
className=
'mr-3'
disabled=
{
editingKey
===
''
}
onClick=
{
()
=>
save
()
}
>
<
Typography
.
Link
className=
'mr-3'
disabled=
{
editingKey
===
null
}
onClick=
{
()
=>
save
()
}
>
保存
保存
</
Typography
.
Link
>
</
Typography
.
Link
>
<
Typography
.
Link
disabled=
{
editingKey
===
''
}
onClick=
{
()
=>
{
cancel
()}
}
>
<
Typography
.
Link
disabled=
{
editingKey
===
null
}
onClick=
{
()
=>
{
cancel
()}
}
>
取消
取消
</
Typography
.
Link
>
</
Typography
.
Link
>
</>
</>
)
:
(
)
:
(
<>
<>
<
Typography
.
Link
className=
'mr-3'
disabled=
{
editingKey
!==
''
}
onClick=
{
()
=>
edit
(
record
)
}
>
<
Typography
.
Link
className=
'mr-3'
disabled=
{
editingKey
!==
null
}
onClick=
{
()
=>
edit
(
record
)
}
>
编辑
编辑
</
Typography
.
Link
>
</
Typography
.
Link
>
<
Typography
.
Link
disabled=
{
editingKey
!==
''
}
onClick=
{
()
=>
remove
(
record
)
}
>
<
Typography
.
Link
className=
'mr-3'
disabled=
{
editingKey
!==
null
}
onClick=
{
()
=>
remove
(
record
)
}
>
删除
删除
</
Typography
.
Link
>
</
Typography
.
Link
>
</>
</>
);
);
},
},
},
},
]
;
]
const
mergedColumns
=
columns
.
map
((
col
)
=>
{
const
mergedColumns
=
()
=>
{
if
(
editable
)
{
let
_columns
=
editableColumn
;
return
_columns
.
map
((
col
)
=>
{
if
(
!
col
.
editable
)
{
if
(
!
col
.
editable
)
{
return
col
;
return
col
;
}
}
...
@@ -280,14 +499,18 @@ const ImportActionIndex = (props) => {
...
@@ -280,14 +499,18 @@ const ImportActionIndex = (props) => {
...
col
,
...
col
,
onCell
:
(
record
)
=>
({
onCell
:
(
record
)
=>
({
record
,
record
,
inputType
:
(
col
.
dataIndex
===
'fileds'
)
?
'select-multiple'
:
(
col
.
dataIndex
===
'mode'
?
'select'
:
'text'
),
dataIndex
:
col
.
dataIndex
,
dataIndex
:
col
.
dataIndex
,
title
:
col
.
title
,
inputType
:
(
col
.
dataIndex
===
'unique'
)
?
'check'
:
'text'
,
colTitle
:
col
.
title
,
editing
:
isEditing
(
record
),
editing
:
isEditing
(
record
),
fileds
:
fileds
||
[]
attributes
,
}),
}),
};
};
});
});
}
return
columns
;
}
const
moveRow
=
useCallback
(
const
moveRow
=
useCallback
(
(
dragIndex
,
hoverIndex
)
=>
{
(
dragIndex
,
hoverIndex
)
=>
{
...
@@ -306,73 +529,67 @@ const ImportActionIndex = (props) => {
...
@@ -306,73 +529,67 @@ const ImportActionIndex = (props) => {
[
data
],
[
data
],
);
);
const
onSearchInputChange
=
(
e
)
=>
{
setEditingKey
(
null
);
setKeyword
(
e
.
target
.
value
||
''
);
}
return
(
return
(
<
div
className=
'model-import-action-index mt-7'
>
<
Divider
>
<>
<>
<
Divider
>
数据表索引
</
Divider
>
<
span
>
数据表索引
</
span
>
{
{
editable
&&
(
editable
&&
<
div
className=
'd-flex mb-3'
>
<
Popover
content=
'表格可以通过拖拽来排序'
>
<
Button
type=
"primary"
onClick=
{
onAddClick
}
style=
{
{
marginLeft
:
'auto'
}
}
disabled=
{
editingKey
!==
''
}
>
新增行
</
Button
>
<
QuestionCircleOutlined
className=
'ml-1 pointer'
/>
</
Popover
>
)
}
</>
</
Divider
>
<
div
className=
'd-flex mb-3'
style=
{
{
justifyContent
:
'space-between'
}
}
>
<
div
className=
'd-flex'
style=
{
{
alignItems
:
'center'
}
}
>
<
span
className=
'mr-3'
>
索引搜索:
</
span
>
<
Input
placeholder=
"请输入索引名称"
allowClear
value=
{
keyword
}
onChange=
{
onSearchInputChange
}
style=
{
{
width
:
230
}
}
/>
</
div
>
</
div
>
{
editable
&&
<
Button
className=
'ml-3'
type=
"primary"
onClick=
{
onAddClick
}
disabled=
{
editingKey
!==
null
||
keyword
!==
''
}
>
新增行
</
Button
>
}
}
</
div
>
<
DndProvider
backend=
{
HTML5Backend
}
>
<
DndProvider
backend=
{
HTML5Backend
}
>
<
Form
form=
{
form
}
component=
{
false
}
>
<
Form
form=
{
form
}
component=
{
false
}
onValuesChange=
{
onValuesChange
}
>
<
Table
<
Table
components=
{
{
components=
{
{
body
:
{
body
:
{
cell
:
EditableCell
,
cell
:
EditableCell
,
//编辑状态下不允许拖动
//编辑
或者搜索
状态下不允许拖动
row
:
(
editable
&&
editingKey
===
''
)?
DragableBodyRow
:
null
,
row
:
(
editable
&&
editingKey
===
null
&&
keyword
===
''
)?
DragableBodyRow
:
null
,
},
},
}
}
}
}
onRow=
{
(
record
,
index
)
=>
{
onRow=
{
(
record
,
index
)
=>
{
if
(
!
editable
||
editingKey
!==
''
)
return
null
;
if
(
!
editable
||
editingKey
!==
null
||
keyword
.
length
>
0
)
return
null
;
return
{
return
{
index
,
index
,
moveRow
moveRow
}
}
}
}
}
}
dataSource=
{
data
}
dataSource=
{
filterData
||
[]
}
columns=
{
mergedColumns
}
columns=
{
mergedColumns
()
}
size=
'small'
size=
'small'
rowKey=
'name'
rowClassName=
"editable-row"
rowClassName=
"editable-row"
pagination=
{
false
}
pagination=
{
false
}
expandable=
{
{
expandedRowRender
:
record
=>
(
<>
{
editingKey
!==
''
&&
<>
{
suggests
&&
suggests
.
length
>
0
&&
(
<>
<
Divider
orientation=
"left"
>
建议
</
Divider
>
<
div
className=
'mb-3 ml-7'
>
{
suggests
&&
suggests
.
map
((
suggest
,
index
)
=>
{
return
(
<
div
key=
{
index
}
className=
'mt-3'
>
{
suggest
.
name
||
''
}
</
div
>
)
})
}
</
div
>
<
Button
className=
'mb-3 ml-7'
type=
'primary'
onClick=
{
constraintSave
}
>
强制保存
</
Button
>
</>
)
}
</>
}
</>
),
expandIcon
:
({
expanded
,
onExpand
,
record
})
=>
{
return
<></>;
},
rowExpandable
:
record
=>
(
editingKey
!==
''
&&
(
suggests
||
[]).
length
>
0
),
expandedRowKeys
:
[
editingKey
]
}
}
/>
/>
</
Form
>
</
Form
>
</
DndProvider
>
</
DndProvider
>
</>
</
div
>
);
);
};
};
...
...
src/view/Manage/Model/Component/ImportActionTable.jsx
View file @
1e0e1b61
...
@@ -220,7 +220,7 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) =>
...
@@ -220,7 +220,7 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) =>
const
ImportActionTable
=
(
props
)
=>
{
const
ImportActionTable
=
(
props
)
=>
{
const
{
modelerData
,
onChange
,
editable
,
supportedDatatypes
,
constraint
,
template
,
validateReports
}
=
props
;
const
{
modelerData
,
onChange
,
editable
,
supportedDatatypes
,
constraint
,
template
,
validateReports
}
=
props
;
const
data
=
modelerData
.
easyDataModelerDataModelAttributes
||
[]
;
const
[
data
,
setData
]
=
useState
([])
;
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
[
editingKey
,
setEditingKey
]
=
useState
(
''
);
const
[
editingKey
,
setEditingKey
]
=
useState
(
''
);
...
@@ -229,6 +229,9 @@ const ImportActionTable = (props) => {
...
@@ -229,6 +229,9 @@ const ImportActionTable = (props) => {
const
[
filterData
,
setFilterData
]
=
useState
([]);
const
[
filterData
,
setFilterData
]
=
useState
([]);
const
onChangeRef
=
useRef
();
onChangeRef
.
current
=
onChange
;
//规则改变的时候 数据表为可编辑状态
//规则改变的时候 数据表为可编辑状态
useEffect
(()
=>
{
useEffect
(()
=>
{
setEditingKey
(
''
);
setEditingKey
(
''
);
...
@@ -236,6 +239,7 @@ const ImportActionTable = (props) => {
...
@@ -236,6 +239,7 @@ const ImportActionTable = (props) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
setData
(
modelerData
.
easyDataModelerDataModelAttributes
||
[]);
setFilterData
((
modelerData
.
easyDataModelerDataModelAttributes
||
[]).
filter
(
item
=>
(
item
.
name
||
''
).
indexOf
(
keyword
)
!==-
1
||
(
item
.
cnName
).
indexOf
(
keyword
)
!==-
1
));
setFilterData
((
modelerData
.
easyDataModelerDataModelAttributes
||
[]).
filter
(
item
=>
(
item
.
name
||
''
).
indexOf
(
keyword
)
!==-
1
||
(
item
.
cnName
).
indexOf
(
keyword
)
!==-
1
));
},
[
modelerData
,
keyword
])
},
[
modelerData
,
keyword
])
...
@@ -287,14 +291,17 @@ const ImportActionTable = (props) => {
...
@@ -287,14 +291,17 @@ const ImportActionTable = (props) => {
try
{
try
{
const
row
=
await
form
.
validateFields
();
const
row
=
await
form
.
validateFields
();
if
((
row
.
datatype
.
name
||
''
)
===
''
)
{
form
.
setFields
([{
name
:
'datatype'
,
errors
:
[
'必须选择类型'
]
}]);
return
;
}
(
row
.
datatype
.
parameterNames
||
[]).
forEach
((
parameterName
,
index
)
=>
{
(
row
.
datatype
.
parameterNames
||
[]).
forEach
((
parameterName
,
index
)
=>
{
if
(
!
row
.
datatype
.
parameterValues
[
index
]
||
row
.
datatype
.
parameterValues
[
index
]
===
''
)
{
if
(
!
row
.
datatype
.
parameterValues
[
index
]
||
row
.
datatype
.
parameterValues
[
index
]
===
''
)
{
row
.
datatype
.
parameterValues
[
index
]
=
0
;
row
.
datatype
.
parameterValues
[
index
]
=
0
;
}
}
})
})
// console.log('row', row);
const
newData
=
[...
data
];
const
newData
=
[...
data
];
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
iid
);
const
index
=
newData
.
findIndex
((
item
)
=>
editingKey
===
item
.
iid
);
...
@@ -392,7 +399,7 @@ const ImportActionTable = (props) => {
...
@@ -392,7 +399,7 @@ const ImportActionTable = (props) => {
dataIndex
:
'nullable'
,
dataIndex
:
'nullable'
,
editable
:
true
,
editable
:
true
,
render
:
(
nullable
,
record
,
index
)
=>
{
render
:
(
nullable
,
record
,
index
)
=>
{
if
(
nullable
===
fals
e
)
{
if
(
!
nullabl
e
)
{
return
'否'
;
return
'否'
;
}
else
if
(
nullable
===
true
)
{
}
else
if
(
nullable
===
true
)
{
return
'是'
;
return
'是'
;
...
@@ -407,7 +414,7 @@ const ImportActionTable = (props) => {
...
@@ -407,7 +414,7 @@ const ImportActionTable = (props) => {
dataIndex
:
'partOfPrimaryKey'
,
dataIndex
:
'partOfPrimaryKey'
,
editable
:
true
,
editable
:
true
,
render
:
(
partOfPrimaryKey
,
record
,
index
)
=>
{
render
:
(
partOfPrimaryKey
,
record
,
index
)
=>
{
if
(
partOfPrimaryKey
===
false
)
{
if
(
!
partOfPrimaryKey
)
{
return
'否'
;
return
'否'
;
}
else
if
(
partOfPrimaryKey
===
true
)
{
}
else
if
(
partOfPrimaryKey
===
true
)
{
return
'是'
;
return
'是'
;
...
@@ -422,7 +429,7 @@ const ImportActionTable = (props) => {
...
@@ -422,7 +429,7 @@ const ImportActionTable = (props) => {
dataIndex
:
'partOfDistributionKey'
,
dataIndex
:
'partOfDistributionKey'
,
editable
:
true
,
editable
:
true
,
render
:
(
partOfDistributionKey
,
record
,
index
)
=>
{
render
:
(
partOfDistributionKey
,
record
,
index
)
=>
{
if
(
partOfDistributionKey
===
false
)
{
if
(
!
partOfDistributionKey
)
{
return
'否'
;
return
'否'
;
}
else
if
(
partOfDistributionKey
===
true
)
{
}
else
if
(
partOfDistributionKey
===
true
)
{
return
'是'
;
return
'是'
;
...
@@ -574,7 +581,7 @@ const ImportActionTable = (props) => {
...
@@ -574,7 +581,7 @@ const ImportActionTable = (props) => {
],
],
});
});
onChange
&&
onChange
(
newData
);
onChange
Ref
.
current
&&
onChangeRef
.
current
(
newData
);
},
},
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
[
data
],
[
data
],
...
@@ -665,7 +672,7 @@ const ImportActionTable = (props) => {
...
@@ -665,7 +672,7 @@ const ImportActionTable = (props) => {
</>
</>
),
),
expandIcon
:
({
expanded
,
onExpand
,
record
})
=>
{
expandIcon
:
({
expanded
,
onExpand
,
record
})
=>
{
return
<></>
;
return
null
;
},
},
rowExpandable
:
record
=>
(
editingKey
!==
''
&&
(
suggests
||
[]).
length
>
0
),
rowExpandable
:
record
=>
(
editingKey
!==
''
&&
(
suggests
||
[]).
length
>
0
),
expandedRowKeys
:
[
editingKey
]
expandedRowKeys
:
[
editingKey
]
...
...
src/view/Manage/Model/Component/ImportModal.jsx
View file @
1e0e1b61
...
@@ -110,7 +110,7 @@ const ImportModal = (props) => {
...
@@ -110,7 +110,7 @@ const ImportModal = (props) => {
const
cancel
=
()
=>
{
const
cancel
=
()
=>
{
reset
();
reset
();
onCancel
&&
onCancel
(
true
);
onCancel
&&
onCancel
();
}
}
const
save
=
async
()
=>
{
const
save
=
async
()
=>
{
...
...
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