From 59f678a3d7d2c7ef11ed9ed36b8f064017281f78 Mon Sep 17 00:00:00 2001 From: memorylkf <312904636@qq.com> Date: Mon, 2 Feb 2026 22:18:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86]?= =?UTF-8?q?=20=E8=AF=95=E5=89=82=E7=BB=93=E7=AE=97=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BD=BF=E7=94=A8=E7=9A=84=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E8=A3=85=E7=9A=84=EF=BC=88=E5=88=86=E8=A3=85=E5=8D=A0?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=87=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/calUnitTools.js | 47 ++++++++++++++ .../template/comps/sp/SWYPFXFFXYPZBB/ZQDYJMD.vue | 74 +++++++++++++++++++++- 2 files changed, 118 insertions(+), 3 deletions(-) diff --git a/src/utils/calUnitTools.js b/src/utils/calUnitTools.js index 6de2ec5..faa340f 100644 --- a/src/utils/calUnitTools.js +++ b/src/utils/calUnitTools.js @@ -27,6 +27,32 @@ export function addTj(valueArr, unitArr) { } } +//体积不同单位相减 +export function subTj(valueArr, unitArr) { + let unit = ['pL', 'nL', 'uL', 'mL', 'L'] + + //计算最小单位 + let mixIndex = unit.length - 1 + for (let i = 0; i < unitArr.length; i++) { + let thisIndex = unit.indexOf(unitArr[i]) + mixIndex = thisIndex < mixIndex ? thisIndex : mixIndex + } + + let total = multiplyDecimals( + parseFloat(valueArr[0]), + Math.pow(1000, unit.indexOf(unitArr[0]) - mixIndex) + ) + + let sub = multiplyDecimals( + parseFloat(valueArr[1]), + Math.pow(1000, unit.indexOf(unitArr[1]) - mixIndex) + ) + return { + total: subDecimals(total, sub), + unit: unit[mixIndex] + } +} + export function addDecimals(a, b) { if (Number.isNaN(a)) { a = 0 @@ -48,6 +74,27 @@ export function addDecimals(a, b) { return result.replace(/(\.\d*?)0+$/, '$1').replace(/\.$/, '') } +export function subDecimals(a, b) { + if (Number.isNaN(a)) { + a = 0 + } + if (Number.isNaN(b)) { + b = 0 + } + const strA = a.toString() + const strB = b.toString() + + // 获取小数位数 + const getDecimals = (str) => (str.split('.')[1] || '').length + const maxLen = Math.max(getDecimals(strA), getDecimals(strB)) + + // 相加并格式化为字符串 + const result = (parseFloat(a) - parseFloat(b)).toFixed(maxLen) + + // 去掉末尾的0 + return result.replace(/(\.\d*?)0+$/, '$1').replace(/\.$/, '') +} + export function multiplyDecimals(a, b) { if (Number.isNaN(a) || Number.isNaN(b)) { return 0 diff --git a/src/views/business/comps/template/comps/sp/SWYPFXFFXYPZBB/ZQDYJMD.vue b/src/views/business/comps/template/comps/sp/SWYPFXFFXYPZBB/ZQDYJMD.vue index 10abc71..9cfbd5c 100644 --- a/src/views/business/comps/template/comps/sp/SWYPFXFFXYPZBB/ZQDYJMD.vue +++ b/src/views/business/comps/template/comps/sp/SWYPFXFFXYPZBB/ZQDYJMD.vue @@ -71,7 +71,7 @@ import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue" import SelectReagentDialog from '../../../dialog/SelectReagentDialog.vue'; import { EventBus } from "@/utils/eventBus"; import { sj_subpackage,sj_startConfiguration,sj_configurationCompleted } from '@/api/business/sj/sj'; -import { addTj,uniqeResource } from "@/utils/calUnitTools"; +import { addTj,uniqeResource,uniqeResourceOne,addDecimals } from "@/utils/calUnitTools"; export default { name: "ZQDYJMD", @@ -334,6 +334,70 @@ export default { //配置的试剂 let item = tableList[i] + //使用的 + tmpResource.push({ + mc: null, + bh: item.sjry, + ph: null, + ndz: null, + nd: null, + nddw: null, + ly: 'ELN配制', + sxrq: null, + kc: null, + kcdw: null, + syl: item.sjryxql, + type: null, + elnType: this.product, + syldw:content.headerSelectFields.sjryxqlUnit, + yxzq:null, + yxzqdw:null, + }) + tmpResource.push({ + mc: null, + bh: content.subJz, + ph: null, + ndz: null, + nd: null, + nddw: null, + ly: 'ELN配制', + sxrq: null, + kc: null, + kcdw: null, + syl: item.sjjzxql, + type: null, + elnType: this.product, + syldw:content.headerSelectFields.sjjzxqlUnit, + yxzq:null, + yxzqdw:null, + }) + //分装的 + let fzTotal = 0//分装总量 + if(item.fzsj && item.fzsj.fzList && item.fzsj.fzList.length>0){ + for(let j=0;j0?fzTotal:null, type: null, elnType: this.product, - syldw:unit, + syldw:fzTotal>0?item.fzsj.dw:unit, yxzq:null, yxzqdw:null, }) } } } + debugger + if(tmpResource.length>0){ + tmpResource = uniqeResourceOne(tmpResource) + } //使用的试剂、仪器 const stepResource = this.$refs.stepRef.getStepResource() this.resourceTmp =uniqeResource(tmpResource,stepResource.sjResource||[])