Commit 28411606 by zhaochengxiang

修改规则 模版问题

parent 91e55e5c
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect } from 'react';
import { Alert, Select } from 'antd'; import { Alert, Select } from 'antd';
import ImportActionHeader from './ImportActionHeader'; import ImportActionHeader from './ImportActionHeader';
...@@ -20,9 +20,6 @@ const ImportAction = (props) => { ...@@ -20,9 +20,6 @@ const ImportAction = (props) => {
const [ supportedDatatypes, setSupportedDatatypes ] = useState([]); const [ supportedDatatypes, setSupportedDatatypes ] = useState([]);
const [ validateReports, setValidateReports ] = useState([]); const [ validateReports, setValidateReports ] = useState([]);
const mountRef = useRef();
mountRef.current = true;
useEffect(() =>{ useEffect(() =>{
if (action==='add' && (hints||[]).length === 0) return; if (action==='add' && (hints||[]).length === 0) return;
...@@ -36,24 +33,20 @@ const ImportAction = (props) => { ...@@ -36,24 +33,20 @@ const ImportAction = (props) => {
}); });
} }
if (action === 'detail') { dispatch({
getCurrentDataModel(); type: 'datamodel.getAllConstraintsAndTemplates',
} else { callback: data => {
dispatch({ setConstraints(data.constraints||[]);
type: 'datamodel.getAllConstraintsAndTemplates', setTemplates(data.templates||[]);
callback: data => { if (action === 'add') {
setConstraints(data.constraints||[]); setConstraint((data.constraints||[]).length>0?data.constraints[0]:{});
setTemplates(data.templates||[]); setTemplate((data.templates||[]).length>0?data.templates[0]:{});
if (action === 'add') { getDraft((data.constraints||[]).length>0?data.constraints[0]:{}, (data.templates||[]).length>0?data.templates[0]:{} ,hints);
setConstraint((data.constraints||[]).length>0?data.constraints[0]:{}); } else if(action === 'edit' || action === 'detail') {
setTemplate((data.templates||[]).length>0?data.templates[0]:{}); getCurrentDataModel();
getDraft((data.constraints||[]).length>0?data.constraints[0]:{}, (data.templates||[]).length>0?data.templates[0]:{} ,hints);
} else if(action === 'edit') {
getCurrentDataModel();
}
} }
}) }
} })
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [action, hints, modelerId ]); }, [action, hints, modelerId ]);
...@@ -109,7 +102,7 @@ const ImportAction = (props) => { ...@@ -109,7 +102,7 @@ const ImportAction = (props) => {
let currentConstraint = null, _hints = []; let currentConstraint = null, _hints = [];
(constraints||[]).forEach((_constraint, index) => { (constraints||[]).forEach((_constraint, index) => {
if (_constraint.id === value) { if (_constraint.name === value) {
currentConstraint = _constraint; currentConstraint = _constraint;
} }
}); });
...@@ -132,7 +125,7 @@ const ImportAction = (props) => { ...@@ -132,7 +125,7 @@ const ImportAction = (props) => {
let currentTemplate = null, _hints = []; let currentTemplate = null, _hints = [];
(templates||[]).forEach((_template, index) => { (templates||[]).forEach((_template, index) => {
if (_template.id === value) { if (_template.name === value) {
currentTemplate = _template; currentTemplate = _template;
} }
}); });
...@@ -188,8 +181,8 @@ const ImportAction = (props) => { ...@@ -188,8 +181,8 @@ const ImportAction = (props) => {
return ( return (
<> <>
{ {
action!=='detail' && <div className='d-flex mb-3'> <div className='d-flex mb-3'>
<Select value={constraint.name?constraint.name:null} placeholder='请选择规则' style={{ marginLeft: 'auto', minWidth: 100 }} onChange={onConstraintChange}> <Select value={constraint.name?constraint.name:null} placeholder='请选择规则' style={{ marginLeft: 'auto', minWidth: 100 }} onChange={onConstraintChange} disabled={ action==='detail' } >
{ {
(constraints||[]).map((constraint, index) => { (constraints||[]).map((constraint, index) => {
return ( return (
...@@ -198,7 +191,7 @@ const ImportAction = (props) => { ...@@ -198,7 +191,7 @@ const ImportAction = (props) => {
}) })
} }
</Select> </Select>
<Select className='ml-3' value={template.name?template.name:null} placeholder='请选择模版' style={{ minWidth: 100 }} onChange={onTemplateChange}> <Select className='ml-3' value={template.name?template.name:null} placeholder='请选择模版' style={{ minWidth: 100 }} onChange={onTemplateChange} disabled={action==='detail'}>
{ {
(templates||[]).map((template, index) => { (templates||[]).map((template, index) => {
return ( return (
...@@ -214,14 +207,14 @@ const ImportAction = (props) => { ...@@ -214,14 +207,14 @@ const ImportAction = (props) => {
editable={action!=='detail'} editable={action!=='detail'}
modelerData={modelerData||{}} modelerData={modelerData||{}}
/> />
{ {/* {
action!=='detail' && <Alert action!=='detail' && <Alert
message="表格可以通过拖拽来排序" message="表格可以通过拖拽来排序"
type="info" type="info"
closable closable
className='mb-3' className='mb-3'
/> />
} } */}
<ImportActionTable <ImportActionTable
modelerData={modelerData||{}} modelerData={modelerData||{}}
constraint={constraint} constraint={constraint}
......
import React, { useState, useCallback, useRef, useEffect } from 'react'; import React, { useState, useCallback, useRef, useEffect } from 'react';
import { Table, Input, Form, Typography, Radio, Divider, Button, Popconfirm, Select, Row, Col, Popover } from 'antd'; import { Table, Input, Form, Typography, Radio, Divider, Button, Popconfirm, Select, Row, Col, Popover } from 'antd';
import { QuestionCircleOutlined } 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';
...@@ -520,7 +521,17 @@ const ImportActionTable = (props) => { ...@@ -520,7 +521,17 @@ const ImportActionTable = (props) => {
return ( return (
<div className='model-import-action-table'> <div className='model-import-action-table'>
<Divider>数据表结构</Divider> <Divider>
<>
<span>数据表结构</span>
{ editable && (
<Popover content='表格可以通过拖拽来排序'>
<QuestionCircleOutlined className='ml-1 pointer' />
</Popover>
)
}
</>
</Divider>
{ {
editable && <div className='d-flex mb-3'> editable && <div className='d-flex mb-3'>
<Button type="primary" onClick={onAddClick} style={{ marginLeft: 'auto' }} disabled={ editingKey!=='' } >新增行</Button> <Button type="primary" onClick={onAddClick} style={{ marginLeft: 'auto' }} disabled={ editingKey!=='' } >新增行</Button>
......
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