Commit 183a9392 by zhaochengxiang

要素可选

parent aacf8430
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';
...@@ -354,6 +354,22 @@ const AssetAction = (props) => { ...@@ -354,6 +354,22 @@ const AssetAction = (props) => {
}) })
} }
const elementItem = (element) => {
if (element?.metadataItem === '是') return <MetadataInfo reference={reference} />
if (element?.selectMode === '单选') {
return <Select disabled={element?.manualMaintain==='否'}>
{
(typeof(element?.optional) === 'string') && (element?.optional??'').split(',').map((item, index) => <Select.Option key={index} value={item}>{item}</Select.Option>)
}
</Select>
} else if (element.selectMode === '多选') {
return <MultipleItem element={element} />
}
return <Input disabled={element?.manualMaintain==='否'} />
}
const formItemLayout = { const formItemLayout = {
labelCol: { labelCol: {
xs: { span: 24 }, xs: { span: 24 },
...@@ -564,7 +580,7 @@ const AssetAction = (props) => { ...@@ -564,7 +580,7 @@ const AssetAction = (props) => {
key={_index} key={_index}
style={{ marginBottom: (_index===sameAttributeElements.length-1)? 0 : 15 }} style={{ marginBottom: (_index===sameAttributeElements.length-1)? 0 : 15 }}
> >
{ (element.metadataItem==='是') ? <MetadataInfo reference={reference} /> : <Input disabled={element.manualMaintain==='否'} /> } {elementItem(element)}
</Form.Item> </Form.Item>
); );
}) })
...@@ -602,4 +618,20 @@ const AssetAction = (props) => { ...@@ -602,4 +618,20 @@ const AssetAction = (props) => {
) )
} }
export default AssetAction; export default AssetAction;
\ No newline at end of file
const MultipleItem = ({ value, onChange, element }) => {
return (
<Select
value={value?value.split(','):undefined}
mode="multiple"
disabled={element?.manualMaintain==='否'}
onChange={(val) => {
onChange?.((val??[]).length === 0 ? undefined : val.toString())
}}>
{
(typeof(element?.optional) === 'string') && (element.optional??'').split(',').map((item, index) => <Select.Option key={index} value={item}>{item}</Select.Option>)
}
</Select>
)
}
\ No newline at end of file
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