<!-- 生物样品接收记录表 -->
<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.yp.yp002.swypyjjlbxx" label="template.yp.yp002.swypyjjlbxx"
						ref="swypyjInfoRef" :formConfig="swypyjInfoFormConfig" :formData="formData"
						/>

					<BaseInfoFormPackage fieldItemLabel="template.yp.yp002.qbjsxx" label="template.yp.yp002.qbjsxx"
						@clickButton="handleClickButton"
						ref="ypjsInfoRef" :formConfig="ypjsInfoFormConfig" :formData="formData" />
					
					<BaseInfoFormPackage fieldItemLabel="template.yp.yp002.jsbz" label="template.yp.yp002.jsbz"
						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 moment from "moment";

export default {
	name: "YP002",
	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,
						},
					}
				},
			]
		},
		// 生物样品移交记录表信息
		swypyjInfoFormConfig() {
			return [
				{
					type: "cellItem",
					config: {
						qxbd: {
							span:1,
							label: 'template.yp.yp002.qxbd',
							type: 'qxbd',
							fillType: 'actFill',
							filledCodes:['bdmc','bdbh'],
						},
					}
				},
			]
		},
		// 样品接收信息
		ypjsInfoFormConfig() {
			return [
				{
					type: "cellItem",
					label: 'template.yp.yp002.jsdd',
					config: {
						jsdd: {
							span:1,
							label: 'template.yp.yp002.jsdd',
							type: 'input',
							fillType: 'actFill',
							maxlength: 200
						},
					}
				},
				{
					type: "conditionItem",
					label: 'template.yp.yp002.jsscftj',
					config: {
						jsscftj: {
							label: 'template.yp.yp002.jsscftj',
							type: 'select',
							multiple: true,
							fillType: 'actFill',
							options: this.getDictOptions('business_cftj'),
							otherCode: 'jsscftjOther',
						},
					}
				},
				{
					type: "cellItem",
					label: 'template.yp.yp002.jssj',
					config: {
						jssj: {
							label: 'template.yp.yp002.jssj',
							type: 'input',
							fillType: 'actFill',
							maxlength: 200,
							subType:"button",
							subKey:"jssjButton",
							buttonName:"获取时间"
						},
					}
				},
				{
					type: "cellItem",
					label: 'template.yp.yp002.jsqk',
					config: {
						mcysl: {
							label: 'template.yp.yp002.mcysl',
							type: 'radioAndOther',
							fillType: 'actFill',
							span:1,
							otherCode:'mcyslOther',
							options:[
								{label:'一致',value:'一致'},
								{label:'不一致',value:'不一致'},
							]
						},
						ypgzk: {
							label: 'template.yp.yp002.ypgzk',
							type: 'radioAndOther',
							fillType: 'actFill',
							span:1,
							otherCode:'ypgzkOther',
							options:[
								{label:'正常',value:'正常'},
								{label:'异常',value:'异常'},
							]
						},
						zyhxx: {
							label: 'template.yp.yp002.zyhxx',
							type: 'radioAndOther',
							fillType: 'actFill',
							span:1,
							otherCode:'zyhxxOther',
							options:[
								{label:'空转运盒',value:'空转运盒'},
								{label:'给药组转运盒',value:'给药组转运盒'},
								{label:'其他',value:'其他'},
							]
						},
					}
				},
			]
		},
	},
	data() {
		return {
			formData: {},
		};
	},
	mounted() {
	},
	methods: {
		// 点击按钮
		handleClickButton(item,signData){
			this.$refs.ypjsInfoRef.updateFormData("jssj", moment().format("YYYY/MM/DD HH:mm"),{isUpdateRecord:true,signData});
		},
		//获取已填写的表单数据
		getFilledFormData() {
			const baseData = this.$refs.baseInfoRef.getFilledFormData();
			const swypyjData = this.$refs.swypyjInfoRef.getFilledFormData();
			const ypjsData = this.$refs.ypjsInfoRef.getFilledFormData();
			const remarkData = this.$refs.remarkRef.getFilledFormData();

			return {
				...baseData,
				...swypyjData,
				...ypjsData,
				...remarkData,
			}
		},
		//获取填写完成的表单数据
		async getFormData() {
			//先校验再获取值
			const validFlag = await this.validFields();
			if (!validFlag) {
				return false;
			}
			let content = this.getFilledFormData();
			return content
		},
		//只做校验
		async validFields() {
			// 构建需要验证的引用数组
			let refsToValidate = ["baseInfoRef", "swypyjInfoRef", "ypjsInfoRef", "remarkRef"];
			return await this.validFormFields(refsToValidate);
		},
		getResource() {
			let content = this.getFilledFormData();
			//使用的试剂、仪器
			this.resourceTmp =  []
			this.yqResourceTmp = []
			return this.resourceTmp;
		},
		// onRegentSubmit(val,val1,val2){
		// 	debugger
		// },
		// beforeReagentSubmit(val,val1,val2){
		// 	debugger
		// },
		//保存
		async onSave() {
			const formData = this.getStepResource();
			console.log(formData, "formData")
		},
	}
};
</script>
<style rel="stylesheet/scss" lang="scss">
.mt-20 {
	margin-top: 20px;
}

.print-btn {
	margin-bottom: 20px;
}
.config-header-end {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	margin-bottom: 15px;
	font-weight: bold;
	font-size: 16px;
	color: #303133;
}
</style>