<template>
	<view class="page-box-bg-fff m-t20 r-30 p-30 finance_content">
		<StatisticsTitle :genre="0" :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="">
			<view class="sys-from-background-color row-justify-sb center m-b16 r-20 p-20 finance_item"
				v-for="(item,index) in dataList" :key="index">
				<view class="row-c">
					<image class="wh-60" src="/static/img/index/index-avatar.png" mode=""></image>
					<view class="column m-l16">
						<text class="size-28 text-color-12 sys-weight-400">{{item.name}}</text>
						<text class="size-24 text-color-8F9 sys-weight-400">{{item.created_at}}</text>
					</view>
				</view>
				<text class="size-28 text-color-12 sys-weight-600">{{item.money}}万</text>
			</view>
      <en-blank v-if="totalNum<=0"></en-blank>
		</view>
	</view>
</template>

<script>
	import StatisticsTitle from "./statistics_title.vue";
  import {getSysMoneyList} from "@/api/statistics";
  import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";

	export default {
		name: 'stat-finance',
    props:{
      'dateTypeObj':{
        default:()=>{
          return {
            dateType:4,
            selectDate:'2023-02-25',
            money_type:1,
            censusUserType:0,
            product_id:5,
          }
        }
      },
      'pageType':{
        default:1
      }
    },
		components: {
      EnBlank,
			StatisticsTitle
		},
    watch:{
      'dateTypeObj':function () {
        if(this.dateTypeObj.censusUserType>0){
          this.startList()
        }
      }
    },
		data() {
			return {
				current: 0,
				list: ['放款', '回款'],
        dataList:[],
        totalNum:0,
        page:1
			};
		},
		methods: {
      onHandle(e){
        console.log(e)
      },
			onChange(e) {
				this.current = e
        this.startList()
			},
      startList(){
        this.dataList=[]
        this.page=1
        this.totalNum=0
        this.getSysMoneyList()
      },
      getSysMoneyList(){
        let fromData = {
          dateType:this.dateTypeObj.dateType,
          selectDate:this.dateTypeObj.selectDate,
          pageNum:this.pageType===1?5:15,
          page:this.page,
          moneyType:this.current+1,
        }
        getSysMoneyList(fromData).then((res)=>{
          if(res.code === 1){
            this.dataList = res.data.items
            this.totalNum = res.data.totalNum
          }else{
            this.dataList = []
            this.totalNum = 0
          }
          ++this.page
        })
      },
		}
	}
</script>

<style lang="scss" scoped>
	.finance_content {
		// min-height: 600rpx;
	}

	.subsection {
		width: 350rpx;
	}

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