<template>
	<view class="">
		<StatLoanChart ref="outObj" :genre="1" :leftText="'提放汇总占比'"></StatLoanChart>
		<StatRanking :leftText="'提放汇总明细'"></StatRanking>
    <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 StatRanking from "../module/stat_situation.vue"
	import StatSituation from "../module/stat_ranking.vue"
  import md5 from "js-md5";

	export default {
    props:{
      'dateTypeObj':{
        default:()=>{
          return {
            dateType:4,
            selectDate:'2023-02-25',
            money_type:1,
            censusUserType:0,
            product_id:5,
          }
        }
      }
    },
		components: {
			StatLoanChart,
			StatRanking,
			StatSituation,
		},
		data() {
			return {

			}
		},
    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>