|
|
|
@ -15,32 +15,32 @@ |
|
|
|
:formConfig="storageFormConfig" :formData="formData" /> |
|
|
|
<LineLabel label="样本说明" /> |
|
|
|
<el-button class="mt-20" v-if="fillType === 'actFill'" type="primary" @click="onAdd">新增</el-button> |
|
|
|
<div class="template-form-item"> |
|
|
|
<div v-for="(item, index) in formData.ybsmDataList" :key="index" class="template-form-item"> |
|
|
|
<div class="config-header"> |
|
|
|
<div></div> |
|
|
|
<el-button v-if="fillType === 'actFill'" type="text" icon="el-icon-delete" |
|
|
|
@click="deleteConfig">{{ $t('template.common.deleteBtn') |
|
|
|
@click="deleteConfig(index)">{{ $t('template.common.deleteBtn') |
|
|
|
}}</el-button> |
|
|
|
</div> |
|
|
|
<BaseInfoFormPackage fieldItemLabel="样本说明" :ref="refConfig.ybsmFormPackageRef" |
|
|
|
:formConfig="ybsmFormConfig" @blur="onHandleBlur" :formData="formData" /> |
|
|
|
<BaseInfoFormPackage fieldItemLabel="样本说明" :ref="`ybsmFormPackageRef${index}`" |
|
|
|
:formConfig="ybsmFormConfig" @blur="onHandleBlur" :formData="item" /> |
|
|
|
<el-button v-if="fillType === 'actFill'" type="primary" @click="onImportAnimal">导入动物</el-button> |
|
|
|
<CustomTable |
|
|
|
:ref = "refConfig.ybsmTableRef" |
|
|
|
:ref = "`ybsmTableRef${index}`" |
|
|
|
:columns="ybsmColumns" |
|
|
|
:showOperation="fillType === 'actFill'" |
|
|
|
:showAddRow="fillType === 'actFill'" |
|
|
|
:dataSource="formData.ybsmData" > |
|
|
|
:dataSource="item.ybsmData || []" > |
|
|
|
<template slot="operation" slot-scope="{ row, rowIndex, columns }"> |
|
|
|
<TableOpertaionDelete |
|
|
|
:row="row" |
|
|
|
:rowIndex="rowIndex" |
|
|
|
:columns="columns" |
|
|
|
@deleteRow="() => deleteTableRow(rowIndex, 'ybsmTableRef')" |
|
|
|
@deleteRow="() => deleteTableRow(rowIndex, `ybsmTableRef${index}`)" |
|
|
|
></TableOpertaionDelete> |
|
|
|
</template> |
|
|
|
</CustomTable> |
|
|
|
<Step :ref="refConfig.stepRef" :formData="formData.stepData"></Step> |
|
|
|
<Step :ref="`stepRef${index}`" :formData="item.stepData"></Step> |
|
|
|
</div> |
|
|
|
<BaseInfoFormPackage fieldItemLabel="template.common.remark" label="template.common.remark" |
|
|
|
:ref="refConfig.remarkRef" :formConfig="remarkConig" :formData="formData" /> |
|
|
|
@ -63,6 +63,7 @@ import Step from "@/components/Template/Step"; |
|
|
|
import templateMixin from "../../mixins/templateMixin"; |
|
|
|
import CustomTable from '@/components/Template/CustomTable.vue'; |
|
|
|
import { uniqeResource } from "@/utils/calUnitTools"; |
|
|
|
import {getuuid} from "@/utils/index"; |
|
|
|
import { getBaseInfoFormConfig, getStorageFormConfig, getRemarkFormConfig, getYbsmFormConfig,getTableColumns } from "../../formConfig/sp/SP0021"; |
|
|
|
const refConfig = { |
|
|
|
baseInfoRef: "baseInfoRef", |
|
|
|
@ -110,20 +111,40 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
refConfig, |
|
|
|
formData: {}, |
|
|
|
}; |
|
|
|
}, |
|
|
|
return { |
|
|
|
refConfig, |
|
|
|
}; |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
|
|
|
|
if(this.fillType === 'preFill'){//预填的时候默认新增一个。 |
|
|
|
this.onAdd() |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
//删除样本说明 |
|
|
|
deleteConfig(){}, |
|
|
|
deleteConfig(index){ |
|
|
|
// 确保 ybsmDataList 存在 |
|
|
|
if (!this.formData.ybsmDataList) { |
|
|
|
this.formData.ybsmDataList = [{}]; |
|
|
|
return; |
|
|
|
} |
|
|
|
if (this.formData.ybsmDataList.length > 1) { |
|
|
|
this.formData.ybsmDataList.splice(index, 1); |
|
|
|
} else { |
|
|
|
this.$message.warning('至少需要保留一个样本说明项'); |
|
|
|
} |
|
|
|
}, |
|
|
|
//新增样本说明 |
|
|
|
onAdd(){ |
|
|
|
|
|
|
|
if (!this.formData.ybsmDataList) { |
|
|
|
this.$set(this.formData, 'ybsmDataList', []); |
|
|
|
} |
|
|
|
// 添加新的平行配制配置 |
|
|
|
this.formData.ybsmDataList.push({ |
|
|
|
id: getuuid(), |
|
|
|
ybsmFormData: {}, |
|
|
|
stepData: [], |
|
|
|
}); |
|
|
|
}, |
|
|
|
onLoadExcelData(excelData) { |
|
|
|
const data = excelData.splice(1); |
|
|
|
@ -146,12 +167,43 @@ export default { |
|
|
|
}, |
|
|
|
//获取已填写的表单数据 |
|
|
|
getFilledFormData() { |
|
|
|
return this.getFilledFormDataByRefs(compRefs) |
|
|
|
// 基础表单数据 |
|
|
|
const baseData = this.getFilledFormDataByRefs(compRefs); |
|
|
|
// 处理多个样本说明项 |
|
|
|
const ybsmDataList = this.formData.ybsmDataList.map((item, index) => { |
|
|
|
const ybsmFormData = this.$refs[`ybsmFormPackageRef${index}`]?.getFilledFormData() || {}; |
|
|
|
const ybsmTableData = this.$refs[`ybsmTableRef${index}`]?.getFilledFormData() || []; |
|
|
|
const stepData = this.$refs[`stepRef${index}`]?.getFilledFormData() || {}; |
|
|
|
return { |
|
|
|
...ybsmFormData, |
|
|
|
ybsmData: ybsmTableData, |
|
|
|
stepData: stepData |
|
|
|
}; |
|
|
|
}); |
|
|
|
return { |
|
|
|
...baseData, |
|
|
|
ybsmDataList |
|
|
|
}; |
|
|
|
}, |
|
|
|
//获取填写完成的表单数据 |
|
|
|
async getFormData() { |
|
|
|
// 基础表单验证 |
|
|
|
let content = await this.validFormFields(compRefs); |
|
|
|
return content; |
|
|
|
if (!content) return null; |
|
|
|
|
|
|
|
// 验证多个样本说明项 |
|
|
|
for (let index = 0; index < this.formData.ybsmDataList.length; index++) { |
|
|
|
// 验证样本说明表单 |
|
|
|
const ybsmFormValid = await this.$refs[`ybsmFormPackageRef${index}`]?.validFormFields() || true; |
|
|
|
if (!ybsmFormValid) return null; |
|
|
|
|
|
|
|
// 验证步骤数据 |
|
|
|
const stepValid = await this.$refs[`stepRef${index}`]?.getFormData() || true; |
|
|
|
if (!stepValid) return null; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取所有数据 |
|
|
|
return this.getFilledFormData(); |
|
|
|
}, |
|
|
|
getResource() { |
|
|
|
let content = this.getFilledFormData(); |
|
|
|
@ -179,14 +231,21 @@ export default { |
|
|
|
}) |
|
|
|
} |
|
|
|
//使用的试剂、仪器 |
|
|
|
const stepResource = this.$refs.stepRef.getStepResource() |
|
|
|
this.resourceTmp = uniqeResource(tmpResource, stepResource.sjResource || []) |
|
|
|
this.yqResourceTmp = stepResource.yqResource || [] |
|
|
|
let allSjResource = []; |
|
|
|
let allYqResource = []; |
|
|
|
// 收集所有样本说明项的步骤资源 |
|
|
|
for (let index = 0; index < this.formData.ybsmDataList.length; index++) { |
|
|
|
const stepResource = this.$refs[`stepRef${index}`]?.getStepResource() || { sjResource: [], yqResource: [] }; |
|
|
|
allSjResource = [...allSjResource, ...(stepResource.sjResource || [])]; |
|
|
|
allYqResource = [...allYqResource, ...(stepResource.yqResource || [])]; |
|
|
|
} |
|
|
|
this.resourceTmp = uniqeResource(tmpResource, allSjResource) |
|
|
|
this.yqResourceTmp = allYqResource |
|
|
|
return this.resourceTmp; |
|
|
|
}, |
|
|
|
//保存 |
|
|
|
async onSave() { |
|
|
|
let content = await this.$refs.stepRef.getFormData(); |
|
|
|
let content = await this.getFormData(); |
|
|
|
console.log(content); |
|
|
|
|
|
|
|
}, |
|
|
|
|