<template>
  <el-dialog
      :modal="true"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
      title="统计"
      :model-value="dialogVisible"

      :before-close="handleClose"
  >
    <div id="page-content"  class="content">
      <div class="form-group">
        <h1 style="font-family:仿宋;font-size:20px;text-align:center">住建领域信用信息概览</h1>
        <p style="font-family:黑体;font-size:20px">一、信用信息目录情况（本年度，统计历年以来的所有目录情况）</p>
        <p style="font-family:仿宋;font-size:20px"><span style="padding-left:2em;"></span>市住建委本级编制完成
          <a style="color:red">{{form.YYYY}}</a>
          年度住建领域信用管理“三清单”（数据清单、行为清单、应用清单），被纳入本市信用管理目录的条目数量为
          <a id="QD_ALL" style="color:red">{{ form.QD_ALL }}</a>
          项，涵盖了建筑市场监管、质量安全监管、城市综合管理、燃气管理、机关党委等条线。委本级信用管理目录具体情况如下：</p>
      </div>
      <div  class="cp-table">
        <table class="table-example" style="width:100%;">
          <thead style="width: 100%; height: 100%">
          <tr>
            <th style="width:14%">目录类别</th>
            <th style="width:13%">建筑市场监管</th>
            <th style="width:13%">质量安全监管</th>
            <th style="width:13%">城市综合管理</th>
            <th style="width:13%">燃气管理</th>
            <th style="width:13%">机关党委</th>
            <th style="width:13%">总计</th>
          </tr>
          </thead>
          <tbody id="tbodyJ"></tbody>
        </table>
<!--        <my-table border-->
<!--                  :has-operation="false"-->
<!--                  :table-data="tableDataML"-->
<!--                  :headers="matterImputationStaticsReportMLHeader">-->
<!--        </my-table>-->

      </div>
      <div class="form-group">
        <p  style="font-family:黑体;font-size:20px">一、信用信息归集情况（每月）</p>
        <p  style="font-family:仿宋;font-size:20px"><span style="padding-left:2em;"></span>截至今年<a style="color:red">{{ form.MM }}</a>月<a style="color:red">{{ form.DD }}</a>日，委信用数据库累计归集信用信息<a style="color:red">{{ form.XYXX }}</a>条。具体归集情况如下：</p>
        <p  style="font-family:仿宋;font-size:20px"><span style="padding-left:2em;"></span>资质许可类信息事项共计<a style="color:red">{{ form.XYXX_XK }}</a>条信息，其中法人<a   style="color:red">{{ form.XYXX_XK_FR }}</a>条、自然人<a   style="color:red">{{ form.XYXX_XK_ZRR }}</a>条。监管处罚类信息事项共计<a  style="color:red">{{ form.XYXX_CF }}</a>条信息，其中法人<a   style="color:red">{{ form.XYXX_CF_FR }}</a>条、自然人<a  style="color:red">{{ form.XYXX_CF_ZRR }}</a>条。履约类信息事项共计<a  style="color:red">{{ form.XYXX_YQ }}</a>条自然人信息。</p>
        <p  style="font-family:仿宋;font-size:20px"><span style="padding-left:2em;"></span>建筑市场监管、质量安全监管相关信用信息有<a  style="color:red">{{ form.XYXX_WXZFWZX }}</a>条，公积金管理相关信用信息有<a   style="color:red">{{ form.XYXX_SGJJGLZX }}</a>条，城管执法相关信用信息有<a  style="color:red">{{ form.XYXX_SCGZFJ }}</a>条。</p>
        <p  style="font-family:黑体;font-size:20px">二、信用联合奖惩情况（每月）</p>
        <p  style="font-family:仿宋;font-size:20px"><span style="padding-left:2em;"></span>目前市住建委在<a  style="color:red">{{ form.LHJC_LENGTH }}</a>个业务事项上，实施了失信被执行人信用联合惩戒，分别是<a style="color:red">{{ form.LHJC_XXSX }}</a></p>
        <p  style="font-family:仿宋;font-size:20px"><span style="padding-left:2em;"></span>截至今年<a style="color:red">{{ form.MM1 }}</a>月<a  style="color:red">{{ form.DD1 }}</a>日，相关业务系统核查对比失信被执行人共计<a  style="color:red">{{ form.LHJC_XXSX_ALL }}</a>次，已成功拦截<a  style="color:red">{{ form.LHJC_XXSX_SUCCESS }}</a>次，实施惩戒对象<a style="color:red">{{ form.LHJC_XXSX_UNIT }}</a>个，所有惩戒结果全部反馈至市信用信息平台。我委具体惩戒实施情况如下图所示：</p>
        <p  style="font-family:黑体;font-size:20px">（联合惩戒统计表格信息）</p>
      </div>
      <div class="cp-table">
        <table class="table-example" style="width:100%;">
          <thead style="width: 100%; height: 100%">
          <tr>
            <th style="width:48%">事项名称</th>
            <th style="width:13%">比对次数</th>
            <th style="width:13%">限制惩戒</th>
            <th style="width:15%">限制惩戒对象数</th>
          </tr>
          </thead>
          <tbody id="tbodyP"></tbody>
        </table>
      </div>
      <div class="form-group">
        <p  style="font-family:仿宋;font-size:20px"><span style="padding-left:2em;"></span><a id="LHJC_JD" style="color:red">{{ form.LHJC_JD }}</a>季度，信用联合惩戒案例新增<a id="LHJC_RS_XZ" style="color:red">{{ form.LHJC_RS_XZ }}</a>人<a  id="LHJC_CS_XZ" style="color:red">{{ form.LHJC_CS_XZ }}</a>次，<a id="LHJC_LZ_XZ" style="color:red">{{ form.LHJC_LZ_XZ }}</a>等多次申请<a id="LHJC_SX_XZ" style="color:red">{{ form.LHJC_SX_XZ }}</a>，经核查比对，发现已列入法院失信被执行人名单，因此决定不予通过。</p>
      </div>

    </div>

  </el-dialog>
</template>

<script>
import MyTable from "@/components/common/MyTable.vue";
import {Close, Delete, Edit, Plus, Search, SuccessFilled} from "@element-plus/icons-vue";
import {onBeforeMount, ref} from "vue";
import {matterImputationStaticsReportMLHeader,matterImputationStaticsReportCJHeader} from "@/data/all-table-header";

import {
  proSelectXyxxCount,
  proselectXyxxjctjLz,
  proSelectXyxxQdtj
} from "@/service/credit-data/data-imputation-push/data-imputation-push";
import {
  proSelectXyxxJctj
} from "@/service/credit-data/combined-rewards-and-punishments/combined-rewards-and-punishments";
import saveAs from 'file-saver';
import "../../../../../units/jquery.wordexport"
export default {
  name: "MatterImputationStaticsSituationReportSettingDialog",
  components: {MyTable},
  computed: {
    Delete() {
      return Delete
    },
    Edit() {
      return Edit
    },
    Plus() {
      return Plus
    },
    SuccessFilled() {
      return SuccessFilled
    },
    Close() {
      return Close
    },
    Search(){
      return Search
    }
  },
  props:{
    dialogVisible:{  //是否可见

    },
    dialogOperationType:{   //操作类型

    },
    currentDialogObj:{   //当前选中信息

    },
  },
  setup(props,{emit}){
    const tableDataML = ref([]);
    const tableDataCJ = ref([]);
    const form = ref({});
    function handleClose(){
      emit('update:dialogVisible',false);
    }
    function getTableData(){
      let date1 = new Date();
      let year1 = date1.getFullYear();
      let firstMonth = year1 + '-' + '01' + '-' + '01';
      let start = firstMonth;
      let year = date1.getFullYear();
      let month = date1.getMonth();
      if (month == 0) {
        month = 12;
        year = year - 1;
      }
      if (month < 10) {
        month = '0' + month;
      }
      let myDate = new Date(year, month, 0);
      let endDate = year + '-' + month + '-' + myDate.getDate();
      let end = endDate;
      form.value.MM = month;
      form.value.DD = myDate.getDate();
      form.value.MM1 = month;
      form.value.DD1 =  myDate.getDate();
      proSelectXyxxCount({
        start_time:start,
        end_time:end
      }).then(res =>{
        count_xyxx_detail(res);
        count_lhjc()
      })
    }
    function count_xyxx_detail(data){
      let date = data.msg[0];
      for (let i = 0; i < date.Rows.length; i++) {
        form.value[date.Rows[i].TITLE] = date.Rows[i].NUMBERS;
      }
    }
    function count_lhjc(){
      let date1 = new Date();
      let year1 = date1.getFullYear();
      let firstMonth = year1 + '-' + '01' + '-' + '01';
      let start = firstMonth;
      let year = date1.getFullYear();
      let month = date1.getMonth();
      if (month == 0) {
        month = 12;
        year = year - 1;

      }
      if (month < 10) {
        month = '0' + month;
      }
      let myDate = new Date(year, month, 0);
      let endDate = year + '-' + month + '-' + myDate.getDate()
      let end = endDate;
      proSelectXyxxJctj({
        start_time:start,
        //startC:"2019-01",
        end_time:end,
        pageSize:10000,
        pageIndex:1
      }).then(res =>{
        count_lhjc_detail(res);
        count_lhjc_jd();
      })
    }
    function count_lhjc_detail(data){
      let date = data.msg[0];
      //数据标题
      let dataTitle = [];
      let dataTitleT = [];
      //数据内容
      let dataLeft_bin = [];
      let dataRight_bin = [];
      let dataMiddle_bin = [];
      if (date.Rows != null && date.Rows != "null"){
        $("#tbodyP").empty();
        var str = "";
        var totalLeft = 0;
        var totalRight = 0;
        var totalMiddle = 0;
        for (var i = 0; i < date.Rows.length; i++) {
          date.Rows[i].比较次数 = date.Rows[i].比较次数 * 1;
          date.Rows[i].限制惩戒 = date.Rows[i].限制惩戒 * 1;
          totalLeft += date.Rows[i].比较次数 * 1;
          totalRight += date.Rows[i].限制惩戒 * 1;
          totalMiddle += date.Rows[i].单位数 * 1;
          if (date.Rows[i].限制惩戒 == "") {
            date.Rows[i].限制惩戒 = 0;
          }
          if (date.Rows[i].单位数 == "") {
            date.Rows[i].单位数 = 0;
          }
        }
        var sortTwoCate = function (a, b) {
          var srcDataNew = ["对建筑工程施工的许可", "对建筑施工企业安全生产的许可", "建设工程企业资质许可", "建设工程注册从业人员资格许可", "投标企业基本情况表", "联动奖惩黑名单查询"];
          if (srcDataNew.indexOf(a.SXMC) === srcDataNew.indexOf(b.SXMC)) {
            return 0;
          } else {
            if (srcDataNew.indexOf(a.SXMC) > srcDataNew.indexOf(b.SXMC)) {
              return 1;
            } else {
              return -1;
            }
          }

        }
        date.Rows.sort(sortTwoCate)
        for (var i = 0; i < date.Rows.length; i++) {
          if (date.Rows[i].SXMC == "联动奖惩黑名单查询") {
            dataTitle.push("公积金贷款");
            str += "<tr><td>公积金贷款</td><td>" + date.Rows[i].比较次数.toLocaleString() + "</td><td>" + date.Rows[i].限制惩戒.toLocaleString() + "</td><td>" + date.Rows[i].单位数.toLocaleString() + "</td></tr>"
            dataLeft_bin.push(date.Rows[i].比较次数);
            dataRight_bin.push(date.Rows[i].限制惩戒);
            dataMiddle_bin.push(date.Rows[i].单位数);
          } else {
            str += "<tr><td>" + date.Rows[i].SXMC + "</td><td>" + date.Rows[i].比较次数.toLocaleString() + "</td><td>" + date.Rows[i].限制惩戒.toLocaleString() + "</td><td>" + date.Rows[i].单位数.toLocaleString() + "</td></tr>"
            dataTitle.push(date.Rows[i].SXMC);
            dataLeft_bin.push(date.Rows[i].比较次数);
            dataRight_bin.push(date.Rows[i].限制惩戒);
            dataMiddle_bin.push(date.Rows[i].单位数);
          }
        }
        dataTitle.reverse();
        dataLeft_bin.reverse();
        dataRight_bin.reverse();
        dataMiddle_bin.reverse();
        str += "<tr><td>总计</td><td>" + totalLeft.toLocaleString() + "</td><td>" + totalRight.toLocaleString() + "</td><td>" + totalMiddle.toLocaleString() + "</td></tr>"
        $("#tbodyP").append(str);
      }else{
        dataTitle = ['投标企业基本情况表', '建设工程企业资质许可', '建设工程注册从业人员资格许可', '对建筑工程施工的许可', '对建筑施工企业安全生产的许可', '公积金贷款', '总计']
        dataLeft_bin = [0, 0, 0, 0, 0, 0, 0];
        dataRight_bin = [0, 0, 0, 0, 0, 0, 0];
        dataMiddle_bin = [0, 0, 0, 0, 0, 0, 0];
        $("#tbodyP").empty();
      }
      form.value.LHJC_LENGTH = date.Rows.length;
      let title_string = '';
      for (let i = 0; i < dataTitle.length; i++) {
        if (i != dataTitle.length - 1) {
          title_string += dataTitle[i] + "、";
        } else {
          title_string += dataTitle[i];
        }
      }
      form.value.LHJC_XXSX = title_string;
      form.value.LHJC_XXSX_ALL = totalLeft.toLocaleString();
      form.value.LHJC_XXSX_SUCCESS = totalRight.toLocaleString();
      form.value.LHJC_XXSX_UNIT = totalMiddle.toLocaleString();
    }
    function count_lhjc_jd(){
      var date1 = new Date();
      var year1 = date1.getFullYear();
      var firstMonth = year1 + '-' + '01' + '-' + '01';
      var start = firstMonth;
      var year = date1.getFullYear();
      var month = date1.getMonth();
      if (month == 0) {
        month = 12;
        year = year - 1;

      }
      if (month < 10) {
        month = '0' + month;
      }

      var myDate = new Date(year, month, 0);
      var endDate = year + '-' + month + '-' + myDate.getDate()
      var end = endDate;
      if (end <= 3) {
        start = year1-1 + '-' + '10' + '-' + '01';
        end = year1 + '-' + '12' + '-' + '31';
        document.getElementById("LHJC_JD").innerText = '去年四';
      } else if (end >= 4 && end <= 6) {
        start = year1 + '-' + '01' + '-' + '01';
        end = year1 + '-' + '03' + '-' + '31';
        document.getElementById("LHJC_JD").innerText = '今年一';
      } else if (end >= 7 && end <= 9) {
        start = year1 + '-' + '04' + '-' + '01';
        end = year1 + '-' + '06' + '-' + '30';
        document.getElementById("LHJC_JD").innerText = '今年二';
      } else {
        start = year1 + '-' + '07' + '-' + '01';
        end = year1 + '-' + '09' + '-' + '30';
        document.getElementById("LHJC_JD").innerText = '今年三';
      }
      proSelectXyxxJctj({
        start_time:start,
        //startC:"2019-01",
        end_time:end,
        pageSize:10000,
        pageIndex:1
      }).then(res =>{
        count_lhjc_detail_jd(res);
        count_lhjc_jd_lz();
      })
    }
    function count_lhjc_detail_jd(data){
      let date = data.msg[0];
      //数据标题
      var dataTitle = [];
      var dataTitleT = [];
      //数据内容
      var dataLeft_bin = [];
      var dataRight_bin = [];
      var dataMiddle_bin = [];
      if (date.Rows != null && date.Rows != "null") {
        var totalLeft = 0;
        var totalRight = 0;
        var totalMiddle = 0;

        for (var i = 0; i < date.Rows.length; i++) {
          date.Rows[i].比较次数 = date.Rows[i].比较次数 * 1;
          date.Rows[i].限制惩戒 = date.Rows[i].限制惩戒 * 1;
          totalLeft += date.Rows[i].比较次数 * 1;
          totalRight += date.Rows[i].限制惩戒 * 1;
          totalMiddle += date.Rows[i].单位数 * 1;
          if (date.Rows[i].限制惩戒 == "") {
            date.Rows[i].限制惩戒 = 0;
          }
          if (date.Rows[i].单位数 == "") {
            date.Rows[i].单位数 = 0;
          }
        }
        // $("#LHJC_LENGTH").val(date.Rows.length);
        form.value.LHJC_LENGTH = date.Rows.length;
        var title_string = '';
        for (var i = 0; i < dataTitle.length; i++) {
          if (i != dataTitle.length - 1) {
            title_string += dataTitle[i] + "、";
          } else {
            title_string += dataTitle[i];
          }

        }
        form.value.LHJC_CS_XZ = totalRight.toLocaleString();
        form.value.LHJC_RS_XZ = totalMiddle.toLocaleString();
      }
    }

    function count_lhjc_jd_lz(){
      var date1 = new Date();
      var year1 = date1.getFullYear();
      var firstMonth = year1 + '-' + '01' + '-' + '01';
      var start = firstMonth;
      var year = date1.getFullYear();
      var month = date1.getMonth();
      if (month == 0) {
        month = 12;
        year = year - 1;

      }
      if (month < 10) {
        month = '0' + month;
      }

      var myDate = new Date(year, month, 0);
      var endDate = year + '-' + month + '-' + myDate.getDate()
      var end = endDate;
      if (end <= 3) {
        start = year1 - 1 + '-' + '10' + '-' + '01';
        end = year1 + '-' + '12' + '-' + '31';
        document.getElementById("LHJC_JD").innerText = '去年四';
      } else if (end >= 4 && end <= 6) {
        start = year1 + '-' + '01' + '-' + '01';
        end = year1 + '-' + '03' + '-' + '31';
        document.getElementById("LHJC_JD").innerText = '今年一';
      } else if (end >= 7 && end <= 9) {
        start = year1 + '-' + '04' + '-' + '01';
        end = year1 + '-' + '06' + '-' + '30';
        document.getElementById("LHJC_JD").innerText = '今年二';
      } else {
        start = year1 + '-' + '07' + '-' + '01';
        end = year1 + '-' + '09' + '-' + '30';
        document.getElementById("LHJC_JD").innerText = '今年三';
      }
      proselectXyxxjctjLz({
        start_time:start,
        end_time:end
      }).then(res =>{
        count_lhjc_qd();
        count_lhjc_detail_jd_lz(res);
      })
    }

    function count_lhjc_detail_jd_lz(data) {
      let date = data.msg[0];
      if (date.Rows != null && date.Rows != "null") {
        var lz =''
        form.value.LHJC_LZ_XZ = date.Rows[0].DXMC;
        form.value.LHJC_SX_XZ = date.Rows[0].YWSX;
      }
    }
    function count_lhjc_qd(){
      var date1 = new Date();
      var year1 = date1.getFullYear();
      form.value.YYYY = year1;
      proSelectXyxxQdtj({
        BBH:year1
      }).then(res =>{
        count_lhjc_qd_detail(res);
      })
    }
    function count_lhjc_qd_detail(data) {
      let date = data.msg[0];
      if (date.Rows != null && date.Rows != "null") {
        $("#tbodyJ").empty();
        var str = "";
        var sjqd = [];
        var xwqd = [];
        var yyqd = [];
        var totalsjqd = 0;
        var totalwxqd = 0;
        var totalyyqd = 0;

        for (var i = 0; i < date.Rows.length; i++) {
          if (date.Rows[i].SORCE =='sjqd') {

            sjqd.push({NUMBERS:date.Rows[i].NUMBERS,
              BZBM: date.Rows[i].BZBM,
            });
            totalsjqd += date.Rows[i].NUMBERS * 1;
          }
          if (date.Rows[i].SORCE == 'wxqd') {
            xwqd.push({
              NUMBERS: date.Rows[i].NUMBERS,
              BZBM: date.Rows[i].BZBM,
            });
            totalwxqd += date.Rows[i].NUMBERS * 1;
          }
          if (date.Rows[i].SORCE == 'yyqd') {
            yyqd.push({
              NUMBERS: date.Rows[i].NUMBERS,
              BZBM: date.Rows[i].BZBM,
            });
            totalyyqd += date.Rows[i].NUMBERS * 1;
          }
        }
        sjqd.push({
          NUMBERS: totalsjqd,
          BZBM: "总计",
        });
        xwqd.push({
          NUMBERS: totalwxqd,
          BZBM: "总计",
        });
        yyqd.push({
          NUMBERS: totalyyqd,
          BZBM: "总计",
        });
        var TOTAL = totalsjqd + totalwxqd + totalyyqd;
        let srcData = ["建筑市场", "房地产市场", "物业管理", "燃气管理", "宣传", "总计"];
        var sjqdNew = [];
        var xwqdNew = [];
        var yyqdNew = [];
        for (var i = 0; i < srcData.length; i++) {
          sjqdNew.push({
            BZBM: srcData[i],
            NUMBERS: 0
          })
          xwqdNew.push({
            BZBM: srcData[i],
            NUMBERS: 0
          })
          yyqdNew.push({
            BZBM: srcData[i],
            NUMBERS: 0
          })
        }
        for (var i = 0; i < sjqdNew.length; i++) {
          for (var j = 0; j < sjqd.length; j++) {
            if (sjqd[j].BZBM == sjqdNew[i].BZBM) {

              sjqdNew[i] = sjqd[j];
            }

          }
        }
        for (var i = 0; i < xwqdNew.length; i++) {
          for (var j = 0; j < xwqd.length; j++) {
            if (xwqd[j].BZBM == xwqdNew[i].BZBM) {

              xwqdNew[i] = xwqd[j];
            }

          }
        }
        for (var i = 0; i < yyqdNew.length; i++) {
          for (var j = 0; j < yyqd.length; j++) {
            if (yyqd[j].BZBM == yyqdNew[i].BZBM) {

              yyqdNew[i] = yyqd[j];
            }

          }
        }
        str = '<tr><td>信用信息数据事项</td>';
        for (var i = 0; i < sjqdNew.length; i++) {
          str += "<td>" + sjqdNew[i].NUMBERS.toLocaleString() + "</td>"
        }
        str += "</tr><tr><td>信用行为分类事项</td>"
        for (var i = 0; i < xwqdNew.length; i++) {
          str += "<td>" + xwqdNew[i].NUMBERS.toLocaleString() + "</td>"
        }
        str += "</tr><tr><td>信用信息应用事项</td>"
        for (var i = 0; i < yyqdNew.length; i++) {
          str += "<td>" + yyqdNew[i].NUMBERS.toLocaleString() + "</td>"
        }
        str += "</tr>"
        $("#tbodyJ").append(str);
      }
      form.value.QD_ALL = TOTAL;
      $("#page-content").wordExport('月报');
    }
    onBeforeMount(()=>{
      getTableData()
    })
    return{
      matterImputationStaticsReportMLHeader,
      matterImputationStaticsReportCJHeader,
      handleClose,
      tableDataML,
      tableDataCJ,
      form
    }
  }
}
</script>

<style scoped lang="scss">
:deep{
  table{
    min-width: 100%;
    border-collapse: collapse; /* 表格边框合并 ，合并后显示细线边框*/

  }
  table, thead,tr, td, th {
    border: 1px solid #E2E2E2; /* 表格边框颜色 */
  }
  table thead{
    background-color: #F2F2F2;/* 表头背景颜色 */
  }
  table th,table td{
    min-width: 100px;
    min-height: 36px;
    line-height: 36px;
    text-align: center;/* 内容居中显示 */
    padding: 0px 10px;/* 内容左右间距 */
    word-break: keep-all;/* 禁止表格内容换行 */
    white-space: nowrap;/* 禁止表格内容换行 */
  }
  table tr:nth-child(even)
  {
    background: #f1f1f1;/* 表格斑马线 */
  }

  table tr:hover
  {
    background: #f9f9f9;/* 表格斑马线 */
  }
}
</style>