<template>

  <div>

    <a-row :gutter="0" style="height: 800px">
      <a-col :span="0" style="height: 100%;" v-if='taskType!=="3"'>
        <a-card title="任务选择" :bordered="false" style="height: 100%">
          <a-directory-tree
            style="height: auto"
            v-model:expandedKeys="expandedKeys"
            v-model:selectedKeys="selectedKeys"
            multiple
            :tree-data="treeData"
            @expand="onExpand"
            @select="onTreeNodeSelect"
          ></a-directory-tree>
        </a-card>
      </a-col>
      <a-col :span="0" style="height: 100%;" v-if='taskType==="3"'>
      </a-col>
      <!--筛选条件-->

      <a-row>
        <a-col :span="24">
          <a-form layout="inline">
            <a-row :gutter="24">

              <a-col :xl="16" :lg="7" :md="8" :sm="24">
                <a-form-item label="稽核工作日期范围">
                  <a-range-picker @change="handleChange" v-model:value="taskDate"/>
                  <a-radio-group @change="changeReportDate()" style="padding-left: 10px" v-model:value="latestDate" button-style="solid">
                    <a-radio-button value="7">最近7天</a-radio-button>
                    <a-radio-button value="30">最近30天</a-radio-button>
                    <a-radio-button value="180">最近180天</a-radio-button>
                  </a-radio-group>
                </a-form-item>
              </a-col>
              <a-col   :xl="8" :lg="7" :md="12" :sm="24">
                <a-form-item label="稽核类型">
                  <j-dict-select-tag placeholder="请选择稽核类型" v-model:value="taskType" @change="changeReportDate()" style='width: 180px'  dictCode="sms_check_task_type" />
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
        </a-col>
        <a-col :span="6" style="padding-top: 10px">
          <a-card>
            <a-statistic
              title="未完善客户数量"
              :value="toImproveUser"
              :precision="0"
              suffix="个"
              :value-style="{ color: '#fa073f' }"
              style="margin-right: 50px"
            >
              <template #prefix>
                <arrow-up-outlined/>
              </template>
            </a-statistic>
          </a-card>
        </a-col>
        <a-col :span="6" style="padding-top: 10px">
          <a-card>
            <a-statistic
              title="待整改客户数量"
              :value="tobeRectified"
              :precision="0"
              suffix="个"
              :value-style="{ color: '#810320' }"
              style="margin-right: 50px"
            >
              <template #prefix>
                <arrow-up-outlined/>
              </template>
            </a-statistic>
          </a-card>
        </a-col>
        <a-col :span="6" style="padding-top: 10px">
          <a-card>
            <a-statistic
              title="待稽核客户数量"
              :value="toBeAudited"
              :precision="0"
              suffix="个"
              :value-style="{ color: '#0a0a09' }"
              style="margin-right: 50px"
            >
              <template #prefix>
                <arrow-up-outlined/>
              </template>
            </a-statistic>
          </a-card>
        </a-col>
        <a-col :span="6" style="padding-top: 10px">
          <a-card>
            <a-statistic
              title="稽核通过客户数量"
              :value="auditPassed"
              :precision="0"
              suffix="个"
              :value-style="{ color: '#3f8600' }"
              style="margin-right: 50px"
            >
              <template #prefix>
                <arrow-up-outlined/>
              </template>
            </a-statistic>
          </a-card>
        </a-col>
        <a-col :span="24" style="top: 10px">
          <a-card title="整改类型（差错类型）" :bordered="false">
            <div id="statusRefusePie" ref="statusRefusePie" style="width:100%;height:500px"></div>
          </a-card>
        </a-col>
        <a-col :span="24" style="top: 10px">
          <a-card title=" " :bordered="false">
            <h2 style='text-align:center'>整改类型（差错类型）历史明细</h2>
            <a-col :span="19"  >
              <div class="table-page-search-wrapper">
                <a-form layout="inline" @keyup.enter.native="searchQuery">
                  <a-row :gutter="24">
                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                      <a-form-item label="客户编号">
                        <j-input placeholder="请输入客户编号"  ></j-input>
                      </a-form-item>
                    </a-col>
                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                      <a-form-item label="客户名称">
                        <j-input placeholder="客户名称"  ></j-input>
                      </a-form-item>
                    </a-col>
                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                      <a-form-item label="任务名称">
                        <j-input placeholder="任务名称"  ></j-input>
                      </a-form-item>
                    </a-col>

                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                      <a-form-item label="任务状态">
                        <j-dict-select-tag placeholder="请选择任务状态"    dictCode="sms_check_task_state" />
                      </a-form-item>
                    </a-col>
                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                      <a-form-item label="稽核类型">
                        <j-dict-select-tag placeholder="请选择稽核类型"   dictCode="sms_check_task_type" />
                      </a-form-item>
                    </a-col>
                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                      <a-form-item label="稽核状态">
                        <j-dict-select-tag placeholder="请选择稽核状态"    dictCode="check_status" />
                      </a-form-item>
                    </a-col>
                    <template v-if="toggleSearchStatus">


                      <a-col :xl="10" :lg="11" :md="12" :sm="24">
                        <a-form-item label="稽核开始时间">
                          <j-date :show-time="true" date-format="YYYY-MM-DD" placeholder="请选择开始时间" class="query-group-cust" ></j-date>

                        </a-form-item>
                        <a-form-item label="稽核结束时间">
                          <j-date :show-time="true" date-format="YYYY-MM-DD" placeholder="请选择结束时间" class="query-group-cust" ></j-date>
                        </a-form-item>
                      </a-col>
                    </template>
                    <div class="table-operator" style='float: right'>
                      <!-- 高级查询区域 -->
                      <a-dropdown v-if="selectedRowKeys.length > 0">
                        <a-menu slot="overlay">
                          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
                        </a-menu>
                        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
                      </a-dropdown>
                      <a-button type="primary" icon="download" @click="handleExportXls('稽核任务')">导出</a-button>
                      <a-button type="primary" @click="searchQuery()" icon="search" >查询</a-button>
                      <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                      <a @click="handleToggleSearch" style="margin-left: 8px">
                        {{ toggleSearchStatus ? '收起' : '展开' }}
                        <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
                      </a>

                    </div>
                  </a-row>
                </a-form>

              </div>
            </a-col>


            <div>
              <a-table
                ref="table"
                size="middle"
                :scroll="{x:true}"
                bordered
                rowKey="id"
                :columns="columns"
                :dataSource="dataSource"
                :pagination="ipagination"
                :loading="loading"
                :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
                class="j-table-force-nowrap"
                @change="handleTableChange">
              </a-table>
            </div>
            <!-- table区域 end -->
            <div style="width: 600px;height:5px;"></div>
          </a-card>
        </a-col>
      </a-row>
    </a-row>


  </div>

  <!-- 查询区域 -->


</template>

<script>


import moment from 'moment';
import {getAction} from "@api/manage";
import * as echarts from 'echarts';
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'SmsCheckWorkLogList',
  mixins:[JeecgListMixin],
  data() {
    return {
      dataSource:[
        {
          "id": "1712649352008179713",
          "dataId": "1712660980103651330",
          "dataLogId": "1712661582091132929",
          "taskId": "1712648713974849538",
          "customerNo": "200001817629",
          "customerName": null,
          "smsNumber": null,
          "userNo": "行短稽核任务1",
          "networkAccessTime": "2010-10-11",
          "networkAccessTimeEnd": "2012-10-11",
          "userState": "在用",
          "staffInfo": "张文超(104009353459)(B03619)",
          "staffUsername": "zhangwenchao",
          "staffName": "待处理",
           "field": "法人联系方式",
          "staffNameStart": "2023-10-10 19:23:17",
          
          "staffNameEnd": "2023-10-12 20:33:17",
          "staffNameTime": "50小时",
          "staffNo": "1000",
          "staffDeptLevel2": "北区电信局(2800000000)",
          "staffDeptLevel2Name": "北区电信局",
          "staffDeptLevel2No": "孙可",
          "staffDeptLevel3": "其他（校园中心）(103013215530)",
          "staffDeptLevel3Name": "其他（校园中心）",
          "staffDeptLevel3No": "103013215530",
          "userOpenState": null,
          "smsNumberPrefix": null,
          "smsNumberUsage": null,
          "accountManager": null,
          "accountManagerPhone": null,
          "customerContacts": '行短稽核任务',
          "customerContactsPhone": null,
          "contractExpireTime": null,
          "smsNumberCertificateExpireTime": null,
          "recordNoticeExpireTime": null,
          "valueAddedLicenceExpireTime": null,
          "businessLicenceExpireTime": null,
          "contractOpenCustomerSame": null,
          "groupPriceApproval": null,
          "dataComplete": null,
          "rectifyReformOver": null,
          "checkState": 500,
          "description": null,
          "delFlag": 0,
          "createBy": "admin",
          "createTime": "2023-10-13 10:00:00",
          "updateBy": null,
          "updateTime": null,
          "sysOrgCode": "A03A02",
          "submitSpecialDate": null,
          "shutdownLabel": null,
          "shutdownLabelDate": null,
          "reopenTime": null,
          "materialLabel": null,
          "nameFindCompliance": null,
          "type": null,
          "checkState_dictText": "待稽核"
        },
        {
          "id": "1712649353086115842",
          "dataId": null,
          "dataLogId": null,
          "taskId": "1712648713974849538",
          "customerNo": "200002340549",
          "customerName": null,
          "smsNumber": null,
          "userNo": "行短稽核任务1",
          "networkAccessTime": "2012-02-14",
          "networkAccessTimeEnd": "2012-10-11",
          "userState": "在用",
          "staffInfo": "毛捷(1004320610)(A00776)",
          "staffUsername": "A00776",
          "staffName": "已处理",
          "field": "客户经理手机号",
          "staffNameStart": "2023-10-10 19:23:17",
          "staffNameEnd": "2023-10-12 15:16:17",
          "staffNameTime": "44小时",
          "staffNo": "2000",
          "staffDeptLevel2": "北区电信局(2800000000)",
          "staffDeptLevel2Name": "北区电信局",
          "staffDeptLevel2No": "赵六",
          "staffDeptLevel3": "北区电信局(2800000000)",
          "staffDeptLevel3Name": "北区电信局",
          "staffDeptLevel3No": "2800000000",
          "userOpenState": null,
          "smsNumberPrefix": null,
          "smsNumberUsage": null,
          "accountManager": null,
          "accountManagerPhone": null,
          "customerContacts": '行短稽核任务',
          "customerContactsPhone": null,
          "contractExpireTime": null,
          "smsNumberCertificateExpireTime": null,
          "recordNoticeExpireTime": null,
          "valueAddedLicenceExpireTime": null,
          "businessLicenceExpireTime": null,
          "contractOpenCustomerSame": null,
          "groupPriceApproval": null,
          "dataComplete": null,
          "rectifyReformOver": null,
          "checkState": 500,
          "description": null,
          "delFlag": 0,
          "createBy": "admin",
          "createTime": "2023-10-13 10:00:00",
          "updateBy": null,
          "updateTime": null,
          "sysOrgCode": "A03A02",
          "submitSpecialDate": null,
          "shutdownLabel": null,
          "shutdownLabelDate": null,
          "reopenTime": null,
          "materialLabel": null,
          "nameFindCompliance": null,
          "type": null,
          "checkState_dictText": "未处理"
        },
        {
          "id": "1712649343284027393",
          "dataId": null,
          "dataLogId": null,
          "taskId": "17126487139748495f38",
          "customerNo": "104003061446",
          "customerName": null,
          "smsNumber": null,
          "userNo": "中继线稽核任务1",
          "networkAccessTime": "2013-08-05",
          "networkAccessTimeEnd": "2012-10-11",
          "userState": "在用",
          "staffInfo": "张文超(104009353459)(B03619)",
          "staffUsername": "zhangwenchao",
          "staffName": "已处理",
          "field": "使用场景",
          "staffNameStart": "2023-10-10 19:23:17",
          "staffNameEnd": "2023-10-12 13:33:00",
          "staffNameTime": "43小时",
          "staffNo": "1500",
          "staffDeptLevel2": "北区电信局(2800000000)",
          "staffDeptLevel2Name": "北区电信局",
          "staffDeptLevel2No": "王武",
          "staffDeptLevel3": "其他（校园中心）(103013215530)",
          "staffDeptLevel3Name": "其他（校园中心）",
          "staffDeptLevel3No": "103013215530",
          "userOpenState": null,
          "smsNumberPrefix": null,
          "smsNumberUsage": null,
          "accountManager": null,
          "accountManagerPhone": null,
          "customerContacts": '中继线稽核',
          "customerContactsPhone": null,
          "contractExpireTime": null,
          "smsNumberCertificateExpireTime": null,
          "recordNoticeExpireTime": null,
          "valueAddedLicenceExpireTime": null,
          "businessLicenceExpireTime": null,
          "contractOpenCustomerSame": null,
          "groupPriceApproval": null,
          "dataComplete": null,
          "rectifyReformOver": null,
          "checkState": 500,
          "description": null,
          "delFlag": 0,
          "createBy": "admin",
          "createTime": "2023-10-13 09:59:58",
          "updateBy": null,
          "updateTime": null,
          "sysOrgCode": "A03A02",
          "submitSpecialDate": null,
          "shutdownLabel": null,
          "shutdownLabelDate": null,
          "reopenTime": null,
          "materialLabel": null,
          "nameFindCompliance": null,
          "type": null,
          "checkState_dictText": "未处理"
        },
        {
          "id": "1712649344286466049",
          "dataId": null,
          "dataLogId": null,
          "taskId": "1712648713974849538",
          "customerNo": "104003061446",
          "customerName": null,
          "smsNumber": null,
          "userNo": "特审复开任务1",
          "networkAccessTime": "2013-04-03",
          "networkAccessTimeEnd": "2012-10-11",
          "userState": "在用",
          "staffInfo": "张文超(104009353459)(B03619)",
          "staffUsername": "zhangwenchao",
          "staffName": "已处理",
          "field": "营业执照有效期是否长期",
          "staffNameStart": "2023-10-10 19:23:17",
          "staffNameEnd": "2023-10-11 20:33:15",
          "staffNameTime": "25小时",
          "staffNo": "2500",
          "staffDeptLevel2": "北区电信局(2800000000)",
          "staffDeptLevel2Name": "北区电信局",
          "staffDeptLevel2No": "李四",
          "staffDeptLevel3": "其他（校园中心）(103013215530)",
          "staffDeptLevel3Name": "其他（校园中心）",
          "staffDeptLevel3No": "103013215530",
          "userOpenState": null,
          "smsNumberPrefix": null,
          "smsNumberUsage": null,
          "accountManager": null,
          "accountManagerPhone": null,
          "customerContacts": '特审复开稽核',
          "customerContactsPhone": null,
          "contractExpireTime": null,
          "smsNumberCertificateExpireTime": null,
          "recordNoticeExpireTime": null,
          "valueAddedLicenceExpireTime": null,
          "businessLicenceExpireTime": null,
          "contractOpenCustomerSame": null,
          "groupPriceApproval": null,
          "dataComplete": null,
          "rectifyReformOver": null,
          "checkState": 300,
          "description": null,
          "delFlag": 0,
          "createBy": "admin",
          "createTime": "2023-10-13 09:59:58",
          "updateBy": null,
          "updateTime": null,
          "sysOrgCode": "A03A02",
          "submitSpecialDate": null,
          "shutdownLabel": null,
          "shutdownLabelDate": null,
          "reopenTime": null,
          "materialLabel": null,
          "nameFindCompliance": null,
          "type": null,
          "checkState_dictText": "未处理"
        },
        {
          "id": "1712649345687363585",
          "dataId": null,
          "dataLogId": null,
          "taskId": "1712648713974849538",
          "customerNo": "104004941911",
          "customerName": null,
          "smsNumber": null,
          "userNo": "特审复开任务1",
          "networkAccessTime": "2012-06-01",
          "networkAccessTimeEnd": "2012-10-11",
          "userState": "在用",
          "staffInfo": "张文超(104009353459)(B03619)",
          "staffUsername": "zhangwenchao",
          "staffName": "处理中",
          "field": "服务号码（全）",
          "staffNameStart": "2023-10-10 19:23:17",
          "staffNameEnd": "2023-10-12 19:33:17",
          "staffNameTime": "10小时",
          "staffNo": "3000",
          "staffDeptLevel2": "北区电信局(2800000000)",
          "staffDeptLevel2Name": "北区电信局",
          "staffDeptLevel2No": "张三",
          "staffDeptLevel3": "其他（校园中心）(103013215530)",
          "staffDeptLevel3Name": "其他（校园中心）",
          "staffDeptLevel3No": "103013215530",
          "userOpenState": null,
          "smsNumberPrefix": null,
          "smsNumberUsage": null,
          "accountManager": null,
          "accountManagerPhone": null,
          "customerContacts": '特审复开稽核',
          "customerContactsPhone": null,
          "contractExpireTime": null,
          "smsNumberCertificateExpireTime": null,
          "recordNoticeExpireTime": null,
          "valueAddedLicenceExpireTime": null,
          "businessLicenceExpireTime": null,
          "contractOpenCustomerSame": null,
          "groupPriceApproval": null,
          "dataComplete": null,
          "rectifyReformOver": null,
          "checkState": 500,
          "description": null,
          "delFlag": 0,
          "createBy": "admin",
          "createTime": "2023-10-13 09:59:58",
          "updateBy": null,
          "updateTime": null,
          "sysOrgCode": "A03A02",
          "submitSpecialDate": null,
          "shutdownLabel": null,
          "shutdownLabelDate": null,
          "reopenTime": null,
          "materialLabel": null,
          "nameFindCompliance": null,
          "type": null,
          "checkState_dictText": "未处理"
        }
      ],
      columns: [

        {
          title:'稽核类型',
          align:"center",
          sorter: true,
          dataIndex: 'customerContacts'
        },
        {
          title:'任务名称',
          align:"center",
          dataIndex: 'userNo'
        },
        {
          title:'客户编号',
          align:"center",
          sorter: true,
          dataIndex: 'customerNo'
        },

        {
          title:'任务开始时间',
          align:"center",
          sorter: true,
          dataIndex: 'networkAccessTime'
        }, {
          title:'任务结束时间',
          align:"center",
          sorter: true,
          dataIndex: 'networkAccessTimeEnd'
        },
        {
          title: '当前处理人',
          align: "center",
          dataIndex: 'staffDeptLevel2No'
        },
        {
          title:'整改时间',
          align:"center",
          dataIndex: 'staffNameStart'
        } , {
          title:'整改字段',
          align:"center",
          dataIndex: 'field'
        } ,
        {
          title:'当前状态',
          align:"center",
          dataIndex: 'staffName'
        },
        {
          title: '员工所在部门',
          align: "center",
          dataIndex: 'staffDeptLevel2Name'
        }

      ],
      /* table选中keys*/
      selectedRowKeys: [],
      /* table选中records*/
      selectionRows: [],
      /* 查询折叠 */
      toggleSearchStatus:false,
      /* 高级查询条件生效状态 */
      superQueryFlag:false,
      /* 高级查询条件 */
      superQueryParams: '',
      /** 高级查询拼接方式 */
      superQueryMatchType: 'and',
      /* 自动查询 默认开启 */
      autoSearch: true,
      description: '稽核工作日志管理页面',
      taskDate: '',
      taskType:'',
      url: {
        "statusRefuse": "/smsCheck/customerInfo/status/refuse",
        "taskList": "/smsCheck/task/list",
        "dateList": "/smsCheck/task/year/list",
        //基本信息 规范信息  附件资料 异常稽核统计
        "checkStateCount": "/smsCheck/workLog/check/state/count",
        "abnormalCreateTime": "/smsCheck/workLog/check/abnormal/count"
      },
      // '1': '未完善',
      statusMap: {
        '0': '未完善',
        '2': '待稽核',
        '4': '待整改',
        "5": '稽核通过',
      },
      abnormalMap: {
        "basicCheckState": "基本信息异常",
        "standardState": "规范信息异常",
        "dataState": "附件资料异常异常"
      },
      $statusRefusePie: "",
      $abnormalCheckPie: "",
      $abnormalCheckHistogram: "",
      $abnormalCreateTimeTrend: "",
      toImproveUser: 0,
      latestDate: '180',
      toBeAudited: 0,
      tobeRectified: 0,
      auditPassed: 0,
      treeData: [],
      expandedKeys: ['2022', '2022-10'],
      selectedKeys: {},
      statusAuditPieData: [],
      canvas: {},
      taskId:null,

    }
  },
  created() {
    const waterMarkText = '智慧运营系统';
    this.canvas = document.createElement('canvas');
    const ctx = this.canvas.getContext('2d');
    this.canvas.width = this.canvas.height = 100;
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';
    ctx.globalAlpha = 0.08;
    ctx.font = '20px Microsoft Yahei';
    ctx.translate(50, 50);
    ctx.rotate(-Math.PI / 4);
    ctx.fillText(waterMarkText, 0, 0);

    //初始化日期 默认最近180天
    this.taskDate = [this.getRecentDay(parseInt(this.latestDate)), this.getRecentDay(0)]

    //稽核任务列表（树）
    this.taskList();
    //稽核概况统计
    this.statusRefuse();
    //稽核历史异常分析
    this.checkStateCount(this.url.checkStateCount);
    this.abnormalCreateTime();


  },
  computed: {},

  methods: {

    changeReportDate(a, event){
      //当前 value this.latestDatec
      //console.log(this.latestDate)
      if (this.taskType ==='3'){
        this.onTreeNodeSelect('all')
      }

      this.taskDate = [this.getRecentDay(parseInt(this.latestDate)), this.getRecentDay(0)]
      this.statusRefuse(this.taskId);
      this.checkStateCount(this.url.checkStateCount, this.taskId);
      this.abnormalCreateTime(this.taskId);
    },

    handleChange(value,model){
      this.taskDate = model
      // model 当前value
      this.statusRefuse(this.taskId);
      this.checkStateCount(this.url.checkStateCount, this.taskId);
      this.abnormalCreateTime(this.taskId);

    },
    // handleChange2(value,model){
    //   this.taskDate = model
    //   // model 当前value
    //   this.statusRefuse(this.taskId);
    //   this.checkStateCount(this.url.checkStateCount, this.taskId);
    //   this.abnormalCreateTime(this.taskId);
    //
    // },
    abnormalCreateTime(infoId) {
      let taskDate = this.taskDate;
      let queryParam = {
        "taskType":this.taskType,
        "startDate": taskDate[0],
        "endDate": taskDate[1],
        "infoId": infoId
      }
      getAction(this.url.abnormalCreateTime, queryParam).then(res => {
        if (res.success) {
          let data = [];
          let resultList = res.resultList;
          for (var i in resultList) {
            let resultListElement = resultList[i];
            let time = resultListElement.createTime;
            let count = parseInt(resultListElement.count);
            data.push([time, count])
          }
          let dateList = data.map(function (item) {
            return item[0];
          });
          let valueList = data.map(function (item) {
            return item[1];
          });
          this.abnormalCreateTimetrend(dateList, valueList)
        }
      }).finally(() => {

      })

    },

    abnormalCreateTimetrend(dateList, valueList) {
      let option = {
        title: {
          text: '稽核异常数量',
          left: 'center',

        },
        lineStyle: {
          color: '#5a6fc0'
        },

        backgroundColor: {
          type: 'pattern',
          image: this.canvas,
          repeat: 'repeat'
        },
        visualMap: [
          {
            show: false,
            type: 'continuous',
            seriesIndex: 0,
            min: 0,
            max: 400
          },
          {
            show: false,
            type: 'continuous',
            seriesIndex: 1,
            dimension: 0,
            min: 0,
            max: dateList.length - 1
          }
        ],
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['稽核异常']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: dateList
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '异常数',
            type: 'line',
            stack: 'Total',
            data: valueList
          }
        ]
      };

      // this.$abnormalCreateTimeTrend = echarts.init(document.getElementById('abnormalCreateTimeTrend'))
      // this.$abnormalCreateTimeTrend.setOption(option)

    },


    checkStateCount(url, taskId) {
      let taskDate = this.taskDate;
      let queryParam = {
        "taskType":this.taskType,
        "startDate": taskDate[0],
        "endDate": taskDate[1],
        "infoId": taskId
      }
      getAction(url, queryParam).then(res => {
        if (res.success) {
          let resultList = res.resultList;
          let pieData = [];
          let histogramSource = ['资料驳回分布']
          let dimensions = ['product']

          for (var i in resultList) {
            let resultListElement = resultList[i];
            let name = resultListElement.name;
            let state = resultListElement.state;
            let count = resultListElement.count;
            if (state === "2") {
              var abnormalMapElement = this.abnormalMap[name];
              if (abnormalMapElement != null && abnormalMapElement != undefined) {
                pieData.push({
                  "name": abnormalMapElement,
                  "value": count
                })
                dimensions.push(abnormalMapElement.toString())
                histogramSource.push(parseInt(count));
              }
            }
          }
          this.checkStatePie(pieData);
          this.checkStateHistogram(dimensions, histogramSource)


        }
      }).finally(() => {

      })
    },

    checkStateHistogram(dimensions, source) {

      let option = {
        backgroundColor: {
          type: 'pattern',
          image: this.canvas,
          repeat: 'repeat'
        },
        legend: {},
        tooltip: {},
        dataset: {
          source: [
            dimensions,
            source
          ]
        },
        xAxis: {type: 'category'},
        yAxis: {},
        // Declare several bar series, each will be mapped
        // to a column of dataset.source by default.
        series: [{type: 'bar'}, {type: 'bar'}, {type: 'bar'}]
      };
      // this.$abnormalCheckHistogram = echarts.init(document.getElementById('statusAuditHistogram'))
      // this.$abnormalCheckHistogram.setOption(option)

    },
    checkStatePie(data) {

      let option = {
        tooltip: {
          trigger: 'item'
        },
        backgroundColor: {
          type: 'pattern',
          image: this.canvas,
          repeat: 'repeat'
        },
        /*title: [
          {
            text: '异常类型占比',
            //subtext: '总计 ' + builderJson.all + " 稽核通过 " + builderJson.charts["稽核通过"],
            left: '25%',
            textAlign: 'center'
          },
        ],*/
        legend: {
          top: '5%',
          left: 'center'
        },
        series: [
          {
            name: '',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: '#fff',
              borderWidth: 2
            },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '40',
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: data
          }
        ]
      };
      this.$abnormalCheckPie = echarts.init(document.getElementById('statusAuditPie'))
      this.$abnormalCheckPie.setOption(option)
    },


    //树点击事件
    onTreeNodeSelect(id) {
      if (id && id.length > 0) {
        if (id == "all") {
          this.statusRefuse();
          this.checkStateCount(this.url.checkStateCount);
          this.abnormalCreateTime();
          this.taskId = null;
          return;
        }
        let split = id[0].split("key-");
        if (split.length == 2) {
          let taskId = split[1];
          this.statusRefuse(taskId);
          this.checkStateCount(this.url.checkStateCount, taskId);
          this.abnormalCreateTime(taskId);
          this.taskId = taskId;
        }
      }
    },
    onExpand(expandedKeys) {
      this.expandedKeys = expandedKeys;
    },

    taskDateList(taskData) {
      getAction(this.url["dateList"]).then(res => {
          if (res.success) {
            let result = res.result;
            let years = result[0];
            let months = result[1];
            let YearLevel = {}
            let monthLevel = {}

            for (var i in years) {
              let year = years[i].yearTime;
              let children = {
                "title": year,
                "key": year,
                "children": []
              }
              YearLevel[year] = children
            }

            for (var j in months) {
              let month = months[j].monthTime;
              let splitElement = month.split("-")[0];
              let children = {
                "title": month,
                "key": month,
                "children": []
              }
              YearLevel[splitElement].children.push(children)
            }
            let allChildren1 = {
              "title": "行短稽核",
              "key": "hd",
              "children": []
            }

            for (var k in taskData) {
              let taskDatum = taskData[k];
              let taskStartTime = taskDatum.taskStartTime;
              if (taskStartTime != null && taskStartTime != undefined) {
                let children = {
                  "title": taskDatum.taskName + "[" + taskDatum.customerCount + "]",
                  "key": "key" + "-" + taskDatum.id,
                  "isLeaf": true,
                }
                let strings = taskStartTime.split("-");
                let year = strings[0];
                let month = strings[0] + "-" + strings[1];
                for (var z in YearLevel[year].children) {
                  let title = YearLevel[year].children[z].title;
                  if (title == month) {
                    if (taskData[k].type===1){
                      allChildren1=YearLevel[year].children[z].children.push(children);
                      break;
                    }
                    if (taskData[k].type===2){
                      allChildren1=YearLevel[year].children[z].children.push(children);
                      break;
                    }
                    if (taskData[k].type===3){
                      allChildren1=YearLevel[year].children[z].children.push(children);
                      break;
                    }
                    if (taskData[k].type===4){
                      allChildren1=YearLevel[year].children[z].children.push(children);
                      break;
                    }
                    YearLevel[year].children[z].children.push(children);
                    break;
                  }
                }
              }
            }

            let allChildren = {
              "title": "全部任务",
              "key": "all",
              "children": []
            }


            for (var u in YearLevel) {
              this.treeData.push(YearLevel[u])
            }
            this.treeData.push(allChildren)
            this.treeData = this.treeData.reverse();


          }
        }
      )

    },

    //任务列表数据
    taskList() {
      let queryParam = {
        pageNo: 1,
        pageSize: 1000000,
      }
      getAction(this.url["taskList"], queryParam).then(res => {
        if (res.success) {
          let records = res.result.records;
          //稽核任务菜单
          this.taskDateList(records);
        }
      })


    },


    //查询各类型稽核进度
    statusRefuse(taskId) {
      let taskDate = this.taskDate;
      let queryParam = {
        "taskType":this.taskType,
        "startDate": taskDate[0],
        "endDate": taskDate[1],
        "taskId": taskId
      }
      if (taskDate.length = 2) {
        getAction(this.url["statusRefuse"], queryParam).then(res => {
          if (res.success) {
            let builderJson = {};
            let columnDate = {};
            let pieDate = {};
            let all = 0;
            let resultList = res.resultList;
            for (var i in resultList) {
              let resultListElement = resultList[i];
              let status = this.statusMap[resultListElement.checkState];
              if (status != undefined && status != null) {
                all = all + resultListElement.count
                columnDate[status] = resultListElement.count
              }
            }
            builderJson = {
              "all": all,
              "charts": columnDate,
              "ie": 9743
            }
            this.statusRefusePie(builderJson)
          }
        })
      }
    },
    statusRefusePie(builderJson) {
      var myChart = echarts.init(document.getElementById('statusRefusePie'));

      builderJson = {
        all: 10887,
        charts: {
          诺书上传资料备注: 1593,
          短信模板上传资料备注: 2060,
          入网签报上传资料备注: 1537,
          经办人证件资料上传资料备注: 1908,
          间资料上传资料备注: 2107,
          测试卡申请单稽核结果备注: 1692,
          基本信息稽核结果备注: 1568,
        },
        components: {
          更新日期: 2984,
          备案通知到期时间: 2739,
          合同到期时间: 2744,
          营业执照到期时间: 2466,
          用户发展员工: 3034,
          码号: 1945
        },
        ie: 9743
      };
      var downloadJson = {
        诺书上传资料备注: 1593,
        短信模板上传资料备注: 2060,
        入网签报上传资料备注: 1537,
        经办人证件资料上传资料备注: 1908,
        间资料上传资料备注: 2107,
        测试卡申请单稽核结果备注: 1692,
        基本信息稽核结果备注: 1568,
      };
      var themeJson = {
        更新日期: 2984,
        备案通知到期时间: 2739,
        合同到期时间: 2744,
        营业执照到期时间: 2466,
        用户发展员工: 3034,
        码号: 1945
      };
      var waterMarkText = 'ECHARTS';
      var canvas = document.createElement('canvas');
      var ctx = canvas.getContext('2d');
      canvas.width = canvas.height = 100;
      ctx.textAlign = 'center';
      ctx.textBaseline = 'middle';
      ctx.globalAlpha = 0.08;
      ctx.font = '20px Microsoft Yahei';
      ctx.translate(50, 50);
      ctx.rotate(-Math.PI / 4);
      ctx.fillText(waterMarkText, 0, 0);
      var option = {
        backgroundColor: {
          type: 'pattern',
          image: canvas,
          repeat: 'repeat'
        },
        tooltip: {},
        title: [
          {
            text: '整改记录（上为资料整改 下为基本信息整改）',
            subtext: '总计 ' + builderJson.all,
            left: '30%',
            textAlign: 'center'
          },
          {
            text: '资料整改字段占比',
            subtext:
              '总计 ' +
              Object.keys(downloadJson).reduce(function (all, key) {
                return all + downloadJson[key];
              }, 0),
            left: '75%',
            textAlign: 'center'
          },
          {
            text: '基本信息整改字段占比',
            subtext:
              '总计 ' +
              Object.keys(themeJson).reduce(function (all, key) {
                return all + themeJson[key];
              }, 0),
            left: '75%',
            top: '50%',
            textAlign: 'center'
          }
        ],
        grid: [
          {
            top: 50,
            width: '50%',
            bottom: '45%',
            left: 10,
            containLabel: true
          },
          {
            top: '55%',
            width: '50%',
            bottom: 0,
            left: 10,
            containLabel: true
          }
        ],
        xAxis: [
          {
            type: 'value',
            max: builderJson.all,
            splitLine: {
              show: false
            }
          },
          {
            type: 'value',
            max: builderJson.all,
            gridIndex: 1,
            splitLine: {
              show: false
            }
          }
        ],
        yAxis: [
          {
            type: 'category',
            data: Object.keys(builderJson.charts),
            axisLabel: {
              interval: 0,
              rotate: 30
            },
            splitLine: {
              show: false
            }
          },
          {
            gridIndex: 1,
            type: 'category',
            data: Object.keys(builderJson.components),
            axisLabel: {
              interval: 0,
              rotate: 30
            },
            splitLine: {
              show: false
            }
          }
        ],
        series: [
          {
            type: 'bar',
            stack: 'chart',
            z: 3,
            label: {
              position: 'right',
              show: true
            },
            data: Object.keys(builderJson.charts).map(function (key) {
              return builderJson.charts[key];
            })
          },
          {
            type: 'bar',
            stack: 'chart',
            silent: true,
            itemStyle: {
              color: '#eee'
            },
            data: Object.keys(builderJson.charts).map(function (key) {
              return builderJson.all - builderJson.charts[key];
            })
          },
          {
            type: 'bar',
            stack: 'component',
            xAxisIndex: 1,
            yAxisIndex: 1,
            z: 3,
            label: {
              position: 'right',
              show: true
            },
            data: Object.keys(builderJson.components).map(function (key) {
              return builderJson.components[key];
            })
          },
          {
            type: 'bar',
            stack: 'component',
            silent: true,
            xAxisIndex: 1,
            yAxisIndex: 1,
            itemStyle: {
              color: '#eee'
            },
            data: Object.keys(builderJson.components).map(function (key) {
              return builderJson.all - builderJson.components[key];
            })
          },
          {
            type: 'pie',
            radius: [0, '30%'],
            center: ['75%', '25%'],
            data: Object.keys(downloadJson).map(function (key) {
              return {
                name: key.replace('.js', ''),
                value: downloadJson[key]
              };
            })
          },
          {
            type: 'pie',
            radius: [0, '30%'],
            center: ['75%', '75%'],
            data: Object.keys(themeJson).map(function (key) {
              return {
                name: key.replace('.js', ''),
                value: themeJson[key]
              };
            })
          }
        ]
      };
      myChart.setOption(option);
    },

    getRecentDay: function (n) {
      let day = moment(new Date())
        .subtract(n, "days")
        .format("YYYY-MM-DD");
      return day;
    },

  }
}
</script>
<style scoped>

</style>