Browse Source

feat:[模板管理][烦人的浓度计算和单位换算]

lkf
luojie 2 months ago
parent
commit
603a545f17
6 changed files with 152 additions and 38 deletions
  1. +12
    -9
      src/components/Template/CustomTable.vue
  2. +1
    -1
      src/components/Template/mixins/formPackageMixins.js
  3. +26
    -3
      src/views/business/comps/template/comps/sp/SP003.vue
  4. +64
    -9
      src/views/business/comps/template/comps/sp/SP00456.vue
  5. +1
    -1
      src/views/business/comps/template/formConfig/paralleAndLadderConfig.js
  6. +48
    -15
      src/views/business/comps/template/mixins/templateMixin.js

+ 12
- 9
src/components/Template/CustomTable.vue View File

@ -73,7 +73,7 @@
:fieldItemLabel="fieldItemLabel" type="select" class="body-select"
@blur="onBlur(rowIndex, col.prop, $event)"
:item="getBodyItem(col, rowIndex)" v-model="row[col.prop]"
@change="onBodyValueChange(rowIndex, colIndex, $event)"
@change="onBodyValueChange(rowIndex, colIndex, $event,row,'select')"
:error="hasError(rowIndex, colIndex, col.prop)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)"
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" />
@ -135,7 +135,7 @@
@blur="onSubBlur(rowIndex, col.bodySubKey, $event)"
@copy="onCopy(rowIndex, col)" :item="getBodySubItem(col)"
v-model="row[col.bodySubKey]"
@change="onBodySubValueChange(rowIndex, colIndex, $event)"
@change="onBodySubValueChange(rowIndex, colIndex,$event,)"
:error="hasError(rowIndex, colIndex, col.bodySubKey)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.bodySubKey, $event)"
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.bodySubKey)" />
@ -145,7 +145,7 @@
:fieldItemLabel="fieldItemLabel" type="select" class="body-select"
@blur="onSubBlur(rowIndex, col.bodySubKey, $event)"
:item="getBodySubItem(col, rowIndex)" v-model="row[col.bodySubKey]"
@change="onBodySubValueChange(rowIndex, colIndex, $event)"
@change="onBodySubValueChange(rowIndex, colIndex, $event,row,'select')"
:error="hasError(rowIndex, colIndex, col.bodySubKey)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.bodySubKey, $event)"
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.bodySubKey)" />
@ -506,12 +506,11 @@ export default {
},
//
onHeaderSelectChange(col, value) {
console.log(col,"ccc")
if (col.headerSelectTo) {
this.headerSelectFields[col.headerSelectTo] = value;
}
this.headerSelectFields[col.headerSelectKey] = value;
console.log(this.headerSelectFields, "this.headerSelectFields")
this.$emit('headerSelectChange', {key:col.headerSelectKey, headerSelectFields:this.headerSelectFields,dataSource:this.localDataSource});
//
this.formErrors = this.formErrors.filter(error =>
!(error.rowIndex === -1 &&
@ -573,7 +572,7 @@ export default {
},
//
onBodyValueChange(rowIndex, colIndex, value) {
onBodyValueChange(rowIndex, colIndex, value,row,type) {
const col = this.columns[colIndex];
this.localDataSource[rowIndex][col.prop] = value;
@ -586,10 +585,12 @@ export default {
error.colIndex === colIndex &&
error.field === col.prop)
);
this.$emit('body-value-change', rowIndex, colIndex, value);
if(type === "select"){
this.$emit('bodySelectChange', {rowIndex,item:row, colIndex, value,key:col.prop,dataSource:this.localDataSource,headerSelectFields:this.headerSelectFields});
}
},
//
onBodySubValueChange(rowIndex, colIndex, value) {
onBodySubValueChange(rowIndex, colIndex, value,row,type) {
const col = this.columns[colIndex];
this.localDataSource[rowIndex][col.bodySubKey] = value;
@ -612,7 +613,9 @@ export default {
error.colIndex === colIndex &&
error.field === col.bodySubKey)
);
this.$emit('body-sub-value-change', rowIndex, colIndex, value);
if(type === "select"){
this.$emit('bodySelectChange', {rowIndex,item:row, colIndex, value,key:col.bodySubKey,dataSource:this.localDataSource,headerSelectFields:this.headerSelectFields});
}
},
getHeaderItem(col) {
return {

+ 1
- 1
src/components/Template/mixins/formPackageMixins.js View File

@ -54,7 +54,7 @@ export default {
}
this.onValueChangeCompareTo(key, val);
this.formFields[key] = val;
this.$emit("select", { key, value: val, type });
this.$emit("select", { key, value: val, type,...this.formFields });
// 清除该表单项的错误状态
if (this.errors[key]) {
this.$set(this.errors, key, false);

+ 26
- 3
src/views/business/comps/template/comps/sp/SP003.vue View File

@ -18,10 +18,13 @@
<BaseInfoFormPackage ref="stepFormPackageRef" fieldItemLabel="template.common.operationSteps"
@onRegentSubmit="onRegentSubmit"
@beforeReagentSubmit="onBeforeReagentSubmit"
@select = "onFormSelect"
:formConfig="stepFormConfig" @blur="onHandleBlur"
:formData="formData" />
<CustomTable fieldItemLabel="template.common.operationSteps" @blur="onHandleTableBlur"
:showAddRow="fillType === 'preFill' ? true : false" :showOperation="fillType === 'actFill'"
<CustomTable
@headerSelectChange="onHeaderSelectChange"
fieldItemLabel="template.common.operationSteps" @blur="onHandleTableBlur"
:showAddRow="false" :showOperation="fillType === 'actFill'"
ref="stepTableRef" :columns="stepColumns" :formData="formData">
<template slot="operation" slot-scope="{ row, rowIndex, columns }">
<TableOpertaion @startConfig="startConfig" @configComplete="configComplete"
@ -435,7 +438,27 @@ export default {
// const re = convertConcentration.convert('100mg/mL',"ng/mL")
},
methods: {
onFormSelect(fields){
this.onHandleBlur(fields)
},
//table header
onHeaderSelectChange(data){
const {key, headerSelectFields,dataSource=[]} = data;
const keys = [
'targetStartSolutionVolumeUnit',
'targetDiluentVolumeUnit',
'targetSolutionConcentrationUnit',
'targetSolutionVolumeUnit',
]
if(keys.includes(key)){
const {targetStartSolution,subTargetStartSolution} = this.$refs.stepFormPackageRef?.getFilledFormData();
const params = {
subTargetStartSolution,
headerSelectFields
}
this.batchUpdateTargetStartSolutionVolume(dataSource,targetStartSolution,params)
}
},
//
onRegentSubmit(data) {
const { selectInfo, key } = data;

+ 64
- 9
src/views/business/comps/template/comps/sp/SP00456.vue View File

@ -36,10 +36,13 @@
@beforeReagentSubmit="(data) => onBeforeReagentSubmit(data,ladderIndex, ladderConfig)"
:ref="`ladderStepFormPackageRef_${ladderIndex}`" :formConfig="ladderStepFormConfig"
:formData="ladderConfig" :fieldItemLabel="$t('template.common.jtpz')"
@blur="(e) => onHandleBlur(e,'ladder', ladderIndex)"
@select = "(e) => onHandleBlur(e,'ladder', ladderIndex)"
:prefixKey="'ladder_' + ladderIndex" />
<CustomTable @blur="(e) => onHandleTableBlur('ladder', ladderIndex, e)"
:ref="`ladderStepTableRef_${ladderIndex}`" :showOperation="fillType === 'actFill' || fillType === 'preFill'"
:columns="ladderStepColumns" :formData="ladderConfig"
@headerSelectChange="(data)=>onHeaderSelectChange(data,'ladder',ladderIndex)"
:prefixKey="'ladder_' + ladderIndex" :fieldItemLabel="$t('template.common.jtpz')">
<template slot="operation" slot-scope="{ row, rowIndex, columns }">
<TableOpertaion @printTag="(e) => printTag(e, 'ladderConfigs', ladderIndex)"
@ -77,6 +80,8 @@
<CustomTable @blur="(e) => onHandleTableBlur('paralle', paralleIndex, e)"
:ref="`paralleStepTableRef_${paralleIndex}`" :showOperation="fillType === 'actFill' || fillType === 'preFill'"
:columns="paralleStepColumns"
@bodySelectChange = "bodySelectChange"
@headerSelectChange="(data)=>onHeaderSelectChange(data,'paralle',paralleIndex)"
@beforeReagentSubmit="(data) => onTableBeforeReagentSubmit(data, paralleIndex, paralleConfig)"
@onRegentSubmit="(data) => onTableRegentSubmit('paralle', paralleIndex, data)"
:formData="paralleConfig" :prefixKey="'paralle' + paralleIndex"
@ -194,7 +199,56 @@ export default {
}
},
methods: {
bodySelectChange(data){
this.paralleUpdateTargetStartSolutionVolume(data.item,data.headerSelectFields);
},
//
paralleUpdateTargetStartSolutionVolume(item,headerSelectFields){
const volumne = item.targetStartSolutionConcentration;
const subTargetStartSolution = item.targetStartSolutionConcentrationPrecision;
const params = {
headerSelectFields,
subTargetStartSolution
}
if (volumne) {
this.updateTargetStartSolutionVolume(item, volumne,params);
}
},
onHandleBlur(e,type,configIndex){
const {targetStartSolution,subTargetStartSolution} = e;
const {stepTableFormData,headerSelectFields} = this.$refs[`ladderStepTableRef_${configIndex}`][0]?.getFilledFormData();
const params = {
subTargetStartSolution,
headerSelectFields
}
this.batchUpdateTargetStartSolutionVolume(stepTableFormData,targetStartSolution,params)
},
//table header
onHeaderSelectChange(data,type,configIndex){
const {key, headerSelectFields,dataSource=[]} = data;
const keys = [
'targetStartSolutionVolumeUnit',
'targetDiluentVolumeUnit',
'targetSolutionConcentrationUnit',
'targetSolutionVolumeUnit',
]
console.log(key,"key")
if(keys.includes(key)){
if(type === 'ladder'){
const {targetStartSolution,subTargetStartSolution} = this.$refs[`ladderStepFormPackageRef_${configIndex}`][0]?.getFilledFormData();
const params = {
subTargetStartSolution,
headerSelectFields
}
this.batchUpdateTargetStartSolutionVolume(dataSource,targetStartSolution,params)
}else{
dataSource.forEach(item => {
this.paralleUpdateTargetStartSolutionVolume(item,headerSelectFields);
})
}
}
},
//
subPackageSubmit(data, configType, index) {
const { fzsj, rowData, headerSelectFields } = data;
@ -390,18 +444,19 @@ export default {
//
onHandleTableBlur(type, configIndex, e) {
const { colKey = "", item, rowIndex } = e;
const { colKey = "", item, rowIndex,headerSelectFields } = e;
if (colKey === "targetStartSolutionConcentration" || colKey === "targetSolutionVolume" || colKey === "targetSolutionConcentration" || colKey === "targetStartSolutionVolumePrecision" || colKey === "targetDiluentVolumePrecision") {
if (type === "ladder") {
const volume = this.$refs[`ladderStepFormPackageRef_${configIndex}`][0]?.getFormDataByKey("targetStartSolution") || 0;
if (volume) {
this.updateTargetStartSolutionVolume(item, volume);
const {targetStartSolution,subTargetStartSolution} = this.$refs[`ladderStepFormPackageRef_${configIndex}`][0]?.getFilledFormData();
const params = {
subTargetStartSolution,
headerSelectFields
}
} else if (type === "paralle") {
const volumne = item.targetStartSolutionConcentration || 0;
if (volumne) {
this.updateTargetStartSolutionVolume(item, volumne);
if (targetStartSolution) {
this.updateTargetStartSolutionVolume(item, targetStartSolution,params);
}
} else if (type === "paralle") {
this.paralleUpdateTargetStartSolutionVolume(item,headerSelectFields);
}
} else if (colKey === "actStartSolutionVolume" || colKey === "actDiluentVolume") {//
if (type === "ladder") {

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

@ -356,7 +356,7 @@ export const getParallelColumnsConfig = ($this) => {
{
label: 'template.sp.sp00456.yjxsytj',
prop: 'targetDiluentVolume',
headerSelectKey: 'preDiluentVolumeUnit',
headerSelectKey: 'targetDiluentVolumeUnit',
fillType: 'preFill',
headerOptions: $this.getDictOptions('business_tjdw'),
width: 280,

+ 48
- 15
src/views/business/comps/template/mixins/templateMixin.js View File

@ -3,6 +3,8 @@ import { getLatestSn, getLatestSnArr } from '@/api/template';
import { isValueEmpty } from '@/utils/index';
import { isCommonUnit } from "@/utils/conTools";
import { sj_subpackage, sj_startConfiguration, sj_configurationCompleted } from '@/api/business/sj/sj';
import {convertConcentration} from "@/utils/conConverter";//浓度单位转换
import {volumeConverter} from "@/utils/volConverter";//体积单位转换
export default {
dicts: [
'business_pztj',
@ -347,14 +349,15 @@ export default {
targetSolutionCode: `STD${Number(codeSTD) - index}`
}))
this.$refs.stepTableRef.updateDataSource(arr)
} else if (key === 'targetStartSolution') {
} else if (key === 'targetStartSolution' || key === 'subTargetStartSolution') {
//起始溶液体积失焦时,更新目标溶液预计浓度
const arr = this.$refs.stepTableRef?.getDataSource();
const {headerSelectFields} = this.$refs.stepTableRef?.getFilledFormData();
const params = {
startUnit:subTargetStartSolution,
subTargetStartSolution,
headerSelectFields
}
arr.forEach((item, rowIndex) => {
this.updateTargetStartSolutionVolume(
item,
@ -364,10 +367,19 @@ export default {
})
}
},
//批量更新目标起始源溶液体积
batchUpdateTargetStartSolutionVolume(arr, startConcentration, params) {
arr.forEach((item, rowIndex) => {
this.updateTargetStartSolutionVolume(
item,
startConcentration,
params
)
})
},
//统一处理table失焦事件
onHandleTableBlur(params) {
const { rowIndex, colKey, value, item, dataSource,headerSelectFields } = params
console.log(params, "params");
if (
colKey === 'targetSolutionVolume' ||
colKey === 'targetSolutionConcentration' ||
@ -383,7 +395,7 @@ export default {
'subTargetStartSolution'
)
const params = {
startUnit:subTargetStartSolution,
subTargetStartSolution:subTargetStartSolution,
headerSelectFields
}
if (isValueEmpty(volume)) {
@ -465,25 +477,46 @@ export default {
}
return this.calcNd(item, targetAcSolution)
},
//更新起始溶液体积时,计算目标溶液预计浓度
//更新起始溶液体积时,计算预设起始溶液体积和预设稀释液体积
updateTargetStartSolutionVolume(item, volume,unitParams) {
const {startUnit,headerSelectFields} = unitParams
const {targetSolutionConcentrationUnit,targetSolutionVolumeUnit,targetStartSolutionVolumeUnit,targetDiluentVolumeUnit} = headerSelectFields
const precision = item.targetStartSolutionVolumePrecision || 0
const concentration = item.targetSolutionConcentration || 0
const targetVolume = item.targetSolutionVolume || 0
const concentration = item.targetSolutionConcentration
const targetVolume = item.targetSolutionVolume
const {subTargetStartSolution,headerSelectFields} = unitParams
const {targetSolutionConcentrationUnit,targetSolutionVolumeUnit,targetStartSolutionVolumeUnit,targetDiluentVolumeUnit} = headerSelectFields
const targetStartVolUnit = targetSolutionConcentrationUnit.split("/")[1];//先按照预设目标溶液浓度的单位标准
//目标溶液预计浓度:(目标溶液预计体积 乘以 起始溶液浓度)除以 起始溶液体积
const result = Number(((concentration * targetVolume) / volume).toFixed(
if(
isValueEmpty(concentration) ||
isValueEmpty(targetVolume)||
isValueEmpty(subTargetStartSolution)||
isValueEmpty(targetSolutionConcentrationUnit)||
isValueEmpty(targetSolutionVolumeUnit)||
isValueEmpty(targetStartSolutionVolumeUnit)||
isValueEmpty(targetDiluentVolumeUnit)
){
return;
}
//将起始溶液浓度转换为和预设目标溶液浓度一样的单位再计算;
const converStartCon = convertConcentration.convert(volume+subTargetStartSolution,targetSolutionConcentrationUnit)
//将预设目标溶液体积转换为和预设目标溶液浓度单位的分母一样的单位再计算;如:预设目标溶液浓度单位为mg/mL,预设目标溶液体积单位为uL,则将预设目标溶液体积转换为mL
const convertTargetVol = volumeConverter.convert(targetVolume+targetSolutionVolumeUnit,targetStartVolUnit)
//预设起始溶液体积:(目标溶液预计浓度 乘以 目标溶液预计体积)除以 起始溶液浓度
const result = Number(((concentration * convertTargetVol) / converStartCon).toFixed(
precision
))
item.targetStartSolutionVolume = result
//根据预设起始溶液体积单位转换计算后的数据
const convertYsVol = volumeConverter.convert(result+targetStartVolUnit,targetStartSolutionVolumeUnit)
item.targetStartSolutionVolume = convertYsVol
// this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetStartSolutionVolume: result });
if (targetVolume) {
//预设稀释液体积:目标溶液预计体积 减去 源溶液预计体积;
const precision1 = item.targetDiluentVolumePrecision || 0
const result1 = (targetVolume - result).toFixed(precision1)
item.targetDiluentVolume = Number(result1)
const precision1 = item.targetDiluentVolumePrecision || 0;
//将预设目标溶液体积转换为和预设起始溶液体积单位一样的单位再计算;
const convertTargetVol1 = volumeConverter.convert(targetVolume+targetSolutionVolumeUnit,targetStartSolutionVolumeUnit)
const result1 = (convertTargetVol1 - convertYsVol).toFixed(precision1)
item.targetDiluentVolume = volumeConverter.convert(result1+targetStartSolutionVolumeUnit,targetDiluentVolumeUnit)
// this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetDiluentVolume: result1 });
}
}

Loading…
Cancel
Save