<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 {dataApplyGeneralSituationEcharts} from "@/echarts/option";
import {getFullYear} from "@/units/use-method/veritification-tools";
import {proSelectXyxxSjtjYyYear} from "@/service/credit-data/apply-information/apply-information";
import {InsertSyslog} from "@/units/use-method/user-log";

export default {
  name: "DataApplyGeneralSituation",
  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
      proSelectXyxxSjtjYyYear({
        startM: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].Rows
      let lastData = [
        {
          name: '在沪建筑业企业信用评价',
          type: 'bar',
          data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        },
        {
          name: '三类人员资格审查',
          type: 'bar',
          data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        }
      ]
      for (let i = 0; i < date.length; i++) {
        if (date[i].NAME == '在沪建筑业企业信用评价') {
          let  key_yuefen = date[i].YUEFEN *1 -1;
          lastData[0].data[key_yuefen] = date[i].VALUE
        }
        if (date[i].NAME == '三类人员资格审查') {
          let key_yuefen = date[i].YUEFEN * 1 - 1;
          lastData[1].data[key_yuefen] = date[i].VALUE
        }
      }
      nextTick(() => {
        debugger
        dataApplyGeneralSituationEcharts(monthEcharts.value,lastData);
      })
    }
    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>