<!-- 配体结合分析处理记录表 -->
<template>
	<div>
		<div class="detail-container">
			<div class="detail-title"><img src="@/assets/images/detail-title.png">{{ formData.bdmc }}<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" />
					
					
					<LineLabel label="template.lba.lba003.jclc" />
					<Step ref="stepRef" :formData="formData.stepData"></Step>
					<BaseInfoFormPackage fieldItemLabel="template.lba.lba003.fj" label="template.lba.lba003.fj"
						ref="fjRef" :formConfig="getFjFormConfig" :formData="formData" />
					<BaseInfoFormPackage fieldItemLabel="template.common.remark" label="template.common.remark"
						ref="remarkRef" :formConfig="remarkConig" :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 { EventBus } from "@/utils/eventBus";
import { uniqeResource } from "@/utils/calUnitTools";
import { debounce } from 'lodash-es';

export default {
	name: "LBA003",
	components: { BaseInfoFormPackage, LineLabel, TableList, Step },
	mixins: [templateMixin],
	props: {
		fillType: {
			type: String,
			default: 'preFill',
		},
	},
	computed: {
		// 备注表单配置
		remarkConig() {
			return [
				{
					type: "cellItem",
					config: {
						remark: {
							label: "",
							type: "textarea",
							fillType: "actFill",
							span: 1,
							placeholder: 'template.common.remarkPlaceholder',
							maxlength: 1000,
							rows: 5
						}
					}
				}
			]
		},
		// 试验基本信息表单配置
		baseInfoFormConfig() {
			return [
				{
					type: "cardItem",
					config: {
						studyMc: {
							label: 'template.common.testName',
							type: "input",
							disabled: true,
						},
						studySn: {
							label: 'template.common.testNumber',
							type: "input",
							disabled: true,
						},
						methodCode: {
							label: 'template.common.methodCode',
							type: "input",
							fillType: "preFill",
							maxlength: 50
						},
						versionNum: {
							label: 'template.common.versionNumber',
							type: "inputNumber",
							fillType: "actFill",
							prepend: "V",
							maxlength: 50
						},
					}
				},
				{
					type: "conditionItem",
					label: 'template.lba.lba002.cztj',
					config: {
						pre: {
							label: 'template.common.preFill',
							type: "select",
							multiple: true,
							fillType: "preFill",
							options: this.getDictOptions('business_pztj'),
							otherCode: "preOther",
						},
						act: {
							label: 'template.common.actualFill',
							type: "select",
							fillType: "actFill",
							otherCode: "actOther",
							multiple: true,
							compareTo: "pre",
							options: this.getDictOptions('business_pztj')
						}
					}
				},
				{
					type: "cellItem",
					label: 'template.lba.lba002.czsj',
					config: {
						startDate: {
							label: 'template.common.startTime',
							type: "input",
						},
						endDate: {
							label: 'template.common.endTime',
							type: "input",
						},
					}
				}
			]
		},
		// 附件表单配置
		getFjFormConfig() {
			return [
				{
					type: "attachment",
					config: {
						attTitle: {
							label: 'template.lba.lba003.fj',
							type: "attachment",
							fillType: "actFill",
						},
					}
				}
			]
		},
		
	},
	data() {
		return {
			formData: {}
		};
	},
	mounted() {
	},
	methods: {
		//获取已填写的表单数据
		getFilledFormData() {
			return this.getFilledFormDataByRefs(["baseInfoRef","stepRef", "remarkRef","fjRef"])
		},
		//获取填写完成的表单数据
		async getFormData() {
			let content = await this.validFormFields(["baseInfoRef","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>