Browse Source

feat:[模板管理][update]

lkf
luojie 2 months ago
parent
commit
fee4613c60
3 changed files with 105 additions and 10 deletions
  1. +78
    -0
      src/utils/conTools.js
  2. +10
    -1
      src/views/business/comps/template/comps/sp/SP003.vue
  3. +17
    -9
      src/views/business/comps/template/formConfig/paralleAndLadderConfig.js

+ 78
- 0
src/utils/conTools.js View File

@ -0,0 +1,78 @@
/**
* 判断单位是否属于同一系列
* @param {string} startUnit - 基准单位
* @param {Array<string>} 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;
};

+ 10
- 1
src/views/business/comps/template/comps/sp/SP003.vue View File

@ -20,7 +20,6 @@
:formData="formData" />
<CustomTable fieldItemLabel="template.common.operationSteps" @blur="onHandleTableBlur"
:showAddRow="fillType === 'preFill' ? true : false" :showOperation="fillType === 'actFill'"
:isBorder="false"
ref="stepTableRef" :columns="stepColumns" :formData="formData">
<template slot="operation" slot-scope="{ row, rowIndex, columns }">
<TableOpertaion @startConfig="startConfig" @configComplete="configComplete"
@ -51,6 +50,7 @@ import SelectReagentDialog from '../../dialog/SelectReagentDialog.vue';
import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue";
import { EventBus } from "@/utils/eventBus";
import { addTj, uniqeResource, uniqeResourceOne, addDecimals } from "@/utils/calUnitTools";
import { isConUnitDiff } from "@/utils/conTools";
export default {
name: "SP003",
components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion },
@ -563,6 +563,15 @@ export default {
},
async getFormData() {
let content = await this.validFormFields(["baseInfoRef", "stepFormPackageRef", "stepTableRef", "stepRef", "remarkRef"]);
console.log(content,"content")
if(content){
const {headerSelectFields = {},subTargetStartSolution} = content;
const {targetSolutionConcentrationUnit,actSolutionConcentrationUnit} = headerSelectFields;
if(!isConUnitDiff(subTargetStartSolution,[targetSolutionConcentrationUnit,actSolutionConcentrationUnit])){
this.$message.error("起始浓度单位与目标浓度单位不符,请重新选择!");
return false;
}
}
return content;
},
getResource() {

+ 17
- 9
src/views/business/comps/template/formConfig/paralleAndLadderConfig.js View File

@ -40,7 +40,8 @@ export const getLadderColumnsConfig = ($this) => {
bodyPrecisionKey: 'targetStartSolutionVolumePrecision',
bodyMaxlength: 10,
bodyDisabled: true,
bodySubPlaceholder: 'template.common.xswsPlaceholder'
bodySubPlaceholder: 'template.common.xswsPlaceholder',
selectTo:"actStartSolutionVolumeUnit",
},
{
label: 'template.sp.sp00456.sjqsrytj',
@ -74,7 +75,8 @@ export const getLadderColumnsConfig = ($this) => {
bodyPrecisionKey: 'targetDiluentVolumePrecision',
bodyMaxlength: 10,
bodySubPlaceholder: 'template.common.xswsPlaceholder'
bodySubPlaceholder: 'template.common.xswsPlaceholder',
selectTo:"actDiluentVolumeUnit",
},
{
label: 'template.sp.sp00456.sjxsytj',
@ -100,7 +102,8 @@ export const getLadderColumnsConfig = ($this) => {
headerOptions: $this.getDictOptions('business_nddw'),
bodyType: 'inputNumber',
bodyFillType: 'preFill',
bodyMaxlength: 10
bodyMaxlength: 10,
selectTo:"actSolutionConcentrationUnit",
},
{
label: 'template.sp.sp00456.sjmbrynd',
@ -133,7 +136,8 @@ export const getLadderColumnsConfig = ($this) => {
headerOptions: $this.getDictOptions('business_tjdw'),
bodyType: 'inputNumber',
bodyFillType: 'preFill',
bodyMaxlength: 10
bodyMaxlength: 10,
selectTo:"actSolutionVolumeUnit",
},
{
label: 'template.sp.sp00456.sjmbrytj',
@ -192,7 +196,8 @@ export const getParallelColumnsConfig = ($this) => {
headerOptions: $this.getDictOptions('business_nddw'),
bodyType: 'inputNumber',
bodyFillType: 'preFill',
bodyMaxlength: 10
bodyMaxlength: 10,
selectTo:"actSolutionConcentrationUnit",
},
{
label: 'template.sp.sp00456.sjmbrynd',
@ -224,7 +229,8 @@ export const getParallelColumnsConfig = ($this) => {
headerOptions: $this.getDictOptions('business_tjdw'),
bodyType: 'inputNumber',
bodyFillType: 'preFill',
bodyMaxlength: 10
bodyMaxlength: 10,
selectTo:"actSolutionVolumeUnit",
},
{
label: 'template.sp.sp00456.sjmbrytj',
@ -297,7 +303,7 @@ export const getParallelColumnsConfig = ($this) => {
bodySubOptions: $this.getDictOptions('business_nddw'),
bodySubFillType: 'preFill',
bodyMaxlength: 10,
showBodySub: true
showBodySub: true,
},
{
label: 'template.sp.sp00456.sjysrynd',
@ -328,7 +334,8 @@ export const getParallelColumnsConfig = ($this) => {
bodySubPlaceholder: 'template.common.xswsPlaceholder',
bodyDisabled: true,
showBodySub: true,
showBodySub: $this.fillType === 'preFill'
showBodySub: $this.fillType === 'preFill',
selectTo:"actStartSolutionVolumeUnit",
},
{
@ -363,7 +370,8 @@ export const getParallelColumnsConfig = ($this) => {
bodyPrecisionKey: 'targetDiluentVolumePrecision',
bodySubPlaceholder: 'template.common.xswsPlaceholder',
bodyDisabled: true,
showBodySub: $this.fillType === 'preFill'
showBodySub: $this.fillType === 'preFill',
selectTo:"actDiluentVolumeUnit",
},
{
label: 'template.sp.sp00456.sjxsytj',

Loading…
Cancel
Save