<template>
	<view class="receivable_records">
		<view class="receivable_head">
			<view class="box">
				<view class="head_item" style="margin-top: 43rpx;">
					<view>订单总金额</view>
					<view>&yen; {{info.contract_moneys ? info.contract_moneys : '0'}}</view>
				</view>
				<view class="head_item" style="margin-top: 43rpx;">
					<view>已回款金额</view>
					<view>&yen; {{info.receivables_moneys ? info.receivables_moneys : '0'}}</view>
				</view>
				<view class="head_item" v-if="info.no_moneys >= 0">
					<view>未回款金额</view>
					<view>&yen; {{info.no_moneys ? info.no_moneys : '0'}}</view>
				</view>
				<view class="head_item" v-else>
					<view>超额回款金额</view>
					<view>&yen; {{info.no_moneys ? -info.no_moneys : '0'}}</view>
				</view>
				<view class="head_item">
					<view>计划回款金额</view>
					<view>&yen; {{info.plan_moneys ? info.plan_moneys : '0'}}</view>
				</view>
			</view>
		</view>
		
		<view class="receivable_content">
			<view class="con_item" v-for="(item,index) in list" :key="index">
				<view class="item_head" v-if="roleType == 1">
					<view>{{item.name ? item.name : '--'}}</view>
				</view>
				<view class="item_head" v-if="roleType != 1">
					<view>{{item.date ? item.date : '--'}}</view>
				</view>
				<view class="item_body">
					<view class="body_style">计划回款金额： <text>&yen; {{item.plan ? item.plan : '0'}}</text></view>
					<view class="body_style">已回款金额： <text> &yen; {{item.receivables ? item.receivables : '0'}}</text></view>
					<view class="body_style" style="padding-bottom: 33rpx;">未回款金额： <text> &yen; {{item.no ? item.no : '0'}}</text></view>
				</view>
			</view>
			<view style="height: 200rpx;"></view>
			<u-empty v-if="list.length == 0" text="暂无更多"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		netGetreceivableStaff,
		netGetOthersReceivable
	} from '@/api/kehu.js'

	export default {
		data() {
			return {
				roleType: 2,
				info: {},
				list: [],
			}
		},
		onShow() {
			this.roleType = uni.getStorageSync('roleType')
			if (this.roleType == 1) {
				//其他
				this.getOtherList()
			} else {
				//员工
				this.getStafflist()
			}
		},
		methods: {
			getStafflist() {
				netGetreceivableStaff().then(res => {
					this.info = res.data
					this.list = res.data.data
				})
			},
			getOtherList() {
				netGetOthersReceivable().then(res => {
					this.info = res.data
					this.list = res.data.data
				})
			}
		}
	}
</script>

<style lang="scss">
	.receivable_head {
		background-color: #fff;
		margin-top: 5rpx;
		text-align: center;
		padding: 0 0 10rpx 0;
		margin-bottom: 20rpx;

		.box {
			width: 690rpx;
			height: 300rpx;
			background: $uni-text-color;
			margin: 20rpx auto;
			display: flex;
			flex-wrap: wrap;
			border-radius:20rpx ;
		}

		.head_item {
			width: 50%;
			color: #fff;
			:first-child {
				font-size: 30rpx;
				color: #fff;
			}
			:last-child{
				color: #FFFFFF;
				font-size: 34rpx;
				font-weight: 600;
				margin-top: 15rpx;
			}

			:last-child {
				font-size: 28rpx;
			}
		}
	}

	.receivable_content {
		.con_item {
			margin-bottom: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;

			.item_head {
				display: flex;
				justify-content: space-between;
				border-bottom: 1rpx solid #ededed;
				padding: 20rpx 62rpx;

				:first-child {
					font-size: 32rpx;
					color: #999;
					font-weight: 700;
				}
			}

			.item_body {
				padding-left: 62rpx;
				.body_style {
					padding-top: 35rpx;
					color: #999;
					font-size: 32rpx;
					text {
						color: #333;
						float: right;
						margin-right: 30rpx;
						font-size: 32rpx;
						font-weight: 600;
					}
				}
			}
		}
	}

	.button_bottom {
		display: flex;
		position: fixed;
		width: 100%;
		height: 100rpx;
		background-color: #fff;
		bottom: 0;
		right: 0;
		left: 0;
		text-align: center;
		padding-top: 10rpx;
		color: #999;

		:first-child {
			flex: 1;
		}

		:last-child {
			flex: 1;
		}

		.icon-follow {
			margin-top: 8rpx;
		}
	}
</style>
