Commit a9dcad0f by zhaochengxiang

标签增加类型

parent 2bf590b0
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Modal, Button, AutoComplete, Input, Avatar, TreeSelect, Form } from 'antd'; import { Modal, Button, AutoComplete, Input, Avatar, TreeSelect, Form, Select } from 'antd';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { showMessage } from '../../../../util'; import { showMessage } from '../../../../util';
import './AddTagModal.less'; import './AddTagModal.less';
const { Option } = Select;
const AddTagModal = (props) => { const AddTagModal = (props) => {
const { visible, onCancel, id, type, creator } = props; const { visible, onCancel, id, type, creator } = props;
...@@ -148,7 +150,12 @@ const AddTagModal = (props) => { ...@@ -148,7 +150,12 @@ const AddTagModal = (props) => {
const newTagForm = JSON.parse(JSON.stringify(tagForm)); const newTagForm = JSON.parse(JSON.stringify(tagForm));
(newTagForm?.targetParameters||[]).forEach(param => { (newTagForm?.targetParameters||[]).forEach(param => {
param.value = row[param.name];
if (param.selectMode === 'multiSelect') {
param.value = row[param.name].join(',');
} else {
param.value = row[param.name];
}
}) })
setConfirmLoading(true); setConfirmLoading(true);
...@@ -314,6 +321,38 @@ const AddTagModal = (props) => { ...@@ -314,6 +321,38 @@ const AddTagModal = (props) => {
if (param.name === 'usable') return null; if (param.name === 'usable') return null;
let itemComponent = (
<Input disabled={param.name==='name'} />
);
if (param.selectMode==='singleSelect') {
itemComponent = (
<TreeSelect
style={{ width: '100%' }}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
treeData={loop(param?.tagCatalogNode?.children||[])}
treeDefaultExpandAll
allowClear
/>
);
} else if (param.selectMode==='multiSelect') {
itemComponent = (
<Select
mode="multiple"
allowClear
style={{ width: '100%' }}
>
{
(param?.tagClassifyNodes||[]).map((item, index) => {
return (
<Option key={item.id}>{item.cnName||''}</Option>
);
})
}
</Select>
);
}
return ( return (
<Form.Item <Form.Item
key={index} key={index}
...@@ -321,15 +360,7 @@ const AddTagModal = (props) => { ...@@ -321,15 +360,7 @@ const AddTagModal = (props) => {
name={param.name||''} name={param.name||''}
rules={[{ required: param.required, message: `请选择${param.cnName}!` }]} rules={[{ required: param.required, message: `请选择${param.cnName}!` }]}
> >
{ { itemComponent }
(param.selectMode==='singleSelect') ? <TreeSelect
style={{ width: '100%' }}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
treeData={loop(param?.tagCatalogNode?.children||[])}
treeDefaultExpandAll
allowClear
/> : <Input disabled={param.name==='name'} />
}
</Form.Item> </Form.Item>
); );
}) })
......
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