<template>
  <div class="data-all-wrap">
    <div v-if="dataType == 0" class="data-chart">
      <div class="box-list">
        <div class="box-min">
          <div v-for="(item , index) in cardData" :key="index" class="box-card" v-bind:class="{ 'box-last': index == 2 }">
            <el-tooltip v-if="index == 2" class="item-tool" placement="bottom-end" effect="light">
              <div slot="content">
                <p v-for="text in item.content">{{ text }}</p>
              </div>
              <i class="el-icon-question notice"></i>
            </el-tooltip>
            <div class="left-content">
              <p class="title">{{ item.title }}</p>
              <p class="value">{{ item.value }}</p>
            </div>
            <div class="vertical"></div>
            <div class="right-content">
              <p class="has">{{ item.hasKey }}：{{ item.hasNum | toThousands }}</p>
              <p class="should">{{ item.shouldKey }}：{{ item.shouldNum | toThousands }}</p>
            </div>
          </div>
        </div>
      </div>
      <div class="date-table">
         <el-tabs class="change-range" v-model="checkRange" type="card" @tab-click="handleCheckRange">
          <el-tab-pane label="累计" name="1"></el-tab-pane>
          <el-tab-pane label="新增" name="2"></el-tab-pane>
        </el-tabs>
        <el-radio-group v-if="showRadioValue === 0" class="change-date" v-model="checkTime" size="medium" @change="handleCheckTime">
          <el-radio-button label="1">日</el-radio-button>
          <el-radio-button label="2">周</el-radio-button>
          <el-radio-button label="3">月</el-radio-button>
          <el-radio-button label="4">年</el-radio-button>
        </el-radio-group>
        <div v-if="showRadioValue === 1" class="change-radio">{{ changeRadio[checkTime] }}</div>
        <el-table :data="tableDateTime" style="width: 100%">
          <el-table-column prop="date" label="日期" align="center" min-width="100"></el-table-column>
          <el-table-column prop="hospitalCount" label="应参与机构数" align="center"></el-table-column>
          <el-table-column prop="hospitalJoinCount" label="已参与机构数" align="center"></el-table-column>
          <el-table-column prop="doctorCount" label="应参与人数" align="center"></el-table-column>
          <el-table-column prop="doctorJoinCount" label="已参与人数" align="center"></el-table-column>
          <el-table-column prop="finishCount" :label="finishCountLabel" align="center"></el-table-column>

          <el-table-column v-if="gradeFlag[0] == true" prop="grade1Count" label="优秀" align="center"></el-table-column>
          <el-table-column v-if="gradeFlag[1] == true" prop="grade2Count" label="良好" align="center"></el-table-column>
          <el-table-column v-if="gradeFlag[2] == true" prop="grade3Count" label="及格" align="center"></el-table-column>
          <el-table-column v-if="gradeFlag[3] == true" prop="grade4Count" label="不及格" align="center"></el-table-column>
          <div slot="empty">
            <div class="table-empty">
              <img src="../../assets/image/noData.png" />
            </div>
          </div>
        </el-table>
        <div class="pagination">
          <el-pagination
            background
            @size-change="handleSizeDwmy"
            @current-change="handleCurrentDwmy"
            :current-page="formDwmy.pageNo"
            :page-sizes="[20, 30, 100 ,200]"
            :page-size="formDwmy.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount"
          ></el-pagination>
        </div>
      </div>
      <div v-if="certFlag != 0">
      <div v-if="downloadId == null">
        <div class="spacing"></div>
        <div class="chart-title">证书分布情况</div>
        <div v-if="showDistributeChart === true" class="chart-distributeChart">
          <div class="distributeChart" id="distributeChart" ref="distributeChart"></div>
          <div class="data-text">
            <div class="content-text">
              <p v-for="item in distributeList" >{{item.label}}：{{item.value}}人</p>
            </div>
          </div>
        </div>
        <div v-if="showDistributeChart === false" class="empty-img">
          <img src="../../assets/image/noData.png" />
        </div>
      </div>
      <div class="spacing"></div>
      <div class="chart-title">证书级别按学历分布情况</div>
      <div class="overflow-chart">
      <div v-if="showRecordChart === true" class="chart-recordChart">
        <div class="recordChart" id="recordChart" ref="recordChart"></div>
        <div class="data-text">
          <div class="content-text">
            <p v-for="item in recordList" >{{item.label}}：{{item.value}}人</p>
          </div>
        </div>
      </div>
      </div>
      <div v-if="showRecordChart === false" class="empty-img">
        <img src="../../assets/image/noData.png" />
      </div>
      </div>
      <!-- <div v-if="certFlag != 0"> -->
        <div class="spacing"></div>
        <div class="chart-title-more">
          <p>项目情况排名</p>
          <el-radio-group v-if="showCertificateChart === true && showRadioValue === 0"  class="rank-radio" size="medium" v-model="rankType" @change="changeRank">
            <el-radio-button label="1">{{ rankLabel1 }}</el-radio-button>
            <el-radio-button label="2">{{ rankLabel2 }}</el-radio-button>
            <el-radio-button label="3">按参与人数排名</el-radio-button>
          </el-radio-group>
          <div v-if="showRadioValue === 1" class="change-radio2">{{ changeRadio2[rankType] }}</div>
        </div>
        <div v-if="showCertificateChart === true" class="overflow-chart">
          <div class="chartCert" id="certificateChart" ref="certificateChart"></div>
        </div>
        <div v-if="showCertificateChart === false" class="empty-img">
          <img src="../../assets/image/noData.png" />
        </div>
        <div class="spacing"></div>
        <div class="chart-title">在线培训完成天数情况</div>
        <div v-if="showDurationChart === true" class="overflow-chart">
          <div class="chartDuration" id="durationChart" ref="durationChart"></div>
        </div>
        <div v-if="showDurationChart === false" class="empty-img">
          <img src="../../assets/image/noData.png" />
        </div>
        <div class="chart-remarks">注：在线培训完成天数=完成项目时间-开始参与项目时间</div>
        <div class="spacing"></div>
      </div>
    <!-- </div> -->
    <div v-if="dataType == 1" class="data-table">
      <div class="box-list">
        <div class="box-min-2">
          <div v-for="(item , index) in cardData" :key="index" class="box-card box-card2" v-bind:class="{ 'box-last': index == 1 }">
            <el-tooltip v-if="index == 1" class="item-tool" placement="bottom-end" effect="light">
              <div slot="content">
                <p v-for="text in item.content">{{ text }}</p>
              </div>
              <i class="el-icon-question notice"></i>
            </el-tooltip>
            <div class="left-content">
              <p class="title">{{ item.title }}</p>
              <p class="value">{{ item.value }}</p>
            </div>
            <div class="vertical"></div>
            <div class="right-content">
              <p class="has">{{ item.hasKey }}：{{ item.hasNum | toThousands }}</p>
              <p class="should">{{ item.shouldKey }}：{{ item.shouldNum | toThousands }}</p>
            </div>
          </div>
        </div>
      </div>
      <div class="date-table">
         <el-tabs class="change-range" v-model="checkRange" type="card" @tab-click="handleCheckRange">
          <el-tab-pane label="累计" name="1"></el-tab-pane>
          <el-tab-pane label="新增" name="2"></el-tab-pane>
        </el-tabs>
        <el-radio-group v-if="showRadioValue === 0" class="change-date" v-model="checkTime" size="medium" @change="handleCheckTime">
          <el-radio-button label="1">日</el-radio-button>
          <el-radio-button label="2">周</el-radio-button>
          <el-radio-button label="3">月</el-radio-button>
          <el-radio-button label="4">年</el-radio-button>
        </el-radio-group>
        <div v-if="showRadioValue === 1" class="change-radio">{{ changeRadio[checkTime] }}</div>
        <el-table :data="tableDateTime" style="width: 100%">
          <el-table-column prop="date" label="日期" align="center" min-width="100"></el-table-column>
          <el-table-column prop="doctorCount" label="应参与人数" align="center"></el-table-column>
          <el-table-column prop="doctorJoinCount" label="已参与人数" align="center"></el-table-column>
          <el-table-column prop="finishCount" :label="finishCountLabel" align="center"></el-table-column>

          <el-table-column v-if="gradeFlag[0] == true" prop="grade1Count" label="优秀" align="center"></el-table-column>
          <el-table-column v-if="gradeFlag[1] == true" prop="grade2Count" label="良好" align="center"></el-table-column>
          <el-table-column v-if="gradeFlag[2] == true" prop="grade3Count" label="及格" align="center"></el-table-column>
          <el-table-column v-if="gradeFlag[3] == true" prop="grade4Count" label="不及格" align="center"></el-table-column>
          <div slot="empty">
            <div class="table-empty">
              <img src="../../assets/image/noData.png" />
            </div>
          </div>
        </el-table>
        <div class="pagination">
          <el-pagination
            background
            @size-change="handleSizeDwmy"
            @current-change="handleCurrentDwmy"
            :current-page="formDwmy.pageNo"
            :page-sizes="[20, 30, 100 ,200]"
            :page-size="formDwmy.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount"
          ></el-pagination>
        </div>
      </div>
      <div class="spacing"></div>
      <div class="person">
        <div class="person-title">项目人员情况</div>
        <el-tabs v-if="downloadId == null" class="tabs-person" v-model="tableType" type="card" @tab-click="handlePerson">
          <el-tab-pane :label="tableLabel1" name="1"></el-tab-pane>
          <el-tab-pane :label="tableLabel2" name="2"></el-tab-pane>
          <el-tab-pane label="未参与" name="3"></el-tab-pane>
        </el-tabs>
        <div v-if="downloadId == null">
          <el-table
          v-loading="loadingTable"
          :data="tableData"
          class="person-table"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.8)"
          >
            <el-table-column v-if="tableType == '1'" prop="rankNo" label="排名" align="center"></el-table-column>
            <el-table-column prop="doctorName" label="姓名" align="center"></el-table-column>
            <el-table-column prop="sex" label="性别" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.sex  | sexValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="departmentName" label="科室" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.departmentName | departmentNameValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="joinFlag" label="是否参与项目" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.joinFlag  | joinFlagValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="finishFlag" label="是否完成项目" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.finishFlag | finishFlagValue}}</span>
              </template>
            </el-table-column>
            <el-table-column v-if="certFlag == 2" prop="certGrade" label="证书级别" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.certGrade | certGradeValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="finishDate" label="完成项目日期" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.finishDate | nullOfValue}}</span>
              </template>
            </el-table-column>
            <el-table-column v-if="containOfficialFlag == 1" prop="score" label="成绩" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.score | nullOfValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="learnTime" min-width="150" label="学习时长" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.learnTime | learnTimeValue}}</span>
              </template>
            </el-table-column>
            <div slot="empty">
              <div class="table-empty">
                <img src="../../assets/image/noData.png" />
              </div>
            </div>
          </el-table>
        </div>
        <div v-if="downloadId != null" class="front-table">
          <el-table :data="tableData.slice((formTable.pageNo-1)*formTable.pageSize,formTable.pageNo*formTable.pageSize)" class="person-table">
            <el-table-column prop="doctorName" label="姓名" align="center"></el-table-column>
            <el-table-column prop="sex" label="性别" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.sex  | sexValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="departmentName" label="科室" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.departmentName | departmentNameValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="joinFlag" label="是否参与项目" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.joinFlag  | joinFlagValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="finishFlag" label="是否完成项目" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.finishFlag | finishFlagValue}}</span>
              </template>
            </el-table-column>
            <el-table-column v-if="certFlag == 2" prop="certGrade" label="证书级别" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.certGrade | certGradeValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="finishDate" label="完成项目日期" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.finishDate | nullOfValue}}</span>
              </template>
            </el-table-column>
            <el-table-column v-if="containOfficialFlag == 1" prop="score" label="成绩" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.score | nullOfValue}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="learnTime" min-width="150" label="学习时长" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.learnTime | learnTimeValue}}</span>
              </template>
            </el-table-column>
            <div slot="empty">
              <div class="table-empty">
                <img src="../../assets/image/noData.png" />
              </div>
            </div>
          </el-table>
        </div>
        <div class="chart-remarks">注：成绩=完成项目要求的所有考试平均分（不包含摸底考试）</div>
        <div class="pagination">
          <el-pagination
            class="pagination"
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="formTable.pageNo"
            :page-sizes="[20, 30, 100 ,200]"
            :page-size="formTable.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalRows"
          ></el-pagination>
        </div>
      </div>
      <div class="spacing"></div>
    </div>
  </div>
</template>
<script>
import { openLoading, closeLoading } from "../../utils/utils";
import * as commonUtil from "../../utils/utils";
import * as operationData from "../../utils/operation";
import * as chartData from "../../utils/learning/chartData";
import echarts from "echarts";
import { setTimeout } from "timers";
let vm = null;
export default {
  props: {
    formInline: {
      type: Object
    },
    activeName: {
      type: String
    },
    organizationNum: {
      type: Number
    },
    organizationList: {
      type: Array
    },
    timeInfoData: {
      type: Object
    },
    showRadio: {
      type: Number
    }
  },
  data() {
    return {
      roleType: "L1",
      projectId: "",
      dataType: 0,
      tableType: "1",
      echartsData: {
        chart0: {},
        chart1: {},
        chart2: {},
        chart3: {}
      },
      distributeList: [],
      recordList: [],
      cardData: [],
      rankType: "1",
      rankOptions: [
        {
          value: 1,
          label: "按获证比例排名"
        },
        {
          value: 2,
          label: "按参与人数排名"
        }
      ],
      tableData: [],
      tableDateTime: [],
      totalRows: 0,
      formDwmy: {
        pageNo: 1,
        pageSize: 20,
      },
      formTable: {
        pageNo: 1,
        pageSize: 20,
      },
      checkRange: "1",
      checkTime: "1",
      totalCount: 0,
      gradeFlag: [false, false, false, false],
      hospitalCnt: '',
      hospitalCutList: [],
      certFlag: 0,
      downloadId: null,
      timeInfoChild: {},

      showDistributeChart: true,
      showRecordChart: true,
      showCertificateChart: true,
      showDurationChart: true,

      finishCountLabel: '获证人数',
      rankLabel1: '按获证人数排名',
      rankLabel2: '按获证比例排名',
      tableLabel1: '已获证',
      tableLabel2: '未获证',
      containOfficialFlag: 1,
      changeRadio: {
        '1': '日',
        '2': '周',
        '3': '月',
        '4': '年',
      },
      changeRadio2: {
        '1': '按完成人数排名',
        '2': '按完成比例排名',
        '3': '按参与人数排名',
      },
      showRadioValue: 0,
      loadingTable: false,
    };
  },
  watch: {
    timeInfoData: {
      deep: true,
      handler(nv, ov) {
        vm.timeInfoChild = nv;
      }
    },
    showRadio: {
      deep: true,
      handler(nv, ov) {
        vm.showRadioValue = nv;
      }
    },
  },
  created() {
    vm = this;
    vm.projectId = vm.getUrlSearch(window.location.href, "id");
    vm.downloadId = vm.getUrlSearch(window.location.href, "downloadId");
  },
  mounted: function() {
    this.$on("search", () => {
      vm.gethHspitalsCnt();
    });
    this.$on("static", () => {
      vm.getStatic();
    });
  },
  methods: {
    getStatic() {
      // console.log(vm.timeInfoChild.reportParamModel);
      if(vm.timeInfoChild.reportParamModel.hospitalIdList != null && vm.timeInfoChild.reportParamModel.hospitalIdList.length == 1) {
        vm.dataType = 1;
      } else {
        vm.dataType = 0;
      }
      // console.log('展示all类型：',vm.dataType)
      vm.setStatic();
    },
    setCertLabel() {
      if(vm.certFlag == 0) {
        //无证
        vm.finishCountLabel = '完成人数';
        vm.rankLabel1 = '按完成人数排名';
        vm.rankLabel2 = '按完成比例排名';
        vm.tableLabel1 = '已完成';
        vm.tableLabel2 = '未完成';

        let a = '1';
        let b = '2';
        vm.changeRadio2[a] = '按完成人数排名';
        vm.changeRadio2[b] = '按完成比例排名';
      } else {
        vm.finishCountLabel = '获证人数';
        vm.rankLabel1 = '按获证人数排名';
        vm.rankLabel2 = '按获证比例排名';
        vm.tableLabel1 = '已获证';
        vm.tableLabel2 = '未获证';

        let a = '1';
        let b = '2';
        vm.changeRadio2[a] = '按获证人数排名';
        vm.changeRadio2[b] = '按获证比例排名';
      }
    },
    setStatic() {
      vm.certFlag = vm.timeInfoChild.doctorInfoRep.certFlag;
      vm.containOfficialFlag = vm.timeInfoChild.doctorInfoRep.containOfficialFlag;
      vm.setCertLabel();
      vm.searchDwmy();
      vm.initCard(vm.timeInfoChild.genSituationModel.percentData);
      if(vm.dataType == 0) {
        //多个机构
        setTimeout(function(){
          if(vm.certFlag !== 0) {
            vm.setRecordChart(vm.timeInfoChild.genSituationModel.eduData);
          }
          // if(vm.certFlag !== 0) {
          let certificateChart = vm.timeInfoChild.genSituationModel.studyRankMap[0];
          if(certificateChart === undefined) {
            certificateChart = [];
          }
          vm.setCertificateChart(certificateChart);
          vm.setDurationChart(vm.timeInfoChild.genSituationModel.costRank);
          // }
        },20)
      } else {
        //单个几个
        let genSituationModel = vm.timeInfoChild.genSituationModel;
        vm.totalRows = genSituationModel.personData.length;
        vm.tableData = genSituationModel.personData;
      }
    },
    gethHspitalsCnt() {
      if (vm.formInline.organization.length == 0) {//无机构
        let req = {
          projectId: vm.projectId,
          // regionId: vm.formInline.region[vm.formInline.region.length - 1]
          regionId: vm.formInline.selectRegionId
        };
        vm.GET("stats/region/hospitals/cnt", req, '', '', true).then(res => {
          if (res.code == "000000") {
            vm.hospitalCnt = res.data.hospitalCnt;
            if(vm.hospitalCnt == 1) {
              vm.hospitalCutList = res.data.list;
            }
          }
        });
      }else {
        vm.hospitalCnt = 1;
      }
      vm.getDisplay();
    },
    getDisplay() {
      let reqInfo = {
        projectId: vm.projectId,
      };
      vm.GET("stats/region/info", reqInfo).then(res => {
        if (res.code == "000000") {
          vm.certFlag = res.data.certFlag; //有无证书，0无证书，1有证书
          vm.containOfficialFlag = res.data.containOfficialFlag;
          vm.setCertLabel();
          vm.searchType();
        }
      });
    },
    searchType() {
      if(vm.formInline.organization.length == 1) {
        vm.dataType = 1;
      } else {
        if(vm.hospitalCnt == 1) { //有机构
          vm.dataType = 1;
        } else { //无机构
          vm.dataType = 0;
        }
      }
      // console.log('vm.hospitalCnt',vm.hospitalCnt);
      vm.checkRange = "1";
      vm.checkTime = "1";
      vm.rankType = "1";
      vm.tableType = "1";
      if(vm.dataType == 0) {
        this.search();
        this.searchDwmy();
      } else {
        this.searchDwmy();
        this.searchPerson();
      }
    },
    searchPerson(type) {
      let req = {
        projectId: vm.projectId,
        beginDate: operationData.setDuringTime(vm.formInline.during,'begin'),
        endDate: operationData.setDuringTime(vm.formInline.during,'end'),
        hospitalIdList: vm.formInline.organization,
        originalFlag: vm.formInline.checked == false ? 2 : 1,
        // regionId: vm.formInline.region[vm.formInline.region.length - 1],
        regionId: vm.formInline.selectRegionId,
        timeFlag: vm.formInline.timeFlag,
        sourceType: 2,
        pageNo: vm.formTable.pageNo,
        pageSize: vm.formTable.pageSize,
      };
      // if(req.hospitalIdList.length == 0) {
      //   req.hospitalIdList = [];
      //   req.hospitalIdList[0] = vm.hospitalCutList[0].hospitalId;
      // }
      vm.loadingTable = true;
      vm.POST("stats/report/generalPersonal/"+vm.tableType, req, '', '', true).then(res => {
        if (res.code == "000000") {
          vm.loadingTable = false;
          if(type != 1) {
            vm.initCard(res.data.percentData);
          }
          vm.totalRows = res.data.totalSize;
          vm.tableData = res.data.personData;
        }
      });
    },
    handlePerson(tab, event) {
      vm.tableType = tab.name;
      vm.formTable.pageNo = 1;
      vm.searchPerson(1);
    },
    search() {
      let req = {
        projectId: vm.projectId,
        beginDate: operationData.setDuringTime(vm.formInline.during,'begin'),
        endDate: operationData.setDuringTime(vm.formInline.during,'end'),
        hospitalIdList: vm.formInline.organization,
        originalFlag: vm.formInline.checked == false ? 2 : 1,
        // regionId: vm.formInline.region[vm.formInline.region.length - 1],
        regionId: vm.formInline.selectRegionId,
        timeFlag: vm.formInline.timeFlag,
      };
      vm.POST("stats/report/general_pc", req, '', '', true).then(res => {
        if (res.code == "000000") {
          vm.initCard(res.data.percentData);
          if(vm.certFlag !== 0) { //有证书情况
            vm.setDistributeChart(res.data.certData);
            vm.setRecordChart(res.data.eduData);
          }
          // if(vm.certFlag !== 0) {
          vm.setCertificateChart(res.data.studyRank);
          vm.setDurationChart(res.data.costRank);
          // }
        }
      });
    },
    //整体情况中获取累积或新增table的数据
    searchDwmy() {
      let req = {};
      if(vm.downloadId == null) {
        req = {
          projectId: vm.projectId,
          beginDate: operationData.setDuringTime(vm.formInline.during,'begin'),
          endDate: operationData.setDuringTime(vm.formInline.during,'end'),
          hospitalIdList: vm.formInline.organization,
          originalFlag: vm.formInline.checked == false ? 2 : 1,
          // regionId: vm.formInline.region[vm.formInline.region.length - 1],
          regionId: vm.formInline.selectRegionId,
          timeFlag: vm.formInline.timeFlag,
          timeType: parseInt(vm.checkTime), //日周月年的选择
          dataType: parseInt(vm.checkRange),//累积和新增的选择
          pageNo: vm.formDwmy.pageNo,
          pageSize: vm.formDwmy.pageSize,
        };
      } else {
        let reportParamModel = vm.timeInfoChild.reportParamModel;
        req = {
          projectId: reportParamModel.projectId,
          beginDate: reportParamModel.beginDate,
          endDate: reportParamModel.endDate,
          hospitalIdList: reportParamModel.hospitalIdList,
          originalFlag: reportParamModel.originalFlag,
          regionId: reportParamModel.regionId,
          timeFlag: reportParamModel.timeFlag,
          timeType: parseInt(vm.checkTime),
          dataType: parseInt(vm.checkRange),
          pageNo: vm.formDwmy.pageNo,
          pageSize: vm.formDwmy.pageSize,
        };
      }
      vm.POST("stats/dwmy/", req, '', '', true).then(res => {
        if (res.code == "000000") {
          vm.tableDateTime = res.data.list;
          vm.totalCount = res.data.totalCount;
          for(let i=0 ; i < res.data.title.length ; i++) {
            vm.gradeFlag[i] = res.data.title[i].show;
          }
        }
      });
    },
    handleCheckRange(tab, event) {
      vm.formDwmy.pageNo = 1;
      vm.checkRange = tab.name;
      vm.searchDwmy();
    },
    handleCheckTime(value) {
      vm.formDwmy.pageNo = 1;
      vm.timeType = value;
      vm.searchDwmy();
    },
    //初始化机构参与率、人员参与率...
    initCard(data) {
      let cardData = [
        {
          value: "0%",
          title: "机构参与率",
          hasKey: "已参与机构数",
          hasNum: "0",
          shouldKey: "应参与机构数",
          shouldNum: "0",
          content: [
            "机构参与率：已参与机构数/应参与机构数*100% ",
            "应参与机构数：筛选范围下，所有圈选机构数量，包含白名单反退出来的机构",
            "已参与机构数：筛选范围下，在应参与机构中，机构学员有参与项目行为的机构数量"
          ]
        },
        {
          value: "0%",
          title: "人员参与率",
          hasKey: "已参与人数",
          hasNum: "0",
          shouldKey: "应参与人数",
          shouldNum: "0",
          content: [
            "人员参与率：已参与人数/应参与人数*100%",
            "应参与人数：筛选范围下，所圈选人员数量",
            "已参与人数：筛选范围下，在应参与人员中，有参与项目行为的人员数量"
          ]
        },
        {
          value: "0%",
          title: "获证率",
          hasKey: "已获证人数",
          hasNum: "0",
          shouldKey: "应参与人数",
          shouldNum: "0",
          content: [
            "获证率：已获证人数/应参与人数*100%",
          ]
        }
      ];
      if(data == null) {
        //数据为空
        if(vm.dataType == 0) {
          vm.cardData = cardData;
        } else if(vm.dataType == 1) {
          vm.cardData = cardData.slice(1);
        }
        return;
      }
      cardData[2].title = vm.certFlag == 0 ? '完成率' : '获证率';
      cardData[2].hasKey = vm.certFlag == 0 ? '已完成人数' : '已获证人数';
      if(vm.certFlag == 0) {
        cardData[2].content = [
          "完成率：已完成人数/应参与人数*100%",
        ]
      } else {
        cardData[2].content = [
          "获证率：已获证人数/应参与人数*100%",
        ]
      }

      cardData[1].value = parseFloat((data.doctorRate*100).toFixed(1)) + '%';
      cardData[1].hasNum = data.joinCount;
      cardData[1].shouldNum = data.doctorCount;

      cardData[2].value = parseFloat((data.certificateRate*100).toFixed(1)) + '%';
      cardData[2].hasNum = data.finishCount;
      cardData[2].shouldNum = data.doctorCount;
      if(vm.dataType == 0) {
        cardData[0].value = parseFloat((data.hospitalRate*100).toFixed(1)) + '%';
        cardData[0].hasNum = data.hospitalJoinCount;
        cardData[0].shouldNum = data.hospitalCount;

        vm.cardData = cardData;
      } else if(vm.dataType == 1) {
        vm.cardData = cardData.slice(1);
      }
    },
    updateResize() {
      // setTimeout(function() {
      //   window.onresize = function() {
      //     vm.echartsData.chart0.resize();
      //     vm.echartsData.chart1.resize();
      //     vm.echartsData.chart2.resize();
      //     vm.echartsData.chart3.resize();
      //   };
      // },100);
    },
    //设置--证书分布情况
    setDistributeChart(data) {
      if(data.length == 0) {
        vm.showDistributeChart = false;
        return;
      } else {
        vm.showDistributeChart = true;
      }
      let keyName = ['未获证人数','优秀人数','良好人数','及格人数','不及格人数','已获证人数'];
      let keyName2 = ['未获证人数占比','优秀人数占比','良好人数占比','及格人数占比','不及格人数占比','已获证人数占比'];
      let distributeList = [];
      let legendData = [];
      let seriesData = [];
      //certId为-1 或 单证下 特殊处理
      for(let i = 0; i<data.length ; i++) {
        if(data[i].certId == -1) {
          data[i].certId = 0;
        }
        if(vm.certFlag == 1 && data[i].certId !== -1 && data[i].certId !== 0) {
          data[i].certId = 5;
        }
      }
      //
      for(let i = 0; i<data.length ; i++) {
        let obj = {
          label: keyName[data[i].certId],
          value: data[i].doneCount,
        };
        distributeList.push(obj);

        legendData.push(keyName2[data[i].certId])
        let objSer = {
          name: keyName2[data[i].certId],
          value: data[i].doneCount,
        }
        seriesData.push(objSer);
      }
      vm.distributeList = distributeList;
      setTimeout(function(){
        let myChart = echarts.init(vm.$refs.distributeChart);
        let option = chartData.dustributeOption(legendData,seriesData);
        myChart.setOption(option);
        // vm.echartsData.chart0 = myChart;
        // vm.updateResize();
      },20);
    },
    //设置--证书级别按学历分布情况
    setRecordChart(data) {
      if(data.length == 0) {
        vm.showRecordChart = false;
        return;
      } else {
        vm.showRecordChart = true;
      }
      let recordList = [
        {
          label: '博士后',
          value: 0,
        },
        {
          label: '博士',
          value: 0,
        },
        {
          label: '硕士',
          value: 0,
        },
        {
          label: '本科',
          value: 0,
        },
        {
          label: '大专',
          value: 0,
        },
        {
          label: '中专及以下',
          value: 0,
        },
        {
          label: '其他',
          value: 0,
        },
      ]
      let keyName = ['未获证人数','获优秀人数','获良好人数','获及格人数','获不及格人数','已获证人数'];
      let legendData = [];
      let xAxisData = ["博士后","博士", "硕士", "本科", "大专", "中专及以下", "其他"];
      //certId为-1 或 单证下 特殊处理
      for(let i = 0; i<data.length ; i++) {
        if(data[i].certId == -1) {
          data[i].certId = 0;
        }
        if(vm.certFlag == 1 && data[i].certId !== -1 && data[i].certId !== 0) {
          data[i].certId = 5;
        }
      }
      //
      for(let i = 0; i<data.length; i++) {
        // console.log('data[i]',data[i].certList);
        let certList = data[i].certList;
        legendData.push(keyName[data[i].certId]);
        for(let a = 0; a < certList.length ; a++) {
          recordList[a].value += certList[a].value;
        }
      }
      let seriesData = [];
      let seriesArr = [];
      let seriesName = [];
      let index = 0;
      for(let x = data.length - 1 ; x >= 0 ; x--) {
        let certList = data[x].certList;
        seriesArr[index] = [];
        seriesName.push(keyName[data[x].certId]);
        for(let y = 0; y < certList.length ; y++) {
          seriesArr[index].push(certList[y].value);
        }
        index++;
      }
      let colorValue = ['#5D7092', '#39AF9A', '#FFB01B', '#FF9A4B', '#3BA0FF'];
      for(let z = 0; z < seriesArr.length ; z++) {
        let seriesObj = {
          name: seriesName[z],
          type: "bar",
          stack: "总量",
          barWidth: 18,
          label: {
            normal: {
              show: true,
              rotate: -90,
            }
          },
          itemStyle: {
            color: colorValue[seriesArr.length - z -1],
          },
          data: seriesArr[z],
        };
        seriesData.push(seriesObj);
      }
      vm.recordList = recordList;
      setTimeout(function(){
        let myChart = echarts.init(vm.$refs.recordChart);
        let option = chartData.recordOption(legendData, xAxisData, seriesData);
        // console.log('data',legendData,xAxisData,seriesData,option);
        myChart.clear();
        myChart.setOption(option);
        // vm.echartsData.chart1 = myChart;
        // vm.updateResize();
      },20);
    },
    changeRank(value) {
      if(vm.downloadId == null) {
        let req = {
          projectId: vm.projectId,
          beginDate: operationData.setDuringTime(vm.formInline.during,'begin'),
          endDate: operationData.setDuringTime(vm.formInline.during,'end'),
          // hospitalIdList: vm.formInline.organization,
          hospitalIdList: vm.formInline.orgId,
          originalFlag: vm.formInline.checked == false ? 2 : 1,
          // regionId: vm.formInline.region[vm.formInline.region.length - 1],
          regionId: vm.formInline.selectRegionId,
          timeFlag: vm.formInline.timeFlag,
        };
        openLoading(vm);
        vm.POST("stats/report/studyRank/"+value, req).then(res => {
          closeLoading(vm);
          vm.setCertificateChart(res.data.studyRank);
        });
      } else {
        let index = parseInt(value) - 1;
        vm.setCertificateChart(vm.timeInfoChild.genSituationModel.studyRankMap[index]);
      }
    },
    //设置--项目情况排名
    setCertificateChart(data) {
      if(data.length == 0) {
        vm.showCertificateChart = false;
        return;
      } else {
        vm.showCertificateChart = true;
      }
      let legendData = [];
      if(vm.certFlag == 0) {
        legendData = ["参与人数", "完成人数", "完成比例"];
      } else {
        legendData = ["参与人数", "获证人数", "获证比例"];
      }
      let xAxisData = [];
      let seriesJoin = [];
      let seriesCert = [];
      let seriesRate = [];
      for(let i = 0 ; i < data.length ; i++) {
        xAxisData.push(data[i].subName);
        seriesJoin.push(data[i].joinCount);
        seriesCert.push(data[i].certCount);
        seriesRate.push(parseFloat((data[i].certRate*100).toFixed(1)));
      }
      setTimeout(function(){
        let myChart = echarts.init(vm.$refs.certificateChart);
        let option = chartData.certificateOption(xAxisData, seriesJoin, seriesCert, seriesRate, legendData);
        myChart.setOption(option);
        // vm.echartsData.chart2 = myChart;
        // vm.updateResize();
      },20);
    },
    //设置--在线培训完成天数情况
    setDurationChart(data) {
      if(data.length == 0) {
        vm.showDurationChart = false;
        return;
      } else {
        vm.showDurationChart = true;
      }
      let xAxisData = [];
      let seriesData = [];
      for(let i = 0 ; i<data.length ; i++) {
        xAxisData.push(data[i].subName);
        seriesData.push(parseFloat((data[i].costTime).toFixed(1)));
      }
      setTimeout(function(){
        let myChart = echarts.init(vm.$refs.durationChart);
        let option = chartData.durationOption(xAxisData, seriesData);
        myChart.setOption(option);
        vm.echartsData.chart3 = myChart;
        vm.updateResize();
      },20);
    },
    //日周月年分页
    handleSizeDwmy(val) {
      console.log(`每页 ${val} 条`);
      vm.formDwmy.pageSize = val;
      vm.formDwmy.pageNo = 1;
      vm.searchDwmy();
    },
    handleCurrentDwmy(val) {
      console.log(`当前页: ${val}`);
      vm.formDwmy.pageNo = val;
      vm.searchDwmy();
    },
    //机构人员分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      vm.formTable.pageSize = val;
      vm.formTable.pageNo = 1;
      if(vm.downloadId == null) {
        vm.searchPerson(1);
      }
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      vm.formTable.pageNo = val;
      if(vm.downloadId == null) {
        vm.searchPerson(1);
      }
    },
  }
};
</script>
<style lang="scss">
.el-tooltip__popper.is-light[x-placement^=bottom-end] {
  width: 330px;
  background-color: #449284;
  border-color: #449284;
  color: #ffffff;
  .popper__arrow::after {
    border-bottom-color: #449284;
  }
  .popper__arrow {
    border-bottom-color: #449284;
  }
}
.data-all-wrap {
  background: #fff;
  overflow: hidden;
  // padding: 10px;
  .change-radio {
    position: absolute;
    top: 0px;
    right: 25px;
    width:60px;
    height:34px;
    background:rgba(68,146,132,1);
    border-radius:4px;
    font-size:14px;
    line-height: 34px;
    text-align: center;
    color: #fff;
  }
  .change-radio2 {
    position: absolute;
    top: 26px;
    right: 30px;
    width: 120px;
    height:34px;
    background:rgba(68,146,132,1);
    border-radius:4px;
    font-size:14px;
    line-height: 34px;
    text-align: center;
    color: #fff;
  }
  .table-empty {
    img {
      height: 24px;
      width: 106px;
    }
  }
  .box-list {
    position: relative;
    margin: 30px 30px 0 30px;
    height: 120px;
    overflow-x: auto;
    overflow-y: hidden;
    .box-min {
      height: 106px;
      min-width: 1050px;
    }
    .box-min-2 {
      height: 106px;
      min-width: 900px;
    }
    .box-card {
      position: relative;
      background-color: #F1F7F6;
      color: #449284;
      width: 32%;
      margin-right: 2%;
      height: 106px;
      float: left;
      border-radius:2px;
      .notice {
        position: absolute;
        z-index: 999;
        top: 21px;
        right: 14px;
        width: 16px;
        height: 16px;
      }
      .el-card__header {
        border-bottom-width: 0;
      }
      .el-card__body {
        padding: 0px;
      }
      .left-content {
        position: relative;
        float: left;
        width: 33%;
        height: 106px;
        text-align: left;
        padding: 23px 0 0 20px;
        .title {
          font-size: 14px;
          height: 14px;
          line-height: 14px;
        }
        .value {
          margin-top: 20px;
          height: 22px;
          font-size: 30px;
          line-height: 22px;
          font-weight: 500;
        }
      }
      .vertical {
        position: absolute;
        left: 120px;
        float: left;
        margin-top: 23px;
        width:1px;
        height:57px;
        background-color: #C1D8D4;
      }
      .right-content {
        position: relative;
        float: left;
        width: 64%;
        height: 106px;
        text-align: left;
        font-size: 14px;
        padding: 33px 0 0 29px;
        p {
          height: 14px;
          line-height: 14px;
        }
        .should {
          margin-top: 12px;
        }
      }
    }
    .box-card2 {
      width: 49%;
      margin-right: 2%;
    }
    .box-last {
      margin-right: 0;
    }
  }
  .spacing {
    position: relative;
    width: 100%;
    height: 20px;
    background: #f0f2f5;
  }
  .date-table {
    position: relative;
    width: 100%;
    margin-top: 20px;
    padding: 0 30px 0 30px;
    .change-range {
      .el-tabs__header {
        margin-bottom: 0px;
      }
      .el-tabs__nav-scroll {
        margin-left: 0px;
      }
    }
    .change-date {
      position: absolute;
      top: 0px;
      right: 30px;
      z-index: 10;
    }
  }
  .rank-radio {
    position: relative;
  }
  .chart-title {
    position: relative;
    margin-top: 30px;
    margin-left: 30px;
    height: 25px;
    font-size:18px;
    font-weight:600;
    line-height: 25px;
    color: #000000;
  }
  .chart-title-more {
    position: relative;
    width: 100%;
    height: 70px;
    p {
      position: relative;
      float: left;
      width: 400px;
      margin-top: 30px;
      margin-left: 30px;
      height: 25px;
      font-size:18px;
      font-weight:600;
      line-height: 25px;
      color: #000000;
    }
    .rank-radio {
      position: relative;
      margin: 30px 30px 0 0;
      float: right;
      .el-radio-button__inner {
        padding: 7px 11px;
      }
    }
  }
  .chart-remarks {
    position: relative;
    height: 66px;
    padding: 20px 0 30px 30px;
    font-size: 16px;
    font-weight: 400;
    line-height: 16px;
    color: #666666;
  }
  .chartCert {
    position: relative;
    margin: 20px auto 0 auto;
    width: 1064px;
    height: 462px;
  }
  .chartDuration {
    position: relative;
    margin: 20px auto 0 auto;
    width: 1064px;
    height: 380px;
  }
  .chart-distributeChart {
    position: relative;
    margin: 20px auto 0 auto;
    // height: 320px;
    width: 100%;
    overflow-x: hidden;
    .distributeChart {
      position: relative;
      // float: left;
      margin: 0 auto 30px auto;
      // width: 70%;
      width: 618px;
      height: 320px;
    }
    .data-text {
      position: absolute;
      top: 0;
      left: 50%;
      margin-left: 307px;
      height: 320px;
      width: 30%;
      .content-text {
        position: relative;
        margin-top: 78px;
        text-align: left;
        p {
          margin-top: 20px;
          height:12px;
          font-size:12px;
          font-weight:400;
          color:rgba(102,102,102,1);
          line-height:12px;
        }
      }
    }
  }
  .chart-recordChart {
    position: relative;
    margin: 20px auto 0 auto;
    // height: 350px;
    width: 1030px;
    overflow-x: hidden;
    .recordChart {
      position: relative;
      float: left;
      // width: 83.5%;
      width: 910px;
      height: 416px;
    }
    .data-text {
      position: relative;
      float: left;
      width: 120px;
      height: 416px;
      .content-text {
        position: relative;
        margin-top: 56px;
        text-align: left;
        p {
          margin-top: 20px;
          height:12px;
          font-size:12px;
          font-weight:400;
          color:rgba(102,102,102,1);
          line-height:12px;
        }
      }
    }
  }
  .person {
    position: relative;
    margin-top: 20px;
    width: 100%;
    .tabs-person {
      margin: 0 auto;
      width: 95%;
      .el-tabs__header {
        margin-bottom: 0px;
      }
      .el-tabs__nav-scroll {
        margin-left: 0px;
      }
    }
    .person-title {
      position: relative;
      margin: 30px 0 25px 30px;
      height: 25px;
      font-size:18px;
      font-weight:600;
      line-height: 25px;
      color: #000000;
    }
    .person-radio {
      margin-top: 10px;
      .el-radio-button {
        .el-radio-button__inner {
          border:0 solid #666666 !important;
          box-shadow: 0;
        }
      }
      .is-active {
        border-radius: 10px 10px 0px 0px;
        border-bottom: 2px solid #666666 !important;
        .el-radio-button__inner{
          border-radius:10px 10px 0px 0px;
          background:#DFDFDF !important;
          border:0 solid #666666 !important;
          box-shadow: 0;
        }
      }
    }
    .person-table {
      padding: 0;
      width: 95%;
      margin:0 auto 20px auto;
    }
    .pagination {
      margin-top: 30px;
      margin-right: 13px;
    }
  }
}
</style>
