diff --git a/src/components/FormBuilder/FormItemsRenderer.js b/src/components/FormBuilder/FormItemsRenderer.js index 2740a77..9321ee2 100644 --- a/src/components/FormBuilder/FormItemsRenderer.js +++ b/src/components/FormBuilder/FormItemsRenderer.js @@ -526,17 +526,17 @@ const FormItemsRenderer = ({ return renderFormList(params); // 判断一个项是否需要显示按钮(不是 onlyForLabel 且不是隐藏的) - const isShowButton = (opt) => { + const isShow = (opt) => { return !getHidden(opt.hidden) && !opt.onlyForLabel; }; // 从后往前找,找到第一个需要显示按钮的项的索引 - const findLastButtonIndex = () => { + const findLastShowIndex = () => { for (let i = listOptions.length - 1; i >= 0; i--) { const opt = listOptions[i]; if (opt.render === FORM_ITEM_RENDER_ENUM.FORM_LIST) return i; - if (isShowButton(opt)) + if (isShow(opt)) return i; } return -1; @@ -545,11 +545,11 @@ const FormItemsRenderer = ({ // 判断下一个是否是嵌套的 FormList,或者是 onlyForLabel/hidden 项 const nextOption = listOptions[listIndex + 1]; const isNextNestedFormList = nextOption && nextOption.render === FORM_ITEM_RENDER_ENUM.FORM_LIST; - const isNextNoButton = nextOption && !isShowButton(nextOption); + const isNextNoShow = nextOption && !isShow(nextOption); // 如果是最后一个需要显示按钮的项,或者下一个是嵌套的 FormList,或者下一个不需要按钮,则在其后添加操作按钮 - const lastButtonIndex = findLastButtonIndex(); - if (listIndex === lastButtonIndex || isNextNestedFormList || isNextNoButton) { + const lastShowIndex = findLastShowIndex(); + if (listIndex === lastShowIndex || isNextNestedFormList || isNextNoShow) { delete formItemProps.dependencies; delete formItemProps.shouldUpdate; return (