<template>
  <div class="department-data">
    <diy-el-form ref="formRef"  v-bind="{'span-attrs':{span:4}}"   v-model:model-form="forms" :forms="formConfig">
      <template #searchBtn>
        <el-button  type="primary" :icon="Search" @click="getChartData()">查询</el-button>
      </template>
    </diy-el-form>
    <div class="department-content">
      <div class="echarts" ref="monthEcharts">

      </div>
    </div>
  </div>
</template>

<script>
import DiyElForm from "@/components/common/DiyElForm.vue";
import {Close, Delete, Document, Search, SuccessFilled} from "@element-plus/icons-vue";
import {nextTick, onMounted, ref} from "vue";
import {dataPushSituationMonthlySituation} from "@/data/all-form";
import {
  proSelectXyxxSjtjSxy
} from "@/service/credit-data/data-imputation-push/data-imputation-push";
import {dataPushSituationMonthlyEcharts} from "@/echarts/option";
import {getFullYear} from "@/units/use-method/veritification-tools";
import {InsertSyslog} from "@/units/use-method/user-log";

export default {
  name: "DataPushSituationMonthly",
  components:{DiyElForm},
  computed: {
    Delete() {
      return Delete
    },
    Search() {
      return Search
    },
    Document() {
      return Document
    },
    SuccessFilled() {
      return SuccessFilled
    },
    Close() {
      return Close
    }
  },
  setup(){
    const forms = ref({});
    const formRef = ref(null);
    const formConfig = ref({...dataPushSituationMonthlySituation});
    const monthEcharts = ref(null);
    function getChartData(){
      debugger
      proSelectXyxxSjtjSxy({
        YEARS:forms.value.YEAR,
        pageSize:10000,
        pageIndex:1
      }).then(res =>{
        debugger
        InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息查询", "数据归集推送查询成功", "数据归集推送", "")
        getEcharts(res);
      })
    }
    function getEcharts(data){
      let date = data.msg[0]
      let  tempTest = [
        {
          name: '市信用信息中心',
          type: 'bar',
          data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

        }
      ]
      if(date.Rows != null && date.Rows != "null"){
        for (let j = 0; j < date.Rows.length; j++) {
          var p = date.Rows[j].MONTHS * 1;
          tempTest[0].data[p-1] = date.Rows[j].ALLCOUNT;

        }

      }
      nextTick(() => {
        debugger
        dataPushSituationMonthlyEcharts(monthEcharts.value,tempTest);
      })
    }
    onMounted(()=>{
      forms.value.YEAR = getFullYear("year").toString();
      debugger
      getChartData()
    })
    return {
      forms,
      formRef,
      formConfig,
      getChartData,
      monthEcharts
    }
  }
}
</script>

<style scoped lang="scss">
.department-content{
  height: 600px;
  .echarts{
    height: 580px;
  }
}
</style>