<!-- 试验操作复核记录表 -->
<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" />

					

					<!-- 操作步骤 -->
					<BaseInfoFormPackage fieldItemLabel="template.common.baseInfo" label="template.common.operationSteps"
						ref="operateRef" :formConfig="operateConfig" :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 stepMixins from '@/components/Template/mixins/stepMixins.js';
import CustomTable from '@/components/Template/CustomTable.vue';
import { EventBus } from "@/utils/eventBus";
import { uniqeResource } from "@/utils/calUnitTools";
import { debounce } from 'lodash-es'
import TableOpertaionDelete from "@/components/Template/operation/TableOpertaionDelete.vue"
import StepFormPackage from "@/components/Template/StepFormPackage.vue"

export default {
	name: "DJ001",
	components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, TableOpertaionDelete, StepFormPackage },
	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,
						},
					}
				},
				
			]
		},
		//操作步骤配置
		operateConfig() {
			return [
				{
					type: "cellItem",
					config: {
						syts: {
							label: 'template.dj.dj001.syts',
							type: "input",
							fillType: 'actFill',
						},
					}
				},
				
			]
		}
	},
	data() {
		return {
			formData: {},
		};
	},
	mounted() {
	},
	methods: {
		//获取已填写的表单数据
		getFilledFormData() {
			return this.getFilledFormDataByRefs(
				[
				 "baseInfoRef",  "stepRef", "remarkRef", 
				 "fjRef", "tableFirstRef", "stepFormPackageSecondRef", 
				 "stepFormPackageThirdRef", "stepFormPackageFourthRef", 
				 "stepFormPackageFivthRef", "tableSecondRef", "stepFormPackageSixthRef"
				]
			)
		},
		//获取填写完成的表单数据
		async getFormData() {
			let content = await this.validFormFields([
				"baseInfoRef",  "stepRef", "remarkRef", 
				"fjRef", "tableFirstRef", "stepFormPackageSecondRef", 
				"stepFormPackageThirdRef", "stepFormPackageFourthRef", 
				"stepFormPackageFivthRef", "tableSecondRef", "stepFormPackageSixthRef"
			]);
			return content;
		},
		getResource() {
			//使用的试剂、仪器
			const stepResource = this.$refs.stepRef.getStepResource()
			this.resourceTmp = stepResource.sjResource || []
			this.yqResourceTmp = stepResource.yqResource || []
			return this.resourceTmp;
		},
		//保存
		async onSave() {
			let content = await this.$refs.stepRef.getFormData();
			console.log(content);
		},
		// 删除表格行
		deleteRow(rowIndex,type) {
			const tableRef1 = this.$refs['tableFirstRef'];
			const tableRef2 = this.$refs['tableSecondRef'];
			if (type == 'firstTable' && tableRef1) {
				tableRef1.deleteRow(rowIndex);
			}
			if (type == 'secondTable' && tableRef2) {
				tableRef2.deleteRow(rowIndex);
			}
		},
	}
};
</script>
<style rel="stylesheet/scss" lang="scss">
</style>