V2.07中,没有字段联动计算吗?

比如在表单上需要根据条件,对输入的字段值进行计算,并填写到其他字段中,目前的版本,字段联动中好像没有Formula.js公式计算

v2表单字段使用runjs功能计算赋值

const total_count_en = await ctx.getVar('ctx.formValues.total_count_en');
const total_count_cn = await ctx.getVar('ctx.formValues.total_count_cn');
return total_count_en+total_count_cn;

const item = await ctx.getVar('ctx.formValues.m2m.item');
return ctx.libs.formula.SUM(item);

通过await ctx.getVar(‘ctx.formValues.xxx’)可以取到当前表单的字段值,在子表格弹窗添加的时候,需要使用父表单的记录,请问如何获取?
在runjs文档中没有找到对应的方法;

最新版支持

已解决
//获取当前活动对象
const item = await ctx.getVar(‘ctx.item’);
//活动父窗口的值
const parentValue = item.parentItem.parentItem.value;

这样就可以取到窗口中的要引用计算的值了。

1 Like