diff --git a/src/components/Common/FlowDesign/Config/Components/PrintNode/Template/index.tsx b/src/components/Common/FlowDesign/Config/Components/PrintNode/Template/index.tsx index b2e1bd01b744dab6a8e183d44128b1e63e9d8a1e..5a414ce595f17b8fc83fd48a3bfc1ad85aa2e4e2 100644 --- a/src/components/Common/FlowDesign/Config/Components/PrintNode/Template/index.tsx +++ b/src/components/Common/FlowDesign/Config/Components/PrintNode/Template/index.tsx @@ -58,7 +58,9 @@ const Templates: FC = ({ // 遍历主表和子表,加载字段 for (const xform of [...primaryForms, ...detailForms]) { - const formAttr = (attributes[xform.id] || xform.attributes || []) as XAttribute[]; + const formAttr = (attributes?.[xform.id] || + xform?.attributes || + []) as XAttribute[]; const form = new Form({ ...xform, id: xform.id + '_' }, directory); const xfields = await form.loadFields(false); diff --git a/src/components/Common/FlowDesign/Config/Components/PrintNode/printTemplate/Template1.tsx b/src/components/Common/FlowDesign/Config/Components/PrintNode/printTemplate/Template1.tsx index b6ba8a46f6974e374b984e2bbebf6e38f4b62020..3de30fecf7944e22a0720d1a157e5dcea10dc694 100644 --- a/src/components/Common/FlowDesign/Config/Components/PrintNode/printTemplate/Template1.tsx +++ b/src/components/Common/FlowDesign/Config/Components/PrintNode/printTemplate/Template1.tsx @@ -580,7 +580,7 @@ const Template1: FC = ({ } catch (error) {} } }; - const SubTab: FC = ({ id, valueType, value, checkKey }) => { + const SubTab: FC = ({ id, valueType, value, checkKey, curField }) => { const [userDetail, setUserDetail] = useState<{ [key: string]: string }>({}); useEffect(() => { if (valueType === '用户型') { @@ -591,7 +591,8 @@ const Template1: FC = ({ } }, []); const attributesData = attributes[id].attributes; - const attrsObj = attributesData.filter((item: any) => item.id == checkKey)[0]; + const attrsObj = + curField ?? attributesData.filter((item: any) => item.id == checkKey)[0]; if (valueType == '日期型') { return {value ? formatZhDate(value, 'YYYY年MM月DD日') : ''}; } else if (valueType === '数值型') { @@ -1209,6 +1210,7 @@ const Template1: FC = ({ let tdValue = subItem[subdataitem.id] ?? subItem[subdataitem.code]; + let curField; if (typeof tdValue === 'undefined') { const fields = current.instanceData?.fields[ @@ -1217,7 +1219,7 @@ const Template1: FC = ({ ]?.id ]; if (fields) { - const curField = fields.find( + curField = fields.find( (field: any) => field.code === subdataitem.code || @@ -1274,18 +1276,14 @@ const Template1: FC = ({ subdataitem.valueType, ) ? (
{tdValue}
- ) : (subItem[ - subdataitem.id - ] ?? - subItem[ - subdataitem.code - ]) !== undefined ? ( + ) : tdValue ? (