Browse Source

feat:[模板管理][失效日期计算]

lkf
luojie 3 months ago
parent
commit
9771cabe35
1 changed files with 33 additions and 31 deletions
  1. +33
    -31
      src/views/business/comps/template/mixins/templateMixin.js

+ 33
- 31
src/views/business/comps/template/mixins/templateMixin.js View File

@ -14,12 +14,19 @@ export default {
handler(v) { handler(v) {
if (v) { if (v) {
let n = { ...v }; let n = { ...v };
this.formData =n;
if(v.resource){//试验试剂信息
this.resource = JSON.parse(v.resource);
this.formData = n;
if (v.resource) {//试验试剂信息
this.resource = JSON.parse(v.resource);
} }
if (v.bdnr) { if (v.bdnr) {
this.formData = { ...n, ...JSON.parse(v.bdnr) };
this.formData = { ...JSON.parse(v.bdnr), ...n };
}
const { startDate, effectivePeriod, effectivePeriodUnit, expireDate } = this.formData;
//实际填报的时候,如果有了开始时间,并且有有效周期,但是没有失效日,就计算失效日为开始时间+有效周期
if (startDate && this.fillType === "actFill" && effectivePeriod && effectivePeriodUnit && !expireDate) {
const start = moment(startDate);
const end = start.add(Number(effectivePeriod), effectivePeriodUnit).format("YYYY-MM-DD HH:mm:ss");
this.formData = { ...this.formData, expireDate: end };
} }
console.log(v, "formData from templateData") console.log(v, "formData from templateData")
this.setTemplateData(n); this.setTemplateData(n);
@ -33,19 +40,19 @@ export default {
templateDetail: {}, templateDetail: {},
resource: [],//试验试剂信息 resource: [],//试验试剂信息
sysjColumns: [ sysjColumns: [
{ label: "试剂名称", prop: "reagentName" },
{ label: "编号", prop: "reagentCode" },
{ label: "批号", prop: "reagentNo" },
{ label: "浓度/含量/纯度", prop: "concentration" },
{ label: "来源", prop: "source" },
{ label: "失效日", prop: "expireDate" },
],
yqsColumns: [
{ label: "仪器名称", prop: "instrumentName" },
{ label: "仪器型号", prop: "instrumentModel" },
{ label: "仪器编号", prop: "instrumentCode" },
{ label: "下次测试/校准/检定日期", prop: "nextTestDate" },
]
{ label: "试剂名称", prop: "reagentName" },
{ label: "编号", prop: "reagentCode" },
{ label: "批号", prop: "reagentNo" },
{ label: "浓度/含量/纯度", prop: "concentration" },
{ label: "来源", prop: "source" },
{ label: "失效日", prop: "expireDate" },
],
yqsColumns: [
{ label: "仪器名称", prop: "instrumentName" },
{ label: "仪器型号", prop: "instrumentModel" },
{ label: "仪器编号", prop: "instrumentCode" },
{ label: "下次测试/校准/检定日期", prop: "nextTestDate" },
]
} }
}, },
mounted() { mounted() {
@ -58,11 +65,11 @@ export default {
return this.resource; return this.resource;
}, },
//根据ref数组获取直接formData //根据ref数组获取直接formData
getFilledFormDataByRefs(refArr = []){
getFilledFormDataByRefs(refArr = []) {
let result = {}; let result = {};
refArr.map(ref => { refArr.map(ref => {
const refData = this.$refs[ref]?.getFilledFormData() || {}; const refData = this.$refs[ref]?.getFilledFormData() || {};
result = { ...result, ...refData };
result = { ...result, ...refData };
}); });
return result; return result;
}, },
@ -98,7 +105,7 @@ export default {
getDictOptions(dictType) { getDictOptions(dictType) {
return this.dict.type[dictType] || []; return this.dict.type[dictType] || [];
}, },
setTemplateData(data) { setTemplateData(data) {
this.$store.commit('template/SET_TEMPLATE_DATA', data) this.$store.commit('template/SET_TEMPLATE_DATA', data)
}, },
@ -111,12 +118,7 @@ export default {
onHandleBlur(fields) { onHandleBlur(fields) {
const { key, effectivePeriodUnit, effectivePeriod, codeSTD, targetStartSolution } = fields; const { key, effectivePeriodUnit, effectivePeriod, codeSTD, targetStartSolution } = fields;
const { startDate } = this.formData; const { startDate } = this.formData;
if (key === "effectivePeriod") {//统一处理有效周期失焦,计算失效事件,保证字段名不能变
if(!startDate) return;
const start = moment(startDate);
const end = start.add(Number(effectivePeriod), effectivePeriodUnit).format("YYYY-MM-DD HH:mm:ss");
this.$refs.stepFormPackageRef.updateFormData("expireDate", end);
} else if (key === "codeSTD") {//起始编号STD失焦时,更新stepDataSource
if (key === "codeSTD") {//起始编号STD失焦时,更新stepDataSource
const arr = Array.from({ length: codeSTD }, (item, index) => ({ const arr = Array.from({ length: codeSTD }, (item, index) => ({
actSolutionVolumePrecision: 3,//小数点精度默认为3 actSolutionVolumePrecision: 3,//小数点精度默认为3
actSolutionConcentrationPrecision: 3,//小数点精度默认为3 actSolutionConcentrationPrecision: 3,//小数点精度默认为3
@ -140,16 +142,16 @@ export default {
if (volume) { if (volume) {
this.updateTargetStartSolutionVolume(item, volume); this.updateTargetStartSolutionVolume(item, volume);
} }
}else if(colKey === "actStartSolutionVolume" || colKey === "actDiluentVolume"){//实际起始溶液体积和实际目标溶液体积
} else if (colKey === "actStartSolutionVolume" || colKey === "actDiluentVolume") {//实际起始溶液体积和实际目标溶液体积
const targetAcSolution = this.$refs.stepFormPackageRef?.getFormDataByKey("targetAcSolution") || 0;//获取实际起始溶液浓度 const targetAcSolution = this.$refs.stepFormPackageRef?.getFormDataByKey("targetAcSolution") || 0;//获取实际起始溶液浓度
if(targetAcSolution){
this.updateSjmbrynd(item,targetAcSolution);
if (targetAcSolution) {
this.updateSjmbrynd(item, targetAcSolution);
} }
} }
}, },
//计算并更新实际目标溶液浓度 先计算实际目标溶液体积再计算实际目标溶液浓度 //计算并更新实际目标溶液浓度 先计算实际目标溶液体积再计算实际目标溶液浓度
updateSjmbrynd(item,targetAcSolution){
updateSjmbrynd(item, targetAcSolution) {
//实际源溶液浓度÷(实际终体积÷源溶液加入体积); //实际源溶液浓度÷(实际终体积÷源溶液加入体积);
const precision = item.actSolutionConcentrationPrecision || 0; const precision = item.actSolutionConcentrationPrecision || 0;
const volPrecision = item.actSolutionVolumePrecision || 0; const volPrecision = item.actSolutionVolumePrecision || 0;
@ -157,7 +159,7 @@ export default {
const actDiluentVolume = item.actDiluentVolume || 0; const actDiluentVolume = item.actDiluentVolume || 0;
const actStartSolutionVolume = item.actStartSolutionVolume || 0; const actStartSolutionVolume = item.actStartSolutionVolume || 0;
//实际高源溶液加入体积+实际稀释液加入体积 //实际高源溶液加入体积+实际稀释液加入体积
const actVol = (Number(actStartSolutionVolume)+Number(actDiluentVolume)).toFixed(volPrecision);
const actVol = (Number(actStartSolutionVolume) + Number(actDiluentVolume)).toFixed(volPrecision);
//实际目标溶液体积 //实际目标溶液体积
item.actSolutionVolume = actVol; item.actSolutionVolume = actVol;
//实际目标溶液浓度 //实际目标溶液浓度

Loading…
Cancel
Save