Merge pull request #936 from SuanmoSuanyangTechnology/feature/if_else_zy

fix(web): if-else port position
This commit is contained in:
yingzhao
2026-04-17 20:42:25 +08:00
committed by GitHub
2 changed files with 12 additions and 6 deletions

View File

@@ -109,7 +109,7 @@ const ConditionNode: ReactShapeConfig['component'] = ({ node }) => {
}
</Flex>
{expression.sub_variable_condition?.conditions?.length > 0 && expression.sub_variable_condition?.conditions.every(isSubExprSet)
? <div className="rb-border-l rb:ml-2">
? <div className="rb-border-l rb:ml-2 rb:mt-1.5">
{expression.sub_variable_condition?.conditions.map((sub: any, sIndex: number) => (
<div key={sIndex} className="rb:relative">
{expression.sub_variable_condition?.conditions.length > 1 && sIndex > 0 && <div className="rb:absolute rb:-top-2 rb:right-2 rb:text-[10px] rb:text-[#155EEF] rb:font-medium rb:leading-3.5 rb:text-right rb:pr-0.5">{expression.sub_variable_condition?.logical_operator?.toLocaleUpperCase()}</div>}

View File

@@ -2,7 +2,7 @@
* @Author: ZhaoYing
* @Date: 2026-03-24 15:07:49
* @Last Modified by: ZhaoYing
* @Last Modified time: 2026-04-17 19:13:22
* @Last Modified time: 2026-04-17 20:40:47
*/
import { portItemArgsY, conditionNodePortItemArgsY, conditionNodeHeight } from './constant'
@@ -91,6 +91,7 @@ export const getConditionNodeCasePortY = (cases: any[], caseIndex: number) => {
let portItemArgsYNum = 0;
for (let i = 0; i < caseIndex; i++) {
const notHasSub = cases[i]?.expressions?.filter((e: any) => !e?.sub_variable_condition?.conditions || e?.sub_variable_condition?.conditions.length <1).length
const n = cases[i]?.expressions?.length || 0;
let casePortItemArgsYNum = n + 1;
// Add extra y for expressions with all sub_variable_condition set
@@ -110,11 +111,16 @@ export const getConditionNodeCasePortY = (cases: any[], caseIndex: number) => {
cases[i]?.expressions?.forEach((e: any) => {
const subs = e?.sub_variable_condition?.conditions;
if (subs?.length && subs.every(isSubExprSet) && subs.length > 1) {
extraExprs += subs.length;
} else if (!subs && n > 2) {
extraExprs += n - 2;
}
extraExprs += subs.length + 2;
}
});
console.log('extraExprs notHasSub', notHasSub)
if (notHasSub > 3) {
extraExprs += n - 2 + notHasSub/4;
} else {
extraExprs += n - 2 + notHasSub/4
}
}
}