<!-- 生物样品分析溶液配制表 -->
<template>
	<div>
		<div class="detail-container">
			<div class="detail-title"><img src="@/assets/images/detail-title.png">{{ formData.bdmc ||
				$t('template.sp.sp007.title') }}<img src="@/assets/images/detail-title.png" /></div>
			<div class="detail-content">
				<div class="content">
					<BaseInfoFormPackage fieldItemLabel="template.common.baseInfo" label="template.common.baseInfo"
						ref="baseInfoRef" :formConfig="baseInfoFormConfig" :formData="formData" />
					<TableList label="template.common.reagentInfo" :columns="sysjColumns" :dataSource="resource" />
					<TableList label="template.common.wzInfo" :columns="sywzColumns" :dataSource="resourceWz" v-if="resourceWz.length>0"/>
					<TableList label="template.common.instrumentInfo" :columns="yqColumns" :dataSource="yqResource" />
					<BaseInfoFormPackage fieldItemLabel="template.common.storageCondition"
						label="template.common.storageCondition" ref="storageConditionRef"
						:formConfig="storageFormConfig" :formData="formData" />
					<BaseInfoFormPackage fieldItemLabel="template.sp.sp007.ybsm" label="template.sp.sp007.ybsm"
						ref="ybRef" :formConfig="ybFormConfig" :formData="formData" />
					<LineLabel label="template.common.operationSteps" />
					<Step ref="stepRef" :formData="formData.stepData"></Step>
					<BaseInfoFormPackage fieldItemLabel="template.common.remark" label="template.common.remark"
						ref="remarkRef" :formConfig="remarkConig" :formData="formData" />
					<BaseInfoFormPackage fieldItemLabel="template.lba.lba003.fj" label="template.lba.lba003.fj"
						ref="fjRef" :formConfig="getFjFormConfig" :formData="formData" />
				
				</div>
			</div>
		</div>
		<!-- <button @click="onSave">保存</button> -->
	</div>
</template>

<script>
import BaseInfoFormPackage from "@/components/Template/BaseInfoFormPackage";
import LineLabel from "@/components/Template/LineLabel";
import TableList from "@/components/Template/Table";
import Step from "@/components/Template/Step";
import templateMixin from "../../mixins/templateMixin";
import CustomTable from '@/components/Template/CustomTable.vue';
import { getLatestSn } from '@/api/template';
import { EventBus } from "@/utils/eventBus";
import { uniqeResource } from "@/utils/calUnitTools";
import { debounce } from 'lodash-es';
import {getBaseInfoFormConfig, getRemarkFormConfig,getStorageFormConfig,getYbFormConfig,getfjFormConfig} from "../../formConfig/sp/SP007";

export default {
	name: "SP007",
	components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable },
	mixins: [templateMixin],
	props: {
		fillType: {
			type: String,
			default: 'preFill',
		},
	},
	computed: {
		// 配置条件
		storageFormConfig() {
			return getStorageFormConfig(this);
		},
		// 备注表单配置
		remarkConig() {
			return getRemarkFormConfig();
		},
		// 样本说明
		ybFormConfig() {
			return getYbFormConfig();
		},
		// 试验基本信息表单配置
		baseInfoFormConfig() {
			return getBaseInfoFormConfig(this);
		},
		// 附件表单配置
		getFjFormConfig() {
			return getfjFormConfig(this);
		},
		
	},
	data() {
		return {
			formData: {}
		};
	},
	mounted() {
	},
	methods: {
		//打印标签
		printTag() {
			const printConfig = this.getBasePrintConfig();
			const { storageCondition, targetCodeSn } = this.formData;
			printConfig["存储条件"] = storageCondition;
			printConfig["编号"] = targetCodeSn;

			EventBus.$emit('showTagPrintDialog', { printConfig })
		},
	
		//获取已填写的表单数据
		getFilledFormData() {
			return this.getFilledFormDataByRefs(["baseInfoRef", "storageConditionRef", "ybRef","stepRef", "remarkRef","fjRef"])
		},
		//获取填写完成的表单数据
		async getFormData() {
			let content = await this.validFormFields(["baseInfoRef", "storageConditionRef", "ybRef","stepRef", "remarkRef","fjRef"]);
			return content;
		},
		getResource() {
			let content = this.getFilledFormData();
			//使用的试剂、仪器
			const stepResource = this.$refs.stepRef.getStepResource()
			this.resourceTmp = stepResource.sjResource || []
			this.yqResourceTmp = stepResource.yqResource || []
			return this.resourceTmp;
		},
		//保存
		async onSave() {
			let content =await this.$refs.fjRef.getFormData();
			console.log(content);
			
		},
	}
};
</script>
<style rel="stylesheet/scss" lang="scss">
.mt-20 {
	margin-top: 20px;
}

.print-btn {
	margin-bottom: 20px;
}
</style>