<template>
	<view class="">
		<StatLoanChart ref="outObj" :genre="1" :leftText="'提放汇总占比'"></StatLoanChart>
    <stat_gather is_group :leftText="'提放汇总明细'"  :out-list="outList" ></stat_gather>
    <StatRanking ref="rankingObj" :is_margin_top="false" :is_type="2" :leftText="'个人业绩排行'" :data-list="userList"></StatRanking>
    <StatSituation ref="situationObj" :date-type-obj="dateTypeObj" :type="1"></StatSituation>
	</view>
</template>

<script>
	import StatLoanChart from "../module/stat_loan_chart.vue"
  import md5 from "js-md5";
  import {getRanking,getDepartmentMoney} from "@/api/statistics";
  import StatSituation from "@/pages/statistics/module/stat_situation.vue";
  import StatRanking from "@/pages/statistics/module/stat_ranking.vue";
  import Stat_gather from "@/pages/statistics/module/stat_gather.vue";

	export default {
    props:{
      'dateTypeObj':{
        default:()=>{
          return {
            dateType:4,
            selectDate:'2023-02-25',
            money_type:1,
            censusUserType:0,
            product_id:5,
          }
        }
      }
    },
		components: {
      Stat_gather,
      StatRanking,
      StatSituation,
			StatLoanChart,
		},
		data() {
			return {
        userList:[],
        moneyData:{},
        outList:[]
			}
		},
    watch:{
      'dateTypeObj':function () {
        this.initData()
      }
    },
    mounted() {
      this.initData()
    },
    methods:{
      setSendMd5(){
        let str=JSON.stringify(this.dateTypeObj)
        return md5(str)
      },
      initData(){
        if(this.dateTypeObj.censusUserType>0){
          let sendMd5=this.setSendMd5()
          if(sendMd5 !== this.sendMd5){
            this.sendMd5=sendMd5
            this.getDepartmentMoney()
            this.setUserRanking()
            this.$refs.situationObj.startList()
          }
        }
      },
       setUserRanking(){
        let fromData = this.dateTypeObj
        fromData.pageNum = 10
         getRanking(fromData).then((res)=>{
          if(res.code === 1){
            this.userList = res.data.items
            this.$refs.rankingObj.setDataList(this.userList)
          }else{
            this.userList = []
          }
        })
      },
      getDepartmentMoney(){
         getDepartmentMoney(this.dateTypeObj).then((res)=>{
          if(res.code === 1){
            this.moneyData.out_money=res.data.moneyData.loanMoney
            this.moneyData.out_num=res.data.moneyData.loanNum
            this.outList=res.data.items
            // this.$refs.outObj.setPeakChartData(this.outList)
          }
        })
      },
    }

	}
</script>

<style>
</style>