diff --git a/src/components/Template/BaseInfoFormPcakge.vue b/src/components/Template/BaseInfoFormPcakge.vue index 5ed37d8..0df2758 100644 --- a/src/components/Template/BaseInfoFormPcakge.vue +++ b/src/components/Template/BaseInfoFormPcakge.vue @@ -513,7 +513,8 @@ export default { onCopy(config, key) { const { formFields } = this; if (config.copyFrom) { - formFields[key] = formFields[config.copyFrom] + formFields[key] = formFields[config.copyFrom]; + this.onBlur(key, formFields[key]); } }, }, diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index 7f64c1c..0ac4625 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -178,6 +178,7 @@ export default { return } this.$set(this.localDataSource[rowIndex], col.prop, this.localDataSource[rowIndex][col.copyFrom]) + this.onBlur(rowIndex, col.prop, this.localDataSource[rowIndex][col.prop]); } }, // 初始化表头选择器值 diff --git a/src/components/Template/DecimalInput.vue b/src/components/Template/DecimalInput.vue index 20ed979..1023504 100644 --- a/src/components/Template/DecimalInput.vue +++ b/src/components/Template/DecimalInput.vue @@ -45,7 +45,7 @@ export default { if (newVal === '' || newVal == null) { this.internalValue = ''; } else { - this.internalValue = String(newVal); + this.internalValue = this.handleDecimalDigits(String(newVal)); } } }, @@ -115,13 +115,12 @@ export default { this.$emit('input', cleaned === '-' ? '-' : ''); } else { const num = parseFloat(cleaned); - console.log(num,isNaN(num),"num") this.$emit('input', isNaN(num) ? '' : num); } }, - - handleBlur() { - let finalValue = this.internalValue.trim(); + handleDecimalDigits(val) { + const actVal = val || this.internalValue; + let finalValue = actVal.trim(); if (finalValue === '' || finalValue === '-') { this.internalValue = ''; @@ -149,7 +148,11 @@ export default { const displayDecimalDigits = Math.min(actualDecimalDigits, this.decimalDigits); formatted = num.toFixed(displayDecimalDigits).replace(/\.?0*$/, ''); } - + return formatted; + }, + + handleBlur() { + let formatted = this.handleDecimalDigits(this.internalValue); this.internalValue = formatted; // emit 数字类型(也可 emit 字符串,根据需求) this.$emit('input', parseFloat(formatted)); diff --git a/src/components/Template/README.md b/src/components/Template/README.md new file mode 100644 index 0000000..f04b265 --- /dev/null +++ b/src/components/Template/README.md @@ -0,0 +1,61 @@ +## BaseInfoFormPackage组件config字段描述: +# demo: +``` + "formConfig":[ + { + type: "conditionItem" | "cardItem" |"cellItem"| "step",//ui层面的区分,具体可以参考色谱第一个模板 + config: { + storageCondition: {//当前表单的key值; + label: "存储条件",//当前表单的label值,有的表单可能没有; + type: "input"|"select"|"inputerNumber"|"textarea"|"dateTime"|"span"|"clickable",//当前表单的type值 + fillType: "preFill" |"actFill",//主要是边框的区分,preFill为预填(蓝色),actFill为实际填报(橙色); + options: this.getDictOptions("business_cctj"),//当前表单的type为select时,options为必填项,如:[{label:"",value:""}] + otherCode: "storageConditionOther",//当前表单可能会触发其他输入项,otherCode为其他输入项的key值; + span:2,//一行几列,默认2列,目前最多配置3列,如果有需要后续再调整; + maxlength:100,//当前表单的最大长度,默认50; + placeholder: "请输入存储条件",//当前表单的placeholder值,不填写时默认拼接请输入/请选择+label; + rows: 5,//当前表单的type为textarea时,默认5行; + disabled: true,//当前表单是否禁用,默认false; + multiple: true,//当前表单的type为select时,是否可以多选,默认false; + subType:“input”,//和type的类型是一样的,主要用于第二个表单的类型; + subKey:“subStorageCondition”,//第二个表单的key值 + subOptions:[],//第二个表单的type为select时,options为必填项,如:[{label:"",value:""}] + subFillType: "preFill" |"actFill",//第二个字段的边框区分,preFill为预填(蓝色),actFill为实际填报(橙色); + subPlaceholder: "请输入存储条件",//第二个表单的placeholder值,不填写时默认拼接请输入/请选择+label; + compareTo: "storageCondition",//需要比较的字段,字段不一样时背景标红; + copyFrom:"storageCondition",//需要复制的字段,复制后会自动填充到当前表单; + }, + + } + } + ] + ``` + + ## CommonTable组件config字段描述: +# demo: +``` +formConfig:[ + { + label: "存储条件",//当前表单的label值 + prop: "storageCondition",//当前表单的key值; + headerSelectKey: "storageCondition",//当前table表头的key值,目前只有下拉框, + fillType: "preFill" |"actFill",//当前表单header的边框区分,preFill为预填(蓝色),actFill为实际填报(橙色);后续看下有没有必要改成headerFillType + headerOptions: this.getDictOptions("business_cctj"),//当前表单表头的下拉选项; + bodyType: "input"|“inputNumber”|“select”|"span",//当前表单的type值参考上面的type; + bodySubType: "inputNumber",//当前表单的第二个type 目前只有inputNumber + bodySubKey: "storageConditionUnit",//当前表单的第二个key值 + bodyFillType: "preFill" |"actFill",//当前表单的第二个type的边框区分,preFill为预填(蓝色),actFill为实际填报(橙色); + bodySubFillType: "preFill" |"actFill",//当前表单的第二个type的边框区分,preFill为预填(蓝色),actFill为实际填报(橙色); + showBodySub: true,//是否显示第二个表单,默认false;有的表单在实际填报的时候不显示小数点位数的输入框; + bodyDisabled: true,//当前表单是否禁用,默认false; + bodyMaxlength: 10,//当前表单的最大长度,默认50; + bodySubPlaceholder: "请输入保留小数位数",//当前表单的第二个type的placeholder值,不填写时默认拼接请输入/请选择+label; + compareTo: "storageCondition",//需要比较的字段,字段不一样时背景标红; + copyFrom:"storageCondition",//需要复制的字段,复制后会自动填充到当前表单; + bodyPrecisionKey: "storageConditionPrecision",//当前表单小数点位数 + + } + +] + +``` \ No newline at end of file diff --git a/src/components/Template/SelectTable.vue b/src/components/Template/SelectTable.vue index c84b9d6..0d5ea80 100644 --- a/src/components/Template/SelectTable.vue +++ b/src/components/Template/SelectTable.vue @@ -84,7 +84,7 @@ export default { id: 1, name: '试剂1', code: 'R001', - vol: '100', + sjnd: '100', unit: 'mg/mL', expireDate: '2023-12-31', ss: '试验1', @@ -93,7 +93,7 @@ export default { id: 2, name: '试剂2', code: 'R002', - vol: '200', + sjnd: '200', unit: 'mg/mL', expireDate: '2024-06-30', ss: '试验2', @@ -102,7 +102,7 @@ export default { id: 3, name: '试剂2', code: 'R002', - vol: '200', + sjnd: '200', unit: 'mg/mL', expireDate: '2024-06-30', ss: '试验2', diff --git a/src/store/modules/template.js b/src/store/modules/template.js index f2ca50c..88d740a 100644 --- a/src/store/modules/template.js +++ b/src/store/modules/template.js @@ -37,10 +37,6 @@ const template = { SET_TEMPLATE_STATUS: (state, status) => { state.templateStatus = status }, - SET_CONDITION_OPTIONS: (state, options) => { - console.log(options,"setOptions") - state.conditionOptions = options - }, SET_TEMPLATE_DATA: (state, data) => { state.templateData = data }, @@ -49,9 +45,6 @@ const template = { setTemplateStatus({ commit }, status) { commit('SET_TEMPLATE_STATUS', status) }, - setConditionOptions({ commit }, status) { - commit('SET_CONDITION_OPTIONS', status) - }, setTemplateData({ commit }, data) { commit('SET_TEMPLATE_DATA', data) }, diff --git a/src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue b/src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue index 184d6ea..e3ac461 100644 --- a/src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue @@ -314,7 +314,6 @@ export default { headerSelectKey: "targetDiluentVolumeUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_tjdw'), - defaultValue: "mg", bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "targetDiluentVolumePrecision", @@ -357,7 +356,6 @@ export default { headerSelectKey: "actSolutionConcentrationUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_nddw'), - defaultValue: "mg", bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "actSolutionConcentrationPrecision", @@ -367,7 +365,6 @@ export default { bodyDisabled: true, bodyPrecisionKey: "actSolutionConcentrationPrecision", bodyMaxlength: 10, - copyFrom: "targetSolutionConcentration",//复制哪个字段 bodySubPlaceholder: "请输入保留小数位数", }, { @@ -388,7 +385,6 @@ export default { headerSelectKey: "actSolutionVolumeUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_tjdw'), - defaultValue: "mg", bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "actSolutionVolumePrecision", @@ -398,7 +394,6 @@ export default { bodyDisabled: true, bodyPrecisionKey: "actSolutionVolumePrecision", bodyMaxlength: 10, - copyFrom: "targetSolutionVolume",//复制哪个字段 bodySubPlaceholder: "请输入保留小数位数", }, ] @@ -434,10 +429,9 @@ export default { methods: { handleClickable(item) { if(this.fillType === "preFill"){ - // return; + return; } const {subKey = ""} = item; - console.log(subKey,"subKey") if(subKey === "subStartSolution" || subKey === "subSolution"){//起始源溶液点击事件 this.selectReagentVisible = true; this.currentSubKey = subKey; @@ -446,11 +440,10 @@ export default { //选择试剂提交事件 onSelectReagentSubmit(code,row){ if(this.currentSubKey === "subStartSolution"){//起始源溶液点击事件 - this.$refs.stepFormPackageRef.updateFormData("targetAcSolution", row.vol); + this.$refs.stepFormPackageRef.updateFormData("targetAcSolution", row.sjnd); this.updateStepTableData(row); } this.$refs.stepFormPackageRef.updateFormData(this.currentSubKey, code); - this.selectReagentVisible = false; }, //更新table数据 diff --git a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue index 4698be6..e4c9cf7 100644 --- a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue @@ -84,6 +84,7 @@ export default { } ] }, + baseInfoFormConfig() { return [ { diff --git a/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue b/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue index 88c774a..8f9d91f 100644 --- a/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue @@ -394,7 +394,7 @@ export default { headerSelectKey: "targetStartSolutionVolumeUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_tjdw'), - defaultValue: "mg", + bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "targetStartSolutionVolumePrecision", @@ -425,7 +425,6 @@ export default { headerSelectKey: "targetDiluentVolumeUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_tjdw'), - defaultValue: "mg", bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "targetDiluentVolumePrecision", @@ -467,7 +466,6 @@ export default { headerSelectKey: "actSolutionConcentrationUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_nddw'), - defaultValue: "mg", bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "actSolutionConcentrationPrecision", @@ -498,7 +496,6 @@ export default { headerSelectKey: "actSolutionVolumeUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_tjdw'), - defaultValue: "mg", bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "actSolutionVolumePrecision", @@ -540,7 +537,7 @@ export default { headerSelectKey: "targetStartSolutionVolumeUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_tjdw'), - defaultValue: "mg", + bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "targetStartSolutionVolumePrecision", @@ -571,7 +568,7 @@ export default { headerSelectKey: "targetDiluentVolumeUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_tjdw'), - defaultValue: "mg", + bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "targetDiluentVolumePrecision", @@ -613,7 +610,7 @@ export default { headerSelectKey: "actSolutionConcentrationUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_nddw'), - defaultValue: "mg", + bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "actSolutionConcentrationPrecision", @@ -644,7 +641,7 @@ export default { headerSelectKey: "actSolutionVolumeUnit", fillType: "preFill", headerOptions: this.getDictOptions('business_tjdw'), - defaultValue: "mg", + bodyType: "inputNumber", bodySubType: "inputNumber", bodySubKey: "actSolutionVolumePrecision", diff --git a/src/views/business/comps/template/dialog/SelectReagentDialog.vue b/src/views/business/comps/template/dialog/SelectReagentDialog.vue index 4f4f2d0..259fe41 100644 --- a/src/views/business/comps/template/dialog/SelectReagentDialog.vue +++ b/src/views/business/comps/template/dialog/SelectReagentDialog.vue @@ -65,7 +65,7 @@ export default { code: { label:"试剂编号", }, - vol: { + sssy: { label:"所属试验", }, } @@ -83,7 +83,7 @@ export default { label: '试剂编号', }, { - prop: 'vol', + prop: 'sjnd', label: '试剂浓度', }, { diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index 4262697..cf527c1 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -82,9 +82,6 @@ export default { setTemplateStatus(status) { this.$store.commit('template/SET_TEMPLATE_STATUS', status) }, - setConditionOptions(options) { - this.$store.commit('template/SET_CONDITION_OPTIONS', options) - }, setTemplateData(data) { this.$store.commit('template/SET_TEMPLATE_DATA', data) }, @@ -123,27 +120,50 @@ export default { //统一处理table失焦事件 onHandleTableBlur(params) { const { rowIndex, colKey, value, item } = params; - console.log(rowIndex, colKey, value, item, "params") if (colKey === "targetSolutionVolume" || colKey === "targetSolutionConcentration" || colKey === "targetStartSolutionVolumePrecision" || colKey === "targetDiluentVolumePrecision") { const volume = this.$refs.stepFormPackageRef?.getFormDataByKey("targetStartSolution") || 0; if (volume) { - this.updateTargetStartSolutionVolume(rowIndex, item, volume); + this.updateTargetStartSolutionVolume(item, volume); + } + }else if(colKey === "actStartSolutionVolume" || colKey === "actDiluentVolume"){//实际起始溶液体积和实际目标溶液体积 + const targetAcSolution = this.$refs.stepFormPackageRef?.getFormDataByKey("targetAcSolution") || 0;//获取实际起始溶液浓度 + console.log(targetAcSolution,"tart") + if(targetAcSolution){ + this.updateSjmbrynd(item,targetAcSolution); } } }, - //更新起始溶液体积时,更新目标溶液预计浓度 - updateTargetStartSolutionVolume(rowIndex, item, volume) { + //计算并更新实际目标溶液浓度 先计算实际目标溶液体积再计算实际目标溶液浓度 + updateSjmbrynd(item,targetAcSolution){ + //实际源溶液浓度÷(实际终体积÷源溶液加入体积); + const precision = item.actSolutionConcentrationPrecision || 0; + const volPrecision = item.actSolutionVolumePrecision || 0; + //实际稀释液体积 + const actDiluentVolume = item.actDiluentVolume || 0; + const actStartSolutionVolume = item.actStartSolutionVolume || 0; + //实际高源溶液加入体积+实际稀释液加入体积 + const actVol = (Number(actStartSolutionVolume)+Number(actDiluentVolume)).toFixed(volPrecision); + //实际目标溶液体积 + item.actSolutionVolume = actVol; + //实际目标溶液浓度 + const actNd = (targetAcSolution / actStartSolutionVolume / actVol).toFixed(precision); + item.actSolutionConcentration = actNd; + }, + //更新起始溶液体积时,计算目标溶液预计浓度 + updateTargetStartSolutionVolume(item, volume) { const precision = item.targetStartSolutionVolumePrecision || 0; const concentration = item.targetSolutionConcentration || 0; const targetVolume = item.targetSolutionVolume || 0; //目标溶液预计浓度:(目标溶液预计体积 乘以 起始溶液浓度)除以 起始溶液体积 const result = ((concentration * targetVolume) / volume).toFixed(precision); - this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetStartSolutionVolume: result }); + item.targetStartSolutionVolume = result; + // this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetStartSolutionVolume: result }); if (targetVolume) { //预设稀释液体积:目标溶液预计体积 减去 源溶液预计体积; const precision1 = item.targetDiluentVolumePrecision || 0; const result1 = (targetVolume - result).toFixed(precision1); - this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetDiluentVolume: result1 }); + item.targetDiluentVolume = result1; + // this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetDiluentVolume: result1 }); } }