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