<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.goodsName}}
			</u-form-item>
			<u-form-item label-width='260' label="仓位号">
				{{list.positionNumber}}
			</u-form-item>
			<u-form-item label-width='260' label="车牌号">
				{{ list.carNo }}({{ list.tranCarNo }})
			</u-form-item>
			<u-form-item label-width='260' label="入库日期">
				{{list.warehousingDate}}
			</u-form-item>
			<u-form-item label-width='260' label="蛋白(%)>=">
				{{list.protein}}
			</u-form-item>
			<u-form-item label-width='260' label="水分(%)<=">
				{{list.waterContent}}
			</u-form-item>
			<u-form-item label-width='260' label="单价(元/吨)">
				{{list.unitPrice}}
			</u-form-item>
			<u-form-item label-width='260' label="基差(元/吨)">
				{{list.basisPrice}}
			</u-form-item>
			<u-form-item label-width='260' label="卸车费(元/吨)">
				{{list.unloadingCharge}}
			</u-form-item>
			<u-form-item label-width='260' label="发票费(元/吨)">
				{{list.invoiceFee}}
			</u-form-item>
			<u-form-item label-width='260' label="扣款(元/吨)">
				{{list.deductionAmount}}
			</u-form-item>
			<u-form-item label-width='260' label="结算单价(元/吨)">
				{{list.settlementPrice}}
			</u-form-item>
			<u-form-item label-width='260' label="净重(吨)">
				{{list.netWeight}}
			</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.carryForward}}
			</u-form-item>
			<u-form-item  label-width='260' label="客户确认">
				{{list.customerConfirmationStatus}}
			</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="发票类型">
				{{list.invoiceType}}
			</u-form-item>
			<u-form-item label-width='260' label="已开发票(元)">
				{{list.alreadyInvoice}}
			</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', '/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', '/salesDeliveryReport/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', '/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()
										})
									}else{
										that.$api.msg('系统异常，请联系管理员');
									}
								})
							}
						}
				})
			},
			reject(){
				var that=this
				uni.showModal({
					content: "是否确定驳回？",
					showCancel: true,
					confirmText: '提交',
					success: function(res) {
						if (res.confirm) {
							that.$api.doRequest('post', '/workflow/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(res1.data.message);
									}
								}).catch()
							}
						}
				})
			}
		}
	}
</script>

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