提交 baa43d1b authored 作者: 姚鑫国's avatar 姚鑫国

新增Tree组件

上级 bda6718e
import React from 'react';
import { Tree } from 'antd';
export default class TreeDiy extends React.Component {
constructor(props) {
super(props);
const allJson = props.option || {};
this.state = {
allJson,
};
}
// static getDerivedStateFromProps(nextProps, prevState) {
// if ('value' in nextProps) {
// return { ...nextProps.value }; // 更新state
// }
// }
// componentDidUpdate(prevProps, prevState) {}
render() {
return <Tree {...this.state.allJson} />;
}
}
...@@ -37,6 +37,7 @@ import TreeSelectDiy from '../TreeSelect/index'; ...@@ -37,6 +37,7 @@ import TreeSelectDiy from '../TreeSelect/index';
import { connect } from 'dva'; import { connect } from 'dva';
import UploadCom from '../libs/UploadCom'; import UploadCom from '../libs/UploadCom';
import TableSelect from '../libs/TableSelect'; import TableSelect from '../libs/TableSelect';
import TreeDiy from '../libs/TreeDiy';
import LocationCom from '../libs/LocationCom'; import LocationCom from '../libs/LocationCom';
import MobileDate from '../libs/MobileDate'; import MobileDate from '../libs/MobileDate';
import ChildForm from '../libs/ChildForm'; import ChildForm from '../libs/ChildForm';
...@@ -150,10 +151,10 @@ export default class TableCom extends Component { ...@@ -150,10 +151,10 @@ export default class TableCom extends Component {
}; };
this.excludeKeys = ['defaultValues', '']; this.excludeKeys = ['defaultValues', ''];
this.otherProps = {}; this.otherProps = {};
if(props.json?.otherProps){ if (props.json?.otherProps) {
try { try {
this.otherProps = new Function(props.json?.otherProps)(); this.otherProps = new Function(props.json?.otherProps)();
}catch (e) { } catch (e) {
} }
} }
...@@ -748,7 +749,7 @@ export default class TableCom extends Component { ...@@ -748,7 +749,7 @@ export default class TableCom extends Component {
); );
//message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10) //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
} }
} else if (['Echart', 'QRCode', 'Graph', 'Tabs'].includes(json.comName)) { } else if (['Echart', 'QRCode', 'Graph', 'Tabs', 'Tree'].includes(json.comName)) {
try { try {
const x = callback(data); const x = callback(data);
if (x != null) { if (x != null) {
...@@ -823,7 +824,7 @@ export default class TableCom extends Component { ...@@ -823,7 +824,7 @@ export default class TableCom extends Component {
e, e,
); );
} }
} else if (['Echart', 'QRCode', 'Graph', 'Tabs'].includes(json.comName)) { } else if (['Echart', 'QRCode', 'Graph', 'Tabs', 'Tree'].includes(json.comName)) {
try { try {
const x = callback(data); const x = callback(data);
if (x != null) { if (x != null) {
...@@ -844,8 +845,7 @@ export default class TableCom extends Component { ...@@ -844,8 +845,7 @@ export default class TableCom extends Component {
if (x == null || x != 'NaN') this.props.form.setFieldsValue({ [base52]: x }); if (x == null || x != 'NaN') this.props.form.setFieldsValue({ [base52]: x });
} catch (e) { } catch (e) {
console.log( console.log(
`页面${this.props.currentFormTitle} ${this.props.formKey} ${ `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName
json.comName
}${this.props.i + 1}行,第${this.props.j + }${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`, 1}列:公式配置有误,回调函数内部错误,`,
e, e,
...@@ -934,7 +934,7 @@ export default class TableCom extends Component { ...@@ -934,7 +934,7 @@ export default class TableCom extends Component {
e, e,
); );
} }
} else if (['Echart', 'QRCode', 'Graph', 'Tabs'].includes(json.comName)) { } else if (['Echart', 'QRCode', 'Graph', 'Tabs', 'Tree'].includes(json.comName)) {
try { try {
const x = callback(data); const x = callback(data);
if (x != null) { if (x != null) {
...@@ -1017,7 +1017,7 @@ export default class TableCom extends Component { ...@@ -1017,7 +1017,7 @@ export default class TableCom extends Component {
e, e,
); );
} }
} else if (['Echart', 'QRCode', 'Graph', 'Tabs'].includes(json.comName)) { } else if (['Echart', 'QRCode', 'Graph', 'Tabs', 'Tree'].includes(json.comName)) {
try { try {
const x = callback(data); const x = callback(data);
if (x != null) { if (x != null) {
...@@ -1234,7 +1234,7 @@ export default class TableCom extends Component { ...@@ -1234,7 +1234,7 @@ export default class TableCom extends Component {
}, },
); );
} }
} else if (['Echart', 'QRCode', 'Graph', 'Tabs'].includes(json.comName)) { } else if (['Echart', 'QRCode', 'Graph', 'Tabs', 'Tree'].includes(json.comName)) {
this.setState({ option: value }); this.setState({ option: value });
} else { } else {
try { try {
...@@ -1612,7 +1612,7 @@ export default class TableCom extends Component { ...@@ -1612,7 +1612,7 @@ export default class TableCom extends Component {
return this.props.form.getFieldDecorator(uuid, { return this.props.form.getFieldDecorator(uuid, {
initialValue: '', initialValue: '',
})( })(
<EchartsDiy json={json} uuid={uuid} option={this.state.option}/> <EchartsDiy json={json} uuid={uuid} option={this.state.option} />
) )
} }
if (json.comName === 'Graph') { if (json.comName === 'Graph') {
...@@ -1658,7 +1658,7 @@ export default class TableCom extends Component { ...@@ -1658,7 +1658,7 @@ export default class TableCom extends Component {
{this.props.form.getFieldDecorator(uuid, { {this.props.form.getFieldDecorator(uuid, {
initialValue: fk, initialValue: fk,
})(<Input type="hidden" />)} })(<Input type="hidden" />)}
{json.isLabel?(<Form.Item {json.isLabel ? (<Form.Item
labelCol={{ span: json.labelSpan }} labelCol={{ span: json.labelSpan }}
wrapperCol={{ span: json.wrapperSpan }} wrapperCol={{ span: json.wrapperSpan }}
label={json.label} label={json.label}
...@@ -1673,7 +1673,7 @@ export default class TableCom extends Component { ...@@ -1673,7 +1673,7 @@ export default class TableCom extends Component {
{...datas[fk]} {...datas[fk]}
form={this.props.form} form={this.props.form}
/> />
</Form.Item>):( <ZdyTable </Form.Item>) : (<ZdyTable
{...this.partFormProps} {...this.partFormProps}
currentFormTitle={ currentFormTitle={
this.props.getCurrentFormTitle ? this.props.getCurrentFormTitle(fk) : null this.props.getCurrentFormTitle ? this.props.getCurrentFormTitle(fk) : null
...@@ -1732,6 +1732,16 @@ export default class TableCom extends Component { ...@@ -1732,6 +1732,16 @@ export default class TableCom extends Component {
return xx; return xx;
} }
if (json.comName === 'Tree') {
if (!(this.state.option && this.state.option.treeData)) {
return <>无treeData配置项</>;
}
const xx = (
<TreeDiy json={this.props.json} option={this.state.option} />
);
return xx;
}
// if([ // if([
// // 'Select', // // 'Select',
// // 'Input', // // 'Input',
...@@ -2338,8 +2348,8 @@ ${obj[dataColumn.base52]} ...@@ -2338,8 +2348,8 @@ ${obj[dataColumn.base52]}
if (Array.isArray(labels) && labels.length && typeof labels[0] === 'object') { if (Array.isArray(labels) && labels.length && typeof labels[0] === 'object') {
stringLabels = ''; stringLabels = '';
let vLabels = []; let vLabels = [];
for(let item of labels){ // 解决禅道 32141 如果存在其他问题 估计要从otherProps中获取是否是多选 如果不是多选只取一个值 for (let item of labels) { // 解决禅道 32141 如果存在其他问题 估计要从otherProps中获取是否是多选 如果不是多选只取一个值
if(Object.values(item)){ if (Object.values(item)) {
vLabels.push(Object.values(item)); vLabels.push(Object.values(item));
} }
} }
...@@ -3576,7 +3586,7 @@ ${obj[dataColumn.base52]} ...@@ -3576,7 +3586,7 @@ ${obj[dataColumn.base52]}
} }
}); });
} }
: () => {} : () => { }
} }
format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'} format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'}
{...otherProps} {...otherProps}
...@@ -3893,7 +3903,7 @@ ${obj[dataColumn.base52]} ...@@ -3893,7 +3903,7 @@ ${obj[dataColumn.base52]}
message: '请上传图片', message: '请上传图片',
}, },
], ],
})(<ImgUploadCom json={json} disabled={disabled} otherProps={this.otherProps}/>); })(<ImgUploadCom json={json} disabled={disabled} otherProps={this.otherProps} />);
if ( if (
get === 'mobile' && get === 'mobile' &&
((json.isMobileLabel != null && json.isMobileLabel) || ((json.isMobileLabel != null && json.isMobileLabel) ||
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论