<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 {compareSearchStaticsMonthlyEcharts, dataPushSituationMonthlyEcharts} from "@/echarts/option";
import {getFullYear} from "@/units/use-method/veritification-tools";
import {proSelectJctd} from "@/service/credit-data/combined-rewards-and-punishments/combined-rewards-and-punishments";
import {InsertSyslog} from "@/units/use-method/user-log";

export default {
  name: "CompareSearchStaticsMonthly",
  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
      proSelectJctd({
        YEAR: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 dataLeft_bin = [];
      let dataRight_bin =  [];
      if(date.Rows != null && date.Rows != "null"){
        for (let i = 0; i < date.Rows.length; i++) {
          if (date.Rows[i].XXLY == "公积金") {
            dataLeft_bin = date.Rows[i];
          }
          if (date.Rows[i].XXLY == "委行政服务中心") {
            dataRight_bin = date.Rows[i];
          }
        }
      }
      nextTick(() => {
        debugger
        compareSearchStaticsMonthlyEcharts(monthEcharts.value,dataLeft_bin,dataRight_bin);
      })
    }
    onMounted(()=>{
      forms.value.YEAR = getFullYear("year").toString();
      getChartData()
    })
    return {
      forms,
      formRef,
      formConfig,
      getChartData,
      monthEcharts
    }
  }
}
</script>

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