|
@@ -12,7 +12,7 @@ const { Option } = Select;
|
|
|
const { TextArea } = Input;
|
|
|
function AddRules(props) {
|
|
|
const [form] = Form.useForm();
|
|
|
- const { back,userChange } = props;
|
|
|
+ const { back, userChange } = props;
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
const { type } = useContext(FiledContext);
|
|
|
function handleOk() {
|
|
@@ -61,14 +61,18 @@ function ContentForm(props) {
|
|
|
const [tableList, setTableList] = useState([]);//表名称
|
|
|
const [colList, setColList] = useState([[]]);//字段名称
|
|
|
const [list, setList] = useState([]);
|
|
|
+ const [tableCname, setTableCname] = useState();
|
|
|
+ const [tableEname, setTableEname] = useState();
|
|
|
+ const [columnCname, setcolumnCname] = useState();
|
|
|
+ const [columnEname, setcolumnEname] = useState();
|
|
|
const [disable, seDisable] = useState([true]);
|
|
|
const { type, detail } = useContext(FiledContext);
|
|
|
const { back, form, cancel } = props;
|
|
|
const initialValues = detail
|
|
|
+ console.log(type);
|
|
|
const vilidateRules = {
|
|
|
required: '${label}不能为空!',
|
|
|
};
|
|
|
- console.log(initialValues);
|
|
|
//获取正则式名称
|
|
|
function getRegular(name) {
|
|
|
const param = {
|
|
@@ -81,13 +85,13 @@ function ContentForm(props) {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- function getAddUpColumnName(tableCname, tableEname, columnCname, columnEname) {
|
|
|
+ function getAddUpColumnName() {
|
|
|
post(api.getAddUpColumnName, {
|
|
|
tableCname: tableCname,
|
|
|
tableEname: tableEname,
|
|
|
+ columnId: type == 2 ? detail.columnId : null,
|
|
|
columnCname: columnCname,
|
|
|
columnEname: columnEname,
|
|
|
-
|
|
|
}).then((res) => {
|
|
|
if (res.data.code === 200) {
|
|
|
const data = res.data.data;
|
|
@@ -114,7 +118,7 @@ function ContentForm(props) {
|
|
|
})
|
|
|
}
|
|
|
//表选择
|
|
|
- function tablechange(i, value, options,ins) {
|
|
|
+ function tablechange(i, value, options, ins) {
|
|
|
const formData = form.getFieldsValue();
|
|
|
if (value) {
|
|
|
colList[i] = list[options.key].getColumnNameDTOList
|
|
@@ -129,16 +133,16 @@ function ContentForm(props) {
|
|
|
getAddUpColumnName()
|
|
|
}
|
|
|
let columnList = formData.columnList;
|
|
|
- if(ins == 1){
|
|
|
+ if (ins == 1) {
|
|
|
if (value) {
|
|
|
columnList[i].tableEname = options.val
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
columnList[i].tableEname = undefined
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (value) {
|
|
|
columnList[i].tableCname = options.val
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
columnList[i].tableCname = undefined
|
|
|
}
|
|
|
}
|
|
@@ -147,27 +151,26 @@ function ContentForm(props) {
|
|
|
form.setFieldsValue({
|
|
|
columnList: columnList
|
|
|
});
|
|
|
- console.log(form.getFieldsValue());
|
|
|
}
|
|
|
- function colchange(i, value, options,ins) {
|
|
|
+ function colchange(i, value, options, ins) {
|
|
|
const formData = form.getFieldsValue();
|
|
|
let columnList = formData.columnList;
|
|
|
if (value) {
|
|
|
columnList[i].id = options.key
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
columnList[i].id = undefined
|
|
|
}
|
|
|
-
|
|
|
- if(ins == 1){
|
|
|
+
|
|
|
+ if (ins == 1) {
|
|
|
if (value) {
|
|
|
columnList[i].columnEname = options.val
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
columnList[i].columnEname = undefined
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (value) {
|
|
|
columnList[i].columnCname = options.val
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
columnList[i].columnCname = undefined
|
|
|
}
|
|
|
}
|
|
@@ -177,19 +180,23 @@ function ContentForm(props) {
|
|
|
}
|
|
|
//表名称搜索(中文)
|
|
|
function cnameSearch(val) {
|
|
|
- getAddUpColumnName(val, '', '', '')
|
|
|
+ setTableCname(val)
|
|
|
+ getAddUpColumnName()
|
|
|
}
|
|
|
//表名称搜索(英文)
|
|
|
function enameSearch(val) {
|
|
|
- getAddUpColumnName('', val, '', '')
|
|
|
+ setTableEname(val)
|
|
|
+ getAddUpColumnName()
|
|
|
}
|
|
|
//字段名称搜索(中文)
|
|
|
function colmeSearch(val) {
|
|
|
- getAddUpColumnName(val, '', '', '')
|
|
|
+ setcolumnCname(val)
|
|
|
+ getAddUpColumnName()
|
|
|
}
|
|
|
//字段名称搜索(英文)
|
|
|
function coleneSearch(val) {
|
|
|
- getAddUpColumnName('', val, '', '')
|
|
|
+ setcolumnEname(val)
|
|
|
+ getAddUpColumnName()
|
|
|
}
|
|
|
//表字段添加
|
|
|
function modifyData(i) {
|
|
@@ -214,7 +221,7 @@ function ContentForm(props) {
|
|
|
setColList([...colList])
|
|
|
disable[index] = true
|
|
|
seDisable([...disable])
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
//标准值维护
|
|
|
function modifyStand(i) {
|
|
@@ -316,7 +323,7 @@ function ContentForm(props) {
|
|
|
<div className='item'>
|
|
|
<div className='item-box'>
|
|
|
<Form.Item label="表名称(中文)" rules={[{ required: true }]} style={{ width: '50%' }} name={['columnList', i, 'tableCname']} labelAlign="right" >
|
|
|
- <Select allowClear showSearch onChange={(value, option) => tablechange(i, value, option,1)} onSearch={cnameSearch} style={{ width: 160 }} placeholder="请选择">
|
|
|
+ <Select allowClear showSearch onChange={(value, option) => tablechange(i, value, option, 1)} onSearch={cnameSearch} style={{ width: 160 }} placeholder="请选择">
|
|
|
{tableList.map((item) => {
|
|
|
return (
|
|
|
<Option value={item.tableCname} val={item.tableEname} key={item.index}>{item.tableCname}</Option>
|
|
@@ -325,7 +332,7 @@ function ContentForm(props) {
|
|
|
</Select>
|
|
|
</Form.Item>
|
|
|
<Form.Item label="表名称(英文)" rules={[{ required: true }]} name={['columnList', i, 'tableEname']} labelAlign="right">
|
|
|
- <Select allowClear showSearch onChange={(value, option) => tablechange(i, value, option,2)} onSearch={enameSearch} style={{ width: 160 }} placeholder="请选择" >
|
|
|
+ <Select allowClear showSearch onChange={(value, option) => tablechange(i, value, option, 2)} onSearch={enameSearch} style={{ width: 160 }} placeholder="请选择" >
|
|
|
{tableList.map((item) => {
|
|
|
return (
|
|
|
<Option value={item.tableEname} val={item.tableCname} key={item.index}>{item.tableEname}</Option>
|
|
@@ -336,7 +343,7 @@ function ContentForm(props) {
|
|
|
</div>
|
|
|
<div className='item-box'>
|
|
|
<Form.Item label="字段名称(中文)" rules={[{ required: true }]} style={{ width: '50%' }} name={['columnList', i, 'columnCname']} labelAlign="right">
|
|
|
- <Select allowClear showSearch onChange={(value, option) => colchange(i, value, option,1)} onSearch={colmeSearch} style={{ width: 160 }} placeholder="请选择" disabled={disable[i]}>
|
|
|
+ <Select allowClear showSearch onChange={(value, option) => colchange(i, value, option, 1)} onSearch={colmeSearch} style={{ width: 160 }} placeholder="请选择" disabled={disable[i]}>
|
|
|
{colList[i].map((item) => {
|
|
|
return (
|
|
|
<Option value={item.columnCname} val={item.columnEname} key={item.id} index={i}>{item.columnCname}</Option>
|
|
@@ -345,7 +352,7 @@ function ContentForm(props) {
|
|
|
</Select>
|
|
|
</Form.Item>
|
|
|
<Form.Item label="字段名称(英文)" rules={[{ required: true }]} name={['columnList', i, 'columnEname']} labelAlign="right">
|
|
|
- <Select allowClear showSearch onChange={(value, option) => colchange(i, value, option,2)} onSearch={coleneSearch} style={{ width: 160 }} placeholder="请选择" disabled={disable[i]}>
|
|
|
+ <Select allowClear showSearch onChange={(value, option) => colchange(i, value, option, 2)} onSearch={coleneSearch} style={{ width: 160 }} placeholder="请选择" disabled={disable[i]}>
|
|
|
{colList[i].map((item) => {
|
|
|
return (
|
|
|
<Option value={item.columnEname} val={item.columnCname} key={item.id} index={i}>{item.columnEname}</Option>
|