<template>
	<view class="">
		<u-sticky offset-top="50">
			<u-subsection fontSize='25' mode='subsection' :list="list" :current="curNow" @change="sectionChange"
				activeColor='#157A2C'></u-subsection>
		</u-sticky>

		<view v-show="curNow===0">
			<u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='140rpx'>
				<u-form-item label="收货单编码" prop="receiveNo" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.receiveNo"></u--input>
				</u-form-item>
				<u-form-item label="订单编码" prop="orderNo" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.orderNo"></u--input>
				</u-form-item>
				<u-form-item label="制单人" prop="makerName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.makerName"></u--input>
				</u-form-item>
				<u-form-item label="供应商名称" prop="supplierName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.supplierName"></u--input>
				</u-form-item>
				<u-form-item label="供应商联系人" prop="linkName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.linkName"></u--input>
				</u-form-item>
				<u-form-item label="供应商电话" prop="linkPhone" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.linkPhone"></u--input>
				</u-form-item>
				<u-form-item label="需求类型" prop="sourceTypeName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.sourceTypeName"></u--input>
				</u-form-item>
			</u--form>

		</view>
		<view v-show="curNow===1">
			<!-- <u-sticky offset-top="100">
				<u-tag :text="`总计: ${form.totalAmount.toFixed(2)} 应付金额: ${form.payAmount.toFixed(2)}`" size="large"
					type="success"></u-tag>
			</u-sticky> -->
			<view v-for="(item,index) in form['productList']" :key="index">
				<u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='140rpx'>
					<u-row v-for="(key,index1) in tableField" :key="index1">
						<u-col :span="12">
							<u-form-item :label="key.label" prop="categoryName" borderBottom>
								<u--input style="width: 100%;" :title='item[key.field]' disabled
									v-model="item[key.field]"></u--input>
							</u-form-item>
						</u-col>

					</u-row>
				</u--form>
				<u-gap height="40" bgColor="#f0f0f0"></u-gap>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		purchaseOrderReceiveGetByIdAPI
	} from '@/api/wt/index.js'
	export default {
		props: {
			businessId: {
				default: ''
			},
			taskDefinitionKey: {
				default: ''
			},
		},
		data() {
			return {
				form: {},
				tableField: [{
						label: '名称',
						field: 'productName',
					},
					{
						label: '编码',
						field: 'productCode',
					},
					{
						label: '类型',
						field: 'productCategoryName',
					},
					{
						label: '规格',
						field: 'specification',
					},
					{
						label: '仓库名称',
						field: 'warehouseName',
					},
					{
						label: '单价',
						field: 'singlePrice',
					},
					{
						label: '进货数量',
						field: 'totalCount',
					},

					{
						label: '合计',
						field: 'totalPrice',
					},
				],
				list: ['收货信息', '产品清单'],
				curNow: 0
			}
		},
		async mounted() {
			await this.getDetailData(this.businessId);
		},
		methods: {
			sectionChange(index) {
				this.curNow = index;
			},
			async getDetailData(id) {
				const data = await purchaseOrderReceiveGetByIdAPI(id);
				this.form = data;
			},
			//
			getTableValue() {
				return new Promise(async (resolve, reject) => {
					try {
						await this.$refs.uForm[0].validate()
						resolve(this.form)
					} catch(e) {
						reject(e)
					}


				})
			},
		}
	}
</script>

<style>
</style>