<template>
	<view>
		<view class="box">
			<view class="top" style="margin-top: -1rpx;">
				<text class="title">其他业务</text>
			</view>
			<view class="add" @click="addFn">+添加</view>
		</view>
		<view class="card-box">
			<view class="card" v-for="(businessItem,index) in businessItemList" :key="index">
				<view class="t">
					<image class="icon" src="../../static/home-icon-01.png"></image>
					<text class="title">{{businessItem.customerName}}</text>
				</view>
				<view style="line-height: 60rpx;">
					<view class="title">录入时间：{{businessItem.createTime}}</view>
					<view class="title">订单号：{{businessItem.no}}</view>
				</view>

				<view class="c">
					<view class="item car-num-item">
						<text class="car-num">{{businessItem.carNoStr}}</text>
					</view>

					<view class="item">
						<text class="p1">业务项:</text>
						<text class="p2">{{businessItem.goodsName}}</text>
					</view>
					<view class="item">
						<text class="p1">载重(kg):</text>
						<text class="p2">
							<text v-if="businessItem.netWeight">{{businessItem.netWeight}}</text>
							<text>空车</text>
						</text>
					</view>
					<view class="item">
						<text class="p1">账单确认:</text>
						<text class="p2">
							<text v-if="businessItem.confirmInput==0">未确认</text>
							<text v-else>已确认</text>
						</text>
					</view>
					<view class="item">
						<text class="p1">支付状态:</text>
						<text class="p2">
							<text v-if="businessItem.payStatus==1">未支付</text>
							<!-- <text v-if="businessItem.payStatus==2">已支付(未确认)</text> -->
							<text v-if="businessItem.payStatus==3">已支付</text>
						</text>
					</view>
				</view>
				<view class="b">
					<view class="btn b3" v-if="businessItem.adminConfirmInput==0
								&&perList.indexOf('tb-flex-business-confirm')!=-1" @click="sureZdFn(businessItem)">
						账单确认</view>
					<view class="btn b3" @click="toDetail(businessItem)">详情</view>
					<view class="btn b1"
						v-if="businessItem.adminConfirmInput==0&&perList.indexOf('tb-flex-business-edit')!==-1"
						@click="editFn(businessItem)">修改</view>
					<view class="btn b4" v-if="businessItem.adminConfirmInput==0
								&&perList.indexOf('tb-business-del')!==-1" @click="deleteFn(businessItem)">删除</view>
				</view>
			</view>
		</view>
		<noData v-if="businessItemList.length==0"></noData>
		<u-loadmore style="margin: 30rpx;" :status="status" />

	</view>
</template>

<script>
	export default {
		data() {
			return {
				p: {
					adminConfirmInput: -1,
					pageNo: 1,
					pageSize: 3,
					dataCount: 0
				},
				customemrId: '1',
				fk: {
					ids: '',
				},
				rc: {
					id: '',
					inChannel: '',
					showTime: false,
					visible: false,
					realInTime: ''
				},
				current: 0,
				status: 'loadmore',
				page: 0,
				tabs: [{
					name: '进场',
				}, {
					name: '出场',
				}],
				businessItemList: [],
				perList: []
			}
		},
		onShow() {
			this.customemrId = uni.getStorageSync('customerId')
			this.getBusinessList();
			this.perList = uni.getStorageSync('perList')
		},
		mounted() {},
		onBackPress() {
			this.$common.to('/pages/index/index')
			return true;
		},
		methods: {
			addFn() {
				this.$common.to('/pages/onely-disinfect/disinfect-Index')
			},
			toDetail(data) {
				this.$common.to('/pages/onely-disinfect/type-business-info?id=' + data.id)
			},
			editFn(data) {
				this.$api.getGoodsById({
					id: data.goodsId
				}).then(resp => {
					let goods = resp.data;
					this.$common.to('/pages/onely-disinfect/type-business-edit?id=' + data.id+'&goodsJson='+JSON.stringify(goods))
				})
			},
			deleteFn(data) {
				let that = this;
				uni.showModal({
					title: "警告",
					content: "是否删除该业务？",
					success(res) {
						if (res.confirm) {
							that.$api.deleteOtherBusiness({
								id: data.id
							}).then(resp => {
								that.$common.toast('已删除');
								that.getBusinessList();
							})
						}
					}
				})
			},
			sureZdFn(data) {
				this.$common.to('/pages/wx/payOrderTemp?id=' + data.id)
			},
			getBusinessList() {
				this.$api.getOtherBusiness(this.p).then(resp => {
					this.status = 'loadmore';
					this.p.pageNo = resp.pageNo;
					this.p.pageSize = resp.pageSize;
					this.p.dataCount = resp.dataCount;
					this.businessItemList = resp.data;
				})
			},
			//点击上方切换栏，根据点击项重新加载数据
			change(index) {
				this.current = index;
				if (index == 0) {
					//只加载进场订单
				}
				if (index == 1) {
					//只加载出场订单
				}
			},
			//点击按钮
			//------------------------------------------

			fkconfirm() {
				this.$api.adminConfirmPay(this.fk).then(resp => {
					this.$refs.fkpopup.close();
					this.getBusinessList();
				})
			},

			rcconfirm() {
				if (!this.rc.inChannel) {
					this.$common.toast('请填写入场通道');
					return false;
				}
				this.$api.adminConfirmIn(this.rc).then(resp => {
					this.$refs.rcpopup.close();
					this.getBusinessList();
				})
			},

			ccconfirm(index) {
				this.$refs.ccpopup.close()
			},
			zd() {
				this.$refs.zdpopup.open('center')
			},
			zdconfirm(index) {
				this.$refs.zdpopup.close()
			},
			//------------------------------------------
			//上拉加载更多，分页模拟数据
			onReachBottom() {
				if (parseInt(this.p.dataCount) > parseInt(this.p.pageSize) * parseInt(this.p.pageNo)) {
					this.status = 'loading';
					this.p.pageSize += 5;
					this.getBusinessList();
				} else {
					this.status = 'nomore';
				}
			}
		}
	}
</script>

<style lang="scss">
	.add {
		position: absolute;
		right: 40rpx;
		top: -60rpx;
		z-index: 999;
		border: 1rpx solid #359aff;
		border-radius: 8rpx;
		color: #c8e4ff;
		padding: 10rpx 20rpx;
		font-size: 28rpx;
	}

	.card-box {
		display: flex;
		width: 100%;
		flex-direction: column;

		.card {
			background-color: #fff;
			border-radius: 20rpx;
			margin: 20rpx 20rpx 0 20rpx;
			padding: 30rpx;
			box-sizing: border-box;
			display: flex;
			flex-direction: column;

			.t {
				width: 100%;
				display: flex;
				align-items: center;
				padding-bottom: 30rpx;
				border-bottom: 1rpx solid #f5f5f5;

				.icon {
					width: 40rpx;
					height: 40rpx;
				}

				.title {
					font-size: 30rpx;
					font-weight: bold;
					margin-left: 20rpx;
				}
			}

			.c {
				padding: 15rpx 0 30rpx 0;
				display: flex;
				flex-wrap: wrap;
				border-bottom: 1rpx solid #f5f5f5;

				.item {
					width: 50%;
					padding: 20rpx 0;

					.car-num {
						background-color: #edf6ff;
						color: #0080ff;
						font-size: 44rpx;
						padding: 15rpx 0;
						text-align: center;
						width: 100%;
						border-radius: 10rpx;
						font-weight: bold;
					}

					.p1 {
						font-size: 28rpx;
						color: #999;
					}

					.p2 {
						font-size: 28rpx;
						color: #191919;
						font-weight: bold;
						margin-left: 20rpx;
					}
				}

				.car-num-item {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}

			.b {
				display: flex;
				width: 100%;
				align-items: center;
				justify-content: space-between;

				.btn {
					height: 70rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: calc(50% - 15rpx);
					margin: 30rpx 0 0 0;
					border-radius: 10rpx;
					border-width: 1rpx;
					box-sizing: border-box;
				}

				.b1 {
					background-color: #0080ff;
					color: #fff;
				}

				.b2 {
					background-color: #f7f7f7;
					color: #191919;
				}

				.b3 {
					background-color: #fff;
					color: #0080ff;
					border: 1rpx solid #0080ff;
				}

				.b4 {
					background-color: #ff0000;
					color: #fff;
				}
			}
		}
	}

	@import '@/common/common.scss'
</style>
