<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'>
				<!-- @tap="showDeptPicker" -->
				<u-form-item label="需求类型" prop="sourceTypeName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.sourceTypeName"></u--input>
				</u-form-item>
				<!-- @tap="showUserPicker" -->
				<u-form-item label="需求单名称" prop="requirementName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.requirementName"></u--input>
					<!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
				</u-form-item>
				<u-form-item label="需求部门" prop="requireDeptName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.requireDeptName"></u--input>
				</u-form-item>
				<u-form-item label="需求人" prop="requireUserName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.requireUserName"></u--input>
				</u-form-item> 
				<u-form-item v-if='form.sourceType==1' label="销售合同" prop="saleContractName" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.saleContractName"></u--input>
				</u-form-item>
				<u-form-item v-if='form.sourceType==1' label="销售订单" prop="saleOrderNo" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.saleOrderNo"></u--input>
				</u-form-item>
				<u-form-item label="是否接受拆单" prop="acceptUnpack" borderBottom>

					<u-tag v-if='form.acceptUnpack==1' text="接受"  size="large" type="success"></u-tag>
					<u-tag v-else-if='form.acceptUnpack==0' text="不接受"  size="large" type="warning"></u-tag>
					<u--input v-else style="width: 100%;" disabled v-model="form.acceptUnpack"></u--input>
				</u-form-item>

				<u-form-item label="用途" prop="useTo" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.useTo"></u--input>
				</u-form-item>
				<u-form-item label="备注" prop="remark" borderBottom>
					<u--input style="width: 100%;" disabled v-model="form.remark"></u--input>
				</u-form-item>
			</u--form>

		</view>
		<view v-show='curNow==1'>
			<view v-for="(item,index) in form['detailList']" :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 {
		getPurchaseRequirementByIdsAPI
	} from '@/api/wt/index.js'
	export default {
		props: {
			businessId: {
				default: ''
			},
			taskDefinitionKey: {
				default: ''
			},
		},
		data() {
			return {
				detailData: {},
				form: {},
				tableField: [{
						label: '名称',
						field: 'productName',
					},
					{
						label: '编码',
						field: 'productCode',
					},
					{
						label: '类型',
						field: 'productCategoryName',
					},
					{
						label: '数量',
						field: 'totalCount',
					},
					{
						label: '单位',
						field: 'measuringUnit',
					},
					{
						label: '品牌',
						field: 'brand',
					},
					{
						label: '型号',
						field: 'modelType',
					},
					{
						label: '规格',
						field: 'specification',
					},
					
				],
				list: ['基本信息', '需求清单'],
				curNow: 0
			}
		},
		async mounted() {
			await this.getDetailData(this.businessId);
		},
		methods: {
			sectionChange(index) {
				this.curNow = index;
			},
			async getDetailData(id) {
				const data = await getPurchaseRequirementByIdsAPI(id);
				this.form = data
			}
		}
	}
</script>

<style>
</style>