Browse Source

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

lkf
luojie 2 months ago
parent
commit
c4f223f362
6 changed files with 84 additions and 26 deletions
  1. +10
    -1
      src/components/Template/BaseInfoFormPackage.vue
  2. +5
    -0
      src/components/Template/CustomTable.vue
  3. +31
    -0
      src/components/Template/HandleFormItem.vue
  4. +9
    -1
      src/views/business/comps/template/comps/sp/SP003.vue
  5. +1
    -1
      src/views/business/comps/template/comps/sp/SP00456.vue
  6. +28
    -23
      src/views/business/comps/template/mixins/templateMixin.js

+ 10
- 1
src/components/Template/BaseInfoFormPackage.vue View File

@ -86,10 +86,11 @@
:error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" />
</div>
<div v-else-if="sItem.type === 'input'">
<div v-else-if="sItem.type === 'input'" :class="sItem.subType === 'text'?'item-center':''">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+key" @blur="onBlur(key, $event)" :item="sItem" v-model="formFields[key]"
@copy="onCopy(sItem, key)" :error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" />
<span v-if="sItem.subType === 'text'" class="ml-5">{{ $t( sItem.text) }}</span>
</div>
<div v-else-if="sItem.type === 'textarea'">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+key" @blur="onBlur(key, $event)" type="textarea" :item="sItem"
@ -111,6 +112,7 @@
@onRegentSubmit="(data)=>onRegentSubmit(data,key,sItem)"
:item="sItem" :value="formFields[key]" />
</div>
</div>
</div>
@ -420,4 +422,11 @@ export default {
color: #606266;
font-size: 14px;
}
.item-center{
display: flex;
align-items: center;
}
.ml-5{
margin-left: 5px;
}
</style>

+ 5
- 0
src/components/Template/CustomTable.vue View File

@ -54,6 +54,7 @@
@change="onBodyValueChange(rowIndex, colIndex, $event)"
:error="hasError(rowIndex, colIndex, col.prop)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)"
@beforeSaveRecord = "(data,callback)=>beforeSaveRecord(data,callback,rowIndex, col,row)"
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" />
</template>
<template v-else-if="col.bodyType === 'inputNumber'">
@ -64,6 +65,7 @@
@blur="onBlur(rowIndex, col.prop, $event)"
@change="onBodyValueChange(rowIndex, colIndex, $event)"
:error="hasError(rowIndex, colIndex, col.prop)"
@beforeSaveRecord = "(data,callback)=>beforeSaveRecord(data,callback,rowIndex, col,row)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)"
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" />
</template>
@ -287,6 +289,9 @@ export default {
this.oldLocalDataSource = [];
},
methods: {
beforeSaveRecord(data,callback,rowIndex, col,row){
this.$emit("beforeSaveRecord", {inputData:data, callback,rowIndex, key:col.prop, rowData:row,dataSource:this.localDataSource})
},
getCellWidth(col){
const {templateFillType} = this;
let width = col.width ? col.width + 'px' : 'auto';

+ 31
- 0
src/components/Template/HandleFormItem.vue View File

@ -628,12 +628,43 @@ export default {
}
},
async onCommonHandleSaveRecord(val) {
const isEmpty = this.isValueEmpty(this.inputValue);
if (this.error && !isEmpty) {
this.$emit('update:error', false);
} else if (!this.error && isEmpty) {
this.$emit('update:error', true);
}
//
const validationController = {
isPrevented: false,
errorMsg: '',
prevent(msg) {
this.isPrevented = true;
if (msg) this.errorMsg = msg;
}
};
// beforeSaveRecord
this.$emit('beforeSaveRecord', {
value: this.inputValue,
oldValue: this.oldValue,
fieldKey: this.fieldKey
}, validationController);
//
if (validationController.isPrevented) {
//
if (validationController.errorMsg) {
this.$message.error(validationController.errorMsg);
}
// 退
this.inputValue = this.oldValue;
this.$emit('input', this.inputValue);
return;
}
if (!this.isFieldsRecord) {//
this.$emit("blur", this.inputValue);
this.$emit('input', this.inputValue);

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

@ -24,6 +24,7 @@
<CustomTable
@headerSelectChange="onHeaderSelectChange"
fieldItemLabel="template.common.operationSteps" @blur="onHandleTableBlur"
@beforeSaveRecord = "beforeSaveRecord"
:showAddRow="false" :showOperation="fillType === 'actFill'"
ref="stepTableRef" :columns="stepColumns" :formData="formData">
<template slot="operation" slot-scope="{ row, rowIndex, columns }">
@ -56,7 +57,7 @@ import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue";
import { EventBus } from "@/utils/eventBus";
import { addTj, uniqeResource, uniqeResourceOne, addDecimals } from "@/utils/calUnitTools";
import { isCommonUnit } from "@/utils/conTools";
import { convertConcentration } from "@/utils/conConverter";
import { isValueEmpty } from "@/utils/index";
export default {
name: "SP003",
components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion },
@ -220,6 +221,8 @@ export default {
disabled: true,
maxlength: 10,
compareTo: "targetStartSolution",
subKey: "subTargetAcSolutionUnit",
subType:"span"
},
solution: {
label: "template.sp.sp003.xsy",
@ -438,6 +441,10 @@ export default {
// const re = convertConcentration.convert('100mg/mL',"ng/mL")
},
methods: {
beforeSaveRecord(data){
const formFields = this.$refs.stepFormPackageRef?.getFilledFormData();
this.onCommonVerifyNdException(formFields,data);
},
onFormSelect(fields){
this.onHandleBlur(fields)
},
@ -465,6 +472,7 @@ export default {
const { row } = selectInfo;
if (key === "subStartSolution") {//table
this.$refs.stepFormPackageRef.updateFormData("targetAcSolution", row.nd);
this.$refs.stepFormPackageRef.updateFormData("subTargetAcSolutionUnit", row.nddw);
this.updateStepTableData(row);
}
},

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

@ -553,7 +553,7 @@ export default {
item.startSolutionCode = row.bh;
} else {
item.startSolutionCode = newData[index - 1].targetSolutionCode + newData[index - 1].subTargetSolutionCode;
initNd = newData[i - 1].actSolutionConcentration;
initNd = newData[index - 1].actSolutionConcentration;
}
const volResult = this.updateSjmbrynd(item, initNd);
if (!volResult) {

+ 28
- 23
src/views/business/comps/template/mixins/templateMixin.js View File

@ -332,6 +332,30 @@ export default {
this.$refs.stepTableRef.deleteRow(index)
},
//统一处理浓度校验异常
onCommonVerifyNdException(formFields,data){
const {callback,rowIndex, key,dataSource} = data;
const keys = [
'actStartSolutionVolume',
'actDiluentVolume',
]
if(keys.includes(key)){
const {targetAcSolution} = formFields;
if (rowIndex === 0) {//第一行的浓度取选择的溶液,
if (isValueEmpty(targetAcSolution)) {
callback.prevent("请先选择起始源溶液")
}
} else {
//非第一行的浓度取上一行的浓度
const prevItem = dataSource[rowIndex - 1]
const prevConcentration = prevItem.actSolutionConcentration;
if (!prevConcentration) {
callback.prevent("请先计算上一行的实际目标溶液浓度")
}
}
}
},
//统一处理blur事件,因为有效周期和过期日期是相关的,所以需要在有效周期失焦时更新过期日期
onHandleBlur(fields) {
const {
@ -410,13 +434,13 @@ export default {
colKey === 'actDiluentVolume'
) {
//实际起始溶液体积和实际目标溶液体积
const targetAcSolution =
this.$refs.stepFormPackageRef?.getFormDataByKey('targetAcSolution') //获取实际起始溶液浓度
const {targetAcSolution} =
this.$refs.stepFormPackageRef?.getFilledFormData() //获取实际起始溶液浓度
if (isValueEmpty(targetAcSolution)) {
this.$message.error('请先选择起始源溶液')
return
} else {
const volResult = this.updateSjmbrynd(item, targetAcSolution, rowIndex, dataSource, "ladder")
const volResult = this.updateSjmbrynd(item, targetAcSolution)
if (!volResult) {
return
}
@ -457,26 +481,7 @@ export default {
},
//计算并更新实际目标溶液浓度 先计算实际目标溶液体积再计算实际目标溶液浓度
updateSjmbrynd(item, targetAcSolution, rowIndex, dataSource, type) {
//如果是阶梯配置的就需要传rowIndex,dataSource,type字段
if (type === "ladder") {
if (rowIndex === 0) {//第一行的浓度取选择的溶液,
if (isValueEmpty(targetAcSolution)) {
this.$message.error('请先选择起始源溶液')
return
}
return this.calcNd(item, targetAcSolution)
} else {
//非第一行的浓度取上一行的浓度
const prevItem = dataSource[rowIndex - 1]
const prevConcentration = prevItem.actSolutionConcentration;
if (!prevConcentration) {
this.$message.error('请先计算上一行的实际目标溶液浓度')
return false
}
return this.updateSjmbrynd(item, prevConcentration);
}
}
updateSjmbrynd(item, targetAcSolution) {
return this.calcNd(item, targetAcSolution)
},
//更新起始溶液体积时,计算预设起始溶液体积和预设稀释液体积

Loading…
Cancel
Save