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
1ee001e7
Commit
1ee001e7
authored
Nov 21, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
要素调整
parent
87d65c56
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
4 deletions
+73
-4
AssetAction.jsx
src/view/Manage/AssetManage/Component/AssetAction.jsx
+73
-4
No files found.
src/view/Manage/AssetManage/Component/AssetAction.jsx
View file @
1ee001e7
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Form
,
Spin
,
Input
,
Descriptions
,
Space
,
Button
,
Tooltip
}
from
'antd'
;
import
{
Form
,
Spin
,
Input
,
Descriptions
,
Space
,
Button
,
Tooltip
,
Select
}
from
'antd'
;
import
{
DownOutlined
,
UpOutlined
}
from
'@ant-design/icons'
;
import
{
DownOutlined
,
UpOutlined
}
from
'@ant-design/icons'
;
import
MetadataInfo
from
'./MetadataInfo'
;
import
MetadataInfo
from
'./MetadataInfo'
;
...
@@ -103,6 +103,18 @@ const AssetAction = (props) => {
...
@@ -103,6 +103,18 @@ const AssetAction = (props) => {
setAssetParams
({
assets
:
{},
attributes
:
_attributes
,
attributesFoldMap
:
newAttributesFoldMap
});
setAssetParams
({
assets
:
{},
attributes
:
_attributes
,
attributesFoldMap
:
newAttributesFoldMap
});
form
?.
resetFields
();
form
?.
resetFields
();
if
(
currentAction
===
'add'
)
{
let
newFiledsValue
=
{};
(
data
||
[]).
forEach
(
element
=>
{
if
(
element
.
defaultValue
)
{
newFiledsValue
[
element
.
name
]
=
element
.
defaultValue
}
});
form
?.
setFieldsValue
(
newFiledsValue
);
}
cb
&&
cb
();
cb
&&
cb
();
},
},
error
:
()
=>
{
error
:
()
=>
{
...
@@ -357,6 +369,31 @@ const AssetAction = (props) => {
...
@@ -357,6 +369,31 @@ const AssetAction = (props) => {
},
},
};
};
const elementComponent = (element) => {
if (element.name==='资产项') return <MetadataInfo />
if (element.selectMode==='单选') {
return (
<Select
allowClear
disabled={element.manualMaintain==='否'}
>
{
element.optional?.split(',').map((value, index) => {
return <Select.Option key={index} value={value}>
{value}
</Select.Option>
})
}
</Select>
)
}
if (element.selectMode==='多选') return <MultipleSelect element={element} />
return <Input disabled={element.manualMaintain==='否'} />
}
return (
return (
<div
<div
className='flex'
className='flex'
...
@@ -523,7 +560,7 @@ const AssetAction = (props) => {
...
@@ -523,7 +560,7 @@ const AssetAction = (props) => {
</div>
</div>
<div className='px-common py-compact-common'>
<div className='px-common py-compact-common'>
{
{
(currentAction==='add'||currentAction==='edit') ?
<Form {...formItemLayout} form={form}>
(currentAction==='add'||currentAction==='edit') ?
<AppContext.Consumer>
<AppContext.Consumer>
{
{
value => {
value => {
...
@@ -541,22 +578,27 @@ const AssetAction = (props) => {
...
@@ -541,22 +578,27 @@ const AssetAction = (props) => {
});
});
return (
return (
<Form {...formItemLayout} form={form}>
{
(sameAttributeElements||[]).map((element, _index) => {
(sameAttributeElements||[]).map((element, _index) => {
return (
return (
<Form.Item
<Form.Item
label={<div className='title-color'>{element.name||''}</div>}
label={<div className='title-color'>{element.name||''}</div>}
name={element.name}
name={element.name}
rules={[{ required: element.required }]}
key={_index}
key={_index}
style={{ marginBottom: (_index===sameAttributeElements.length-1)? 0 : 15 }}
style={{ marginBottom: (_index===sameAttributeElements.length-1)? 0 : 15 }}
>
>
{ (element.name==='资产项') ? <MetadataInfo /> : <Input disabled={element.manualMaintain==='否'} />
}
{elementComponent(element)
}
</Form.Item>
</Form.Item>
);
);
})
})
}
</Form>
);
);
}}
}}
</AppContext.Consumer>
</AppContext.Consumer>
</Form>
: <Descriptions column={1}>
: <Descriptions column={1}>
{
{
(sameAttributeElements||[]).map((item, index) => {
(sameAttributeElements||[]).map((item, index) => {
return (
return (
...
@@ -602,3 +644,29 @@ const AssetAction = (props) => {
...
@@ -602,3 +644,29 @@ const AssetAction = (props) => {
}
}
export default AssetAction;
export default AssetAction;
const MultipleSelect = ({ value = null, element, onChange }) => {
const handleChange = (values) => {
onChange?.(values?.join(','))
}
return (
<Select
allowClear
value={value?value?.split(','):[]}
mode='multiple'
disabled={element.manualMaintain==='否'}
onChange={handleChange}
>
{
element.optional?.split(',').map((value, index) => {
return <Select.Option key={index} value={value}>
{value}
</Select.Option>
})
}
</Select>
)
}
\ No newline at end of file
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