提交 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';
......@@ -87,7 +88,7 @@ import StepDiy from '@/webPublic/one_stop_public/tableCompon/Split_Index/StepDiy
import EchartsDiy from '@/webPublic/one_stop_public/tableCompon/Split_Index/EchartsDiy';
import { getServicesNomal } from '../Services/services';
import {
getHeaderListApi,
getHeaderListApi,
getSqlDataApi,
findApi,
getSqlOptionsApi,
......@@ -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) {
}
}
......@@ -288,9 +289,9 @@ export default class TableCom extends Component {
onFilter: (value, record) =>
record[dataIndex]
? record[dataIndex]
.toString()
.toLowerCase()
.includes(value.toLowerCase())
.toString()
.toLowerCase()
.includes(value.toLowerCase())
: '',
onFilterDropdownVisibleChange: visible => {
if (visible) {
......@@ -412,9 +413,9 @@ export default class TableCom extends Component {
this.props.fatherCode != null
? bindObj
? {
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
: { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
: bindObj;
if (this.props.fatherCode == null && dataColumn == null) {
......@@ -676,7 +677,7 @@ export default class TableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i +
1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`,
1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`,
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) {
......@@ -770,7 +771,7 @@ export default class TableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -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,10 +845,9 @@ 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}列:公式配置有误,回调函数内部错误,`,
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 {
......@@ -1252,7 +1252,7 @@ export default class TableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i +
1}行,第${this.props.j + 1}列:公式配置有误,暂存失败,`,
1}行,第${this.props.j + 1}列:公式配置有误,暂存失败,`,
e,
);
}
......@@ -1275,9 +1275,9 @@ export default class TableCom extends Component {
this.props.fatherCode != null
? bindObj
? {
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
: { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
: bindObj;
if (this.props.fatherCode == null && dataColumn == null) {
......@@ -1479,16 +1479,16 @@ export default class TableCom extends Component {
allValues,
}).then(options => {
const optionsx = [];
for (var i = 0; i < options.length; i++) {
optionsx.push({
label: options[i][dataColumn.referenceNameName],
value: options[i][dataColumn.referenceCodeName],
});
}
this.setState({
options: optionsx,
selectDis: false,
for (var i = 0; i < options.length; i++) {
optionsx.push({
label: options[i][dataColumn.referenceNameName],
value: options[i][dataColumn.referenceCodeName],
});
}
this.setState({
options: optionsx,
selectDis: false,
});
});
} else if (!this.props.isEdit && Object.keys(obj).length > 0) {
if (obj[dataColumn.base52]) {
......@@ -1511,16 +1511,16 @@ export default class TableCom extends Component {
allValues,
}).then(options => {
const optionsx = [];
for (var i = 0; i < options.length; i++) {
optionsx.push({
label: options[i][dataColumn.referenceNameName],
value: options[i][dataColumn.referenceCodeName],
});
}
this.setState({
options: optionsx,
selectDis: false,
for (var i = 0; i < options.length; i++) {
optionsx.push({
label: options[i][dataColumn.referenceNameName],
value: options[i][dataColumn.referenceCodeName],
});
}
this.setState({
options: optionsx,
selectDis: false,
});
});
}
};
......@@ -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,17 +1673,17 @@ export default class TableCom extends Component {
{...datas[fk]}
form={this.props.form}
/>
</Form.Item>):( <ZdyTable
{...this.partFormProps}
currentFormTitle={
this.props.getCurrentFormTitle ? this.props.getCurrentFormTitle(fk) : null
}
key={fk}
currentFormKey={fk}
{...datas[fk]}
form={this.props.form}
/>)}
</Form.Item>) : (<ZdyTable
{...this.partFormProps}
currentFormTitle={
this.props.getCurrentFormTitle ? this.props.getCurrentFormTitle(fk) : null
}
key={fk}
currentFormKey={fk}
{...datas[fk]}
form={this.props.form}
/>)}
</>
);
}
......@@ -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',
......@@ -2147,9 +2157,9 @@ export default class TableCom extends Component {
this.props.fatherCode != null
? bindObj
? {
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
: { base52: `${this.props.fatherCode}.[${this.props.index}].${uuid}` }
: bindObj;
......@@ -2294,18 +2304,18 @@ ${obj[dataColumn.base52]}
<span>
{labels != null
? labels.map((r, i) =>
i == 0 ? (
typeof r == 'string' ? (
<span>{r}</span>
) : (
Object.values(r)
)
) : typeof r == 'string' ? (
<span style={{ marginLeft: 12 }}>{r}</span>
i == 0 ? (
typeof r == 'string' ? (
<span>{r}</span>
) : (
',' + Object.values(r)
),
)
Object.values(r)
)
) : typeof r == 'string' ? (
<span style={{ marginLeft: 12 }}>{r}</span>
) : (
',' + Object.values(r)
),
)
: ''}
</span>
);
......@@ -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));
}
}
......@@ -2421,8 +2431,8 @@ ${obj[dataColumn.base52]}
<span>
{vTime
? moment(+new Date(vTime)).format(
json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
)
json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
)
: ''}
</span>
);
......@@ -2504,10 +2514,10 @@ ${obj[dataColumn.base52]}
}
}
cm = <UploadComReadOnly get={get}
obj={obj}
dataColumn={dataColumn}
isPrint={this.props.isPrint}
otherProps={otherProps}
obj={obj}
dataColumn={dataColumn}
isPrint={this.props.isPrint}
otherProps={otherProps}
/>
break;
case 'ImgUploadCom':
......@@ -2759,11 +2769,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + title,
},
],
{
required: required,
message: '请选择' + title,
},
],
})}
disabled={disabled}
onClick={checked => {
......@@ -2776,7 +2786,7 @@ ${obj[dataColumn.base52]}
}
>
{(json.isMobileLabel != null && json.isMobileLabel) ||
(json.isMobileLabel == null && json.isLabel)
(json.isMobileLabel == null && json.isLabel)
? title
: ''}
</MobileList.Item>
......@@ -2790,11 +2800,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + title,
},
],
{
required: required,
message: '请选择' + title,
},
],
})(<SwitchWeb json={json} disabled={disabled} />);
break;
......@@ -2940,11 +2950,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请输入' + title,
},
],
{
required: required,
message: '请输入' + title,
},
],
})(
<InputNumber
disabled={disabled}
......@@ -3047,7 +3057,7 @@ ${obj[dataColumn.base52]}
defaultValues={defaultValues}
/>
* */
null}
null}
</Tabs.TabPane>
);
})}
......@@ -3064,11 +3074,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + dataColumn.title,
},
],
{
required: required,
message: '请选择' + dataColumn.title,
},
],
})(<Radio.Group options={options} disabled={disabled} />);
if (get == 'mobile') {
cm = <div>{cm}</div>;
......@@ -3104,11 +3114,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + dataColumn.title,
},
],
{
required: required,
message: '请选择' + dataColumn.title,
},
],
})(<Checkbox.Group options={options} disabled={disabled} />)}
</Flex>
);
......@@ -3139,11 +3149,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + dataColumn.title,
},
],
{
required: required,
message: '请选择' + dataColumn.title,
},
],
})(
<Checkbox.Group
options={options}
......@@ -3152,7 +3162,7 @@ ${obj[dataColumn.base52]}
/>,
);
break;
case 'TreeSelect':
case 'TreeSelect':
if (json?.otherProps) {
otherProps = json?.otherProps;
try {
......@@ -3196,8 +3206,8 @@ ${obj[dataColumn.base52]}
const optDiy = Array.isArray(json?.options)
? json.options
: Array.isArray(options)
? options
: [];
? options
: [];
// if(uuid === 'violation_type_id'){
// console.log(json);
// }
......@@ -3211,11 +3221,11 @@ ${obj[dataColumn.base52]}
Array.isArray(json.vlds) && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + dataColumn.title,
},
],
{
required: required,
message: '请选择' + dataColumn.title,
},
],
})(
!optDiy.length ? (
<Input disabled={true} style={{ width: json.width }} />
......@@ -3231,18 +3241,18 @@ ${obj[dataColumn.base52]}
onFocus={() => {
get === 'mobile' // 移动端取消输入键盘弹出
? setTimeout(() => {
if (document.querySelectorAll(`.ant-select-search__field`).length > 0) {
let ary = [...document.querySelectorAll(`.ant-select-search__field`)];
ary.map(item => {
item.setAttribute('readonly', 'readonly');
// setTimeout(() => {
// ary.map(arr => {
// arr.removeAttribute('readonly');
// })
// });
});
}
})
if (document.querySelectorAll(`.ant-select-search__field`).length > 0) {
let ary = [...document.querySelectorAll(`.ant-select-search__field`)];
ary.map(item => {
item.setAttribute('readonly', 'readonly');
// setTimeout(() => {
// ary.map(arr => {
// arr.removeAttribute('readonly');
// })
// });
});
}
})
: null;
}}
filterOption={(input, option) =>
......@@ -3314,11 +3324,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + dataColumn.title,
},
],
{
required: required,
message: '请选择' + dataColumn.title,
},
],
})(
<Cascader // 这里的options 获取方式存在bug 公式会重复调用
options={options}
......@@ -3340,11 +3350,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + dataColumn.title,
},
],
{
required: required,
message: '请选择' + dataColumn.title,
},
],
})(<MobileCascader options={options} label={title} disabled={disabled} json={json} />);
}
......@@ -3377,22 +3387,22 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
validator: (rule, value, callback) => {
let errors = [];
if (
(Object.keys(value).length == 0 ||
Object.keys(value.selects).length == 0) &&
required != null &&
required
) {
errors.push(new Error('请选择至少一个', rule.field));
}
callback(errors);
},
required: required,
{
validator: (rule, value, callback) => {
let errors = [];
if (
(Object.keys(value).length == 0 ||
Object.keys(value.selects).length == 0) &&
required != null &&
required
) {
errors.push(new Error('请选择至少一个', rule.field));
}
callback(errors);
},
],
required: required,
},
],
})(
<TableSelect
get={get}
......@@ -3467,20 +3477,20 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择起止时间',
validator: (rule, value, callback) => {
let errors = [];
if (!value || !Array.isArray(value) || value.length !== 2) {
// 移动端起止时间必须是个数组 且 length = 2
errors.push(new Error('请选择', rule.field));
}
callback(errors);
},
{
required: required,
message: '请选择起止时间',
validator: (rule, value, callback) => {
let errors = [];
if (!value || !Array.isArray(value) || value.length !== 2) {
// 移动端起止时间必须是个数组 且 length = 2
errors.push(new Error('请选择', rule.field));
}
callback(errors);
},
],
},
],
})(
<MobileDate
disabled={disabled}
......@@ -3517,11 +3527,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择起止时间',
},
],
{
required: required,
message: '请选择起止时间',
},
],
})(<RangePickerDiy json={json} disabled={disabled} uuid={uuid} />);
}
if (json.label == null) title = '起止时间';
......@@ -3549,11 +3559,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择起止时间',
},
],
{
required: required,
message: '请选择起止时间',
},
],
})(
<DatePicker
disabled={disabled}
......@@ -3562,21 +3572,21 @@ ${obj[dataColumn.base52]}
onOpenChange={
get === 'mobile'
? () => {
// 取消唤起移动端小键盘
setTimeout(() => {
if (document.querySelector('.ant-calendar-input ')) {
// 取消唤起移动端小键盘
setTimeout(() => {
if (document.querySelector('.ant-calendar-input ')) {
document
.querySelector('.ant-calendar-input ')
.setAttribute('readonly', 'readonly');
setTimeout(() => {
document
.querySelector('.ant-calendar-input ')
.setAttribute('readonly', 'readonly');
setTimeout(() => {
document
.querySelector('.ant-calendar-input ')
.removeAttribute('readonly');
});
}
});
}
: () => {}
.removeAttribute('readonly');
});
}
});
}
: () => { }
}
format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'}
{...otherProps}
......@@ -3613,11 +3623,11 @@ ${obj[dataColumn.base52]}
json?.vlds && json?.vlds.length > 0
? json.vlds
: [
{
required,
message: '请进行签章',
},
],
{
required,
message: '请进行签章',
},
],
})(
<SignArray // 签章组件 编辑模式
json={json}
......@@ -3701,11 +3711,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请输入',
},
],
{
required: required,
message: '请输入',
},
],
})(<WangEditor json={json} dataColumn={dataColumn} disabled={disabled} uuid={uuid} />);
break;
case 'Steps':
......@@ -3742,11 +3752,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请输入',
},
],
{
required: required,
message: '请输入',
},
],
})(<DraftEditorCom placeholder={json.placeholder} disabled={json.disabled} />);
if (
get === 'mobile' &&
......@@ -3773,11 +3783,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请输入' + title,
},
],
{
required: required,
message: '请输入' + title,
},
],
})(<CronEditorDiy />);
break;
case 'LocationCom':
......@@ -3787,22 +3797,22 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required,
message: '请获取定位信息',
validator: (rule, valueThis, callback) => {
let errors = [];
console.log(valueThis);
if (
(!valueThis || !JSON.stringify(valueThis).includes('address')) &&
required
) {
errors.push(new Error('请获取定位信息', rule.field));
}
callback(errors);
},
{
required,
message: '请获取定位信息',
validator: (rule, valueThis, callback) => {
let errors = [];
console.log(valueThis);
if (
(!valueThis || !JSON.stringify(valueThis).includes('address')) &&
required
) {
errors.push(new Error('请获取定位信息', rule.field));
}
callback(errors);
},
],
},
],
})(
<LocationCom
get={get}
......@@ -3888,12 +3898,12 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请上传图片',
},
],
})(<ImgUploadCom json={json} disabled={disabled} otherProps={this.otherProps}/>);
{
required: required,
message: '请上传图片',
},
],
})(<ImgUploadCom json={json} disabled={disabled} otherProps={this.otherProps} />);
if (
get === 'mobile' &&
((json.isMobileLabel != null && json.isMobileLabel) ||
......@@ -3919,11 +3929,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请上传视频',
},
],
{
required: required,
message: '请上传视频',
},
],
})(<VideoUploadCom json={json} disabled={disabled} />);
if (
get === 'mobile' &&
......@@ -3950,11 +3960,11 @@ ${obj[dataColumn.base52]}
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请进行签名',
},
],
{
required: required,
message: '请进行签名',
},
],
})(<Signature width={json.width} height={json.height} get={get} />);
if (
get === 'mobile' &&
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论