|
|
|
@ -1,11 +1,19 @@ |
|
|
|
import moment from "moment"; |
|
|
|
import moment from 'moment' |
|
|
|
export default { |
|
|
|
dicts: ['business_pztj', 'business_cctj', 'business_nddw', 'business_tjdw', 'business_yxqdw', 'business_rqcz', 'business_jmdyzqdyp'], |
|
|
|
dicts: [ |
|
|
|
'business_pztj', |
|
|
|
'business_cctj', |
|
|
|
'business_nddw', |
|
|
|
'business_tjdw', |
|
|
|
'business_yxqdw', |
|
|
|
'business_rqcz', |
|
|
|
'business_sp_jmdyzqdyp' |
|
|
|
], |
|
|
|
props: { |
|
|
|
templateData: { |
|
|
|
type: Object, |
|
|
|
default: () => { }, |
|
|
|
}, |
|
|
|
default: () => {} |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
templateData: { |
|
|
|
@ -14,23 +22,48 @@ export default { |
|
|
|
handler(v) { |
|
|
|
if (v) { |
|
|
|
const { |
|
|
|
studyMc,studySn,templateMc,templateMcEn,templateSn,startDate,endDate, |
|
|
|
} = v; |
|
|
|
if (v.resource) {//试验试剂信息
|
|
|
|
this.resource = JSON.parse(v.resource); |
|
|
|
studyMc, |
|
|
|
studySn, |
|
|
|
templateMc, |
|
|
|
templateMcEn, |
|
|
|
templateSn, |
|
|
|
startDate, |
|
|
|
endDate |
|
|
|
} = v |
|
|
|
if (v.resource) { |
|
|
|
//试验试剂信息
|
|
|
|
this.resource = JSON.parse(v.resource) |
|
|
|
} |
|
|
|
if (v.bdnr) { |
|
|
|
this.formData = { ...JSON.parse(v.bdnr), studyMc,studySn,templateMc,templateMcEn,templateSn,startDate,endDate, }; |
|
|
|
this.formData = { |
|
|
|
...JSON.parse(v.bdnr), |
|
|
|
studyMc, |
|
|
|
studySn, |
|
|
|
templateMc, |
|
|
|
templateMcEn, |
|
|
|
templateSn, |
|
|
|
startDate, |
|
|
|
endDate |
|
|
|
} |
|
|
|
} |
|
|
|
const { effectivePeriod, effectivePeriodUnit, expireDate } = this.formData; |
|
|
|
const { 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 }; |
|
|
|
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(this.formData, "formData from templateData") |
|
|
|
this.setTemplateData(v); |
|
|
|
console.log(this.formData, 'formData from templateData') |
|
|
|
this.setTemplateData(v) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -39,72 +72,71 @@ export default { |
|
|
|
return { |
|
|
|
formData: {}, |
|
|
|
templateDetail: {}, |
|
|
|
resource: [],//试验试剂信息
|
|
|
|
resource: [], //试验试剂信息
|
|
|
|
sysjColumns: [ |
|
|
|
{ label: "试剂名称", prop: "reagentName" }, |
|
|
|
{ label: "编号", prop: "reagentCode" }, |
|
|
|
{ label: "批号", prop: "reagentNo" }, |
|
|
|
{ label: "浓度/含量/纯度", prop: "concentration" }, |
|
|
|
{ label: "来源", prop: "source" }, |
|
|
|
{ label: "失效日", prop: "expireDate" }, |
|
|
|
{ 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: 'instrumentName' }, |
|
|
|
{ label: '仪器型号', prop: 'instrumentModel' }, |
|
|
|
{ label: '仪器编号', prop: 'instrumentCode' }, |
|
|
|
{ label: '下次测试/校准/检定日期', prop: 'nextTestDate' } |
|
|
|
] |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
}, |
|
|
|
mounted() {}, |
|
|
|
unmounted() { |
|
|
|
this.setTemplateData({}); |
|
|
|
this.setTemplateData({}) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getResource() { |
|
|
|
return this.resource; |
|
|
|
return this.resource |
|
|
|
}, |
|
|
|
//根据ref数组获取直接formData
|
|
|
|
getFilledFormDataByRefs(refArr = []) { |
|
|
|
let result = {}; |
|
|
|
refArr.map(ref => { |
|
|
|
const refData = this.$refs[ref]?.getFilledFormData() || {}; |
|
|
|
result = { ...result, ...refData }; |
|
|
|
}); |
|
|
|
return result; |
|
|
|
let result = {} |
|
|
|
refArr.map((ref) => { |
|
|
|
const refData = this.$refs[ref]?.getFilledFormData() || {} |
|
|
|
result = { ...result, ...refData } |
|
|
|
}) |
|
|
|
return result |
|
|
|
}, |
|
|
|
//统一校验form表单是否填写
|
|
|
|
async validFormFields(refArr = []) { |
|
|
|
let result = {}; |
|
|
|
const refs = refArr.map(ref => { |
|
|
|
let refData = {}; |
|
|
|
let result = {} |
|
|
|
const refs = refArr.map((ref) => { |
|
|
|
let refData = {} |
|
|
|
if (this.$refs[ref][0]) { |
|
|
|
refData = this.$refs[ref][0]?.getFormData() || {}; |
|
|
|
refData = this.$refs[ref][0]?.getFormData() || {} |
|
|
|
} else { |
|
|
|
refData = this.$refs[ref]?.getFormData() || {}; |
|
|
|
refData = this.$refs[ref]?.getFormData() || {} |
|
|
|
} |
|
|
|
return refData; |
|
|
|
}); |
|
|
|
const validFormData = await Promise.all(refs).catch(err => { |
|
|
|
return refData |
|
|
|
}) |
|
|
|
const validFormData = await Promise.all(refs).catch((err) => { |
|
|
|
// this.$message.error(err);
|
|
|
|
if (err.errorType && err.errorType === "step") { |
|
|
|
this.$message.error("请添加步骤"); |
|
|
|
if (err.errorType && err.errorType === 'step') { |
|
|
|
this.$message.error('请添加步骤') |
|
|
|
return |
|
|
|
} |
|
|
|
this.$message.error("表单内容未填完,请填写后再提交"); |
|
|
|
}); |
|
|
|
this.$message.error('表单内容未填完,请填写后再提交') |
|
|
|
}) |
|
|
|
if (validFormData) { |
|
|
|
validFormData.forEach(item => { |
|
|
|
validFormData.forEach((item) => { |
|
|
|
result = { ...result, ...item } |
|
|
|
}) |
|
|
|
return result; |
|
|
|
return result |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false |
|
|
|
}, |
|
|
|
//试验配制条件options
|
|
|
|
getDictOptions(dictType) { |
|
|
|
return this.dict.type[dictType] || []; |
|
|
|
return this.dict.type[dictType] || [] |
|
|
|
}, |
|
|
|
|
|
|
|
setTemplateData(data) { |
|
|
|
@ -112,41 +144,67 @@ export default { |
|
|
|
}, |
|
|
|
//统一处理删除行
|
|
|
|
deleteRow(index) { |
|
|
|
this.$refs.stepTableRef.deleteRow(index); |
|
|
|
this.$refs.stepTableRef.deleteRow(index) |
|
|
|
}, |
|
|
|
|
|
|
|
//统一处理blur事件,因为有效周期和过期日期是相关的,所以需要在有效周期失焦时更新过期日期
|
|
|
|
onHandleBlur(fields) { |
|
|
|
const { key, effectivePeriodUnit, effectivePeriod, codeSTD, targetStartSolution } = fields; |
|
|
|
const { startDate } = this.formData; |
|
|
|
if (key === "codeSTD") {//起始编号STD失焦时,更新stepDataSource
|
|
|
|
const { |
|
|
|
key, |
|
|
|
effectivePeriodUnit, |
|
|
|
effectivePeriod, |
|
|
|
codeSTD, |
|
|
|
targetStartSolution |
|
|
|
} = fields |
|
|
|
const { startDate } = this.formData |
|
|
|
if (key === 'codeSTD') { |
|
|
|
//起始编号STD失焦时,更新stepDataSource
|
|
|
|
const arr = Array.from({ length: codeSTD }, (item, index) => ({ |
|
|
|
actSolutionVolumePrecision: 3,//小数点精度默认为3
|
|
|
|
actSolutionConcentrationPrecision: 3,//小数点精度默认为3
|
|
|
|
targetDiluentVolumePrecision: 3,//小数点精度默认为3
|
|
|
|
targetStartSolutionVolumePrecision: 3,//小数点精度默认为3
|
|
|
|
actSolutionVolumePrecision: 3, //小数点精度默认为3
|
|
|
|
actSolutionConcentrationPrecision: 3, //小数点精度默认为3
|
|
|
|
targetDiluentVolumePrecision: 3, //小数点精度默认为3
|
|
|
|
targetStartSolutionVolumePrecision: 3, //小数点精度默认为3
|
|
|
|
targetSolutionCode: `STD${Number(codeSTD) - index}` |
|
|
|
})); |
|
|
|
this.$refs.stepTableRef.updateDataSource(arr); |
|
|
|
} else if (key === "targetStartSolution") {//起始溶液体积失焦时,更新目标溶液预计浓度
|
|
|
|
const arr = this.$refs.stepTableRef?.getDataSource(); |
|
|
|
})) |
|
|
|
this.$refs.stepTableRef.updateDataSource(arr) |
|
|
|
} else if (key === 'targetStartSolution') { |
|
|
|
//起始溶液体积失焦时,更新目标溶液预计浓度
|
|
|
|
const arr = this.$refs.stepTableRef?.getDataSource() |
|
|
|
arr.forEach((item, rowIndex) => { |
|
|
|
this.updateTargetStartSolutionVolume(rowIndex, item, targetStartSolution); |
|
|
|
this.updateTargetStartSolutionVolume( |
|
|
|
rowIndex, |
|
|
|
item, |
|
|
|
targetStartSolution |
|
|
|
) |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
//统一处理table失焦事件
|
|
|
|
onHandleTableBlur(params) { |
|
|
|
const { rowIndex, colKey, value, item } = params; |
|
|
|
if (colKey === "targetSolutionVolume" || colKey === "targetSolutionConcentration" || colKey === "targetStartSolutionVolumePrecision" || colKey === "targetDiluentVolumePrecision") { |
|
|
|
const volume = this.$refs.stepFormPackageRef?.getFormDataByKey("targetStartSolution") || 0; |
|
|
|
const { 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(item, volume); |
|
|
|
this.updateTargetStartSolutionVolume(item, volume) |
|
|
|
} |
|
|
|
} else if (colKey === "actStartSolutionVolume" || colKey === "actDiluentVolume") {//实际起始溶液体积和实际目标溶液体积
|
|
|
|
const targetAcSolution = this.$refs.stepFormPackageRef?.getFormDataByKey("targetAcSolution") || 0;//获取实际起始溶液浓度
|
|
|
|
} else if ( |
|
|
|
colKey === 'actStartSolutionVolume' || |
|
|
|
colKey === 'actDiluentVolume' |
|
|
|
) { |
|
|
|
//实际起始溶液体积和实际目标溶液体积
|
|
|
|
const targetAcSolution = |
|
|
|
this.$refs.stepFormPackageRef?.getFormDataByKey('targetAcSolution') || |
|
|
|
0 //获取实际起始溶液浓度
|
|
|
|
if (targetAcSolution) { |
|
|
|
this.updateSjmbrynd(item, targetAcSolution); |
|
|
|
this.updateSjmbrynd(item, targetAcSolution) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -154,37 +212,43 @@ export default { |
|
|
|
//计算并更新实际目标溶液浓度 先计算实际目标溶液体积再计算实际目标溶液浓度
|
|
|
|
updateSjmbrynd(item, targetAcSolution) { |
|
|
|
//实际源溶液浓度÷(实际终体积÷源溶液加入体积);
|
|
|
|
const precision = item.actSolutionConcentrationPrecision || 0; |
|
|
|
const volPrecision = item.actSolutionVolumePrecision || 0; |
|
|
|
const precision = item.actSolutionConcentrationPrecision || 0 |
|
|
|
const volPrecision = item.actSolutionVolumePrecision || 0 |
|
|
|
//实际稀释液体积
|
|
|
|
const actDiluentVolume = item.actDiluentVolume || 0; |
|
|
|
const actStartSolutionVolume = item.actStartSolutionVolume || 0; |
|
|
|
const actDiluentVolume = item.actDiluentVolume || 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 |
|
|
|
//实际目标溶液浓度
|
|
|
|
const actNd = (targetAcSolution / actStartSolutionVolume / actVol).toFixed(precision); |
|
|
|
item.actSolutionConcentration = actNd; |
|
|
|
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 precision = item.targetStartSolutionVolumePrecision || 0 |
|
|
|
const concentration = item.targetSolutionConcentration || 0 |
|
|
|
const targetVolume = item.targetSolutionVolume || 0 |
|
|
|
//目标溶液预计浓度:(目标溶液预计体积 乘以 起始溶液浓度)除以 起始溶液体积
|
|
|
|
const result = ((concentration * targetVolume) / volume).toFixed(precision); |
|
|
|
item.targetStartSolutionVolume = result; |
|
|
|
const result = ((concentration * targetVolume) / volume).toFixed( |
|
|
|
precision |
|
|
|
) |
|
|
|
item.targetStartSolutionVolume = result |
|
|
|
// this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetStartSolutionVolume: result });
|
|
|
|
if (targetVolume) { |
|
|
|
//预设稀释液体积:目标溶液预计体积 减去 源溶液预计体积;
|
|
|
|
const precision1 = item.targetDiluentVolumePrecision || 0; |
|
|
|
const result1 = (targetVolume - result).toFixed(precision1); |
|
|
|
item.targetDiluentVolume = result1; |
|
|
|
const precision1 = item.targetDiluentVolumePrecision || 0 |
|
|
|
const result1 = (targetVolume - result).toFixed(precision1) |
|
|
|
item.targetDiluentVolume = result1 |
|
|
|
// this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetDiluentVolume: result1 });
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
} |