<!-- 生物样品分析溶液配制表 -->
<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" />
					<LineLabel label="template.common.instrumentInfo" />
					<CustomTable 
						:columns="yqInfoColumns"  
						:formData = "formData"
						ref = "yqInfoTableRef"
						@onRegentSubmit="(data, col, rowIndex, colIndex, row)=>onYqSubmit(data, col, rowIndex, colIndex, row)"
						:showAddRow = "fillType === 'actFill'"
						:showOperation = "fillType === 'actFill'"
						:prefixKey="`yqTable`"
					>
						<template slot="operation" slot-scope="{ row, rowIndex, columns }">
							<TableOpertaionDelete  :row="row" :rowIndex="rowIndex" :columns="columns"  @deleteRow="()=>deleteRow(rowIndex,'yqInfoTableRef')" ></TableOpertaionDelete>
						</template>
					</CustomTable>
					<BaseInfoFormPackage class="mt-20" fieldItemLabel="色谱柱型号" label="色谱柱型号" ref="spzxhRef"
						:formConfig="storageFormConfig" :formData="formData" />
					<LineLabel label="溶液" />
					<CustomTable 
						:columns="ryColumns"  
						ref = "ryTableRef"
						@onRegentSubmit = "(e)=>onRegentSubmit(e)"
						:showOperation = "fillType === 'preFill'"
						:formData="{stepTableFormData:formData.stepTableFormData_1,headerSelectFields:{}}" :prefixKey="`ryTable`"
					>
						<template slot="operation" slot-scope="{ row, rowIndex, columns }">
							<TableOpertaionDelete  :row="row" :rowIndex="rowIndex" :columns="columns"  @deleteRow="()=>deleteRow(rowIndex,'ryTableRef')" ></TableOpertaionDelete>
						</template>
					</CustomTable>
					<BaseInfoFormPackage class="mt-20" fieldItemLabel="仪器平衡" label="仪器平衡" ref="storageConditionRef"
						:formConfig="yqphFormConfig" :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 CustomTable from '@/components/Template/CustomTable.vue';
import TableOpertaionDelete from "@/components/Template/operation/TableOpertaionDelete.vue"

import { getBaseInfoFormConfig, storageFormConfig, getYqColumns,getRyColumns,getYqphFormConfig } from "../../formConfig/sp/SP0019"

export default {
	name: "SP0019",
	components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable,TableOpertaionDelete },
	mixins: [templateMixin],
	props: {
		fillType: {
			type: String,
			default: 'preFill',
		},
	},
	computed: {
		//仪器平衡
		yqphFormConfig(){
			return getYqphFormConfig(this);
		},
		//溶液
		ryColumns(){
			return getRyColumns(this);
		},
		//仪器信息
		yqInfoColumns() {
			return getYqColumns(this);
		},
		// 配置条件
		storageFormConfig() {
			return storageFormConfig;
		},
		// 备注表单配置
		remarkConig() {
			return [
				{
					type: "cellItem",
					config: {
						remark: {
							label: "",
							type: "textarea",
							fillType: "actFill",
							span: 1,
							placeholder: 'template.common.remarkPlaceholder',
							maxlength: 1000,
							rows: 5
						}
					}
				}
			]
		},
		// 试验基本信息表单配置
		baseInfoFormConfig() {
			return getBaseInfoFormConfig(this);
		},
	},
	data() {
		return {
			formData: {}
		};
	},
	mounted() {
	

	},
	methods: {
		onRegentSubmit(e){
			const {selectInfo, key, col, rowIndex, colIndex, rowData} = e;
			const {row} = selectInfo;
			if(key === "rymc"){
				const params = {
					pzrq: row.pzrq,
					sxr: row.sxr,
				}
				this.$refs.ryTableRef.updateDataSourceByRowIndex(rowIndex, params);
			}
		},
		onYqSubmit(data, col, rowIndex, colIndex, row){
			console.log(data, col, rowIndex, colIndex, row,"onRegentSubmit")
		},
		//获取已填写的表单数据
		getFilledFormData() {
			return this.getFilledFormDataByRefs(["baseInfoRef", "storageConditionRef", "spzxhRef", "yqInfoTableRef", "ryTableRef", "remarkRef"])
		},
		//获取填写完成的表单数据
		async getFormData() {
			let content = await this.validFormFields(["baseInfoRef", "storageConditionRef", "spzxhRef","yqInfoTableRef","ryTableRef", "remarkRef"]);
			console.log(content)
			return content;
		},
		//保存
		async onSave() {

		},
	}
};
</script>
<style rel="stylesheet/scss" lang="scss">
.mt-20 {
	margin-top: 20px;
}

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