/**计算自动填充意见,只适用于审批流程 */
export function radioToText() {
const textArr: string[] = [];
// tslint:disable-next-line:ter-max-len
const dom = Array.prototype.slice.call(document.querySelectorAll(".ant-radio-group"))?.map(i =>
i && i.lastElementChild && i.lastElementChild.className);
const titleDom = Array.prototype.slice.call(document.querySelectorAll(".ant-form-item-required"))?.map(i => i.innerText);
dom.forEach((i, index) => {
if (i.includes("-checked")) {
textArr.push(titleDom[index].replace("是否", "不"));
}
});
return textArr.join(",");
}
componentDidUpdate() {
const { form: { isFieldsTouched } } = this.props;
if (isFieldsTouched(["forestryPlanningCheck", "riverWaterCheck", "voltagePowerCheck", "railwayCheck"])) {
this.setState({ text: radioToText() });
}
}
<Form.Item label="公路铁路及各类工程管线是否安全退让距离" style={flexLaout}>
{getFieldDecorator("railwayCheck", {
initialValue: result ? result.railwayCheck : undefined,
rules: [{ required: true, message: "公路铁路及各类工程管线是否安全退让距离必须选择!" }],
})(
<Radio.Group disabled={Boolean(nodeId > getId) || isHistory}>
<Radio value>是</Radio>
<Radio value={false}>否</Radio>
</Radio.Group>,
)}
</Form.Item>
获取.ant-radio-group下次级的最后一个元素 i.lastElementChild.className