<template>
	<view>
		<uni-collapse>
			<uni-forms ref="form" :modelValue="formData">
				<uni-collapse-item title="不良记录单" :open="true">
					<uni-forms-item label="记录单编码" :labelWidth='90' name="pwoRecordCode">
						<uni-easyinput v-model="formData.pwoRecordCode" />
					</uni-forms-item>
					<uni-forms-item label="记录单名称" :labelWidth='90' name="pwoRecordName">
						<uni-easyinput v-model="formData.pwoRecordName" />
					</uni-forms-item>
				</uni-collapse-item>
				<uni-collapse-item title="不良记录单明细" :open="true">
					<uni-swipe-action>
						<uni-swipe-action-item :key="index" v-for="(item, index) in formData.mesPwoRecordDetailList">
							<uni-badge :text="index+1" type="primary"></uni-badge>
							<uni-forms-item label="作业编码" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.pwoJobCode"></uni-easyinput>
							</uni-forms-item>
							<uni-forms-item label="维修工单" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.pwoCode"></uni-easyinput>
							</uni-forms-item>
							<uni-forms-item label="制程" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.opCode" />
							</uni-forms-item>
							<uni-forms-item label="维修产品编码" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.ptNoTar" />
							</uni-forms-item>
							<uni-forms-item label="维修产品名称" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.ptTitleTar" />
							</uni-forms-item>
							<uni-forms-item label="物料规格" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.specification1" />
							</uni-forms-item>
							<uni-forms-item label="记录人员" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.empCode" />
							</uni-forms-item>
							<uni-forms-item label="不良原因" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.defectReason" />
							</uni-forms-item>
							<uni-forms-item label="维修数量" :labelWidth='90'>
								<uni-easyinput type="number" v-model="item.dataInfo.number" />
							</uni-forms-item>
							<uni-forms-item label="维修时间" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.dateTime" />
							</uni-forms-item>
							<uni-forms-item label="设备" :labelWidth='90'>
								<uni-easyinput disabled type="text" v-model="item.dataInfo.eqpCode" />
							</uni-forms-item>
						</uni-swipe-action-item>
					</uni-swipe-action>
				</uni-collapse-item>
			</uni-forms>
		</uni-collapse>
		<u-button type="primary" @click="submit">提交</u-button>
	</view>
</template>

<script>
	import {
		listMesPwoRecordrecord,
		getMesPwoRecordrecord,
		delMesPwoRecordrecord,
		addMesPwoRecordrecord,
		updateMesPwoRecordrecord
	} from "@/api/mes/mesPwoRecordrecord";
	import {
		listMesPwoRecordDetail,
		getMesPwoRecordDetail,
		delMesPwoRecordDetail,
		addMesPwoRecordDetail,
		updateMesPwoRecordDetail,
	} from "@/api/mes/mesPwoRecordDetail";
	export default {
		onLoad(option) {
			this.formData = JSON.parse(option.formData);
			console.log(this.formData)
		},
		mounted() {},
		data() {
			return {
				formData: {
					pwoRecordCode: null,
					pwoRecordName: null,
					mesPwoRecordDetailList: []
				},
			}
		},
		methods: {
			submit() {
				for (var i in this.formData.mesPwoRecordDetailList) {
					this.formData.mesPwoRecordDetailList[i].dataInfo = JSON.stringify(this.formData.mesPwoRecordDetailList[
						i].dataInfo);
					updateMesPwoRecordDetail(this.formData.mesPwoRecordDetailList[i]).then(res => {
						this.$modal.msgSuccess("修改成功!");
					})
					this.formData.mesPwoRecordDetailList[i].dataInfo = JSON.parse(this.formData.mesPwoRecordDetailList[
						i].dataInfo);
				}

			}
		}
	}
</script>

<style>
</style>