<template name="task">
	<view class="content">
	<u-form :model="form" ref="uForm">
			<u-form-item label-width='260' label="合同编号">
				{{list.contractNo}}
			</u-form-item>
			<u-form-item label-width='260' label="平仓日期">
				{{list.closePositionDate}}
			</u-form-item>
			<u-form-item label-width='260' label="平仓数量">
				{{list.closingQuantity}}
			</u-form-item>
			<u-form-item label-width='260' label="成交价格">
				{{ list.transactionPrice }}
			</u-form-item>
			<u-form-item label-width='260' label="平仓价格(元/吨)">
				{{list.closeRate}}
			</u-form-item>
			<u-form-item label-width='260' label="基差(元/吨)">
				{{list.basisPrice}}
			</u-form-item>
			<u-form-item label-width='260' label="应付金额(元)">
				{{list.amountIngPayable}}
			</u-form-item>
			<u-form-item label-width='260' label="已付金额(元)">
				{{list.amountEdPayable}}
			</u-form-item>
			<u-form-item label-width='260' label="未付金额(元)">
				{{list.amountNotPayable}}
			</u-form-item>
			<u-form-item label-width='260' label="付款日期">
				{{list.paymentDate}}
			</u-form-item>
			<u-form-item label-width='260' label="应收金额(元)">
				{{list.collectionIngPayable}}
			</u-form-item>
			<u-form-item label-width='260' label="已收金额(元)">
				{{list.collectionEdPayable}}
			</u-form-item>
			<u-form-item label-width='260' label="未收金额(元)">
				{{list.collectionNotPayable}}
			</u-form-item>
			<u-form-item label-width='260' label="收款日期">
				{{list.collectionDate}}
			</u-form-item>
			<u-form-item  label-width='260' label="客户">
				{{list.customerName}}
			</u-form-item>
			<u-form-item  label-width='260' label="库点">
				{{list.warehouseName}}
			</u-form-item>
			<u-form-item  label-width='260' label="状态">
				<view v-if='list.approveStatus!=null'>
					{{list.approveStatus}}
				</view>
				<view v-else>{{list.status}}</view>
			</u-form-item>
		</u-form>
		<view style='padding:10px;' class='flex'>
			<u-button v-if='list.status=="未审核"' @click='reject' type="error">驳回</u-button>
			<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")
		},
		methods: {
			getData(){
				var data=[]
				this.$api.doRequest('get', '/salesClosingReport/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', '/newWorkflow/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()
													})
												}else{
													that.$api.msg(res1.data.message);
												}
											})
										}
									}
							})
						},
						reject(){
							var that=this
							uni.showModal({
								content: "是否确定驳回？",
								showCancel: true,
								confirmText: '提交',
								success: function(res) {
									if (res.confirm) {
										that.$api.doRequest('post', '/newWorkflow/api/handle', {
											taskId:that.list.taskId,
											approved: false,
											auditMind: '已驳回',
											needReapply: true,
											}).then(res1 => {
												if (res1.data.code == 200) {
													that.$api.msg('驳回成功');
													that.$nextTick(function(){
														uni.navigateBack()
													})
												}else{
													that.$api.msg('系统异常，请联系管理员');
												}
											}).catch()
										}
									}
							})
						}
		}
	}
</script>

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