<template>
	<view class="container">
		<view class="content">
			<view class="top">
				<view>合同编号</view>
				<view>123456796</view>
			</view>
			<view class="car-container" v-for="(item,index) in list">
				<view class="car-num title">{{item.carNo}}({{item.tranCarNo}})</view>
				<view class="car-type-item">
					<view class="left">装</view>
					<view class="left">{{item.loadingWeight}}吨</view>
				</view>
				<view class="car-type-item">
					<view class="left">卸</view>
					<view class="left">{{item.unloadingWeight}}吨</view>
				</view>
				<view class="car-type-item">
					<view class="left">结</view>
					<view class="left">{{item.settlementWeightchange}}吨</view>
				</view>
				<view class="car-type-item">
					<view class="left">运</view>
					<view class="left">{{item.transportPrice}}元/吨</view>
				</view>
				<view class="car-type-item">
					<view class="left">扣</view>
					<view class="left">{{item.deductionAmountchange}}元</view>
				</view>
				<view class="car-type-item">
					<view class="left">付</view>
					<view class="left">{{item.amountEdPayable}}元</view>
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
		<view class="bottom-btn">
			<u-button type="primary" class="submit" hover-class="none" @click="rejectSubmit()">驳回</u-button>
			<u-button type="primary" class="submit" hover-class="none" @click="passSubmit()">通过</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				currentPage: 1,
				pageSize: 10,
				list: [],

			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList() {
				this.$api.doRequest('get', '/tranSettlementReport/selectTranSettlementReport', {
					compId: "2710b21efc1e4393930c5dc800010dc4",
					currentPage: this.currentPage,
					pageSize: this.pageSize,
					contractNo: "全部合同"
				}).then(res => {
					if (res.data.code == 200) {
						this.list = res.data.data.records
					}
				})
			},
			// 驳回
			rejectSubmit() {
				if (this.list.length == 0) {
					this.$message.success('没有要审核的条目！')
				} else {
					uni.showModal({
						content: "是否确定驳回?",
						showCancel: true,
						confirmText: '确定',
						success: function(res) {
							if (res.confirm) {
								this.audit(this.list[0], 0, false, true, '已驳回')
							}
						}
					})
				}
			},
			//通过
			passSubmit() {
				if (this.list.length == 0) {
					this.$message.success('没有要审核的条目！')
				} else {
					uni.showModal({
						content: "是否确定通过?",
						showCancel: true,
						confirmText: '确定',
						success: function(res) {
							if (res.confirm) {
								this.a(0)
								// this.audit(this.list[0], 0, true, 2)
							}
						}
					})
				}
			},
			a(ing){
				console.log(ing)
			},
			//审核方法
			audit(item, index, status, status2, reason) {
				if (index < this.list.length) {
					this.$api.doRequest('post', '/workflow/api/handle', {
						taskId: item.taskId,
						approved: status,
						auditMind: reason != undefined ? '已驳回' : '34',
						needReapply: status2 != undefined ? true : false,
					}).then(res => {
						this.audit(this.list[index + 1], index + 1, status)
					})
				} else {
					if (status == true) {
						this.$message.success('通过成功')
						this.getList()
					} else if (status == false) {
						this.$message.success('驳回成功')
						this.getList()
					}
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.container {
		margin: 10rpx;
		padding: 20rpx 20rpx 140rpx 20rpx;
		border-radius: 20rpx;
		background: white;
	}

	.content {
		.top {
			display: flex;
			justify-content: space-between;
		}

		.title {
			font-size: 28rpx;
			font-weight: 600;
			color: #333333;
			text-align: left;
		}

		.car-type-item {
			display: inline-flex;
			// justify-content: center;
			width: 33.33%;
		}
	}

	.bottom-btn {
		width: 92%;
		position: fixed;
		bottom: 40rpx;
		display: flex;
		z-index: 2;
	}

	.submit {
		width: 40%;
		background: #22C572;
		border-radius: 10rpx;
	}
</style>
