Browse Source

feat:[模板管理][update]

lkf
luojie 2 months ago
parent
commit
5fb3e0f118
9 changed files with 1245 additions and 1145 deletions
  1. +765
    -743
      src/components/Template/CustomTable.vue
  2. +0
    -2
      src/components/Template/DecimalInput.vue
  3. +7
    -7
      src/components/Template/HandleFormItem.vue
  4. +2
    -1
      src/components/Template/mixins/formPackageMixins.js
  5. +7
    -6
      src/components/Template/operation/TableOpertaion.vue
  6. +9
    -4
      src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue
  7. +74
    -12
      src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue
  8. +12
    -6
      src/views/business/comps/template/dialog/SubPackageDialog.vue
  9. +369
    -364
      src/views/business/comps/template/mixins/templateMixin.js

+ 765
- 743
src/components/Template/CustomTable.vue
File diff suppressed because it is too large
View File


+ 0
- 2
src/components/Template/DecimalInput.vue View File

@ -41,7 +41,6 @@ export default {
watch: {
value(newVal) {
//
console.log(newVal,"newVal")
if (newVal === '' || newVal == null) {
this.internalValue = '';
} else {
@ -51,7 +50,6 @@ export default {
},
methods: {
handleInput(val) {
console.log(val,"val")
if (val === '') {
this.internalValue = '';
this.$emit('input', '');

+ 7
- 7
src/components/Template/HandleFormItem.vue View File

@ -325,7 +325,6 @@ export default {
//
onSelectBlur(visible) {
if (!visible) {
console.log(this.inputValue, "onSelectBlur")
this.onCommonHandleSaveRecord(this.inputValue);
}
},
@ -382,18 +381,19 @@ export default {
} else if (!this.error && isEmpty) {
this.$emit('update:error', true);
}
if(!this.isFieldsRecord){//
this.$emit("blur", this.inputValue);
this.$emit('input', this.inputValue);
this.$emit("change", this.inputValue);
return;
}
//
const isSame = this.isEqual(this.oldValue, this.inputValue);
if(isSame){
return;
}
if (this.oldValue && !isSame && this.templateFillType === "actFill") {
if(!this.isFieldsRecord){//
this.$emit("blur", this.inputValue);
this.$emit('input', this.inputValue);
this.$emit("change", this.inputValue);
return;
}
this.$refs.editSignRef.show()
// this.handleUpdateRecord();
}else{//

+ 2
- 1
src/components/Template/mixins/formPackageMixins.js View File

@ -343,7 +343,8 @@ export default {
}
},
resetRecord(key){
this.formFields = {...this.formFields, ...this.oldFormFields}
this.formFields = {...this.formFields, ...this.oldFormFields};
this.$emit("resetRecord");
},
}
}

+ 7
- 6
src/components/Template/operation/TableOpertaion.vue View File

@ -19,6 +19,7 @@
<script>
import { EventBus } from "@/utils/eventBus";
import { addTj } from "@/utils/calUnitTools";
import {getuuid} from "@/utils/index"
export default {
name: "TableOpertaion",
@ -64,12 +65,10 @@ export default {
data() {
return {
innerRow: this.row,
uuid:getuuid(),
}
},
mounted() {
console.log("mounted")
},
methods: {
//
onStartConfig() {
@ -117,10 +116,12 @@ export default {
if (innerRow.fzsj) {
defaultData = {...innerRow.fzsj,...defaultData}
}
EventBus.$emit("showSubPackageDialog", defaultData)
EventBus.$emit("showSubPackageDialog", {...defaultData,uuid:this.uuid})
},
onSubPackageSubmit(data) {
if (data.rowIndex === this.rowIndex) {
console.log(data,"submit")
if (data.uuid === this.uuid) {
console.log(data,"inner submit")
this.innerRow.fzsj = data;
//
const params = {

+ 9
- 4
src/views/business/comps/template/comps/sp/SWYPBQGZYZBB.vue View File

@ -15,6 +15,7 @@
<LineLabel label="操作步骤" />
<div class="template-form-item">
<BaseInfoFormPackage @clickable="handleClickable" ref="stepFormPackageRef"
@resetRecord="resetRecord"
:formConfig="stepFormConfig" @blur="onHandleBlur" :formData="formData" />
<CustomTable fieldItemLabel="操作步骤" @blur="onHandleTableBlur" :showAddRow="false"
:showOperation="fillType === 'actFill'" ref="stepTableRef" :columns="stepColumns"
@ -416,6 +417,9 @@ export default {
mounted() {
},
methods: {
resetRecord(){
this.$refs.stepTableRef.resetRecord();
},
startConfig(val){
const { rowData } = val;
let postData = {
@ -507,10 +511,10 @@ export default {
//
onSelectReagentSubmit(code, row) {
if (this.currentSubKey === "subStartSolution") {//
this.$refs.stepFormPackageRef.updateFormData("targetAcSolution", row.nd);
this.$refs.stepFormPackageRef.updateFormData("targetAcSolution", row.nd,["targetAcSolution"]);
this.updateStepTableData(row);
}
this.$refs.stepFormPackageRef.updateFormData(this.currentSubKey, code);
this.$refs.stepFormPackageRef.updateFormData(this.currentSubKey, code,[this.currentSubKey]);
this.$refs.selectReagentDialogRef.onCancel()
},
//table
@ -523,7 +527,6 @@ export default {
//
for (let i = 0; i < newStepTableData.length; i++) {
const item = newStepTableData[i];
const volume = item.actStartSolutionVolume || 0;
if (i === 0) {
// row.code
newStepTableData[i].startSolutionCode = row.bh;
@ -532,7 +535,9 @@ export default {
// targetSolutionCode
newStepTableData[i].startSolutionCode = newStepTableData[i - 1].targetSolutionCode;
}
this.updateSjmbrynd(item, row.nd)
const {actVol,actNd} = this.updateSjmbrynd(item, row.nd);
item.actSolutionVolume = actVol;
item.actSolutionConcentration = actNd;
}
// stepTableRef

+ 74
- 12
src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue View File

@ -28,6 +28,7 @@
@click="deleteLadderConfig(ladderIndex)">删除</el-button>
</div>
<BaseInfoFormPackage @clickable="(e) => handleClickable('ladder', ladderIndex, e)"
@resetRecord="(e) => resetRecord('ladder', ladderIndex, e)"
:ref="`ladderStepFormPackageRef_${ladderIndex}`" :formConfig="ladderStepFormConfig"
@blur="onHandleBlur" :formData="ladderConfig" fieldItemLabel="阶梯配制"
:prefixKey="'ladder_' + ladderIndex" />
@ -67,6 +68,7 @@
fieldItemLabel="平行配制" />
<CustomTable @blur="(e) => onHandleTableBlur('paralle', paralleIndex, e)"
:ref="`paralleStepTableRef_${paralleIndex}`" :columns="paralleStepColumns"
@clickable="(e, tableRowIndex, rowData) => handleTableClickable('paralle', paralleIndex, e, tableRowIndex, rowData)"
:formData="paralleConfig" :prefixKey="'paralle' + paralleIndex" fieldItemLabel="平行配制">
<template slot="operation" slot-scope="{ row, rowIndex, columns }">
<TableOpertaion @printTag="(e) => printTag(e, 'paralleConfigs', paralleIndex)"
@ -107,6 +109,7 @@ import SelectReagentDialog from '../../dialog/SelectReagentDialog.vue';
import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue";
import { getExpireDate } from "@/utils/index.js";
import moment from "moment";
import { addTj } from "@/utils/calUnitTools";
import { getLadderColumnsConfig, getParallelColumnsConfig, getLadderFormConfig, getBaseInfoFormConfig, getRemarkFormConfig, getStorageConditionFormConfig, getParalleStepFormConfig } from "../../formConfig/paralleAndLadderConfig.js";
export default {
name: "SWYPBQGZYZBB",
@ -176,17 +179,44 @@ export default {
currentTableIndex: "",//
currentTableKey: "",//key
targetAcSolutionFromTable: true,//
currentRowData: {},//
};
},
mounted() {
},
methods: {
subPackageSubmit(val, configType, index) {
// const { rowData } = val;
// let postData = {
// bh: rowData.targetSolutionCode + rowData.subTargetSolutionCode,
// }
// this.startConfigRequest(postData);
resetRecord(type, index, e) {
this.$refs[`ladderStepTableRef_${index}`][0].resetRecord();
},
//
subPackageSubmit(data, configType, index) {
const { fzsj, rowData, headerSelectFields } = data;
const { fzList = [], dw = "", mybh } = fzsj;
if (fzList && fzList.length > 0) {
const list = fzList.map((item) => {
return {
bh: mybh + item.subCode,
kc: item.num,
kcdw: dw,
}
})
let postData = {
studyId: this.formData.studyId,
studyFormId: this.formData.id,
bh: mybh,
nd: rowData.actSolutionConcentration || 0,
nddw: headerSelectFields.actSolutionConcentrationUnit,
list: list
}
this.subPackageRequest(postData);
}
},
startConfig(val) {
const { rowData } = val;
let postData = {
bh: rowData.targetSolutionCode + rowData.subTargetSolutionCode,
}
this.startConfigRequest(postData);
},
configComplete(val) {
const { rowData, headerSelectFields } = val;
@ -277,7 +307,6 @@ export default {
async handleUpdateCode() {
Promise.all([this.assignNumbersToTableData("ladderConfigs"), this.assignNumbersToTableData("paralleConfigs")
]).then(() => {
console.log("nextTick")
//
const params = {
type: "fieldChanged",
@ -349,7 +378,7 @@ export default {
//
onHandleTableBlur(type, configIndex, e) {
const { colKey = "", item } = e;
const { colKey = "", item,rowIndex } = e;
if (colKey === "targetStartSolutionConcentration" || colKey === "targetSolutionVolume" || colKey === "targetSolutionConcentration" || colKey === "targetStartSolutionVolumePrecision" || colKey === "targetDiluentVolumePrecision") {
if (type === "ladder") {
const volume = this.$refs[`ladderStepFormPackageRef_${configIndex}`][0]?.getFormDataByKey("targetStartSolution") || 0;
@ -366,24 +395,30 @@ export default {
if (type === "ladder") {
const targetAcSolution = this.$refs[`ladderStepFormPackageRef_${configIndex}`][0]?.getFormDataByKey("targetAcSolution") || 0;//
if (targetAcSolution) {
this.updateSjmbrynd(item, targetAcSolution);
const {actVol, actNd} = this.updateSjmbrynd(item, targetAcSolution);
this.$refs[`ladderStepTableRef_${configIndex}`][0]?.updateDataSourceByRowIndex(rowIndex,{actSolutionVolume: actVol,
actSolutionConcentration: actNd,});
}
} else if (type === "paralle") {
const targetAcSolution = item.targetAcSolution || 0;//
if (targetAcSolution) {
this.updateSjmbrynd(item, targetAcSolution);
const {actVol, actNd} = this.updateSjmbrynd(item, targetAcSolution);
this.$refs[`paralleStepTableRef_${configIndex}`][0]?.updateDataSourceByRowIndex(rowIndex,{actSolutionVolume: actVol,
targetAcSolution: actNd,});
}
}
}
},
//
handleTableClickable(type, rowIndex, col, tableRowIndex) {
handleTableClickable(type, rowIndex, col, tableRowIndex, rowData) {
if (col.prop === "actStartSolutionCode") {//
this.currentTableKey = col.prop;
this.currentType = type;
this.currentRowIndex = rowIndex;
this.currentTableIndex = tableRowIndex;
this.currentRowData = rowData;
this.$refs.selectReagentDialogRef.show();
}
},
@ -410,20 +445,47 @@ export default {
if (currentSubKey === "subStartSolution") {
packageRef.updateFormData("targetAcSolution", row.nd, ["targetAcSolution"]);
packageRef.onValueChangeCompareTo("targetAcSolution", row.nd, "targetStartSolution");
this.updateTableNd(row);
}
packageRef.updateFormData(currentSubKey, code);
packageRef.updateFormData(currentSubKey, code, [currentSubKey]);
this.currentSubKey = "";
} else if (currentTableKey === "actStartSolutionCode") {//
const tableRef = this.$refs[`paralleStepTableRef_${currentRowIndex}`][0];
if (tableRef) {
const { actVol, actNd } = this.updateSjmbrynd(this.currentRowData, row.nd);
tableRef.updateDataSourceByRowIndex(currentTableIndex, {
actStartSolutionCode: code,
targetAcSolution: row.nd,
actSolutionVolume: actVol,
targetAcSolution: actNd,
})
}
}
this.$refs.selectReagentDialogRef.onCancel()
this.$refs.selectReagentDialogRef.onCancel();
},
updateRecord() {
this.$nextTick(() => {
EventBus.$emit('onModifyRecord', {
type: "fieldChanged",
newRecord: null,
resourceList: null,
},)
})
},
//table
updateTableNd(row) {
const { stepTableFormData = [] } = this.$refs[`ladderStepTableRef_${this.currentRowIndex}`][0].getFilledFormData();
const newData = JSON.parse(JSON.stringify(stepTableFormData));
//
newData.forEach((item, index) => {
const { actVol, actNd } = this.updateSjmbrynd(item, row.nd);
item.actSolutionVolume = actVol;
item.actSolutionConcentration = actNd;
})
// stepTableRef
this.$refs[`ladderStepTableRef_${this.currentRowIndex}`][0].updateDataSource(newData);
// this.updateRecord();
},
//
async validFields() {

+ 12
- 6
src/views/business/comps/template/dialog/SubPackageDialog.vue View File

@ -10,7 +10,8 @@
<div class="header-item">
<div class="header-title">分装数量</div>
<HandleFormItem :isFieldsRecord="false" @blur="onBlurFzsl" :item="integerInputNumberItem"
:error="formErrors.fzsl" v-model="formData.fzsl" />
type = "inputNumber"
:error="formErrors.fzsl" v-model="formData.fzsl" />
</div>
</div>
<div class="content-container">
@ -23,7 +24,7 @@
</div>
<span class="ml-20">每份包装量</span>
<div class="unit-select">
<HandleFormItem :isFieldsRecord="false" :item="inputNumberItem" v-model="formData.mfbzl" />
<HandleFormItem type="inputNumber" :isFieldsRecord="false" :item="inputNumberItem" v-model="formData.mfbzl" />
</div>
<el-button type="primary" plain @click="onAverage">平均分配</el-button>
<el-button type="primary" plain @click="onReset">重置</el-button>
@ -32,7 +33,7 @@
<div v-for="(item, index) in fzList" class="list-item" :key="index">
<div class="list-label">{{ formData.mybh }}-set{{ item.subCode }}</div>
<HandleFormItem :isFieldsRecord="false" :item="inputNumberItem" :error="fzListErrors[index]"
@blur="onBlurFzNum(index)" v-model="item.num" />
type="inputNumber" @blur="onBlurFzNum(index)" v-model="item.num" />
<el-button type="primary" plain @click="onPrint(item)">打印</el-button>
</div>
</div>
@ -88,7 +89,8 @@ export default {
fzsl: false,
dw: false,
},
fzListErrors: [] //
fzListErrors: [], //
uuid:"",//id
}
},
computed: {
@ -109,6 +111,9 @@ export default {
},
show(data) {
const cloneData = JSON.parse(JSON.stringify(data));
if(data && data.uuid) {//eventBusid
this.uuid = data.uuid
}
if (data.fzList) {
this.fzList = JSON.parse(JSON.stringify(cloneData.fzList));
//
@ -151,7 +156,7 @@ export default {
},
submitEmit(){
EventBus.$emit('dialogSubPackageSubmit', {...this.formData, fzList: this.fzList});
EventBus.$emit('dialogSubPackageSubmit', {...this.formData, fzList: this.fzList,uuid:this.uuid});
setTimeout(() => {
this.close();
}, 500);
@ -207,6 +212,7 @@ export default {
},
//
async onBlurFzsl(e) {
console.log(e,"失去焦点时的数量")
//
if (e) {
this.formErrors.fzsl = false;
@ -256,7 +262,7 @@ export default {
this.formErrors.mfbzl = false;
},
onPrint(item) {
EventBus.$emit('subPackageDialogPrintTag', {...this.formData, printCode: `${this.formData.mybh}-set${item.subCode}`});
EventBus.$emit('subPackageDialogPrintTag', {...this.formData, printCode: `${this.formData.mybh}-set${item.subCode}`,uuid:this.uuid});
},
onCommonBlur(e, field) {
if (this.formData[field]) {

+ 369
- 364
src/views/business/comps/template/mixins/templateMixin.js View File

@ -1,372 +1,377 @@
import moment from 'moment'
import { getLatestSn } from '@/api/template';
import { sj_subpackage,sj_startConfiguration,sj_configurationCompleted } from '@/api/business/sj/sj';
import { sj_subpackage, sj_startConfiguration, sj_configurationCompleted } from '@/api/business/sj/sj';
export default {
dicts: [
'business_pztj',
'business_cctj',
'business_nddw',
'business_tjdw',
'business_yxqdw',
'business_rqcz',
dicts: [
'business_pztj',
'business_cctj',
'business_nddw',
'business_tjdw',
'business_yxqdw',
'business_rqcz',
'business_sp_jmdyzqdyp', //色谱-编号-准确度与精密度
'business_sp_nbgzy', //色谱-编号-内标工作液
'business_sp_zkgzy', //色谱-编号-质控工作液
'business_sp_bqgzy', //色谱-编号-标曲工作液
'business_sp_bzqxzkypzbb', //色谱-编号-标准曲线/质控样品制备表
'business_sp_tqhsl', //色谱-编号-提取回收率
'business_sp_qxwdx', //色谱-编号-全血稳定性
'business_sp_cbyhgzywdx', //色谱-编号-储备液和工作液稳定性
'business_sp_rxjzxy', //色谱-编号-溶血基质效应
'business_sp_jzxy', //色谱-编号-基质效应
'business_sp_xzxytyx', //色谱-编号-选择性与特异性
'business_sp_zdybs', //色谱-编号-最大样本数
'business_sp_xskkx', //色谱-编号-稀释可靠性
'business_sp_cbydb' //色谱-编号-储备液对比
],
props: {
templateData: {
type: Object,
default: () => {}
}
},
watch: {
templateData: {
immediate: true,
deep: true,
handler(v) {
if (v) {
const {
studyId,
studyMc,
studySn,
templateMc,
templateMcEn,
templateSn,
startDate,
bdmc,
endDate,
id
} = v
if (v.resource) {
//试验试剂信息
this.resource = JSON.parse(v.resource)
}
if (v.bdnr) {
this.formData = {
...JSON.parse(v.bdnr),
studyId,
studyMc,
studySn,
templateMc,
templateMcEn,
templateSn,
startDate,
bdmc,
endDate,
id
}
} else {
this.formData = {
studyId,
studyMc,
studySn,
templateMc,
templateMcEn,
templateSn,
startDate,
bdmc,
endDate,
id
}
}
const { effectivePeriod, effectivePeriodUnit, expireDate } =
this.formData
//实际填报的时候,如果有了开始时间,并且有有效周期,但是没有失效日,就计算失效日为开始时间+有效周期
if (
startDate &&
this.fillType === 'actFill' &&
effectivePeriod &&
effectivePeriodUnit &&
!expireDate
) {
const start = moment(startDate)
const unit = effectivePeriodUnit === '天' ? 'days' : 'hours'
const end = start
.add(Number(effectivePeriod), unit)
.format('YYYY-MM-DD HH:mm:ss')
this.formData = { ...this.formData, expireDate: end }
}
console.log(this.formData, 'formData from templateData')
this.setTemplateData(v)
}
}
}
},
data() {
return {
formData: {},
templateDetail: {},
resource: [], //试验试剂信息
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' }
]
}
},
mounted() {},
unmounted() {
this.setTemplateData({})
},
methods: {
//开始配置
//postData: {bh: '123456'}
async startConfigRequest (postData){
const res = await sj_startConfiguration(postData)
if (res.code === 200) {
this.$message.success('开始配置成功')
} else {
this.$message.error('开始配置失败')
}
},
//完成配置
async configCompleteRequest (postData){
const res = await sj_configurationCompleted(postData)
if (res.code === 200) {
this.$message.success('完成配置成功')
} else {
this.$message.error('完成配置失败')
}
},
//分装
async subPackageRequest (postData){
const res = await sj_subpackage(postData)
if (res.code === 200) {
this.$message.success('分装成功')
} else {
this.$message.error('分装失败')
}
},
//获取打印配置
getBasePrintConfig (data = {}){
const { printCode,type,row = {} } = data;
const {stepStorageCondition,startDate,expireDate} = this.formData;;
const { nickName, name } = this.$store.getters;
const lang = this.$i18n.locale;
const printConfig = {
"品名":"暂时还不知道品名是哪个字段",
"存储条件":stepStorageCondition,
"配制日期":moment(startDate).format("YYYY-MM-DD"),
"有效期至":moment(expireDate).format("YYYY-MM-DD HH:mm"),
"配置者":lang === "zh_CN" ? nickName : name,
//type==="subPackage"从分装打印过来的,
//type==="row" 从列表上点过来的
"编号":type === "subPackage" ? printCode : (row.targetSolutionCode+row.subTargetSolutionCode),
}
return printConfig
},
async getLatestSn(count = 1) {
const res = await getLatestSn({ count })
if (res.code === 200) {
return res.data
}
return null
},
getResource() {
return this.resource
},
//根据ref数组获取直接formData
getFilledFormDataByRefs(refArr = []) {
let result = {}
refArr.map((ref) => {
const refData = this.$refs[ref]?.getFilledFormData() || {}
for (const [key, value] of Object.entries(refData)) {
let index = 0
// 如果当前键是可能重复的字段,且结果对象中已经存在该键,则添加索引后缀
if (
(key === 'headerSelectFields' || key === 'stepTableFormData') &&
result.hasOwnProperty(key)
) {
// 为重复字段生成带索引的键名,从1开始(因为第一个组件不需要后缀)
const newKey = `${key}_${++index}`
result[newKey] = value
} else {
// 正常合并其他字段
result[key] = value
}
}
})
return result
},
//统一校验form表单是否填写
async validFormFields(refArr = []) {
let result = {}
const refs = refArr.map((ref) => {
let refData = {}
if (this.$refs[ref][0]) {
refData = this.$refs[ref][0]?.getFormData() || {}
} else {
refData = this.$refs[ref]?.getFormData() || {}
}
return refData
})
const validFormData = await Promise.all(refs).catch((err) => {
// this.$message.error(err);
if (err.errorType && err.errorType === 'step') {
this.$message.error('请添加步骤')
return
}
this.$message.error('表单内容未填完,请填写后再提交')
})
if (validFormData) {
validFormData.forEach((item) => {
for (const [key, value] of Object.entries(item)) {
let index = 0
// 如果当前键是可能重复的字段,且结果对象中已经存在该键,则添加索引后缀
if (
(key === 'headerSelectFields' || key === 'stepTableFormData') &&
result.hasOwnProperty(key)
) {
// 为重复字段生成带索引的键名,从1开始(因为第一个组件不需要后缀)
const newKey = `${key}_${++index}`
result[newKey] = value
} else {
// 正常合并其他字段
result[key] = value
}
}
})
return result
}
return false
},
//试验配制条件options
getDictOptions(dictType) {
return this.dict.type[dictType] || []
},
'business_sp_jmdyzqdyp', //色谱-编号-准确度与精密度
'business_sp_nbgzy', //色谱-编号-内标工作液
'business_sp_zkgzy', //色谱-编号-质控工作液
'business_sp_bqgzy', //色谱-编号-标曲工作液
'business_sp_bzqxzkypzbb', //色谱-编号-标准曲线/质控样品制备表
'business_sp_tqhsl', //色谱-编号-提取回收率
'business_sp_qxwdx', //色谱-编号-全血稳定性
'business_sp_cbyhgzywdx', //色谱-编号-储备液和工作液稳定性
'business_sp_rxjzxy', //色谱-编号-溶血基质效应
'business_sp_jzxy', //色谱-编号-基质效应
'business_sp_xzxytyx', //色谱-编号-选择性与特异性
'business_sp_zdybs', //色谱-编号-最大样本数
'business_sp_xskkx', //色谱-编号-稀释可靠性
'business_sp_cbydb' //色谱-编号-储备液对比
],
props: {
templateData: {
type: Object,
default: () => { }
}
},
watch: {
templateData: {
immediate: true,
deep: true,
handler(v) {
if (v) {
const {
studyId,
studyMc,
studySn,
templateMc,
templateMcEn,
templateSn,
startDate,
bdmc,
endDate,
id
} = v
if (v.resource) {
//试验试剂信息
this.resource = JSON.parse(v.resource)
}
if (v.bdnr) {
this.formData = {
...JSON.parse(v.bdnr),
studyId,
studyMc,
studySn,
templateMc,
templateMcEn,
templateSn,
startDate,
bdmc,
endDate,
id
}
} else {
this.formData = {
studyId,
studyMc,
studySn,
templateMc,
templateMcEn,
templateSn,
startDate,
bdmc,
endDate,
id
}
}
const { effectivePeriod, effectivePeriodUnit, expireDate } =
this.formData
//实际填报的时候,如果有了开始时间,并且有有效周期,但是没有失效日,就计算失效日为开始时间+有效周期
if (
startDate &&
this.fillType === 'actFill' &&
effectivePeriod &&
effectivePeriodUnit &&
!expireDate
) {
const start = moment(startDate)
const unit = effectivePeriodUnit === '天' ? 'days' : 'hours'
const end = start
.add(Number(effectivePeriod), unit)
.format('YYYY-MM-DD HH:mm:ss')
this.formData = { ...this.formData, expireDate: end }
}
console.log(this.formData, 'formData from templateData')
this.setTemplateData(v)
}
}
}
},
data() {
return {
formData: {},
templateDetail: {},
resource: [], //试验试剂信息
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' }
]
}
},
mounted() { },
unmounted() {
this.setTemplateData({})
},
methods: {
//开始配置
//postData: {bh: '123456'}
async startConfigRequest(postData) {
const res = await sj_startConfiguration(postData)
if (res.code === 200) {
this.$message.success('开始配置成功')
} else {
this.$message.error('开始配置失败')
}
},
//完成配置
async configCompleteRequest(postData) {
const res = await sj_configurationCompleted(postData)
if (res.code === 200) {
this.$message.success('完成配置成功')
} else {
this.$message.error('完成配置失败')
}
},
//分装
async subPackageRequest(postData) {
const res = await sj_subpackage(postData)
if (res.code === 200) {
this.$message.success('分装成功')
} else {
this.$message.error('分装失败')
}
},
//获取打印配置
getBasePrintConfig(data = {}) {
const { printCode, type, row = {} } = data;
const { stepStorageCondition, startDate, expireDate } = this.formData;;
const { nickName, name } = this.$store.getters;
const lang = this.$i18n.locale;
const printConfig = {
"品名": "暂时还不知道品名是哪个字段",
"存储条件": stepStorageCondition,
"配制日期": moment(startDate).format("YYYY-MM-DD"),
"有效期至": moment(expireDate).format("YYYY-MM-DD HH:mm"),
"配置者": lang === "zh_CN" ? nickName : name,
//type==="subPackage"从分装打印过来的,
//type==="row" 从列表上点过来的
"编号": type === "subPackage" ? printCode : (row.targetSolutionCode + row.subTargetSolutionCode),
}
return printConfig
},
async getLatestSn(count = 1) {
const res = await getLatestSn({ count })
if (res.code === 200) {
return res.data
}
return null
},
getResource() {
return this.resource
},
//根据ref数组获取直接formData
getFilledFormDataByRefs(refArr = []) {
let result = {}
refArr.map((ref) => {
const refData = this.$refs[ref]?.getFilledFormData() || {}
for (const [key, value] of Object.entries(refData)) {
let index = 0
// 如果当前键是可能重复的字段,且结果对象中已经存在该键,则添加索引后缀
if (
(key === 'headerSelectFields' || key === 'stepTableFormData') &&
result.hasOwnProperty(key)
) {
// 为重复字段生成带索引的键名,从1开始(因为第一个组件不需要后缀)
const newKey = `${key}_${++index}`
result[newKey] = value
} else {
// 正常合并其他字段
result[key] = value
}
}
})
return result
},
//统一校验form表单是否填写
async validFormFields(refArr = []) {
let result = {}
const refs = refArr.map((ref) => {
let refData = {}
if (this.$refs[ref][0]) {
refData = this.$refs[ref][0]?.getFormData() || {}
} else {
refData = this.$refs[ref]?.getFormData() || {}
}
return refData
})
const validFormData = await Promise.all(refs).catch((err) => {
// this.$message.error(err);
if (err.errorType && err.errorType === 'step') {
this.$message.error('请添加步骤')
return
}
this.$message.error('表单内容未填完,请填写后再提交')
})
if (validFormData) {
validFormData.forEach((item) => {
for (const [key, value] of Object.entries(item)) {
let index = 0
// 如果当前键是可能重复的字段,且结果对象中已经存在该键,则添加索引后缀
if (
(key === 'headerSelectFields' || key === 'stepTableFormData') &&
result.hasOwnProperty(key)
) {
// 为重复字段生成带索引的键名,从1开始(因为第一个组件不需要后缀)
const newKey = `${key}_${++index}`
result[newKey] = value
} else {
// 正常合并其他字段
result[key] = value
}
}
})
return result
}
return false
},
//试验配制条件options
getDictOptions(dictType) {
return this.dict.type[dictType] || []
},
setTemplateData(data) {
this.$store.commit('template/SET_TEMPLATE_DATA', data)
},
//统一处理删除行
deleteRow(index) {
this.$refs.stepTableRef.deleteRow(index)
},
setTemplateData(data) {
this.$store.commit('template/SET_TEMPLATE_DATA', data)
},
//统一处理删除行
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 arr = Array.from({ length: codeSTD }, (item, index) => ({
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()
arr.forEach((item, rowIndex) => {
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
if (volume) {
this.updateTargetStartSolutionVolume(item, volume)
}
} else if (
colKey === 'actStartSolutionVolume' ||
colKey === 'actDiluentVolume'
) {
//实际起始溶液体积和实际目标溶液体积
const targetAcSolution =
this.$refs.stepFormPackageRef?.getFormDataByKey('targetAcSolution') ||
0 //获取实际起始溶液浓度
if (targetAcSolution) {
this.updateSjmbrynd(item, targetAcSolution)
}
}
},
//统一处理blur事件,因为有效周期和过期日期是相关的,所以需要在有效周期失焦时更新过期日期
onHandleBlur(fields) {
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
targetSolutionCode: `STD${Number(codeSTD) - index}`
}))
this.$refs.stepTableRef.updateDataSource(arr)
} else if (key === 'targetStartSolution') {
//起始溶液体积失焦时,更新目标溶液预计浓度
const arr = this.$refs.stepTableRef?.getDataSource()
arr.forEach((item, rowIndex) => {
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
if (volume) {
this.updateTargetStartSolutionVolume(item, volume)
}
} else if (
colKey === 'actStartSolutionVolume' ||
colKey === 'actDiluentVolume'
) {
//实际起始溶液体积和实际目标溶液体积
const targetAcSolution =
this.$refs.stepFormPackageRef?.getFormDataByKey('targetAcSolution') ||
0 //获取实际起始溶液浓度
if (targetAcSolution) {
const { actVol, actNd } = this.updateSjmbrynd(item, targetAcSolution);
this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { actSolutionVolume: actVol })
this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { actSolutionConcentration: actNd })
}
}
},
//计算并更新实际目标溶液浓度 先计算实际目标溶液体积再计算实际目标溶液浓度
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)
console.log(actNd,targetAcSolution,actStartSolutionVolume,actVol, "actNd")
item.actSolutionConcentration = actNd === 'Infinity' ? 0 : 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
)
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
// this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetDiluentVolume: result1 });
}
}
}
//计算并更新实际目标溶液浓度 先计算实际目标溶液体积再计算实际目标溶液浓度
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)
const nd = actNd === 'Infinity' ? 0 : actNd
console.log(actNd, targetAcSolution, actStartSolutionVolume, actVol, "actNd")
// item.actSolutionConcentration = actNd === 'Infinity' ? 0 : actNd
return { actVol, actNd: nd }
},
//更新起始溶液体积时,计算目标溶液预计浓度
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
)
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
// this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetDiluentVolume: result1 });
}
}
}
}

Loading…
Cancel
Save