import DDComponents from '@/components/DDComponents'; import React, { useMemo, useState } from 'react'; import { Form } from '@ant-design/compatible'; import '@ant-design/compatible/assets/index.css'; const layout = { labelCol: { span: 8, }, wrapperCol: { span: 16, }, }; const AuditDetailed = props => { // const [form] = Form.useForm(); const { items, form } = props; const behavior = useMemo(() => { let data = {}; items.forEach(d => { const item = d.props; if (item.behaviorLinkage) { const key = item.id; const options = item.options.map(o => { let data; try { data = JSON.parse(o); } catch (error) { data = { key: o, value: o }; } return data; }); item.behaviorLinkage.forEach(b => { const value = b.value; b.targets.forEach(t => { data[t.fieldId] = { key, value: options.find(o => o.key == value)?.value }; }); }); } }); return data; }, [items]); const onFinish = values => { console.log(values); }; const GetComponent = item => { const { id, label, bizAlias, required, placeholder, options, align, statField, hideLabel, objOptions, format, pushToAttendance, labelEditableFreeze, requiredEditableFreeze, unit, extract, link, payEnable, bizType, childFieldVisible, notPrint, verticalPrint, hiddenInApprovalDetail, disabled, notUpper, children, // 子控件 } = item.props; // 判断是否属于关联项 if (behavior[id]) { const { key, value } = behavior[id]; let currentValue = form.getFieldValue(key); try { currentValue = JSON.parse(currentValue); } catch (error) {} // 判断是否需要渲染 if (currentValue instanceof Array) { if (currentValue?.indexOf(value) == -1) return null; } else { if (currentValue != value) return null; } } let formLabel; if (bizAlias) { formLabel = bizAlias; } else { try { // 判断label是否为JSON数组 formLabel = JSON.parse(label).join(','); } catch (error) { formLabel = label; } } const component = DDComponents({ item }); if (!component) return null; return ( {form.getFieldDecorator(id, { rules: [{ required }], })(component)} {notUpper == 1 &&

大写

}
); }; return (
{items.map(item => GetComponent(item))}
); }; export default AuditDetailed;