<template>
	<view class="page-box-bg-fff m-t20 r-30 p-30">
		<StatisticsTitle :genre="genre" :leftText="leftText" :rightText="'全部'" @onHandle="onHandle"></StatisticsTitle>
		<view class="row-justify-c m-b25">
			<view class="subsection">
				<uv-subsection :list="list" :bgColor="'#DBE8DB'" :activeColor="'#0FB160'" :inactiveColor="'#121212'"
					:fontSize="14" custom-style="height: 70rpx;border-radius: 30rpx;"
					custom-item-style="border-radius: 30rpx;" :current="current" @change="onChange"></uv-subsection>
			</view>
		</view>
		<view class="" v-if="current == 0">
			<view class="sys-from-background-color m-b16 r-20 p-20 finance_item sys-weight-400"
				v-for="(item,index) in businessList" :key="index">
				<view class="">
					<view class="row-justify-sb center">
						<view class="row-c">
							<text class="size-26 text-color-666">客户：</text>
							<text class="size-26 text-color-12 sys-weight-500">{{item.name}}</text>
						</view>
						<view class="row-c">
							<text class="size-24 text-color-666">客户经理：</text>
							<text class="size-26 text-color-12sys-weight-500">{{item.user_name}}</text>
						</view>
					</view>
					<view class="page-box-bg-fff row-justify-sb center size-24 p-tb16 p-lr40 r-20 m-t20">
						<text class="text-color-E21 sys-weight-600">{{item.total_money}}万</text>
						<text>{{item.status_str}}</text>
						<view class="">
							<text class="text-color-12">{{item.use_date}}</text>
							<text class="text-color-666">用款</text>
						</view>
					</view>
				</view>
			</view>
			<en-blank v-if="businessList.length<=0"></en-blank>
		</view>
    <view v-else>
      <view class="finance_item sys-from-background-color m-b16 r-20 p-30 row-justify-sb center"
            v-for="(item,index) in useList" :key="index" >
        <text class="size-28 text-color-12">{{item.name}}</text>
        <text class="size-28 text-color-E21 sys-weight-600 m-r10">{{item.total_money}}万</text>
        <view class="size-24">
          <text class="text-color-000">{{item.use_date}}</text>
          <text class="text-color-666">用款</text>
        </view>
      </view>
      <en-blank v-if="useList.length<=0"></en-blank>
    </view>

	</view>
</template>

<script>
	import PeakChart from "@/common/chart/peak_chart.vue";
	import StatisticsTitle from "./statistics_title.vue";
	import StatRanking from "./stat_ranking.vue";
	import {
		getBusinessList,
		getUseList
	} from "@/api/statistics";
	import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";

	export default {
		name: 'stat_situation',
		components: {
			EnBlank,
			PeakChart,
			StatisticsTitle,
			StatRanking
		},
		props: {
			type: {
				type: Number,
				default: 1
			},
			genre: {
				type: Number,
				default: 3
			},
			leftText: {
				type: String,
				default: '情况说明'
			},
			'dateTypeObj': {
				default: () => {
					return {
						dateType: 4,
						selectDate: '2023-02-25',
						money_type: 1,
						censusUserType: 0,
						product_id: 5,
					}
				}
			},
		},
		data() {
			return {
				list: ['到访情况', '预计出款'],
				current: 0,
				useNum: 0,
				usePage: 1,
				useList: [],
				businessNum: 0,
				businessPage: 1,
				businessList: [],
			};
		},
		methods: {
			onChange(e) {
				this.current = e
				this.startList()
			},
			startList() {
				if (this.dateTypeObj.censusUserType > 0) {
					if (this.current === 0) {
						this.getBusinessList()
					} else {
						this.getUseList()
					}
				}
			},
			// 到访记录
			getBusinessList() {
				this.dateTypeObj.page = 1
				getBusinessList(this.dateTypeObj).then((res) => {
					if (res.code === 1) {
						this.businessNum = res.data.totalNum
						this.businessList = res.data.items
					}
				})
			},
			// 预计出款
			getUseList() {
				this.dateTypeObj.page = 1
				getUseList(this.dateTypeObj).then((res) => {
          if(res.code===1){
            this.useNum = res.data.totalNum
            this.useList = res.data.items
          }


				})
			},

		},
	}
</script>

<style lang="scss" scoped>
	.subsection {
		width: 350rpx;
	}

	.finance_item:last-child {
		margin-bottom: 0;
	}
</style>