|
|
|
@ -19,30 +19,26 @@ |
|
|
|
<div class="config-header"> |
|
|
|
<div></div> |
|
|
|
<el-popconfirm title="确认删除当前样本?" @confirm="deleteConfig(item)"> |
|
|
|
<el-button slot="reference" v-if="fillType === 'actFill'" type="text" icon="el-icon-delete" >{{ |
|
|
|
$t('template.common.deleteBtn') |
|
|
|
}}</el-button> |
|
|
|
<el-button slot="reference" v-if="fillType === 'actFill'" type="text" |
|
|
|
icon="el-icon-delete">{{ |
|
|
|
$t('template.common.deleteBtn') |
|
|
|
}}</el-button> |
|
|
|
</el-popconfirm> |
|
|
|
</div> |
|
|
|
<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 = "`ybsmTableRef${index}`" |
|
|
|
:columns="ybsmColumns" |
|
|
|
:showOperation="fillType === 'actFill'" |
|
|
|
:showAddRow="fillType === 'actFill'" |
|
|
|
:formData = "item"> |
|
|
|
<BaseInfoFormPackage fieldItemLabel="样本说明" :ref="`ybsmFormPackageRef${index}`" |
|
|
|
:formConfig="ybsmFormConfig" @blur="onHandleBlur" :formData="item" /> |
|
|
|
<el-button v-if="fillType === 'actFill'" type="primary" |
|
|
|
@click="onImportAnimal(item, index)">导入动物</el-button> |
|
|
|
<CustomTable :ref="`ybsmTableRef${index}`" :columns="ybsmColumns" |
|
|
|
:showOperation="fillType === 'actFill'" :showAddRow="fillType === 'actFill'" |
|
|
|
:formData="item"> |
|
|
|
<template slot="operation" slot-scope="{ row, rowIndex, columns }"> |
|
|
|
<TableOpertaionDelete |
|
|
|
:row="row" |
|
|
|
:rowIndex="rowIndex" |
|
|
|
:columns="columns" |
|
|
|
@deleteRow="() => deleteTableRow(rowIndex, `ybsmTableRef${index}`)" |
|
|
|
></TableOpertaionDelete> |
|
|
|
<TableOpertaionDelete :row="row" :rowIndex="rowIndex" :columns="columns" |
|
|
|
@deleteRow="() => deleteTableRow(rowIndex, `ybsmTableRef${index}`)"> |
|
|
|
</TableOpertaionDelete> |
|
|
|
</template> |
|
|
|
</CustomTable> |
|
|
|
<Step :ref="`stepRef${index}`" :formData="item.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" /> |
|
|
|
@ -50,7 +46,8 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<!-- <button @click="onSave">保存</button> --> |
|
|
|
<ImportExcelDialog ref="ImportExcelDialog" @onLoadData="onLoadExcelData" :downloadArr="['动物编号']" @downloadExcelTemplate="downloadExcelTemplate" /> |
|
|
|
<ImportExcelDialog ref="ImportExcelDialog" @onLoadData="onLoadExcelData" :downloadArr="['动物编号']" |
|
|
|
@downloadExcelTemplate="downloadExcelTemplate" /> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
@ -65,8 +62,8 @@ 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,justUpdateFilledFormData} from "@/utils/index"; |
|
|
|
import { getBaseInfoFormConfig, getStorageFormConfig, getRemarkFormConfig, getYbsmFormConfig,getTableColumns } from "../../formConfig/sp/SP0021"; |
|
|
|
import { getuuid, justUpdateFilledFormData } from "@/utils/index"; |
|
|
|
import { getBaseInfoFormConfig, getStorageFormConfig, getRemarkFormConfig, getYbsmFormConfig, getTableColumns } from "../../formConfig/sp/SP0021"; |
|
|
|
const refConfig = { |
|
|
|
baseInfoRef: "baseInfoRef", |
|
|
|
remarkRef: "remarkRef", |
|
|
|
@ -78,7 +75,7 @@ const refConfig = { |
|
|
|
const compRefs = Object.values(refConfig); |
|
|
|
export default { |
|
|
|
name: "SP0021", |
|
|
|
components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable,TableOpertaionDelete,ImportExcelDialog }, |
|
|
|
components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, TableOpertaionDelete, ImportExcelDialog }, |
|
|
|
mixins: [templateMixin], |
|
|
|
props: { |
|
|
|
fillType: { |
|
|
|
@ -113,23 +110,24 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
refConfig, |
|
|
|
}; |
|
|
|
}, |
|
|
|
return { |
|
|
|
refConfig, |
|
|
|
currentIndex: -1, |
|
|
|
}; |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
if(this.fillType === 'preFill' &&!this.formData.ybsmDataList){//预填的时候默认新增一个。 |
|
|
|
if (this.fillType === 'preFill' && !this.formData.ybsmDataList) {//预填的时候默认新增一个。 |
|
|
|
this.onAdd() |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
//删除样本说明 |
|
|
|
deleteConfig(item){ |
|
|
|
deleteConfig(item) { |
|
|
|
// 确保 ybsmDataList 存在 |
|
|
|
if (this.formData.ybsmDataList.length > 1) { |
|
|
|
const configIndex = this.formData.ybsmDataList.findIndex(config => config.id === item.id); |
|
|
|
console.log(configIndex,"configIndex") |
|
|
|
if(configIndex>-1){ |
|
|
|
console.log(configIndex, "configIndex") |
|
|
|
if (configIndex > -1) { |
|
|
|
const newList = [...this.formData.ybsmDataList] |
|
|
|
newList.splice(configIndex, 1); |
|
|
|
this.$set(this.formData, 'ybsmDataList', newList); |
|
|
|
@ -141,19 +139,19 @@ export default { |
|
|
|
} else { |
|
|
|
this.$message.warning('至少保留一个样本说明项'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
//新增样本说明 |
|
|
|
onAdd(){ |
|
|
|
onAdd() { |
|
|
|
if (!this.formData.ybsmDataList) { |
|
|
|
this.$set(this.formData, 'ybsmDataList', []); |
|
|
|
} |
|
|
|
let defaultInfo = { |
|
|
|
let defaultInfo = { |
|
|
|
id: getuuid(), |
|
|
|
stepData: [], |
|
|
|
} |
|
|
|
if(this.fillType === "actFill"){ |
|
|
|
const {ybsmDataList} = this.formData |
|
|
|
if (this.fillType === "actFill") { |
|
|
|
const { ybsmDataList } = this.formData |
|
|
|
defaultInfo.stepData = ybsmDataList[0]?.stepData || [] |
|
|
|
} |
|
|
|
// 添加新的平行配制配置 |
|
|
|
@ -161,21 +159,29 @@ export default { |
|
|
|
}, |
|
|
|
onLoadExcelData(excelData) { |
|
|
|
const data = excelData.splice(1); |
|
|
|
const transData = data.map((item)=>{ |
|
|
|
return{ |
|
|
|
dwbh: item[0], |
|
|
|
id: getuuid(), |
|
|
|
} |
|
|
|
}) |
|
|
|
this.$refs[`ybsmTableRef${this.currentIndex}`][0].pushDataSource(transData) |
|
|
|
this.$refs.ImportExcelDialog.cancel() |
|
|
|
setTimeout(() => { |
|
|
|
justUpdateFilledFormData(); |
|
|
|
}, 100); |
|
|
|
}, |
|
|
|
downloadExcelTemplate(arr){ |
|
|
|
downloadExcelTemplate(arr) { |
|
|
|
this.exportExcel(arr) |
|
|
|
}, |
|
|
|
// 导入动物 |
|
|
|
onImportAnimal(){ |
|
|
|
onImportAnimal(item, index) { |
|
|
|
this.currentIndex = index; |
|
|
|
this.$refs.ImportExcelDialog.show() |
|
|
|
}, |
|
|
|
// 删除表格行 |
|
|
|
deleteTableRow(rowIndex, refName) { |
|
|
|
this.$refs[refName].deleteRow(rowIndex) |
|
|
|
this.$refs[refName][0].deleteRow(rowIndex) |
|
|
|
}, |
|
|
|
//获取已填写的表单数据 |
|
|
|
getFilledFormData() { |
|
|
|
@ -202,18 +208,18 @@ export default { |
|
|
|
// 基础表单验证 |
|
|
|
let content = await this.validFormFields(compRefs); |
|
|
|
if (!content) return null; |
|
|
|
|
|
|
|
|
|
|
|
// 验证多个样本说明项 |
|
|
|
for (let index = 0; index < this.formData.ybsmDataList.length; index++) { |
|
|
|
// 验证样本说明表单 |
|
|
|
const ybsmFormValid = await this.$refs[`ybsmFormPackageRef${index}`][0]?.getFormData() || true; |
|
|
|
if (!ybsmFormValid) return null; |
|
|
|
|
|
|
|
|
|
|
|
// 验证步骤数据 |
|
|
|
const stepValid = await this.$refs[`stepRef${index}`][0]?.getFormData() || true; |
|
|
|
if (!stepValid) return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取所有数据 |
|
|
|
return this.getFilledFormData(); |
|
|
|
}, |
|
|
|
@ -272,6 +278,7 @@ export default { |
|
|
|
.print-btn { |
|
|
|
margin-bottom: 20px; |
|
|
|
} |
|
|
|
|
|
|
|
.config-header { |
|
|
|
display: flex; |
|
|
|
justify-content: space-between; |
|
|
|
|