| | |
| | | } |
| | | |
| | | /** |
| | | * 获取纯单元格引用公式的坐标名,例如 =F4、=$F$4。 |
| | | * 纯引用应直接复制原值,避免把“外观”等中文文本送入数值计算。 |
| | | */ |
| | | function getDirectReferenceName(f) { |
| | | if (typeof f !== "string") { |
| | | return null; |
| | | } |
| | | const matched = f.trim().match(/^=\s*\$?([A-Za-z]{1,3})\$?(\d{1,7})\s*$/); |
| | | return matched ? `${matched[1].toUpperCase()}${matched[2]}` : null; |
| | | } |
| | | |
| | | /** |
| | | * 按检验项id取当前样品下的检验项信息,取不到时返回空对象,避免公式计算因缺项中断 |
| | | * |
| | | * @param id 检验项id |
| | |
| | | // 如果是函数方法,则执行此方法 |
| | | let comResult = ""; //初始化计算结果 |
| | | try { |
| | | if ( |
| | | const directReferenceName = getDirectReferenceName(item.v.f); |
| | | if (directReferenceName && Object.prototype.hasOwnProperty.call(comValue, directReferenceName)) { |
| | | // =F4 这类公式既可能引用数字,也可能引用中文文本,直接保留源值。 |
| | | comResult = comValue[directReferenceName]; |
| | | } else if ( |
| | | getInspectionValueType(item.i) == 1 || |
| | | isNumericFormula(item.v.f) |
| | | ) { |