From fee4613c609b6562e077fdd4f8c84af43866853d Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Mon, 9 Feb 2026 20:18:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][upd?= =?UTF-8?q?ate]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/conTools.js | 78 ++++++++++++++++++++++ .../business/comps/template/comps/sp/SP003.vue | 11 ++- .../template/formConfig/paralleAndLadderConfig.js | 26 +++++--- 3 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 src/utils/conTools.js diff --git a/src/utils/conTools.js b/src/utils/conTools.js new file mode 100644 index 0000000..c8bd164 --- /dev/null +++ b/src/utils/conTools.js @@ -0,0 +1,78 @@ +/** + * 判断单位是否属于同一系列 + * @param {string} startUnit - 基准单位 + * @param {Array} units - 需要比较的单位数组 + * @returns {boolean} 是否属于同一系列 + */ + +export const isConUnitDiff = (startUnit, units) => { + if (!startUnit || !Array.isArray(units) || units.length === 0) { + return false; + } + + // 提取单位分子部分(斜杠前的部分) + const extractNumerator = (unit) => { + const normalizedUnit = unit + .replace('ug', 'μg') + .replace('umol', 'μmol') + .replace('IU', 'U'); + + if (!normalizedUnit.includes('/')) { + return null; // 不是浓度单位 + } + + const [numerator] = normalizedUnit.split('/'); + return numerator; + }; + + // 标准化分子部分,识别类别 + const classifyNumerator = (numerator) => { + // 质量单位 + const massUnits = ['mg', 'μg', 'ng', 'pg', 'fg', 'g']; + if (massUnits.some(massUnit => numerator.includes(massUnit))) { + return 'mass'; + } + + // 摩尔单位 + const moleUnits = ['mol', 'mmol', 'μmol', 'nmol', 'pmol']; + if (moleUnits.some(moleUnit => numerator.includes(moleUnit))) { + return 'mole'; + } + + // 酶活性单位 + const enzymeUnits = ['U', 'IU']; + if (enzymeUnits.some(enzymeUnit => numerator.includes(enzymeUnit))) { + return 'enzyme'; + } + + return 'other'; + }; + + // 获取基准单位的分子类别 + const startNumerator = extractNumerator(startUnit); + if (!startNumerator) { + console.warn(`基准单位 ${startUnit} 不是有效的浓度单位格式`); + return false; + } + + const startCategory = classifyNumerator(startNumerator); + + // 检查所有单位 + for (const unit of units) { + const numerator = extractNumerator(unit); + + if (!numerator) { + console.log(`单位 ${unit} 不是有效的浓度单位格式`); + return false; + } + + const category = classifyNumerator(numerator); + + if (category !== startCategory) { + console.log(`单位 ${unit} 属于 ${category} 类别,与基准 ${startCategory} 类别不同`); + return false; + } + } + + return true; +}; diff --git a/src/views/business/comps/template/comps/sp/SP003.vue b/src/views/business/comps/template/comps/sp/SP003.vue index 1772405..820efa1 100644 --- a/src/views/business/comps/template/comps/sp/SP003.vue +++ b/src/views/business/comps/template/comps/sp/SP003.vue @@ -20,7 +20,6 @@ :formData="formData" />