<template name="task">
	<view class="content">
	<u-form :model="form" ref="uForm">
			<u-form-item label-width='260' label="合同编号">
				<view @click="show = true">{{list.contractNo?list.contractNo:'请选择合同编号'}}</view>
				<u-select v-model="show" mode="single-column" :list="contractNoList" @confirm="confirm"></u-select>
			</u-form-item>
			<u-form-item label-width='260' label="采购计划">
				{{list.procurementPlan}}
			</u-form-item>
			<u-form-item label-width='260' label="客户">
				{{list.seller}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="现货"' label-width='260' label="单价(元/吨)">
				<u-input v-model="list.unitPrice" />
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="基差(元/吨)">
				{{basis}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="冻结定金(元)">
				{{list.freezingDeposit}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="拖欠定金(元)">
				{{list.defaultDeposit}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="卸车费(元/吨)">
				{{list.unloadingCharge}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="发票费(元/吨)">
				{{list.invoiceFee}}
			</u-form-item>
			<u-form-item label-width='260' label="合同重量(吨)">
				{{list.transactionsNumber}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="已入库量(吨)">
				{{list.stockInQuantity}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="可平仓量(吨)">
				{{list.openPosition}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="已平仓量(吨)">
				{{list.closedPosition}}
			</u-form-item>
			<u-form-item v-if='list.procurementPlanType=="期货"' label-width='260' label="已成交量(吨)">
				{{list.cumulativeTurnover}}
			</u-form-item>
			<u-form-item  label-width='260' label="发票类型">
				{{list.type}}
			</u-form-item>
			<u-form-item  label-width='260' label="包装方式">
				{{list.packingType}}
			</u-form-item>
			<u-form-item label-width='260' label="状态">
				{{list.status}}
			</u-form-item>
			<u-form-item  label-width='260' label="更新时间">
				{{list.updateDate}}
			</u-form-item>
		</u-form>
		<view style='padding:10px;' class='flex'><u-button v-if='list.status=="待审核"' @click='audit' type="success">审核</u-button></view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		name: "task",
		
		data() {
			return {
				show:false,
				id:0,
				form: {
					name: '',
					intro: '',
					sex: ''
				},
				list:{},
				radio: '',
				pcUserInfo:uni.getStorageSync('pcUserInfo'),
				switchVal: false,
				contractNoList:[]
			};
		},
		computed: {
			...mapState(['hasLogin', 'userInfo'])
		},
		onLoad(options){
			console.log(options)
			this.id=options.id
		},
		onShow() {
			var that=this
			this.$nextTick(function(){
				that.getData()
			})
			
			// this.userInfo =  uni.getStorageSync("userInfo")
		},
		onReachBottom() { //上拉触底函数
			if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
				this.warehouseInOutInfo.currentPage += 1
				this.Data()
			}
		},
		methods: {
			getData(){
				var data=[]
				this.$api.doRequest('get', '/warehouseBaseInfo/selectContractNoList', 
				{compId:this.pcUserInfo.compId,flag:3}).then(res => {
					if(res.data.code==200){
						for(var i=0;i<res.data.data.length;i++){
							data.push({value:res.data.data[i].contractNo,label:res.data.data[i].contractNo})
						}
						this.contractNoList=data
					}
				})
				this.$api.doRequest('get', '/purchaseOrder/getInfo', {id:this.id}).then(res => {
					if(res.data.code==200){
						this.list=res.data.data
					}
					})
			},
			confirm(item){
				this.list.contractNo=item[0].value
			},
			audit(){
				var that=this
				uni.showModal({
					content: "审核通过后，将通知客户订单生效，是否确定通过审核？",
					showCancel: true,
					confirmText: '提交',
					success: function(res) {
						if (res.confirm) {
							that.$api.doRequest('post', '/purchaseOrder/api/editPurchaseOrder', that.list).then(res => {
								if (res.data.code == 200) {
									that.$api.doRequest('post', '/workflow/api/handle', {
										taskId:that.list.taskId,
										approved: true,
										auditMind: '34',
										needReapply: false,
										}).then(res1 => {
										if (res1.data.code == 200) {
											that.$api.msg('审核成功');
											that.$nextTick(function(){
												uni.navigateBack(-1)
											})
										}else{
											that.$api.msg(res1.data.message);
										}
									})
								}else{
									that.$api.msg(res.data.message);
								}
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background: #fff;
	}
	.content{
		padding:10px;
	}
</style>
